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

📄 mmismsread.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	char *sms_text;
	int i;
	int txt_len;

	win_data = getWinData(win); 
	data = getUserData_T_SMSREAD_R(win_data);
	list_data = &(data->sms_list_data);
	
	TRACE_FUNCTION("SmsRead_R_mfw_cb");

	switch(event)
	{
 		case E_SMS_OK: 
			TRACE_EVENT("SmsRead_R_mfw_cb case:E_SMS_OK ");
			if(deleting_win)
			{
				T_MFW_SMS_STAT  sms_list_type = MFW_SMS_ALL;
				
				listsDestroy(list_win);
				list_win=0;
			    SmsRead_R_destroy(data->win);
				SmsRead_R_start(NULL, (MfwMnuAttr*)&sms_list_type);
   	            SEND_EVENT(deleting_win,DIALOG_DESTROY,0,0 );

				//API - Added line to show if the message was deleted!
				dlg_initDisplayData_TextId( &DisplayInfo, TxtNull, TxtNull, TxtDeleted,  TxtNull, COLOUR_STATUS_WAIT);
				dlg_initDisplayData_events( &DisplayInfo, NULL, TWO_SECS, KEY_HUP );
				info_dialog (0, &DisplayInfo);
    
				deleting_win = 0;
			}

		break;
	case E_SMS_MO:
		TRACE_EVENT("SmsRead_R_mfw_cb case:E_SMS_MO ");
		MoMessage = (T_MFW_SMS_MO *)parameter;
		
		// We are reading all the SMS on the SIM
		if (g_sms_state EQ READ_SMS_LIST)
		{
			// If no message text, display the address: TBD international format and phonebook
			if (MoMessage->msg_len == 0)
			{
				// If there is an associated name, it is displayed (but not stored here, we will have to retrieve it again if detailed view)
				sms_text = (MoMessage->dest_addr).number;
				sms_len = strlen(sms_text);
			}
			else
			{
				sms_text = MoMessage->sms_msg;
				sms_len = MoMessage->msg_len;
			}

			memset((char*)sms_text_ascii,'\0',UCS2_MENU_TEXT_LEN + 1);

			TRACE_EVENT_P1("MO Message Status = %d", msg_info.stat);
			sms_copy_idx(MoMessage->msg_ref, &msg_info);

			//GW-SPR#780-Use common procedure to display status info.
			txt_len = SmsRead_GetStatusText( sms_text_ascii, msg_info.stat);

			/*MC, SPR1242 don't trust the DCS, check for Unicode tag*/
			if (MoMessage->sms_msg[0] == 0x80 ||MoMessage->dcs == MFW_DCS_UCS2 )
			{	input_type = MFW_DCS_UCS2;
				input_length =  MoMessage->msg_len-1;/*MC,SPR 1453, prevent @ symbol on end of string*/
			}
			else
			{	input_type = MFW_DCS_8bits;
				input_length =  MoMessage->msg_len;/*MC, SPR 1453*/
			}

			/*mc end*/
			
			if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
			{	unicode = TRUE;/*MC, SPR 1442, we'll be displaying messages as unicode*/
				
					SmsRead_convertSMSmsg(	MoMessage->sms_msg, input_type /*MC SPR1242*/, MoMessage->msg_len,
										&sms_text_ascii[txt_len], MFW_DCS_UCS2,  UCS2_MENU_TEXT_LEN-(txt_len+1), TRUE);

			}
			else
			{	unicode = FALSE;/*MC, SPR 1442, we'll be displaying messages as ASCII*/
			
				SmsRead_convertSMSmsg(	MoMessage->sms_msg, input_type /*MC SPR1242*/, input_length/*SPR 1453*/,
										&sms_text_ascii[txt_len] , MFW_ASCII,  MENU_TEXT_LENGTH-(txt_len+1), TRUE);
				
			}


		/* just in case  */
	  if (g_sms_list_counter >= 0)
	  {
				list_data->sms_header[g_sms_list_counter] = (wstring_t *) ALLOC_MEMORY (UCS2_MENU_TEXT_LEN + 1/*MC SPR1242*/);
				/*MC, SPR 1442, use truncation function to copy message header to list*/
				resources_truncate_to_screen_width(sms_text_ascii,0,(char*) list_data->sms_header[g_sms_list_counter], UCS2_MENU_TEXT_LEN, SCREEN_SIZE_X, unicode);
		}
			TRACE_EVENT_P1("g_sms_list_counter = %d", g_sms_list_counter);
			
			g_sms_list_counter--;

	        if (g_sms_list_counter >= 0)
	        {
	        	// There are still messages to read.
	            sms_read(MFW_SMS_MESSAGE, SHORTToUBYTE(list_data->sms_messages[g_sms_list_counter].index));
	      		g_nb_line_sms++;
	        }
	        else
	        {
	        	// All the messages have been retrieved --> display the list of SMS
				if (Mmi_getCurrentLanguage() != CHINESE_LANGUAGE)
					SmsRead_R_BuildList(win,0);
				else
					SmsRead_R_BuildList(win,1);
			}
		}
		// A particular SMS has been selected. We need to get all the info: full text, time stamp...
		else if (g_sms_state EQ READ_SELECTED_SMS)
		{
			data->sms_editor_data.sms_info = (T_MFW_SMS_PARA *)ALLOC_MEMORY (sizeof (T_MFW_SMS_PARA));
			
			data->sms_editor_data.sms_type = MMI_SMS_MO;
		    memcpy(data->sms_editor_data.sms_info, (T_MFW_SMS_PARA *)MoMessage, sizeof(T_MFW_SMS_PARA));
		
			SmsRead_R_TEXTEDT2_start(win, (MfwMnuAttr *)&(data->sms_editor_data));
		}
	
		break;
		
	case E_SMS_MT:
// nm 16.8
	case E_SMS_MT_RECEIVED:
// nm 
		MtMessage = (T_MFW_SMS_MT *)parameter;

		TRACE_EVENT_P1("g_sms_list_counter in MT = %d", g_sms_list_counter);


		if (g_sms_state EQ READ_SMS_LIST)
		{

			// If no message text, display the address: TBD international format and phonebook
			if (MtMessage->msg_len == 0)
			{
				// If there is an associated name, it is displayed (but not stored here, we will have to retrieve it again if detailed view)
				// MZ check for assoc_name !!! 14/2/01
				sms_text = (MtMessage->orig_addr).number;
				sms_len = strlen(sms_text);
			}
			else
			{
			
				sms_text = MtMessage->sms_msg;
				sms_len = MtMessage->msg_len;
			}

   			//MZ 24/05/01 clear the temp sms text buffer.
   			memset((char*)sms_text_ascii,'\0',UCS2_MENU_TEXT_LEN + 1);

			sms_copy_idx(MtMessage->index, &msg_info);
			
			//GW-SPR#780-Use common procedure to display status info.
			TRACE_EVENT_P1("Status of message = %d", msg_info.stat);
			txt_len = SmsRead_GetStatusText( sms_text_ascii, msg_info.stat);
	
			/*MCSPR1242 don't trust the DCS, check for Unicode tag*/
			if (MtMessage->sms_msg[0] == 0x80||MtMessage->dcs == MFW_DCS_UCS2 )
			{	input_type = MFW_DCS_UCS2;/*MC*/
				input_length =  MtMessage->msg_len-1;/*1498, use MT length*/
			}
			else
			{	input_type = MFW_DCS_8bits;/*MC*/
				input_length =  MtMessage->msg_len;/*1498, use MT length*/
			}
			
			/*mc end*/
			if (Mmi_getCurrentLanguage() != CHINESE_LANGUAGE)
			{	unicode = FALSE; /*MC, SPR 1442, we'll be displaying messages as ASCII*/
				SmsRead_convertSMSmsg(	MtMessage->sms_msg, input_type/*MC SPR1242*/, input_length/*SPR 1453*/,
										&sms_text_ascii[txt_len], MFW_ASCII /*MC SPR1242*/,  MENU_TEXT_LENGTH-(txt_len+1)/*MC SPR1242*/, TRUE);
			}
			else //language = Chinese
			{	unicode = TRUE;/*MC, SPR 1442, we'll be displaying messages as unicode*/

				SmsRead_convertSMSmsg(	MtMessage->sms_msg, input_type /*SH*/, MtMessage->msg_len,
											&sms_text_ascii[txt_len], MFW_DCS_UCS2,  UCS2_MENU_TEXT_LEN-txt_len/*MC SPR1242*/, TRUE);
			}
			list_data->sms_header[g_sms_list_counter] = (wstring_t *) ALLOC_MEMORY (UCS2_MENU_TEXT_LEN + 1/*MC SPR1242*/);

			//Check for allocation fail before using memory
		    if(list_data->sms_header[g_sms_list_counter]  != NULL)
		    {	/*MC, SPR 1442, use truncation function to copy message header to list*/
		    	resources_truncate_to_screen_width(sms_text_ascii,0,(char*) list_data->sms_header[g_sms_list_counter], UCS2_MENU_TEXT_LEN, SCREEN_SIZE_X, unicode);
				
			}
			else
				TRACE_EVENT(" Memory allocation failed ");
				
			g_sms_list_counter--;

	        if (g_sms_list_counter >= 0)
	        {
	        	// There are  still messages to read.
	        	sms_read(MFW_SMS_MESSAGE, (UBYTE)list_data->sms_messages[g_sms_list_counter].index);
	        	g_nb_line_sms++;
	         }
	        else
	        {
	        	// All the messages have been retrieved --> display the list of SMS
				if (Mmi_getCurrentLanguage() != CHINESE_LANGUAGE)
					SmsRead_R_BuildList(win,0);
				else
					SmsRead_R_BuildList(win,1);
	        }
		}
		else if (g_sms_state EQ READ_SELECTED_SMS)
		{
			TRACE_EVENT_P1("MtMessage len: %d", MtMessage->msg_len);
			
			data->sms_editor_data.sms_info = (T_MFW_SMS_PARA *)ALLOC_MEMORY (sizeof (T_MFW_SMS_PARA));
			
			data->sms_editor_data.sms_type = MMI_SMS_MT;
		    memcpy(data->sms_editor_data.sms_info, (T_MFW_SMS_PARA *)MtMessage, sizeof(T_MFW_SMS_PARA));

			sms_copy_idx(MtMessage->index, &msg_info);
		
			
			SmsRead_R_TEXTEDT2_start(win, (MfwMnuAttr *)&(data->sms_editor_data));
		}
		break;
    case E_SMS_ERR:
      TRACE_EVENT("SMS Error");
      if (info_win){
        SEND_EVENT(info_win,DIALOG_DESTROY,0,0 );
        info_win = 0;
      }
    default:
    		TRACE_EVENT(" SmsRead_R_mfw_cb case: Default");
    	return MFW_EVENT_REJECTED;
		}
    return MFW_EVENT_CONSUMED;
}

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

 $Function:    	SmsRead_R_smslist_cb

 $Description:	Callback function for the dynamic list of the SMS read window.
 
 $Returns:		none

 $Arguments:	Parent - window handler
 				ListData - Menu list data.
 				
*******************************************************************************/

void SmsRead_R_smslist_cb(T_MFW_HND * Parent, ListMenuData * ListData)
{



    T_MFW_WIN       * win_data;
    T_SMSREAD_R * data;    
	  
	T_MFW_HND      * l_parent;
    SHORT            l_id;


	TRACE_FUNCTION("SmsRead_R_smslist_cb ");
	
	win_data = getWinData(Parent); 
	data = getUserData_T_SMSREAD_R(win_data);

	// In all the case, we need the index of the selected message
	data->sms_editor_data.sms_index = data->sms_list_data.sms_messages[ListData->ListPosition].index;
	
	if (ListData->Reason EQ LISTS_REASON_SELECT/* && ListData->KeyReason EQ KCD_LEFT*/)
	{
		TRACE_EVENT(">>> Reason:LISTS_REASON_SELECT ");
		// We want only to retrieve the selected SMS
		g_sms_state = READ_SELECTED_SMS;

		if (!info_win)
			info_win = mmi_dialog_information_screen_forever(Parent,TxtPleaseWait, NULL, COLOUR_STATUS_WAIT);

		/*NM p030 just in case not to using the '0' index for reading */
		if (data->sms_editor_data.sms_index NEQ 0)
	    sms_read(MFW_SMS_MESSAGE, (UBYTE)data->sms_editor_data.sms_index);

	}

	/*NM p032 check if the TEST SIM is inserted.
	  During testing FTA 34.2.3 we would like to delete
	  the sms from the list without changing the sms-status
	  from unread to read
	*/
	if (test_sim EQ TRUE)
	{

	 if (ListData->Reason EQ LISTS_REASON_HANGUP)
	{
		TRACE_EVENT(">>> Reason: LISTS_REASON_HANGUP ");
		listsDestroy(ListData->win);
		list_win=0;
	    SmsRead_R_destroy(data->win);
	}
	/*
	the right-soft-key  deletes
	the selected sms in the list-menu without changing
	the read-status of the sms.

	go-back key is now on the "Hang_up"
	*/
	if ((ListData->Reason EQ LISTS_REASON_BACK )
    || (ListData->Reason EQ LISTS_REASON_CLEAR ))
	{
		T_DISPLAY_DATA DisplayInfo;
		
		TRACE_EVENT(">>> Reason: LISTS_REASON_BACK/CLEAR ");
		
		/* show for a short period  "Message deleted" and go
		   back to the previous menu-screen
		*/
		if((sms_msg_delete((UBYTE)data->sms_editor_data.sms_index) EQ MFW_SMS_OK)
		   && (data->sms_editor_data.sms_index NEQ 0))
		{
		
	    	DisplayInfo.TextString   = '\0';
		    DisplayInfo.TextString2  = '\0';
    		DisplayInfo.LeftSoftKey  = 0;
		    DisplayInfo.RightSoftKey = 0;
			DisplayInfo.Time         = THREE_SECS;
			DisplayInfo.KeyEvents    = KEY_CLEAR|KEY_LEFT|KEY_RIGHT;;
	    	DisplayInfo.TextId       = TxtMessage;
		    DisplayInfo.TextId2      = TxtDeleted;
    		DisplayInfo.Identifier   = NULL;
			DisplayInfo.Callback     = NULL;

			info_dialog(data->win, &DisplayInfo);

		}
	
		/* destroy the read-sms-menu and go back to 
		the previous screen
		*/
		listsDestroy(ListData->win);
		list_win=0;
	    SmsRead_R_destroy(data->win);

		}

	}
	else
	{
	 if ((ListData->Reason EQ LISTS_REASON_BACK /*&& ListData->KeyReason EQ KCD_RIGHT*/)
    || (ListData->Reason EQ LISTS_REASON_CLEAR /*&& ListData->KeyReason EQ KCD_HUP */)
    || (ListData->Reason EQ LISTS_REASON_HANGUP))	// sbh - added hangup key
	{
		TRACE_EVENT(">>> Reason: LISTS_REASON_BACK/CLEAR ");
		listsDestroy(ListData->win);
		list_win=0;
	    SmsRead_R_destroy(data->win);
	}

	
	}
	/*NM p032 end*/
	
}

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

 $Function:    	SmsRead_R_dialog_cb

 $Description:	Dialog callback function of the SMS read window (dynamic list of all the SMS)
 				Case where SMS has not been initialized yet
 
 $Returns:		status

 $Arguments:	win - current window handler
 				Identifier - window id
 				Reason - Event cause.
 				
*******************************************************************************/

int SmsRead_R_dialog_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
{
    T_MFW_WIN       * win_data;
    T_SMSREAD_R * data;    
	T_MFW_HND *lparent;

	win_data = getWinData(win); 
	data = getUserData_T_SMSREAD_R(win_data);
	lparent = data->parent;
	
    TRACE_FUNCTION ("SmsRead_dialog_cb()");
	
	switch (Reason)
	{
	case INFO_TIMEOUT:
	case INFO_KCD_HUP:
		// Commit suicide
		SmsRead_R_destroy(win);
		// Send E_RETURN event to parent window
		SEND_EVENT(lparent, E_RETURN, data->id, NULL);
		return MFW_EVENT_CONSUMED;

	default:
		return MFW_EVENT_REJECTED;
	}
}

⌨️ 快捷键说明

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