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

📄 mmismsbroadcast.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    if (own_window)
	{
	    win_data = ((T_MFW_HDR *)own_window)->data;
	    data = (T_M_CB_ACT *)win_data->user;

	    if (data)
		{
		    /*
		     * Delete WIN handler
		     */ 
		    win_delete (data->win);

		    /*     
		     * Free Memory
		     */
		    FREE_MEMORY ((void *)data, sizeof (T_M_CB_ACT));
		}
	    else
		{
		    TRACE_EVENT ("smscb_M_CB_ACT_destroy() called twice");
		}
	}
}
/*******************************************************************************

 $Function:    	smscb_M_CB_ACT_exec_cb

 $Description:	

 $Returns:		none.

 $Arguments:	
 
*******************************************************************************/
void smscb_M_CB_ACT_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * dummy)
    /* callback handler for events sent to to trigger execution */
{

    T_MFW_WIN      * win_data = ((T_MFW_HDR *) win)->data;
    T_M_CB_ACT          * data = (T_M_CB_ACT *)win_data->user;
    T_MFW_HND      * l_parent;
    SHORT            l_id;

    TRACE_FUNCTION ("smscb_M_CB_ACT_exec_cb()");

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

	    /* initialization of the dialog data */

	    /* create the dialog handler */
	    listCreate                (data->win,(MfwMnuAttr *)&smscb_M_CB_ACTAttrib, E_MNU_ESCAPE, (ListCbFunc)smscb_M_CB_ACT_mnu_cb); // c020 rsa
	    break;
	    // c007 rsa
	case E_RETURN: /* back from child */
    	    /* winUpdate(data->win); c021 rsa */
	    break;
	    // end c007 rsa
	case E_BACK:
	case E_ABORT:
	case E_EXIT:  /* defaultreaction */
	    l_parent = data->parent;
	    l_id = data->id;
	    smscb_M_CB_ACT_destroy(data->win);
	    SEND_EVENT (l_parent, event, l_id, NULL); /* forward event to parent */
	    break;
	default:
	    return;
	}
}

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

 $Function:    	smscb_M_CB_ACT_mnu_cb

 $Description:

 $Returns:		none.

 $Arguments:	
 
*******************************************************************************/
// c020 rsa
static void smscb_M_CB_ACT_mnu_cb (T_MFW_HND * win, ListMenuData * ListData)
    /* smscb_M_CB_ACT menu event handler */
{
    T_MFW_WIN  * win_data = ((T_MFW_HDR *)win)->data;
    T_M_CB_ACT      * data = (T_M_CB_ACT *)win_data->user;
    T_MFW_HND  * l_parent;
    SHORT        l_id;
    int index;

    TRACE_FUNCTION ("smscb_M_CB_ACT_listmnu_cb()");

    switch (ListData->Reason)
        {
	case E_MNU_SELECT:
	    //on SELECT: menucreate 
	    break;
	case LISTS_REASON_BACK: /* back to previous menu */
	    l_parent = data->parent;
	    l_id = data->id;
	    smscb_M_CB_ACT_destroy(data->win);
	    SEND_EVENT (data->parent, E_RETURN, l_id, NULL);
	    break;
	default:
	    return;
        }
    return;
}
// end c020 rsa

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

			M_CB_TOP	 DYNAMIC MENU WINDOW. DECLARATION

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

typedef struct
{
    /* administrative data */

    T_MMI_CONTROL   mmi_control;
    T_MFW_HND       win;
    SHORT           id;
    T_MFW_HND       parent;

    /* associated handlers */

    T_MFW_HND       menu;

    /* internal data */
    T_CB_index_param CB_index_param; /* parameter for called submenus (index in list) */
} T_M_CB_TOP;

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

		M_CB_TOP	     DYNAMIC MENU WINDOW. CONTENTS BEHAVIOUR

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

 $Function:    	smscb_M_CB_TOP_ExeConsult

 $Description:	

 $Returns:		none.

 $Arguments:	
 
*******************************************************************************/
static int smscb_M_CB_TOP_ExeConsult(MfwMnu* m, MfwMnuItem* i)
{
    T_MFW_HND       win      = mfwParent((MfwHdr *)mfw_header());
    T_MFW_WIN     * win_data = ((T_MFW_HDR *)win)->data;
    T_M_CB_TOP    * data     = (T_M_CB_TOP *)win_data->user;


#ifdef DEBUG_SMS_CB
    UBYTE ii;
    char buf[60];

	for (ii = 0; ii < MAX_MIDS; ii++)
	{
	   sprintf (buf, "g_smscb_data.CBTopics.entry[0].msg_id:%d, i:%d", g_smscb_data.CBTopics.entry[ii].msg_id,ii);
	   TRACE_EVENT (buf); 
	}
#endif


	if (!smsidle_get_ready_state())
	{
	    info_screen(0, TxtSimNot, TxtReady, NULL); 
	    TRACE_EVENT ("SIM is not ready !!");
		return;
	}		
	
	if (g_smscb_data.CBTopics.length EQ 0) 
	{
	    info_screen(0, TxtEmptyList,TxtNull, NULL); 

	    TRACE_EVENT ("CellBroadcast Topic-list is empty !!");
		return;
	}

    //	selection "Consult": menucreate M_CB_TOP_CONS
    return (int)smscb_M_CB_TOP_CONS_start (win, NULL);
}
/*******************************************************************************

 $Function:    	smscb_M_CB_TOP_ExeAddNew

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
static int smscb_M_CB_TOP_ExeAddNew(MfwMnu* m, MfwMnuItem* i)
{
    T_MFW_HND      win      = mfwParent((MfwHdr *)mfw_header());
    T_MFW_WIN    * win_data = ((T_MFW_HDR *)win)->data;
    T_M_CB_TOP   * data     = (T_M_CB_TOP *)win_data->user;
    int            index;

    //	selection "Add": call sms_cb_edit_topic(List=CBTopics, Index=ADD)
    index = g_smscb_data.CBTopics.length;/* get the index of the next free entry in list CBTopics */

    if (index > MAX_MIDS)
	{
	    /* all entries are already used */
	    info_screen (win, TxtFull /* ??? */,TxtNull, NULL);
	    return MFW_EVENT_CONSUMED;
	}
    else
	{


	    data->CB_index_param.index = index; 
	    return (int)smscb_CB_EDT_TEXTEDT_start(win, &data->CB_index_param);
	}
}


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

			M_CB_TOP_CONS	 DYNAMIC MENU WINDOW. DECLARATION

*********************************************************************
**********************************************************************/
typedef struct
{
    /* administrative data */

    T_MMI_CONTROL   mmi_control;
    T_MFW_HND       win;
    SHORT           id;
    T_MFW_HND       parent;

    /* associated handlers */

    /* internal data */
    T_CB_index_param CB_index_param; /* parameter for called submenus (index in list) */
    MfwMnuItem      menuItems[MAX_MIDS]; /* List=CBTopics */
    ListMenuData    list_menu_data;
} T_M_CB_TOP_CONS;

static T_MFW_HND smscb_M_CB_TOP_CONS_create (T_MFW_HND parent);
static void smscb_M_CB_TOP_CONS_destroy (T_MFW_HND window);
static void smscb_M_CB_TOP_CONS_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * dummy);
static void smscb_M_CB_TOP_CONS_listmnu_cb (T_MFW_HND * win, ListMenuData * ListData);


static const MfwMnuAttr smscb_M_CB_TOP_CONSAttrib =
{
    &smscb_M_CB_TOP_CONSArea,
    MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu       */
    -1,                                 /* use default font         */
    NULL,                               /* with these items         */
    0,                                   /* number of items     */
	COLOUR_LIST_SMS,	TxtNull, NULL, MNUATTRSPARE

};

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

			M_CB_TOP_CONS	DYNAMIC MENU WINDOW. IMPLEMENTATION

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

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

 $Function:    	smscb_M_CB_TOP_CONS_start

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
T_MFW_HND smscb_M_CB_TOP_CONS_start(T_MFW_HND parent_window, void *dummy)
{
    T_MFW_HND win;

    TRACE_FUNCTION ("smscb_M_CB_TOP_CONS_start()");

    win = smscb_M_CB_TOP_CONS_create (parent_window);

    if (win NEQ NULL)
	{
	    SEND_EVENT (win, E_INIT, smscb_M_CB_TOP_CONS_ID, NULL);
	}
    return win;
}


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

 $Function:    	smscb_M_CB_TOP_CONS_create

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
static T_MFW_HND smscb_M_CB_TOP_CONS_create(MfwHnd parent_window)
{
    T_M_CB_TOP_CONS      * data = (T_M_CB_TOP_CONS *)ALLOC_MEMORY (sizeof (T_M_CB_TOP_CONS));
    T_MFW_WIN  * win;

    TRACE_FUNCTION ("smscb_M_CB_TOP_CONS_create()");

    /*
     * Create window handler
     */

    data->win = 
	win_create (parent_window, 0, 0, NULL);
    if (data->win EQ NULL)
	{
	    return NULL;
	}

    /* 
     * connect the dialog data to the MFW-window
     */

    data->mmi_control.dialog = (T_DIALOG_FUNC)smscb_M_CB_TOP_CONS_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
     */

    winShow(data->win);
    return data->win;
}

static void smscb_M_CB_TOP_CONS_destroy(MfwHnd own_window)
{
    T_MFW_WIN * win_data;
    T_M_CB_TOP_CONS     * data;

    TRACE_FUNCTION ("smscb_M_CB_TOP_CONS_destroy()");

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

	    if (data)
		{
		    /*
		     * Delete WIN handler
		     */ 
		    win_delete (data->win);

		    /*     
		     * Free Memory
		     */
		    FREE_MEMORY ((void *)data->list_menu_data.List, MAX_MIDS * sizeof (MfwMnuItem)); // c017 rsa
		    FREE_MEMORY ((void *)data, sizeof (T_M_CB_TOP_CONS));
		}
	    else
		{
		    TRACE_EVENT ("smscb_M_CB_TOP_CONS_destroy() called twice");
		}
	}
}

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

 $Function:    	smscb_M_CB_TOP_CONS_recreate

 $Description:	

 $Returns:		
 
 $Arguments:	
 
*******************************************************************************/
static void smscb_M_CB_TOP_CONS_recreate(T_M_CB_TOP_CONS *data)
{
    int i;
    int len;

#ifdef DEBUG_SMS_CB
    UBYTE ii;
    char buf[80];

	   TRACE_EVENT ("before create a list !"); 
	for (ii = 0; ii < MAX_MIDS; ii++)
	{
	   sprintf (buf, " 01 midlist:%d, i:%d", g_smscb_data.CBTopics.entry[ii].msg_id,ii);
	   TRACE_EVENT (buf); 
	}
	   sprintf (buf, "01 length:%d", g_smscb_data.CBTopics.length);
	   TRACE_EVENT (buf); 
#endif

    //on RECREATE|INIT: menucreate dynamiclist (List=CBTopics, SoftLeft=SELECT, SoftRight=BACK) /* show: 1. Name 2. MID */ 

    // c017 rsa
    /* allocate sufficient memory to hold the maximum list of menu items */
    data->list_menu_data.List = (MfwMnuItem *)ALLOC_MEMORY (MAX_MIDS * sizeof (MfwMnuItem));
    // end c017 rsa

    for (i=0; i < g_smscb_data.CBTopics.length; i++) /* Fill Menu List */
	{
		mnuInitDataItem(&data->list_menu_data.List[i]);


	    /* get the correct entry in list of CBTopics */
	    data->list_menu_data.List[i].str = g_smscb_data.CBTopics.entry[i].name; 
	    data->list_menu_data.List[i].flagFunc = item_flag_none;


	}

	//actual number of entries in list menu
	data->list_menu_data.ListLength = g_smscb_data.CBTopics.length; 

	data->list_menu_data.autoDestroy    = TRUE;

    listDisplayListMenu(data->win, &data->list_menu_data, (ListCbFunc)smscb_M_CB_TOP_CONS_listmnu_cb,0);

⌨️ 快捷键说明

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