×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    5

    How to retrive the name of incoming message

    Hello every body

    I want to retrieve the name from Contact Database of corresponding to the phone number of incoming message.

    It means that when my application will receive a message, it should search and retrieve the name based on the phone number of incoming message.

    Does anybody have any idea about that.

    Thanks in advance

    Frangdara

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: How to retrive the name of incoming message

    Quote Originally Posted by frangdara View Post
    Does anybody have any idea about that.
    You can get it using TMsvEntry class which has member data iDetails which will give you name corresponding to the phonebook entry.

    See this article: http://wiki.forum.nokia.com/index.ph...e_Phone_Number

    Use entry.iDetails instead of FromAddress() of CsmsHeader class.
    Nokia Developer Wiki Moderation team

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    5

    Re: How to retrive the name of incoming message

    Hello Kiran

    Thanks for your help. I need both the phone number and Name of the incoming message. In order to get phone number we are doing like this

    iSmsMtm->SwitchCurrentEntryL(aEntryId);
    iSmsMtm->LoadMessageL();
    CSmsHeader& header = iSmsMtm->SmsHeader();

    TPtrC from = header.FromAddress();
    const TDesC& phoneNumber = from;

    Now if I wanna get the name corresponding to the phone number of incoming message, should I do some thing like this
    iSmsMtm->SwitchCurrentEntryL(aEntryId);
    iSmsMtm->LoadMessageL();
    SmsHeader& header = iSmsMtm->SmsHeader();

    TPtrC senderName = header.iDetails;
    const TDesC& name = senderName;

    now next step is that I want to add this phoneNumber and name to the body of incoming message .

    Here is Message Body
    HBufC* SMSContent = HBufC::NewLC(400);

    SMSContent.Copy
    HBufC8* SMSContent8 = HBufC8::NewLC(400);
    CRichText& richText= iSmsMtm->Body();
    const TInt length = richText.DocumentLength();

    SMSContent->Des().Copy(richText.Read(0,length)); // Gives you actual content(Body) of SMS
    richText.Reset();

    SMSContent8->Des().Copy(SMSContent->Des());

    TBuf<160> arrivedMessage;
    arrivedMessage.Copy(SMSContent8->Des());

    now in arrivedMessage we have the message body.

    Now could you be kind enough to guide me how to add the name and phoneNumbe (which we have retrieved above) to the arrivedMessage.

    Thanks in Advance
    Last edited by frangdara; 2009-03-24 at 09:51.

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: How to retrive the name of incoming message

    Quote Originally Posted by frangdara View Post
    Hello Kiran
    Now if I wanna get the name corresponding to the phone number of incoming message, should I do some thing like this
    iSmsMtm->SwitchCurrentEntryL(aEntryId);
    iSmsMtm->LoadMessageL();
    SmsHeader& header = iSmsMtm->SmsHeader();

    TPtrC senderName = header.iDetails;
    const TDesC& name = senderName;
    Not like that. You can retrieve corresponding name with this method.
    Code:
    CMsvEntry* serverEntry = iSession->GetEntryL( aEntryId );   // current entry
    CleanupStack::PushL( serverEntry );
    TMsvEntry entry = serverEntry->Entry(); 
    TBufC<50> number_with_name(entry.iDetails); // This will give you name of a contact if there is corresponding entry in the phonebook
    ...
    ...

    Quote Originally Posted by frangdara View Post
    Now could you be kind enough to guide me how to add the name and phoneNumbe (which we have retrieved above) to the arrivedMessage.
    Thanks in Advance
    See this Wiki article: SMS Operations

    Let me know if you still find any problem with that.
    Nokia Developer Wiki Moderation team

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    5

    Re: How to retrive the name of incoming message

    Hello Kiran Br

    Thank you very much. It is just working fine with that code, which you have mentioned.

    You always help me, either it is on the Nokia forum or giving me time for meeting.


  6. #6
    Registered User
    Join Date
    Jun 2008
    Posts
    5

    Re: How to retrive the name of incoming message

    Hello Kiran

    Now I want to proceed with this SMS stuff.

    I have the application which receives the SMS and forward it. The maximum length which the application can forward is 160.

    Now I would like that the application should send automatically two messages if the length of incoming message is more then 16o and should send three message if the length of incoming message is more then 320 and so on.

    Do you have any idea or reference to some relevant links.

    Thanks in advance

    Niaz

  7. #7
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: How to retrive the name of incoming message

    Read the received messages in the heap based descriptor(HBufC) with maximum expected size. And try to forward the same content as that of HBufC variable and see what happens.
    Nokia Developer Wiki Moderation team

  8. #8
    Registered User
    Join Date
    Jun 2008
    Posts
    5

    Re: How to retrive the name of incoming message

    Hello Kiran


    When I am trying to declare the size of HBufC 3000, as you can see in the following code. Then the program crashes by giving the error App. Closed: Main KERN-EXEC 3. When I tried to investigate it through Logfile, It crashes in CreateMsgL() of SmsHandler.

    Here is My MessageReceivedL() function

    Code:
    void CSmsHandler::MessageReceivedL( TMsvId aEntryId )
        {
        WriteToFile(_L8("\nMessage Received"));
        CMsvEntry* serverEntry = iSession->GetEntryL( aEntryId );   // current entry
        CleanupStack::PushL( serverEntry );
        
        TMsvEntry entry = serverEntry->Entry(); // currently handled message entry
        
        entry.SetNew( ETrue );
        entry.SetUnread( ETrue );
        entry.SetVisible( ETrue );
    
        serverEntry->ChangeL( entry );  // commit changes
        WriteToFile(_L8("\nAfter ChangeL"));
        
        
        // This will give you name of a contact if there is corresponding entry in the phonebook
        WriteToFile(_L8("\nBefore iDetails"));
        TBufC<50> numberWithName(entry.iDetails); 
        
    
        
        iSmsMtm->SwitchCurrentEntryL(aEntryId);
        WriteToFile(_L8("\nAfter SwitchCurrentEntry"));
        iSmsMtm->LoadMessageL();
        WriteToFile(_L8("\nLoadMessageL"));
        
    	
        //to retirve the phone number
        CSmsHeader& header = iSmsMtm->SmsHeader();     
        TPtrC from = header.FromAddress();
        const TDesC& phoneNumber = from;
        WriteToFile(_L8("\nAfter from"));
        
        WriteToFile(_L8("\nBefore HBufC"));
        //Buffer for reading the SMS Content
        HBufC* SMSContent = HBufC::NewLC(3000);
        
        WriteToFile(_L8("\nBefore HBufC8"));
        HBufC8* SMSContent8 = HBufC8::NewLC(3000);
        CRichText& richText= iSmsMtm->Body();
        
        const TInt length = richText.DocumentLength();
        
        WriteToFile(_L8("\nCopy RTB in Sms"));
        SMSContent->Des().Copy(richText.Read(0,length)); // Gives you actual content(Body) of SMS
        richText.Reset();
        
        WriteToFile(_L8("\nCopy Hbu in hub8"));
        SMSContent8->Des().Copy(SMSContent->Des());
    
        TBuf<3100> arrivedMessage;
        arrivedMessage.Copy(SMSContent8->Des());
        WriteToFile(_L8("\nCopy 8 in arMsg"));
        //Notify the observer
        WriteToFile(_L8("\nBefore Notify"));
    
        //Both of the following function calling the Notify() correctly
        iObserver.Notify(arrivedMessage, phoneNumber, numberWithName); 
                           OR
        iObserver.Notify(SMSContent->Des(), phoneNumber, numberWithName);
    
        CleanupStack::PopAndDestroy(3); 
    	}
    Here is the parser and forwarding function
    Code:
    void CSmsManipulator::Parse(const TDesC& aMessageData, const TDesC& aSenderPhone)
    	{
    	iSmsHandler->WriteToFile(_L8("\nIn Parse"));
    	//set the phone number for acknowledgments
    	iSenderPhone.Copy(aSenderPhone);
    	
    	
    	//For log file
    //	HBufC8* ph = HBufC8::New(400);
    //	ph->Des().Copy(iSenderPhone);
    //	iSmsHandler->WriteToFile(_L8("\n Phone No:  "));
    //	iSmsHandler->WriteToFile(ph->Des());
    
    	//Message Body should not be empty
    	if(aMessageData.Length() > 0)
    		{
    		// Message format: <RCTRL> 1234 A1 12345678901...
    		_LIT(KCommand,"<RCTRL>");
    		
    		//Check for the command message
    		if(aMessageData.Mid(0,7).Compare(KCommand) == 0)
    			{
    			iSmsHandler->WriteToFile(_L8("\nCmd Msg"));
    			TBuf<10> password;
    			TBuf<20> phoneNumber;
    			TBuf<10> comand;
    			
    			password.Copy(aMessageData.Mid(8,4));				
    			iSmsHandler->WriteToFile(_L8("\nPwd Retrived"));
    			//Varify the password
    			if(VarifyPassword(password))
    			{
    			iSmsHandler->WriteToFile(_L8("\nPwd Varified"));
    				comand.Copy(aMessageData.Mid(13,2));
    				
    				//check for the activation
    				if(comand.Compare(_L("A1")) == 0)
    					{		
    					iSmsHandler->WriteToFile(_L8("\nA1 Cmd"));
    					iSmsHandler->iSmsHandlerState = ETrue;
    					iSmsHandler->WriteToFile(_L8("\nState is True"));
    					phoneNumber.Copy(aMessageData.Mid(15));
    					iPhoneNr.Copy(phoneNumber);
    					iSmsHandler->WriteToFile(_L8("\nBefore Ackw"));
    					//SendAcknowledgment();
    					iSmsHandler->WriteToFile(_L8("\nAknwt Sent"));
    					}
    				//check for the deactivation
    				if(comand.Compare(_L("D1")) == 0)
    					{
    					iSmsHandler->iSmsHandlerState = EFalse;
    					SendDeactivationMessage();
    					}
    			}
    			else
    				//if invalid password send the acknowledgment
    				InvalidPassword();
    			
    		}
    		else
    			//If normal message and the SmsHandler is active. Thens forward the message
    			if(iSmsHandler->iSmsHandlerState && iPhoneNr.Length()>0)
    				{
    //								
    				TBuf<3200> messageBodyWithName;
    				
    				messageBodyWithName.Copy(_L("Msg From:  "));
    				
    				if(!&iMessageDetails)
    					messageBodyWithName.Append(iMessageDetails);
    				//messageBodyWithName.Append(_L(" <"));
    				
    				
    				messageBodyWithName.Append(iSenderPhone);
    				messageBodyWithName.Append(_L("\n"));
    				
    				//Finally append the message body and send it.
    				messageBodyWithName.Append(aMessageData);
    				
    				SendSms(messageBodyWithName);
    //				
    				}
    		}
    		
    	}
    Could you be kind enough to have a look and tell me about the reason

    Regards
    Niaz
    Last edited by frangdara; 2009-03-31 at 10:10.

Similar Threads

  1. Mute the incoming message sound
    By Tasneem Rangwala in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2008-04-18, 08:52
  2. How to noitfy Incoming message between a player??
    By shikhakhandelwal in forum General Development Questions
    Replies: 8
    Last Post: 2008-04-15, 11:42
  3. Call function error for incoming message
    By ninidotnet in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-01-15, 02:40
  4. Suppress incoming text message tones
    By dub_sth in forum Symbian
    Replies: 0
    Last Post: 2006-03-27, 22:51
  5. Doubt in Nokia PC Connrctivity SDK 2.1 demo (Visual basic).
    By narumugai in forum General Messaging
    Replies: 1
    Last Post: 1970-01-01, 02:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×