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

📄 global.pas

📁 是一个手机功能的模拟程序
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    msg_len:Word;
    sms_msg:array[0..MAX_MSG_LEN-1] of char;
  end;

{  PPC_SMS_Content=^TPC_SMS_Content; //572 bytes,传输短信记录的数据结构
  TPC_SMS_Content=record
    name:array[0..PHB_name_len+3-1] of char;
    flashsmsitem:TFlashSms;
  end;
}
  PShortMessage=^TShortMessage;//这个是在shortmessagelist中的单元结构
  TShortMessage=record
    Location:array[0..3] of char;   //4bytes
    SN:array[0..3] of char;        //3bytes
    Sort:array[0..9] of char;  //
    number:array[0..MFW_NUM_LEN-1] of char;  //41 bytes
    name:array[0..PHB_name_len+3-1] of char;//16 bytes
    datetime:array[0..20] of char; //21 bytes
    sms_msg:array[0..MAX_MSG_LEN-1] of char;//573
    data:TPC_SMS_Content;
    serialNo:Longint; //如果是PC数据,则表示在数据库中的索引
  end;

//*******CR*******/
  PPC_App_Cmd_CR=^TPC_App_Cmd_CR;
  TPC_App_Cmd_CR=record
    cid1:byte;
    cid2:byte;
    ctype:byte;// CR_TYPE_LMN, CR_TYPE_LRN, CR_TYPE_LDN
    index:byte;//基于0的通话记录的索引
  end;

//call record dl buffer
//when CID2 = PC_AppCID2_Info
  PPC_CR_Count=^TPC_CR_Count;
  TPC_CR_Count=record
    LMNID:byte;
    LRNID:byte;
    LDNID:byte;
  end;

  PPC_CR_Content=^TPC_CR_Content;
  TPC_CR_Content=record
    number:array[0..23] of char;//24 bytes
    name:array[0..CR_name_length-1] of char;//24 bytes
    time:array[0..20] of char;//21 bytes
  end;

  PCallRecord=^TCallRecord;
  TCallRecord=record
    Location:array[0..3] of char;
    SN:array[0..3] of char;
    CRType:array[0..7] of char;
    datetime:array[0..20] of char;
    PhoneNo:array[0..23] of char;
    Name:array[0..CR_name_length-1] of char;
    serialNo:integer;
  end;

//**************file type***************//
  P_FFS_STAT=^T_FFS_STAT;
  T_FFS_STAT=record
    ftype:Byte; //FFS_OBJECT_TYPE=(OT_FILE=1,OT_DIR=2,OT_LINK=3,OT_SEGMENT=4);
    flags:Byte; //FFS_OBJECT_FLAGS=(OF_READONLY= 1 shl 4);
    inode:short;
    size:integer; //size of data space occupied by object
  end;

  PFileHead=^TFileHead;
  TFileHead=record
    stat:T_FFS_STAT;
    fnsize:integer;
  end;

  PFileRec=^TFileRec;
  TFileRec=Record
    Pathname:array[0..511] of char;
    Filename:array[0..255] of char;
    Filesize:integer;
    ReadOnly:boolean;
  end;

  function Serial_Open(name:PChar;baudtrate:DWORD):integer; stdcall;external 'pcsyn_prtcdll.dll';
  function Serial_Close:Integer; stdcall;external 'pcsyn_prtcdll.dll';
  function pc_interface(p:PPC_Interface_Info):integer; stdcall;external 'pcsyn_prtcdll.dll';
  procedure pcsyn_protocol_init; stdcall;external 'pcsyn_prtcdll.dll';
  procedure pcsyn_protocol_close; stdcall;external 'pcsyn_prtcdll.dll';

  //公共部分
  procedure UnicodetoASC(Sour:array of char;var Dest:array of char);
  procedure UnCompressNum(CompNum:PChar;var Num:array of char);
  function  ASCtoUnicode(Sour:array of char;var Dest:array of char):Word;//将中文转换成unicode字符
  procedure UnicodetoASC2(Sour:array of char;var Dest:array of char;strsize:integer);
  procedure GSMtoASC2(Sour:array of char;var Dest:array of char;strsize:integer);
  procedure ASC2toGSM(Sour:array of char;var Dest:array of char;strsize:integer);
  function infotogroup(info:char):byte;
  function grouptoinfo(gp:byte):char;

  //PhoneBook相关
  procedure GetPHBCount(cbfunc:Pointer);
  function doPHBCount(p:pointer):DWord;
  procedure getPHBcontent(ctype:T_MFW_PHB_SELECT;cindex:byte;cbfunc:Pointer);
  function doPHBList(p:pointer):DWord;
  procedure delPHB(cbfunc:Pointer);
  function doDelPHB(p:pointer):DWord;
  procedure putPhbRecord(ctype:T_MFW_PHB_SELECT;cindex:byte;ulrecn:PPhbkDetailItem;cbfunc:Pointer);
  function doputPhbRecord(p:pointer):DWord;

  //shortmessage相关
  procedure getSMSCount(cbfunc:Pointer);//向手机发出获得各种短消息的数量请求
  function doSMSCount(p:pointer):DWord;
  procedure getSMScontent(ctype:T_PCSYN_SMS_STAT;cindex:byte;cbfunc:Pointer);
  function doSMSFlashList(p:pointer):DWord;
  function doSMSSIMList(p:pointer):DWord;
  procedure delSMS(ctype:byte;cindex:byte;cbfunc:Pointer);
  function doDelSMS(p:pointer):DWord;
  procedure ChangeTime(var text:array of char;rctp:PT_MFW_SMS_SCTP);
  procedure UnChangeTime(var rctp:T_MFW_SMS_SCTP;text:array of char);
  function putSMSRecord(stype:byte;rptype:byte;ulrecn:PPC_SMS_Content;cbfunc:Pointer):DWord;
  function doputSMSRecord(p:pointer):DWord;
  procedure CopySMS(ctype:byte;cindex:byte;ulrecn:PPC_SMS_Content;cbfunc:Pointer);
  function doCopySMS(p:pointer):DWord;

  //CallRecord相关
  procedure GetCRCount(cbfunc:Pointer);
  procedure doCRCount(p:pointer);
  procedure getCRcontent(ctype:byte;cindex:byte;cbfunc:Pointer);
  procedure doCRList(p:pointer;ctype:byte);
  procedure delCR(cbfunc:Pointer);
  function doDelCR(p:pointer):DWord;

  //文件相关
  procedure getfileInfo(cbfunc:Pointer;filename:string);
  function dogetfileinfo(p:pointer):DWord;  //处理回调返文件情况
  procedure getfile(cbfunc:Pointer;filename:string);
  function dodownloadfile(p:pointer):Dword;
  procedure putfile(cbfunc:Pointer;sourfile:string;Destpath:string);
  function douploadfile(p:pointer):DWord;
  procedure DELfile(cbfunc:Pointer;filename:string);
  function doDelFILE(p:pointer):DWord;

var
  NumberSet:TCharSet=['0'..'9','p','#','*','+',#8,#3,#22,#24,#26];//#8=backspace,copy,paste,cut
  Comhandle:THandle;
//PhoneBook变量
  status_PHB:integer; //PHB处于什么状态
  Count_PHB_PC:word; //电话簿电话记录数量
  Count_PHB_SIM:word; //SIM卡电话簿电话记录数量
  Count_PHB_NVM:word; //手机电话簿电话记录数量
//  CurPHB_type:byte;  //当前接收的电话簿类型
  CurPHB_index:word;  //当前接收电话记录索引
//  CurPHBTable:byte;      //当前打开的电话簿index
  Max_PHB_PC:word; //
  Max_PHB_SIM:word;//最多可以存放在sim卡里的电话簿记录
  Max_PHB_NVM:word;//最多可以存放在flash里的电话簿记录
  PhoneBookList:TList;
  DelPHBList:TList; //记下被删除的多个记录索引
  CurInsPHB_Index:short;  //当前插入的电话簿索引

//ShortMessage变量
  status_SMS:integer; //短消息处于什么状态
  Count_SMS_PC:byte; //pc短消息数量
  Count_SMS_Flash:byte; //flash短消息数量
  Count_SMS_SIM:byte;  //SIM卡的短消息
  Count_SMS_Flash_MO:byte; //flash中发件箱短消息数量
  Count_SMS_Flash_MT:byte; //flash中收件箱短消息数量
  Count_SMS_SIM_MO:byte; //sim短消息发件箱内数量
  Count_SMS_SIM_MT:byte; //sim短消息收件箱内数量
//  CurPHB_type:byte;  //当前接收的电话簿类型
  CurSMS_index:short;  //当前接收短消息索引
  CurSMSTable:byte;      //当前打开的短消息文件index
  MaxCount_SMS_PC:integer;
  MaxCount_SMS_FLash:integer;
  MaxCount_SMS_SIM:integer;
  ShortMessageList:TList;
  DelSMSList:TList; //记下被删除的多个记录索引
  servicecenter:string;
  EditState_SMS:TEditState_SMS;
  CurInsSMS_Index:byte;  //当前插入的短消息索引

//CallRecord变量
  status_CR:integer; //CR处于什么状态
  Count_CR_LMN:byte; //CR未接电话数量
  Count_CR_LRN:byte; //CR已接电话数量
  Count_CR_LDN:byte; //CR已拨电话数量
//  CurCR_type:byte;  //当前接收的来电类型
  CurCR_index:byte;  //当前接收的来电记录索引
  CallRecordList:TList;
  DelCRList:TList; //记下被删除的多个记录索引

//文件
  status_FILE:integer; //短消息处于什么状态
  FileList:TList; //记下的文件记录索引


implementation

uses main,fileop;

//发送上载文件命令
procedure getfileInfo(cbfunc:Pointer;filename:string);
var  tempinfo:pPC_Interface_Info;
     tempcmd_file:pPC_App_Cmd_file;
     tempbuffer_rx:PChar;
begin
  getmem(tempinfo,sizeof(TPC_Interface_Info));
  getmem(tempcmd_file,sizeof(TPC_App_Cmd_file));
  getmem(tempbuffer_rx,SIZE_BUFFER);

 	fillchar(tempinfo^,sizeof(TPC_Interface_Info),#0);
 	fillchar(tempcmd_file^,sizeof(TPC_App_Cmd_file),#0);
 	fillchar(tempbuffer_rx^,SIZE_BUFFER,#0);

	tempcmd_file.cid1:= PC_AppCID1_File;
	tempcmd_file.cid2:= PC_AppCID2_info;
  strpcopy(tempcmd_file.filename,filename);

	tempinfo.flag := PC_IF_FLAGS_DATADL;
	tempinfo.pdata_cmd:=Pchar(tempcmd_file);
	tempinfo.size_cmd:=(strlen(tempcmd_file.filename)+2+3)and(not	$03);//字节对齐

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

	pc_interface(tempinfo);
end;

function dogetfileinfo(p:pointer):DWord;  //处理回调返文件情况
var tempPC_Interface_Info:pPC_Interface_Info;
    buff:array[0..SIZE_BUFFER-1] of char;
    tempchar:pchar;
    filehead:PFileHead;
    dlsize:integer;
    namebuf:array[0..255] of char;
    rootnode,tempnode:TTreeNode;
    tempitem:TListItem;
begin
  tempPC_Interface_Info:=pPC_Interface_Info(p);
  result:=tempPC_Interface_Info.status;
  Form_fileop.ListView_file.Clear;
  rootnode:=Form_fileop.TreeView_dir.Selected;
  if rootnode<>nil then
  begin
    rootnode.DeleteChildren;
  end;

  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);

    dlsize:=tempPC_Interface_Info.size_dlbuff;
    if rootnode<>nil then
    begin
//      Form_fileop.ListView_file.Clear;
      rootnode.DeleteChildren;
      while dlsize>0 do
      begin
        tempchar:=pchar(tempPC_Interface_Info.pdata_dlbuff+(tempPC_Interface_Info.size_dlbuff-dlsize));
        filehead:=PFileHead(tempchar);
        inc(tempchar,sizeof(TFileHead));
        fillchar(namebuf,sizeof(namebuf),#0);
        move(tempchar^,namebuf[0],filehead.fnsize);
        case filehead.stat.ftype of
        ord(OT_DIR):
          begin
            tempnode:=Form_fileop.TreeView_dir.Items.AddChild(rootnode,namebuf);
            tempnode.ImageIndex:=0;
            tempnode.SelectedIndex:=1;
          end;
        ord(OT_FILE):
          begin
            tempitem:=Form_fileop.ListView_file.Items.Add;
            tempitem.Caption:=namebuf;
            tempitem.SubItems.Add(format('%.0n',[filehead.stat.size*1.0]));
            if filehead.stat.flags=ord(OF_READONLY) then
              tempitem.SubItems.Add('是')
            else
              tempitem.SubItems.Add('否');
//              Form_fileop.ListView_file.Repaint;
//            Form_fileop.ListView_file.Width:=Form_fileop.ListView_file.Width-1;
//            Form_fileop.ListView_file.Width:=Form_fileop.ListView_file.Width+1;
          end;
        end;
        dlsize:=dlsize-filehead.fnsize-sizeof(TFileHead);
      end;
      rootnode.Expanded:=true;
    end;
  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 getfile(cbfunc:Pointer;filename:string);
var  tempinfo:pPC_Interface_Info;
     tempcmd_file:pPC_App_Cmd_file;
     tempbuffer_rx:PChar;
begin
  getmem(tempinfo,sizeof(TPC_Interface_Info));
  getmem(tempcmd_file,sizeof(TPC_App_Cmd_file));
  getmem(tempbuffer_rx,SIZE_BUFFER);

 	fillchar(tempinfo^,sizeof(TPC_Interface_Info),#0);
 	fillchar(tempcmd_file^,sizeof(TPC_App_Cmd_file),#0);
 	fillchar(tempbuffer_rx^,SIZE_BUFFER,#0);

	tempcmd_file.cid1:= PC_AppCID1_File;
	tempcmd_file.cid2:= PC_AppCID2_Read;
  strpcopy(tempcmd_file.filename,filename);

	tempinfo.flag := PC_IF_FLAGS_DATADL;
	tempinfo.pdata_cmd:=Pchar(tempcmd_file);
	tempinfo.size_cmd:=(strlen(tempcmd_file.filename)+2+3)and(not	$03);//字节对齐

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

	pc_interface(tempinfo);
end;

function dodownloadfile(p:pointer):DWord;
var tempPC_Interface_Info:pPC_Interface_Info;
    FileHandle:Thandle;
//    n:string;
begin
  tempPC_Interface_Info:=pPC_Interface_Info(p);
  if tempPC_Interface_Info.size_dlbuff>0 then
  begin
//    n:=strpas(PFileRec(filelist.items[0]).filename);
    FileHandle:=filecreate(Form_fileop.FileListBox1.Directory+'\'+strpas(PFileRec(filelist.items[0]).filename));
    if FileHandle>0 then
    begin
      filewrite(FileHandle,tempPC_Interface_Info.pdata_dlbuff^,tempPC_Interface_Info.size_dlbuff);
      FileClose(FileHandle);
    end;
  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 putfile(cbfunc:Pointer;sourfile:string;Destpath:string);
var  tempinfo:pPC_Interface_Info;
     tempcmd_file:pPC_App_Cmd_file;
     tempbuffer_rx:PChar;
     FileHandle:integer;
     readbufsize:integer;
     filelen:integer;
begin
  FileHandle:=FileOpen(sourfile,fmOpenRead);
  if FileHandle<0 then
  begin

⌨️ 快捷键说明

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