Newer
Older
Import / projects / LGN-IP3870 / qtpyui / device-files / ui.py
# -*- encoding: euc-kr -*-

import uiconfig, config
import ntptime
import widget
import runtime, status
from setting import setting
import utils,os
from vdciapp import g_set_screen_clip
import model
from roxiadebug import *
import profile
from baseui import BaseUI, BaloonUI, SmallWindowUI, \
	NotifyCall2UI, NotifyConfCallUI, \
	LargeWindowUI, NotifyCallUI, NotifyUI, BaloonMessageUI, title_image_layer, EntryUI, CheckPasswordUI,ChangePasswordUI,PopupWindowUI
from baseui import RichTextUI
from alarmdb import alarmdb

class AutoProvisionRegisterUI(BaloonMessageUI):
	def __init__(self):
		icon = uiconfig.video_call_connect_icon
		message = _('Registering.')+'\n'+_('Please wait for a moment.')
		BaloonMessageUI.__init__(self, '', '', '', icon, message)

class VideoCallRegisteringUI(BaloonMessageUI):
	show_bg = True
	def __init__(self, show_bg = True, reg=True, msg=_('Registering.')+'\n'+_('Please wait for a moment.')):
		self.show_bg = show_bg
		icon = uiconfig.video_call_connect_icon
		message = msg
		if reg:
			#BaloonMessageUI.__init__(self, '', _('END'), '', icon, message)
			BaloonMessageUI.__init__(self, '', '', '', icon, message, menu4=_('CANCEL'))
		else:
			BaloonMessageUI.__init__(self, '', '', '', icon, message)

class InUseByDectUI(BaloonMessageUI):
	show_bg = True
	def __init__(self, show_bg = True, reg=False, msg=_('Dect in use.')):
		self.show_bg = show_bg
		icon = uiconfig.video_call_connect_icon
		message = msg
		if reg:
			BaloonMessageUI.__init__(self, '', '', '', icon, message, '', _('END'))
		else:
			BaloonMessageUI.__init__(self, '', '', '', icon, message, '', '')

class dectSubscribingUI(BaloonMessageUI):
	show_bg = True
	def __init__(self, show_bg = True, reg=True, msg=_('Subscribing handy.')+'\n'+_('Please wait for a moment.')):
		self.show_bg = show_bg
		icon = uiconfig.video_call_connect_icon
		message = msg
		if reg:
			BaloonMessageUI.__init__(self, '', '', '', icon, message, '', _('END'))
		else:
			BaloonMessageUI.__init__(self, '', '', '', icon, message, '', '')

class dectDesubscribingUI(BaloonMessageUI):
	show_bg = True
	def __init__(self, show_bg = True, reg=True, msg=_('De-Subscribing handy.')+'\n'+_('Please wait for a moment.')):
		self.show_bg = show_bg
		icon = uiconfig.video_call_connect_icon
		message = msg
		if reg:
			BaloonMessageUI.__init__(self, '', '', '', icon, message, '', _('END'))
		else:
			BaloonMessageUI.__init__(self, '', '', '', icon, message, '', '')

class dectPagingUI(BaloonMessageUI):
	show_bg = True
	def __init__(self, show_bg = True, reg=True, msg=''):
		self.show_bg = show_bg
		icon = uiconfig.video_call_connect_icon
		message = _('Paging handy.') #+'\n'+_('Please wait for a moment.')
		if reg:
			BaloonMessageUI.__init__(self, '', '', '', icon, message, '', _('CANCEL'))
		else:
			BaloonMessageUI.__init__(self, '', '', '', icon, message, '', '')

	def changeMessage(self, message):
		self.message = message

class WaitingResultUI(BaloonMessageUI):
	show_bg = True
	def __init__(self, show_bg = True, reg=True, msg=''):
		self.show_bg = show_bg
		icon = uiconfig.video_call_connect_icon
		self.message = _('Please wait for a moment.')
		if reg:
			BaloonMessageUI.__init__(self, '', _('END'), '', icon, self.message)
		else:
			BaloonMessageUI.__init__(self, '', '', '', icon, self.message)

	def changeMessage(self, message):
		self.message = message

class dectPathTestUI(BaloonUI):
	show_bg = True
	def __init__(self):
		BaloonUI.__init__(self, '', '', '', icon='')

		icon, pos = uiconfig.video_call_connect_icon
		self.dectPathTest = utils.put_image(icon, pos)
		self.add(self.dectPathTest)
		
		message = _('1. registering.')
		self.message = runtime.evas.text(text=message,
			font=uiconfig.dect_path_test_font,
			pos=uiconfig.dect_path_test_pos,
			color=uiconfig.dect_path_test_color)
		self.add(self.message)

	def changeMessage(self, message):
		if self.message:
			self.message.hide()
			self.remove(self.message)
			self.message = None

		self.message = runtime.evas.text(text=message,
			font=uiconfig.dect_path_test_font,
			pos=uiconfig.dect_path_test_pos,
			color=uiconfig.dect_path_test_color)
		self.add(self.message)
		self.message.show()

class VideoCallDeRegisteringUI(BaloonMessageUI):
	show_bg = True
	def __init__(self, show_bg = True):
		self.show_bg = show_bg
		icon = uiconfig.video_call_connect_icon
		message = _('De-registering.')+'\n'+_('Please wait for a moment.')
		BaloonMessageUI.__init__(self, '', _('END'), '', icon, message)

class VideoCallRequestUI(BaloonMessageUI):
	show_bg = True
	def __init__(self):
		icon = uiconfig.video_call_connect_icon
		message = _('Your video call request has been sent.')
# hcryoo : [20070509_2]
# hcryoo : [20070419_1]
		BaloonMessageUI.__init__(self, '', '', '', icon, message)
# hcryoo : [20070419_1]==
# hcryoo : [20070509_2]==

class VideoCallRequestedUI(BaloonMessageUI):
	def __init__(self):
		icon = uiconfig.video_call_connect_icon
		self.cursor = None

		message = _('The caller invites you to start a video call.')+' '+_('To accept it, please press Video key!')
		# hcryoo : [20070419_1]
		BaloonMessageUI.__init__(self, '', _('REJECT'), '', icon, message)
		# hcryoo : [20070419_1]==

class VideoCallConnectingUI(BaloonMessageUI):
	show_bg = True
	def __init__(self, caller, video_recv=False):
		icon = uiconfig.video_call_connect_icon

		if video_recv:
# eicho 06.08.14 by warning 123.2
			#message = _('Video call receiving')
			message = '\n' + _('Receiving videocall. Please wait.')
		else:
			message = '\n'+_('Please wait for a moment.')+'\n'+_('The video call is being established.')
			if status.dial_number:
				message = message + ' '+ _('This waiting time has no cost.')

		BaloonMessageUI.__init__(self, '', _('END'), '', icon, message)

		self.progress = widget.ProgressType2(uiconfig.video_call_progress_type2_pos, \
					uiconfig.video_call_progress_type2_size, \
					uiconfig.video_call_progress_out_icon2, \
					uiconfig.video_call_progress_in_icon2)
		self.add(self.progress)
	def set_max_duration(self, max):
		self.progress.set_max_value(max)
	def set_value(self, value):
		self.progress.set_value(value)


class VideoIncomingCallConnectedUI(BaseUI):
	def __init__(self):
		from baseui import videocall_bg_layer, videocall_detail_layer
	
		BaseUI.__init__(self, '', '', '')
		self.pressedNumber = []

		self.animationTimer = None
		self.outgoingCallAnimation = []
		self.numberOfFrame = len(uiconfig.outgoing_call_ani)
		
		for imageFrame in uiconfig.outgoing_call_ani:
			animationframe = utils.put_image(imageFrame, uiconfig.outgoing_call_ani_pos)
			animationframe.hide()
			self.outgoingCallAnimation.append(animationframe)
		self.animationIndex = -1

		icon, pos = uiconfig.call_info
		self.callInfo = utils.put_image(icon, pos)
		self.add(self.callInfo)

		icon, pos = uiconfig.call_info_bar
		self.callInfoBar = utils.put_image(icon, pos)
		self.add(self.callInfoBar)
		
		messagePrefix = _('Video call connecting...')
		self.messagePrefix = runtime.evas.text(text=messagePrefix,
			font=uiconfig.call_info_bar_font,
			pos=uiconfig.call_info_bar_text_pos,
			color=uiconfig.call_info_bar_text_color)
		self.add(self.messagePrefix)

		callerName = status.display_caller_name(status.active_call_index)
		callerNumber = status.display_caller_number(status.active_call_index)

		self.name = None
		self.number = None

		if callerName:			
			self.name = runtime.evas.text(text=callerName,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
		if callerNumber:
			self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
				font=uiconfig.call_info_number_font,
				pos=uiconfig.call_info_number_pos,
				color=uiconfig.call_info_number_color)
			self.add(self.number)

		self.hour = 0
		self.minute = 0
		self.second = 0
		callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second) 
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)

		icon, pos = uiconfig.video_call_info_icon
		self.videoCallInfoIcon = utils.put_image(icon, pos)
		self.add(self.videoCallInfoIcon)

		icon, pos = uiconfig.outgoing_icon
		self.outgoingIcon = utils.put_image(icon, pos)
		self.add(self.outgoingIcon)

		icon, pos = uiconfig.outgoing_text_icon
		self.outgoingTextIcon = utils.put_image(icon, pos)
		self.add(self.outgoingTextIcon)
		
		icon, pos = uiconfig.timer_icon
		self.timerIcon = utils.put_image(icon, pos)
		self.add(self.timerIcon)

		icon, pos = uiconfig.timer_text_icon
		self.timerTextIcon = utils.put_image(icon, pos)
		self.add(self.timerTextIcon)

		icon, pos = uiconfig.frame_image
		self.frameImage = utils.put_image(icon, pos)
		self.add(self.frameImage)
			
		self.callSoftbarImage = None

		self.connect_start_time = int(ntptime.ntime())

	def stopCallDuration(self):
		status.currentCallDuration = (self.hour, self.minute, self.second)

	def stopCallAnimation(self):
		self.animationTimer =None
		'''
		#self.outgoingCallAnimation[self.animationIndex].hide()

		icon, pos = uiconfig.videocall_background_icon
		self.videocallBackground = utils.put_image(icon, pos)
		#self.videocallBackground.layer = videocall_detail_layer+1
		#self.add(self.videocallBackground)
		self.videocallBackground.show()
		
		icon, pos = uiconfig.videocall_info_mark_icon
		self.videocallInfoMark = utils.put_image(icon, pos)
		#self.videocallInfoMark.layer = videocall_detail_layer+1
		#self.add(self.videocallInfoMark)
		self.videocallInfoMark.show()
		'''
		
	def show(self):
		BaseUI.show(self)

		if not self.animationTimer:
			self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()
		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)
		
		if runtime.vdciapp:
			runtime.vdciapp.set_screen_clip()
	
	def showSoftbar(self):
		icon, pos = uiconfig.call_softbar_image
		self.callSoftbarImage = utils.put_image(icon, pos)
		self.callSoftbarImage.show()

	def animationTimer_callback(self):
		if not self.animationTimer:
			return False
			
		if self.animationIndex == -1:
			self.animationIndex += 1
		else:
			self.outgoingCallAnimation[self.animationIndex].hide()
			self.animationIndex += 1
			if self.animationIndex > self.numberOfFrame-1:
				self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		'''
		if self.animationTimer:
			self.animationTimer = None
		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		'''
		return True
	
	def callDurationTimer_callback(self):
		if not self.callDurationTimer:
			return

		if self.time:
			self.time.hide()
			self.remove(self.time)
			self.time = None

		self.second = self.second + 1
		if self.second >= 60:
			self.minute = self.minute + 1
			self.second = 0
		if self.minute >= 60:
			self.hour = self.hour + 1
			self.minute = 0
		callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second)
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)
		self.time.show()

		'''
		runtime.evas.timeout_remove(self.callDurationTimer)
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)
		'''
		return True

	'''
	def changeMessagePrefix(self):
		if self.messagePrefix:
			self.messagePrefix.hide()
			self.remove(self.messagePrefix)
			self.messagePrefix = None

		messagePrefix = _('Audio call connected')
		self.messagePrefix = runtime.evas.text(text=messagePrefix,
			font=uiconfig.call_info_bar_font,
			pos=uiconfig.call_info_bar_text_pos,
			color=uiconfig.call_info_bar_text_color)
		self.add(self.messagePrefix)
		self.messagePrefix.show()
	'''
	
	def hide(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex

		for animationframe in self.outgoingCallAnimation:
			animationframe.hide()

		if self.callSoftbarImage:
			self.callSoftbarImage.hide()

		if runtime.vdciapp:
			runtime.vdciapp.set_screen_clip(True)

		BaseUI.hide(self)
		
	def destroy(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex
		g_set_screen_clip(True)

		for animationframe in self.outgoingCallAnimation:
			animationframe.free()

		if self.callSoftbarImage:
			self.callSoftbarImage.free()

		BaseUI.destroy(self)

	# hcryoo : [20071120_4] : 부가 서비스 사용 중 눌러진 DTMF의 화면 표시
	def write_number(self, number):
		for widget in self.pressedNumber:
			widget.hide()

		self.pressedNumber = []
		from baseui import videocall_detail_layer

		self.video_call_number_image = utils.put_image(uiconfig.video_call_number_bg_img, uiconfig.video_call_number_bg_pos)
		self.video_call_number_image.layer = videocall_detail_layer+1
		self.pressedNumber.append(self.video_call_number_image)
		
		#self.number_bg = runtime.evas.rectangle(pos=uiconfig.video_call_number_bg_pos, size=uiconfig.video_call_number_size)
		#self.number_bg.color = uiconfig.video_call_bg_color
		#self.number_bg.layer = videocall_detail_layer
		#self.pressedNumber.append(self.number_bg)

		self.number_text = runtime.evas.text(text=number, font=uiconfig.video_call_number_font, pos=uiconfig.video_call_number_pos, color=uiconfig.video_call_number_font_color)
		self.number_text.layer = videocall_detail_layer+2
		self.pressedNumber.append(self.number_text)

		for widget in self.pressedNumber:
			widget.show()

	def disable_write_number(self):
		for widget in self.pressedNumber:
			widget.hide()
	# hcryoo : [20071120_4] : 부가 서비스 사용 중 눌러진 DTMF의 화면 표시==


class VideoCallConnectedUI(BaseUI):
	show_bg = False
	VIDEO_LAYER = 1
	
	def __init__(self):
		from baseui import videocall_bg_layer, videocall_detail_layer
	
		BaseUI.__init__(self, '', '', '')
		self.pressedNumber = []

		self.animationTimer = None
		self.outgoingCallAnimation = []
		self.numberOfFrame = len(uiconfig.outgoing_call_ani)

		self.firstIsBusy = False
		
		for imageFrame in uiconfig.outgoing_call_ani:
			animationframe = utils.put_image(imageFrame, uiconfig.outgoing_call_ani_pos)
			animationframe.hide()
			self.outgoingCallAnimation.append(animationframe)
		self.animationIndex = -1

		icon, pos = uiconfig.call_info
		self.callInfo = utils.put_image(icon, pos)
		self.add(self.callInfo)

		icon, pos = uiconfig.call_info_bar
		self.callInfoBar = utils.put_image(icon, pos)
		self.add(self.callInfoBar)
		
		from mmiSoundPath import SP_Context
		self.callStatus = runtime.SP_context.getBaseCallStatus()
		
		if self.callStatus == SP_Context.INCOMING_VIDEO or self.callStatus == SP_Context.CONNECTED:
			messagePrefix = _('Video call connected')
		else:		
			messagePrefix = _('Video call connecting...')
		self.messagePrefix = runtime.evas.text(text=messagePrefix,
			font=uiconfig.call_info_bar_font,
			pos=uiconfig.call_info_bar_text_pos,
			color=uiconfig.call_info_bar_text_color)
		self.add(self.messagePrefix)

		self.name = None
		self.number = None

		callerName = status.display_caller_name(status.active_call_index)
		callerNumber = status.display_caller_number(status.active_call_index)
		if callerName.find('anonymous') != -1:
			self.name = runtime.evas.text(text=_('Anonymous'),
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
		elif callerName == '' or callerName == callerNumber:
			callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
		else:		
			if len(unicode(callerName, 'utf-8')) > 8:
				callerName = unicode(callerName, 'utf-8')[:7].encode('utf-8') + '...'
			self.name = runtime.evas.text(text=callerName,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)

			callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]

		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)

		if status.currentCallDuration == (0, 0, 0):
			self.hour = 0
			self.minute = 0
			self.second = 0
			callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second) 
		else:
			self.hour, self.minute, self.second = status.currentCallDuration
			callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second) 
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)

		icon, pos = uiconfig.video_call_info_icon
		self.videoCallInfoIcon = utils.put_image(icon, pos)
		self.add(self.videoCallInfoIcon)

		self.incomingIcon = None
		self.incomingTextIcon = None
		self.outgoingIcon = None
		self.outgoingTextIcon = None
				
		if not status.dial_number:
			icon, pos = uiconfig.incoming_icon
			self.incomingIcon = utils.put_image(icon, pos)
			self.add(self.incomingIcon)

			icon, pos = uiconfig.incoming_text_icon
			self.incomingTextIcon = utils.put_image(icon, pos)
			self.add(self.incomingTextIcon)
		else:
			icon, pos = uiconfig.outgoing_icon
			self.outgoingIcon = utils.put_image(icon, pos)
			self.add(self.outgoingIcon)

			icon, pos = uiconfig.outgoing_text_icon
			self.outgoingTextIcon = utils.put_image(icon, pos)
			self.add(self.outgoingTextIcon)
		
		icon, pos = uiconfig.timer_icon
		self.timerIcon = utils.put_image(icon, pos)
		self.add(self.timerIcon)
		
		icon, pos = uiconfig.timer_text_icon
		self.timerTextIcon = utils.put_image(icon, pos)
		self.add(self.timerTextIcon)

		icon, pos = uiconfig.frame_image
		self.frameImage = utils.put_image(icon, pos)
		self.add(self.frameImage)

		#self.callSoftbarImage = None
		icon, pos = uiconfig.call_softbar_image
		self.callSoftbarImage = utils.put_image(icon, pos)
		self.add(self.callSoftbarImage)

		self.connect_start_time = int(ntptime.ntime())

		self.largeView = runtime.evas.rectangle()
		self.largeView.geometry = uiconfig.large_view_geometry
		self.largeView.layer = self.VIDEO_LAYER
		self.largeView.color = uiconfig.transparent_color

		self.largeViewForMenu = runtime.evas.rectangle()
		self.largeViewForMenu.geometry = uiconfig.large_view_for_menu_geometry
		self.largeViewForMenu.layer = self.VIDEO_LAYER
		self.largeViewForMenu.color = uiconfig.transparent_color

		self.smallView = None
		self.avata = None

		if status.pushVideoAd:
			#영상광고인 경우네는 Local화면 대신 avata화면을 보여준다. 
			from phonedb import phonedb
			if callerNumber:
				avata = phonedb.get_snapshot2(callerNumber)
			else:
				avata = None
			self.set_avata(avata)

			self.smallView = None
			
		else:
			self.smallView = runtime.evas.rectangle()
			self.smallView.geometry = uiconfig.small_view_geometry
			self.smallView.layer = self.VIDEO_LAYER
			self.smallView.color = uiconfig.transparent_color		

			self.avata = None

		# soundpath info icon
		devices = runtime.SP_context.getCurrentDevice()
		for device in devices:			
			from mmiSoundPath import SP_State
			if device == SP_State.DEVICE_HS:
				icon, pos = uiconfig.soundpath_handset
			elif device == SP_State.DEVICE_SPK:
				icon, pos = uiconfig.soundpath_speaker
		self.soundPath = utils.put_image(icon, pos)
		self.add(self.soundPath)
		
		icon, pos = uiconfig.soundpath_mute
		self.micMute= utils.put_image(icon, pos)
		self.add(self.micMute)		

		self.isInService = False
		
		self.secondCallInfoBar = None
		self.secondVideoCallInfoIcon = None
		self.secondCallMessagePrefix = None
		self.secondCallMessageName = None
		self.secondCallMessageNumber = None
		self.callInfoService = None

		self.inUseIcon = None
		
		self.firstCallNameInThreeWay = None
		self.firstCallNumberInThreeWay = None
		self.secondCallNameInThreeWay = None
		self.secondCallNumberInThreeWay = None
		self.threeWayTextIcon = None

		self.volume_img=[]
		self.volume_img_bg = None

		self.transferInfoBar = None
		self.transferInfoIcon = None
		self.transferMessagePrefix = None

		self.notify_box = None
		self.notify_icon = None
		self.notify_msg = None
		self.notify_timer = None
		
		runtime.evas.use_transparency(True)
		self.micMuteFlag = False		
		self.second_avata = None

		self.write_number_tag = None
		self.hideAD = False

	# 영상 광고인 경우데는 avata를 보여준다.
	def set_avata(self, avata):
		if not avata:
			self.avata = utils.put_image(uiconfig.no_photo, uiconfig.avata_pos)
		else:
			self.avata = utils.put_image(avata, uiconfig.avata_pos)
		x, y = uiconfig.avata_pos
		w, h = uiconfig.avata_size
		utils.image_center_sized(self.avata, x + w/2, y + h/2, w, h)
		self.add(self.avata)

	def hideCallInfo(self):
		# 3 way
		if self.callInfoService: self.callInfoService.hide()
		if self.threeWayTextIcon: self.threeWayTextIcon.hide()
		if self.firstCallNumberInThreeWay: self.firstCallNumberInThreeWay.hide()
		if self.firstCallNameInThreeWay: self.firstCallNameInThreeWay.hide()
		if self.secondCallNameInThreeWay: self.secondCallNameInThreeWay.hide()
		if self.secondCallNumberInThreeWay: self.secondCallNumberInThreeWay.hide()
		if self.inUseIcon: self.inUseIcon.hide()

		# normal
		if self.callInfo: self.callInfo.hide()
		if self.incomingIcon: self.incomingIcon.hide()
		if self.incomingTextIcon: self.incomingTextIcon.hide()
		if self.outgoingIcon: self.outgoingIcon.hide()
		if self.outgoingTextIcon: self.outgoingTextIcon.hide()
		if self.name: self.name.hide()
		if self.number: self.number.hide()
		if self.timerIcon: self.timerIcon.hide()
		if self.timerTextIcon: self.timerTextIcon.hide()
		if self.callSoftbarImage: self.callSoftbarImage.hide()

	def showInfoMessage(self):
		self.videoCallInfoIcon.show()
		self.callInfoBar.show()
		self.messagePrefix.show()
		
	def showThreeWayConference(self, firstCallNumber, secondCallNumber):
		runtime.mmiDebug.mmiTrace('VideoCallConnectedUI::showThreeWayConference')

		self.isInService = True
		
		self.hideCallInfo()

		icon, pos = uiconfig.call_info_service
		self.callInfoService = utils.put_image(icon, pos)
		self.callInfoService.show()

		icon, pos = uiconfig.three_way_text_icon
		self.threeWayTextIcon = utils.put_image(icon, pos)
		self.threeWayTextIcon.show()
		
		from phonedb import phonedb
		firstCallName = phonedb.get_name(firstCallNumber)

		if firstCallName == firstCallNumber and firstCallName.find('anonymous') != -1:
			firstCallName = 'anonymous'
			firstCallNumber = ''
				
		if firstCallName == firstCallNumber:			
			firstCallNumberInThreeWay = firstCallNumber
			self.firstCallNumberInThreeWay = runtime.evas.text(text=firstCallNumberInThreeWay,
				font=uiconfig.secondCall_info_bar_font,
				pos=uiconfig.threeWayCall_info_firstNumber_pos,
				color=uiconfig.secondCall_info_bar_text_color)
			self.firstCallNumberInThreeWay.show()
		else:
			if firstCallName.find('anonymous') != -1:
				firstCallName = _('Anonymous')

				firstCallNameInThreeWay = firstCallName
				self.firstCallNameInThreeWay = runtime.evas.text(text=firstCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font_for_anonymous,
					pos=uiconfig.threeWayCall_info_firstName_pos_for_anonymous2,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNameInThreeWay.show()
			else:
				firstCallNameInThreeWay = firstCallName
				if len(unicode(firstCallNameInThreeWay, 'utf-8')) > 6:
					firstCallNameInThreeWay = unicode(firstCallNameInThreeWay, 'utf-8')[:5].encode('utf-8') + '...'
				self.firstCallNameInThreeWay = runtime.evas.text(text=firstCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_firstName_pos2,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNameInThreeWay.show()

				firstCallNumberInThreeWay = firstCallNumber
				self.firstCallNumberInThreeWay = runtime.evas.text(text=firstCallNumberInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_firstNumber_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNumberInThreeWay.show()

		from phonedb import phonedb
		secondCallName = phonedb.get_name(secondCallNumber)

		if secondCallName == secondCallNumber and secondCallName.find('anonymous') != -1:
			secondCallName = 'anonymous'
			secondCallNumber = ''		
		
		if secondCallName == secondCallNumber:			
			secondCallNumberInThreeWay = secondCallNumber
			self.secondCallNumberInThreeWay = runtime.evas.text(text=secondCallNumberInThreeWay,
				font=uiconfig.secondCall_info_bar_font,
				pos=uiconfig.threeWayCall_info_secondNumber_pos,
				color=uiconfig.secondCall_info_bar_text_color)
			self.secondCallNumberInThreeWay.show()
		else:
			if secondCallName.find('anonymous') != -1:
				secondCallName = _('Anonymous')

				secondCallNameInThreeWay = secondCallName
				self.secondCallNameInThreeWay = runtime.evas.text(text=secondCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font_for_anonymous,
					pos=uiconfig.threeWayCall_info_secondName_pos_for_anonymous2,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNameInThreeWay.show()
			else:
				secondCallNameInThreeWay = secondCallName
				if len(unicode(secondCallNameInThreeWay, 'utf-8')) > 6:
					secondCallNameInThreeWay = unicode(secondCallNameInThreeWay, 'utf-8')[:5].encode('utf-8') + '...'
				self.secondCallNameInThreeWay = runtime.evas.text(text=secondCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_secondName_pos2,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNameInThreeWay.show()

				secondCallNumberInThreeWay = secondCallNumber
				self.secondCallNumberInThreeWay = runtime.evas.text(text=secondCallNumberInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_secondNumber_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNumberInThreeWay.show()

		if self.smallView:
			self.showSmallView()
		else:
			self.smallView = runtime.evas.rectangle()
			self.smallView.geometry = uiconfig.small_view_geometry
			self.smallView.layer = self.VIDEO_LAYER
			self.smallView.color = uiconfig.transparent_color					

	def showCallWaiting(self, firstCallNumber, secondCallNumber, firstIsBusy=None):
		runtime.mmiDebug.mmiTrace('VideoCallConnectedUI::showCallWaiting')

		if firstIsBusy != None:
			self.firstIsBusy = firstIsBusy
		self.isInService = True
		
		self.hideCallInfo() #임시로 해줌. 정상적인 CS 메시지가 오면 처리됨.
		self.hideInfoMessage()		
		self.removeSecondCallNumber()

		icon, pos = uiconfig.call_info_service
		self.callInfoService = utils.put_image(icon, pos)
		self.callInfoService.show()

		icon, pos = uiconfig.three_way_text_icon
		self.threeWayTextIcon = utils.put_image(icon, pos)
		self.threeWayTextIcon.show()
		
		from phonedb import phonedb
		firstCallName = phonedb.get_name(firstCallNumber)

		if firstCallName == firstCallNumber and firstCallName.find('anonymous') != -1:
			firstCallName = 'anonymous'
			firstCallNumber = ''				
		
		if firstCallName == firstCallNumber:			
			firstCallNumberInThreeWay = firstCallNumber
			self.firstCallNumberInThreeWay = runtime.evas.text(text=firstCallNumberInThreeWay,
				font=uiconfig.secondCall_info_bar_font,
				pos=uiconfig.threeWayCall_info_firstNumber_pos,
				color=uiconfig.secondCall_info_bar_text_color)
			self.firstCallNumberInThreeWay.show()
		else:
			if firstCallName.find('anonymous') != -1:
				firstCallName = _('Anonymous')

				firstCallNameInThreeWay = firstCallName
				self.firstCallNameInThreeWay = runtime.evas.text(text=firstCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font_for_anonymous,
					pos=uiconfig.threeWayCall_info_firstName_pos_for_anonymous,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNameInThreeWay.show()
			else:
				firstCallNameInThreeWay = firstCallName
				if len(unicode(firstCallNameInThreeWay, 'utf-8')) > 6:
					firstCallNameInThreeWay = unicode(firstCallNameInThreeWay, 'utf-8')[:5].encode('utf-8') + '...'
				if firstIsBusy:
					tempPosition = uiconfig.threeWayCall_info_firstName_pos
				else:
					tempPosition = uiconfig.threeWayCall_info_firstName_pos2
				self.firstCallNameInThreeWay = runtime.evas.text(text=firstCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=tempPosition,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNameInThreeWay.show()

				firstCallNumberInThreeWay = firstCallNumber
				self.firstCallNumberInThreeWay = runtime.evas.text(text=firstCallNumberInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_firstNumber_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNumberInThreeWay.show()

		from phonedb import phonedb
		secondCallName = phonedb.get_name(secondCallNumber)

		if secondCallName == secondCallNumber and secondCallName.find('anonymous') != -1:
			secondCallName = 'anonymous'
			secondCallNumber = ''		
		
		if secondCallName == secondCallNumber:			
			secondCallNumberInThreeWay = secondCallNumber
			self.secondCallNumberInThreeWay = runtime.evas.text(text=secondCallNumberInThreeWay,
				font=uiconfig.secondCall_info_bar_font,
				pos=uiconfig.threeWayCall_info_secondNumber_pos,
				color=uiconfig.secondCall_info_bar_text_color)
			self.secondCallNumberInThreeWay.show()
		else:
			if secondCallName.find('anonymous') != -1:
				secondCallName = _('Anonymous')

				secondCallNameInThreeWay = secondCallName
				self.secondCallNameInThreeWay = runtime.evas.text(text=secondCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font_for_anonymous,
					pos=uiconfig.threeWayCall_info_secondName_pos_for_anonymous2,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNameInThreeWay.show()
			else:
				secondCallNameInThreeWay = secondCallName
				if len(unicode(secondCallNameInThreeWay, 'utf-8')) > 6:
					secondCallNameInThreeWay = unicode(secondCallNameInThreeWay, 'utf-8')[:5].encode('utf-8') + '...'
				if firstIsBusy:
					tempPosition = uiconfig.threeWayCall_info_secondName_pos2
				else:
					tempPosition = uiconfig.threeWayCall_info_secondName_pos
				self.secondCallNameInThreeWay = runtime.evas.text(text=secondCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=tempPosition,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNameInThreeWay.show()

				secondCallNumberInThreeWay = secondCallNumber
				self.secondCallNumberInThreeWay = runtime.evas.text(text=secondCallNumberInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_secondNumber_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNumberInThreeWay.show()

		if self.firstIsBusy:
			icon, pos = uiconfig.in_use_icon_1
			self.inUseIcon = utils.put_image(icon, pos)
			self.inUseIcon.show()
		else:
			icon, pos = uiconfig.in_use_icon_2
			self.inUseIcon = utils.put_image(icon, pos)
			self.inUseIcon.show()

		if status.pushVideoAd:
			from phonedb import phonedb
			if firstCallNumber:
				avata = phonedb.get_snapshot2(firstCallNumber)
			else:
				avata = None
			self.set_avata(avata)
		else:
			self.showSmallView()
		
	def changeCallerInfo(self, callerNumber, changeMessage=False):
		if self.isInService: self.isInService = False
		self.hideCallInfo()
		
		if changeMessage:
			self.changeMessagePrefix()

		if self.callInfo: self.callInfo.show()
		if self.incomingIcon: self.incomingIcon.show()
		if self.incomingTextIcon: self.incomingTextIcon.show()
		if self.outgoingIcon: self.outgoingIcon.show()
		if self.outgoingTextIcon: self.outgoingTextIcon.show()
		if self.timerIcon: self.timerIcon.show()
		if self.timerTextIcon: self.timerTextIcon.show()

		if self.callInfoBar: self.callInfoBar.show()
		if self.videoCallInfoIcon: self.videoCallInfoIcon.show()

		if self.name:
			self.name.hide()
			self.remove(self.name)
			self.name = None

		if self.number:
			self.number.hide()
			self.remove(self.number)
			self.number = None
		
		from phonedb import phonedb
		callerName = phonedb.get_name(callerNumber)

		if callerName.find('anonymous') != -1:
			self.name = runtime.evas.text(text=_('Anonymous'),
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
			self.name.show()
		elif callerName == '' or callerName == callerNumber:
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
				self.number.show()
		else:		
			if len(unicode(callerName, 'utf-8')) > 8:
				callerName = unicode(callerName, 'utf-8')[:7].encode('utf-8') + '...'
			self.name = runtime.evas.text(text=callerName,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
			self.name.show()

			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
				self.number.show()

	def update_soundpath(self):
		devices = runtime.SP_context.getCurrentDevice()
		for device in devices:			
			from mmiSoundPath import SP_State
			if device == SP_State.DEVICE_HS:
				icon, pos = uiconfig.soundpath_handset
			elif device == SP_State.DEVICE_SPK:
				icon, pos = uiconfig.soundpath_speaker
			self.soundPath.file = uiconfig.image_dir + icon
				
	def update_mic(self):
		if self.micMuteFlag:
			self.micMute.show()
		else:
			self.micMute.hide()	

	def showB2H_TransferMessage(self):
		icon, pos = uiconfig.second_call_message_info_bar
		self.transferInfoBar = utils.put_image(icon, pos)
		self.transferInfoBar.layer = 2
		self.transferInfoBar.show()

		icon, pos = uiconfig.second_audio_call_message_info_icon
		self.transferInfoIcon = utils.put_image(icon, pos)
		self.transferInfoIcon.layer = 2
		self.transferInfoIcon.show()

		transferMessagePrefix = _('Call transferring...')
		self.transferMessagePrefix = runtime.evas.text(text=transferMessagePrefix,
			font=uiconfig.second_call_message_info_bar_font,
			pos=uiconfig.second_call_message_info_bar_text_pos,
			color=uiconfig.second_call_message_info_bar_text_color)
		self.transferMessagePrefix.layer = 2
		self.transferMessagePrefix.show()

		self.showB2H_TransferSoftkey()

	def hideB2H_TransferMessage(self):
		self.transferInfoBar.hide()
		self.transferInfoIcon.hide()
		self.transferMessagePrefix.hide()
		
	def showH2B_TransferMessage(self, handsetNumber):
		icon, pos = uiconfig.second_call_message_info_bar
		self.transferInfoBar = utils.put_image(icon, pos)
		self.transferInfoBar.layer = 2
		self.transferInfoBar.show()

		icon, pos = uiconfig.second_audio_call_message_info_icon
		self.transferInfoIcon = utils.put_image(icon, pos)
		self.transferInfoIcon.layer = 2
		self.transferInfoIcon.show()

		transferMessagePrefix = _('Request for call transfer') + _('[HS') + str(handsetNumber) + ']' 
		self.transferMessagePrefix = runtime.evas.text(text=transferMessagePrefix,
			font=uiconfig.second_call_message_info_bar_font,
			pos=uiconfig.second_call_message_info_bar_text_pos,
			color=uiconfig.second_call_message_info_bar_text_color)
		self.transferMessagePrefix.layer = 2
		self.transferMessagePrefix.show()

		self.showH2B_TransferSoftkey()

	def hideH2B_TransferMessage(self):
		self.transferInfoBar.hide()
		self.transferInfoIcon.hide()
		self.transferMessagePrefix.hide()
		
		self.hideH2B_TransferSoftkey()

	def hideInfoMessage(self):
		if self.secondCallInfoBar: self.secondCallInfoBar.hide()
		if self.secondVideoCallInfoIcon: self.secondVideoCallInfoIcon.hide()
		if self.secondCallMessagePrefix: self.secondCallMessagePrefix.hide()
		if self.secondCallMessageNumber: self.secondCallMessageNumber.hide()
		if self.secondCallMessageName: self.secondCallMessageName.hide()		

		if self.videoCallInfoIcon: self.videoCallInfoIcon.hide()
		if self.callInfoBar: self.callInfoBar.hide()
		if self.messagePrefix: self.messagePrefix.hide()

	def showSecondCallNumber(self, secondCallNumber):
		self.hideInfoMessage()
		self.removeSecondCallNumber()
		
		# KA: test
		from phonedb import phonedb
		name = phonedb.get_name(secondCallNumber)

		if name == '':
			name = 'anonymous'
			
		hideName = False
		if name == secondCallNumber:
			hideName = True
			
		if self.secondCallInfoBar:
			self.secondCallInfoBar.show()
		else:
			icon, pos = uiconfig.second_call_info_bar
			self.secondCallInfoBar = utils.put_image(icon, pos)
			self.secondCallInfoBar.layer = 2
			self.secondCallInfoBar.show()

		if self.secondVideoCallInfoIcon:
			self.secondVideoCallInfoIcon.show()
		else:
			icon, pos = uiconfig.second_audio_call_info_icon
			self.secondVideoCallInfoIcon = utils.put_image(icon, pos)
			self.secondVideoCallInfoIcon.layer = 2
			self.secondVideoCallInfoIcon.show()

		if setting.in_restrict and (secondCallNumber  in setting.in_restrict_nums):		
			secondCallMessagePrefix = _('Prohibited number')
		else:
			secondCallMessagePrefix = _('Call receiving')	
		self.secondCallMessagePrefix = runtime.evas.text(text=secondCallMessagePrefix,
			font=uiconfig.secondCall_info_bar_font,
			pos=uiconfig.secondCall_info_bar_text_pos,
			color=uiconfig.secondCall_info_bar_text_color)
		self.secondCallMessagePrefix.layer = 2
		self.secondCallMessagePrefix.show()

		if hideName:
			secondCallMessageNumber = secondCallNumber
			if secondCallMessageNumber.find('anonymous') != -1:
				secondCallMessageNumber = _('Anonymous')
			
			self.secondCallMessageNumber = runtime.evas.text(text=secondCallMessageNumber,
				font=uiconfig.secondCall_info_bar_font,
				pos=uiconfig.secondCall_info_bar_number_pos,
				color=uiconfig.secondCall_info_bar_text_color)
			self.secondCallMessageNumber.layer = 2
			self.secondCallMessageNumber.show()
		else:
			if name.find('anonymous') != -1:
				name = _('Anonymous')

				secondCallMessageName = name
				if len(unicode(secondCallMessageName, 'utf-8')) > 8:
					secondCallMessageName = unicode(secondCallMessageName, 'utf-8')[:7].encode('utf-8') + '...'
				self.secondCallMessageName = runtime.evas.text(text=secondCallMessageName,
					font=uiconfig.secondCall_info_bar_anonymous_font,
					pos=uiconfig.secondCall_info_bar_name_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallMessageName.layer = 2
				self.secondCallMessageName.show()
			else:
				secondCallMessageName = name
				if len(unicode(secondCallMessageName, 'utf-8')) > 8:
					secondCallMessageName = unicode(secondCallMessageName, 'utf-8')[:7].encode('utf-8') + '...'
				self.secondCallMessageName = runtime.evas.text(text=secondCallMessageName,
					font=uiconfig.secondCall_info_bar_anonymous_font,
					pos=uiconfig.secondCall_info_bar_name_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallMessageName.layer = 2
				self.secondCallMessageName.show()

				secondCallMessageNumber = secondCallNumber
				self.secondCallMessageNumber = runtime.evas.text(text=secondCallMessageNumber,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.secondCall_info_bar_number_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallMessageNumber.layer = 2
				self.secondCallMessageNumber.show()

		# KA: test
		from phonedb import phonedb
		if secondCallNumber:
			avata = phonedb.get_snapshot2(secondCallNumber)
		else:
			avata = None
		self.set_second_avata(avata)
		
	def set_second_avata(self, avata):
		if not avata:
			self.second_avata = utils.put_image(uiconfig.no_photo, (59, 84))
		else:
			self.second_avata = utils.put_image(avata, (59, 84))
		x, y = (59, 84)
		w, h = (96, 74)
		utils.image_center_sized(self.second_avata, x + w/2, y + h/2, w, h)
		self.second_avata.layer = 2
		self.add(self.second_avata)

	def removeSecondCallNumber(self):
		if self.secondCallInfoBar: self.secondCallInfoBar.hide()
		if self.secondVideoCallInfoIcon: self.secondVideoCallInfoIcon.hide()
		if self.secondCallMessagePrefix: self.secondCallMessagePrefix.hide()
		if self.secondCallMessageName: self.secondCallMessageName.hide()
		if self.secondCallMessageNumber: self.secondCallMessageNumber.hide()
		if self.second_avata: self.second_avata.hide()		

		if self.secondCallMessagePrefix: self.secondCallMessagePrefix.free()
		if self.secondCallMessageName: self.secondCallMessageName.free()
		if self.secondCallMessageNumber: self.secondCallMessageNumber.free()
		if self.second_avata: self.second_avata.free()		

	def showLargeView(self):
		self.largeView.show()

	def showLargeViewForMenu(self):
		self.largeViewForMenu.show()

	def showSmallView(self):
		if self.smallView:
			self.smallView.show()
		else:
			self.smallView = runtime.evas.rectangle()
			self.smallView.geometry = uiconfig.small_view_geometry
			self.smallView.layer = self.VIDEO_LAYER
			self.smallView.color = uiconfig.transparent_color					
		
	def hideLargeView(self):
		self.largeView.hide()

	def hideLargeViewForMenu(self):
		self.largeViewForMenu.hide()

	def hideSmallView(self):
		self.smallView.hide()
		self.callInfo.show()

	def hideADView(self):
		self.hideAD = True
		self.hideLargeView()
		self.largeView.layer = -10
		self.hideLargeViewForMenu()
		self.largeViewForMenu.layer = -10
		self.messagePrefix.text_set(_('Audio call connected'))
		
	def showADView(self):
		self.hideAD = False
		self.showLargeView()
		self.largeView.layer = self.VIDEO_LAYER
		self.hideLargeViewForMenu()
		self.largeViewForMenu.layer = self.VIDEO_LAYER
		
	def stopCallDuration(self):
		status.currentCallDuration = (self.hour, self.minute, self.second)
		status.currentCallDuration_copy = status.currentCallDuration
		self.callDurationTimer = None

	def stopCallAnimation(self):
		self.animationTimer =None
		
	def show(self):
		BaseUI.show(self)
		runtime.evas.use_transparency(True)
		from mmiSoundPath import SP_Context
		if self.callStatus == SP_Context.INCOMING_VIDEO:
			self.showLargeView()
			if not status.pushVideoAd:
				self.showSmallView()
				#self.avata.show()			
		else:
			if not self.animationTimer:
				self.animationIndex = 0
			self.outgoingCallAnimation[self.animationIndex].show()
			self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)
		self.update_mic()
		#self.update_soundpath()
		
	def showSoftbar(self):
		if not self.callSoftbarImage:
			icon, pos = uiconfig.call_softbar_image
			self.callSoftbarImage = utils.put_image(icon, pos)
			self.callSoftbarImage.layer = 2 # 2
		self.callSoftbarImage.show()

	def changeSoftkeyFlag(self, micMuteFlag):
		self.micMuteFlag = micMuteFlag
		if self.micMuteFlag:
			runtime.lb.set_text_top(_('UNMUTE'))
		else:
			runtime.lb.set_text_top(_('MUTE'))
		self.update_mic()

	def showSoftkey(self):
		self.showSoftbar()
		if self.micMuteFlag:
			runtime.lb.set_text_top(_('UNMUTE'))
		else:
			runtime.lb.set_text_top(_('MUTE'))

		if status.pushVideoAd and self.hideAD == False:
			runtime.rb.set_text_top(_('Disable VideoAd'))
		elif status.pushVideoAd and self.hideAD == True:
			runtime.rb.set_text_top(_('VideoAd incoming'))
		else:
			runtime.rb.set_text_top(_('FLASH'))

		if status.pushVideoAd:
			runtime.menu3.set_text_top('')
		else:
			runtime.menu3.set_text_top(_('SWAP'))
		runtime.menu4.set_text_top(_('PBOOK'))
		
		runtime.lb.show()
		runtime.rb.show()
		runtime.menu3.show()
		runtime.menu4.show()		

	def hideSoftkey(self):
		if self.callSoftbarImage:
			self.callSoftbarImage.hide()
			self.callSoftbarImage.free()
			self.callSoftbarImage = None
	
		runtime.lb.hide()
		runtime.rb.hide()
		runtime.menu3.hide()
		runtime.menu4.hide()

	def showB2H_TransferSoftkey(self):
		self.showSoftbar()
		runtime.lb.set_text_top('')
		runtime.rb.set_text_top('')
		runtime.menu3.set_text_top('')
		runtime.menu4.set_text_top(_('CANCEL'))

		runtime.lb.show()
		runtime.rb.show()
		runtime.menu3.show()
		runtime.menu4.show()		

	def hideB2H_TransferSoftkey(self):
		self.hideSoftkey()

	def showH2B_TransferSoftkey(self):
		self.showSoftbar()
		'''
		self.set_left(_('ACCEPT'))
		self.set_right('')
		self.set_menu3('')
		self.set_menu4('')

		runtime.lb.layer = 20
		runtime.rb.layer = 20
		runtime.menu3.layer = 20
		runtime.menu4.layer = 20
		'''
		
		runtime.lb.set_text_top(_('ACCEPT'))
		runtime.rb.set_text_top('')
		runtime.menu3.set_text_top('')
		runtime.menu4.set_text_top('')

		runtime.lb.show()
		runtime.rb.show()
		runtime.menu3.show()
		runtime.menu4.show()		

	def hideH2B_TransferSoftkey(self):
		self.hideSoftkey()
		
	def animationTimer_callback(self):
		if not self.animationTimer:
			return
			
		if self.animationIndex == -1:
			self.animationIndex += 1
		else:
			self.outgoingCallAnimation[self.animationIndex].hide()
			self.animationIndex += 1
			if self.animationIndex > self.numberOfFrame-1:
				self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		'''
		if self.animationTimer:
			self.animationTimer = None
		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		'''
		return True

	def callDurationTimer_callback(self):
		if not self.callDurationTimer:
			return

		if self.time:
			self.time.hide()
			self.remove(self.time)
			self.time = None

		self.second = self.second + 1
		if self.second >= 60:
			self.minute = self.minute + 1
			self.second = 0
		if self.minute >= 60:
			self.hour = self.hour + 1
			self.minute = 0
		callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second)
		if self.isInService:
			self.time = runtime.evas.text(text=callDuration,
				font=uiconfig.service_call_info_time_font,
				pos=uiconfig.service_call_info_time_pos,
				color=uiconfig.service_call_info_time_color)
			self.add(self.time)
		else:		
			self.time = runtime.evas.text(text=callDuration,
				font=uiconfig.call_info_time_font,
				pos=uiconfig.call_info_time_pos,
				color=uiconfig.call_info_time_color)
			self.add(self.time)
		self.time.show()

		import time,ntptime
		callInfoMinute = time.localtime(ntptime.ntime())[5]
		if callInfoMinute != self.callInfoMinute:
			self.changeCallInfoDate()

		return True
		
	def changeCallInfoDate(self):
		if self.callInfoDate:
			self.callInfoDate.hide()
			self.remove(self.callInfoDate)
			self.callInfoDate = None

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)
		self.callInfoDate.show()

		return True

	def showAutoAnswering(self):
		if self.messagePrefix:
			self.messagePrefix.hide()
			self.remove(self.messagePrefix)
			self.messagePrefix = None

		self.callInfoBar.layer = 2
		self.callInfoBar.show()
		
		self.videoCallInfoIcon.layer = 2
		self.videoCallInfoIcon.show()

		messagePrefix = _('Auto answering...')
		self.messagePrefix = runtime.evas.text(text=messagePrefix,
			font=uiconfig.call_info_bar_font,
			pos=uiconfig.call_info_bar_text_pos,
			color=uiconfig.call_info_bar_text_color)
		self.messagePrefix.layer = 2
		self.add(self.messagePrefix)
		self.messagePrefix.show()
		
	def deleteAutoAnswering(self):
		if self.messagePrefix:
			self.messagePrefix.hide()
			self.remove(self.messagePrefix)
			self.messagePrefix = None

		self.callInfoBar.layer = -10
		self.videoCallInfoIcon.layer = -10
		self.callInfoBar.hide()
		self.videoCallInfoIcon.hide()

	def changeMessagePrefix(self, messagePrefix=None):
		runtime.mmiDebug.mmiTrace('VideoCallConnectedUI::changeMessagePrefix()')
		if self.messagePrefix:
			self.messagePrefix.hide()
			self.remove(self.messagePrefix)
			self.messagePrefix = None

		if not messagePrefix:
			messagePrefix = _('Video call disconnected')
			self.messagePrefix = runtime.evas.text(text=messagePrefix,
				font=uiconfig.call_info_bar_font,
				pos=uiconfig.call_info_bar_text_pos,
				color=uiconfig.call_info_bar_text_color)
		else:		
			self.messagePrefix = runtime.evas.text(text=messagePrefix,
				font=uiconfig.call_info_bar_font,
				pos=uiconfig.call_info_bar_text_pos,
				color=uiconfig.call_info_bar_text_color)
			self.messagePrefix.layer = 2
		self.add(self.messagePrefix)
		self.messagePrefix.show()

		def changeMessagePrefix_callback():
			if self.messagePrefix:
				self.messagePrefix.hide()
				self.remove(self.messagePrefix)
				self.messagePrefix = None

			self.messagePrefixTimer = None

		self.messagePrefixTimer = utils.Timer(3000, changeMessagePrefix_callback)
	
	def changeConnectedNumber(self):
		if self.name:
			self.name.hide()
			self.remove(self.name)
			self.name = None
		connectedName = status.display_caller_name(status.active_call_index)
		self.name = runtime.evas.text(text=connectedName,
			font=uiconfig.call_info_name_font,
			pos=uiconfig.call_info_name_pos,
			color=uiconfig.call_info_name_color)
		self.add(self.name)
		self.name.show()

		if self.number:
			self.number.hide()
			self.remove(self.number)
			self.number = None
		connectedNumber = status.display_caller_number(status.active_call_index)
		self.number = runtime.evas.text(text=connectedNumber,
			font=uiconfig.call_info_number_font,
			pos=uiconfig.call_info_number_pos,
			color=uiconfig.call_info_number_color)
		self.add(self.number)
		self.number.show()
	
	def hide(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex

		for animationframe in self.outgoingCallAnimation:
			animationframe.hide()

		if self.callSoftbarImage:
			self.callSoftbarImage.hide()

		if self.largeView: self.largeView.hide()
		if self.largeViewForMenu: self.largeViewForMenu.hide()
		if self.smallView: self.smallView.hide()
			
		if self.secondCallInfoBar: self.secondCallInfoBar.hide()
		if self.secondVideoCallInfoIcon: self.secondVideoCallInfoIcon.hide()
		if self.secondCallMessagePrefix: self.secondCallMessagePrefix.hide()
		if self.secondCallMessageNumber: self.secondCallMessageNumber.hide()
		if self.secondCallMessageName: self.secondCallMessageName.hide()		

		if self.callInfoService: self.callInfoService.hide()
		if self.firstCallNameInThreeWay: self.firstCallNameInThreeWay.hide()
		if self.firstCallNumberInThreeWay: self.firstCallNumberInThreeWay.hide()
		if self.secondCallNameInThreeWay: self.secondCallNameInThreeWay.hide()
		if self.secondCallNumberInThreeWay: self.secondCallNumberInThreeWay.hide()
		if self.threeWayTextIcon: self.threeWayTextIcon.hide()
		
		if self.inUseIcon: self.inUseIcon.hide()

		if self.transferInfoBar: self.transferInfoBar.hide()
		if self.transferInfoIcon: 	self.transferInfoIcon.hide()
		if self.transferMessagePrefix: self.transferMessagePrefix.hide()
			
		for widget in self.pressedNumber:
			widget.hide()

		runtime.evas.use_transparency(False)
		BaseUI.hide(self)
		
	def destroy(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex

		for animationframe in self.outgoingCallAnimation:
			animationframe.free()

		if self.callSoftbarImage:
			self.callSoftbarImage.free()
			
		if self.volume_img:
			self.volume_img=[]
			self.volume_img_bg.free()

		if self.largeView: self.largeView.free()
		if self.largeViewForMenu: self.largeViewForMenu.free()
		if self.smallView: self.smallView.free()

		if self.secondCallInfoBar: self.secondCallInfoBar.free()
		if self.secondVideoCallInfoIcon: self.secondVideoCallInfoIcon.free()
		if self.secondCallMessagePrefix: self.secondCallMessagePrefix.free()
		if self.secondCallMessageNumber: self.secondCallMessageNumber.free()
		if self.secondCallMessageName: self.secondCallMessageName.free()		

		if self.callInfoService: self.callInfoService.free()
		if self.firstCallNameInThreeWay: self.firstCallNameInThreeWay.free()
		if self.firstCallNumberInThreeWay: self.firstCallNumberInThreeWay.free()
		if self.secondCallNameInThreeWay: self.secondCallNameInThreeWay.free()
		if self.secondCallNumberInThreeWay: self.secondCallNumberInThreeWay.free()
		if self.threeWayTextIcon: self.threeWayTextIcon.free()
		if self.inUseIcon: self.inUseIcon.free()

		if self.transferInfoBar: self.transferInfoBar.free()
		if self.transferInfoIcon: 	self.transferInfoIcon.free()
		if self.transferMessagePrefix: self.transferMessagePrefix.free()

		for widget in self.pressedNumber:
			widget.free()
		if self.notify_timer:
			self.notify_msg_free()

		BaseUI.destroy(self)

	def write_number(self, number):
		for widget in self.pressedNumber:
			widget.hide()

		self.pressedNumber = []
		from baseui import videocall_detail_layer

		self.video_call_number_image = utils.put_image(uiconfig.video_call_number_bg_img, uiconfig.video_call_number_bg_pos)
		self.video_call_number_image.layer = 2
		self.pressedNumber.append(self.video_call_number_image)
		
		self.number_text = runtime.evas.text(text=number, font=uiconfig.video_call_number_font, pos=uiconfig.video_call_number_pos, color=uiconfig.video_call_number_font_color)
		self.number_text.layer = 2
		self.pressedNumber.append(self.number_text)

		for widget in self.pressedNumber:
			widget.show()

		# shchun : per KT requirement. hide second enblock after 10 sec
		self.restart_write_number_timer()
		
	def hide_write_number(self):
		# shchun : per KT requirement. hide second enblock after 10 sec
		debugLogN('hide_write_number')
		for widget in self.pressedNumber:
			widget.hide()
	
	def restart_write_number_timer(self):
		# shchun : per KT requirement. hide second enblock after 10 sec
		debugLogN('restart_write_number_timer')
		self.write_number_tag = utils.Timer(config.write_number_show_timeout, self.hide_write_number)


	def disable_write_number(self):
		for widget in self.pressedNumber:
			widget.hide()

	# KA: [20080514] call menu - volume
	def hideVolume(self):
		if self.volume_img:
			for i in range(len(self.volume_img)):
				#self.volume_img[i].free()
				del_img = self.volume_img.pop()
				del_img.free()
			self.volume_img_bg.free()
			#self.volume_img=[]
			#self.volume_img.hide()
			
	def volume_control(self, first_flag=False, increase=True):
		#현재 path의 volume값 
		devices = runtime.SP_context.getCurrentDevice()
		for device in devices:
			from mmiSoundPath import SP_State
			if device == SP_State.DEVICE_HS:
				level = setting.handset_volume
			elif device == SP_State.DEVICE_SPK:
				level = setting.speaker_volume

		if first_flag: #최초 그림 그려준다.
			self.fill_grade(level)
		elif not first_flag and increase:
			level += 1
			if level > 5:
				level = 5
			else:
				self.up_br_grade(level)			
		else:
			level -= 1
			if level < 1:
				level = 1
			else:
				self.down_br_grade()
			
		setting.set_master_volume(level, device)
		
			
	def fill_grade(self, level):
		name, pos = uiconfig.volume_grade_bg
		self.volume_img_bg = utils.put_image(name, pos)
		self.add(self.volume_img_bg)
		
		if level < 1:
			return False
		if level > 5:
			return True
		self.volume_img=[]
		i = 0
		while i < level:
			filler_img = self.draw_grade(i)
			self.volume_img.append(filler_img)
			i = i+1
		#self.add(self.volume_img)
		return True

	# grade에 해당하는 image를 1개 그린다.
	def draw_grade(self,grade):
		start_xpos = 376
		start_ypos = 252
		filler = uiconfig.volume_grade
		pos = (start_xpos+16*grade, start_ypos)
		img = utils.put_image(filler, pos)
		self.add(img)
		return img
		
	# grade 1개 내리기
	def down_br_grade(self):
		del_img = self.volume_img.pop()
		del_img.free()

	# grade 1개 올리기
	def up_br_grade(self, level):
		filler_img = self.draw_grade(level-1)
		self.volume_img.append(filler_img)
	# KA: [20080514] call menu - volume ==
	# KA: [20080515] call menu - volume
	def notify_msg_show(self, msg):
		icon, pos = uiconfig.call_notify_box
		self.notify_box = utils.put_image(icon, pos)
		self.notify_box.layer = 2
		self.notify_box.show()

		icon, pos = uiconfig.call_notify_camera_icon
		self.notify_icon = utils.put_image(icon, pos)
		self.notify_icon.layer = 2
		self.notify_icon.show()
		
		self.notify_msg = runtime.evas.text(text=msg,
			font=uiconfig.sms_notify_font,
			pos=uiconfig.call_notify_text_pos,
			color=uiconfig.color_dark_gray)
		self.notify_msg.layer = 2
		self.notify_msg.show()

		self.notify_timer = utils.Timer(3000, self.notify_msg_free)

	def notify_msg_free(self):
		self.notify_timer = None
		self.notify_box.free()
		self.notify_icon.free()
		self.notify_msg.free()

	def HM_msg_show(self, msg, hide=True):
		icon, pos = uiconfig.HM_notify_box
		self.notify_box = utils.put_image(icon, pos)
		self.notify_box.layer = 2
		self.notify_box.show()

		icon, pos = uiconfig.HM_icon
		self.notify_icon = utils.put_image(icon, pos)
		self.notify_icon.layer = 2
		self.notify_icon.show()
		
		self.notify_msg = runtime.evas.text(text=msg,
			font=uiconfig.sms_notify_font,
			pos=uiconfig.HM_notify_msg,
			color=uiconfig.color_dark_gray)
		self.notify_msg.layer = 2
		self.notify_msg.show()
	# KA: [20080515] call menu - volume ==
		

class VideoCallConnectedUI_old(BaseUI):
	show_bg = False
	def __init__(self):
		self.pressedNumber = []
		from baseui import videocall_bg_layer, videocall_detail_layer
		BaseUI.__init__(self, _('OPTIONS'), '', '')

		# Set background
		'''
		self.bg_grey = runtime.evas.rectangle(pos=uiconfig.video_call_bg_pos,\
				size=uiconfig.video_call_bg_size)
		self.bg_grey.color = uiconfig.video_call_bg_color
		self.bg_grey.layer = videocall_bg_layer
		self.add(self.bg_grey)
		'''
		# Set detail ui
		runtime.evas.set_clip(0, 0, 480, 272)
		self.set_detail_screen()

		self.mute_image = utils.put_image(uiconfig.video_call_mute_icon_img,
				uiconfig.video_call_mute_icon_pos_small)
		self.mute_image.layer = videocall_detail_layer+1
		self.add(self.mute_image)
		icon, pos = uiconfig.video_call_audio_mute_icon
		self.audio_mute_image=utils.put_image(icon, pos)
		self.audio_mute_image.layer = videocall_detail_layer+1
		self.add(self.audio_mute_image)
		icon, pos = uiconfig.video_call_hands_free_icon
		self.hands_free_image = utils.put_image(icon, pos)
		self.hands_free_image.layer = videocall_detail_layer+1
		self.add(self.hands_free_image)
		icon, pos = uiconfig.tde_logo_small_icon
		self.tde_logo = utils.put_image(icon, pos)

		self.tde_logo.layer = videocall_detail_layer+1

		self.add(self.tde_logo)
		icon, pos = uiconfig.supervision_remote_icon
		self.supervision_remote = utils.put_image(icon, pos)
		self.supervision_remote.layer = videocall_detail_layer+1
		self.add(self.supervision_remote)

		'''
		icon, pos = uiconfig.videocall_background_icon
		self.videocall_background = utils.put_image(icon, pos)
		self.videocall_background.layer = videocall_detail_layer+1
		self.add(self.videocall_background)
		'''
		
		# set mute ui
		self.mute_grey = runtime.evas.rectangle(pos=uiconfig.video_call_mute_grey_pos_full,\
				size=uiconfig.video_call_bg_size)
		self.mute_grey.color = uiconfig.video_call_bg_color
		self.mute_grey.layer = videocall_detail_layer
		self.add(self.mute_grey)

		self.connect_start_time = int(ntptime.ntime())

		self.show()
		runtime.evas.render_now()
		utils.log_time('Start video call process complete')

	def move_mute_image(self):
		if status.videocall_dimension in (config.DIMENSION_REMOTE_BIG_LOCAL_SMALL, config.DIMENSION_REMOTE_BIG_ONLY):
			self.mute_image.pos = uiconfig.video_call_mute_icon_pos_full
		else:
			self.mute_image.pos = uiconfig.video_call_mute_icon_pos_small

	def move_remote_mute_image(self):
		if status.videocall_dimension in (config.DIMENSION_REMOTE_BIG_LOCAL_SMALL, config.DIMENSION_REMOTE_BIG_ONLY):
			self.tde_logo.pos = uiconfig.video_call_remote_mute_icon_pos_full
		else:
			self.tde_logo.pos = uiconfig.video_call_remote_mute_icon_pos_small

	def set_detail_screen(self):
		self.details = []
		from baseui import videocall_detail_layer
		self.detail_bg = runtime.evas.rectangle(pos=uiconfig.video_call_detail_bg_pos, size=uiconfig.video_call_detail_bg_size)
		self.detail_bg.color = uiconfig.video_call_bg_color
		self.detail_bg.layer = videocall_detail_layer
		self.details.append(self.detail_bg)

		call_number = status.dial_number or status.caller_number
		if setting.phone_extension:
			if call_number.startswith(setting.phone_extension):
				call_number = call_number[len(setting.phone_extension):]
				if call_number[0] == 'P':
					call_number = call_number[1:]

		if call_number.startswith(config.FAC_HIDE_ID_CODE):
			call_number = call_number[3:]
		if not call_number:
			name = _('Unknown')
		else:
			name = call_number
			name = unicode(name, 'utf-8')
			cut_name, font = utils.resize_text(name, 105, uiconfig.video_call_detail_font)
			name = cut_name.encode('utf-8')
		if name == _('Private number'):
			name = _('Private num.')

		self.number_text = runtime.evas.text(text=_('Number: ') +\
				name, font=uiconfig.video_call_detail_font,\
				pos=uiconfig.video_call_detail_number_pos,\
				color=uiconfig.video_call_detail_color)
		self.number_text.layer = videocall_detail_layer+2
		self.details.append(self.number_text)
		self.volume_text = runtime.evas.text(text=_('Audio volume: '),\
				font=uiconfig.video_call_detail_font,\
				pos=uiconfig.video_call_detail_volume_pos,\
				color=uiconfig.video_call_detail_color)
		self.volume_text.layer = videocall_detail_layer+2
		self.details.append(self.volume_text)
		self.state_text = runtime.evas.text(text=_('State: Connected'),\
				font=uiconfig.video_call_detail_font,\
				pos=uiconfig.video_call_detail_state_pos,\
				color=uiconfig.video_call_detail_color)
		self.state_text.layer = videocall_detail_layer+2
		self.details.append(self.state_text)
		self.fluency_text = runtime.evas.text(text=_('Video Quality: '),\
				font=uiconfig.video_call_detail_font,\
				pos=uiconfig.video_call_detail_fluency_pos,\
				color=uiconfig.video_call_detail_color)
		self.fluency_text.layer = videocall_detail_layer+2
		self.details.append(self.fluency_text)
		self.speed_text = runtime.evas.text(text=_('Modem speed: '),\
				font=uiconfig.video_call_detail_font,\
				pos=uiconfig.video_call_detail_speed_pos,\
				color=uiconfig.video_call_detail_color)
		self.details.append(self.speed_text)
		# _('Frame rate: 00 fps')
		self.fps_text = runtime.evas.text(text=_('Frame rate: 0'),\
				font=uiconfig.video_call_detail_font,\
				pos=uiconfig.video_call_detail_fps_pos,\
				color=uiconfig.video_call_detail_color)
		self.fps_text.layer = videocall_detail_layer+2
		self.details.append(self.fps_text)

		for i in self.details:
			self.add(i)

	def set_details_info(self, volume, fluency, speed):
		self.volume_text.text = _('Audio volume: ') + str(volume)
		self.fluency_text.text = _('Video Quality: ') + str(fluency)
		if profile.ip_mode == 0:
			self.speed_text.text = _('Modem speed: ') + str(speed)
		else:
			self.speed_text.text = ' '

	def set_detail_fps_info(self, fps):
		if config.videocall_debug:
			print "FPS VALUE: ", fps
		if fps == '0':
			fps = '1'
		self.fps_text.text = _('Frame rate: ') + fps

	def show(self):
		BaseUI.show(self)

		if status.audio_mute == 0:
			self.set_right('')
			if config.key_debug:
				print 'Ignore End'
		else:
			self.set_right( _('ENABLE MIC') )
		self.draw_icons()

		if runtime.vdciapp:
			runtime.vdciapp.set_screen_clip()

	def hide(self):
		if runtime.vdciapp:
			runtime.vdciapp.set_screen_clip(True)
		BaseUI.hide(self)

	# hcryoo : [20071120_4] : 부가 서비스 사용 중 눌러진 DTMF의 화면 표시
	def write_number(self, number):
		for widget in self.pressedNumber:
			widget.hide()

		self.pressedNumber = []
		from baseui import videocall_detail_layer

		self.video_call_number_image = utils.put_image(uiconfig.video_call_number_bg_img, uiconfig.video_call_number_bg_pos)
		self.video_call_number_image.layer = videocall_detail_layer+1
		self.pressedNumber.append(self.video_call_number_image)
		
		#self.number_bg = runtime.evas.rectangle(pos=uiconfig.video_call_number_bg_pos, size=uiconfig.video_call_number_size)
		#self.number_bg.color = uiconfig.video_call_bg_color
		#self.number_bg.layer = videocall_detail_layer
		#self.pressedNumber.append(self.number_bg)

		self.number_text = runtime.evas.text(text=number, font=uiconfig.video_call_number_font, pos=uiconfig.video_call_number_pos, color=uiconfig.video_call_number_font_color)
		self.number_text.layer = videocall_detail_layer+2
		self.pressedNumber.append(self.number_text)

		for widget in self.pressedNumber:
			widget.show()

	def disable_write_number(self):
		for widget in self.pressedNumber:
			widget.hide()
	# hcryoo : [20071120_4] : 부가 서비스 사용 중 눌러진 DTMF의 화면 표시==
			
	def draw_icons(self):

		if status.videocall_remote_mute == status.VideoMuteOff:
			self.tde_logo.hide()
		if status.videocall_remote_mute == status.VideoMuteOn:
			#self.move_remote_mute_image()
			self.tde_logo.hide() # KA: [20070912] Temporary KT DEMO

		'''
		print 'XXXXXX SHOW BG in VIDEOCALL'
		self.videocall_background.show()
		'''
		
		if status.supervision_remote == 1:
			self.supervision_remote.show()
		else:
			self.supervision_remote.hide()
		if status.videocall_mute == status.VideoMuteOff:
			self.mute_image.hide()
			self.mute_grey.hide()
		elif status.videocall_mute == status.VideoMuteOn:
			self.move_mute_image()
			if status.videocall_dimension == config.DIMENSION_REMOTE_BIG_ONLY:
				self.mute_grey.hide()
			else:
				self.mute_grey.show()
			self.mute_image.show()
		if status.audio_mute == 0:
			self.audio_mute_image.hide()
		elif status.audio_mute == 1:
			self.hands_free_image.hide()
			self.audio_mute_image.show()
		if status.modem_audio_state == status.HS:
			self.hands_free_image.hide()
		else:
			if status.audio_mute == 1:
				self.hands_free_image.hide()
			else:
				# hcryoo : [20071108_1] : 비디오 영상에서 SPK 표시 삭제
				#self.hands_free_image.show()
				self.hands_free_image.hide()
				# hcryoo : [20071108_1] : 비디오 영상에서 SPK 표시 삭제==
		# show or hide details information
		# Show all detail information
		if status.videocall_show_details == status.VideoDetailsShow:
			for widget in self.details:
				widget.show()
		else:	# Hide all detail information
			for widget in self.details:
				widget.hide()
		# Show minimum detail information

	def destroy(self):
		g_set_screen_clip(True)
		self.tag_hide_minimum_info = None
		BaseUI.destroy(self)

class SnapshotUI(BaseUI):
	show_bg = False
	def __init__(self):
		BaseUI.__init__(self, _('CAPTURE'), _('BACK'), '')
		icon, pos = uiconfig.tde_logo_center_icon
		self.tde_logo = utils.put_image(icon, pos)
		self.add(self.tde_logo)
		self.tde_logo.hide()
	def show(self):
		BaseUI.show(self)
		if status.videocall_remote_mute == status.VideoMuteOff:
			self.tde_logo.hide()
		if status.videocall_remote_mute == status.VideoMuteOn:
			self.tde_logo.show()

	def destroy(self):
		BaseUI.destroy(self)


class NetworkDetailUI(LargeWindowUI):
	#def __init__(self, status, mac, mac2, dhcp, ip, mask, gateway, dns1, dns2):
	def __init__(self, status, mac, dhcp, ip, mask, gateway, dns1, dns2):
		LargeWindowUI.__init__(self, menu4=_('BACK'), small_title=_('DETAILS'))
		self.status = status
		self.mac = mac
		#self.mac2 = mac2
		self.dhcp = dhcp
		self.ip = ip
		self.mask = mask
		self.gateway = gateway
		self.dns1 = dns1
		self.dns2 = dns2
		self.flist = True
		self.show_list()

	def show_list(self):

		t = runtime.evas.text()
		t.font=uiconfig.details_font
		t.color=uiconfig.swver_details_color
		#t.text= _('Status: ') + self.status
		t.text= _('Connection status') + self.status		
		t.pos = uiconfig.networkdetail_text_pos[0]
		self.add(t)

		t = runtime.evas.text()
		t.font=uiconfig.details_font
		t.color=uiconfig.swver_details_color
		#t.text= _('DHCP: ') + self.dhcp
		if self.dhcp == _('Yes'):
			t.text= _('Network modes') + 'DHCP'
		else:
			t.text= _('Network modes') + 'Static'
		t.pos = uiconfig.networkdetail_text_pos[1]
		self.add(t)
	
		t = runtime.evas.text()
		t.font=uiconfig.details_font
		t.color=uiconfig.swver_details_color
		#t.text= _('Wired MAC: ') + self.mac
		
		if profile.profile.get_profile() == 1:
			t.text= _('Ethernet MAC address: ') + self.mac
		else:
			t.text= _('Wireless LAN MAC address: ') + self.mac
		t.pos = uiconfig.networkdetail_text_pos[2]
		self.add(t)

		#t = runtime.evas.text()
		#t.font=uiconfig.details_font
		#t.color=uiconfig.swver_details_color
		##t.text= _('Wireless MAC: ') + self.mac2
		#t.text= _('Wireless LAN MAC address: ') + self.mac2
		#t.pos = uiconfig.networkdetail_text_pos[3]
		#self.add(t)

		t = runtime.evas.text()
		t.font=uiconfig.details_font
		t.color=uiconfig.swver_details_color
		#t.text= _('IP address: ') + self.ip
		t.text= 'IP address: ' + self.ip
		t.pos = uiconfig.networkdetail_text_pos[3]
		self.add(t)

		t = runtime.evas.text()
		t.font=uiconfig.details_font
		t.color=uiconfig.swver_details_color
		#t.text= _('Subnet mask: ') + self.mask
		t.text= 'Subnet Mask: ' + self.mask
		t.pos = uiconfig.networkdetail_text_pos[4]
		self.add(t)

		t = runtime.evas.text()
		t.font=uiconfig.details_font
		t.color=uiconfig.swver_details_color
		#t.text= _('Gateway: ') + self.gateway
		t.text= 'Gateway: ' + self.gateway
		t.pos = uiconfig.networkdetail_text_pos[5]
		self.add(t)

		t = runtime.evas.text()
		t.font=uiconfig.details_font
		t.color=uiconfig.swver_details_color
		t.text= _('DNS1: ') + self.dns1
		t.pos = uiconfig.networkdetail_text_pos[6]
		self.add(t)

		t = runtime.evas.text()
		t.font=uiconfig.details_font
		t.color=uiconfig.swver_details_color
		t.text= _('DNS2: ') + self.dns2
		t.pos = uiconfig.networkdetail_text_pos[7]
		self.add(t)

	def set_list(self, booln):
		self.hide()
		LargeWindowUI.__init__(self, '', _('BACK'), _('DETAILS'), _('DETAILS'))
		self.flist = booln
		self.show_list()
		self.show()

class FirstHeldSecondIncomingUI(NotifyCall2UI):
	show_bg = True
	def __init__(self, active_line_name, incoming_name):
		icon1 = uiconfig.front_in_call_wait_icon
		icon2 = ''
		message1 = _('Call held') + ':'
		message2 = active_line_name
		message3 = _('Incoming call from') + ':'
		message4 = incoming_name
		NotifyCall2UI.__init__(self, _('ACCEPT'), _('REJECT') , '', message1, message2, message3, message4, icon1, icon2)

		runtime.evas.incoming_temp_ani = None
		self.incoming_ani = []
		self.index = 0

		for w in uiconfig.back_incoming_icon_ani:
			runtime.evas.incoming_temp_ani = utils.put_image(w, uiconfig.back_incoming_icon_ani_pos)
			self.incoming_ani.append(runtime.evas.incoming_temp_ani)
			self.incoming_ani[self.index].hide()
			self.index+= 1

		self.ani_count = -1

		icon, pos = uiconfig.front_speaker_icon
		self.hands_free_image = utils.put_image(icon, pos)
		icon, pos = uiconfig.front_mute_icon
		self.mute_image = utils.put_image(icon, pos)

		self.add(self.hands_free_image)
		self.add(self.mute_image)

	def show(self):
		NotifyCall2UI.show(self)

		if not model.ani_timer:
			self.ani_count = 0
		self.incoming_ani[self.ani_count].show()
		model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

		if not status.audio_mute:
			self.mute_image.hide()
		if status.modem_audio_state == status.HS:
			self.hands_free_image.hide()
		elif status.audio_mute:
			self.hands_free_image.hide()

 	def ani_timer_cb(self):
 		if not model.ani_timer:
 			return
 		if self.ani_count == -1:
 			self.ani_count += 1
 		else:
 			self.incoming_ani[self.ani_count].hide()
 			self.ani_count += 1
 			if self.ani_count > 3:
 				self.ani_count = 0
 		self.incoming_ani[self.ani_count].show()

 		if model.ani_timer:
 			runtime.evas.timeout_remove(model.ani_timer)
 		model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

	def hide(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)
		model.ani_timer = None

		NotifyCall2UI.hide(self)
		for w in self.incoming_ani:
			w.hide()

	def destroy(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)

		NotifyCall2UI.destroy(self)
		for w in self.incoming_ani:
			w.free()

class FirstConnectedSecondIncomingUI(NotifyCall2UI):
	show_bg = True
	def __init__(self, active_line_name, incoming_name):
		icon1 = ''
		icon2 = ''
		message1 = _('Call connected') + ':'
		message2 = active_line_name
		message3 = _('Incoming call from') + ':'
		message4 = incoming_name
		NotifyCall2UI.__init__(self, _('ACCEPT'), _('REJECT') , '', message1, message2, message3, message4, icon1, icon2)

		runtime.evas.incoming_temp_ani = None
		runtime.evas.outgoing_temp_ani = None
		self.incoming_ani = []
		self.outgoing_ani = []

		self.index = 0
		self.index2 = 0

		for w in uiconfig.front_outgoing_icon_ani:
			runtime.evas.outgoing_temp_ani = utils.put_image(w, uiconfig.front_outgoing_icon_ani_pos)
			self.outgoing_ani.append(runtime.evas.outgoing_temp_ani)
			self.outgoing_ani[self.index].hide()
			self.index += 1
		for w in uiconfig.back_incoming_icon_ani:
			runtime.evas.incoming_temp_ani = utils.put_image(w, uiconfig.back_incoming_icon_ani_pos)
			self.incoming_ani.append(runtime.evas.incoming_temp_ani)
			self.incoming_ani[self.index2].hide()
			self.index2+= 1
		self.ani_count = -1

		icon, pos = uiconfig.front_speaker_icon
		self.hands_free_image = utils.put_image(icon, pos)
		icon, pos = uiconfig.front_mute_icon
		self.mute_image = utils.put_image(icon, pos)
		# hcryoo : [20070521_3]
		icon, pos = uiconfig.front_in_call_wait_icon
		self.front_image = utils.put_image(icon, pos)

		self.add(self.front_image)
		self.add(self.hands_free_image)
		self.add(self.mute_image)

		self.mute_image.hide()
		self.hands_free_image.hide()
		self.front_image.hide()
		# hcryoo : [20070521_3]==

	def show(self):
		NotifyCall2UI.show(self)

		# hcryoo : [20070525_3]
		if status.get_hold_flag(status.active_call_index) or status.get_held_flag(status.active_call_index):
			if model.ani_timer:
				runtime.evas.timeout_remove(model.ani_timer)
			self.outgoing_ani[self.ani_count].hide()
			self.front_image.show()
			NotifyCall2UI.change_message1_to_held(self)
		else:
			self.front_image.hide()
			NotifyCall2UI.change_message1_to_normal(self)
			if not model.ani_timer:
				self.ani_count = 0
			self.outgoing_ani[self.ani_count].show()
			model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)
		# hcryoo : [20070525_3]==

		if not status.audio_mute:
			self.mute_image.hide()
		if status.modem_audio_state == status.HS:
			self.hands_free_image.hide()
		elif status.audio_mute:
			self.hands_free_image.hide()

 	def ani_timer_cb(self):
 		if not model.ani_timer:
 			return
 		if self.ani_count == -1:
 			self.ani_count += 1
 		else:
 			self.incoming_ani[self.ani_count].hide()
 			self.outgoing_ani[self.ani_count].hide()
 			self.ani_count += 1
 			if self.ani_count > 3:
 				self.ani_count = 0
 		self.incoming_ani[self.ani_count].show()
		self.outgoing_ani[self.ani_count].show()

 		if model.ani_timer:
 			runtime.evas.timeout_remove(model.ani_timer)
 		model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

	def hide(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)
		model.ani_timer = None

		NotifyCall2UI.hide(self)
		for w in self.incoming_ani:
			w.hide()
		for w in self.outgoing_ani:
			w.hide()


	def destroy(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)

		NotifyCall2UI.destroy(self)
		for w in self.incoming_ani:
			w.free()
		for w in self.outgoing_ani:
			w.free()

class FirstConnectingSecondIncomingUI(NotifyCall2UI):
	show_bg = True
	def __init__(self, active_line_name, incoming_name):
		icon1 = uiconfig.front_dial_call_icon
		icon2 = ''
		message1 = _('Connecting') + ':'
		message2 = active_line_name
		message3 = _('Incoming call from') + ':'
		message4 = incoming_name
		NotifyCall2UI.__init__(self, _('ACCEPT'), _('REJECT') , '', message1, message2, message3, message4, icon1, icon2)

		runtime.evas.incoming_temp_ani = None
		self.incoming_ani = []
		self.index = 0

		for w in uiconfig.back_incoming_icon_ani:
			runtime.evas.incoming_temp_ani = utils.put_image(w, uiconfig.back_incoming_icon_ani_pos)
			self.incoming_ani.append(runtime.evas.incoming_temp_ani)
			self.incoming_ani[self.index].hide()
			self.index+= 1

		self.ani_count = -1

		icon, pos = uiconfig.front_speaker_icon
		self.hands_free_image = utils.put_image(icon, pos)

		icon, pos = uiconfig.front_mute_icon
		self.mute_image = utils.put_image(icon, pos)

		self.add(self.hands_free_image)
		self.add(self.mute_image)

	def show(self):
		NotifyCall2UI.show(self)

		if not model.ani_timer:
			self.ani_count = 0
		self.incoming_ani[self.ani_count].show()
		model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

		if not status.audio_mute:
			self.mute_image.hide()
		if status.modem_audio_state == status.HS:
			self.hands_free_image.hide()
		elif status.audio_mute:
			self.hands_free_image.hide()

 	def ani_timer_cb(self):
 		if not model.ani_timer:
 			return
 		if self.ani_count == -1:
 			self.ani_count += 1
 		else:
 			self.incoming_ani[self.ani_count].hide()
 			self.ani_count += 1
 			if self.ani_count > 3:
 				self.ani_count = 0
 		self.incoming_ani[self.ani_count].show()

 		if model.ani_timer:
 			runtime.evas.timeout_remove(model.ani_timer)
 		model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

	def hide(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)
		model.ani_timer = None

		NotifyCall2UI.hide(self)
		for w in self.incoming_ani:
			w.hide()

	def destroy(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)

		NotifyCall2UI.destroy(self)
		for w in self.incoming_ani:
			w.free()

class TwoIncomingUI(NotifyCall2UI):
	show_bg = True
	def __init__(self, active_line_name, incoming_name):
		icon1 = ''
		icon2 = ''
		message1 = _('Incoming call from') + ':'
		message2 = active_line_name
		message3 = _('Incoming call from') + ':'
		message4 = incoming_name
		NotifyCall2UI.__init__(self, _('ACCEPT'), _('REJECT') , '', message1, message2, message3, message4, icon1, icon2)

		runtime.evas.incoming_temp_ani = None
		runtime.evas.incoming_temp_ani2 = None
		self.incoming_ani = []
		self.incoming_ani2 = []
		self.index = 0
		self.index2 = 0
		for w in uiconfig.front_incoming_icon_ani:
			runtime.evas.incoming_temp_ani = utils.put_image(w, uiconfig.front_incoming_icon_ani_pos)
			self.incoming_ani.append(runtime.evas.incoming_temp_ani)
			self.incoming_ani[self.index].hide()
			self.index += 1

		for w in uiconfig.back_incoming_icon_ani:
			runtime.evas.incoming_temp_ani2 = utils.put_image(w, uiconfig.back_incoming_icon_ani_pos)
			self.incoming_ani2.append(runtime.evas.incoming_temp_ani2)
			self.incoming_ani2[self.index2].hide()
			self.index2+= 1

		self.ani_count = -1

		icon, pos = uiconfig.front_speaker_icon
		self.hands_free_image = utils.put_image(icon, pos)
		icon, pos = uiconfig.front_mute_icon
		self.mute_image = utils.put_image(icon, pos)

		self.add(self.hands_free_image)
		self.add(self.mute_image)

	def show(self):
		NotifyCall2UI.show(self)

		if not model.ani_timer:
			self.ani_count = 0
		self.incoming_ani[self.ani_count].show()
		self.incoming_ani2[self.ani_count].show()
		model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

		if not status.audio_mute:
			self.mute_image.hide()
		if status.modem_audio_state == status.HS or status.modem_audio_state == status.IDLE:
			self.hands_free_image.hide()
		elif status.audio_mute:
			self.hands_free_image.hide()

 	def ani_timer_cb(self):
 		if not model.ani_timer:
 			return
 		if self.ani_count == -1:
 			self.ani_count += 1
 		else:
 			self.incoming_ani[self.ani_count].hide()
 			self.incoming_ani2[self.ani_count].hide()
 			self.ani_count += 1
 			if self.ani_count > 3:
 				self.ani_count = 0
 		self.incoming_ani[self.ani_count].show()
		self.incoming_ani2[self.ani_count].show()

 		if model.ani_timer:
 			runtime.evas.timeout_remove(model.ani_timer)
 		model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

	def hide(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)
		model.ani_timer = None

		NotifyCall2UI.hide(self)
		for w in self.incoming_ani:
			w.hide()
		for w in self.incoming_ani2:
			w.hide()

	def destroy(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)

		NotifyCall2UI.destroy(self)
		for w in self.incoming_ani:
			w.free()
		for w in self.incoming_ani2:
			w.free()

#####################
class MWINotificationUI(BaloonMessageUI):
	def __init__(self, normal_new, normal_old, urgent_new, urgent_old, icon=uiconfig.baloon_mwi_icon):

		self.normal_new = int(normal_new)
		self.normal_total = int(normal_old) + int(normal_new)
		self.urgent_new = int(urgent_new)
		self.urgent_total = int(urgent_old) + int(urgent_new)

		message = '\n'+ _('Voice message received') + ':\n'
		message = message + _('Normal')+ ' %d' % self.normal_new + '/' + '%d' % self.normal_total + ','
		message = message + ' '+_('Urgent') + ' %d' % self.urgent_new + '/' + '%d' % self.urgent_total + '\n'


		BaloonMessageUI.__init__(self, _('DIAL'),  _('EXIT'), '', icon, message)

		name, pos = uiconfig.idle_mwi_icon
		self.mwi_image = utils.put_image(name, pos)
		self.add(self.mwi_image)

#####################

class ConferenceUI(NotifyConfCallUI):
	show_bg = True
	def __init__(self, connected_name, held_name):
		icon = uiconfig.conference_icon
		message1 = _('In conference') + ':'
		message2 = connected_name
		message3 = held_name
		# hcryoo : [20070522_1]
		NotifyConfCallUI.__init__(self, _('OPTIONS'), '', '', message1, message2, message3, icon)
		# hcryoo : [20070522_1]==
		icon, pos = uiconfig.front_speaker_icon
		self.hands_free_image = utils.put_image(icon, pos)

		icon, pos = uiconfig.front_mute_icon
		self.mute_image = utils.put_image(icon, pos)

		self.add(self.hands_free_image)
		self.add(self.mute_image)

	# hcryoo : [20070515_2]
	def set_connectedHeld_icon(self):
		self.show()
		
	def cancel_connectedHeld_icon(self):
		self.show()
	# hcryoo : [20070515_2]==

	# hcryoo : [20070525_2]
	def show_held_name(self, name):
		NotifyConfCallUI.change_hold_number(self,name)

	def show_connected_name(self, name):
		NotifyConfCallUI.change_caller_number(self,name)
		
	# hcryoo : [20070525_2]==
	
	def show(self):
		NotifyConfCallUI.show(self)
		if not status.audio_mute:
			self.mute_image.hide()
		if status.modem_audio_state == status.HS:
			self.hands_free_image.hide()
		elif status.audio_mute:
			self.hands_free_image.hide()
		if not status.audio_mute:
			self.set_right('')
		else:
			self.set_right(_('ENABLE MIC'))

class TwoCallOneConnectingUI(NotifyCall2UI):
	show_bg = True
	def __init__(self, connected_name, held_name, left, right):
		icon1 = uiconfig.front_dial_call_icon
		icon2 = uiconfig.back_in_call_wait_icon
		message1 = _('Connecting') + ':'
		message2 = connected_name
		message3 = _('Call held') + ':'
		message4 = held_name
		NotifyCall2UI.__init__(self, left, right, '', message1, message2, message3, message4, icon1, icon2)

		icon, pos = uiconfig.front_speaker_icon
		self.hands_free_image = utils.put_image(icon, pos)
		icon, pos = uiconfig.front_mute_icon
		self.mute_image = utils.put_image(icon, pos)

		self.add(self.hands_free_image)
		self.add(self.mute_image)

	def show(self):
		NotifyCall2UI.show(self)
		if not status.audio_mute:
			self.mute_image.hide()
		if status.modem_audio_state == status.HS:
			self.hands_free_image.hide()
		elif status.audio_mute:
			self.hands_free_image.hide()

	def destroy(self):
		NotifyCall2UI.destroy(self)

class TwoCallOneDialingUI(NotifyCall2UI):
	show_bg = True
	def __init__(self, connected_name, held_name, left, right):
		icon1 = uiconfig.front_second_call_icon
		icon2 = uiconfig.back_in_call_wait_icon
		message1 = _('Dialing') + ':'
		message2 = connected_name
		message3 = _('Call held') + ':'
		message4 = held_name
		NotifyCall2UI.__init__(self, left, right, '', message1, message2, message3, message4, icon1, icon2)

		icon, pos = uiconfig.front_speaker_icon
		self.hands_free_image = utils.put_image(icon, pos)
		icon, pos = uiconfig.front_mute_icon
		self.mute_image = utils.put_image(icon, pos)

		self.add(self.hands_free_image)
		self.add(self.mute_image)

	def show(self):
		NotifyCall2UI.show(self)
		if not status.audio_mute:
			self.mute_image.hide()
		if status.modem_audio_state == status.HS:
			self.hands_free_image.hide()
		elif status.audio_mute:
			self.hands_free_image.hide()

	def destroy(self):
		NotifyCall2UI.destroy(self)

class TwoCallOneHoldUI(NotifyCall2UI):
	show_bg = True
	def __init__(self, connected_name, held_name, left, right):
		icon1 = ''
		icon2 = uiconfig.back_in_call_wait_icon
		message1 = _('Call connected') + ':'
		message2 = connected_name
		message3 = _('Call held') + ':'
		message4 = held_name
		NotifyCall2UI.__init__(self, left, right, '', message1, message2, message3, message4, icon1, icon2)

		runtime.evas.outgoing_temp_ani = None
		self.outgoing_ani = []
		self.index = 0
		for w in uiconfig.front_outgoing_icon_ani:
			runtime.evas.outgoing_temp_ani = utils.put_image(w, uiconfig.front_outgoing_icon_ani_pos)
			self.outgoing_ani.append(runtime.evas.outgoing_temp_ani)
			self.outgoing_ani[self.index].hide()
			self.index += 1
		self.ani_count = -1

		icon, pos = uiconfig.front_speaker_icon
		self.hands_free_image = utils.put_image(icon, pos)
		icon, pos = uiconfig.front_mute_icon
		self.mute_image = utils.put_image(icon, pos)

		# hcryoo : [20070521_3]
		icon, pos = uiconfig.front_in_call_wait_icon
		self.front_image = utils.put_image(icon, pos)

		self.add(self.front_image)
		self.add(self.hands_free_image)
		self.add(self.mute_image)

		self.mute_image.hide()
		self.hands_free_image.hide()
		self.front_image.hide()
		# hcryoo : [20070521_3]==

	def show(self):
		NotifyCall2UI.show(self)
		
		if status.business_option_status == status.CallTransferOption:
			right = _('TRANSFER')
		elif status.business_option_status == status.CallConferenceOption:
			right = _('CONFERENCE')
		else: # CallHoldOption
			right = _('ALTERNATE')

		# hcryoo : [20070521_3]
		if status.get_hold_flag(status.active_call_index) or status.get_held_flag(status.active_call_index):
			#print '1ooooooooooooooo'
			if model.ani_timer:
				runtime.evas.timeout_remove(model.ani_timer)
			self.outgoing_ani[self.ani_count].hide()
			self.front_image.show()
	 		if status.business_option_status == status.CallTransferOption:
				NotifyCall2UI.set_right(self, _('END') )
			elif status.business_option_status == status.CallConferenceOption:
				NotifyCall2UI.set_right(self, _('END') )
			else: # CallHoldOption
				NotifyCall2UI.set_right(self, _('END') )
			NotifyCall2UI.change_message1_to_held(self)
		else:
			#print '2ooooooooooooooo'
			self.front_image.hide()
			NotifyCall2UI.change_message1_to_normal(self)
	 		if status.business_option_status == status.CallTransferOption:
				NotifyCall2UI.set_right(self, _('TRANSFER') )
			elif status.business_option_status == status.CallConferenceOption:
				NotifyCall2UI.set_right(self, _('CONFERENCE') )
			else: # CallHoldOption
				NotifyCall2UI.set_right(self, _('ALTERNATE') )
			if not model.ani_timer:
				self.ani_count = 0
			self.outgoing_ani[self.ani_count].show()
			model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)
		# hcryoo : [20070521_3]==

		if not status.audio_mute:
			self.mute_image.hide()
		if status.modem_audio_state == status.HS:
			self.hands_free_image.hide()
		elif status.audio_mute:
			self.hands_free_image.hide()

		runtime.evas.render_now()

	def ani_timer_cb(self):
		if not model.ani_timer:
			return
		if self.ani_count == -1:
			self.ani_count += 1
		else:
			self.outgoing_ani[self.ani_count].hide()
			self.ani_count += 1
			if self.ani_count > 3:
				self.ani_count = 0
		self.outgoing_ani[self.ani_count].show()

		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)
		model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

	def hide(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)
		model.ani_timer = None
		NotifyCall2UI.hide(self)
		for w in self.outgoing_ani:
			w.hide()
			
	def destroy(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)
		NotifyCall2UI.destroy(self)
		for w in self.outgoing_ani:
			w.free()

class CallHoldUI(NotifyCallUI):
	show_bg = True
	def __init__(self, caller):
		icon = uiconfig.connected_hold_icon
		message1 = _('Call held') + ':'
		message2 = caller
		NotifyCallUI.__init__(self, _('RESUME'), _('CALL'), '', message1, message2, icon)
		runtime.evas.outgoing_temp_ani = None
		self.outgoing_ani = []
		self.index = 0
		for w in uiconfig.outgoing_icon_ani:
			runtime.evas.outgoing_temp_ani = utils.put_image(w, uiconfig.outgoing_icon_ani_pos)
			self.outgoing_ani.append(runtime.evas.outgoing_temp_ani)
			self.outgoing_ani[self.index].hide()
			self.index += 1
		self.ani_count = -1

	def show(self):
		NotifyCallUI.show(self)
		if not model.ani_timer:
			self.ani_count = 0
		self.outgoing_ani[self.ani_count].show()
		model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

	def ani_timer_cb(self):
		if not model.ani_timer:
			return
		if self.ani_count == -1:
			self.ani_count += 1
		else:
			self.outgoing_ani[self.ani_count].hide()
			self.ani_count += 1
			if self.ani_count > 3:
				self.ani_count = 0
		self.outgoing_ani[self.ani_count].show()
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)
		model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

	def hide(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)
		model.ani_timer = None
		NotifyCallUI.hide(self)
		for w in self.outgoing_ani:
			w.hide()

	def destroy(self):
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)
		NotifyCallUI.destroy(self)
		for w in self.outgoing_ani:
			w.free()

#################################
class ConnectedHeldUI(NotifyCallUI):
	show_bg = True
	def __init__(self, caller):
		icon = uiconfig.connected_hold_icon
		#message1 = _('Call held') + ':'
		message1 = _('Call connected') + '(Held)' + ':'
		message2 = caller
		
	def show(self):
		NotifyCallUI.show(self)
		#if not model.ani_timer:
		#	self.ani_count = 0
		#self.outgoing_ani[self.ani_count].show()
		#model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

	def ani_timer_cb(self):
		if not model.ani_timer:
			return
		if self.ani_count == -1:
			self.ani_count += 1
		else:
			self.outgoing_ani[self.ani_count].hide()
			self.ani_count += 1
			if self.ani_count > 3:
				self.ani_count = 0
		self.outgoing_ani[self.ani_count].show()
		if model.ani_timer:
			runtime.evas.timeout_remove(model.ani_timer)
		model.ani_timer = runtime.evas.timeout_add(500, self.ani_timer_cb)

	def hide(self):
		
		NotifyCallUI.hide(self)

	def destroy(self):
		#if model.ani_timer:
		#	runtime.evas.timeout_remove(model.ani_timer)
		NotifyCallUI.destroy(self)
		#for w in self.outgoing_ani:
		#	w.free()
#################################


class ShowVersionUI(LargeWindowUI):

	def __init__(self, swver, hwver, auto_provision, auto_config, upgrade_state, cycle=''):
		LargeWindowUI.__init__(self, '', _('BACK'), _('SHOW HW/SW VERSION'))

		index = 0
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=_('Hardware version') + ':' + ' Rel. %s' % hwver
		t.pos =(uiconfig.version_detail_pos_x, uiconfig.version_detail_pos_y[index])
		self.add(t)

		index += 1
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=_('Software version') + ':' + ' Rel. %s' % swver
		t.pos =(uiconfig.version_detail_pos_x, uiconfig.version_detail_pos_y[index])
		self.add(t)

		if auto_provision:
			index += 1
			t = runtime.evas.text()
			t.font=uiconfig.swver_details_font
			t.color=uiconfig.swver_details_color
			t.text=_('Auto-provision state') + ':' + ' ' + auto_provision
			t.pos =(uiconfig.version_detail_pos_x, uiconfig.version_detail_pos_y[index])
			self.add(t)

		index += 1
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=_('Auto-configuration state') + ':' + ' ' + auto_config
		t.pos =(uiconfig.version_detail_pos_x, uiconfig.version_detail_pos_y[index])
		self.add(t)

		index += 1
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=_('Upgrading state') + ':' + ' ' + upgrade_state
		t.pos =(uiconfig.version_detail_pos_x, uiconfig.version_detail_pos_y[index])
		self.add(t)

		if cycle:
			index += 1
			t = runtime.evas.text()
			t.font=uiconfig.swver_details_font
			t.color=uiconfig.swver_details_color
			t.text = cycle
			t.pos =(uiconfig.version_detail_pos_x, uiconfig.version_detail_pos_y[index])
			self.add(t)



class ModelNameUI(SmallWindowUI):
	def __init__(self,modelName):
		SmallWindowUI.__init__(self, '', _('BACK'),'',_('Model Name'))
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text= ' %s' % modelName
		t.pos =(uiconfig.ver_detail_pos_x, uiconfig.ver_detail_pos_y)
		self.add(t)

class CompanyNameUI(SmallWindowUI):
	def __init__(self,companyName):
		SmallWindowUI.__init__(self, '', _('BACK'),'',_('Company Name'))
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=' %s' % companyName
		t.pos =(uiconfig.ver_detail_pos_x, uiconfig.ver_detail_pos_y)
		self.add(t)

class HWVersionUI(SmallWindowUI):
	def __init__(self,hwver):
		SmallWindowUI.__init__(self, '', _('BACK'),'',_('H/W Version'))
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=' Rel. %s' % hwver
		t.pos =(uiconfig.ver_detail_pos_x, uiconfig.ver_detail_pos_y)
		self.add(t)

class SWVersionUI(SmallWindowUI):
	def __init__(self,swver):
		SmallWindowUI.__init__(self, '', _('BACK'),'',_('S/W Version'))
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=' Rel. %s' % swver
		t.pos =(uiconfig.ver_detail_pos_x, uiconfig.ver_detail_pos_y)
		self.add(t)
		

class CpuUsageUI(SmallWindowUI):
	def __init__(self, cpuUsage):
		SmallWindowUI.__init__(self, '', _('BACK'),'',_('CPU usage'))
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=' %s' % cpuUsage
		t.pos =(uiconfig.ver_detail_pos_x, uiconfig.ver_detail_pos_y)
		self.add(t)

class TotalMemoryUI(SmallWindowUI):
	def __init__(self, totalMemory):
		SmallWindowUI.__init__(self, '', _('BACK'),'',_('Used Memory/Total Memory'))
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=' %s' % totalMemory
		t.pos =(uiconfig.ver_detail_pos_x, uiconfig.ver_detail_pos_y)
		self.add(t)

class TotalMemoryUsageUI(SmallWindowUI):
# obselete
	def __init__(self, totalMemoryUsage):
		SmallWindowUI.__init__(self, '', _('BACK'),'','Total memory usage')
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=_('Total memory usage') + ':' + ' %s' % totalMemoryUsage
		t.pos =(uiconfig.ver_detail_pos_x, uiconfig.ver_detail_pos_y)
		self.add(t)

class FlashMemoryUI(SmallWindowUI):
	def __init__(self, flashMemory):
		SmallWindowUI.__init__(self, '', _('BACK'),'','Flash Memory')
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=' %s' % flashMemory
		t.pos =(uiconfig.ver_detail_pos_x, uiconfig.ver_detail_pos_y)
		self.add(t)

class FlashMemoryUsageUI(SmallWindowUI):
#obselete
	def __init__(self, flashMemoryUsage):
		SmallWindowUI.__init__(self, '', _('BACK'),'','Flash memory usage')
		t = runtime.evas.text()
		t.font=uiconfig.swver_details_font
		t.color=uiconfig.swver_details_color
		t.text=_('Flash memory usage') + ':' + ' %s' % flashMemoryUsage
		t.pos =(uiconfig.ver_detail_pos_x, uiconfig.ver_detail_pos_y)
		self.add(t)

class IncomingSMSUI(BaloonUI):
	def __init__(self, num_sms, icon=uiconfig.baloon_message_icon):
		BaloonUI.__init__(self, _('READ'), _('EXIT'), '', icon)

		self.num_sms = num_sms
		message = '%d ' % self.num_sms + _('SMS received!')

		self.t = runtime.evas.text(text=message, font=uiconfig.idle_sms_font, color=uiconfig.idle_sms_color)
		self.t.pos = uiconfig.idle_sms_pos
		self.add(self.t)

		from smsmanager import smsmgr
		if config.message_entry_max <= smsmgr.count_received():
			name, pos = uiconfig.idle_icon_messagefull
			self.sms_image = utils.put_image(name, pos)
			self.add(self.sms_image)
		else:
			name, pos = uiconfig.idle_sms_icon
			self.sms_image = utils.put_image(name, pos)
			self.add(self.sms_image)

	def set_num_sms(self, num_sms):
		if config.sms_debug:
			print 'IncomingSMSUI.set_num_sms, num_sms = ', num_sms
		self.num_sms = num_sms
		message = '%d '  % self.num_sms + _('SMS received!')
		self.t.text = message

def check_wifi_connection():
	try:
		import os
#ka...3800 wifi 2007.04.25
#		os.system('iwpriv wlan0 getlinkstate > /tmp/wifi_getlinkstate')
		os.system('wlchecklink')

		fp = open('/tmp/wifi_getlinkstate')
		tmpState = fp.read()

		result = int(tmpState[0].strip())
#ka...3800 wifi 2007.04.25 changed succ[0 -> 1] fail[1->0]
		if result == 1:
			roxia_event('wifi connected (OK)')
# KA: [20080320] Temporary wifi link up check
			if profile.wifi_profile.dhcp == 'yes':
				network_info = utils.get_address('wlan')
				if not network_info[0][1]:
					runtime.manager.ifconfig_run('wifi')
# KA: [20080320] Temporary wifi link up check ==			
			return True
		else:
			roxia_event('wifi disconnected (X)')
			return False

	except:
		roxia_event('wifi disconnected (X)')
		return False

def wifi_status_timer():
	if profile.profile.get_profile() != 2: # wifi profile
		return False

	cur_connection = check_wifi_connection()

	status.wifi_connected = cur_connection

	return True

#Thang: [20080318 -1] show calendar clock, temper	
#Thang: [20080314 -1] show calendar clock, temper
class IdleUI(BaseUI):
	show_bg = True
	first = True
	def __init__(self):
		BaseUI.__init__(self, _('MENU'),_('PHONEBOOK'), '', _('Date/Weather'), _('Life service'))
		
		title = widget.OutlineLabel(text='',
			font=uiconfig.idle_font,
			pos=uiconfig.idle_pos,
			color=uiconfig.idle_color,
			outline_color=uiconfig.idle_outline_color)
		self.add(title)

		# TelNUM ---------
		from vdcisetting import vdci_setting
		if profile.ip_mode == 1:
			my_number = utils.conv_telnum(vdci_setting.tel_num)
		else:
			my_number = ''
		if len(my_number) > 25:
			my_number = my_number[:25]+'\n'+my_number[25:]

		if profile.profile.get_profile() == 2:
			if len(profile.wifi_profile.essid) > 28:
				my_number = my_number + '\n' + profile.wifi_profile.essid[:28] + '...'
			else:
				my_number = my_number + '\n' + profile.wifi_profile.essid		

		self.my_number = widget.OutlineLabel(text = my_number,
									font = uiconfig.idle_mynumber_font,
									pos = uiconfig.idle_mynumber_pos,
									color = uiconfig.idle_mynumber_color,
									outline_color = uiconfig.idle_mynumber_outline_color,
									align = 1,
									abbr_width = uiconfig.large_window_text_width)
		self.add(self.my_number)

		#name, pos = uiconfig.idle_number_box	
		#self.number_box = utils.put_image(name, pos)
		#self.add(self.number_box)
		#self.number_box.hide()
		# TelNUM ---------

		
		#Calendar
		name, pos = uiconfig.idle_calendar_bg		
		self.calendar_bg = utils.put_image(name, pos)
		self.add(self.calendar_bg)
		
		name, pos = uiconfig.idle_temper_bg		
		self.temper_bg = utils.put_image(name, pos)
		self.add(self.temper_bg)		
		
		#os.system('th_test_onetime.bin > /tmp/temperature.txt')
		#fp = open('/tmp/temperature.txt')
		#temperature = fp.readline().strip()
		#fp.close()
		
		
		self.temper = runtime.evas.text(text='16.45C', pos = (340, 208), font=(uiconfig.def_font,13), color = (127,225,0,255))
		self.add(self.temper)
		self.humi = runtime.evas.text(text='6.45%', pos = (426, 208), font=(uiconfig.def_font,13), color = (127,225,0,255))
		self.add(self.humi)		

		
		#---------------------------------

		#name, pos = uiconfig.idle_agenda_icon
		#self.agenda_image = utils.put_image(name, pos)
		#self.add(self.agenda_image)
		# profile
		name, pos = uiconfig.idle_profile_lan
		self.profile_image = utils.put_image(name, pos)
		self.add(self.profile_image)
		self.update_register_tag = None
		# sip
#		name, pos = uiconfig.idle_profile_lan_nosip
#		self.sip_image = utils.put_image(name, pos)
#		self.add(self.sip_image)
		self.update_register_tag = None

		#miss call
		name, pos = uiconfig.idle_missed_call_icon
		self.missed_call_image = utils.put_image(name, pos)
		self.add(self.missed_call_image)

		#sms
		name, pos = uiconfig.idle_sms_icon
		self.sms_image = utils.put_image(name, pos)
		self.add(self.sms_image)

		# alarm
		name, pos = uiconfig.idle_alarm_icon
		self.alarm_image = utils.put_image(name, pos)
		self.add(self.alarm_image)
		self.alarm_image.hide()

		# Absence
		name, pos = uiconfig.idle_absence_icon
		self.absence_image = utils.put_image(name, pos)
		self.add(self.absence_image)
		self.absence_image.hide()

		# SRS WOW
		name, pos = uiconfig.idle_srswow_icon
		self.srswow_image = utils.put_image(name, pos)
		self.add(self.srswow_image)
		self.srswow_image.hide()

		#name, pos = uiconfig.idle_sound_disable_icon
		#self.sound_disable_image = utils.put_image(name, pos)
		#self.add(self.sound_disable_image)

		#name, pos = uiconfig.idle_vip_filter_icon
		#self.vip_filter_image = utils.put_image(name, pos)
		#self.add(self.vip_filter_image)

		#name, pos = uiconfig.idle_reserved_filter_icon
		#self.reserved_filter_image = utils.put_image(name, pos)
		#self.add(self.reserved_filter_image)

		#name, pos = uiconfig.idle_video_supervision
		#self.video_supervision = utils.put_image(name, pos)
		#self.add(self.video_supervision)
		#self.video_supervision.hide()

		#name, pos = uiconfig.idle_mwi_icon
		#self.mwi_image = utils.put_image(name, pos)
		#self.add(self.mwi_image)

		#name, pos = uiconfig.idle_icon_messagefull
		#self.message_full = utils.put_image(name, pos)
		#self.add(self.message_full)

		self.show_calendar()

		# 화면 문구
		pos = uiconfig.background_text_pos_center
		font = uiconfig.def_font, uiconfig.screen_text_size_list[setting.ScreenTextSizeIndex]
		color = uiconfig.screen_text_color_list[setting.ScreenTextColorIndex]
		bg_text = setting.ScreenTextText
		self.ScreenText_text= runtime.evas.text(text=bg_text, font=font, pos=pos, color=color)
		self.add(self.ScreenText_text)
		self.ScreenText_text.hide()

		
	def display_idle_style(self,idle_style):
		if idle_style == 2:
			self.calendar_bg.show()
			self.ball_icon.show()	
			self.line.show()		
			self.week01.show()
			self.week02.show()
			self.week03.show()
			self.week04.show()
			self.week05.show()
			self.week06.show()
			self.week07.show()
			self.ref.show()			
			self.ap.show()
			self.colon.show()
			self.hour1.show()
			self.hour2.show()
			self.min1.show()
			self.min2.show()
			self.year1.show()
			self.year2.show()
			self.year3.show()
			self.year4.show()
			self.month_long.show()
			#self.month_short.show()
			self.temper_bg.hide()
			self.temper.hide()
			self.humi.hide()
			#--------------------------
			self.clock_bg.hide()
			self.hour_arrow.hide()
			self.min_arrow.hide()
			self.year1_02.hide()
			self.year2_02.hide()
			self.year3_02.hide()
			self.year4_02.hide()			
			self.month_02.hide()
			self.day_02.hide()
			self.week_02.hide()
			#--------------------------
			self.calender_bg02.hide()
			self.year1_03.hide()
			self.year2_03.hide()
			self.year3_03.hide()
			self.year4_03.hide()
			self.month_03.hide()
			self.day_03.hide()
			self.week_03.hide()
			self.ap03.hide()
			self.colon03.hide()
			self.hour1_03.hide()
			self.hour2_03.hide()
			self.min1_03.hide()
			self.min2_03.hide()
			self.weather01.hide()
			self.weather02.hide()
		elif idle_style == 1:
			self.calendar_bg.show()
			self.clock_bg.show()
			self.hour_arrow.show()
			self.min_arrow.show()
			self.year1_02.show()
			self.year2_02.show()
			self.year3_02.show()
			self.year4_02.show()
			self.month_02.show()
			self.day_02.show()
			self.week_02.show()
			self.temper_bg.hide()
			self.temper.hide()
			self.humi.hide()
			#------------------------
			self.ball_icon.hide()		
			self.line.hide()		
			self.week01.hide()
			self.week02.hide()
			self.week03.hide()
			self.week04.hide()
			self.week05.hide()
			self.week06.hide()
			self.week07.hide()
			self.ref.hide()
			i =1
			while i <=42:				
				self.arr_cal[i].hide()
				self.arr_selcal[i].hide()
				i = i + 1
			
			self.ap.hide()
			self.colon.hide()
			self.hour1.hide()
			self.hour2.hide()
			self.min1.hide()
			self.min2.hide()
			self.year1.hide()
			self.year2.hide()
			self.year3.hide()
			self.year4.hide()
			self.month_long.hide()
			#self.month_short.hide()		
			#--------------------------
			self.calender_bg02.hide()
			self.year1_03.hide()
			self.year2_03.hide()
			self.year3_03.hide()
			self.year4_03.hide()
			self.month_03.hide()
			self.day_03.hide()
			self.week_03.hide()
			self.ap03.hide()
			self.colon03.hide()
			self.hour1_03.hide()
			self.hour2_03.hide()
			self.min1_03.hide()
			self.min2_03.hide()
			self.weather01.hide()
			self.weather02.hide()
		elif idle_style == 0:
			#--------------------------
			self.calender_bg02.show()
			self.year1_03.show()
			self.year2_03.show()
			self.year3_03.show()
			self.year4_03.show()
			self.month_03.show()
			self.day_03.show()
			self.week_03.show()
			self.ap03.show()
			self.colon03.show()
			self.hour1_03.show()
			self.hour2_03.show()
			self.min1_03.show()
			self.min2_03.show()
			self.weather01.show()	#self.weather01.hide()
			self.weather02.show()	#self.weather02.hide()
			#---------------------
			self.calendar_bg.hide()
			self.clock_bg.hide()
			self.hour_arrow.hide()
			self.min_arrow.hide()
			self.year1_02.hide()
			self.year2_02.hide()
			self.year3_02.hide()
			self.year4_02.hide()
			self.month_02.hide()
			self.day_02.hide()
			self.week_02.hide()
			self.temper_bg.hide()
			self.temper.hide()
			self.humi.hide()
			#------------------------
			self.ball_icon.hide()		
			self.line.hide()		
			self.week01.hide()
			self.week02.hide()
			self.week03.hide()
			self.week04.hide()
			self.week05.hide()
			self.week06.hide()
			self.week07.hide()
			self.ref.hide()
			i =1
			while i <=42:				
				self.arr_cal[i].hide()
				self.arr_selcal[i].hide()
				i = i + 1
			
			self.ap.hide()
			self.colon.hide()
			self.hour1.hide()
			self.hour2.hide()
			self.min1.hide()
			self.min2.hide()
			self.year1.hide()
			self.year2.hide()
			self.year3.hide()
			self.year4.hide()
			self.month_long.hide()
			#self.month_short.hide()	
		else:
			#--------------------------
			self.calender_bg02.hide()
			self.year1_03.hide()
			self.year2_03.hide()
			self.year3_03.hide()
			self.year4_03.hide()
			self.month_03.hide()
			self.day_03.hide()
			self.week_03.hide()
			self.ap03.hide()
			self.colon03.hide()
			self.hour1_03.hide()
			self.hour2_03.hide()
			self.min1_03.hide()
			self.min2_03.hide()
			self.weather01.hide()
			self.weather02.hide()
			#---------------------
			self.calendar_bg.hide()
			self.clock_bg.hide()
			self.hour_arrow.hide()
			self.min_arrow.hide()
			self.year1_02.hide()
			self.year2_02.hide()
			self.year3_02.hide()
			self.year4_02.hide()
			self.month_02.hide()
			self.day_02.hide()
			self.week_02.hide()
			self.temper_bg.hide()
			self.temper.hide()
			self.humi.hide()
			#------------------------
			self.ball_icon.hide()		
			self.line.hide()		
			self.week01.hide()
			self.week02.hide()
			self.week03.hide()
			self.week04.hide()
			self.week05.hide()
			self.week06.hide()
			self.week07.hide()
			self.ref.hide()
			i =1
			while i <=42:				
				self.arr_cal[i].hide()
				self.arr_selcal[i].hide()
				i = i + 1
			
			self.ap.hide()
			self.colon.hide()
			self.hour1.hide()
			self.hour2.hide()
			self.min1.hide()
			self.min2.hide()
			self.year1.hide()
			self.year2.hide()
			self.year3.hide()
			self.year4.hide()
			self.month_long.hide()
			#self.month_short.hide()
			
	def Max_Month(self,month,year):
        	if month in [1,3,5,7,8,10,12]:
            		return 31
        	elif month in [4,6,9,11]:
            		return 30
        	elif (month == 2) and (year % 4 == 0):
            		return 29
        	elif (month == 2) and (year % 4 != 0):
            		return 28
	
	def update_calendar(self):
		debugLogC('idlestage.ui.update_calendar')
		import time,ntptime
		year,month,day,h,m,ss,w = time.localtime(setting.current_time)[:7]
		#self.month_short.file = uiconfig.image_dir + uiconfig.idle_month_short[month-1]
		self.year1.file = uiconfig.image_dir + uiconfig.idle_year[int(year/1000)]
		self.year1_02.file = uiconfig.image_dir + uiconfig.idle_year_02[int(year/1000)]
		self.year1_03.file = uiconfig.image_dir + uiconfig.idle_year_02[int(year/1000)]
		year = year % 1000
		self.year2.file = uiconfig.image_dir + uiconfig.idle_year[int(year/100)]
		self.year2_02.file = uiconfig.image_dir + uiconfig.idle_year_02[int(year/100)]
		self.year2_03.file = uiconfig.image_dir + uiconfig.idle_year_02[int(year/100)]
		year = year % 100
		self.year3.file = uiconfig.image_dir + uiconfig.idle_year[int(year/10)]	
		self.year3_02.file = uiconfig.image_dir + uiconfig.idle_year_02[int(year/10)]	
		self.year3_03.file = uiconfig.image_dir + uiconfig.idle_year_02[int(year/10)]
		
		year = year % 10
		self.year4.file = uiconfig.image_dir + uiconfig.idle_year[int(year)]
		self.year4_02.file = uiconfig.image_dir + uiconfig.idle_year_02[int(year)]
		self.year4_03.file = uiconfig.image_dir + uiconfig.idle_year_02[int(year)]
		
		self.month_02.file =uiconfig.image_dir + uiconfig.idle_day_02[month-1]	
		self.day_02.file =uiconfig.image_dir + uiconfig.idle_day_02[day-1]
		self.week_02.file = uiconfig.image_dir + uiconfig.idle_week_02[w]
		
		self.week_03.file  = uiconfig.image_dir + uiconfig.idle_week_03[w]		
		self.day_03.file = uiconfig.image_dir + uiconfig.idle_day_03[day -1]
		self.month_03.file = uiconfig.image_dir + uiconfig.idle_month03[month -1]
		self.month_long.file = uiconfig.image_dir +uiconfig.idle_month_long[month-1]
		
		c = time.localtime(time.mktime((year,month,1,h,m,0,0,0,0)))[6]		
		c = (c + 2) 
		if c > 7:
			c = c % 7
		i = 1
		while i < len(self.arr_cal):
			self.arr_cal[i].hide()
			self.arr_selcal[i].hide()
			i = i + 1
		d = 1
		i = c - 1
		j = 1
		while i >=1:
			if month == 1:
				self.arr_cal[i].file = uiconfig.image_dir + uiconfig.idle_pday[self.Max_Month(12,year) - j]
			else:
				self.arr_cal[i].file = uiconfig.image_dir + uiconfig.idle_pday[self.Max_Month(month -1,year) - j]
			self.arr_cal[i].show()
			i = i -1
			j = j + 1
		i = c
        	while d <= self.Max_Month(month,year):         
			if i % 7 ==1:
				self.arr_cal[i].file = uiconfig.image_dir + uiconfig.idle_ho[d-1]
				if d == day:
					self.arr_selcal[i].file = uiconfig.image_dir + uiconfig.idle_hdaysel[d-1]
					self.arr_selcal[i].show()
			else:
				self.arr_cal[i].file = uiconfig.image_dir + uiconfig.idle_day[d-1]
          			if d == day:
					self.arr_selcal[i].file = uiconfig.image_dir + uiconfig.idle_daysel[d-1]
					self.arr_selcal[i].show()
			self.arr_cal[i].show()
			d += 1
			i += 1
		j = 0
		while i <= 42:
			self.arr_cal[i].file = uiconfig.image_dir + uiconfig.idle_pday[j]
			self.arr_cal[i].show()
			i = i + 1
			j = j + 1
		if h >= 12:
			self.ap.file = uiconfig.image_dir + uiconfig.idle_pm[0]
			self.ap03.file = uiconfig.image_dir + uiconfig.idle_pm03[0]
		else:
			self.ap.file = uiconfig.image_dir + uiconfig.idle_am[0]
			self.ap03.file = uiconfig.image_dir + uiconfig.idle_am03[0]
		h = h % 12
		if h == 0:
			h = 12			
		
		self.hour1.file = uiconfig.image_dir +uiconfig.idle_time[int(h/10)]		
		self.hour2.file = uiconfig.image_dir +uiconfig.idle_time[int(h%10)]		
		self.min1.file = uiconfig.image_dir +uiconfig.idle_time[int(m/10)]			
		self.min2.file = uiconfig.image_dir +uiconfig.idle_time[int(m%10)]	
		self.hour1_03.file = uiconfig.image_dir +uiconfig.idle_time03[int(h/10)]		
		self.hour2_03.file = uiconfig.image_dir +uiconfig.idle_time03[int(h%10)]		
		self.min1_03.file = uiconfig.image_dir +uiconfig.idle_time03[int(m/10)]			
		self.min2_03.file = uiconfig.image_dir +uiconfig.idle_time03[int(m%10)]	
		
		self.hour_arrow.file = uiconfig.image_dir + uiconfig.idle_hour_arrow[(h % 12) * 6 +  int(m /10)]
		self.min_arrow.file  = uiconfig.image_dir +  uiconfig.idle_min_arrow[m]
          	self.ca = utils.Timer(10*1000,self.update_time)          	
          	idle_style = setting.idle_style          	
		self.display_idle_style(idle_style)
		
   	def update_time(self):
		import time,ntptime
		year,month,day,h,m,ss,w = time.localtime(setting.current_time)[:7]

		#print "[yylee debug] update_time",h, m, ss
		# check minute changed
		if status.current_display_hour == h and status.current_display_minute == m:
			self.ca = utils.Timer(10*1000,self.update_time)
			return
		else:
			status.current_display_hour = h
			status.current_display_minute = m
		#print "[yylee debug] update_display_time",status.current_display_hour, status.current_display_minute
			
		if h >= 12:
			self.ap.file = uiconfig.image_dir + uiconfig.idle_pm[0]
			self.ap03.file = uiconfig.image_dir + uiconfig.idle_pm03[0]
		else:
			self.ap.file = uiconfig.image_dir + uiconfig.idle_am[0]
			self.ap03.file = uiconfig.image_dir + uiconfig.idle_am03[0]
		h = h % 12
		if h == 0:
			h = 12
		if h in (12,1) and m in (0,1,2):
			self.update_calendar()
				
		self.hour1.file = uiconfig.image_dir +uiconfig.idle_time[int(h/10)]		
		self.hour2.file = uiconfig.image_dir +uiconfig.idle_time[int(h%10)]		
		self.min1.file = uiconfig.image_dir +uiconfig.idle_time[int(m/10)]			
		self.min2.file = uiconfig.image_dir +uiconfig.idle_time[int(m%10)]   
		self.hour1_03.file = uiconfig.image_dir +uiconfig.idle_time03[int(h/10)]		
		self.hour2_03.file = uiconfig.image_dir +uiconfig.idle_time03[int(h%10)]		
		self.min1_03.file = uiconfig.image_dir +uiconfig.idle_time03[int(m/10)]			
		self.min2_03.file = uiconfig.image_dir +uiconfig.idle_time03[int(m%10)]	
		#--------------------------------->
		self.hour_arrow.file = uiconfig.image_dir + uiconfig.idle_hour_arrow[(h % 12) * 6 +  int(m /10)]
		self.min_arrow.file  = uiconfig.image_dir +  uiconfig.idle_min_arrow[m]
		#--------------------------------->
		
   		#os.system('th_test_onetime.bin > /tmp/temperature.txt')
		#fp = open('/tmp/temperature.txt')
		#temperature = fp.readline().strip()
		#fp.close()		
		self.temper.text_set('16.45C')
		self.humi.text_set('6.45%')
		self.ca = utils.Timer(10*1000,self.update_time)
		idle_style = setting.idle_style
		self.display_idle_style(idle_style)
		
	def show_calendar(self):
		import time,ntptime
		year,month,day,h,m,ss,w = time.localtime(setting.current_time)[:7]
		#Thang [20080319 -1 ] display thirt idle
		name, pos = uiconfig.idle_calender_bg02
		self.calender_bg02 = utils.put_image(name, pos)
		self.add(self.calender_bg02)
		
		self.week_03 = utils.put_image(uiconfig.idle_week_03[w], (408, 79))
		self.add(self.week_03)
		self.day_03 = utils.put_image(uiconfig.idle_day_03[day -1], (411, 37))
		self.add(self.day_03)

		
		#Thang [20080319 -1 ] ===============
		#self.month_short = utils.put_image(uiconfig.idle_month_short[month-1],(325 , 13))
		#self.add(self.month_short)
		self.month_03 = utils.put_image(uiconfig.idle_month03[month-1],(443 , 9))
		self.add(self.month_03)
		
		name, pos = uiconfig.idle_ball_icon	
		self.ball_icon = utils.put_image(name, pos)
		self.add(self.ball_icon)		

		name, pos = uiconfig.idle_line
		self.line = utils.put_image(name, pos)
		self.add(self.line)

		name, pos = uiconfig.idle_week01
		self.week01 = utils.put_image(name, pos)
		self.add(self.week01)

		name, pos = uiconfig.idle_week02
		self.week02 = utils.put_image(name, pos)
		self.add(self.week02)

		name, pos = uiconfig.idle_week03
		self.week03 = utils.put_image(name, pos)
		self.add(self.week03)

		name, pos = uiconfig.idle_week04
		self.week04 = utils.put_image(name, pos)
		self.add(self.week04)

		name, pos = uiconfig.idle_week05
		self.week05 = utils.put_image(name, pos)
		self.add(self.week05)

		name, pos = uiconfig.idle_week06
		self.week06 = utils.put_image(name, pos)
		self.add(self.week06)

		name, pos = uiconfig.idle_week07
		self.week07 = utils.put_image(name, pos)
		self.add(self.week07)

		
		
		self.year1 = utils.put_image(uiconfig.idle_year[int(year/1000)],(369, 20))
		self.add(self.year1)
		self.year1_02 = utils.put_image(uiconfig.idle_year_02[int(year/1000)],uiconfig.idle_pos_year_02[0])
		self.add(self.year1_02)
		self.year1_03 = utils.put_image(uiconfig.idle_year_02[int(year/1000)],uiconfig.idle_pos_year_03[0])
		self.add(self.year1_03)
		
		year = year % 1000
		self.year2 = utils.put_image(uiconfig.idle_year[int(year/100)],(377, 20))
		self.add(self.year2)
		self.year2_02 = utils.put_image(uiconfig.idle_year_02[int(year/100)],uiconfig.idle_pos_year_02[1])
		self.add(self.year2_02)
		self.year2_03 = utils.put_image(uiconfig.idle_year_02[int(year/100)],uiconfig.idle_pos_year_03[1])
		self.add(self.year2_03)
		
		year = year % 100
		self.year3 = utils.put_image(uiconfig.idle_year[int(year/10)],(385, 20))
		self.add(self.year3)
		self.year3_02 = utils.put_image(uiconfig.idle_year_02[int(year/10)],uiconfig.idle_pos_year_02[2])
		self.add(self.year3_02)
		self.year3_03 = utils.put_image(uiconfig.idle_year_02[int(year/10)],uiconfig.idle_pos_year_03[2])
		self.add(self.year3_03)
		
		year = year % 10
		self.year4 = utils.put_image(uiconfig.idle_year[int(year)],(393, 20))
		self.add(self.year4)
		self.year4_02 = utils.put_image(uiconfig.idle_year_02[int(year)],uiconfig.idle_pos_year_02[3])
		self.add(self.year4_02)
		self.year4_03 = utils.put_image(uiconfig.idle_year_02[int(year)],uiconfig.idle_pos_year_03[3])
		self.add(self.year4_03)
		
		self.month_long = utils.put_image(uiconfig.idle_month_long[month-1],(406, 22))
		self.add(self.month_long)
		
		self.month_02 = utils.put_image(uiconfig.idle_day_02[month-1],uiconfig.idle_pos_day_02[0])
		self.add(self.month_02)

		self.day_02 = utils.put_image(uiconfig.idle_day_02[day-1],uiconfig.idle_pos_day_02[1])
		self.add(self.day_02)

		self.week_02 = utils.put_image(uiconfig.idle_week_02[w],uiconfig.idle_pos_day_02[2])
		self.add(self.week_02)
		
		
		################################
		self.arr_cal = []
		self.arr_selcal = []
		d = 1
		y = 58
		y_sel = 49
		
		x = 22
		
		i = 0		
		self.arr_cal.insert(0,'test')
		self.arr_selcal.insert(0,'test')
		co = 1
		while d <= 42:      		
          		
            		t =  utils.put_image(uiconfig.idle_day[0],(292 + x * co, y))			
			i = i + 1
			self.arr_cal.insert(i, t)
			self.add(self.arr_cal[i])    
			self.arr_cal[i].hide()
			t =  utils.put_image(uiconfig.idle_daysel[0],(284 + x * co, y_sel))	
			self.arr_selcal.insert(i, t)
			self.add(self.arr_selcal[i])    
			self.arr_selcal[i].hide()
			if co % 7 == 0:		
            			y = y + 15
            			y_sel = y_sel + 15
            			co = 0
            		d = d + 1	
            		co = co + 1	
		if h >= 12:
			name, pos = uiconfig.idle_pm
			name1,pos1 = uiconfig.idle_pm03 
		else:
			name, pos = uiconfig.idle_am
			name1,pos1 = uiconfig.idle_am03
		self.ap = utils.put_image(name,pos)
		self.ap03 = utils.put_image(name1,pos1)
		self.add(self.ap)
		self.add(self.ap03)
		h = h % 12
		if h == 0:
			h = 12
		name, pos = uiconfig.idle_time[int(h/10)],uiconfig.hour1_pos
		self.hour1 = utils.put_image(name,pos)
		self.add(self.hour1)
		name, pos = uiconfig.idle_time03[int(h/10)],uiconfig.hour1_pos03
		self.hour1_03 = utils.put_image(name,pos)
		self.add(self.hour1_03)
		
		name, pos = uiconfig.idle_time[int(h%10)],uiconfig.hour2_pos
		self.hour2 = utils.put_image(name,pos)
		self.add(self.hour2)
		name, pos = uiconfig.idle_time03[int(h%10)],uiconfig.hour2_pos03
		self.hour2_03 = utils.put_image(name,pos)
		self.add(self.hour2_03)

		
		name, pos = uiconfig.idle_colon
		self.colon = utils.put_image(name,pos)
		self.add(self.colon)
		name, pos = uiconfig.idle_colon03
		self.colon03 = utils.put_image(name,pos)
		self.add(self.colon03)
		
		name, pos = uiconfig.idle_time[int(m/10)],uiconfig.min1_pos
		self.min1 = utils.put_image(name,pos)
		self.add(self.min1)
		name, pos = uiconfig.idle_time03[int(m/10)],uiconfig.min1_pos03
		self.min1_03 = utils.put_image(name,pos)
		self.add(self.min1_03)
		
		name, pos = uiconfig.idle_time[int(m%10)],uiconfig.min2_pos
		self.min2 = utils.put_image(name,pos)
		self.add(self.min2)	
		name, pos = uiconfig.idle_time03[int(m%10)],uiconfig.min2_pos03
		self.min2_03 = utils.put_image(name,pos)
		self.add(self.min2_03)

		name, pos = uiconfig.idle_ref
		self.ref = utils.put_image(name, pos)
		self.add(self.ref)
		
		name, pos = uiconfig.idle_weather01
		self.weather01 = utils.put_image(name,pos)
		self.add(self.weather01)
		name, pos = uiconfig.idle_weather02
		self.weather02 = utils.put_image(name,pos)
		self.add(self.weather02)
		
		#Thang [20080317 -4 ]display clock in here
		name, pos = uiconfig.idle_clock_bg
		self.clock_bg = utils.put_image(name,pos)
		self.add(self.clock_bg)	
		self.hour_arrow = utils.put_image(uiconfig.idle_hour_arrow[(h % 12) * 6 +  int(m /10)],(366, 45))		
		self.add(self.hour_arrow)
		self.min_arrow = utils.put_image(uiconfig.idle_min_arrow[m],(354, 33))
		self.add(self.min_arrow)
		#Thang [20080317 -4 ]===============
		
		self.ca = utils.Timer(10*1000,self.update_time)
		idle_style = setting.idle_style
		self.display_idle_style(idle_style)

		status.current_display_hour = h
		status.current_display_minute = m
#Thang: [20080314 -1] show calendar clock, temper	
#Thang: [20080318 -1] show calendar clock, temper	

	def update_my_number(self):
		my_number = utils.conv_telnum(status.telnum)

		if len(my_number) > 25:
			my_number = my_number[:25]+'\n'+my_number[25:]

		if profile.profile.get_profile() == 1:
			import errorcode
	 		if len(runtime.idle_errmsg) > 0 and status.get_regstatus() == 0:
				my_number=runtime.idle_errmsg
	 			self.my_number.font = uiconfig.background_text_font
	 			self.my_number.set_text(my_number)
			elif not runtime.peek_lanlink():
				my_number = errorcode.ErrorCode('M101')
	 			self.my_number.font = uiconfig.background_text_font
	 			self.my_number.set_text(my_number)
				#status.registered_status = status.NotRegistered
			elif utils.get_address('eth')[0][1] == None and profile.lan_profile.get_dhcp():
	 			my_number = errorcode.ErrorCode('M301')
	 			self.my_number.font = uiconfig.background_text_font
	 			self.my_number.set_text(my_number)	 			
	 		#elif errorcode.get_idle_errmsg() == errorcode.msg_W103:
			elif errorcode.get_idle_errmsg() ==errorcode.msg_M102:
				# DHCP requesting...
				#my_number =  errorcode.msg_W103
				my_number =  errorcode.msg_M102
	 			self.my_number.font = uiconfig.background_text_font
	 			self.my_number.set_text(my_number)			
			elif errorcode.get_idle_errmsg() ==  errorcode.msg_SR480:
				my_number =  errorcode.msg_SR480
	 			self.my_number.font = uiconfig.background_text_font
	 			self.my_number.set_text(my_number)
			elif errorcode.get_idle_errmsg() ==  errorcode.msg_SR103:
				my_number =  errorcode.msg_SR103
	 			self.my_number.font = uiconfig.background_text_font
	 			self.my_number.set_text(my_number) 			
	 		elif status.get_regstatus() == 1:
	 			# subscriber fail event를 받은 경우 등록은 성공이지만 error msg를 display해줘야 한다. 
				if config.MYNUMBER_SHOW:
					self.my_number.font = uiconfig.idle_mynumber_font
					self.my_number.set_text(my_number)
				else:
					self.my_number.set_text('')
			else:
				import errorcode
				my_number = errorcode.ErrorCode('500')
	 			self.my_number.font = uiconfig.background_text_font
	 			self.my_number.set_text(my_number)
			
		elif profile.profile.get_profile() == 2:
			import errorcode
			if len(runtime.idle_errmsg) > 0 and status.get_regstatus() == 0:
				my_number = runtime.idle_errmsg
	 			self.my_number.font = uiconfig.background_text_font
	 			self.my_number.set_text(my_number)

			elif not runtime.peek_wifilink():
				my_number = errorcode.ErrorCode('W109')
				self.my_number.font = uiconfig.background_text_font
	 			self.my_number.set_text(my_number) 			
	 			#status.registered_status = status.NotRegistered
	 			
			elif utils.get_address('wlan')[0][1] == None: #and wifi_profile.get_dhcp():
				my_number= errorcode.ErrorCode('W104')
	 			self.my_number.font = uiconfig.background_text_font
	 			self.my_number.set_text(my_number)

	 		elif status.get_regstatus() == 1:
				if config.MYNUMBER_SHOW:
				#debugLogN('### name(%s), megaAPEnabled(%d)'%(profile.wifi_profile._name,setting.megaAPEnabled))
				#if profile.wifi_profile._name != 'MegaAP':
					if setting.megaAPEnabled == 0:
						if len(profile.wifi_profile.essid) > 28:
							my_number = my_number + '\n' + profile.wifi_profile.essid[:28] + '...'
						else:
							my_number = my_number + '\n' + profile.wifi_profile.essid
		 			self.my_number.font = uiconfig.idle_mynumber_font
		 			self.my_number.set_text(my_number)
	 			else:
	 				self.my_number.set_text('')
			else:
				import errorcode
				my_number = errorcode.ErrorCode('500')
	 			self.my_number.font = uiconfig.background_text_font
	 			self.my_number.set_text(my_number)

	def set_mwi_waiting(self, waiting):
		if waiting == 1:
			self.mwi_image.show()
		else:
			self.mwi_image.hide()

	def set_msg_waiting(self, waiting):
		if waiting == 1:
			self.mwi_image.show()
		else:
			self.mwi_image.hide()
			
	# Thang [20080315 - 2] Detroy calendar, temper
	def destroy(self):
		BaseUI.destroy(self)		
		self.ca = None
		self.update_register_tag = None
	
	def hide(self):
		if profile.profile.get_profile() != 2: # wifi profile
			self.update_register_tag = None
		BaseUI.hide(self)
		self.ca = None
		
	# Thang [20080315 - 2] Detroy calendar, temper
	def check_lastest_sms_type(self):
		from smsmanager import smsmgr
		lastest_msg_time = -1
		for file,t,read,ems,number, report,summary in smsmgr.get_received_messages():
			if read:
				continue
			if lastest_msg_time < 0:
				lastest_msg_time = t
			if t <= lastest_msg_time:
				lastest_msg_time = t
				if ems:
					setting.incoming_sms_type = 'ems'
				else:
					setting.incoming_sms_type = 'sms'

	def getRSSI(self):
#MMW	2008.07.20
		if status.wifi_connected == True :
			try :
				os.system('wlrssi')
				fp = open('/tmp/tmpRSSI')
				tmpRSSI = fp.read()
				fp.close()
				return abs(int(tmpRSSI[:2].strip()))
			except :
				print 'getRSSI error'
				return 0			
		else :
			return 0
		'''
		try:
			import os
#			pval = os.popen('wl isup').read()
			p = os.popen('wifi_assoc')
			pval=p.read()
			p.close()
			
			if int(pval) == 0: 
				return 0
			os.system('wlrssi')
			fp = open('/tmp/tmpRSSI')
			tmpRSSI = fp.read()
			fp.close()

#			wifi_status_timer()
			return abs(int(tmpRSSI[:2].strip()))
		except:
			return 0
		'''	
#end of MMW

	def update_register(self):
	#status.register_mode
		prof_current = profile.profile.get_profile()

		if not (runtime.manager.stage.name == 'idle' or status.supervision_idle == 1):
#			if prof_current == 2: # wifi profile
#				self.update_register_tag = utils.Timer(10000, wifi_status_timer)
			self.profile_image.hide()
		#	self.sip_image.hide()
			return True
		else:
			self.update_register_tag = None

		if prof_current == 0: # pstn profile
				self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_pstn[0]
		elif prof_current == 1: # lan profile
			if status.LanConnected:
				self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_lan[0]
			#	if status.registered_status == 1:
			#		self.sip_image.file = uiconfig.image_dir + uiconfig.idle_profile_lan_sip[0]
			#	else:
			#		self.sip_image.file = uiconfig.image_dir + uiconfig.idle_profile_lan_nosip[0]
			else:
				self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_lan_d[0]
			#	self.sip_image.file = uiconfig.image_dir + uiconfig.idle_profile_lan_nosip[0]
				
		elif prof_current == 2: # wifi profile
			val = self.getRSSI()
			if status.get_regstatus() == 1:
				if val == 0:				self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_d[0]
				elif 0 < val and val <= 55:	self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_5[0]
				elif 55 < val and val <= 65:	self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_4[0]
				elif 65 < val and val <= 75:	self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_3[0]
				elif 75 < val and val <= 85:	self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_2[0]
				else:					self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_1[0]
			else:
				if val == 0:				self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_d[0]
				elif 0 < val and val <= 55:	self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_nosip_5[0]
				elif 55 < val and val <= 65:	self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_nosip_4[0]
				elif 65 < val and val <= 75:	self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_nosip_3[0]
				elif 75 < val and val <= 85:	self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_nosip_2[0]
				else:					self.profile_image.file = uiconfig.image_dir + uiconfig.idle_profile_wifi_nosip_1[0]

		if self.profile_image:
			self.profile_image.show()
		#if self.sip_image:
		#	self.sip_image.show()

		if prof_current == 2: # wifi profile
			# per kt request 10 sec --> 3 sec
			#self.update_register_tag = utils.Timer(10000, self.update_register)
			self.update_register_tag = utils.Timer(3000, self.update_register)
		else:
			self.update_register_tag = utils.Timer(config.register_update_time, self.update_register)
		return False

	def update_sms_icon(self):
		if setting.sms_missed:
			self.sms_image.show()			
		else:
			self.sms_image.hide()
	
	def show(self):
		if not setting._current_timer:
			setting.init_time()
			setting.enable_ntp()
		BaseUI.show(self)
		self.update_calendar()
		self.update_my_number()
		#if not setting._agenda_tag:
		#	self.agenda_image.hide()

		show_alarm_image = False
		if not alarmdb.is_empty():
			for item in alarmdb.db:
				if  item[1] != _('Disable'):
					show_alarm_image = True

		if show_alarm_image:	self.alarm_image.show()
		else:				self.alarm_image.hide()

		if utils.is_srswow_enabled():
			setting.srswow_enable = 1
		else:
			setting.srswow_enable = 0
		if setting.srswow_enable == 1:	self.srswow_image.show()
		else:						self.srswow_image.hide()

		if setting.autoAnswer == 1:	self.absence_image.show()
		else:					self.absence_image.hide()
			
		#self.message_full.hide()

		self.update_sms_icon()			
		self.update_register()

		def align_center(l, pos):
			x, y = pos
			width,height = l.size
			l.move(x - width/2, y)

		from vdcisetting import vdci_setting
		if setting.ScreenTextEnable > 0:

			if setting.ScreenTextEnable == 1:
				self.ScreenText_text.text = setting.ScreenTextText
			elif setting.ScreenTextEnable == 2:
				self.ScreenText_text.text = utils.conv_telnum(vdci_setting.tel_num)
			if setting.ScreenTextAlign == 0:		pos = uiconfig.background_text_pos_up
			elif setting.ScreenTextAlign == 1:	pos = uiconfig.background_text_pos_center
			else:							pos = uiconfig.background_text_pos_down
		
			self.ScreenText_text.font = uiconfig.def_font, uiconfig.screen_text_size_list[setting.ScreenTextSizeIndex]
			self.ScreenText_text.color = uiconfig.screen_text_color_list[setting.ScreenTextColorIndex]
			align_center(self.ScreenText_text, pos)
			self.ScreenText_text.show()
		else:
			self.ScreenText_text.hide()

		def sms_image_update_KT():
			IdleUI.first = False
			if not (runtime.manager.stage.name == 'idle' or status.supervision_idle == 1):
				return False
			from smsmanager import smsmgr

			if 1 == profile.profile.get_profile() and smsmgr.count_unread():
				self.sms_image.show()

			def is_messagefull():
				if len(smsmgr.received_info) >= config.message_entry_max:
					return True
				return False
				
			if 1 == profile.profile.get_profile() and is_messagefull():
				self.sms_image.hide()
				self.message_full.show()
			return False

		def sms_image_update_KT():
			IdleUI.first = False
			if not (runtime.manager.stage.name == 'idle' or status.supervision_idle == 1):
				return False
				
			from smsmanager import smsmgr
			from mmsmanager import mmsmgr

			if 0 == profile.profile.get_profile() and (smsmgr.count_unread() or mmsmgr.count_unread()):
				self.sms_image.show()

			def is_messagefull():
				from mmsconfig import mms_message_entry_max
				from mmsmanager import mmsmgr
				if len(smsmgr.received_info) >= config.message_entry_max \
					or len(mmsmgr.inbox_info) >= mms_message_entry_max:
					return True
				return False

			if is_messagefull():
				self.sms_image.hide()
				self.message_full.show()
			return False

		#if self.first:
		#	runtime.evas.timeout_add(100, sms_image_update_KT)
		#else:
		#	sms_image_update_KT()

#Roxia Begin jhbang 06.03.29
		#if profile.ip_mode == 1 or not setting.reserved_number_filter:
#Roxia End jhbang
		#	self.reserved_filter_image.hide()
		#if not setting.vip_filter:
		#	self.vip_filter_image.hide()
		#if not setting.ringing_mode == 1:
		#	self.sound_disable_image.hide()

		#import calldb
		#if not calldb.has_unread_missed_call():
		if status.missed_call_count == 0:
			self.missed_call_image.hide()

		#self.update_video_supervision()
		#if profile.ip_mode == 0: # pstn
		#	self.set_msg_waiting(setting.msg_waiting)
		#else:
		#	self.set_mwi_waiting(setting.mwi_waiting)

		
	def update_video_supervision(self):
		if profile.ip_mode == 0: # pstn
			self.video_supervision.hide()
			return

		if not (runtime.manager.stage.name == 'idle' or status.supervision_idle == 1):
			self.video_supervision.hide()
			return

		if setting.video_supervision_enable:
			self.video_supervision.show()
		else:
			self.video_supervision.hide()


class MissedIncomingCallUI(BaloonMessageUI):
	show_bg = True
	def __init__(self, number, time=''):
		icon = uiconfig.baloon_call_log_icon
		comment =  _('Missed calls') + " %d" % status.missed_call_count + _('Call.')
		if number.isdigit():
			telnum = utils.conv_telnum(number)
		else:
			telnum = number
		message = comment + '\n' + telnum + '\n' + time
	
		BaloonMessageUI.__init__(self, _('SHOW'), '', '', icon, message,'', _('EXIT'))

#		name, pos = uiconfig.idle_missed_call_icon
#		self.missed_call_image = utils.put_image(name, pos)
#		self.add(self.missed_call_image)

#		#Roxia Begin cmlim 06.04.11
#		name, pos = uiconfig.idle_mwi_icon
#		self.mwi_image = utils.put_image(name, pos)
#		self.add(self.mwi_image)
#		#Roxia End cmlim 06.04.11

	#Roxia Begin cmlim 06.04.11
	def set_msg_waiting(self, waiting):
		if waiting == 1:
			self.mwi_image.show()
		else:
			self.mwi_image.hide()
	#Roxia End cmlim 06.04.11

	#Roxia Begin cmlim 06.04.13
	def set_mwi_waiting(self, waiting):
		self.set_msg_waiting(waiting)
	#Roxia End cmlim 06.04.13

	def show(self):
		BaloonMessageUI.show(self)
		#Roxia Begin cmlim 06.04.11
#		if 0 == profile.ip_mode:
#			self.set_msg_waiting(setting.msg_waiting)
#		#Roxia Begin cmlim 06.04.13
#		else:
#			self.set_mwi_waiting(setting.mwi_waiting)
#		#Roxia End cmlim 06.04.13
#		#Roxia End cmlim 06.04.11

	def destroy(self):
		BaloonMessageUI.destroy(self)

	def hide(self):
		BaloonMessageUI.hide(self)


# KA: [20080523] VM SMS수신
class MessageNotifyUI(BaloonMessageUI):
	show_bg = True
	def __init__(self, msg):
		icon = uiconfig.baloon_message_sms_icon
		BaloonMessageUI.__init__(self, _('SHOW'), '', '', icon, msg, '', _('EXIT'))

	def show(self):
		BaloonMessageUI.show(self)

	def destroy(self):
		BaloonMessageUI.destroy(self)

	def hide(self):
		BaloonMessageUI.hide(self)

# KA: [20080523] VM SMS수신


class CallingUI(NotifyCallUI):
	show_bg = True
	def __init__(self, number, video=False):
		icon = uiconfig.connected_icon
		if video:
			message1 = _('Calling video to') + ':'
		else:
			message1 = _('Calling to') + ':'
		message2 = number
		NotifyCallUI.__init__(self, '', '', '', message1, message2, icon)

class DirectAudioCallingUI(BaseUI):
	def __init__(self, number):
		BaseUI.__init__(self, '', '', '')

		self.animationTimer = None
		self.outgoingCallAnimation = []
		self.numberOfFrame = len(uiconfig.outgoing_call_ani)
		
		for imageFrame in uiconfig.outgoing_call_ani:
			animationframe = utils.put_image(imageFrame, uiconfig.outgoing_call_ani_pos)
			animationframe.hide()
			self.outgoingCallAnimation.append(animationframe)
		self.animationIndex = -1

		icon, pos = uiconfig.call_info
		self.callInfo = utils.put_image(icon, pos)
		self.add(self.callInfo)

		icon, pos = uiconfig.call_info_bar
		self.callInfoBar = utils.put_image(icon, pos)
		self.add(self.callInfoBar)

		messagePrefix = _('Audio call connecting...')
		self.messagePrefix = runtime.evas.text(text=messagePrefix,
			font=uiconfig.call_info_bar_font,
			pos=uiconfig.call_info_bar_text_pos,
			color=uiconfig.call_info_bar_text_color)
		self.add(self.messagePrefix)

		self.name = None
		self.number = None

		callerNumber = number
		from phonedb import phonedb
		callerName = phonedb.get_name(callerNumber)
		if callerName == 'anonymous':
			hangleMessage = _('No Caller information') #_('발신자 정보 없음')
			nameText = unicode(hangleMessage, 'euc-kr').encode('utf-8')
			self.name = runtime.evas.text(text=_('Anonymous'), #nameText,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
		elif callerName == '' or callerName == callerNumber:
			#callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
		else:		
			if len(unicode(callerName, 'utf-8')) > 8:
				callerName = unicode(callerName, 'utf-8')[:7].encode('utf-8') + '...'
			self.name = runtime.evas.text(text=callerName,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)

			#callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)

		self.hour = 0
		self.minute = 0
		self.second = 0
		callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second) 
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)

		status.currentCallDuration = (0, 0, 0)
		status.currentCallDuration_copy = (0, 0, 0)

		self.avata= None
		from phonedb import phonedb
		if callerNumber:
			avata = phonedb.get_snapshot2(callerNumber)
		else:
			avata = None
		self.set_avata(avata)

		icon, pos = uiconfig.audio_call_info_icon
		self.audioCallInfoIcon = utils.put_image(icon, pos)
		self.add(self.audioCallInfoIcon)
		
		icon, pos = uiconfig.outgoing_icon
		self.outgoingIcon = utils.put_image(icon, pos)
		self.add(self.outgoingIcon)

		icon, pos = uiconfig.outgoing_text_icon
		self.outgoingTextIcon = utils.put_image(icon, pos)
		self.add(self.outgoingTextIcon)
		
		icon, pos = uiconfig.timer_icon
		self.timerIcon = utils.put_image(icon, pos)
		self.add(self.timerIcon)

		icon, pos = uiconfig.timer_text_icon
		self.timerTextIcon = utils.put_image(icon, pos)
		self.add(self.timerTextIcon)

		icon, pos = uiconfig.frame_image
		self.frameImage = utils.put_image(icon, pos)
		self.add(self.frameImage)
		
	def set_avata(self, avata):
		if not avata:
			self.avata = utils.put_image(uiconfig.no_photo, uiconfig.avata_pos)
		else:
			self.avata = utils.put_image(avata, uiconfig.avata_pos)
		x, y = uiconfig.avata_pos
		w, h = uiconfig.avata_size
		utils.image_center_sized(self.avata, x + w/2, y + h/2, w, h)
		self.add(self.avata)

	def show(self):	
		BaseUI.show(self)
		
		if not self.animationTimer:
			self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)

	def animationTimer_callback(self):
		if not self.animationTimer:
			return
			
		if self.animationIndex == -1:
			self.animationIndex += 1
		else:
			self.outgoingCallAnimation[self.animationIndex].hide()
			self.animationIndex += 1
			if self.animationIndex > self.numberOfFrame-1:
				self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		if self.animationTimer:
			self.animationTimer = None
		self.animationTimer = utils.Timer(500, self.animationTimer_callback)

		return True

	def callDurationTimer_callback(self):
		if not self.callDurationTimer:
			return

		if self.time:
			self.time.hide()
			self.remove(self.time)
			self.time = None

		self.second = self.second + 1
		if self.second >= 60:
			self.minute = self.minute + 1
			self.second = 0
		if self.minute >= 60:
			self.hour = self.hour + 1
			self.minute = 0
		callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second)
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)
		self.time.show()

		'''
		if self.callDurationTimer:
			self.callDurationTimer = None
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)
		'''
		
		import time,ntptime
		callInfoMinute = time.localtime(ntptime.ntime())[5]
		if callInfoMinute != self.callInfoMinute:
			self.changeCallInfoDate()

		return True

	def changeCallInfoDate(self):
		if self.callInfoDate:
			self.callInfoDate.hide()
			self.remove(self.callInfoDate)
			self.callInfoDate = None

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)
		self.callInfoDate.show()

		return True

	def setCurrentTime(self):
		import status
		status.currentCallDuration = (self.hour, self.minute, self.second)
		
	def hide(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex
		BaseUI.hide(self)
		
		for animationframe in self.outgoingCallAnimation:
			animationframe.hide()

	def destroy(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex
		BaseUI.destroy(self)
		
		for animationframe in self.outgoingCallAnimation:
			animationframe.free()

class DirectVideoCallingUI(BaseUI):
	def __init__(self, number):
		BaseUI.__init__(self, '', '', '')

		self.animationTimer = None
		self.outgoingCallAnimation = []
		self.numberOfFrame = len(uiconfig.outgoing_call_ani)
		
		for imageFrame in uiconfig.outgoing_call_ani:
			animationframe = utils.put_image(imageFrame, uiconfig.outgoing_call_ani_pos)
			animationframe.hide()
			self.outgoingCallAnimation.append(animationframe)
		self.animationIndex = -1

		icon, pos = uiconfig.call_info
		self.callInfo = utils.put_image(icon, pos)
		self.add(self.callInfo)

		icon, pos = uiconfig.call_info_bar
		self.callInfoBar = utils.put_image(icon, pos)
		self.add(self.callInfoBar)

		messagePrefix = _('Video call connecting...')
		self.messagePrefix = runtime.evas.text(text=messagePrefix,
			font=uiconfig.call_info_bar_font,
			pos=uiconfig.call_info_bar_text_pos,
			color=uiconfig.call_info_bar_text_color)
		self.add(self.messagePrefix)

		self.name = None
		self.number = None

		# caller가 아니라 dialer이어야 함.
		callerNumber = number
		from phonedb import phonedb
		callerName = phonedb.get_name(callerNumber)
		print 'callerNumber = ', callerNumber
		print 'callerName = ', callerName
		if callerName == 'anonymous':
			hangleMessage = _('No Caller information') # _('발신자 정보 없음')
			nameText = unicode(hangleMessage, 'euc-kr').encode('utf-8')
			self.name = runtime.evas.text(text=nameText,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
		elif callerName == '' or callerName == callerNumber:
			#callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
		else:		
			if len(unicode(callerName, 'utf-8')) > 8:
				callerName = unicode(callerName, 'utf-8')[:7].encode('utf-8') + '...'
			self.name = runtime.evas.text(text=callerName,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)

			#callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)

		self.hour = 0
		self.minute = 0
		self.second = 0
		callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second) 
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)

		status.currentCallDuration = (0, 0, 0)
		status.currentCallDuration_copy = (0, 0, 0)

		icon, pos = uiconfig.video_call_info_icon
		self.videoCallInfoIcon = utils.put_image(icon, pos)
		self.add(self.videoCallInfoIcon)		
		
		icon, pos = uiconfig.outgoing_icon
		self.outgoingIcon = utils.put_image(icon, pos)
		self.add(self.outgoingIcon)

		icon, pos = uiconfig.outgoing_text_icon
		self.outgoingTextIcon = utils.put_image(icon, pos)
		self.add(self.outgoingTextIcon)
		
		icon, pos = uiconfig.timer_icon
		self.timerIcon = utils.put_image(icon, pos)
		self.add(self.timerIcon)

		icon, pos = uiconfig.timer_text_icon
		self.timerTextIcon = utils.put_image(icon, pos)
		self.add(self.timerTextIcon)

		icon, pos = uiconfig.frame_image
		self.frameImage = utils.put_image(icon, pos)
		self.add(self.frameImage)

		self.avata= None
		if callerNumber:
			avata = phonedb.get_snapshot2(callerNumber)
		else:
			avata = None
		self.set_avata(avata)

	def stopCallDuration(self):
		status.currentCallDuration = (self.hour, self.minute, self.second)
		status.currentCallDuration_copy = status.currentCallDuration
		self.callDurationTimer = None		

	def set_avata(self, avata):
		if not avata:
			self.avata = utils.put_image(uiconfig.no_photo, uiconfig.avata_pos)
		else:
			self.avata = utils.put_image(avata, uiconfig.avata_pos)
		x, y = uiconfig.avata_pos
		w, h = uiconfig.avata_size
		utils.image_center_sized(self.avata, x + w/2, y + h/2, w, h)
		self.add(self.avata)

	def show(self):	
		BaseUI.show(self)
		
		if not self.animationTimer:
			self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)

	def animationTimer_callback(self):
		if not self.animationTimer:
			return
			
		if self.animationIndex == -1:
			self.animationIndex += 1
		else:
			self.outgoingCallAnimation[self.animationIndex].hide()
			self.animationIndex += 1
			if self.animationIndex > self.numberOfFrame-1:
				self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		'''
		if self.animationTimer:
			runtime.evas.timeout_remove(self.animationTimer)
		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		'''
		
		return True

	def callDurationTimer_callback(self):
		if not self.callDurationTimer:
			return

		if self.time:
			self.time.hide()
			self.remove(self.time)
			self.time = None

		self.second = self.second + 1
		if self.second >= 60:
			self.minute = self.minute + 1
			self.second = 0
		if self.minute >= 60:
			self.hour = self.hour + 1
			self.minute = 0
		callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second)
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)
		self.time.show()

		'''
		if self.callDurationTimer:
			self.callDurationTimer = None
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)
		'''
		
		import time,ntptime
		callInfoMinute = time.localtime(ntptime.ntime())[5]
		if callInfoMinute != self.callInfoMinute:
			self.changeCallInfoDate()

		return True

	def setCurrentTime(self):
		import status
		status.currentCallDuration = (self.hour, self.minute, self.second)

	def changeCallInfoDate(self):
		if self.callInfoDate:
			self.callInfoDate.hide()
			self.remove(self.callInfoDate)
			self.callInfoDate = None

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)
		self.callInfoDate.show()

		return True

	def hide(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex
		BaseUI.hide(self)
		
		for animationframe in self.outgoingCallAnimation:
			animationframe.hide()

	def destroy(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex
		BaseUI.destroy(self)
		
		for animationframe in self.outgoingCallAnimation:
			animationframe.free()

class CallingUI2_old(NotifyCallUI):
	show_bg = True
	def __init__(self, number, video=False):
		self.video = video
		if video:
			message1 = _('Calling video to') + ':'
		else:
			message1 = _('Calling to') + ':'
		message2 = number
		NotifyCallUI.__init__(self, '', '', '', message1, message2)
		self.outgoing_ani = []
		if video:
			self.outgoing_ani = utils.put_image(uiconfig.video_outgoing_icon_ani[0], uiconfig.outgoing_icon_ani_pos)
		else:
			self.outgoing_ani = utils.put_image(uiconfig.outgoing_icon_ani[0], uiconfig.outgoing_icon_ani_pos)
		self.add(self.outgoing_ani)
		self.ani_count = 0
		self.ani_timer = None

	def show(self):
		NotifyCallUI.show(self)
		if not self.ani_timer:
			self.ani_count = 0
		if self.video:
			self.outgoing_ani.file = uiconfig.image_dir + uiconfig.video_outgoing_icon_ani[self.ani_count]
		else:
			self.outgoing_ani.file = uiconfig.image_dir + uiconfig.outgoing_icon_ani[self.ani_count]
		self.ani_timer = utils.Timer(500, self.ani_timer_cb)

	def ani_timer_cb(self):
		if not self.ani_timer:
			return
		if self.ani_count == -1:
			self.ani_count += 1
		else:
			self.ani_count += 1
			if self.ani_count > 3:
				self.ani_count = 0
		if self.video:
			self.outgoing_ani.file = uiconfig.image_dir + uiconfig.video_outgoing_icon_ani[self.ani_count]
		else:
			self.outgoing_ani.file = uiconfig.image_dir + uiconfig.outgoing_icon_ani[self.ani_count]
		return True

	def hide(self):
		self.ani_timer = None
		status.outgoing_ani_index = self.ani_count
		NotifyCallUI.hide(self)

	def destroy(self):
		self.ani_timer = None
		status.outgoing_ani_index = self.ani_count
		NotifyCallUI.destroy(self)

class TerminatedCallUI(NotifyCallUI):
	show_bg = True
	def __init__(self, number):
		icon = uiconfig.baloon_terminated_icon
		message1 = _('Call terminated') + ':'
		message2 = number
		NotifyCallUI.__init__(self, '', '', '', message1, message2, icon)

class CallProhibitUI(NotifyUI):
	show_bg = True
	def __init__(self, message):
		icon = uiconfig.baloon_calling_icon
		NotifyUI.__init__(self, message, icon)

class CallLimitedUI(NotifyCallUI):
	show_bg = True
	def __init__(self, number):
		icon = uiconfig.baloon_calling_icon
		message1 = _('Service not available')
		message2 = number

		NotifyCallUI.__init__(self, '', '', '', message1, message2, icon)

class CallBarringUI(NotifyCallUI):
	show_bg = True
	def __init__(self, number):
		icon = uiconfig.baloon_calling_icon
		message1 = _('Number blocked')
		# 발신 제한 번호를 보여주지 않음.
		message2 = ''
		NotifyCallUI.__init__(self, '', '', '', message1, message2, icon)

class CallConnectingUI(BaseUI):
	show_bg = True
	def __init__(self, caller=None, video=None):
		BaseUI.__init__(self, '', '', '')

		if caller:
			caller = caller.strip()
			
		number = status.caller_number

		self.animationTimer = None
		self.outgoingCallAnimation = []
		self.numberOfFrame = len(uiconfig.incoming_call_ani)
		
		for imageFrame in uiconfig.incoming_call_ani:
			animationframe = utils.put_image(imageFrame, uiconfig.incoming_call_ani_pos)
			animationframe.hide()
			self.outgoingCallAnimation.append(animationframe)
		self.animationIndex = -1

		icon, pos = uiconfig.call_info
		self.callInfo = utils.put_image(icon, pos)
		self.add(self.callInfo)

		icon, pos = uiconfig.call_info_bar
		self.callInfoBar = utils.put_image(icon, pos)
		self.add(self.callInfoBar)

		if video == '1':
			messagePrefix = _('Video call connecting...')
		elif video == '2':
			messagePrefix = _('Connecting HM')
		else:
			messagePrefix = _('Audio call connecting...')

		self.messagePrefix = runtime.evas.text(text=messagePrefix,
			font=uiconfig.call_info_bar_font,
			pos=uiconfig.call_info_bar_text_pos,
			color=uiconfig.call_info_bar_text_color)
		self.add(self.messagePrefix)

		self.name = None
		self.number = None

		callerName = status.display_caller_name(status.active_call_index)
		callerNumber = status.display_caller_number(status.active_call_index)
		if callerName.find('anonymous') != -1:
			self.name = runtime.evas.text(text=_('Anonymous'),
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
		elif callerName == '' or callerName == callerNumber:
			callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
		else:		
			if len(unicode(callerName, 'utf-8')) > 8:
				callerName = unicode(callerName, 'utf-8')[:7].encode('utf-8') + '...'
			self.name = runtime.evas.text(text=callerName,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)

			callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)

		if status.currentCallDuration == (0, 0, 0):
			self.hour = 0
			self.minute = 0
			self.second = 0
			callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second) 
		else:
			self.hour, self.minute, self.second = status.currentCallDuration
			callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second) 
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)

		self.avata= None
		from phonedb import phonedb
		if callerNumber:
			avata = phonedb.get_snapshot2(callerNumber)
		else:
			avata = None
		self.set_avata(avata)

		if video == '1' or video == '2':
			icon, pos = uiconfig.video_call_info_icon
			self.videoCallInfoIcon = utils.put_image(icon, pos)
			self.add(self.videoCallInfoIcon)
		else:
			icon, pos = uiconfig.audio_call_info_icon
			self.audioCallInfoIcon = utils.put_image(icon, pos)
			self.add(self.audioCallInfoIcon)

		icon, pos = uiconfig.incoming_icon
		self.outgoingIcon = utils.put_image(icon, pos)
		self.add(self.outgoingIcon)

		icon, pos = uiconfig.incoming_text_icon
		self.outgoingTextIcon = utils.put_image(icon, pos)
		self.add(self.outgoingTextIcon)
		
		icon, pos = uiconfig.timer_icon
		self.timerIcon = utils.put_image(icon, pos)
		self.add(self.timerIcon)

		icon, pos = uiconfig.timer_text_icon
		self.timerTextIcon = utils.put_image(icon, pos)
		self.add(self.timerTextIcon)

		icon, pos = uiconfig.frame_image
		self.frameImage = utils.put_image(icon, pos)
		self.add(self.frameImage)

	def show(self):	
		BaseUI.show(self)
		
		if not self.animationTimer:
			self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)

	def setCurrentTime(self):
		import status
		status.currentCallDuration = (self.hour, self.minute, self.second)
		
	def animationTimer_callback(self):
		if not self.animationTimer:
			return
			
		if self.animationIndex == -1:
			self.animationIndex += 1
		else:
			self.outgoingCallAnimation[self.animationIndex].hide()
			self.animationIndex += 1
			if self.animationIndex > self.numberOfFrame-1:
				self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		'''
		if self.animationTimer:
			self.animationTimer = None
		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		'''
		
		return True

	def callDurationTimer_callback(self):
		if not self.callDurationTimer:
			return

		if self.time:
			self.time.hide()
			self.remove(self.time)
			self.time = None

		self.second = self.second + 1
		if self.second >= 60:
			self.minute = self.minute + 1
			self.second = 0
		if self.minute >= 60:
			self.hour = self.hour + 1
			self.minute = 0
		callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second)
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)
		self.time.show()

		'''
		if self.callDurationTimer:
			self.callDurationTimer = None
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)
		'''
		
		import time,ntptime
		callInfoMinute = time.localtime(ntptime.ntime())[5]
		if callInfoMinute != self.callInfoMinute:
			self.changeCallInfoDate()

		return True

	def changeCallInfoDate(self):
		if self.callInfoDate:
			self.callInfoDate.hide()
			self.remove(self.callInfoDate)
			self.callInfoDate = None

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)
		self.callInfoDate.show()

		return True

	def setCurrentTime(self):
		import status
		status.currentCallDuration = (self.hour, self.minute, self.second)

	def hide(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex
		BaseUI.hide(self)
		
		for animationframe in self.outgoingCallAnimation:
			animationframe.hide()

	def destroy(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex
		BaseUI.destroy(self)
		
		for animationframe in self.outgoingCallAnimation:
			animationframe.free()

	def set_avata(self, avata):
		if not avata:
			self.avata = utils.put_image(uiconfig.no_photo, uiconfig.avata_pos)
		else:
			self.avata = utils.put_image(avata, uiconfig.avata_pos)
		x, y = uiconfig.avata_pos
		w, h = uiconfig.avata_size
		utils.image_center_sized(self.avata, x + w/2, y + h/2, w, h)
		self.add(self.avata)

class IncomingUI(BaseUI):
	show_bg = True
	VIDEO_LAYER = 1

	ANIMATION = 1
	ONE_PICTURE = 2
	
	def __init__(self, caller_name=None, avata=None, reject_on=True, video=None, myCardInfo=None):
		BaseUI.__init__(self)

		self.video = video
		self.myCardInfo = myCardInfo
		#number = status.caller_number
		self.myCardText = ''
		self.myCardTextString = ''
		self.isMyCardMarqueeText = False
		self.myCardTextLength = 0
		self.myCardTextCurrentIndex = 0
		
		self.animationTimer = None
		self.animationInterval = 500
		self.outgoingCallAnimation = []

		self.mmcidType = None

		#import utils		
		if myCardInfo:
			#print 'myCardInfo = ===> ', myCardInfo
			imageInfo, self.myCardTextString = myCardInfo
			if self.myCardTextString:
				self.myCardTextLength = len(self.myCardTextString)
				self.myCardTextCurrentIndex = 0
				#import utils
				icon, pos = uiconfig.my_card_text_bg_icon
				self.myCardTextBg = utils.put_image(icon, pos)
				self.myCardTextBg.layer = 2 # on the video screen
				self.add(self.myCardTextBg)

				self.myCardText = runtime.evas.text(text=self.myCardTextString, \
					font=uiconfig.my_card_text_font, \
					pos=uiconfig.my_card_text_pos, \
					color=uiconfig.my_card_text_font_color)
				if self.myCardText.geometry[2] > 348:
					self.isMyCardMarqueeText = True
					#import utils
					myCardMarqueeTextString, font = utils.cut_text(self.myCardTextString, uiconfig.my_card_text_width, uiconfig.my_card_text_font)
					self.myCardText = runtime.evas.text(text=myCardMarqueeTextString, \
						font=uiconfig.my_card_text_font, \
						pos=uiconfig.my_card_text_pos, \
						color=uiconfig.my_card_text_font_color)
				self.myCardText.layer = 2
				self.add(self.myCardText)

			fileName, numberOfFrame, delayTime, frameFileList = imageInfo
			if int(numberOfFrame) > 1:
				self.mmcidType = self.ANIMATION

				imageFrames = frameFileList
				self.animationInterval = delayTime
				self.numberOfFrame = int(numberOfFrame)

				for imageFrame in imageFrames:
					#import utils
					animationframe = utils.put_image(imageFrame, uiconfig.incoming_call_ani_pos)
					animationframe.hide()
					self.outgoingCallAnimation.append(animationframe)
				self.animationIndex = -1
			else:
				self.mmcidType = self.ONE_PICTURE
				onePictureImage = utils.put_image(fileName, uiconfig.incoming_call_ani_pos)
				onePictureImage.hide()
				self.add(onePictureImage)
				
		else:
			self.mmcidType = self.ANIMATION
			imageFrames = uiconfig.incoming_call_ani
			self.numberOfFrame = len(uiconfig.incoming_call_ani)

			for imageFrame in imageFrames:
				#import utils
				animationframe = utils.put_image(imageFrame, uiconfig.incoming_call_ani_pos)
				animationframe.hide()
				self.outgoingCallAnimation.append(animationframe)
			self.animationIndex = -1
			
		icon, pos = uiconfig.call_info
		self.callInfo = utils.put_image(icon, pos)
		self.add(self.callInfo)

		icon, pos = uiconfig.call_info_bar
		self.callInfoBar = utils.put_image(icon, pos)
		self.add(self.callInfoBar)

		callerNumber = status.display_caller_number(status.active_call_index)
		if setting.in_restrict and (callerNumber in setting.in_restrict_nums):
			messagePrefix = _('restricted number')

			self.messagePrefix = runtime.evas.text(text=messagePrefix,
				font=uiconfig.call_info_bar_font,
				pos=uiconfig.call_info_bar_text_pos,
				color=uiconfig.call_info_bar_text_color)
			self.add(self.messagePrefix)
		else:
			if video == '1':
				messagePrefix = _('Video call arrived')
			elif video == '2':
				messagePrefix = _('Incoming HM')
			else:
				messagePrefix = _('Audio call arrived')

			self.messagePrefix = runtime.evas.text(text=messagePrefix,
				font=uiconfig.call_info_bar_font,
				pos=uiconfig.call_info_bar_text_pos,
				color=uiconfig.call_info_bar_text_color)
			self.add(self.messagePrefix)

		self.name = None
		self.number = None

		callerName = caller_name
		if callerName.find('anonymous') != -1:
			self.name = runtime.evas.text(text=_('Anonymous'),
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
		elif callerName == '':
			callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
		else:		
			if len(unicode(callerName, 'utf-8')) > 8:
				callerName = unicode(callerName, 'utf-8')[:7].encode('utf-8') + '...'
			self.name = runtime.evas.text(text=callerName,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)

			callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)
		
		self.hour = 0
		self.minute = 0
		self.second = 0
		callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second) 
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)

		self.avata= None
		self.set_avata(avata)			
			
		if video == '1' or video == '2':
			icon, pos = uiconfig.video_call_info_icon
			self.videoCallInfoIcon = utils.put_image(icon, pos)
			self.add(self.videoCallInfoIcon)
		else:
			icon, pos = uiconfig.audio_call_info_icon
			self.audioCallInfoIcon = utils.put_image(icon, pos)
			self.add(self.audioCallInfoIcon)
		
		icon, pos = uiconfig.incoming_icon
		self.outgoingIcon = utils.put_image(icon, pos)
		self.add(self.outgoingIcon)

		icon, pos = uiconfig.incoming_text_icon
		self.outgoingTextIcon = utils.put_image(icon, pos)
		self.add(self.outgoingTextIcon)
		
		icon, pos = uiconfig.timer_icon
		self.timerIcon = utils.put_image(icon, pos)
		self.add(self.timerIcon)

		icon, pos = uiconfig.timer_text_icon
		self.timerTextIcon = utils.put_image(icon, pos)
		self.add(self.timerTextIcon)

		icon, pos = uiconfig.frame_image
		self.frameImage = utils.put_image(icon, pos)
		self.add(self.frameImage)

	def setCurrentTime(self):
		import status
		status.currentCallDuration = (self.hour, self.minute, self.second)

	def show(self):	
		BaseUI.show(self)

		#import utils
		if self.mmcidType == self.ANIMATION:
			#import utils		
			if not self.animationTimer:
				self.animationIndex = 0
			self.outgoingCallAnimation[self.animationIndex].show()
			self.animationTimer = utils.Timer(self.animationInterval, self.animationTimer_callback)
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)

		if self.myCardInfo:
			self.myCardTimer = utils.Timer(3000, self.hideNotifyMessage_callback)
			
		if self.isMyCardMarqueeText:
			self.myCardTextTimer = utils.Timer(250, self.showMyCardText_callback)	
		
		if self.avata:
			self.avata.show()

	def set_avata(self, avata):
		if not avata:
			self.avata = utils.put_image(uiconfig.no_photo, uiconfig.avata_pos)
		else:
			self.avata = utils.put_image(avata, uiconfig.avata_pos)
		x, y = uiconfig.avata_pos
		w, h = uiconfig.avata_size
		utils.image_center_sized(self.avata, x + w/2, y + h/2, w, h)
		self.add(self.avata)

	def clearVideoSetting(self):
		runtime.evas.use_transparency(False)
		self.smallView.hide()
		self.callInfo.show()

	def hideNotifyMessage_callback(self):
		self.callInfoBar.hide()
		self.messagePrefix.hide()
		if self.video == '1' or self.video == '2':
			self.videoCallInfoIcon.hide()
		else:
			self.audioCallInfoIcon.hide()
		self.myCardTimer= None
		
	def animationTimer_callback(self):
		if not self.animationTimer:
			return
			
		if self.animationIndex == -1:
			self.animationIndex += 1
		else:
			self.outgoingCallAnimation[self.animationIndex].hide()
			self.animationIndex += 1
			if self.animationIndex > self.numberOfFrame-1:
				self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		if self.animationTimer:
			self.animationTimer = None
		self.animationTimer = utils.Timer(self.animationInterval, self.animationTimer_callback)

		return True

	def callDurationTimer_callback(self):
		if not self.callDurationTimer:
			return

		if self.time:
			self.time.hide()
			self.remove(self.time)
			self.time = None

		self.second = self.second + 1
		if self.second >= 60:
			self.minute = self.minute + 1
			self.second = 0
		if self.minute >= 60:
			self.hour = self.hour + 1
			self.minute = 0
		callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second)
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)
		self.time.show()

		if self.callDurationTimer:
			self.callDurationTimer = None
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)

		import time,ntptime
		callInfoMinute = time.localtime(ntptime.ntime())[5]
		if callInfoMinute != self.callInfoMinute:
			self.changeCallInfoDate()

		return True

	def changeCallInfoDate(self):
		if self.callInfoDate:
			self.callInfoDate.hide()
			self.remove(self.callInfoDate)
			self.callInfoDate = None

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)
		self.callInfoDate.show()

		return True

	def hide(self):
		self.animationTimer = None
		self.callDurationTimer = None
		self.myCardTimer= None
		self.myCardTextTimer= None
		
		BaseUI.hide(self)

		if self.mmcidType == self.ANIMATION:
			status.outgoing_ani_index = self.animationIndex
			for animationframe in self.outgoingCallAnimation:
				animationframe.hide()

		if self.avata:
			self.avata.hide()

		# delete myCard Data
		utils.remove_dir('/usr/local/lgvp/images/myCard/')

	def destroy(self):
		self.animationTimer = None
		self.callDurationTimer = None
		self.myCardTimer= None
		self.myCardTextTimer = None
		
		BaseUI.destroy(self)
		
		if self.mmcidType == self.ANIMATION:
			status.outgoing_ani_index = self.animationIndex
			for animationframe in self.outgoingCallAnimation:
				animationframe.free()

		if self.avata:
			self.avata.free()

	def showMyCardText_callback(self):
		if not self.myCardTextTimer:
			return

		if self.myCardText:
			self.myCardText.hide()
			self.remove(self.myCardText)
			self.myCardText = None
			
		if type(self.myCardTextString) == type('abc'):
			marquee = unicode(self.myCardTextString, 'utf-8')[self.myCardTextCurrentIndex:]
		else:
			marquee = self.myCardTextString[self.myCardTextCurrentIndex:]
		marquee  = marquee.encode('utf-8')

		if marquee == '':
			self.myCardTextCurrentIndex = 0
			if type(self.myCardTextString) == type('abc'):
				marquee = unicode(self.myCardTextString, 'utf-8')[self.myCardTextCurrentIndex:]
			else:
				marquee = self.myCardTextString[self.myCardTextCurrentIndex:]
			marquee  = marquee.encode('utf-8')
		self.myCardTextCurrentIndex += 1

		import utils
		myCardMarqueeTextString, font = utils.cut_text(marquee, uiconfig.my_card_text_width, uiconfig.my_card_text_font)
		#myCardMarqueeText = utils.get_real_lang_str(self.myCardMarquee)
		self.myCardText = runtime.evas.text(text=myCardMarqueeTextString, \
			font=uiconfig.my_card_text_font, \
			pos=uiconfig.my_card_text_pos, \
			color=uiconfig.my_card_text_font_color)
		self.myCardText.layer = 2
		self.add(self.myCardText)
		self.myCardText.show()

		if self.myCardTextTimer:
			self.myCardTextTimer = None
		self.myCardTextTimer = utils.Timer(250, self.showMyCardText_callback)

		return True
		
	def hideMyCardText(self):
		self.myCardTextBg.hide()
		self.myCardText.hide()
			
class IncomingUI_old(NotifyCallUI):
	show_bg = True
	def __init__(self, caller, avata=None, reject_on=True, video=None):
		message2 = caller
		if video=='1':
			message1 = _('Incoming video call from') + ':'
			icon = uiconfig.incoming_video_icon_ani
		else:
			message1 = _('Incoming call from') + ':'
			icon = uiconfig.incoming_icon_ani

		if setting.ringing_mode in (1, 3, 4, 5, 6): # ring disable, ring after..1,2,3,4
			soft1 = ''
		else:
			if setting.vip_filter:
				if runtime.manager.is_vip():
					soft1 = _('MUTE')
				else:
					soft1 = ''
			else:
				soft1 = _('MUTE')

		if reject_on == True:
			NotifyCallUI.__init__(self, soft1, _('REJECT'), '', message1, message2)
		else:
			NotifyCallUI.__init__(self, soft1, '', '', message1, message2)

		self.set_avata(avata)
		self.icon = icon
		self.ani_count = 0
		self.incoming_ani = None
		self.incoming_ani = utils.put_image(self.icon[self.ani_count], uiconfig.incoming_icon_ani_pos)
#Roxia Begin smyook 06.03.20
		self.incoming_ani.hide()
#Roxia End smyook
		self.add(self.incoming_ani)
		self.ani_timer = None

	def ani_timer_cb(self):
		if not self.ani_timer:
			return
		if self.ani_count == -1:
			self.ani_count += 1
		else:
			self.ani_count += 1
			if self.ani_count > 3:
				self.ani_count = 0
		self.incoming_ani.file = uiconfig.image_dir + self.icon[self.ani_count]

		return True # Ongoing timer

	def show(self):
		NotifyCallUI.show(self)
		self.ani_timer = utils.Timer(500, self.ani_timer_cb)

	def hide(self):
		self.ani_timer = None
		NotifyCallUI.hide(self)

	def destroy(self):
		self.ani_timer = None
		NotifyCallUI.destroy(self)

	def set_avata(self, avata):
		if not avata:
			self.avata = utils.put_image(uiconfig.no_photo, uiconfig.avata_pos)
		else:
			self.avata = utils.put_image(avata, uiconfig.avata_pos)
		x, y = uiconfig.avata_pos
		w, h = uiconfig.avata_size
		utils.image_center_sized(self.avata, x + w/2, y + h/2, w, h)
		self.add(self.avata)


class IncomingVideoUI(NotifyCallUI):
	show_bg = True
	def __init__(self, caller, avata=None):
		message1 = _('Incoming call from') + ':'
		message2 = caller
		NotifyCallUI.__init__(self, _('MUTE'), _('REJECT'), '', message1, message2)

		self.set_avata(avata)
		self.ani_count = 0
		self.incoming_ani = None
		self.incoming_ani = utils.put_image(uiconfig.incoming_icon_ani[self.ani_count], uiconfig.incoming_icon_ani_pos)
		self.add(self.incoming_ani)
		self.ani_timer = None

	def ani_timer_cb(self):
		if not self.ani_timer:
			return
		if self.ani_count == -1:
			self.ani_count += 1
		else:
			self.ani_count += 1
			if self.ani_count > 3:
				self.ani_count = 0
		self.incoming_ani.file = uiconfig.image_dir + uiconfig.incoming_icon_ani[self.ani_count]
		return True

	def show(self):
		NotifyCallUI.show(self)
		self.ani_timer = utils.Timer(500, self.ani_timer_cb)

	def hide(self):
		self.ani_timer = None
		NotifyCallUI.hide(self)

	def destroy(self):
		self.ani_timer = None
		NotifyCallUI.destroy(self)

	def set_avata(self, avata):
		if not avata:
			self.avata = utils.put_image(uiconfig.no_photo, uiconfig.avata_pos)
		else:
			self.avata = utils.put_image(avata, uiconfig.avata_pos)
		x, y = uiconfig.avata_pos
		w, h = uiconfig.avata_size
		utils.image_center_sized(self.avata, x + w/2, y + h/2, w, h)
		self.add(self.avata)


class AudioCallTerminatedUI(BaseUI):
	show_bg = True
	def __init__(self, errorMessage, name, number, isOutgoingCall):
		BaseUI.__init__(self, '', '', '')
		self.animationTimer = None
		self.outgoingCallAnimation = []
		self.numberOfFrame = len(uiconfig.outgoing_call_ani)
		
		#KA: [20080610] call term test
		'''
		for imageFrame in uiconfig.outgoing_call_ani:
			animationframe = utils.put_image(imageFrame, uiconfig.outgoing_call_ani_pos)
			animationframe.hide()
			self.outgoingCallAnimation.append(animationframe)
		self.animationIndex = -1
		'''
		self.animationframe = utils.put_image(uiconfig.outgoing_call_ani[0], uiconfig.outgoing_call_ani_pos)
		self.add(self.animationframe)
		#KA: [20080610] call term test ==

		icon, pos = uiconfig.call_info
		self.callInfo = utils.put_image(icon, pos)
		self.add(self.callInfo)

		icon, pos = uiconfig.call_info_bar
		self.callInfoBar = utils.put_image(icon, pos)
		self.add(self.callInfoBar)

		messagePrefix2 = None
		if errorMessage=='busy':
			hangleMessage = '상대방이 통화 중입니다.'
			messagePrefix = unicode(hangleMessage, 'euc-kr').encode('utf-8')
			runtime.SP_context.setErrorTone(config.PLAY_BUSY_TONE)
		elif errorMessage=='cg':
			hangleMessage = '통화연결을 할 수 없습니다.'
			hangleMessage2 = '재시도하려면 통화버튼을 누르세요.'
			messagePrefix = unicode(hangleMessage, 'euc-kr').encode('utf-8')
			messagePrefix2 = unicode(hangleMessage2, 'euc-kr').encode('utf-8')
			runtime.SP_context.setErrorTone(config.PLAY_CG_TONE)
		elif errorMessage=='server_error':
			hangleMessage = '서버에 연결할 수 없습니다.'
			hangleMessage2 = '재시도하려면 통화버튼을 누르세요.'
			messagePrefix = unicode(hangleMessage, 'euc-kr').encode('utf-8')
			messagePrefix2 = unicode(hangleMessage2, 'euc-kr').encode('utf-8')
			runtime.SP_context.setErrorTone(config.PLAY_CG_TONE)
		else:
			messagePrefix = _('Audio call disconnected')

		if messagePrefix2: # 추후 수정이 필요함. size 및 font
			self.messagePrefix = runtime.evas.text(text=messagePrefix,
				font=uiconfig.call_info_name_font,
				pos=(83, 123),
				color=uiconfig.call_info_bar_text_color)
			self.add(self.messagePrefix)
			
			self.messagePrefix2 = runtime.evas.text(text=messagePrefix2,
				font=uiconfig.call_info_name_font,
				pos=(78, 148),
				color=uiconfig.call_info_bar_text_color)
			self.add(self.messagePrefix2)
		else:
			self.messagePrefix = runtime.evas.text(text=messagePrefix,
				font=uiconfig.call_info_bar_font,
				pos=uiconfig.call_info_bar_text_pos,
				color=uiconfig.call_info_bar_text_color)
			self.add(self.messagePrefix)
			
		self.name = None
		self.number = None

		callerName = name.strip()
		callerNumber = number.strip()

		if callerName.lower().find('anonymous') != -1:
			self.name = runtime.evas.text(text=_('Anonymous'),
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
		elif callerName == '' or callerName == callerNumber:
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
		else:		
			if len(unicode(callerName, 'utf-8')) > 8:
				callerName = unicode(callerName, 'utf-8')[:7].encode('utf-8') + '...'
			self.name = runtime.evas.text(text=callerName,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)

			self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
				font=uiconfig.call_info_number_font,
				pos=uiconfig.call_info_number_pos,
				color=uiconfig.call_info_number_color)
			self.add(self.number)

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)

		if status.currentCallDuration == (0, 0, 0):
			status.currentCallDuration = (0, 0, 1)
			callDuration = '00:00:01'
		else:
			runtime.mmiDebug.mmiTrace('status.currentCallDuration= ', status.currentCallDuration)
			callDuration = '%02d:%02d:%02d' % status.currentCallDuration
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)
		
		self.avata= None
		from phonedb import phonedb
		if callerNumber:
			avata = phonedb.get_snapshot2(callerNumber)
		else:
			avata = None
		self.set_avata(avata)

		icon, pos = uiconfig.audio_call_info_icon
		self.audioCallInfoIcon = utils.put_image(icon, pos)
		self.add(self.audioCallInfoIcon)

		if isOutgoingCall:
			icon, pos = uiconfig.outgoing_icon
			self.outgoingIcon = utils.put_image(icon, pos)
			self.add(self.outgoingIcon)

			icon, pos = uiconfig.outgoing_text_icon
			self.outgoingTextIcon = utils.put_image(icon, pos)
			self.add(self.outgoingTextIcon)
		else:
			icon, pos = uiconfig.incoming_icon
			self.outgoingIcon = utils.put_image(icon, pos)
			self.add(self.outgoingIcon)

			icon, pos = uiconfig.incoming_text_icon
			self.outgoingTextIcon = utils.put_image(icon, pos)
			self.add(self.outgoingTextIcon)
		
		icon, pos = uiconfig.timer_icon
		self.timerIcon = utils.put_image(icon, pos)
		self.add(self.timerIcon)

		icon, pos = uiconfig.timer_text_icon
		self.timerTextIcon = utils.put_image(icon, pos)
		self.add(self.timerTextIcon)

		icon, pos = uiconfig.frame_image
		self.frameImage = utils.put_image(icon, pos)
		self.add(self.frameImage)

		self.callSoftbarImage = None
		
	def set_avata(self, avata):
		if not avata:
			self.avata = utils.put_image(uiconfig.no_photo, uiconfig.avata_pos)
		else:
			self.avata = utils.put_image(avata, uiconfig.avata_pos)
		x, y = uiconfig.avata_pos
		w, h = uiconfig.avata_size
		utils.image_center_sized(self.avata, x + w/2, y + h/2, w, h)
		self.add(self.avata)
		
	def show(self):
		BaseUI.show(self)
		#KA: [20080610] call term test
		'''
		if not self.animationTimer:
			self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		#import utils
		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		self.timeCheckTimer = utils.Timer(1000, self.timeCheckTimer_callback)
		'''
		#KA: [20080610] call term test

	def showSoftbar(self):
		icon, pos = uiconfig.call_softbar_image
		self.callSoftbarImage = utils.put_image(icon, pos)
		self.callSoftbarImage.show()
		
	def animationTimer_callback(self):
		if not self.animationTimer:
			return
			
		if self.animationIndex == -1:
			self.animationIndex += 1
		else:
			self.outgoingCallAnimation[self.animationIndex].hide()
			self.animationIndex += 1
			if self.animationIndex > self.numberOfFrame-1:
				self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		'''
		if self.animationTimer:
			self.animationTimer = None
		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		'''
		
		return True

	def timeCheckTimer_callback(self):
		if not self.timeCheckTimer:
			return

		import time,ntptime
		callInfoMinute = time.localtime(ntptime.ntime())[5]
		if callInfoMinute != self.callInfoMinute:
			self.changeCallInfoDate()

		'''
		if self.timeCheckTimer:
			self.timeCheckTimer = None
		self.timeCheckTimer = utils.Timer(1000, self.timeCheckTimer_callback)
		'''
		
		return True

	def changeCallInfoDate(self):
		if self.callInfoDate:
			self.callInfoDate.hide()
			self.remove(self.callInfoDate)
			self.callInfoDate = None

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)
		self.callInfoDate.show()

		return True
		
	def hide(self):
		self.animationTimer = None
		self.timeCheckTimer = None
		#KA: [20080610] call term test
		#status.outgoing_ani_index = self.animationIndex
		BaseUI.hide(self)
		
		#for animationframe in self.outgoingCallAnimation:
		#	animationframe.hide()
		
	def destroy(self):
		self.animationTimer = None
		self.timeCheckTimer = None
		#KA: [20080610] call term test
		#status.outgoing_ani_index = self.animationIndex
		BaseUI.destroy(self)
		
		#for animationframe in self.outgoingCallAnimation:
		#	animationframe.free()

class VideoCallTerminatedUI(BaseUI):
	def __init__(self, errorMessage, name, number, isOutgoingCall):
		BaseUI.__init__(self, '', '', '')
		
		self.animationTimer = None
		self.outgoingCallAnimation = []
		self.numberOfFrame = len(uiconfig.outgoing_call_ani)
		#KA: [20080610] call term test
		'''
		for imageFrame in uiconfig.outgoing_call_ani:
			animationframe = utils.put_image(imageFrame, uiconfig.outgoing_call_ani_pos)
			animationframe.hide()
			self.outgoingCallAnimation.append(animationframe)
		self.animationIndex = -1
		'''
		self.animationframe = utils.put_image(uiconfig.outgoing_call_ani[0], uiconfig.outgoing_call_ani_pos)
		self.add(self.animationframe)
		#KA: [20080610] call term test ==

		icon, pos = uiconfig.call_info
		self.callInfo = utils.put_image(icon, pos)
		self.add(self.callInfo)

		icon, pos = uiconfig.call_info_bar
		self.callInfoBar = utils.put_image(icon, pos)
		self.add(self.callInfoBar)
		
		messagePrefix2 = None
		if errorMessage=='busy':
			hangleMessage = _('The line is busy') #_('상대방이 통화 중입니다.')
			messagePrefix = unicode(hangleMessage, 'euc-kr').encode('utf-8')
			runtime.SP_context.setErrorTone(config.PLAY_BUSY_TONE)
		elif errorMessage=='cg':
			hangleMessage = _('Could not connect') #_('통화연결을 할 수 없습니다.')
			hangleMessage2 = _('Hit Green key to retry') #_('재시도하려면 통화버튼을 누르세요.')
			messagePrefix = unicode(hangleMessage, 'euc-kr').encode('utf-8')
			messagePrefix2 = unicode(hangleMessage2, 'euc-kr').encode('utf-8')
			runtime.SP_context.setErrorTone(config.PLAY_CG_TONE)
		elif errorMessage=='server_error':
			hangleMessage = _('Couldnot connect to server') # _('서버에 연결할 수 없습니다.')
			hangleMessage2 = _('Hit Green key to retry') #_('재시도하려면 통화버튼을 누르세요.')
			messagePrefix = unicode(hangleMessage, 'euc-kr').encode('utf-8')
			messagePrefix2 = unicode(hangleMessage2, 'euc-kr').encode('utf-8')
			runtime.SP_context.setErrorTone(config.PLAY_CG_TONE)
		else:
			if status.pushVideoAd:
				messagePrefix = _('Audio call disconnected')
			else:
				messagePrefix = _('Video call disconnected')

		if messagePrefix2: # 추후 수정이 필요함. size 및 font
			self.messagePrefix = runtime.evas.text(text=messagePrefix,
				font=uiconfig.call_info_name_font,
				pos=(83, 123),
				color=uiconfig.call_info_bar_text_color)
			self.add(self.messagePrefix)
			
			self.messagePrefix2 = runtime.evas.text(text=messagePrefix2,
				font=uiconfig.call_info_name_font,
				pos=(78, 148),
				color=uiconfig.call_info_bar_text_color)
			self.add(self.messagePrefix2)
		else:
			self.messagePrefix = runtime.evas.text(text=messagePrefix,
				font=uiconfig.call_info_bar_font,
				pos=uiconfig.call_info_bar_text_pos,
				color=uiconfig.call_info_bar_text_color)
			self.add(self.messagePrefix)		

		self.name = None
		self.number = None

		callerName = name.strip()
		callerNumber = number.strip()

		if callerName.lower().find('anonymous') != -1:
			self.name = runtime.evas.text(text=_('Anonymous'),
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
		elif callerName == '' or callerName == callerNumber:
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
		else:		
			if len(unicode(callerName, 'utf-8')) > 8:
				callerName = unicode(callerName, 'utf-8')[:7].encode('utf-8') + '...'
			self.name = runtime.evas.text(text=callerName,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)

			self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
				font=uiconfig.call_info_number_font,
				pos=uiconfig.call_info_number_pos,
				color=uiconfig.call_info_number_color)
			self.add(self.number)

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)

		if status.currentCallDuration == (0, 0, 0):
			status.currentCallDuration = (0, 0, 1)
			callDuration = '00:00:01'
		else:
			runtime.mmiDebug.mmiTrace('status.currentCallDuration= ', status.currentCallDuration)
			callDuration = '%02d:%02d:%02d' % status.currentCallDuration
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)

		self.avata= None
		from phonedb import phonedb
		if callerNumber:
			avata = phonedb.get_snapshot2(callerNumber)
		else:
			avata = None
		self.set_avata(avata)

		icon, pos = uiconfig.video_call_info_icon
		self.audioCallInfoIcon = utils.put_image(icon, pos)
		self.add(self.audioCallInfoIcon)
		
		if isOutgoingCall:
			icon, pos = uiconfig.outgoing_icon
			self.outgoingIcon = utils.put_image(icon, pos)
			self.add(self.outgoingIcon)

			icon, pos = uiconfig.outgoing_text_icon
			self.outgoingTextIcon = utils.put_image(icon, pos)
			self.add(self.outgoingTextIcon)
		else:
			icon, pos = uiconfig.incoming_icon
			self.incomingIcon = utils.put_image(icon, pos)
			self.add(self.incomingIcon)

			icon, pos = uiconfig.incoming_text_icon
			self.incomingTextIcon = utils.put_image(icon, pos)
			self.add(self.incomingTextIcon)
		
		icon, pos = uiconfig.timer_icon
		self.timerIcon = utils.put_image(icon, pos)
		self.add(self.timerIcon)

		icon, pos = uiconfig.timer_text_icon
		self.timerTextIcon = utils.put_image(icon, pos)
		self.add(self.timerTextIcon)

		icon, pos = uiconfig.frame_image
		self.frameImage = utils.put_image(icon, pos)
		self.add(self.frameImage)

		self.callSoftbarImage = None

	def set_avata(self, avata):
		if not avata:
			self.avata = utils.put_image(uiconfig.no_photo, uiconfig.avata_pos)
		else:
			self.avata = utils.put_image(avata, uiconfig.avata_pos)
		x, y = uiconfig.avata_pos
		w, h = uiconfig.avata_size
		utils.image_center_sized(self.avata, x + w/2, y + h/2, w, h)
		self.add(self.avata)

		
	def show(self):
		BaseUI.show(self)
		#KA: [20080610] call term test
		'''
		if not self.animationTimer:
			self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()
		import utils
		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		'''
		#KA: [20080610] call term test
		
	def showSoftbar(self):
		icon, pos = uiconfig.call_softbar_image
		self.callSoftbarImage = utils.put_image(icon, pos)
		self.callSoftbarImage.show()
		
	def animationTimer_callback(self):
		if not self.animationTimer:
			return
			
		if self.animationIndex == -1:
			self.animationIndex += 1
		else:
			self.outgoingCallAnimation[self.animationIndex].hide()
			self.animationIndex += 1
			if self.animationIndex > self.numberOfFrame-1:
				self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		'''
		if self.animationTimer:
			self.animationTimer = None
		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		'''
		
		return True

	def timeCheckTimer_callback(self):
		if not self.timeCheckTimer:
			return

		import time,ntptime
		callInfoMinute = time.localtime(ntptime.ntime())[5]
		if callInfoMinute != self.callInfoMinute:
			self.changeCallInfoDate()

		if self.timeCheckTimer:
			self.timeCheckTimer = None
		self.timeCheckTimer = utils.Timer(1000, self.timeCheckTimer_callback)

		return True

	def changeCallInfoDate(self):
		if self.callInfoDate:
			self.callInfoDate.hide()
			self.remove(self.callInfoDate)
			self.callInfoDate = None

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)
		self.callInfoDate.show()

		return True
		
	def hide(self):
		self.animationTimer = None
		self.timeCheckTimer = None
		#KA: [20080610] call term test
		#status.outgoing_ani_index = self.animationIndex
		BaseUI.hide(self)
		
		#for animationframe in self.outgoingCallAnimation:
		#	animationframe.hide()
		
	def destroy(self):
		self.animationTimer = None
		self.timeCheckTimer = None
		#KA: [20080610] call term test
		#status.outgoing_ani_index = self.animationIndex
		BaseUI.destroy(self)
		
		#for animationframe in self.outgoingCallAnimation:
		#	animationframe.free()

class AudioCallConnectedUI(BaseUI):
	show_bg = True
	def __init__(self, number):
		BaseUI.__init__(self)
		self.pressedNumber = []

		self.animationTimer = None
		self.outgoingCallAnimation = []
		self.numberOfFrame = len(uiconfig.outgoing_call_ani)

		self.firstIsBusy = False
		
		for imageFrame in uiconfig.outgoing_call_ani:
			animationframe = utils.put_image(imageFrame, uiconfig.outgoing_call_ani_pos)
			animationframe.hide()
			self.outgoingCallAnimation.append(animationframe)

		if status.outgoing_ani_index != -1:
			self.animationIndex = status.outgoing_ani_index + 1
		else:
			self.animationIndex = -1

		icon, pos = uiconfig.call_info
		self.callInfo = utils.put_image(icon, pos)
		self.add(self.callInfo)

		icon, pos = uiconfig.call_info_bar
		self.callInfoBar = utils.put_image(icon, pos)
		self.add(self.callInfoBar)

		from mmiSoundPath import SP_Context
		baseCallStatus, baseStatus, dectCallStatus, dectStatus = status.getCurrentCallStatus()
		if baseCallStatus == SP_Context.INCOMING_AUDIO or baseStatus == SP_Context.CONNECTED  or status.pushVideoAd == True:
			messagePrefix = _('Audio call connected')
		else:
			messagePrefix = _('Audio call connecting...')

		self.messagePrefix = runtime.evas.text(text=messagePrefix,
			font=uiconfig.call_info_bar_font,
			pos=uiconfig.call_info_bar_text_pos,
			color=uiconfig.call_info_bar_text_color)
		self.add(self.messagePrefix)

		self.name = None
		self.number = None

		callerName = status.display_caller_name(status.active_call_index)
		callerNumber = status.display_caller_number(status.active_call_index)
		if callerName.find('anonymous') != -1:
			self.name = runtime.evas.text(text=_('Anonymous'),
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
		elif callerName == '' or callerName == callerNumber:
			callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
		else:		
			if len(unicode(callerName, 'utf-8')) > 8:
				callerName = unicode(callerName, 'utf-8')[:7].encode('utf-8') + '...'
			self.name = runtime.evas.text(text=callerName,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)

			callerNumber = status.display_caller_number(status.active_call_index)
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		#callInfoDateList = [_('M'), _('T'), _('W'), _('T'), _('F'), _('S'), _('S')]		
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)

		if status.currentCallDuration == (0, 0, 0):
			self.hour = 0
			self.minute = 0
			self.second = 0
			callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second) 
		else:
			self.hour, self.minute, self.second = status.currentCallDuration
			callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second) 
		self.time = runtime.evas.text(text=callDuration,
			font=uiconfig.call_info_time_font,
			pos=uiconfig.call_info_time_pos,
			color=uiconfig.call_info_time_color)
		self.add(self.time)

		self.avata= None
		from phonedb import phonedb
		if callerNumber:
			avata = phonedb.get_snapshot2(callerNumber)
		else:
			avata = None
		self.set_avata(avata)

		icon, pos = uiconfig.audio_call_info_icon
		self.audioCallInfoIcon = utils.put_image(icon, pos)
		self.add(self.audioCallInfoIcon)

		self.incomingIcon = None
		self.incomingTextIcon = None
		self.outgoingIcon = None
		self.outgoingTextIcon = None
		
		if not status.dial_number:
			icon, pos = uiconfig.incoming_icon
			self.incomingIcon = utils.put_image(icon, pos)
			self.add(self.incomingIcon)

			icon, pos = uiconfig.incoming_text_icon
			self.incomingTextIcon = utils.put_image(icon, pos)
			self.add(self.incomingTextIcon)
		else:
			icon, pos = uiconfig.outgoing_icon
			self.outgoingIcon = utils.put_image(icon, pos)
			self.add(self.outgoingIcon)

			icon, pos = uiconfig.outgoing_text_icon
			self.outgoingTextIcon = utils.put_image(icon, pos)
			self.add(self.outgoingTextIcon)
		
		icon, pos = uiconfig.timer_icon
		self.timerIcon = utils.put_image(icon, pos)
		self.add(self.timerIcon)

		icon, pos = uiconfig.timer_text_icon
		self.timerTextIcon = utils.put_image(icon, pos)
		self.add(self.timerTextIcon)

		icon, pos = uiconfig.frame_image
		self.frameImage = utils.put_image(icon, pos)
		self.add(self.frameImage)

		# soundpath info icon
		devices = runtime.SP_context.getCurrentDevice()
		for device in devices:			
			from mmiSoundPath import SP_State
			if device == SP_State.DEVICE_HS:
				icon, pos = uiconfig.soundpath_handset
			elif device == SP_State.DEVICE_SPK:
				icon, pos = uiconfig.soundpath_speaker
		self.soundPath = utils.put_image(icon, pos)
		self.add(self.soundPath)
		
		icon, pos = uiconfig.soundpath_mute
		self.micMute= utils.put_image(icon, pos)
		self.add(self.micMute)			

		self.isInService = False
		
		self.callSoftbarImage = None

		self.secondCallInfoBar = None
		self.secondAudioCallInfoIcon = None
		self.secondCallMessagePrefix = None
		self.secondCallMessageName = None
		self.secondCallMessageNumber = None
		self.callInfoService = None

		self.firstCallNameInThreeWay = None
		self.firstCallNumberInThreeWay = None
		self.secondCallNameInThreeWay = None
		self.secondCallNumberInThreeWay = None
		self.threeWayTextIcon = None

		self.inUseIcon = None

		self.volume_img=[]
		self.volume_img_bg = None

		self.notify_box = None
		self.notify_icon = None
		self.notify_msg = None
		self.notify_timer = None

		self.micMuteFlag = False
		self.second_avata= None

		self.write_number_tag = None
		
	def update_soundpath(self):
		devices = runtime.SP_context.getCurrentDevice()
		#print 'ka...####### ---- devices=', devices
		for device in devices:			
			from mmiSoundPath import SP_State
			if device == SP_State.DEVICE_HS:
				icon, pos = uiconfig.soundpath_handset
			elif device == SP_State.DEVICE_SPK:
				icon, pos = uiconfig.soundpath_speaker
			self.soundPath.file = uiconfig.image_dir + icon
				
	def update_mic(self):
		if self.micMuteFlag:
			self.micMute.show()
		else:
			self.micMute.hide()	
	
	def set_avata(self, avata):
		if not avata:
			self.avata = utils.put_image(uiconfig.no_photo, uiconfig.avata_pos)
		else:
			self.avata = utils.put_image(avata, uiconfig.avata_pos)
		x, y = uiconfig.avata_pos
		w, h = uiconfig.avata_size
		utils.image_center_sized(self.avata, x + w/2, y + h/2, w, h)
		self.add(self.avata)

	def set_second_avata(self, avata):
		if not avata:
			self.second_avata = utils.put_image(uiconfig.no_photo, (59, 84))
		else:
			self.second_avata = utils.put_image(avata, (59, 84))
		x, y = (59, 84)
		w, h = (96, 74)
		utils.image_center_sized(self.second_avata, x + w/2, y + h/2, w, h)
		self.add(self.second_avata)
		
	def hideInfoMessage(self):
		if self.secondCallInfoBar: self.secondCallInfoBar.hide()
		if self.secondAudioCallInfoIcon: self.secondAudioCallInfoIcon.hide()
		if self.secondCallMessagePrefix: self.secondCallMessagePrefix.hide()
		if self.secondCallMessageNumber: self.secondCallMessageNumber.hide()
		if self.secondCallMessageName: self.secondCallMessageName.hide()		
		
		self.audioCallInfoIcon.hide()
		self.callInfoBar.hide()
		self.messagePrefix.hide()

	def showInfoMessage(self):
		self.audioCallInfoIcon.show()
		self.callInfoBar.show()
		self.messagePrefix.show()
	
	def showSecondCallNumber(self, secondCallNumber):
		self.hideInfoMessage()		
		self.removeSecondCallNumber()
		
		# KA: test
		from phonedb import phonedb
		name = phonedb.get_name(secondCallNumber)

		if name == '':
			name = 'anonymous'

		hideName = False
		if name == secondCallNumber:
			hideName = True
			
		if self.secondCallInfoBar:
			self.secondCallInfoBar.show()
		else:
			icon, pos = uiconfig.second_call_info_bar
			self.secondCallInfoBar = utils.put_image(icon, pos)
			self.secondCallInfoBar.show()

		if self.secondAudioCallInfoIcon:
			self.secondAudioCallInfoIcon.show()
		else:
			icon, pos = uiconfig.second_audio_call_info_icon
			self.secondAudioCallInfoIcon = utils.put_image(icon, pos)
			self.secondAudioCallInfoIcon.show()

		if setting.in_restrict and (secondCallNumber  in setting.in_restrict_nums):		
			secondCallMessagePrefix = _('Prohibited number')
		else:
			secondCallMessagePrefix = _('Call receiving')	
		self.secondCallMessagePrefix = runtime.evas.text(text=secondCallMessagePrefix,
			font=uiconfig.secondCall_info_bar_font,
			pos=uiconfig.secondCall_info_bar_text_pos,
			color=uiconfig.secondCall_info_bar_text_color)
		self.secondCallMessagePrefix.show()

		if hideName:
			secondCallMessageNumber = secondCallNumber
			self.secondCallMessageNumber = runtime.evas.text(text=secondCallMessageNumber,
				font=uiconfig.secondCall_info_bar_font,
				pos=uiconfig.secondCall_info_bar_number_pos,
				color=uiconfig.secondCall_info_bar_text_color)
			self.secondCallMessageNumber.show()
		else:
			if name.find('anonymous') != -1:
				name = _('Anonymous')

				secondCallMessageName = name
				if len(unicode(secondCallMessageName, 'utf-8')) > 8:
					secondCallMessageName = unicode(secondCallMessageName, 'utf-8')[:7].encode('utf-8') + '...'
				self.secondCallMessageName = runtime.evas.text(text=secondCallMessageName,
					font=uiconfig.secondCall_info_bar_anonymous_font,
					pos=uiconfig.secondCall_info_bar_name_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallMessageName.show()
			else:
				secondCallMessageName = name
				if len(unicode(secondCallMessageName, 'utf-8')) > 8:
					secondCallMessageName = unicode(secondCallMessageName, 'utf-8')[:7].encode('utf-8') + '...'
				self.secondCallMessageName = runtime.evas.text(text=secondCallMessageName,
					font=uiconfig.secondCall_info_bar_anonymous_font,
					pos=uiconfig.secondCall_info_bar_name_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallMessageName.show()

				secondCallMessageNumber = secondCallNumber
				self.secondCallMessageNumber = runtime.evas.text(text=secondCallMessageNumber,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.secondCall_info_bar_number_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallMessageNumber.show()

		# KA: test
		from phonedb import phonedb
		if secondCallNumber:
			avata = phonedb.get_snapshot2(secondCallNumber)
		else:
			avata = None
		self.set_second_avata(avata)

	def hideCallInfo(self):
		runtime.mmiDebug.mmiTrace('AudioCallConnectedUI::hideCallInfo()')
		# 3 way
		if self.callInfoService: self.callInfoService.hide()
		if self.threeWayTextIcon: self.threeWayTextIcon.hide()
		if self.firstCallNumberInThreeWay: self.firstCallNumberInThreeWay.hide()
		if self.firstCallNameInThreeWay: self.firstCallNameInThreeWay.hide()
		if self.secondCallNameInThreeWay: self.secondCallNameInThreeWay.hide()
		if self.secondCallNumberInThreeWay: self.secondCallNumberInThreeWay.hide()
		if self.inUseIcon: self.inUseIcon.hide()

		# normal
		if self.callInfo: self.callInfo.hide()
		if self.incomingIcon: self.incomingIcon.hide()
		if self.incomingTextIcon: self.incomingTextIcon.hide()
		if self.outgoingIcon: self.outgoingIcon.hide()
		if self.outgoingTextIcon: self.outgoingTextIcon.hide()
		if self.name: self.name.hide()
		if self.number: self.number.hide()
		if self.timerIcon: self.timerIcon.hide()
		if self.timerTextIcon: self.timerTextIcon.hide()
		if self.callSoftbarImage: self.callSoftbarImage.hide()

		'''
		if self.time: 
			self.time.hide()
			self.callDurationTimer = None		
		'''	
		
	def showThreeWayConference(self, firstCallNumber, secondCallNumber):
		runtime.mmiDebug.mmiTrace('AudioCallConnectedUI::showThreeWayConference')

		self.isInService = True
		
		self.hideCallInfo()

		self.changeMessagePrefix(_('Call conferencing'))
		self.showInfoMessage()

		icon, pos = uiconfig.call_info_service
		self.callInfoService = utils.put_image(icon, pos)
		self.callInfoService.show()

		icon, pos = uiconfig.three_way_text_icon
		self.threeWayTextIcon = utils.put_image(icon, pos)
		self.threeWayTextIcon.show()
		
		from phonedb import phonedb
		firstCallName = phonedb.get_name(firstCallNumber)

		if firstCallName == firstCallNumber and firstCallName.find('anonymous') != -1:
			firstCallName = 'anonymous'
			firstCallNumber = ''
		
		if firstCallName == firstCallNumber:			
			firstCallNumberInThreeWay = firstCallNumber
			self.firstCallNumberInThreeWay = runtime.evas.text(text=firstCallNumberInThreeWay,
				font=uiconfig.secondCall_info_bar_font,
				pos=uiconfig.threeWayCall_info_firstNumber_pos,
				color=uiconfig.secondCall_info_bar_text_color)
			self.firstCallNumberInThreeWay.show()
		else:
			if firstCallName.find('anonymous') != -1:
				firstCallName = _('Anonymous')

				firstCallNameInThreeWay = firstCallName
				self.firstCallNameInThreeWay = runtime.evas.text(text=firstCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font_for_anonymous_for_anonymous,
					pos=uiconfig.threeWayCall_info_firstName_pos_for_anonymous2,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNameInThreeWay.show()
			else:
				firstCallNameInThreeWay = firstCallName
				if len(unicode(firstCallNameInThreeWay, 'utf-8')) > 6:
					firstCallNameInThreeWay = unicode(firstCallNameInThreeWay, 'utf-8')[:5].encode('utf-8') + '...'
				self.firstCallNameInThreeWay = runtime.evas.text(text=firstCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_firstName_pos2,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNameInThreeWay.show()

				firstCallNumberInThreeWay = firstCallNumber
				self.firstCallNumberInThreeWay = runtime.evas.text(text=firstCallNumberInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_firstNumber_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNumberInThreeWay.show()

		from phonedb import phonedb
		secondCallName = phonedb.get_name(secondCallNumber)

		if secondCallName == secondCallNumber and secondCallName.find('anonymous') != -1:
			secondCallName = 'anonymous'
			secondCallNumber = ''
		
		if secondCallName == secondCallNumber:			
			secondCallNumberInThreeWay = secondCallNumber
			self.secondCallNumberInThreeWay = runtime.evas.text(text=secondCallNumberInThreeWay,
				font=uiconfig.secondCall_info_bar_font,
				pos=uiconfig.threeWayCall_info_secondNumber_pos,
				color=uiconfig.secondCall_info_bar_text_color)
			self.secondCallNumberInThreeWay.show()
		else:
			if secondCallName.find('anonymous') != -1:
				secondCallName = _('Anonymous')

				secondCallNameInThreeWay = secondCallName
				self.secondCallNameInThreeWay = runtime.evas.text(text=secondCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font_for_anonymous,
					pos=uiconfig.threeWayCall_info_secondName_pos_for_anonymous2,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNameInThreeWay.show()
			else:
				secondCallNameInThreeWay = secondCallName
				if len(unicode(secondCallNameInThreeWay, 'utf-8')) > 6:
					secondCallNameInThreeWay = unicode(secondCallNameInThreeWay, 'utf-8')[:5].encode('utf-8') + '...'
				self.secondCallNameInThreeWay = runtime.evas.text(text=secondCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_secondName_pos2,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNameInThreeWay.show()

				secondCallNumberInThreeWay = secondCallNumber
				self.secondCallNumberInThreeWay = runtime.evas.text(text=secondCallNumberInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_secondNumber_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNumberInThreeWay.show()
		# 추후 3인통화 아바타를 받은 후 수정해야 함.
		self.set_avata(None)

	def showCallWaiting(self, firstCallNumber, secondCallNumber, firstIsBusy=None):
		runtime.mmiDebug.mmiTrace('AudioCallConnectedUI::showCallWaiting')

		if firstIsBusy != None:
			self.firstIsBusy = firstIsBusy	
		self.isInService = True
		
		self.hideCallInfo() #임시로 해줌. 정상적인 CS 메시지가 오면 처리됨.
		self.hideInfoMessage()		
		self.removeSecondCallNumber()

		if firstIsBusy:
			msg = _('Call waiting')
		else:
			msg = _('Call conferencing.')
		
		self.changeMessagePrefix(msg)
		self.showInfoMessage()

		icon, pos = uiconfig.call_info_service
		self.callInfoService = utils.put_image(icon, pos)
		self.callInfoService.show()

		icon, pos = uiconfig.three_way_text_icon
		self.threeWayTextIcon = utils.put_image(icon, pos)
		self.threeWayTextIcon.show()
		
		from phonedb import phonedb
		firstCallName = phonedb.get_name(firstCallNumber)

		if firstCallName == firstCallNumber and firstCallName.find('anonymous') != -1:
			firstCallName = 'anonymous'
			firstCallNumber = ''
			
		if firstCallName == firstCallNumber:			
			firstCallNumberInThreeWay = firstCallNumber
			self.firstCallNumberInThreeWay = runtime.evas.text(text=firstCallNumberInThreeWay,
				font=uiconfig.secondCall_info_bar_font,
				pos=uiconfig.threeWayCall_info_firstNumber_pos,
				color=uiconfig.secondCall_info_bar_text_color)
			self.firstCallNumberInThreeWay.show()
		else:
			if firstCallName.find('anonymous') != -1:
				firstCallName = _('Anonymous')

				firstCallNameInThreeWay = firstCallName
				self.firstCallNameInThreeWay = runtime.evas.text(text=firstCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font_for_anonymous,
					pos=uiconfig.threeWayCall_info_firstName_pos_for_anonymous,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNameInThreeWay.show()
			else:
				firstCallNameInThreeWay = firstCallName
				if len(unicode(firstCallNameInThreeWay, 'utf-8')) > 6:
					firstCallNameInThreeWay = unicode(firstCallNameInThreeWay, 'utf-8')[:5].encode('utf-8') + '...'
				if firstIsBusy:
					tempPosition = uiconfig.threeWayCall_info_firstName_pos
				else:
					tempPosition = uiconfig.threeWayCall_info_firstName_pos2
					
				self.firstCallNameInThreeWay = runtime.evas.text(text=firstCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=tempPosition,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNameInThreeWay.show()

				firstCallNumberInThreeWay = firstCallNumber
				self.firstCallNumberInThreeWay = runtime.evas.text(text=firstCallNumberInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_firstNumber_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.firstCallNumberInThreeWay.show()

		from phonedb import phonedb
		secondCallName = phonedb.get_name(secondCallNumber)

		if secondCallName == secondCallNumber and secondCallName.find('anonymous') != -1:
			secondCallName = 'anonymous'
			secondCallNumber = ''
		
		if secondCallName == secondCallNumber:			
			secondCallNumberInThreeWay = secondCallNumber
			self.secondCallNumberInThreeWay = runtime.evas.text(text=secondCallNumberInThreeWay,
				font=uiconfig.secondCall_info_bar_font,
				pos=uiconfig.threeWayCall_info_secondNumber_pos,
				color=uiconfig.secondCall_info_bar_text_color)
			self.secondCallNumberInThreeWay.show()
		else:
			if secondCallName.find('anonymous') != -1:
				secondCallName = _('Anonymous')

				secondCallNameInThreeWay = secondCallName
				self.secondCallNameInThreeWay = runtime.evas.text(text=secondCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font_for_anonymous,
					pos=uiconfig.threeWayCall_info_secondName_pos_for_anonymous2,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNameInThreeWay.show()
			else:
				secondCallNameInThreeWay = secondCallName
				if len(unicode(secondCallNameInThreeWay, 'utf-8')) > 6:
					secondCallNameInThreeWay = unicode(secondCallNameInThreeWay, 'utf-8')[:5].encode('utf-8') + '...'
				if firstIsBusy:
					tempPosition = uiconfig.threeWayCall_info_secondName_pos2
				else:
					tempPosition = uiconfig.threeWayCall_info_secondName_pos
				self.secondCallNameInThreeWay = runtime.evas.text(text=secondCallNameInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=tempPosition,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNameInThreeWay.show()

				secondCallNumberInThreeWay = secondCallNumber
				self.secondCallNumberInThreeWay = runtime.evas.text(text=secondCallNumberInThreeWay,
					font=uiconfig.secondCall_info_bar_font,
					pos=uiconfig.threeWayCall_info_secondNumber_pos,
					color=uiconfig.secondCall_info_bar_text_color)
				self.secondCallNumberInThreeWay.show()

		if self.firstIsBusy:
			icon, pos = uiconfig.in_use_icon_1
			self.inUseIcon = utils.put_image(icon, pos)
			self.inUseIcon.show()
			
			from phonedb import phonedb
			avata = phonedb.get_snapshot2(firstCallNumber)
			self.set_avata(avata)
		else:
			icon, pos = uiconfig.in_use_icon_2
			self.inUseIcon = utils.put_image(icon, pos)
			self.inUseIcon.show()

			from phonedb import phonedb
			avata = phonedb.get_snapshot2(secondCallNumber)
			self.set_avata(avata)
	
	def removeSecondCallNumber(self):
		if self.secondCallInfoBar: self.secondCallInfoBar.hide()
		if self.secondAudioCallInfoIcon: self.secondAudioCallInfoIcon.hide()
		if self.secondCallMessagePrefix: self.secondCallMessagePrefix.hide()
		if self.secondCallMessageName: self.secondCallMessageName.hide()
		if self.secondCallMessageNumber: self.secondCallMessageNumber.hide()
		if self.second_avata: self.second_avata.hide()		

		if self.secondCallMessagePrefix: self.secondCallMessagePrefix.free()
		if self.secondCallMessageName: self.secondCallMessageName.free()
		if self.secondCallMessageNumber: self.secondCallMessageNumber.free()
		if self.second_avata: self.second_avata.free()
		
	def stopCallDuration(self):
		status.currentCallDuration = (self.hour, self.minute, self.second)
		status.currentCallDuration_copy = status.currentCallDuration
		self.callDurationTimer = None
		
	def show(self):
		BaseUI.show(self)

		if not self.animationTimer:
			self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		self.animationTimer = utils.Timer(500, self.animationTimer_callback)
		self.callDurationTimer = utils.Timer(1000, self.callDurationTimer_callback)

		self.update_mic()
		self.update_soundpath()
	'''
	def showSoftbar(self):
		icon, pos = uiconfig.call_softbar_image
		self.callSoftbarImage = utils.put_image(icon, pos)
		self.callSoftbarImage.show()		
	'''	
	def animationTimer_callback(self):
		if not self.animationTimer:
			return
			
		if self.animationIndex == -1:
			self.animationIndex += 1
		else:
			self.outgoingCallAnimation[self.animationIndex].hide()
			self.animationIndex += 1
			if self.animationIndex > self.numberOfFrame-1:
				self.animationIndex = 0
		self.outgoingCallAnimation[self.animationIndex].show()

		return True

	def callDurationTimer_callback(self):
		if not self.callDurationTimer:
			return

		if self.time:
			self.time.hide()
			self.remove(self.time)
			self.time = None

		self.second = self.second + 1
		if self.second >= 60:
			self.minute = self.minute + 1
			self.second = 0
		if self.minute >= 60:
			self.hour = self.hour + 1
			self.minute = 0
		callDuration = '%02d:%02d:%02d' % (self.hour, self.minute, self.second)
		if self.isInService:
			self.time = runtime.evas.text(text=callDuration,
				font=uiconfig.service_call_info_time_font,
				pos=uiconfig.service_call_info_time_pos,
				color=uiconfig.service_call_info_time_color)
			self.add(self.time)
		else:		
			self.time = runtime.evas.text(text=callDuration,
				font=uiconfig.call_info_time_font,
				pos=uiconfig.call_info_time_pos,
				color=uiconfig.call_info_time_color)
			self.add(self.time)
		self.time.show()

		import time,ntptime
		callInfoMinute = time.localtime(ntptime.ntime())[5]
		if callInfoMinute != self.callInfoMinute:
			self.changeCallInfoDate()

		return True

	def changeCallInfoDate(self):
		if self.callInfoDate:
			self.callInfoDate.hide()
			self.remove(self.callInfoDate)
			self.callInfoDate = None

		import time,ntptime
		callInfoYear,callInfoMonth,callInfoDay,callInfoHour, self.callInfoMinute, callInfoSecond, callInfoDate = time.localtime(ntptime.ntime())[:7]
		#callInfoDateList = [_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')]
		callInfoDateList = [_('Mon'),_('Tue'),_('Wed'),_('Thu'),_('Fri'),_('Sat'),_('Sun')]
		'''
		if callInfoHour < 12:
			callDate = '%d.%d(%s)%02d:%02dAM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = '%d.%d(%s)12:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		elif callInfoHour < 24:
			callInfoHour = callInfoHour - 12
			callDate = '%d.%d(%s)%02d:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], callInfoHour, self.callInfoMinute)
		elif callInfoHour == 24:
			callDate = '%d.%d(%s)00:%02dPM' % (callInfoMonth, callInfoDay, callInfoDateList[callInfoDate], self.callInfoMinute)
		'''
		if callInfoHour > 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), (callInfoHour-12), self.callInfoMinute)
		elif callInfoHour == 12:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('PM'), callInfoHour, self.callInfoMinute)
		elif callInfoHour == 0:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), (callInfoHour+12), self.callInfoMinute)
		else:
			callDate = "%02d/%02d %s%02d:%02d" % (callInfoMonth, callInfoDay, _('AM'), callInfoHour, self.callInfoMinute)

		self.callInfoDate = runtime.evas.text(text=callDate,
			font=uiconfig.call_info_date_font,
			pos=uiconfig.call_info_date_pos,
			color=uiconfig.call_info_date_color)
		self.add(self.callInfoDate)
		self.callInfoDate.show()

		return True

	def showAutoAnswering(self):
		if self.messagePrefix:
			self.messagePrefix.hide()
			self.remove(self.messagePrefix)
			self.messagePrefix = None

		messagePrefix = _('Auto answering...')
		self.messagePrefix = runtime.evas.text(text=messagePrefix,
			font=uiconfig.call_info_bar_font,
			pos=uiconfig.call_info_bar_text_pos,
			color=uiconfig.call_info_bar_text_color)
		self.add(self.messagePrefix)
		self.messagePrefix.show()

	def changeCallerInfo(self, callerNumber, changeMessage=False):
		if self.isInService: self.isInService = False
		self.hideCallInfo()

		if changeMessage:
			self.changeMessagePrefix()

		if self.isInService: self.isInService = False
		if self.callInfo: self.callInfo.show()
		if self.incomingIcon: self.incomingIcon.show()
		if self.incomingTextIcon: self.incomingTextIcon.show()
		if self.outgoingIcon: self.outgoingIcon.show()
		if self.outgoingTextIcon: self.outgoingTextIcon.show()
		if self.timerIcon: self.timerIcon.show()
		if self.timerTextIcon: self.timerTextIcon.show()

		if self.callInfoBar: self.callInfoBar.show()
		if self.audioCallInfoIcon: self.audioCallInfoIcon.show()
		
		if self.name:
			self.name.hide()
			self.remove(self.name)
			self.name = None

		if self.number:
			self.number.hide()
			self.remove(self.number)
			self.number = None
		
		from phonedb import phonedb
		callerName = phonedb.get_name(callerNumber)

		if callerName.find('anonymous') != -1:
			self.name = runtime.evas.text(text=_('Anonymous'),
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
			self.name.show()
		elif callerName == '' or callerName == callerNumber:
			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
				self.number.show()
		else:		
			if len(unicode(callerName, 'utf-8')) > 8:
				callerName = unicode(callerName, 'utf-8')[:7].encode('utf-8') + '...'
			self.name = runtime.evas.text(text=callerName,
				font=uiconfig.call_info_name_font,
				pos=uiconfig.call_info_name_pos,
				color=uiconfig.call_info_name_color)
			self.add(self.name)
			self.name.show()

			if callerNumber:
				self.number = runtime.evas.text(text=utils.conv_telnum(callerNumber)[:13],
					font=uiconfig.call_info_number_font,
					pos=uiconfig.call_info_number_pos,
					color=uiconfig.call_info_number_color)
				self.add(self.number)
				self.number.show()

		from phonedb import phonedb
		avata = phonedb.get_snapshot2(callerNumber)
		self.set_avata(avata)

		
	def changeMessagePrefix(self, messagePrefix=None):
		runtime.mmiDebug.mmiTrace('AudioCallConnectedUI::changeMessagePrefix()')
		if self.messagePrefix:
			self.messagePrefix.hide()
			self.remove(self.messagePrefix)
			self.messagePrefix = None

		if not messagePrefix:
			messagePrefix = _('Audio call connected')
		self.messagePrefix = runtime.evas.text(text=messagePrefix,
			font=uiconfig.call_info_bar_font,
			pos=uiconfig.call_info_bar_text_pos,
			color=uiconfig.call_info_bar_text_color)
		self.add(self.messagePrefix)
		self.messagePrefix.show()

	def changeConnectedNumber(self):
		if self.name:
			self.name.hide()
			self.remove(self.name)
			self.name = None
		connectedName = status.display_caller_name(status.active_call_index)
		self.name = runtime.evas.text(text=connectedName,
			font=uiconfig.call_info_name_font,
			pos=uiconfig.call_info_name_pos,
			color=uiconfig.call_info_name_color)
		self.add(self.name)
		self.name.show()

		if self.number:
			self.number.hide()
			self.remove(self.number)
			self.number = None
		connectedNumber = status.display_caller_number(status.active_call_index)
		self.number = runtime.evas.text(text=connectedNumber,
			font=uiconfig.call_info_number_font,
			pos=uiconfig.call_info_number_pos,
			color=uiconfig.call_info_number_color)
		self.add(self.number)
		self.number.show()

	# KA: [20080515] call menu - volume
	def notify_msg_show(self, msg):
		icon, pos = uiconfig.call_notify_box
		self.notify_box = utils.put_image(icon, pos)
		self.notify_box.layer = 2
		self.notify_box.show()

		icon, pos = uiconfig.call_notify_camera_icon
		self.notify_icon = utils.put_image(icon, pos)
		self.notify_icon.layer = 2
		self.notify_icon.show()
		
		self.notify_msg = runtime.evas.text(text=msg,
			font=uiconfig.sms_notify_font,
			pos=uiconfig.call_notify_text_pos,
			color=uiconfig.color_dark_gray)
		self.notify_msg.layer = 2
		self.notify_msg.show()

		self.notify_timer = utils.Timer(3000, self.notify_msg_free)

		
	def notify_msg_free(self):
		self.notify_timer = None
		self.notify_box.free()
		self.notify_icon.free()
		self.notify_msg.free()
	# KA: [20080515] call menu - volume ==
		
	def showSoftbar(self):
		if not self.callSoftbarImage:
			icon, pos = uiconfig.call_softbar_image
			self.callSoftbarImage = utils.put_image(icon, pos)
		self.callSoftbarImage.show()

	def showSoftkey(self):
		self.showSoftbar()
		'''
		self.set_right(_('FLASH'))
		if self.micMuteFlag:
			self.set_left(_('UNMUTE'))
		else:
			self.set_left(_('MUTE'))
		self.set_menu3('')
		self.set_menu4(_('PBOOK'))
		'''

		runtime.rb.set_text_top(_('FLASH'))
		if self.micMuteFlag:
			runtime.lb.set_text_top(_('UNMUTE'))
		else:
			runtime.lb.set_text_top(_('MUTE'))
		runtime.menu3.set_text_top('')
		runtime.menu4.set_text_top(_('PBOOK'))
		
		runtime.lb.show()
		runtime.rb.show()
		runtime.menu3.show()
		runtime.menu4.show()

	def changeSoftkeyFlag(self, micMuteFlag):
		self.micMuteFlag = micMuteFlag
		if self.micMuteFlag:
			runtime.lb.set_text_top(_('UNMUTE'))
		else:
			runtime.lb.set_text_top(_('MUTE'))
		self.update_mic()

	def hideSoftkey(self):
		if self.callSoftbarImage:
			self.callSoftbarImage.hide()
			self.callSoftbarImage.free()
			self.callSoftbarImage = None

		runtime.lb.hide()
		runtime.rb.hide()
		runtime.menu3.hide()
		runtime.menu4.hide()		
		
	def hide(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex
		BaseUI.hide(self)
		
		for animationframe in self.outgoingCallAnimation:
			animationframe.hide()

#		if self.callSoftbarImage:
#			self.callSoftbarImage.hide()

		if self.secondCallInfoBar: self.secondCallInfoBar.hide()
		if self.secondAudioCallInfoIcon: self.secondAudioCallInfoIcon.hide()
		if self.secondCallMessagePrefix: self.secondCallMessagePrefix.hide()
		if self.secondCallMessageName: self.secondCallMessageName.hide()
		if self.secondCallMessageNumber: self.secondCallMessageNumber.hide()

		if self.callInfoService: self.callInfoService.hide()
		if self.firstCallNameInThreeWay: self.firstCallNameInThreeWay.hide()
		if self.firstCallNumberInThreeWay: self.firstCallNumberInThreeWay.hide()
		if self.secondCallNameInThreeWay: self.secondCallNameInThreeWay.hide()
		if self.secondCallNumberInThreeWay: self.secondCallNumberInThreeWay.hide()
		if self.threeWayTextIcon: self.threeWayTextIcon.hide()
		if self.inUseIcon: self.inUseIcon.hide()
		
		for widget in self.pressedNumber: widget.hide()

	def write_number(self, number):
		for widget in self.pressedNumber:
			widget.hide()

		self.pressedNumber = []
		from baseui import videocall_detail_layer

		self.video_call_number_image = utils.put_image(uiconfig.video_call_number_bg_img, uiconfig.video_call_number_bg_pos)
		self.video_call_number_image.layer = 2
		self.pressedNumber.append(self.video_call_number_image)
		
		self.number_text = runtime.evas.text(text=number, font=uiconfig.video_call_number_font, pos=uiconfig.video_call_number_pos, color=uiconfig.video_call_number_font_color)
		self.number_text.layer = 2
		self.pressedNumber.append(self.number_text)

		for widget in self.pressedNumber:
			widget.show()

		# shchun : per KT requirement. hide second enblock after 10 sec
		self.restart_write_number_timer()

	def hide_write_number(self):
		# shchun : per KT requirement. hide second enblock after 10 sec
		debugLogN('hide_write_number')	
		for widget in self.pressedNumber:
			widget.hide()
	
	def restart_write_number_timer(self):
		# shchun : per KT requirement. hide second enblock after 10 sec
		debugLogN('restart_write_number_timer')
		self.write_number_tag = utils.Timer(config.write_number_show_timeout, self.hide_write_number)


	def disable_write_number(self):
		for widget in self.pressedNumber:
			widget.hide()

	# KA: [20080514] call menu - volume
	def hideVolume(self):
		if self.volume_img:
			for i in range(len(self.volume_img)):
				#self.volume_img[i].free()
				del_img = self.volume_img.pop()
				del_img.free()
			self.volume_img_bg.free()
		
			
	def volume_control(self, first_flag=False, increase=True):
		#현재 path의 volume값 
		devices = runtime.SP_context.getCurrentDevice()
		for device in devices:
			from mmiSoundPath import SP_State
			if device == SP_State.DEVICE_HS:
				level = setting.handset_volume
			elif device == SP_State.DEVICE_SPK:
				level = setting.speaker_volume

		if first_flag: #최초 그림 그려준다.
			self.fill_grade(level)
		elif not first_flag and increase:
			level += 1
			if level > 5:
				level = 5
			else:
				self.up_br_grade(level)			
		else:
			level -= 1
			if level < 1:
				level = 1
			else:
				self.down_br_grade()
			
		setting.set_master_volume(level, device)
		
			
	def fill_grade(self, level):
		name, pos = uiconfig.volume_grade_bg
		self.volume_img_bg = utils.put_image(name, pos)
		self.add(self.volume_img_bg)
		
		if level < 1:
			return False
		if level > 5:
			return True
		self.volume_img=[]
		i = 0
		while i < level:
			filler_img = self.draw_grade(i)
			self.volume_img.append(filler_img)
			i = i+1
		#self.add(self.volume_img)
		return True

	# grade에 해당하는 image를 1개 그린다.
	def draw_grade(self,grade):
		start_xpos = 376
		start_ypos = 252
		filler = uiconfig.volume_grade
		pos = (start_xpos+16*grade, start_ypos)
		img = utils.put_image(filler, pos)
		self.add(img)
		return img
		
	# grade 1개 내리기
	def down_br_grade(self):
		del_img = self.volume_img.pop()
		del_img.free()

	# grade 1개 올리기
	def up_br_grade(self, level):
		filler_img = self.draw_grade(level-1)
		self.volume_img.append(filler_img)
	# KA: [20080514] call menu - volume ==
		
	def destroy(self):
		self.animationTimer = None
		self.callDurationTimer = None
		status.outgoing_ani_index = self.animationIndex
		
		if self.volume_img:
			#print 'ka....self.volume_img=', self.volume_img
			#for i in range(len(self.volume_img)):
			#	self.volume_img[i].free()
			self.hideVolume()
			#self.volume_img=[]
			#self.volume_img_bg.free()
		
		BaseUI.destroy(self)
		
		for animationframe in self.outgoingCallAnimation:
			animationframe.free()

		if self.callSoftbarImage: self.callSoftbarImage.free()

		if self.secondCallInfoBar: self.secondCallInfoBar.free()
		if self.secondAudioCallInfoIcon: self.secondAudioCallInfoIcon.free()
		if self.secondCallMessagePrefix: self.secondCallMessagePrefix.free()
		if self.secondCallMessageName: self.secondCallMessageName.free()
		if self.secondCallMessageNumber: self.secondCallMessageNumber.free()

		if self.callInfoService: self.callInfoService.free()
		if self.firstCallNameInThreeWay: self.firstCallNameInThreeWay.free()
		if self.firstCallNumberInThreeWay: self.firstCallNumberInThreeWay.free()
		if self.secondCallNameInThreeWay: self.secondCallNameInThreeWay.free()
		if self.secondCallNumberInThreeWay: self.secondCallNumberInThreeWay.free()
		if self.threeWayTextIcon: self.threeWayTextIcon.free()

		if self.inUseIcon: self.inUseIcon.free()
		
		for widget in self.pressedNumber: widget.free()
			
		if self.notify_timer: self.notify_msg_free()

class ConnectedUI_old(NotifyCallUI):
	show_bg = True
	def __init__(self, caller):
		message1 = _('Call connected') + ':'
		message2 = caller
		message3 = _('Call connected') + '(' + _('Held') + ')' + ':'

		# eicho add 06.10.13
		if status.dialed_TdESupplementary == True:
			NotifyCallUI.__init__(self, '', '', '', message1, message2, message4=message3)
		else:
			NotifyCallUI.__init__(self, _('OPTIONS'), '', '', message1, message2, message4=message3)
		# eicho end.
		self.ani_count = 0
		if status.outgoing_ani_index >= 0:
			self.ani_count = status.outgoing_ani_index
			status.outgoing_ani_index = -1
		self.outgoing_ani = None
		self.outgoing_ani = utils.put_image(uiconfig.outgoing_icon_ani[self.ani_count], uiconfig.outgoing_icon_ani_pos)
		self.add(self.outgoing_ani)
		self.ani_timer = None
		icon, pos = uiconfig.connected_hands_free_icon
		self.hands_free_image = utils.put_image(icon, pos)

		icon, pos = uiconfig.connected_mute_icon
		self.mute_image = utils.put_image(icon, pos)
		icon, pos = uiconfig.connected_wait_icon
		self.wait_image = utils.put_image(icon, pos)
#### add 06.06.09
		icon, pos = uiconfig.connected_hold_icon
		self.hold_image = utils.put_image(icon, pos)
		
		self.add(self.hands_free_image)
		self.add(self.mute_image)
		self.add(self.wait_image)
		self.add(self.hold_image)

#####################
	def set_connectedHeld_icon(self):
		#NotifyCallUI.change_message1(self)
		self.show()
		#pass
		
		
	def cancel_connectedHeld_icon(self):
		#NotifyCallUI.change_message4(self)
		self.show()
		#pass
		
#####################

	def show(self):
		# hcryoo : [20070522_1]
		if status.heldline==1:
			#print '### ui.draw_icons - held!'
			if status.get_hold_flag(status.active_call_index) or status.get_held_flag(status.active_call_index):
				NotifyCallUI.change_message1(self)
			else:
				NotifyCallUI.change_message4(self)
		else:
			#print '### ui.draw_icons - normal '
			if status.get_hold_flag(status.active_call_index) or status.get_held_flag(status.active_call_index):
				NotifyCallUI.change_message1(self)
			else:
				NotifyCallUI.change_message4(self)
		# hcryoo : [20070522_1]==
			
		NotifyCallUI.show(self)
		self.ani_timer = utils.Timer(500, self.ani_timer_cb)
		if not status.audio_mute:
			self.set_right('')
		else:
			self.set_right(_('ENABLE MIC'))

		if status.waiting:
			self.set_right(_('DISABLE WAIT'))

		self.draw_icons()

	def draw_icons(self):
		self.wait_image.hide()
		self.mute_image.hide()
		self.hands_free_image.hide()
		self.hold_image.hide()
		
		# hcryoo : [20070522_1]
		if status.heldline==1:
			if status.get_hold_flag(status.active_call_index) or status.get_held_flag(status.active_call_index):
				self.hold_image.show()
			else:
				if status.waiting:
					self.wait_image.show()
				elif status.audio_mute:
					self.mute_image.show()
				elif status.modem_audio_state == status.SPK:
					self.hands_free_image.show()
		else:
			if status.get_hold_flag(status.active_call_index) or status.get_held_flag(status.active_call_index):
				self.hold_image.show()
			else:
				if status.waiting:
					self.wait_image.show()
				elif status.audio_mute:
					self.mute_image.show()
				elif status.modem_audio_state == status.SPK:
					self.hands_free_image.show()
		# hcryoo : [20070522_1]==
	

	def ani_timer_cb(self):
		if not self.ani_timer:
			return
		if self.ani_count == -1:
			self.ani_count += 1
		else:
			self.ani_count += 1
			if self.ani_count > 3:
				self.ani_count = 0
		self.outgoing_ani.file = uiconfig.image_dir + uiconfig.outgoing_icon_ani[self.ani_count]
		return True

	def hide(self):
		self.ani_timer = None
		NotifyCallUI.hide(self)

	def destroy(self):
		self.ani_timer = None
		NotifyCallUI.destroy(self)

class NameConflictUI(BaloonMessageUI):
	def __init__(self):
		icon = uiconfig.baloon_phonebook_icon
		message = _('Name already in phonebook')
		BaloonMessageUI.__init__(self, _('MODIFY'), _('VIEW'), '', icon, message)

class DateEditUI(SmallWindowUI):
	def __init__(self, title, subtitle, date, icon=None):
		SmallWindowUI.__init__(self, _('OK'), _('BACK'), title, subtitle)
		self.icon = icon
		self.date = date
		self.cursor_pos = 0
		year, mon, day = self.date
		self.editing_text = [day/10, day%10, mon/10, mon%10, year/1000, (year/100)%10, (year%100)/10, year%10]

		#date = day,mon,year
		self.date_label = runtime.evas.text(text=self.get_text(),font=uiconfig.date_edit_font)
		self.date_label.color = uiconfig.date_edit_entry_color
		self.date_label.pos = uiconfig.date_edit_pos
		self.add(self.date_label)
		self.underline = runtime.evas.text(text='_', font=uiconfig.date_edit_font)
		self.underline.color = uiconfig.date_edit_entry_color
		self.add(self.underline)
		self.update_underline()

	def update_underline(self):
		font_width = uiconfig.date_edit_char_width
		font_height = uiconfig.date_edit_underline_y
		pos = uiconfig.date_edit_pos
		xpos = (0, 1, 3, 4, 6, 7, 8, 9)[self.cursor_pos]
		x = pos[0] + xpos * font_width
		self.underline.pos = x, pos[1] + font_height

	def get_text(self):
		text = "%01d%01d/%01d%01d/%01d%01d%01d%01d" % tuple(self.editing_text)
		return text

	def update_date(self):
		day = self.editing_text[0] * 10 + self.editing_text[1]
		mon = self.editing_text[2] * 10 + self.editing_text[3]
		year = self.editing_text[4] * 1000 + self.editing_text[5] * 100 + self.editing_text[6] * 10 + self.editing_text[7]
		self.date = (year, mon, day)
		self.date_label.text = self.get_text()

	def handle_key(self, key):
		if key in "0123456789":
			if self.cursor_pos == 0:
				#day 10
				if not key in "0123":
					return True
				day = (ord(key)-ord('0')) * 10 + self.editing_text[1]
				mon = self.editing_text[2] * 10 + self.editing_text[3]
				if day == 0 or day > 31:
					self.editing_text[1] = 1

			elif self.cursor_pos == 1:
				day = self.editing_text[0] * 10 + ord(key) - ord('0')
				mon = self.editing_text[2] * 10 + self.editing_text[3]
				if day > 31 or day == 0:
					return True
			elif self.cursor_pos == 2:
				#mon 10
				if not key in "01":
					return True
				mon = (ord(key)-ord('0')) * 10 + self.editing_text[3]
				day = self.editing_text[0] * 10 + self.editing_text[1]
				if mon == 0:
					self.editing_text[3] = 1
				elif mon > 12:
					self.editing_text[3] = 2
			elif self.cursor_pos == 3:
				#mon 1
				mon = self.editing_text[2] * 10 + ord(key) - ord('0')
				day = self.editing_text[0] * 10 + self.editing_text[1]
				if mon > 12 or mon == 0:
					return True
			elif self.cursor_pos == 4:
				# 2000 or 1900
				if not key in "12":
					return True
				if key == '1' and self.editing_text[5] != 9:
					self.editing_text[5] = 9
				elif key == '2' and self.editing_text[5] != 0:
					self.editing_text[5] = 0
			elif self.cursor_pos == 5:
				# 2000 or 1900
				if not key in "09":
					return True
				yy = self.editing_text[4] * 10 + ord(key) - ord('0')
				if yy < 19 or yy > 20:
					return True
			elif self.cursor_pos == 6:
				# 1970 ~ 2037
				if self.editing_text[5] == 9:
					if not key in "789":
						return True
				else:
					if not key in "0123":
						return True
			elif self.cursor_pos == 7:
				if self.editing_text[6] == 3:
					if not key in "01234567":
						return True
				#pass
			self.editing_text[self.cursor_pos] = ord(key) - ord('0')
			self.update_date()
			self.cursor_pos += 1
			if self.cursor_pos > 7:
				self.cursor_pos = 0
			self.update_underline()
			return True
		elif key == 'Right':
			self.cursor_pos += 1
			if self.cursor_pos > 7:
				self.cursor_pos = 0
			self.update_underline()
		elif key == 'Left':
			self.cursor_pos -= 1
			if self.cursor_pos < 0:
				self.cursor_pos = 7
			self.update_underline()
			return True
		elif key == config.Menu1:
			from basemodel import NotifyStage
			year, mon, day = self.date

			def show_not_valid():
				runtime.manager.stack_stage(NotifyStage(_('Not valid date'), self.icon))
			if mon == 2 and day > 29:
				show_not_valid()
				return False
			elif mon in (2,4,6,9,11) and day > 30:
				show_not_valid()
				return False
			if year < 1970 or year > 2037:
				show_not_valid()
				return False
			return True
		elif key == config.Menu2:
			runtime.manager.back_stage()
			return True
			if self.cursor_pos == 0:
				runtime.manager.back_stage()
				return True
			self.cursor_pos -= 1
			if self.cursor_pos < 0:
				self.cursor_pos = 5
			self.update_underline()
			return True
		return False

class TimeEditUI(SmallWindowUI):
	def __init__(self, title, subtitle, time):
		SmallWindowUI.__init__(self, _('OK'), _('BACK'), title, subtitle)
		self.time = time
		self.cursor_pos = 0
		hour, min = self.time

		self.editing_text = [hour/10, hour%10, min/10, min%10]

		#date = day,mon,year
		self.time_label = runtime.evas.text(text=self.get_text(),font=uiconfig.date_edit_font)
		self.time_label.color = uiconfig.date_edit_entry_color
		self.time_label.pos = uiconfig.date_edit_pos
		self.add(self.time_label)
		self.underline = runtime.evas.text(text='_', font=uiconfig.date_edit_font)
		self.underline.color = uiconfig.date_edit_entry_color
		self.add(self.underline)
		self.update_underline()

	def update_underline(self):
		font_width = uiconfig.date_edit_char_width
		font_height = uiconfig.date_edit_underline_y
		pos = uiconfig.date_edit_pos
		xpos = (0, 1, 3, 4)[self.cursor_pos]
		x = pos[0] + xpos * font_width
		self.underline.pos = x, pos[1] + font_height

	def get_text(self):
		text = "%01d%01d:%01d%01d" % tuple(self.editing_text)
		return text

	def update_time(self):
		hour = self.editing_text[0] * 10 + self.editing_text[1]
		min = self.editing_text[2] * 10 + self.editing_text[3]
		self.time = (hour, min)
		self.time_label.text = self.get_text()

	def handle_key(self, key):
		if key in "0123456789":
			if self.cursor_pos == 0:
				#hour 10
				if not key in "012":
					return True
				if key == '2' and self.editing_text[1] > 3:
					self.editing_text[1] = 3
			elif self.cursor_pos == 1:
				#hour 1
				hour = self.editing_text[0] * 10 + ord(key) - ord('0')
				if hour > 23:
					return True
			elif self.cursor_pos == 2:
				#min 10
				if not key in "012345":
					return True
			elif self.cursor_pos == 3:
				pass
			self.editing_text[self.cursor_pos] = ord(key) - ord('0')
			self.update_time()
			self.cursor_pos += 1
			if self.cursor_pos > 3:
				self.cursor_pos = 0
			self.update_underline()
			return True
		elif key == 'Right':
			self.cursor_pos += 1
			if self.cursor_pos > 3:
				self.cursor_pos = 0
			self.update_underline()
		elif key == 'Left':
			self.cursor_pos -= 1
			if self.cursor_pos < 0:
				self.cursor_pos = 3
			self.update_underline()
			return True
		elif key == config.Menu2:
			runtime.manager.back_stage()
			return True

			if self.cursor_pos == 0:
				runtime.manager.back_stage()
				return True
			self.cursor_pos -= 1
			if self.cursor_pos < 0:
				self.cursor_pos = 3
			self.update_underline()
			return True
		return False

class TimerEditUI(TimeEditUI):
	def __init__(self, title, subtitle, time):
		TimeEditUI.__init__(self, title, subtitle, time)
		self.mmss_label = runtime.evas.text(text=_('MM') +' : '+_('SS'), font=uiconfig.date_edit_font)
		self.mmss_label.color = uiconfig.baloon_text_color
		self.mmss_label.pos = uiconfig.date_edit_pos[0], uiconfig.date_edit_pos[1]+30
		self.add(self.mmss_label)
		self.set_right(_('BACK'))

	def update_underline(self):
		font_width = uiconfig.date_edit_char_width
		font_height = uiconfig.date_edit_underline_y
		pos = uiconfig.date_edit_pos
		xpos = (0, 1, 3, 4)[self.cursor_pos]
		x = pos[0] + xpos * font_width
		self.underline.pos = x, pos[1] + font_height

	def handle_key(self, key):
		# timer min value = 00:10
		# timer max value = 59:59
		if key in "0123456789":
			if self.cursor_pos == 0:
				if not key in "012345":
					return True
				if key == '0' and self.editing_text[1] == 0 and self.editing_text[2] == 0:
					self.editing_text[2] = 1
			elif self.cursor_pos == 1:
				if key == '0' and self.editing_text[0] == 0 and self.editing_text[2] == 0:
					self.editing_text[2] = 1
			elif self.cursor_pos == 2:
				if self.editing_text[0] == 0 and self.editing_text[1] == 0:
					if not key in "12345":
						return True
				else:
					if not key in "012345":
						return True
			self.editing_text[self.cursor_pos] = ord(key) - ord('0')
			self.update_time()
			self.cursor_pos += 1
			if self.cursor_pos > 3:
				self.cursor_pos = 0
			self.update_underline()
			return True
		elif key == 'Right':
			self.cursor_pos += 1
			if self.cursor_pos > 3:
				self.cursor_pos = 0
			self.update_underline()
		elif key == 'Left':
			self.cursor_pos -= 1
			if self.cursor_pos < 0:
				self.cursor_pos = 3
			self.update_underline()
			return True
		elif key == config.Menu2:
			runtime.manager.back_stage()
			return True
		return False

class DigitEditUI(SmallWindowUI):
	def __init__(self, prefix, title, subtitle, max_chars=1):
		SmallWindowUI.__init__(self, _('OK'), _('BACK'), title, subtitle)
		self.prefix = prefix

		prefix_label = runtime.evas.text(text=self.prefix,font=uiconfig.pin_prefix_font)
		prefix_label.color = uiconfig.pin_edit_color
		prefix_label.pos = uiconfig.pin_edit_pos
		self.add(prefix_label)

		x,y = prefix_label.geometry_get()[:2]
		edit_pos = x+prefix_label.horiz_advance_get(), y

		import entry
		self.entry = entry.Entry(edit_pos, uiconfig.pin_edit_size)
		self.entry.set_max(max_chars)
		self.entry.set_automata('123', False)
		self.add(self.entry)

		pos = uiconfig.entry_info_pos
		font = uiconfig.entry_info_font
		color = uiconfig.entry_info_color
		self.einfo = widget.OutlineLabel('', font, pos, color, align=uiconfig.ALIGN_RIGHT)
		self.add(self.einfo)

		self.automata_icon = None

	def show(self):
		SmallWindowUI.show(self)
		self.update_entry_info()
		self.update_automata_icon()

	def destroy(self):
		if self.automata_icon: self.automata_icon.free()
		SmallWindowUI.destroy(self)

	def set_entry_info(self, text):
		self.einfo.set_text(text)

	def update_entry_info(self):
		if self.entry.get_max():
			self.set_entry_info( '%d/%d' % (self.entry.length(), self.entry.get_max()) )

	def update_automata_icon(self):
		name = self.entry._automata.name()
		casemode = self.entry._automata.case_mode()

		self.automata = name, casemode

		if self.automata_icon:
			self.automata_icon.free()

		self.automata_icon = utils.put_image(uiconfig.edit_automata_info_icon(name,casemode), uiconfig.entry_automata_info_pos)
		self.automata_icon.show()

	def get_text(self):
		return self.entry.get_text()

	def delete_char(self):
		self.entry.backspace()
		self.set_right(_('BACK'))
		self.update_entry_info()

	def handle_key(self, keyname):
		if keyname.isdigit():
			self.entry.set_text(keyname)
			self.set_right(_('CLR'))
			self.update_entry_info()
			return True
		return False

#옛 소스 땜시 prefix를 그대로 두었음. 쓰이지는 않는다
class NormalDigitEditUI(EntryUI):
	def __init__(self, prefix, title, subtitle, digit_max_len=20):
		EntryUI.__init__(self, _('OK'), '', title, subtitle, menu4=_('BACK'))
		self.set_fixed_automata('123', False)
		self.set_max(digit_max_len)
		
		self.fixed_automata = False
		self.automata_icon = None
		self.automata_idx = 0
		self.automata = config.automata_list_mult_num
	def handle_key(self, key):
#ka...hangul 2007.02.05 added

		if key == '*':
			self.insert_text('.')
		elif key == '#':
			return True
		#if key == '*' or  key == 'SOFT3':
		#	self.insert_text('.')
		#elif key == '#' or key == 'SOFT4':
		#	return True

# --- End of modify
		elif key == config.Menu4:
			if EntryUI.handle_key(self, key):
				return True
			if self.menu4 == _('BACK'):
				runtime.manager.back_stage()
				return True
		else:
			return EntryUI.handle_key(self, key)
		return False


#ka...Detail 2006.11.07
class CallDetailUI(RichTextUI):
	def __init__(self, calltype, number, name, date, time, count=0, vcount=0):
		font = uiconfig.calllog_details_font
		RichTextUI.__init__(self, left=_('MENU'), text_font = font, menu3=_('CLR'), menu4=_('BACK')) #새로 만들어야 한다.  small title set해줘야 함

		t = ''
		number = _('Number')+ ': ' + number + '\n'
		t += number

		if name:
			name = _('Name')+ ': ' + name + '\n'
			t += name

		t += _('Date')+ ': ' + date + '\n'
		t += _('Time')+ ': ' + time + '\n'

		if calltype == 1: #'missed'
			if count:
				count = _('Number of calls')+ ': ' + str(count+vcount) + '\n'
				t += count
		else:
			if count:
				count = _('Number of voice calls')+ ': ' + str(count) + '\n'
				t += count
			if vcount:
				vcount = _('Number of video calls')+ ': ' + str(vcount) + '\n'
				t += vcount
		self.set_text(t)


class PINInputUI(CheckPasswordUI):
	def __init__(self, left, right, menu3, menu4, digit_max_len=4):
		CheckPasswordUI.__init__(self, left, right, menu3, menu4)
		self.digit_max_len = digit_max_len
		self.digits = ''

		prefix_label = runtime.evas.text(text=_('Password'), font=uiconfig.input_font)
		prefix_label.pos = (uiconfig.pw_entry_pos_x2, uiconfig.pw_entry_pos_y1+16-uiconfig.input_font[1]/2-2)
		prefix_label.color = uiconfig.color_dark_gray
		self.add(prefix_label)

		import entry
		pos = (uiconfig.pw_entry_pos_x3, uiconfig.pw_entry_pos_y1)
		self.entry = entry.Entry(pos, uiconfig.pw_entry_size)
		self.entry.set_max(digit_max_len)
		self.entry.set_automata('123', False)
		self.entry.set_text('')
		self.add(self.entry)
		self.digits = self.get_text()
		#print '##########self.entry.get_text',self.digits
		self.pin = ''

	def get_text(self):
		return self.entry.get_text()

	def insert_symbol(self, s):
		before_text = self.get_text()
		self.insert_text(s)
		after_text = self.get_text()
		if before_text == after_text:
			runtime.manager.change_stage(NotifyStage(_('Max length exceeded'), uiconfig.baloon_message_icon))
		else:
			runtime.manager.back_stage()
		
	def update_underline(self):
		self.digits = self.entry.set_text(self.digits)
		print '##########self.digits',self.digits
		#f = open('password.txt','r')
		#self.password2 = f.readline().split(',')[:-1]
		#self.password2 = self.password2[0]
		#f.close()
		#if len(self.pin) == 0:
		#	self.set_right('')
		#else:
		#	self.set_right(_('CLR'))
		#if len(self.pin) <7:
		#if len(self.pin) < len(self.password2):
		#	self.set_left('')
		#else:
		#	self.set_left(_('OK'))

	def update(self):
		self.digits = '*' * len(self.pin)
		'''
		print '#########update',self.digits
		print '########self.pin',self.pin
		print '$$$$$$$$len(self.pin)',len(self.pin)
		'''
		self.update_underline()
		
	def reset(self):
		self.pin = ''
		self.set_right('')
		self.update()	
		
	def delete_backward(self):
		if len(self.pin) >= 1: #if len(self.entry.get_text()) >=1:
			self.pin = self.pin[:-1]
			if len(self.pin) == 0: #if len(self.entry.get_text()) == 0:
				self.set_right('')
			else:
				self.set_right(_('CLR'))
			self.update()	
	
	def handle_key(self, keyname):
		if keyname.isdigit():
			if len(self.pin) < 4:
				self.pin += keyname
				#print 'press key:',keyname
				self.entry.set_text(keyname)
				self.set_right(_('CLR'))
				#if len(self.pin) >= config.len_pw_number:
					#return False
				#print 'pin nhap vao',self.pin
				self.update()
			return True
		return True


class PopupNotifyUI(PopupWindowUI):
	def __init__(self, title, menu1, menu2, menu3, menu4, message1, message2):
		PopupWindowUI.__init__(self, menu1, menu2, menu3, menu4, title)

		self.font=uiconfig.pop_window_font
		self.color=uiconfig.pop_window_text_color

		if message2 == '':
			self.pos1 = uiconfig.pop_window_text1_pos
			self.msg1 = runtime.evas.text(text=message1, pos=self.pos1, color=self.color, font=self.font)
			self.add(self.msg1)
			self.align_center(self.msg1, self.pos1)
		else:
			self.pos1 = uiconfig.pop_window_text2_pos[0]
			self.msg1 = runtime.evas.text(text=message1, pos=self.pos1, color=self.color, font=self.font)
			self.add(self.msg1)
			self.align_center(self.msg1, self.pos1)

			self.pos2 = uiconfig.pop_window_text2_pos[1]
			self.msg2 = runtime.evas.text(text=message2, pos=self.pos2, color=self.color, font=self.font)
			self.add(self.msg2)
			self.align_center(self.msg2, self.pos2)
			
	def align_center(self, l, pos):
		x, y = pos
		width, height = l.size
		l.move(x - width/2, y)

'''
class PasswordNotifyUI3(PopupWindowUI):		
	def __init__(self,menu1,menu2,menu3,menu4,title):
		PopupWindowUI.__init__(self,menu1,menu2,menu3,menu4,title)
		
		pos1 = 250-10,108
		self.pwmsg1=runtime.evas.text(text="New software is available", pos=pos1, color=uiconfig.date_edit_entry_color,\
							font=uiconfig.pop_window_font)
		self.add(self.pwmsg1)
		self.align_center(self.pwmsg1, pos1)

		pos2 = 250-10,130
		self.pwmsg2=runtime.evas.text(text="Do you update now", pos=pos2, color=uiconfig.date_edit_entry_color,\
							font=uiconfig.pop_window_font)
		self.add(self.pwmsg2)
		self.align_center(self.pwmsg2, pos2)
		
	def align_center(self, l, pos):
		x, y = pos
		width, height = l.size
		l.move(x - width/2, y)
'''
'''
class YesNoUpdateUI(PopupWindowUI):
	def __init__(self,message1,menu1,menu2,menu3,menu4,title):
		PopupWindowUI.__init__(self,menu1,menu2,menu3,menu4,title)
		pos1 = 250-10,124
		self.message1 = message1
		message1 = ''
		self.pwmsg1=runtime.evas.text(text = self.message1, pos = pos1,color = uiconfig.date_edit_entry_color,\
							font=uiconfig.pop_window_font)
		self.add(self.pwmsg1)
		self.align_center(self.pwmsg1, pos1)
		
	def align_center(self, l, pos):
		x, y = pos
		width,height = l.size
		l.move(x - width/2, y)	
'''
		
class UpdateProgressUI(PopupNotifyUI):
	def __init__(self, message, menu1, menu2, menu3, menu4):
		PopupNotifyUI.__init__(self, _('INFO'), menu1, menu2, menu3, menu4, message, ' ')
		
		self.pro_img_index = 0
		self.progress_image = ('load_01.png', 'load_02.png', 'load_03.png', 'load_04.png', 'load_05.png')
		self.progress = utils.put_image('load_01.png', (201-10,154), (98,14))
		self.add(self.progress)
		#self.progress_timer = utils.Timer(1500, self.progress_timer_cb)
		
	def show(self):
		PopupNotifyUI.show(self)
		
	def hide(self):
		self.progress_timer = None
		PopupNotifyUI.hide(self)

	def set_percent(self, percent):
		print 'UpdateProgressUI.set_percent', percent
		if 0 <= percent < 20:		self.pro_img_index = 0
		elif 20 <= percent < 40:	self.pro_img_index = 1
		elif 40 <= percent < 60:	self.pro_img_index = 2
		elif 60 <= percent < 80:	self.pro_img_index = 3
		elif 80 <= percent < 100:	self.pro_img_index = 4
		else:					self.pro_img_index = 4
			
		self.progress .file = uiconfig.image_dir + self.progress_image[self.pro_img_index]
		self.progress.pos = (201-10, 154)
		runtime.evas.render_now()
		self.pro_img_index += 1

	def destroy(self):
		self.progress_timer = None
		PopupNotifyUI.destroy(self)
#Hau[200804] menu -->setting -->phone information-->update software

	
class AudioDetailUI(LargeWindowUI):
	def __init__(self, file, date, filesize):
		LargeWindowUI.__init__(self, '','',_('DETAILS'),_('DETAILS'),'',_('BACK'))

		pos = uiconfig.large_window_pos
		font = uiconfig.large_window_text_font

		def get_multiline_filename(file, width, font):
			buf_text = ''
			filename = []

			for i in range(len(file)):
				buf_text += file[i]

				t = runtime.evas.text(text=buf_text, font=font)
				w = t.geometry[2]
				if w >= width: # cut line
					filename.append(buf_text)
					buf_text = ''

				t.free()

			if len(buf_text) > 0:
				filename.append(buf_text)

			return filename

		file = _('File')+ ': ' + file
		detail_list = get_multiline_filename(file, uiconfig.large_window_text_width, font)
		detail_list.append(_('Date')+ ': ' + date)
		detail_list.append(_('File size')+ ': ' + filesize)

		for i, text in enumerate(detail_list):
			x = pos[0] + uiconfig.large_window_text_pos_x
			y = pos[1] + uiconfig.large_window_text_pos_y[i]
			t = runtime.evas.text(text=text, pos=(x, y), \
				color=uiconfig.large_window_text_color, \
				font=font)
			self.add(t)

class MenuUI(BaseUI):
	show_topmenu_bg = False
	def __init__(self):
		BaseUI.__init__(self, '', '', '')
		self.ani_index = 0
		self.hani_timer = None
		self.focus = 0
		self.menu_list = None
		self.focus_bg = None
		self.topmenu_bg = None
		#self.add(self.softkey_image)
# KA: [20070814] text ui
#		if setting.lang == 'English':
#			self.topmenu_bg = 'top_bg_en.png'
#			self.focus_bg = ('sel_menu1_en.png', 'sel_menu2_en.png', \
#				'sel_menu3_en.png', 'sel_menu4_en.png', 'sel_menu5_en.png', 'sel_menu6_en.png')
#		else:
#			self.topmenu_bg = 'top_bg.png'
#			self.focus_bg = ('sel_menu1.png', 'sel_menu2.png', \
#				'sel_menu3.png', 'sel_menu4.png', 'sel_menu5.png', 'sel_menu6.png')

#Hau: [20080314] change bg
		self.topmenu_bg = ('bg_black.png','bg_white.png')
		self.focus_bg = ('select.png', 'select.png', 'select.png', 'select.png', \
				'select.png', 'select.png','select.png', 'select.png')
		self.title_images = ('tit_01_1.png','tit_03_1.png','tit_02_1.png','tit_04_1.png','tit_05_1.png','tit_07_1.png','tit_06_1.png','tit_08_1.png')
# KA: [20070814] text ui ==
		self.ani_size_1 = ((109, 106), (115, 119), (104, 114), (111, 102), (109, 109), (113, 100),(126,96),(121,103))
		self.ani_size_2 = ((120,118), (117,115), (118,117), (120,119), (110,119), (110,109),(117,116),(115,115))
#Hau: [20080314] change bg
		
		if setting.menu_bg_mode == 0:
			self.topmenu_bg_image = utils.put_image(self.topmenu_bg[0], (0, 0))
			"""
			self.add(self.topmenu_bg_image)
			self.put_title_focus_image()
			self.ani_image = utils.put_image(uiconfig.menu_topmenu_animation_images_blk[0][0], uiconfig.menu_topmenu_animation_pos_blk[0])
			self.ani_image.hide()
			self.add(self.ani_image)
			"""
		else:
			self.topmenu_bg_image = utils.put_image(self.topmenu_bg[1], (0, 0))
		self.add(self.topmenu_bg_image)
		self.put_title_focus_image()
		self.ani_image = utils.put_image(uiconfig.menu_topmenu_animation_images_wht[0][0], uiconfig.menu_topmenu_animation_pos_wht[0])
		self.ani_image.hide()
		self.add(self.ani_image)
		# FOR test
		#self.topmenu_bg_image.layer = title_image_layer #menu_layer
		#self.topmenu_bg_image.layer = -1
		
# KA: [20070814] text ui
# KT DEMO 20080125
		self.menuitems = []
		menutexts = (_('Life Service'), _('Phonebook'), _('Messages'), _('Tools'), _('Multimedia'), _('Sounds'), _('Display'), _('Settings'))

		for_help_wording = _('CALL HISTORY')
		for i in range(8):
			self.menuitems.append(runtime.evas.OutlineLabelEx(text=menutexts[i],
										font = uiconfig.menu_topmenu_font,
										pos = uiconfig.menu_topmenu_text_pos[i],
										color = uiconfig.menu_topmenu_color[i],
										outline_color = uiconfig.menu_topmenu_outline_color,
										align = 1, # uiconfig.ALIGN_CENTER
										abbr_width = uiconfig.large_window_text_width,
										valign = 12)) # VALIGN_CENTER
		for item in self.menuitems:
			item.show()
			self.add(item)

# KA: [20070814] text ui ==

		self.set_focus(0)
	def put_title_focus_image(self):
		self.focus_bg_image = utils.put_image(self.focus_bg[0], uiconfig.menu_topmenu_button_pos[0])
		self.focus_bg_image.hide()
		self.add(self.focus_bg_image)
#Hau: [20080314] add title
#		self.tit_image = utils.put_image(self.title_images[0],uiconfig.menu_topmenu_title_pos[0])
#		self.tit_image.hide()
#		self.add(self.tit_image)

	def show(self):
		BaseUI.show(self)
		self.set_focus(self.focus, show_method=True)
		
		
	def hide(self):
		self.hani_timer = None
		BaseUI.hide(self)
		
	def set_focus(self, i, show_method=False):
		self.focus = i
		self.ani_index = 0
		if setting.menu_bg_mode == 0:
			self.update_title()
#Hau: [20080314] add title
			self.topmenu_bg_image .file = uiconfig.image_dir + self.topmenu_bg[0]
			"""
			self.ani_image.file = uiconfig.image_dir  + uiconfig.menu_topmenu_animation_images_blk[self.focus][self.ani_index]
			self.ani_image.pos = uiconfig.menu_topmenu_animation_pos_blk[self.focus]
			self.ani_image.fill_set(0, 0, self.ani_size_1[self.focus][0], self.ani_size_1[self.focus][1])
			self.ani_image.size = self.ani_size_1[self.focus]
			"""
		else:
			self.update_title()
			self.topmenu_bg_image .file = uiconfig.image_dir + self.topmenu_bg[1]
		self.ani_image.file = uiconfig.image_dir  + uiconfig.menu_topmenu_animation_images_wht[self.focus][self.ani_index]
		self.ani_image.pos = uiconfig.menu_topmenu_animation_pos_wht[self.focus]
		self.ani_image.fill_set(0, 0, self.ani_size_2[self.focus][0], self.ani_size_2[self.focus][1])
		self.ani_image.size = self.ani_size_2[self.focus]

		runtime.evas.render_now()
		self.ani_index += 1
		self.hani_timer = utils.Timer(uiconfig.ani_time, self.ani_timer_cb)

	def update_title(self):
		self.focus_bg_image.file = uiconfig.image_dir  + self.focus_bg[self.focus]
		self.focus_bg_image.pos = uiconfig.menu_topmenu_button_pos[self.focus]
#Hau: [20080314] add title
#		self.tit_image.file = uiconfig.image_dir + self.title_images[self.focus]
#		self.tit_image.pos = uiconfig.menu_topmenu_title_pos[self.focus]

	def ani_timer_cb(self):
		"""
		if setting.menu_bg_mode == 0:
			if self.hani_timer == None:
				return
			if self.ani_index >= 11:
				self.hani_timer = None
				self.ani_index = 0
				return False
			else:
				self.ani_image.file = uiconfig.image_dir  + uiconfig.menu_topmenu_animation_images_blk[self.focus][self.ani_index]
				self.ani_image.pos = uiconfig.menu_topmenu_animation_pos_blk[self.focus]
				runtime.evas.render_now()
				self.ani_index += 1
				return True
		else:
		"""
		if self.hani_timer == None:
			return
		if self.ani_index >= 6:
			self.hani_timer = None
			self.ani_index = 0
			return False
		else:
			self.ani_image.file = uiconfig.image_dir  + uiconfig.menu_topmenu_animation_images_wht[self.focus][self.ani_index]
			self.ani_image.pos = uiconfig.menu_topmenu_animation_pos_wht[self.focus]
			runtime.evas.render_now()
			self.ani_index += 1
			return True

	def handle_key(self, key):
		y, x = divmod(self.focus, 4)
		if key == 'Left':
			x -= 1
			if x < 0:
				x = 3
				if y == 0:
					y = 1
				else:
					y -= 1
		elif key == 'Right':
			x += 1
			if x > 3:
				x = 0
				if y == 1:
					y = 0
				else:
					y += 1
		elif key == 'Up':
			y -= 1
			if y < 0:
				y = 1
				x -= 1
				if x < 0:
					x = 3
		elif key == 'Down':
			y += 1
			if y > 1:
				y = 0
				x += 1
				if x > 3:
					x = 0
		else:
			return False
		self.set_focus(x + y * 4)
		return True

	def update_calllog_caption(self):
		pass

#	def change_theme(self):
#		self.top_image.file = uiconfig.image_dir  + uiconfig.current_theme.indicator_bar

	def change_language(self):
# KA: [20070814] text ui ==
#		if setting.lang == 'English':
#			self.topmenu_bg = 'top_bg_en.png'
#			self.focus_bg = ('sel_menu1_en.png', 'sel_menu2_en.png', \
#				'sel_menu3_en.png', 'sel_menu4_en.png', 'sel_menu5_en.png', 'sel_menu6_en.png')
#		else:
#			self.topmenu_bg = 'top_bg.png'
#			self.focus_bg = ('sel_menu1.png', 'sel_menu2.png', \
#				'sel_menu3.png', 'sel_menu4.png', 'sel_menu5.png', 'sel_menu6.png')

#Hau: [20080314] change bg
		self.topmenu_bg = 'bg_black.png'
		self.focus_bg = ('select.png', 'select.png', 'select.png', 'select.png', \
				'select.png', 'select.png','select.png', 'select.png')
		self.title_images = ('tit_01.png','tit_02.png','tit_03.png','tit_04.png','tit_05.png','tit_06.png','tit_07.png','tit_08.png')
				
#		for i in range(6):
#			self.menuitems[i].change_language()		
# KA: [20070814] text ui ==

#Hau: [20080314] change bg
		self.topmenu_bg_image.file = uiconfig.image_dir  + self.topmenu_bg
		self.focus_bg_image.file = uiconfig.image_dir  + self.focus_bg[self.focus]
		#self.tit_image.file =  uiconfig.image_dir  +self.title_images
#		self.tit_image.file = uiconfig.image_dir + self.title_images[self.focus]
		BaseUI.change_language(self)

class DetailsUI(LargeWindowUI):
	def __init__(self):
		LargeWindowUI.__init__(self, '', _('BACK'), _('DETAILS'), _('DETAILS'))

		self.l = widget.Label('', uiconfig.details_font, uiconfig.details_pos, uiconfig.details_color, align=uiconfig.ALIGN_LEFT)
		self.add(self.l)

	def set_text(self, text):
		self.l.set_text(text)

class CurrentMelodyUI(BaloonUI):
	def __init__(self, title, melody, font = None):
		BaloonUI.__init__(self, _('OPTIONS'), _('BACK'), title, uiconfig.baloon_phonebook_icon)

		if font:
			new_font = font
		else:
			new_font = uiconfig.current_melody_font2

		t = runtime.evas.text(text=_('Current melody: '), font=uiconfig.current_melody_font1)
		t.color = uiconfig.current_melody_color1
		t.pos = uiconfig.current_melody_pos1
		self.add(t)

		t = runtime.evas.text(text=melody, font=new_font)
		t.color = uiconfig.current_melody_color2
		t.pos = uiconfig.current_melody_pos2
		self.add(t)

class MaintenanceMessageUI(BaloonMessageUI):
	def __init__(self, message):
		BaloonMessageUI.__init__(self, '', '', '',uiconfig.baloon_message_icon, message)


#class VideoPreviewUI(LargeWindowUI):
class VideoPreviewUI(BaseUI):
	def __init__(self, left, right, title, subtitle,menu3='', menu4=''):
		#LargeWindowUI.__init__(self, left, right, title, subtitle, menu3, menu4)

		BaseUI.__init__(self, left, right, title, menu3, menu4)

		# bg image
		bg_image = utils.put_image(uiconfig.depth_bg_image, (0, 0))
		bg_image.hide()
		self.add(bg_image)

		# title image	검색
		#titleimage = uiconfig.Third_title_video_recorder
		#name, pos = titleimage
		#title_image = utils.put_image(name, pos)
		#title_image.hide()
		#self.add(title_image)

		# recording Background
		rec_bg_img = uiconfig.mmp_record_bg
		name, pos = rec_bg_img
		rec_bg_image = utils.put_image(name, pos)
		rec_bg_image.hide()
		self.add(rec_bg_image)

		# record information background
		rec_info_bg_img = uiconfig.mmp_rec_info_bg
		name, pos = rec_info_bg_img
		rec_info_bg_image = utils.put_image(name, pos)
		rec_info_bg_image.hide()
		self.add(rec_info_bg_image)

		pos = uiconfig.audio_record_max_duration_pos
		color = uiconfig.audio_record_max_duration_color
		font = uiconfig.audio_record_duration_font
		self.max_duration = runtime.evas.text(pos=pos,color=color,font=font)
		self.max_duration.text =  '00:00'#_('Max: ') + '00:00'
		self.add(self.max_duration)

		font = uiconfig.video_record_duration_font

		'''
		self.progress = widget.Progress(uiconfig.video_record_progress_pos, \
					uiconfig.video_record_progress_size, \
					uiconfig.video_record_progress_out_icon, \
					uiconfig.video_record_progress_in_icon)
		'''
		self.progress = widget.Progress(pos=uiconfig.video_record_progress_pos, \
					size=uiconfig.video_record_progress_size, \
					in_icon=uiconfig.video_record_progress_in_icon_new)
		
		self.add(self.progress)

		pos = uiconfig.video_record_duration_pos
		color = uiconfig.video_record_duration_color
		self.duration = runtime.evas.text(pos=pos,color=color,font=font)
		self.duration.text = '00:00'
		self.add(self.duration)

	def set_max_duration(self, max):
		self.max_duration.text = '%02d:%02d' % divmod(max, 60)
		self.progress.set_max_value(max)

	def set_value(self, value):
		self.progress.set_value(value)

#class AudioRecordUI(SmallWindowUI):
class AudioRecordUI(BaseUI):
	def __init__(self, left, right, title, subtitle,menu3='', menu4=''):
		
		
		#SmallWindowUI.__init__(self, left, right, title, subtitle, menu3, menu4)
		BaseUI.__init__(self, left, right, title, menu3, menu4)

		# bg image
		bg_image = utils.put_image(uiconfig.depth_bg_image, (0, 0))
		bg_image.hide()
		self.add(bg_image)

		# title image	검색
		#titleimage = uiconfig.Third_title_audio_recorder
		#name, pos = titleimage
		#title_image = utils.put_image(name, pos)
		#title_image.hide()
		#self.add(title_image)

		# recording Background
		rec_bg_img = uiconfig.mmp_record_bg
		name, pos = rec_bg_img
		rec_bg_image = utils.put_image(name, pos)
		rec_bg_image.hide()
		self.add(rec_bg_image)

		# audio recording image
		aud_rec_img = uiconfig.mmp_audio_rec_img
		name, pos = aud_rec_img
		aud_rec_image = utils.put_image(name, pos)
		aud_rec_image.hide()
		self.add(aud_rec_image)

		# record information background
		rec_info_bg_img = uiconfig.mmp_rec_info_bg
		name, pos = rec_info_bg_img
		rec_info_bg_image = utils.put_image(name, pos)
		rec_info_bg_image.hide()
		self.add(rec_info_bg_image)
		

		pos = uiconfig.audio_record_max_duration_pos
		color = uiconfig.audio_record_max_duration_color
		font = uiconfig.audio_record_duration_font
		self.max_duration = runtime.evas.text(pos=pos,color=color,font=font)
		self.max_duration.text =  '00:00'#_('Max: ') + '00:00'
		self.add(self.max_duration)

		'''
		self.progress = widget.Progress(uiconfig.audio_record_progress_pos, \
					uiconfig.audio_record_progress_size, \
					uiconfig.audio_record_progress_out_icon, \
					uiconfig.audio_record_progress_in_icon)
		'''
		self.progress = widget.Progress(pos=uiconfig.audio_record_progress_pos, \
					size=uiconfig.audio_record_progress_size, \
					in_icon=uiconfig.audio_record_progress_in_icon_new)

		self.add(self.progress)

		pos = uiconfig.audio_record_duration_pos
		color = uiconfig.audio_record_duration_color
		self.duration = runtime.evas.text(pos=pos,color=color,font=font)
		self.duration.text = '00:00' #_('Duration: ') + '00:00'
		self.add(self.duration)

	def set_max_duration(self, max):
		# self.max_duration.text = _('Max: ') + '%02d:%02d' % divmod(max, 60)
		self.max_duration.text = '%02d:%02d' % divmod(max, 60)
		self.progress.set_max_value(max)

	def set_value(self, value):
		self.progress.set_value(value)
		
class SIMCopyUI(BaloonUI):
	def __init__(self, title, list):
		# lists 는  (name, number, ...) 로 된 리스트임
		BaloonUI.__init__(self, '', _('END'), title, uiconfig.baloon_phonebook_icon)
		self.list = list
		msg = _('Copying...')
		msg, new_font = utils.resize_text(msg, uiconfig.sim_progress_text_width1, uiconfig.sim_progress_font1)
		t = runtime.evas.text(text=_('Copying...'), font=new_font)
		t.color = uiconfig.sim_progress_color1
		t.pos = uiconfig.sim_progress_text_pos1
		self.add(t)

		self.name_text = runtime.evas.text(text=self.list[0][0], font=uiconfig.sim_progress_font2)
		self.name_text.color = uiconfig.sim_progress_color2
		self.name_text.pos = uiconfig.sim_progress_text_pos2
		self.add(self.name_text)

		self.progress = widget.Progress(uiconfig.sim_progress_pos, \
					uiconfig.sim_progress_size, \
					uiconfig.sim_progress_out_icon, \
					uiconfig.sim_progress_in_icon)

		self.add(self.progress)
		self.progress.set_max_value(len(self.list))

	def set_value(self, value):
		self.name_text.text_set(self.list[value][0])
		self.progress.set_value(value)
		runtime.evas.render_now()

class PhoneItemDetailUI(LargeWindowUI):
	def __init__(self, pitem):
		import phonedb
		LargeWindowUI.__init__(self, _('OK'), _('EXIT'), pitem.name)

		idx = phonedb.NUMBER
		pos = uiconfig.list_pos_y4
		icon = (uiconfig.list_icon_normal, uiconfig.list_icon_mobile,\
			uiconfig.list_icon_email, uiconfig.list_icon_fax)
		# for sim item detail, only show normal number
		if len(pitem) == 2:
			pos = uiconfig.list_pos_y1
			icon = icon[0:1]
		for y, image in zip(pos, icon):
			i = utils.put_image(image, (uiconfig.phone_item_detail_icon_x, y))
			text = utils.resize_text(pitem[idx], uiconfig.phoneitem_details_text_width, uiconfig.list_font)[0]
			t = runtime.evas.text(text=text, font=uiconfig.list_font, color=uiconfig.phone_item_detail_text_color)
			t.pos = uiconfig.list_pos_x + uiconfig.list_pos_text_delta_x, y + uiconfig.list_pos_text_delta_y
			self.add(i)
			self.add(t)
			idx += 1


#ka...3800 wizard 2007.04.17
class ConfigPictureUI(BaseUI):
	def __init__(self, left, right, title, image_num=0):
		BaseUI.__init__(self, left, right, title)
		pos = uiconfig.connection_pos
		image = uiconfig.connection_config_picture[image_num]
		self.bar = utils.put_image(image, pos)
		self.posx = pos[0]
		self.posy = pos[1]
		self.add(self.bar)
		
	def destroy(self):
		BaseUI.destroy(self)
#		self.up_arrow.free()
#		self.down_arrow.free()

	def show(self):
		BaseUI.show(self)
#		self.bar.hide()

#		runtime.lb.show()
#		runtime.rb.show()
#		if self._show_arrow:
#			self.up_arrow.show()
#			self.down_arrow.show()

	def hide(self):
		BaseUI.hide(self)
#		self.up_arrow.hide()
#		self.down_arrow.hide()

	def show_arrow(self, show):
		if self._show_arrow != show:
			self._show_arrow = show
			self.hide()
			self.show()

	def set_info(self, text):
		self.einfo.set_text(text)

#	def change_theme(self):
#		self.bar.file = uiconfig.image_dir + uiconfig.current_theme.window_bar

class NationalCodeEditUI(EntryUI):
	def __init__(self, prefix, title, subtitle, digit_max_len=20):
		EntryUI.__init__(self, _('OK'), _('BACK'), title, subtitle)
		self.set_fixed_automata('123', False)
		self.set_max(digit_max_len)

	def handle_key(self, key):
		if key == '*':
			self.insert_text('.')
		elif key == '#':
			return True
		elif key == config.Menu2:
			if EntryUI.handle_key(self, key):
				return True
			if self.right == _('BACK'):
				runtime.manager.back_stage()
				return True
		else:
			return EntryUI.handle_key(self, key)
		return False