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

📄 global.pas

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

    case pc_SMS.state of
      PCSYN_SMS_UNKNOWN:  tempSMS.Sort:='UNKNOWN';
      PCSYN_SMS_UNREAD: tempSMS.Sort:='REC UNREAD';
      PCSYN_SMS_READ: tempSMS.Sort:='REC READ';
      PCSYN_SMS_STOR_UNSENT:  tempSMS.Sort:='STO UNSENT';
      PCSYN_SMS_STOR_SENT:    tempSMS.Sort:='STO SENT';
      PCSYN_SMS_ALL:  tempSMS.Sort:='SMS_ALL';
      PCSYN_SMS_FLASH:  tempSMS.Sort:='SMS_FLASH';
      PCSYN_SMS_FLASH_MO: tempSMS.Sort:='FLASH MO';
      PCSYN_SMS_FLASH_MT: tempSMS.Sort:='FLASH MT';
      PCSYN_SMS_MO: tempSMS.Sort:='SIM MO';           //* MO SMS message          */
      PCSYN_SMS_MT: tempSMS.Sort:='SIM MT';           //* MT SMS message          */
    end;

    strcopy(tempSMS.number,pc_SMS.addr);
    UnicodetoASC(pc_SMS.name,objname); //将姓名unicode中文转换为asc
    strpcopy(tempSMS.name,objname);

    if ord(pc_SMS.time.month[1])<>0 then//月份不为0,则说明有日期
    begin
      ChangeTime(objtime,@pc_SMS.time);
      smsdatetime:=objtime+'+'+format('%.2d',[pc_SMS.time.timezone]);
      strpcopy(tempSMS.datetime,smsdatetime);
    end;
    fillchar(objmsg,sizeof(objmsg),#0);
    if (pc_SMS.dcs=$08)or(pc_SMS.dcs=$18) then
      UnicodetoASC2(pc_SMS.sms_msg,objmsg,pc_SMS.msg_len) //将姓名unicode中文转换为asc
    else
      GSMtoASC2(pc_SMS.sms_msg,objmsg,pc_SMS.msg_len);
    move(objmsg[0],tempsms.sms_msg[0],pc_SMS.msg_len);
//收到的短消息是按时间顺序来确定先后次序的,但是我们要将它改成为按索引号id为顺序放入shortmessagelist
    oldcount:=ShortMessageList.count;
    for i:=Count_SMS_PC+Count_SMS_Flash to ShortMessageList.count-1 do
    begin
      str1:=PShortMessage(ShortMessageList.Items[i]).SN;
      str2:=tempSMS.SN;
      if CompareText(str2,str1)>0 then continue;
      ShortMessageList.Insert(i,tempsms);
      break;
    end;
    if ShortMessageList.count=oldcount then//如果id是最大的,那么就把这条记录放在最后
      ShortMessageList.Add(tempSMS);
  end;
  if tempPC_Interface_Info.pdata_cmd<>nil then
    freemem(tempPC_Interface_Info.pdata_cmd);
  if tempPC_Interface_Info.pdata_dlbuff<>nil then
    freemem(tempPC_Interface_Info.pdata_dlbuff);
  if tempPC_Interface_Info<>nil then
    freemem(tempPC_Interface_Info);
end;

procedure delSMS(ctype:byte;cindex:byte;cbfunc:Pointer);
var  tempinfo:pPC_Interface_Info;
     tempcmd_SMS:pPC_App_Cmd_SMS;
//     tempbuffer_tx:PChar;
begin
  getmem(tempinfo,sizeof(TPC_Interface_Info));
  getmem(tempcmd_sms,sizeof(TPC_App_Cmd_sms));

 	fillchar(tempinfo^,sizeof(TPC_Interface_Info),#0);
 	fillchar(tempcmd_sms^,sizeof(TPC_App_Cmd_SMS),#0);
  //第一个字节存放要删除记录个数,接下去就是要删除的记录索引号,一个记录占2个字节


	tempcmd_sms.cid1:= PC_AppCID1_sms;
	tempcmd_sms.cid2:= PC_AppCID2_Delete;
  tempcmd_sms.ctype:=ctype;
 	tempcmd_sms.index:=cindex;

	tempinfo.flag:= PC_IF_FLAGS_DATADL;
	tempinfo.pdata_cmd:= PChar(tempcmd_sms);
	tempinfo.size_cmd:= sizeof(TPC_App_Cmd_sms);

	tempinfo.callback := cbfunc;
	pc_interface(tempinfo);
end;


function doDelSMS(p:pointer):DWord;
var tempPC_Interface_Info:pPC_Interface_Info;
begin
  tempPC_Interface_Info:=pPC_Interface_Info(p);
  result:=tempPC_Interface_Info.status;
  if tempPC_Interface_Info.pdata_cmd<>nil then
    freemem(tempPC_Interface_Info.pdata_cmd);
  if tempPC_Interface_Info<>nil then
    freemem(tempPC_Interface_Info);
end;

procedure ChangeTime(var text:array of char;rctp:PT_MFW_SMS_SCTP);
begin
  text[0]:=chr(ord(rctp.year[0])+ord('0'));
  text[1]:=chr(ord(rctp.year[1])+ord('0'));
  text[2]:='/';
  text[3]:=chr(ord(rctp.month[0])+ord('0'));
  text[4]:=chr(ord(rctp.month[1])+ord('0'));
  text[5]:='/';
  text[6]:=chr(ord(rctp.day[0])+ord('0'));
  text[7]:=chr(ord(rctp.day[1])+ord('0'));
  text[8]:=' ';
  text[9]:=chr(ord(rctp.hour[0])+ord('0'));
  text[10]:=chr(ord(rctp.hour[1])+ord('0'));
  text[11]:=':';
  text[12]:=chr(ord(rctp.minute[0])+ord('0'));
  text[13]:=chr(ord(rctp.minute[1])+ord('0'));
  text[14]:=':';
  text[15]:=chr(ord(rctp.second[0])+ord('0'));
  text[16]:=chr(ord(rctp.second[1])+ord('0'));

  text[17]:=#0;
end;

procedure UnChangeTime(var rctp:T_MFW_SMS_SCTP;text:array of char);
var tz:array[0..3] of char;
    ts:string;
begin
  rctp.year[0]:=ord(text[0])-ord('0');
  rctp.year[1]:=ord(text[1])-ord('0');
  rctp.month[0]:=ord(text[3])-ord('0');
  rctp.month[1]:=ord(text[4])-ord('0');
  rctp.day[0]:=ord(text[6])-ord('0');
  rctp.day[1]:=ord(text[7])-ord('0');
  rctp.hour[0]:=ord(text[9])-ord('0');
  rctp.hour[1]:=ord(text[10])-ord('0');
  rctp.minute[0]:=ord(text[12])-ord('0');
  rctp.minute[1]:=ord(text[13])-ord('0');
  rctp.second[0]:=ord(text[15])-ord('0');
  rctp.second[1]:=ord(text[16])-ord('0');
  move(text[18],tz[0],2);
  ts:=tz;
  rctp.timezone:=(ord(text[18])-ord('0'))*10+ord(text[19])-ord('0');
end;

function putSMSRecord(stype:byte;rptype:byte;ulrecn:PPC_SMS_Content;cbfunc:Pointer):DWord; 
var  tempinfo:pPC_Interface_Info;
     tempcmd_sms:pPC_App_Cmd_Sms;
     tempbuffer_tx:PChar;
begin
  getmem(tempinfo,sizeof(TPC_Interface_Info));
  getmem(tempcmd_sms,sizeof(TPC_App_Cmd_SMS));
  getmem(tempbuffer_tx,sizeof(TPC_SMS_Content));

 	fillchar(tempinfo^,sizeof(TPC_Interface_Info),#0);
 	fillchar(tempcmd_sms^,sizeof(TPC_App_Cmd_SMS),#0);
 	fillchar(tempbuffer_tx^,sizeof(TPC_sms_Content),#0);

	tempcmd_sms.cid1:= PC_AppCID1_sms;
	tempcmd_sms.cid2:= PC_AppCID2_Write;
 	tempcmd_sms.index:= rptype;  //带上第几条记录
  tempcmd_sms.ctype:= stype;  //发送类型

  move(ulrecn^,tempbuffer_tx^,sizeof(TPC_SMS_Content));

	tempinfo.flag := PC_IF_FLAGS_DATAUL;
	tempinfo.pdata_cmd:=Pchar(tempcmd_sms);
	tempinfo.size_cmd:=sizeof(TPC_App_Cmd_sms);

	tempinfo.pdata_ulbuff := tempbuffer_tx;
	tempinfo.size_ulbuff :=sizeof(TPC_SMS_Content);
	tempinfo.callback := cbfunc;

	pc_interface(tempinfo);
end;

function doputSMSRecord(p:pointer):DWord;
var tempPC_Interface_Info:pPC_Interface_Info;
begin
  tempPC_Interface_Info:=pPC_Interface_Info(p);
  result:=tempPC_Interface_Info.status;
  if tempPC_Interface_Info.pdata_cmd<>nil then
    freemem(tempPC_Interface_Info.pdata_cmd);
  if tempPC_Interface_Info.pdata_ulbuff<>nil then
    freemem(tempPC_Interface_Info.pdata_ulbuff);
  if tempPC_Interface_Info<>nil then
    freemem(tempPC_Interface_Info);
end;

procedure CopySMS(ctype:byte;cindex:byte;ulrecn:PPC_SMS_Content;cbfunc:Pointer);
var  tempinfo:pPC_Interface_Info;
     tempcmd_sms:pPC_App_Cmd_Sms;
     tempbuffer_tx:PChar;
begin
  getmem(tempinfo,sizeof(TPC_Interface_Info));
  getmem(tempcmd_sms,sizeof(TPC_App_Cmd_SMS));
  getmem(tempbuffer_tx,sizeof(TPC_SMS_Content));

 	fillchar(tempinfo^,sizeof(TPC_Interface_Info),#0);
 	fillchar(tempcmd_sms^,sizeof(TPC_App_Cmd_SMS),#0);
 	fillchar(tempbuffer_tx^,sizeof(TPC_sms_Content),#0);

	tempcmd_sms.cid1:= PC_AppCID1_SMS;
	tempcmd_sms.cid2:= PC_AppCID2_Copy;
 	tempcmd_sms.index:= cindex;  //带上第几条记录
  tempcmd_sms.ctype:= ctype;  //发送类型

//  PPC_sms_Content(tempbuffer_tx).name:=tempcmd_sms.ctype;
  move(ulrecn^,tempbuffer_tx^,sizeof(TPC_SMS_Content));

	tempinfo.flag := PC_IF_FLAGS_DATAUL;
	tempinfo.pdata_cmd:=Pchar(tempcmd_sms);
	tempinfo.size_cmd:=sizeof(TPC_App_Cmd_sms);

	tempinfo.pdata_ulbuff := tempbuffer_tx;
	tempinfo.size_ulbuff := sizeof(TPC_SMS_Content);
	tempinfo.callback := cbfunc;

	pc_interface(tempinfo);
end;

function doCopySMS(p:pointer):DWord;
var tempPC_Interface_Info:pPC_Interface_Info;
begin
  tempPC_Interface_Info:=pPC_Interface_Info(p);
  result:=tempPC_Interface_Info.status;
  if tempPC_Interface_Info.pdata_cmd<>nil then
    freemem(tempPC_Interface_Info.pdata_cmd);
  if tempPC_Interface_Info.pdata_ulbuff<>nil then
    freemem(tempPC_Interface_Info.pdata_ulbuff);
  if tempPC_Interface_Info<>nil then
    freemem(tempPC_Interface_Info);
end;

//**********************short message end*********************//

//*************CallRecord******************//
//发送获取callrecord数量命令
procedure getCRCount(cbfunc:Pointer);//向手机发出获得各种来电记录的数量请求
var  tempinfo:pPC_Interface_Info;
     tempcmd_cr:pPC_App_Cmd_CR;
     tempbuffer_rx:PChar;
begin
  getmem(tempinfo,sizeof(TPC_Interface_Info));
  getmem(tempcmd_cr,sizeof(TPC_App_Cmd_CR));
  getmem(tempbuffer_rx,SIZE_BUFFER);

 	fillchar(tempinfo^,sizeof(TPC_Interface_Info),#0);
 	fillchar(tempcmd_cr^,sizeof(TPC_App_Cmd_CR),#0);
 	fillchar(tempbuffer_rx^,SIZE_BUFFER,#0);

	tempcmd_cr.cid1:= PC_AppCID1_CR;
	tempcmd_cr.cid2:= PC_AppCID2_Info;

	tempinfo.flag := PC_IF_FLAGS_DATADL;
	tempinfo.pdata_cmd:=Pchar(tempcmd_cr);
	tempinfo.size_cmd:= sizeof(TPC_App_Cmd_CR);

	tempinfo.pdata_dlbuff := tempbuffer_rx;
	tempinfo.size_dlbuff := SIZE_BUFFER;
	tempinfo.callback := cbfunc;

	pc_interface(tempinfo);
end;

//回调函数中处理CR数量的命令
procedure doCRCount(p:pointer);  //处理回调返回来电记录个数的情况
var tempPC_Interface_Info:pPC_Interface_Info;
    //buff:array[0..SIZE_BUFFER-1] of char;
    PC_CR_count:TPC_CR_Count;
begin
  tempPC_Interface_Info:=pPC_Interface_Info(p);
  if tempPC_Interface_Info.size_dlbuff>0 then
  begin
//    fillchar(buff,sizeof(buff),#0);
//    move(tempPC_Interface_Info.pdata_dlbuff^,buff[0],tempPC_Interface_Info.size_dlbuff);
    move(tempPC_Interface_Info.pdata_dlbuff^,PC_CR_count,sizeof(TPC_CR_Count));
    Count_CR_LMN:=PC_CR_count.LMNID; //未接电话
    Count_CR_LRN:=PC_CR_count.LRNID; //已接电话
    Count_CR_LDN:=PC_CR_count.LDNID; //已拨电话
  end else
  begin
    Count_CR_LMN:=0; //未接电话
    Count_CR_LRN:=0; //已接电话
    Count_CR_LDN:=0; //已拨电话
  end;


  if tempPC_Interface_Info.pdata_cmd<>nil then
    freemem(tempPC_Interface_Info.pdata_cmd);
  if tempPC_Interface_Info.pdata_dlbuff<>nil then
    freemem(tempPC_Interface_Info.pdata_dlbuff);
  if tempPC_Interface_Info<>nil then
    freemem(tempPC_Interface_Info);
end;

//发送获取CR内容的命令
procedure getCRcontent(ctype:byte;cindex:byte;cbfunc:Pointer);
var  tempinfo:pPC_Interface_Info;
     tempcmd_cr:pPC_App_Cmd_CR;
     tempbuffer_rx:PChar;
begin
  getmem(tempinfo,sizeof(TPC_Interface_Info));
  getmem(tempcmd_cr,sizeof(TPC_App_Cmd_CR));
  getmem(tempbuffer_rx,SIZE_BUFFER);

 	fillchar(tempinfo^,sizeof(TPC_Interface_Info),#0);
 	fillchar(tempcmd_cr^,sizeof(TPC_App_Cmd_CR),#0);
 	fillchar(tempbuffer_rx^,SIZE_BUFFER,#0);

	tempcmd_cr.cid1:= PC_AppCID1_CR;
	tempcmd_cr.cid2:= PC_AppCID2_Read;
  tempcmd_cr.ctype:= ctype;   //带上类型
 	tempcmd_cr.index:= cindex;// CurCR_index;   //带上第几条记录

	tempinfo.flag:= PC_IF_FLAGS_DATADL;
	tempinfo.pdata_cmd:= PChar(tempcmd_cr);
	tempinfo.size_cmd:= sizeof(TPC_App_Cmd_CR);

	tempinfo.pdata_dlbuff := tempbuffer_rx;
	tempinfo.size_dlbuff := SIZE_BUFFER;

	tempinfo.callback :=cbfunc ;

	pc_interface(tempinfo);
end;
//回调函数中处理CR内容的命令
procedure doCRList(p:pointer;ctype:byte);
var tempPC_Interface_Info:pPC_Interface_Info;
//    buff:array[0..SIZE_BUFFER-1] of char;
    pc_cr : TPC_CR_Content;
    tempCR:PCallRecord;
    objname:array[0..23] of char;
begin
  tempPC_Interface_Info:=pPC_Interface_Info(p);
  if tempPC_Interface_Info.size_dlbuff>0 then
  begin
//    fillchar(buff,sizeof(buff),#0);
//    move(tempPC_Interface_Info.pdata_dlbuff^,buff[0],tempPC_Interface_Info.size_dlbuff);
    move(tempPC_Interface_Info.pdata_dlbuff^,pc_cr,sizeof(TPC_CR_Content));

    getmem(tempCR,sizeof(TCallRecord));
    tempCR.Location:='手机';
    strpcopy(tempCR.SN,format('%.2d',[CurCR_index+1]));
    case ctype of
    CR_TYPE_LMN: tempCR.CRType:='未接电话';
    CR_TYPE_LRN: tempCR.CRType:='已接电话';
    CR_TYPE_LDN: tempCR.CRType:='已拨电话';
    end;
    strpcopy(tempCR.datetime,pc_cr.time);
    strpcopy(tempCR.PhoneNo,pc_cr.number);
    UnicodetoASC(pc_cr.name,objname); //将姓名unicode中文转换为asc
    strpcopy(tempCR.Name,objname);
    tempCR.serialNo:=0; //用来标记是否要删除的记录
    CallRecordList.Add(tempCR);
  end;
  if tempPC_Interface_Info.pdata_cmd<>nil then
    freemem(tempPC_Interface_Info.pdata_cmd);
  if tempPC_Interface_Info.pdata_dlbuff<>nil then
    freemem(tempPC_Interface_Info.pdata_dlbuff);
  if tempPC_Interface_Info<>nil then
    freemem(tempPC_Interface_Info);
end;

procedure delCR(cbfunc:Pointer);
var  tempinfo:pPC_Interface_Info;
     tempcmd_cr:pPC_App_Cmd_CR;
     tempbuffer_tx:PChar;
     i:integer;
     tempchar:PDelRec;

⌨️ 快捷键说明

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