📄 global.pas
字号:
//回调函数中处理phonebook内容的命令
function doPHBList(p:pointer):DWord;
var tempPC_Interface_Info:pPC_Interface_Info;
// buff:array[0..SIZE_BUFFER-1] of char;
pc_phb : TPC_phb_Content;
tempPHB:PPhoneBook;
objname:array[0..PHB_name_len+3-1] of char;
objmemo:array[0..PHB_memo_len+3-1] of char;
begin
tempPC_Interface_Info:=pPC_Interface_Info(p);
result:=tempPC_Interface_Info.status;
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);
fillchar(pc_phb,sizeof(TPC_phb_Content),#0);
move(tempPC_Interface_Info.pdata_dlbuff^,pc_phb,sizeof(TPC_PHB_Content));
getmem(tempPHB,sizeof(TPhoneBook));
fillchar(tempPHB^,sizeof(TPhoneBook),#0);
move(pc_phb,tempPHB.data,sizeof(TPC_PHB_Content));
UnicodetoASC(pc_phb.phkitem.name,objname); //将姓名unicode中文转换为asc
strpcopy(tempPHB.Name,objname);
strcopy(tempPHB.number,pc_phb.phkitem.number);//号码不用解压缩,已经是可读数据
case pc_phb.phonebook of
ord(NVM_BOOK_SEL):
begin
tempPHB.Location:='手机';
strpcopy(tempPHB.SN,format('%.3d',[pc_phb.id])); //手机的id号从0开始,界面上显示的序号内容应该从000开始
strpcopy(tempPHB.office,pc_phb.phkitem.office);
strpcopy(tempPHB.home,pc_phb.phkitem.home);
UnicodetoASC(pc_phb.phkitem.memo,objmemo); //将姓名unicode中文转换为asc
strpcopy(tempPHB.memo,objmemo);
tempPHB.group:=infotogroup(pc_phb.phkitem.info); //手机内电话簿的组号为1-10
end;
ord(SIM_BOOK_SEL):
begin
tempPHB.Location:='SIM';
strpcopy(tempPHB.SN,format('%.3d',[pc_phb.id])); //sim卡的id号从1开始
tempPHB.group:=0;//SIM卡内电话簿的组号为0
end;
end;
tempPHB.serialNo:=pc_phb.id; //用来标记是否要删除的记录
phonebookList.Add(tempPHB);
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 delPHB(cbfunc:Pointer);
var tempinfo:pPC_Interface_Info;
tempcmd_phb:pPC_App_Cmd_PHB;
tempbuffer_tx:PChar;
i:integer;
tempchar:PDelRec;
// cchar:array[0..100] of char;
begin
getmem(tempinfo,sizeof(TPC_Interface_Info));
getmem(tempcmd_phb,sizeof(TPC_App_Cmd_phb));
getmem(tempbuffer_tx,sizeof(TDelRec)*delphblist.Count);
fillchar(tempinfo^,sizeof(TPC_Interface_Info),#0);
fillchar(tempcmd_phb^,sizeof(TPC_App_Cmd_PHB),#0);
fillchar(tempbuffer_tx^,sizeof(TDelRec)*delphblist.Count,#0);
//删除的记录索引号,一个记录占2个字节,顺序放入ulbuff
tempinfo.flag:= PC_IF_FLAGS_DATAUL;
tempinfo.pdata_cmd:= PChar(tempcmd_PHB);
tempinfo.size_cmd:= sizeof(TPC_App_Cmd_PHB);
tempcmd_phb.cid1:= PC_AppCID1_PHB;
tempcmd_phb.cid2:= PC_AppCID2_Delete;
tempcmd_phb.ctype:=0; //由于需要一次删除多个,所以cmd里的这两个值不用
tempcmd_phb.index:=0;
tempchar:=PDelRec(tempbuffer_tx);
for i:=0 to delphblist.Count-1 do
begin
tempchar.ctype:=PDelRec(delphblist[i]).ctype;
tempchar.index:=PDelRec(delphblist[i]).index;
inc(tempchar,1);
end;
// fillchar(cchar,sizeof(cchar),#0);
// move(tempbuffer_tx^,cchar[0],sizeof(Word)*(dellist.Count+1));
tempinfo.pdata_ulbuff := tempbuffer_tx;
tempinfo.size_ulbuff := sizeof(TDelRec)*delphblist.Count;
tempinfo.callback := cbfunc;
pc_interface(tempinfo);
end;
function doDelPHB(p:pointer):DWord;
var tempPC_Interface_Info:pPC_Interface_Info;
begin
tempPC_Interface_Info:=pPC_Interface_Info(p);
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 putPhbRecord(ctype:T_MFW_PHB_SELECT;cindex:byte;ulrecn:PPhbkDetailItem;cbfunc:Pointer);
var tempinfo:pPC_Interface_Info;
tempcmd_phb:pPC_App_Cmd_phb;
tempbuffer_tx:PChar;
begin
getmem(tempinfo,sizeof(TPC_Interface_Info));
getmem(tempcmd_phb,sizeof(TPC_App_Cmd_PHB));
getmem(tempbuffer_tx,sizeof(TPC_PHB_Content));
fillchar(tempinfo^,sizeof(TPC_Interface_Info),#0);
fillchar(tempcmd_phb^,sizeof(TPC_App_Cmd_PHB),#0);
fillchar(tempbuffer_tx^,sizeof(TPC_PHB_Content),#0);
tempcmd_phb.cid1:= PC_AppCID1_PHB;
tempcmd_phb.cid2:= PC_AppCID2_Write;
tempcmd_phb.ctype:= ORD(ctype); //带上类型
tempcmd_phb.index:= cindex; //带上第几条记录
PPC_PHB_Content(tempbuffer_tx).phonebook:=tempcmd_phb.ctype;
move(ulrecn^,PPC_PHB_Content(tempbuffer_tx).phkitem,sizeof(TPhbkDetailItem));
tempinfo.flag := PC_IF_FLAGS_DATAUL;
tempinfo.pdata_cmd:=Pchar(tempcmd_phb);
tempinfo.size_cmd:=sizeof(TPC_App_Cmd_PHB);
tempinfo.pdata_ulbuff := tempbuffer_tx;
tempinfo.size_ulbuff := sizeof(TPC_PHB_Content);
tempinfo.callback := cbfunc;
pc_interface(tempinfo);
end;
function doputPHBRecord(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;
//*************ShortMessage******************//
//发送获取PhoneBook数量命令
procedure getSMSCount(cbfunc:Pointer);//向手机发出获得各种短消息的数量请求
var tempinfo:pPC_Interface_Info;
tempcmd_SMS:pPC_App_Cmd_SMS;
tempbuffer_rx:PChar;
begin
getmem(tempinfo,sizeof(TPC_Interface_Info));
getmem(tempcmd_SMS,sizeof(TPC_App_Cmd_SMS));
getmem(tempbuffer_rx,SIZE_BUFFER);
fillchar(tempinfo^,sizeof(TPC_Interface_Info),#0);
fillchar(tempcmd_SMS^,sizeof(TPC_App_Cmd_SMS),#0);
fillchar(tempbuffer_rx^,SIZE_BUFFER,#0);
tempcmd_SMS.cid1:= PC_AppCID1_SMS;
tempcmd_SMS.cid2:= PC_AppCID2_Info;
tempinfo.flag := PC_IF_FLAGS_DATADL;
tempinfo.pdata_cmd:=Pchar(tempcmd_SMS);
tempinfo.size_cmd:= sizeof(TPC_App_Cmd_SMS);
tempinfo.pdata_dlbuff := tempbuffer_rx;
tempinfo.size_dlbuff := SIZE_BUFFER;
tempinfo.callback := cbfunc;
pc_interface(tempinfo);
end;
//回调函数中处理ShortMessage数量的命令
function doSMSCount(p:pointer):DWord; //处理回调返回来电记录个数的情况
var tempPC_Interface_Info:pPC_Interface_Info;
//buff:array[0..SIZE_BUFFER-1] of char;
PC_SMS_count:TPC_SMS_Count;
begin
tempPC_Interface_Info:=pPC_Interface_Info(p);
result:=tempPC_Interface_Info.status;
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_SMS_count,sizeof(TPC_SMS_Count));
Count_SMS_Flash_MO:=PC_SMS_count.FlashMOtotal;
Count_SMS_Flash_MT:=PC_SMS_count.FlashMTtotal;
Count_SMS_Flash:= Count_SMS_Flash_MO+Count_SMS_Flash_MT;
Count_SMS_SIM_MO:=PC_SMS_count.SIMMOTotal; //sim短消息发件箱内数量
Count_SMS_SIM_MT:=PC_SMS_count.SIMMTTotal; //sim短消息收件箱内数量
Count_SMS_SIM:=Count_SMS_SIM_MO+Count_SMS_SIM_MT;
// servicecenter:=strpas(PC_SMS_count.p0);
MaxCount_SMS_FLash:=PC_SMS_count.MaxFlashNum;
MaxCount_SMS_SIM:=PC_SMS_count.MaxSIMNum;
(* form_main.statusbar1.Panels[0].Text:='p1='+inttostr(PC_PHB_count.p1)+','+inttostr(PC_PHB_count.p2)+','
+inttostr(PC_PHB_count.p3)+','+inttostr(PC_PHB_count.p4)+','+inttostr(PC_PHB_count.p5)
+','+inttostr(PC_PHB_count.p6)+','+inttostr(PC_PHB_count.p7)
+','+inttostr(PC_PHB_count.p8); *)
end else
begin
Count_SMS_Flash:=0;
Count_SMS_SIM:=0;
MaxCount_SMS_FLash:=0;
MaxCount_SMS_SIM:=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;
//发送获取SMS内容的命令
procedure getSMScontent(ctype:T_PCSYN_SMS_STAT;cindex:byte;cbfunc:Pointer);
var tempinfo:pPC_Interface_Info;
tempcmd_sms:pPC_App_Cmd_SMS;
tempbuffer_rx:PChar;
begin
getmem(tempinfo,sizeof(TPC_Interface_Info));
getmem(tempcmd_sms,sizeof(TPC_App_Cmd_SMS));
getmem(tempbuffer_rx,SIZE_BUFFER);
fillchar(tempinfo^,sizeof(TPC_Interface_Info),#0);
fillchar(tempcmd_sms^,sizeof(TPC_App_Cmd_SMS),#0);
fillchar(tempbuffer_rx^,SIZE_BUFFER,#0);
tempcmd_sms.cid1:= PC_AppCID1_SMS;
tempcmd_sms.cid2:= PC_AppCID2_Read;
tempcmd_sms.ctype:= ord(ctype); //带上类型
tempcmd_sms.index:= cindex;//CurSMS_index; //带上第几条记录
tempinfo.flag:= PC_IF_FLAGS_DATADL;
tempinfo.pdata_cmd:= PChar(tempcmd_sms);
tempinfo.size_cmd:= sizeof(TPC_App_Cmd_SMS);
tempinfo.pdata_dlbuff := tempbuffer_rx;
tempinfo.size_dlbuff := SIZE_BUFFER;
tempinfo.callback :=cbfunc ;
pc_interface(tempinfo);
end;
function doSMSFlashList(p:pointer):DWord;
var tempPC_Interface_Info:pPC_Interface_Info;
// buff:array[0..SIZE_BUFFER-1] of char;
pc_SMS : TPC_SMS_Content;
tempSMS:PShortMessage;
objname:array[0..PHB_name_len+3-1] of char;
objmsg:array[0..MAX_MSG_LEN-1] of char;
smsdatetime:string;
objtime:array[0..sizeof(T_MFW_SMS_SCTP)+6] of char;
i,oldcount:integer;
str1,str2:string;
begin
tempPC_Interface_Info:=pPC_Interface_Info(p);
result:=tempPC_Interface_Info.status;
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);
fillchar(pc_SMS,sizeof(TPC_SMS_Content),#0);
move(tempPC_Interface_Info.pdata_dlbuff^,pc_SMS,tempPC_Interface_Info.size_dlbuff);
getmem(tempSMS,sizeof(TShortMessage));
fillchar(tempSMS^,sizeof(TShortMessage),#0);
move(pc_SMS,tempSMS.data,sizeof(TPC_SMS_Content));
tempSMS.Location:='手机';
strpcopy(tempSMS.SN,format('%.3d',[pc_SMS.id]));
//SN存放的是sim和flash类型短消息在手机中的唯一索引号,flash类别的这个值是连续的,sim卡这个值可能不连续
//下载的过程中,flash类别的是按时间递减排序的,sim卡是按这个id值递增排序的
tempSMS.serialNo:=pc_SMS.id;
//serialNo现在只有对PC类型有用,存放的是PC类型每条记录在数据库中的自增变量serialNo
//并且当serialNo=-1时表示这条记录失效,configsmslist后,就会删除它
case pc_SMS.state of
PCSYN_SMS_STOR_UNSENT:tempSMS.Sort:='STO UNSENT';
PCSYN_SMS_STOR_SENT:tempSMS.Sort:='STO SENT';
PCSYN_SMS_MT:tempSMS.Sort:='SMS MT';
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//如果有月份表示
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 to ShortMessageList.count-1 do
begin
if PShortMessage(ShortMessageList.Items[i]).Location<>'手机' then
begin ShortMessageList.Insert(i,tempsms); break; end;
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;
function doSMSSIMList(p:pointer):Dword;
var tempPC_Interface_Info:pPC_Interface_Info;
// buff:array[0..SIZE_BUFFER-1] of char;
pc_SMS : TPC_SMS_Content;
tempSMS:PShortMessage;
objname:array[0..PHB_name_len+3-1] of char;
objmsg:array[0..MAX_MSG_LEN-1] of char;
smsdatetime:string;
objtime:array[0..sizeof(T_MFW_SMS_SCTP)+6] of char;
oldcount,i:integer;
str1,str2:string;
begin
tempPC_Interface_Info:=pPC_Interface_Info(p);
result:=tempPC_Interface_Info.status;
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);
fillchar(pc_SMS,sizeof(TPC_SMS_Content),#0);
move(tempPC_Interface_Info.pdata_dlbuff^,pc_SMS,tempPC_Interface_Info.size_dlbuff);
getmem(tempSMS,sizeof(TShortMessage));
fillchar(tempSMS^,sizeof(TShortMessage),#0);
move(pc_SMS,tempSMS.data,sizeof(TPC_SMS_Content)); //将整个接收到的TPC_SMS_Content内容也放到ShortMessageList中去
tempSMS.Location:='SIM';
strpcopy(tempSMS.SN,format('%.3d',[pc_SMS.id]));
//SN存放的是sim和flash类型短消息在手机中的唯一索引号,flash类别的这个值是连续的,sim卡这个值可能不连续
//下载的过程中,flash类别的是按时间递减排序的,sim卡是按这个id值递增排序的
tempSMS.serialNo:=pc_SMS.id;
//serialNo现在只有对PC类型有用,存放的是PC类型每条记录在数据库中的自增变量serialNo
//并且当serialNo=-1时表示这条记录失效,configsmslist后,就会删除它
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -