the rest of the file...
Code:
void CFinderContacts::CommunicationDialL(const TDesC& aPhoneNumber)
{
if(!m_pDialer)
{
m_pDialer=CFinderAsyncDialer::NewL();
}
if(m_pDialer&&(!m_pDialer->IsActive()))
{
m_pDialer->Dial(aPhoneNumber);
}
}
/*
*
*/
void CFinderContacts::CommunicationSendSmsL(const TDesC& aPhoneNumber)
{
//if(m_pSendAppUi)
//{
CParaFormatLayer* paraFormatLayer=CParaFormatLayer::NewL();
CleanupStack::PushL(paraFormatLayer);
CCharFormatLayer* charFormatLayer=CCharFormatLayer::NewL();
CleanupStack::PushL(charFormatLayer);
CRichText* pMessageBodyContent=CRichText::NewL(paraFormatLayer,charFormatLayer);
CleanupStack::PushL(pMessageBodyContent);
pMessageBodyContent->InsertL(0,_L(""));
CDesCArrayFlat* pAddressArray=new(ELeave)CDesCArrayFlat(1);
CleanupStack::PushL(pAddressArray);
pAddressArray->AppendL(aPhoneNumber);
//m_pSendAppUi->CreateAndSendMessageL(KUidMsgTypeSMS, pMessageBodyContent,
// NULL, KNullUid, pAddressArray, NULL, EFalse);
CleanupStack::PopAndDestroy(pAddressArray);
CleanupStack::PopAndDestroy(3); //pMessageBodyContent,charFormatLayer,paraFormatLayer
//}
}
CFinderAsyncDialer::CFinderAsyncDialer()
: CActive(CActive::EPriorityStandard),
m_eState(TCallState_Idle)
{
}
CFinderAsyncDialer* CFinderAsyncDialer::NewL()
{
CFinderAsyncDialer* self=NewLC();
CleanupStack::Pop();
return(self);
}
CFinderAsyncDialer* CFinderAsyncDialer::NewLC()
{
CFinderAsyncDialer* self=new(ELeave) CFinderAsyncDialer();
CleanupStack::PushL(self);
self->ConstructL();
return(self);
}
void CFinderAsyncDialer::ConstructL()
{
//Create a connection to the tel server
//CleanupClosePushL(server);
xAppendToLog(_L("Ph.txt"),_L("server.Connect()\n"));
User::LeaveIfError(server.Connect());
m_eState=TCallState_Connected;
//GetTsyModuleL(m_tsyModuleName);
m_tsyModuleName=_L("phonetsy.tsy");
//Load in the phone device driver
xAppendToLog(_L("Ph.txt"),_L("Load tsy("));
//xAppendToLog(_L("Ph.txt"),m_tsyModuleName);
//xAppendToLog(_L("Ph.txt"),_L(")\n"));
User::LeaveIfError(server.LoadPhoneModule(m_tsyModuleName));
m_eState=TCallState_TsyLoaded;
//Find the number of phones available from the tel server
TInt numberPhones;
xAppendToLog(_L("Ph.txt"),_L("enum phones()\n"));
User::LeaveIfError(server.EnumeratePhones(numberPhones));
//Check there are available phones
if(numberPhones < 1)
{
xAppendToLog(_L("Ph.txt"),_L("no phones()\n"));
User::Leave(KErrNotFound);
}
//Get info about the first available phone
xAppendToLog(_L("Ph.txt"),_L("get phone inf()\n"));
User::LeaveIfError(server.GetPhoneInfo(0,info));
//Use this info to open a connection to the phone,the phone is identified by its name
//CleanupClosePushL(phone);
xAppendToLog(_L("Ph.txt"),_L("open phone()\n"));
User::LeaveIfError(phone.Open(server,info.iName));
m_eState=TCallState_PhoneOpened;
// Activates handling
CActiveScheduler::Add(this);
}
CFinderAsyncDialer::~CFinderAsyncDialer()
{
if(m_eState>=TCallState_NewCallOpened)
{
call.DialCancel();
m_eState=TCallState_LineOpened;
call.Close();
}
if(m_eState>=TCallState_LineOpened)
{
line.Close();
m_eState=TCallState_PhoneOpened;
}
if(m_eState>=TCallState_PhoneOpened)
{
phone.Close();
m_eState=TCallState_TsyLoaded;
}
if(m_eState>=TCallState_TsyLoaded)
{
server.UnloadPhoneModule(m_tsyModuleName);
server.Close();
m_eState=TCallState_Idle;
}
}
void CFinderAsyncDialer::RunL()
{
xAppendToLog(_L("Ph.txt"),_L("::RunL..\n"));
DoCancel();
}
#ifndef __WINS__
TBool CFinderAsyncDialer::Dial(const TDesC& aPhoneNumber)
#else
TBool CFinderAsyncDialer::Dial(const TDesC& /*aPhoneNumber*/)
#endif
{
if(!IsActive())
{
// At least one line ?
TInt linesCount;
User::LeaveIfError(phone.EnumerateLines(linesCount));
if(linesCount<1)
{
User::Leave(KErrNotFound);
}
//Get info about the first available line from the phone
xAppendToLog(_L("Ph.txt"),_L("get line inf\n"));
for(TUint32 iLine=0;iLine<(TUint32)linesCount;iLine++)
{
User::LeaveIfError(phone.GetLineInfo(iLine,lineInfo));
#ifdef __WINS__
if(lineInfo.iLineCapsFlags&RPhone::KCapsVoice)
{
break;
}
#else
break;
#endif
}
#ifndef __WINS__
//Use this to open a line
//CleanupClosePushL(line);
xAppendToLog(_L("Ph.txt"),_L("open line("));
User::LeaveIfError(line.Open(phone,lineInfo.iName));
xAppendToLog(_L("Ph.txt"),lineInfo.iName);
xAppendToLog(_L("Ph.txt"),_L("\n"));
m_eState=TCallState_LineOpened;
//Open a new call on this line
TBuf <100> newCallName;
//CleanupClosePushL(call);
xAppendToLog(_L("Ph.txt"),_L("new call\n"));
xAppendToLog(_L("Ph.txt"),newCallName);
User::LeaveIfError(call.OpenNewCall(line,newCallName));
m_eState=TCallState_NewCallOpened;
//newCallName will now contain the name of the call
xAppendToLog(_L("Ph.txt"),_L("::dialing"));
xAppendToLog(_L("Ph.txt"),aPhoneNumber);
xAppendToLog(_L("Ph.txt"),_L("..\n"));
call.Dial(m_eActiveStatus,aPhoneNumber);
m_eState=TCallState_Dialing;
xAppendToLog(_L("Ph.txt"),_L("::dialed..\n"));
SetActive();
xAppendToLog(_L("Ph.txt"),_L("::setactived..\n"));
#endif
}
return false;
}
void CFinderAsyncDialer::DoCancel()
{
if(m_eState>=TCallState_NewCallOpened)
{
call.DialCancel();
m_eState=TCallState_LineOpened;
call.Close();
}
if(m_eState>=TCallState_LineOpened)
{
m_eState=TCallState_PhoneOpened;
line.Close();
}
}[