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

📄 mmsagent.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 3 页
字号:

/*
+-------------------------------------------------------------------+
| PROJECT: MMS               
| $Workfile: mmsagent.c
| $Author: Talcon Hu
| CREATED: 06.20.2004                 
+-------------------------------------------------------------------+
*/
#define NEW_FRAME
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#if defined (NEW_FRAME)

#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"

#else 

#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"

#endif


#include "custom.h"
#include "gsm.h"
#include "vsi.h"

#include "mfw_sys.h"
#include "p_sim.h"

#include "vsi.h"

#include "mfw_mfw.h"
#include "mfw_win.h"

#include "mfw_kbd.h"
#include "mfw_edt.h"
#include "mfw_lng.h"
#include "mfw_tim.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_phb.h"
#include "mfw_cm.h"
#include "mfw_sim.h"
#include "mfw_nm.h"
#include "mfw_phb.h"
#include "ksd.h"
#include "psa.h"
#include "mfw_sms.h"
#include "mfw_sat.h"
#include "mmiicons.h"

#include "mfw_ffs.h"

#include "wap_types.h"
#include "ATBWapACI.h"  
#include "ATBData.h"
#include "ATBWapAUI.h"
#include "AUIWap.h"

#include "mms_codec.h"
#include "mmscfg.h"
#include "manager.h"

#include "mmimmsglobaldef.h"

#include "mmimmsffs.h"

#include "MMSAgent.h"
#include "wap_interface.h"

#ifdef MMI_MMSTASK_ENABLED
#define MMS_COMPILE_FORAPP
#include "mmstask.h"
#endif


#define WAP_TRACE 1
#include "mmiutilapi.h"
#define TRACE_EVENT(f) WAP_TRACE_EVENT(("bmi--mmsagent.c<<<talcon,%s",f));
#define TRACE_FUNCTION(f) TRACE_EVENT(f)




/* mme send and queue*/
static T_MMS_WAP_DATA    *mmslist_head = 0;
/* pocess at current*/
static T_MMS_WAP_DATA    *mmslist_process = 0;

static T_MMS_PUSH_QUEUE *mmspushlist_head = 0;

//mms directory
const char MMS_DIR[]="/mms/message/";
const char MMS_SENDCONF[]="sendconf.mms";

static char  g_fullname[30];
static char g_filename[12];

/************FORCERECV*************/
/*talcon added 2004.07.15,for forcerecv*/
static char FORCERECV = 0;

#define MMS_RANDOM_MIN     10000
#define MMS_RANDOM_MAX    99999

/*talcon add, 2004.07.07 */ 
static int g_codememalloc = 0;
#if 1
#define MMS_new(ptr, size)  		MI_ALLOC(ptr, size,g_codememalloc)
#define MMS_free(ptr,size)     \
	MI_FREE(ptr, g_codememalloc);\
	WAP_TRACE_EVENT(("hyl,mmsagent.c--MMS_free"))
#else
#define MMS_new(ptr, size)  \
	ptr = (void *)mfwAlloc(size);\
	if(ptr ==0)\
		g_codememalloc  = 1;\
	else\
		g_codememalloc  = 0;
#define MMS_free(ptr,size)      			mfwFree((U8*)ptr, size)
#endif


UBYTE MMS_Get_MessageType(char *data)
{
	if(data[0] !=0x8c)
		return 0xff;
	return data[1];
}


int mms_check_status()
{
	if(ATB_wap_get_view(0))
		return 1;
	return 0;	
}
/************************push queue operate************/

T_MMS_PUSH_QUEUE * mmspushlist_wait = 0;
void checkrecv_push_queue()
{
	T_MMS_PUSH_QUEUE *p1 = mmspushlist_head;
	T_MMS_PUSH_QUEUE *p2 = mmspushlist_head;
	while(p1)
	{
		if(p1->type = MMS_PQ_TYPE_FILE && isMMSQueueEmpty(p1->filename) )
		{
			if(p1 == mmspushlist_head)
			{
				mmspushlist_head = p1->next;
			}
			p2 = p1->next;
			
			MMS_free(p1);
			if(mmspushlist_head == 0)
				break;
			p1 = p2;
		}
		else
		{
			WAP_TRACE_EVENT((p1->filename));
			p1 = p1->next;
		}

	}
}
T_MMS_PUSH_QUEUE * handle_push_queue()
{
	TRACE_FUNCTION("handle_push_queue"); 
	if(mmspushlist_head && mmspushlist_wait==0 )
	{

		mmspushlist_wait = mmspushlist_head;
		WAP_TRACE_EVENT(("handle_push_queue-%s",mmspushlist_head->filename));
		remove_pushlist(mmspushlist_head);
		wap_mms_evt_cb(
				NET_PUSH_IND,
				MMI_MMS_SUCCESS,
				mmspushlist_wait->filename  //只传文件名,不带路径
				);
		if(mmspushlist_wait)
		{
			if(mmspushlist_wait->type == MMS_PQ_TYPE_DLVRYIND)
#ifndef MMS_WAP_TEST
			{/*remove deli ind*/
				sprintf(g_fullname,"%s%s",MMS_DIR,mmspushlist_wait->filename);
				ffs_remove(g_fullname);
			}
#endif
			MMS_free(mmspushlist_wait);
			mmspushlist_wait = 0;
		}
			
	}

	TRACE_EVENT("end handle_push_queue");
	return mmspushlist_head;
}
T_MMS_PUSH_QUEUE * append_pushlist(T_MMS_PUSH_QUEUE * data)
{
	TRACE_FUNCTION("append_pushlist");
	if(mmspushlist_head == 0)
	{
		mmspushlist_head = data;
	}
	else
	{
		T_MMS_PUSH_QUEUE *p1 = mmspushlist_head;
		while(p1->next)
			p1  = p1->next;
		p1->next = data;
	}
	return data;
}//

T_MMS_PUSH_QUEUE * append_pushlist_byfile(char * filename,BYTE type)
{
	T_MMS_PUSH_QUEUE* p;
	TRACE_FUNCTION("append_pushlist_byfile");
	
	MMS_new(p,sizeof(T_MMS_PUSH_QUEUE));

	memset(p, 0 , sizeof(T_MMS_PUSH_QUEUE) );
	memcpy(p->filename, filename, strlen(filename) );
	p->type = type;
	return append_pushlist(p);
}

/*************************************************
$Description:
	remove mms push queue by data
$argument
	@return: data returned if data is in queue,otherwise 0 returned
****************************************************/
T_MMS_PUSH_QUEUE *remove_pushlist(T_MMS_PUSH_QUEUE *data)
{
	T_MMS_PUSH_QUEUE *p1 = mmspushlist_head;

	TRACE_FUNCTION("remove_pushlist");
	if(data == 0)
		return data;
	
	if(data == mmspushlist_head)
	{
		mmspushlist_head = mmspushlist_head->next;
	}
	
	else
	{
		while(p1)
		{
			if(p1->next == data)
			{
				p1->next = data->next;
				break;
			}
			p1 = p1->next;
		}
	}
	//MMS_free(data, sizeof(T_MMS_PUSH_QUEUE));
	
	return  data;
}

/*************************************************
$Description:
	get mms push queue head 
****************************************************/
T_MMS_PUSH_QUEUE *get_pushlist_head()
{
	TRACE_FUNCTION("get_mmslist_head");
	
	return mmspushlist_head;
}


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



/*************************************************
$Description:
	determine if mms queu is empty
****************************************************/
BOOL isMMSQueueEmpty()
{
	TRACE_FUNCTION("isMMSQueueEmpty");
	return mmslist_head == 0 ;
}

/*void set_mmslist_process(T_MMS_WAP_DATA *data)
{
	TRACE_FUNCTION("set_mmslist_process");
	mmslist_process = data;
}*/
/*************************************************
$Description:
	append mms queue 
****************************************************/
T_MMS_WAP_DATA *append_mmslist(T_MMS_WAP_DATA *data)
{
	TRACE_FUNCTION("append_mmslist");
	if(mmslist_head == 0)
	{
		mmslist_head = data;
	}
	else
	{
		T_MMS_WAP_DATA *p1 = mmslist_head;
		while(p1->next)
			p1  = p1->next;
		p1->next = data;
	}
	return data;
}

/*************************************************
$Description:
	remove mms queue 
$argument
	@return: data returned if data is in queue,otherwise 0 returned
****************************************************/
T_MMS_WAP_DATA *remove_mmslist(T_MMS_WAP_DATA *data)
{
	T_MMS_WAP_DATA *p1 = mmslist_head;

	TRACE_FUNCTION("remove_mmslist");
	if(data == mmslist_head)
	{
		mmslist_head = mmslist_head->next;
		return data;
	}
	
	while(p1)
	{
		if(p1->next == data)
		{
			p1->next = data->next;
			break;
		}
		p1 = p1->next;
	}
	
	return  p1->next;
}

/*************************************************
$Description:
	get mms queue head by type
****************************************************/
T_MMS_WAP_DATA *get_mmslist_head(UBYTE type)
{
	TRACE_FUNCTION("get_mmslist_head");
	switch(type)
	{
	case MMS_TYPE_SEND:
		return mmslist_head;
	case MMS_TYPE_RECV:
		return mmslist_head;
	}
	return mmslist_head;
}



/****************************************
$Description:
	create a mmssend by filename and mmsaddr, then append to sned queue
************************************************/
T_MMS_WAP_DATA*  mms_sendnew(char *filename, char *mmscaddr)
{
	T_MMS_WAP_DATA* mmssend ;
	TRACE_FUNCTION("mms_sendnew");
	
	MMS_new(mmssend, sizeof(T_MMS_WAP_DATA));

	if(mmssend ==0)return mmssend;

	mmssend->status = MMS_WAP_NOSTATUS;
		
	mmssend->type = MMS_TYPE_SEND;
	mmssend->urlID = URLID_MMS_SEND;

	mmssend->fp = 0;
	
	memcpy(mmssend->filename,filename,strlen(filename) + 1);
	memcpy(mmssend->pubbuff.mmscaddr , mmscaddr, strlen(mmscaddr) + 1);

	mmssend->next = 0;

	append_mmslist(mmssend);
	
	return mmssend;
}

/*************************************************
$Description:
	remove a send quest from send  queue
****************************************************/
void mms_senddelete(T_MMS_WAP_DATA* data)
{
	TRACE_EVENT("mms_senddelete");
	handle_mms_queue_end();
}

//static const char mmscaddr[] = "http://mmsc.monternet.com";
static const char acceptHeader[] = "application/vnd.wap.mms-message" ;
static const char ContentType[] = "application/vnd.wap.mms-message" ;

/*************************************************
$Description:
	create a mms receive quest
****************************************************/
void handle_mmssend(T_MMS_WAP_DATA* data)
{

	//SHORT data_length ; Robert.Chen
	U32	 data_length;
	char *buffer;
	BOOL first;
	BOOL moreData;

	TRACE_FUNCTION("handle_mmssend");
		
	if(data == 0)
	{
		if(mmslist_process == 0)
		{
			TRACE_EVENT("handle_mmssend--exit because mmslist_process is null");
			return;
		}	
		data = mmslist_process;
	}
	
	if(data->fp <=0)/*first*/
	{
		struct stat_s stat;

		sprintf(g_fullname,"%s%s",MMS_DIR,data->filename);

		TRACE_EVENT(data->filename);
		
		if(ffs_stat(g_fullname, &stat) != EFFS_OK)
		{
			TRACE_EVENT("find file error");
			handle_mms_queue_end();
			return ;	
		}
		data->sizeUsed = 0;
		data->sizeTotal = stat.size;
		

⌨️ 快捷键说明

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