Phone Book need help ASP

Login to reply to this topic.
Mon, 2005-08-01 11:44
Joined: 2005-03-04
Forum posts: 12
Hi need some help i want to get name and phone number od a user and store in a Tbuf8 what am i doing worng i only get junk stored



  RPbkViewResourceFile  phonebookResource( *(CEikonEnv::Static())  );

    if ( !phonebookResource.IsOpen())
    {
      phonebookResource.OpenL();
    }


  iPbkContactEngine = CPbkContactEngine::NewL();

  // Add searching array to parameters
    CContactDatabase::TContactViewFilter filter(CContactDatabase::EPhonable);
    CPbkMultipleEntryFetchDlg::TParams params;
    params.iContactView = &iPbkContactEngine->FilteredContactsViewL( filter );

    // Launch fetching dialog
    CPbkMultipleEntryFetchDlg* fetchDlg = CPbkMultipleEntryFetchDlg::NewL( params, * iPbkContactEngine);
    fetchDlg->SetMopParent( this );
    TInt okPressed = fetchDlg->ExecuteLD();
    CleanupStack::PushL( params.iMarkedEntries );
    HBufC *infoText2;
    TBuf8<50> InfoBuf;
    TBuf8<50> addrBuf;

if ( okPressed )
  {

        TInt paramCount = params.iMarkedEntries->Count();
      // Get the selected contacts id array
      for ( TInt i = 0; i < paramCount; ++i )
      {
          const TContactItemId cid = ( *params.iMarkedEntries )[i];
          // Open the selected contact using Phonebook engine,
          // choose correct number (launch list query if needed)
          CPbkContactItem* pbkItem = iPbkContactEngine->ReadContactLC( cid );
          TPtrC tempAddress;

          CPbkPhoneNumberSelect* selectDlg = new (ELeave) CPbkPhoneNumberSelect( );
         // tempAddress.Set( selectDlg->ExecuteLD(*pbkItem, pbkItem->DefaultSmsField() , ETrue) );
          infoText2  = pbkItem->GetContactTitleL();

          HBufC* infoText = StringLoader::LoadLC(R_INFO_TEXT);
       CEikonEnv::Static()->InfoWinL(*pbkItem->GetContactTitleL(), selectDlg->ExecuteLD(*pbkItem, pbkItem->DefaultSmsField() , ETrue)) ;
       iClient->IssueWrite((TDesC8&)*pbkItem->GetContactTitleL());
//       iClient->IssueWrite((TDesC8)(selectDlg->ExecuteLD(*pbkItem, pbkItem->DefaultSmsField() , ETrue)));
//           CEikonEnv::Static()->InfoWinL(*infoText2, tempAddress );

//          addrBuf.FillZ();
//          addrBuf.SetLength(0);


//          InfoBuf.FillZ();
//          InfoBuf.SetLength(0);

   /*       for(int i = 0 ; i < infoText2->Length() ; i++)
          {
            InfoBuf.Append(infoText2[i]);
          }*/
          /*for(int i = 0 ; i < tempAddress.Length() ; i++)
          {
            addrBuf.Append(infoText2[i]);
          }*/

         //infoText2;
          //iClient->IssueWrite(InfoBuf);
      //iClient->PhoneInfoSend(_L8("InfoBuf"), _L8("addrBuf"));

//
          addrBuf.FillZ();
          addrBuf.SetLength(0);
          InfoBuf.FillZ();
          InfoBuf.SetLength(0);


           CleanupStack::PopAndDestroy(2);  // pbkItem, infoText




Fri, 2005-09-30 10:31
Forum Nokia Champion
Joined: 2004-06-30
Forum posts: 36
Re: Phone Book need help ASP
here is your code with name,lastname and phone number stored in TBuf.. You'll only need to store them in your TBuf8...
Code:
RPbkViewResourceFile  phonebookResource( *(CEikonEnv::Static())  );
if ( !phonebookResource.IsOpen())
{
phonebookResource.OpenL();
}
CPbkContactEngine* iPbkContactEngine = CPbkContactEngine::NewL();
// Add searching array to parameters
CContactDatabase::TContactViewFilter filter(CContactDatabase::ESmsable);
CPbkMultipleEntryFetchDlg::TParams params;
params.iContactView = &iPbkContactEngine->FilteredContactsViewL( filter );
// Launch fetching dialog
CPbkMultipleEntryFetchDlg* fetchDlg = CPbkMultipleEntryFetchDlg::NewL( params, * iPbkContactEngine);
fetchDlg->SetMopParent( this );
TInt okPressed = fetchDlg->ExecuteLD();
           
if ( okPressed )
{
   TBuf<30> firstName;
   TBuf<30> lastName;
   TBuf<30> phoneNumber;

   TInt paramCount = params.iMarkedEntries->Count();
   // Get the selected contacts id array
   for ( TInt i = 0; i < paramCount; ++i )
   {
      const TContactItemId cid = ( *params.iMarkedEntries )[i];
      // Open the selected contact using Phonebook engine,
      // choose correct number (launch list query if needed)
      CPbkContactItem* pbkItem = iPbkContactEngine->ReadContactLC( cid );

      TPbkContactItemField* tmp;
      if ((tmp = pbkItem->FindField(EPbkFieldIdFirstName)) != NULL)
      {
         firstName = tmp->Text();
      }
      if ((tmp = pbkItem->FindField(EPbkFieldIdLastName)) != NULL)
      {
         lastName = tmp->Text();
      }
      if ((tmp = pbkItem->FindField(EPbkFieldIdPhoneNumberMobile)) != NULL)
      {
         phoneNumber = tmp->Text();
      }
      else if ((tmp = pbkItem->FindField(EPbkFieldIdPhoneNumberGeneral)) != NULL)
      {
         phoneNumber = tmp->Text();
      }
   }
}
Fri, 2006-07-21 20:38
Joined: 2005-05-19
Forum posts: 45
Re: Phone Book need help ASP
Excellent piece of code... saved me a ton of time.  Thumbs up for the contribution.  Anybody using the code.. remember the ReadContactLC() call and pop the contact off the cleanupstack before pbkItem goes out of scope.

"If we knew what it was we were doing, it would not be called research, would it?" - Albert Einstein

Sat, 2006-07-29 08:58
Joined: 2006-04-13
Forum posts: 34
Re: Phone Book need help ASP
Hi!

Nice piece of code.
It helped me a lot.
Thanks.

Regards

Shilpa K
Thu, 2007-07-26 14:16
Joined: 2007-06-16
Forum posts: 52
Re: Phone Book need help ASP

Excellent code
It helped me a lot

thank u very much....

Thanx&Regards
vijay


ready to face

  • Login to reply to this topic.