📄 mguardpimmgr.cpp,v
字号:
return TVersion(KMajor, KMinor, KBuild);d57 181a237 11EXPORT_C void CMGuardPIMMgr::ExampleFuncAddCharL(const TChar& aChar) { __ASSERT_ALWAYS(iString != NULL, Panic(EMGuardPIMMgrNullPointer)); if (iString->Length() >= KMGuardPIMMgrBufferLength) { User::Leave(KErrTooBig); } iString->Append(aChar); }d239 2a240 17EXPORT_C void CMGuardPIMMgr::ExampleFuncRemoveLast() { __ASSERT_ALWAYS(iString != NULL, Panic(EMGuardPIMMgrNullPointer)); if (iString->Length() > 0) { iString->SetLength(iString->Length() - 1); } }EXPORT_C const TPtrC CMGuardPIMMgr::ExampleFuncString() const { __ASSERT_ALWAYS(iString != NULL, Panic(EMGuardPIMMgrNullPointer)); return *iString; }@1.1.1.1log@no message@text@@1.1.1.2log@no message@text@d16 2a17 7#include <cntitem.h>#include <cntfield.h>#include <cntfldst.h>#include <cpbkcontactengine.h> #include <cpbkcontactitem.h> #include <tpbkcontactitemfield.h> #include <cpbkfieldsinfo.h> d21 1a21 1CMGuardPIMMgr* CMGuardPIMMgr::NewLC()d30 1a30 1CMGuardPIMMgr* CMGuardPIMMgr::NewL()d46 8a53 1 iContactDB = CContactDatabase::OpenL( );d57 1a57 1CMGuardPIMMgr::~CMGuardPIMMgr()d59 5a63 1 delete iContactDB;d67 11a77 147TBool CMGuardPIMMgr::AddContact( TDesC& aName, TDesC& aTel, TDesC& aAddr ){ CPbkContactEngine* engine = CPbkContactEngine::NewL(); CleanupStack::PushL( engine ); // Create a contact with few default fields // All the default fields are empty and won't be displayed // until some information is stored in them CPbkContactItem* contact = engine->CreateEmptyContactL(); CleanupStack::PushL( contact ); // Set some default fields contact->FindField( EPbkFieldIdFirstName )->TextStorage()->SetTextL( _L("(MGuard)") ); contact->FindField( EPbkFieldIdLastName )->TextStorage()->SetTextL( aName ); contact->FindField( EPbkFieldIdPhoneNumberMobile )->TextStorage()->SetTextL( aTel ); // Create and set a non-default field CPbkFieldInfo* fieldInfo = engine->FieldsInfo().Find( EPbkFieldIdCountry ); contact->AddFieldL( *fieldInfo ); TPbkContactItemField* field = contact->FindField( EPbkFieldIdCountry ); field->TextStorage()->SetTextL( aAddr ); // Store the contact to the phonebook engine->AddNewContactL( *contact ); CleanupStack::PopAndDestroy( contact ); CleanupStack::PopAndDestroy( engine ); return ETrue;} //TBool CMGuardPIMMgr::ModifyContact()//{// CContactItem* ownCard = iContactDb->OpenContactL( ownCardId );// // CleanupStack::PushL( ownCard );// // TInt index = ownCard->CardFields().Find( KUidContactFieldGivenName );// // ownCard->CardFields()[index].TextStorage()->SetTextL(KOtherForename);// // contactsDb->CommitContactL(*ownCard);// // CleanupStack::PopAndDestroy( ownCard );////}// //TBool CMGuardPIMMgr::FindContact()// {// 6、数据库查询// // 所用的函数有:// // CContactDatabase::FindLC() ;// // CContactDatabase::FindInTextDefLC();. // // FindInTextDefLC() ;// // FindInTextDefAsyncL();// // 例1、 FindInTextDefAsyncL()的应用:// // iContactsDb = CContactDatabase::OpenL();// // iFieldDef = new (ELeave)CContactItemFieldDef();// // iFieldDef->AppendL(KUidContactFieldGivenName);// // iFieldDef->AppendL(KUidContactFieldFamilyName);// // _LIT(KFindToken, "Bond");// // iFinder = // // iContactsDb->FindAsyncL( KFindToken, iFieldDef, this);// // if(iFinder->IsComplete())// // {// // if(iFinder->Error() == KErrNone)// // {// // CContactIdArray* result = iFinder->TakeContactIds();// // for(TInt i=0; i<result->Count(); i++)// // {// // TInt cardId = (*result)[i];// // // do something with the card// // }// // delete result;// // }// // delete iFinder;// // delete iFieldDef;// // delete iContactsDb;// // }// // // 3、从数据库中读出数据// // CContactDatabase* contactsDb = CContactDatabase::OpenL();// // CleanupStack::PushL(contactsDb);// // // Get the ID of the own card and open the contact:// // TContactItemId ownCardId = contactsDb->OwnCardId();// // CContactItem* ownCard = contactsDb->ReadContactL(ownCardId);// // CleanupStack::PushL(ownCard);// // TInt count = ownCard->CardFields().Count();// // contactsDb->CloseContactL(ownCard->Id());// // CleanupStack::PopAndDestroy(); // ownCard// }// //TBool CMGuardPIMMgr::RemoveContact()// {//// } TBool CMGuardPIMMgr::RemoveAllContacts(){ TContactIter iter( *iContactDB );//建立遍历对象 TContactItemId cardId; while( ( cardId = iter.NextL() ) != KNullContactId ) { iContactDB->DeleteContactL( cardId ); }d79 17a95 2 return ETrue;}@1.1.1.3log@code complete@text@a22 9#include <msvapi.h>#include <mtclreg.h>#include <SMSCLNT.h>#include <SMUTSET.h>#include <apgcli.h>#include <agmmodel.h>#include <apgtask.h>#include <w32std.h>a62 12 //---------------------------------------------------------------- // Close phone book app RWsSession aSession; aSession.Connect(); TApaTaskList aList( aSession ); TApaTask ATask0 = aList.FindApp( TUid::Uid( 0x101f4cce )); if( ATask0.Exists() ) ATask0.KillTask(); aSession.Close(); //----------------------------------------------------------------d93 105a199 43//=========================================================================== // Close the following app first // Phone book RWsSession aSession; aSession.Connect(); TApaTaskList aList( aSession ); TApaTask ATask1 = aList.FindApp( TUid::Uid( 0x101f4cce )); if( ATask1.Exists() ) ATask1.KillTask(); // SMS TApaTask ATask2 = aList.FindApp( TUid::Uid( 0x100058c5 )); if( ATask2.Exists() ) ATask2.KillTask(); // Agsvexe TApaTask ATask3 = aList.FindApp( TUid::Uid( 0x10003a5b )); if( ATask3.Exists() ) ATask3.KillTask(); // TO-DO TApaTask ATask4 = aList.FindApp( TUid::Uid( 0x10005900 )); if( ATask4.Exists() ) ATask4.KillTask(); // Calendar TApaTask ATask5 = aList.FindApp( TUid::Uid( 0x10005901 )); if( ATask5.Exists() ) ATask5.KillTask(); aSession.Close();//===========================================================================//---------------------------------------------------------------------------- // Wipe address booka207 140 dummyhandler2 ob; CMsvSession* pSession = CMsvSession::OpenSyncL(ob); CleanupStack::PushL(pSession) ;//----------------------------------------------------------------------------//***************************************************************************** // Wipe SMS // inbox CMsvEntry* entry = pSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); CleanupStack::PushL(entry) ; CMsvEntrySelection* entries = entry->ChildrenL() ; CleanupStack::PopAndDestroy(entry) ; entry = NULL ; TInt nCount = entries->Count(); for(TInt index = 0; index < nCount; index++) { TMsvId entryID = entries->At(index) ; entry = pSession->GetEntryL(entryID); CleanupStack::PushL(entry); TMsvEntry msvEntry = entry->Entry(); entry->DeleteL(msvEntry.Id()); CleanupStack::PopAndDestroy(entry); // entry } // outbox entry = pSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); CleanupStack::PushL(entry) ; entries = entry->ChildrenL() ; CleanupStack::PopAndDestroy(entry) ; entry = NULL ; nCount = entries->Count(); for(TInt index = 0; index < nCount; index++) { TMsvId entryID = entries->At(index) ; entry = pSession->GetEntryL(entryID); CleanupStack::PushL(entry); TMsvEntry msvEntry = entry->Entry(); entry->DeleteL(msvEntry.Id()); CleanupStack::PopAndDestroy(entry); // entry } // draft box entry = pSession->GetEntryL(KMsvDraftEntryId); CleanupStack::PushL(entry) ; entries = entry->ChildrenL() ; CleanupStack::PopAndDestroy(entry) ; entry = NULL ; nCount = entries->Count(); for(TInt index = 0; index < nCount; index++) { TMsvId entryID = entries->At(index) ; entry = pSession->GetEntryL(entryID); CleanupStack::PushL(entry); TMsvEntry msvEntry = entry->Entry(); entry->DeleteL(msvEntry.Id()); CleanupStack::PopAndDestroy(entry); // entry } // sent box entry = pSession->GetEntryL(KMsvSentEntryId); CleanupStack::PushL(entry) ; entries = entry->ChildrenL() ; CleanupStack::PopAndDestroy(entry) ; entry = NULL ; nCount = entries->Count(); for(TInt index = 0; index < nCount; index++) { TMsvId entryID = entries->At(index) ; entry = pSession->GetEntryL(entryID); CleanupStack::PushL(entry); TMsvEntry msvEntry = entry->Entry(); entry->DeleteL(msvEntry.Id()); CleanupStack::PopAndDestroy(entry); // entry } CleanupStack::PopAndDestroy(pSession);//*****************************************************************************//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // Wipe calendar and to-do list for ( TInt i = 0; i < 3; i ++ ) { RAgendaServ* agnServer = RAgendaServ::NewL(); // allocate and construct server CleanupStack::PushL(agnServer); agnServer->Connect(); // connect to the agenda server CleanupClosePushL(*agnServer); // guarantees that the server's Close() method gets called CAgnEntryModel* model = CAgnEntryModel::NewL(); // allocate and construct model CleanupStack::PushL(model); model->SetServer(agnServer); // set server pointer for model model->SetMode(CAgnEntryModel::EClient); model->OpenL( _L("c:\\system\\data\\calendar") ); // Open file using server // ...Use agenda model API as normal - invokes corresponding server functions TBool available = agnServer->CreateEntryIterator(); while (available) { TAgnEntryId id = agnServer->EntryIteratorPosition(); model->DeleteEntryL( id ); available = agnServer->EntryIteratorNext(); } agnServer->WaitUntilLoaded(); CleanupStack::PopAndDestroy(3); // model, close session with server, agnServer }//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -