新人求教~关于短信阻截与自动回复
新人求教~关于短信拦截与自动回复~
以下是silentsms实例中的拦截和runl部分~我回复短信的一部分摘取了nokia WIKI 上 SMShandler.cpp 文件~这两部分都是官方的实例~我只想把他们联系起来~我在CSMSEngine:Runl()中调用发送函数~当收到短信时出现ESOCK_client 8 错误~程序退出~
求一方法把这两个AO联系起来~实现拦截并自动回复~先拜谢~!
void CSMSEngine::SocketListen()
{
_LIT(KTag, "");
TBuf8<2> matchTag;
matchTag.Copy(KTag);
//Opens a socket by creating a new subsession to the socket server.
TInt err = iSocket.Open(iSocketServer, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol);
if(err==KErrNone)
{
TRequestStatus iStatus;
TSmsAddr smsaddr;
// App. listens for sms msgs with some special tag in it.
smsaddr.SetSmsAddrFamily(ESmsAddrMatchText);
smsaddr.SetTextMatch(matchTag);
TInt BindErr = iSocket.Bind(smsaddr);
if(BindErr == KErrNone)
{
iPckgBuf() = KSockSelectRead;
//Applies an asynchronous I/O control operation on a socket.
iRead=ETrue;
}
}
iSocket.Ioctl( KIOctlSelect,iStatus, &iPckgBuf, KSOLSocket);
SetActive();
}
// -----------------------------------------
// CSMSEngine::RunL()
// Gets hit everytime a message with the 'tag' arrives
// -----------------------------------------
//
void CSMSEngine::RunL()
{
// iSilentSmsAppView->SendMsg();
if(iRead)
{
CSmsBuffer *smsBuffer = CSmsBuffer::NewL();
CleanupStack::PushL(smsBuffer);
//Stream that reads a CSmsMessage object across a socket.
RSmsSocketReadStream readStream(iSocket);
//Allocates and creates a CSmsMessage
//ESmsDeliver-SMS-DELIVER, sent from service center to Mobile Station.
iSmsMessage = CSmsMessage::NewL(iFs,CSmsPDU::ESmsDeliver,smsBuffer);
//Internalises data from stream to CSmsMessage
iSmsMessage->InternalizeL(readStream);
readStream.Close();
//Extracting the received message to a buffer
iSmsMessage->Buffer().Extract(iBuf,0,iSmsMessage->Buffer().Length());
iSocket.Ioctl( KIoctlReadMessageSucceeded,iStatus, NULL, KSolSmsProv);
//Printing the received Message.
CAknInformationNote* note122=new(ELeave) CAknInformationNote;
note122->ExecuteLD(iBuf);
iRead=EFalse;
SetActive();
CleanupStack::PopAndDestroy(smsBuffer);
}
}
求一种方法~还请各位大大帮忙啊~
------解决方案--------------------
。。。。怎么没人帮忙啊 出来点高手帮我们这些新手成长下啊
------解决方案--------------------
到我资源下个。很简单的。
以下是silentsms实例中的拦截和runl部分~我回复短信的一部分摘取了nokia WIKI 上 SMShandler.cpp 文件~这两部分都是官方的实例~我只想把他们联系起来~我在CSMSEngine:Runl()中调用发送函数~当收到短信时出现ESOCK_client 8 错误~程序退出~
求一方法把这两个AO联系起来~实现拦截并自动回复~先拜谢~!
void CSMSEngine::SocketListen()
{
_LIT(KTag, "");
TBuf8<2> matchTag;
matchTag.Copy(KTag);
//Opens a socket by creating a new subsession to the socket server.
TInt err = iSocket.Open(iSocketServer, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol);
if(err==KErrNone)
{
TRequestStatus iStatus;
TSmsAddr smsaddr;
// App. listens for sms msgs with some special tag in it.
smsaddr.SetSmsAddrFamily(ESmsAddrMatchText);
smsaddr.SetTextMatch(matchTag);
TInt BindErr = iSocket.Bind(smsaddr);
if(BindErr == KErrNone)
{
iPckgBuf() = KSockSelectRead;
//Applies an asynchronous I/O control operation on a socket.
iRead=ETrue;
}
}
iSocket.Ioctl( KIOctlSelect,iStatus, &iPckgBuf, KSOLSocket);
SetActive();
}
// -----------------------------------------
// CSMSEngine::RunL()
// Gets hit everytime a message with the 'tag' arrives
// -----------------------------------------
//
void CSMSEngine::RunL()
{
// iSilentSmsAppView->SendMsg();
if(iRead)
{
CSmsBuffer *smsBuffer = CSmsBuffer::NewL();
CleanupStack::PushL(smsBuffer);
//Stream that reads a CSmsMessage object across a socket.
RSmsSocketReadStream readStream(iSocket);
//Allocates and creates a CSmsMessage
//ESmsDeliver-SMS-DELIVER, sent from service center to Mobile Station.
iSmsMessage = CSmsMessage::NewL(iFs,CSmsPDU::ESmsDeliver,smsBuffer);
//Internalises data from stream to CSmsMessage
iSmsMessage->InternalizeL(readStream);
readStream.Close();
//Extracting the received message to a buffer
iSmsMessage->Buffer().Extract(iBuf,0,iSmsMessage->Buffer().Length());
iSocket.Ioctl( KIoctlReadMessageSucceeded,iStatus, NULL, KSolSmsProv);
//Printing the received Message.
CAknInformationNote* note122=new(ELeave) CAknInformationNote;
note122->ExecuteLD(iBuf);
iRead=EFalse;
SetActive();
CleanupStack::PopAndDestroy(smsBuffer);
}
}
求一种方法~还请各位大大帮忙啊~
------解决方案--------------------
。。。。怎么没人帮忙啊 出来点高手帮我们这些新手成长下啊
------解决方案--------------------
到我资源下个。很简单的。