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

📄 mmisatinfo.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 2 页
字号:
			time = sat_calculate_time (sat_command->c.tone.durUnit, sat_command->c.tone.durValue);
			if (time EQ 0)
			{
				/* use default tone duration */
				audio_PlaySoundID(data->device_id, data->sound_id , data->volume, AUDIO_PLAY_ONCE);
				res = SINGLE_TONE; /* overruled by default */
			}
			else
			{
				/* to be stopped by timer */
				data->tim = tim_create (win, time, (T_MFW_CB)sat_play_tone_tim_cb);
				tim_start (data->tim); 
				audio_PlaySoundID(data->device_id, data->sound_id , data->volume, AUDIO_PLAY_INFINITE);
			}
			break;
		}

		/*
		* --> display alpha identifier (if any)
		*/
		txt = &sat_command->c.tone.alpha;
		if (txt->len > 0)
		{
                    data->TextString = sat_create_TEXT_ASCIIZ (txt);
                    display_info.TextString   = data->TextString;
                    display_info.TextString2  = 0;
                    display_info.LeftSoftKey  = 0;
                    display_info.RightSoftKey = TxtCancel;
                    display_info.Time         = TEN_SECS;
                    display_info.KeyEvents    = KEY_RIGHT;
                    display_info.TextId       = 0;
                    display_info.TextId2      = 0;
                    display_info.Identifier   = event;
			display_info.iconindex = REMIND_COMPLETE;/*2003/12/4, wangyan add */
                    display_info.Callback     = (T_VOID_FUNC)sat_info_cb;
                    /*
                    * Call Info Screen
                    */
                    data->info = info_dialog (win, &display_info);
                    /* destroy when dialog times out */ 
		}
		else if (res EQ SINGLE_TONE) 
		{
			/* destroy immediately, if SINGLE_TONE and no info */
			sat_res[SAT_ERR_INDEX] = SatResSuccess;
			sat_res[SAT_AI_INDEX]  = SatResAiNoCause;
			sat_done (sat_command, sat_res, sizeof(T_SAT_RES));
			sat_play_tone_destroy (win);
		}
		break;

		/* sbh - all window types are being provided with this event to destroy the window */
		case SAT_DESTROY_WINDOW:
			sat_play_tone_destroy (win);
			break;
		/* ...sbh */
			
		default:
			TRACE_EVENT ("sim_play_tone_exec() unexpected event");
			break;
	}
}

/*******************************************************************************

 $Function:    	sat_play_tone_tim_cb

 $Description:	Callback function for the play tone timer.
 
 $Returns:		Execution status

 $Arguments:	event -window event
 				tc - timer info
 
*******************************************************************************/

static int sat_play_tone_tim_cb (T_MFW_EVENT event, T_MFW_TIM *tc)
{
    T_MFW_HND       win  = mfw_parent (mfw_header());
    T_MFW_WIN     * win_data = ((T_MFW_HDR *)win)->data;
    T_sat_play_tone * data   = (T_sat_play_tone *)win_data->user;
    T_SAT_RES sat_res;
    
    if ((win EQ NULL) || (win_data EQ NULL) || (data EQ NULL))
        return MFW_EVENT_CONSUMED; /* we have been interrupted by user action */
    
    /* timer elapsed */
    
    sat_res[SAT_ERR_INDEX] = SatResSuccess;
    sat_res[SAT_AI_INDEX]  = SatResAiNoCause;
    sat_done (data->sat_command, sat_res, sizeof(T_SAT_RES));
    data->sat_command = NULL; /* signal response issued to info */
    
    /* the last one has to destroy the window */
    data->tim = NULL; /* signal end of timer to info */
    if (data->info EQ NULL)
    {
        /* no info window or info window timed out: we are the last */
        sat_play_tone_destroy (win);
    }
    return MFW_EVENT_CONSUMED;
}

/*******************************************************************************

 $Function:    	sat_calculate_time

 $Description:	Calculate timeout value
 
 $Returns:		time out

 $Arguments:	unit - number of units
 				value - unit value.
 
*******************************************************************************/
static ULONG sat_calculate_time (UBYTE unit, UBYTE value)
{
    ULONG result = (ULONG)value;

    switch (unit)
        {
        case 0: // Minutes
            result = result * 60 * 1000;
            break;
        case 1: // Seconds
            result = result * 1000;
            break;
        case 2: // tenth of seconds
            result = result * 100;
            break;
        }
    return result;
}

/*******************************************************************************

 $Function:    	sat_set_selected_sound

 $Description:	Choose the Sound ID磗, return appropriate duration and support info
 
 $Returns:		time out

 $Arguments:	tone_tag - tone name
 				data - tone info
 
*******************************************************************************/


static e_TONE_DURATION sat_set_selected_sound  (SatTone tone_tag, T_sat_play_tone * data)

{
    e_TONE_DURATION ret;

    if (tone_tag.durUnit EQ 0)
    {
    	ret = NOT_SUPPORTED;
    }
    else
  	{
//		data->sound_id = tone_tag.tone;

		switch(tone_tag.tone)
		{
			case   SAT_TONE_CALL_SUB_BUSY:
					data->sound_id = 17;
				break;
			case   SAT_TONE_CONGESTION:
					data->sound_id = 19;
				break;
			case   SAT_TONE_RADIO_PATH_ACK:
			case   SAT_TONE_RADIO_PATH_NOT:
					data->sound_id = 21;
				break;
      case   SAT_TONE_DIAL:
			case   SAT_TONE_CALL_WAITING:
				data->sound_id = 22;
				break;
			case   SAT_TONE_POSITIV_ACK:
			case   SAT_TONE_RINGING_TONE:
					data->sound_id = 0x00;
				break;
			case   SAT_TONE_GENERAL_BEEP:
					data->sound_id = 0x26;
				break;
			case   SAT_TONE_ERROR:
			case   SAT_TONE_NEGATIV_ACK:
					data->sound_id = 16;
				break;
		}
		ret = DURATION;
   	}

    return ret;
}

/*******************************************************************************

 $Function:    	sat_info_cb

 $Description:	Callback function information dialog.
 
 $Returns:		none

 $Arguments:	win - window
 				identifier - unique id
 				reason - event
 
*******************************************************************************/

static void sat_info_cb(T_MFW_HND win, UBYTE identifier, UBYTE reason)
{
    /* PLAY TONE   */
    T_MFW_WIN       * play_win_data   = ((T_MFW_HDR *)win)->data;
    T_sat_play_tone * play_data       = (T_sat_play_tone *)play_win_data->user;
    T_SAT_RES sat_res;
	
	if (win EQ NULL)
		return;

    /*
	* Who has initiated the information screen
	*/
    switch (identifier)
	{
	case SAT_PLAY_TONE:
		if ((play_win_data EQ NULL) || (play_data EQ NULL))
			return; /* we have been interrupted by sat_play_tone_tim_cb() */

		switch (reason)
		{
		case INFO_TIMEOUT:
			if (play_data->tim NEQ NULL)
			{
                        /* NOP on short info timeout && infinite: 
                        * tone will be stopped and SUCCESS will be signalled by sat_play_tone_tim_cb() 
                            */
                            play_data->info = NULL; /* signal the end of info to timer */
			} 
                        else 
                        {
                            /* no timer (single tone) or timer timed out: we are the last  */
                            if (play_data->sat_command NEQ NULL)
                            {
                                /* response not yet issued, i.e single tone with info */
                                sat_res[SAT_ERR_INDEX] = SatResSuccess; 
                                sat_res[SAT_AI_INDEX]  = SatResAiNoCause;
                                sat_done (play_data->sat_command, sat_res, sizeof(T_SAT_RES));
                            }

                            /* the last one has to destroy the window */
                            sat_play_tone_destroy (win);
                        }
                        break;
		case INFO_KCD_LEFT:
		case INFO_KCD_RIGHT:
//JVJE		case INFO_KCD_CLEAR:
			/* stop the audio_PlaySoundID ()    */
			if (play_data->tim NEQ NULL)
                        {

                            tim_stop (play_data->tim);
                        }

                        if (play_data->sat_command NEQ NULL)
                        {
                            /* response not yet issued */
                            sat_res[SAT_ERR_INDEX] = SAT_RES_USER_ABORT;
                            sat_res[SAT_AI_INDEX]  = SatResAiNoCause;
                            sat_done (play_data->sat_command, sat_res, sizeof(T_SAT_RES));
                        }
                        sat_play_tone_destroy (win);
			break;
		}
		break;
		
        default:
            TRACE_EVENT("sat_info_cb(): unexp. event");
            break;
	}
}

⌨️ 快捷键说明

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