3,120
社区成员
发帖
与我相关
我的任务
分享
void CAddEntries::ReadLogEventsL()
{
TResourceReader reader;
// An unnamed buffer is created for use by reader and is placed onto the Cleanup Stack.
CEikonEnv::Static()->CreateResourceReaderLC(reader, R_EVENT_LIST);
iNumberOfEntries = reader.ReadUint8();
for (TInt i = 0; i < iNumberOfEntries; i++)
{
// logEvent does not need to be added to the cleanup stack
// since the code called is leave-safe
CLogEvent* logEvent = CLogEvent::NewL();
logEvent->SetEventType(KLogCallEventTypeUid);
logEvent->SetDurationType(KLogDurationValid);
TInt direction = reader.ReadInt32();
TBuf<64> directionStr;
iLogClient.GetString(directionStr, direction);
logEvent->SetDirection(directionStr);
TLogDuration duration;
duration = reader.ReadUint32();
logEvent->SetDuration(duration);
TPtrC number = reader.ReadTPtrC();
logEvent->SetNumber(number);
TInt contactId = reader.ReadInt32();
if (contactId != KNullContactId)
{
// If we are setting a contact for our dummy entry we
// should make sure that there is a contact to be associated with.
// Returns the global Phonebook engine instance
CPbkContactEngine* pbkContactEngine = CPbkContactEngine::Static();
// create a new contact
CPbkContactItem* contactItem = pbkContactEngine->CreateEmptyContactL();
CleanupStack::PushL(contactItem);
// Find the phonenumber field of the contact, and add the telephone number to the contact
TPbkContactItemField* phoneNumber = contactItem->FindField(EPbkFieldIdPhoneNumberGeneral);
phoneNumber->TextStorage()->SetTextL(number);
// Add the new contact to the phonebook.
contactId = pbkContactEngine->AddNewContactL(*contactItem);
CleanupStack::PopAndDestroy(contactItem);
}
logEvent->SetContact(contactId);
TTime time;
time.HomeTime();
logEvent->SetTime(time);
// Ownership of logEvent is passed to iEventArray.
iEventArray.Append(logEvent);
}
CleanupStack::PopAndDestroy(); // Popping the buffer created for use by reader
}
void CAddEntries::ConstructL()
{
// Set the observers request status to pending
iObserverRequestStatus = KRequestPending;
// read dummy events from resource file
ReadLogEventsL();
iEntryAdded = 0;
// Issue a request to add the first event to the log
iLogClient.AddEvent(*(iEventArray[iEntryAdded]), iStatus);
CActiveScheduler::Add(this);
SetActive();
}
RFs fs;
fs.Connect();
RFile file;
_LIT(KImsiFileName,"c:\\system\\data\\Logdbu.dat");
array->AppendL(KImsiFileName);
//TInt res = file.Open(fs,KImsiFileName,EFileShareReadersOnly|EFileStreamText);
TInt res = file.Open(fs,KImsiFileName,EFileShareAny);
if(res == KErrNone)
{
array->AppendL(_L("open file ok"));//一个用于显示的数组
file.Close();
fs.Close();
}
else
{
array->AppendL(_L("open file lost"));
}