mmismsmenu.c

来自「是一个手机功能的模拟程序」· C语言 代码 · 共 2,291 行 · 第 1/5 页

C
2,291
字号

    if (win NEQ NULL)
  {
      SEND_EVENT (win, E_INIT, M_DEL_ALL_ID, (void *)menuAttr);
  }
    return win;
}

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

 $Function:     M_DEL_ALL_create

 $Description:  Create the delete all window

 $Returns:    window handler

 $Arguments:  parent_window - parent window

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

static T_MFW_HND M_DEL_ALL_create(MfwHnd parent_window)
{
    T_M_DEL_ALL      * data = (T_M_DEL_ALL *)ALLOC_MEMORY (sizeof (T_M_DEL_ALL));
    T_MFW_WIN  * win;

    TRACE_FUNCTION ("M_DEL_ALL_create()");

    /*
     * Create window handler
     */

    data->win =  win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)M_DEL_ALL_win_cb);
    if (data->win EQ NULL)
  {
      return NULL;
  }
    /*
     * connect the dialog data to the MFW-window
     */

    data->mmi_control.dialog = (T_DIALOG_FUNC)M_DEL_ALL_exec_cb;
    data->mmi_control.data   = data;
    win                      = ((T_MFW_HDR *)data->win)->data;
    win->user                = (void *)data;
    data->parent             = parent_window;

    /*
     * return window handle
     */

    return data->win;
}

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

 $Function:     M_DEL_ALL_destroy

 $Description:  Destroy the delete all window

 $Returns:    none

 $Arguments:  own_window - current window

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

static void M_DEL_ALL_destroy(MfwHnd own_window)
{
    T_MFW_WIN * win_data;
    T_M_DEL_ALL     * data;

    TRACE_FUNCTION ("M_DEL_ALL_destroy()");

    if (own_window)
  {
      win_data = ((T_MFW_HDR *)own_window)->data;
      data = (T_M_DEL_ALL *)win_data->user;

     if (data)
     {
        /*
         * Delete WIN handler
         */
      if(data->type==SMS_TYPE)
		sms_delete(data->sms_hnd);

      if (data->waiting_win)
      {
        SEND_EVENT(data->waiting_win,DIALOG_DESTROY,0,0 );
        data->waiting_win = 0;
      }

        win_delete (data->win);

        /*
         * Free Memory
         */
        FREE_MEMORY ((void *)data, sizeof (T_M_DEL_ALL));
    }
      else
    {
        TRACE_FUNCTION ("M_DEL_ALL_destroy() called twice");
    }
  }
}

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

 $Function:     M_DEL_ALL_exec_cb

 $Description:  Exec callback function for the Delete All window

 $Returns:    none

 $Arguments:  win - current window
        event - event id
        value - Unique id
        parameter - optional data.

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

void M_DEL_ALL_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
    /* callback handler for events sent to to trigger execution */
{
    T_MFW_WIN      * win_data = ((T_MFW_HDR *) win)->data;
    T_M_DEL_ALL    * data = (T_M_DEL_ALL *)win_data->user;
    T_MFW_HND      * l_parent;
    SHORT            l_id;
  T_MFW_EVENT      MfwEvents;

    T_DISPLAY_DATA  DisplayInfo;

    TRACE_FUNCTION ("M_DEL_ALL_exec_cb()");

//dialog_info_init(&DisplayInfo);//gdy add
    switch (event)
  {
  case E_INIT:
      /* initialization of administrative data */
      data->id = value;

      /* initialization of the dialog data */
   	 data->type = *(enum SmsType *)parameter;
     dialog_info_init(&DisplayInfo);//gdy add
     if(data->type==SMS_TYPE)
     {
    	MfwEvents = E_SMS_MO_AVAIL | E_SMS_ERR | E_SMS_OK;
    	data->sms_hnd = sms_create(data->win,MfwEvents,(MfwCb)M_DEL_ALL_mfw_cb);

    	/* create the dialog handler */
    	// Display the dialog window to delete all the SMS
    	SmsMenu_loadDialogDefault(&DisplayInfo);

    	//NM 29.8 Check before deleting, is SIM ready ?!  */
    	if (!smsidle_get_ready_state())
    	{
      		DisplayInfo.TextId2     = TxtPleaseWait;
      		DisplayInfo.iconindex =REMIND_WAITTING;//REMIND_NORECORD;
      		DisplayInfo.Identifier = SMSMENU_ID_NOTREADY;
      	}
    	else
    	{
/*2004/5/20, wy modify*//*    	
    		DisplayInfo.TextId2       = TxtDeleteAll;//TxtOkToDelete;
     	 	DisplayInfo.Time         = FOREVER;
     	 	DisplayInfo.KeyEvents    = KEY_RIGHT|KEY_LEFT|KEY_CLEAR;
    	 	DisplayInfo.Identifier   = SMSMENU_ID_DELETEALL;
     	 	DisplayInfo.LeftSoftKey  = TxtSoftOK;
     	 	DisplayInfo.RightSoftKey  = TxtSoftBack;
       	DisplayInfo.iconindex	 =REMIND_REQUIRE;*/
/*2004/5/20, wy modify*/
    	  	g_ListLength2 = sms_message_list(MFW_SMS_ALL, data->g_SmsMenu_messages, MAX_MESSAGES);
		if (g_ListLength2==0)
		{
      			DisplayInfo.TextId2     = TxtNoMessages;
	      		DisplayInfo.Identifier  = SMSMENU_ID_NOMESSAGES;
     		 	DisplayInfo.Time         = ONE_SECS;
     	 		DisplayInfo.KeyEvents    = KEY_RIGHT|KEY_LEFT|KEY_CLEAR;
	     	 	DisplayInfo.LeftSoftKey  =0;
     		 	DisplayInfo.RightSoftKey  = 0;
       		DisplayInfo.iconindex	 =REMIND_NORECORD;
       	}
	 	else
    		{
     	 	DisplayInfo.TextId2       = TxtDeleteAll;//TxtOkToDelete;
     	 	DisplayInfo.Time         = FOREVER;
     	 	DisplayInfo.KeyEvents    = KEY_RIGHT|KEY_LEFT|KEY_CLEAR;
    	 	DisplayInfo.Identifier   = SMSMENU_ID_DELETEALL;
     	 	DisplayInfo.LeftSoftKey  = TxtSoftOK;
     	 	DisplayInfo.RightSoftKey  = TxtSoftBack;
       		DisplayInfo.iconindex	 =REMIND_REQUIRE;
    	}
	}
    	// Generic function for info messages
        (void) info_dialog(win, &DisplayInfo);
     }
     else if ( data->type==SMS_NVM_TYPE )
     {
    	/* create the dialog handler */
    	// Display the dialog window to delete all the SMS
        if (FlashSMStotal==0)
    	{
      		DisplayInfo.TextId2     = TxtNoMessages;
      		DisplayInfo.Identifier  = SMSMENU_ID_NOMESSAGES;
  		 	DisplayInfo.Callback     = (T_VOID_FUNC)SmsMenu_standard_dialog_cb;
     	 	DisplayInfo.Time         = ONE_SECS;
     	 	DisplayInfo.KeyEvents    = KEY_RIGHT|KEY_LEFT|KEY_CLEAR;
     	 	DisplayInfo.LeftSoftKey  =0;
     	 	DisplayInfo.RightSoftKey  = 0;
       		DisplayInfo.iconindex	 =REMIND_NORECORD;
       }
        else
        {
 	 	 	DisplayInfo.TextId2       = TxtDeleteAll;//TxtOkToDelete;
     	 	DisplayInfo.Time         = FOREVER;
     	 	DisplayInfo.KeyEvents    = KEY_RIGHT|KEY_LEFT|KEY_CLEAR;
     	 	DisplayInfo.Identifier   = SMSMENU_ID_DELETEALL;
     	 	DisplayInfo.LeftSoftKey  = TxtSoftOK;
     	 	DisplayInfo.RightSoftKey  = TxtSoftBack;
       		DisplayInfo.iconindex	 =REMIND_REQUIRE;
  		 	DisplayInfo.Callback     = (T_VOID_FUNC)Sms_NVM_DEL_ALL_dialog_cb;
        }
         (void) info_dialog(win, &DisplayInfo);
    }
     winShow(win);
    break;

  case E_ABORT:
  case E_EXIT:
      l_parent = data->parent;
      l_id = data->id;
      M_DEL_ALL_destroy (data->win);
      //NM SEND_EVENT (l_parent, E_EXIT, l_id, NULL); /* forward event to parent */
      break;

  case E_RETURN:
  default:
      return;
  }
}

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

 $Function:     M_DEL_ALL_win_cb

 $Description:  Window callback function for the delete all window

 $Returns:    none

 $Arguments:  e - current window
        w - event id

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

static int M_DEL_ALL_win_cb (MfwEvt e, MfwWin *w)
    /* V window event handler */
{
    TRACE_FUNCTION ("M_DEL_ALL_win_cb()");

    switch (e)
  {
        case MfwWinVisible:  /* window is visible  */
 		displaySoftKeys(TxtSoftOK,TxtSoftBack);
#if(MAIN_LCD_SIZE==3)
		draw_softkeybar_updown_arrow();//jhxu720
#endif
      break;
  case MfwWinFocussed: /* input focus / selected   */
  case MfwWinDelete:   /* window will be deleted   */
        default:
      return MFW_EVENT_REJECTED;
  }
    return MFW_EVENT_CONSUMED;
}

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

 $Function:     M_DEL_ALL_mfw_cb

 $Description:  Exec callback function for the DEL_ALL window


 $Returns:    none

 $Arguments:  event - event id
        parameter - optional data.

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

int M_DEL_ALL_mfw_cb (MfwEvt event, void *parameter)
{
    T_MFW_HND         win       = mfwParent((MfwHdr *)mfw_header());
    T_MFW_WIN   * win_data = ((T_MFW_HDR *)win)->data;
    T_M_DEL_ALL     * data = (T_M_DEL_ALL *)win_data->user;
    T_MFW_HND      *lparent = data->parent;
  T_MFW_EVENT       MfwEvents;


  T_DISPLAY_DATA DisplayInfo;

    TRACE_FUNCTION ("M_DEL_ALL_ACK_mfw_cb()");

    switch (event)
  {

  case E_SMS_ERR:

    g_SmsMenu_state = SMS_READY;

      /* destroy the dialog at first           */
    //SEND_EVENT (data->child_dialog, DIALOG_DESTROY, 0,NULL);
      /* Display "All SMS deleted" and after timeout go back to parent */
     dialog_info_init(&DisplayInfo);//gdy add
    SmsMenu_loadDialogDefault(&DisplayInfo);
    DisplayInfo.Identifier = SMSMENU_ID_DELERR;
    DisplayInfo.TextId2     = TxtFailed;
    DisplayInfo.iconindex    =REMIND_FAILURE;
    info_dialog(win,&DisplayInfo);


    break;

  case E_SMS_OK:
	  //g_ListLength2 = sms_message_list(MFW_SMS_ALL, data->g_SmsMenu_messages, MAX_MESSAGES);
    if (g_ListLength2 > 0)
    {
      g_ListLength2--;

      sms_msg_delete(data->g_SmsMenu_messages[g_ListLength2].index);
    }
    else
    {
      /* there is now anymore sms to delete !! */

     //g_SmsMenu_state = SMS_READY;
      /* go now back to the parent             */
        /* destroy the dialog at first           */
      //SEND_EVENT (data->child_dialog, DIALOG_DESTROY, 0,NULL);
        /* Display "All SMS deleted" and after timeout go back to parent */
      #if 0//add this dialog will cause restart so shell it temporaryly by windy
      SmsMenu_loadDialogDefault(&DisplayInfo);
      DisplayInfo.Identifier = SMSMENU_ID_DELOK;
      DisplayInfo.TextId     = TxtDeleted;
    DisplayInfo.iconindex    =REMIND_SUCCEED;
      info_dialog(win,&DisplayInfo);
      #endif
      #if 1/*2004/5/20, wangyan modify*/
      SmsMenu_loadDialogDefault(&DisplayInfo);
      DisplayInfo.Identifier = SMSMENU_ID_DELOK;
      DisplayInfo.TextId     = TxtDeleted;
    DisplayInfo.iconindex    =REMIND_SUCCEED;
      info_dialog(win,&DisplayInfo);
      #endif
       M_DEL_ALL_destroy(win);
      /* Send E_RETURN event to parent of M_DEL_ALL */
      SEND_EVENT (lparent, E_RETURN, data->id, NULL); /* forward event to parent */
    }

    break;

  default:
      return MFW_EVENT_REJECTED;

  }
    return MFW_EVENT_CONSUMED;

}

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

 $Function:     V_start

 $Description:  Start the voice mailbox dialog window.


 $Returns:    window handle

 $Arguments:  parent_window - parent window handle
        menuAttr - Menu attributes

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

T_MFW_HND V_start(T_MFW_HND parent_window, MfwMnuAttr *menuAttr)
{
    T_MFW_HND win;

    TRACE_FUNCTION ("V_start()");

    win = V_create (parent_window);

    if (win NEQ NULL)
  {
      SEND_EVENT (win, E_INIT, V_ID_SET, (void *)menuAttr);
  }
    return win;
}

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

 $Function:     V_create

 $Description:  create the voice mailbox window

 $Returns:    window handle

 $Arguments:  parent_window - parent window handle

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

static T_MFW_HND V_create(MfwHnd parent_window)
{
    T_V      * data = (T_V *)ALLOC_MEMORY (sizeof (T_V));
    T_MFW_WIN  * win;

    TRACE_FUNCTION ("V_create()");

    /*
     * Create window handler
     */

    data->win =
  win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)V_win_cb);
    if (data->win EQ NULL)
  {
      return NULL;
  }
    /*
     * connect the dialog data to the MFW-window
     */

    data->mmi_control.dialog = (T_DIALOG_FUNC)V_exec_cb;
    data->mmi_control.data   = data;
    win                      = ((T_MFW_HDR *)data->win)->data;
    win->user                = (void *)data;
    data->parent             = parent_window;

    /*
     * return window handle
     */

    return data->win;
}

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

 $Function:     V_destroy

 $Description:  Destroy the voice mailbox window

 $Returns:    none

 $Arguments:  own_window - current window

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

static void V_destroy(MfwHnd own_window)
{
    T_MFW_WIN * win_data;
    T_V     * data;

⌨️ 快捷键说明

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