×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Text formatting

  1. #1
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    246

    Text formatting

    Hi,

    I would like to send notification message to recipient which need the user to reply yes or no. The message format is like the following:

    Sending handshake. Do you want to accept?
    0 No
    1 yes
    Reply?


    void CSMSExampleAddressContainer::SendNotificationL(TDesC& aName)
    {
    iContactName = aName;

    _LIT( KBreaks, "\n" );
    TBuf <100> bufMessage;
    bufMessage.Append(iContactName); // Contact name
    bufMessage.Append(KNotifyMes0); // is sending handshake. Do you want to accept?
    bufMessage.Append(KBreaks);
    bufMessage.Append(KNotifyMes1); // 0 No
    bufMessage.Append(KBreaks);
    bufMessage.Append(KNotifyMes2); // 1 Yes
    bufMessage.Append(KBreaks);
    bufMessage.Append(KNotifyMes3); // Reply?
    }


    I'm using the above code and it's working for notes. i just wondering if i can use the same code as message.
    Last edited by ninidotnet; 2006-12-05 at 03:05.
    Regards,
    Nini

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

    Smile Re: Text formatting

    Hi Nini,
    Quote Originally Posted by ninidotnet
    Hi,

    I would like to send notification message to recipient which need the user to reply yes or no. The message format is like the following:

    Sending handshake. Do you want to accept?
    0 No
    1 yes
    Reply?


    void CSMSExampleAddressContainer::SendNotificationL(TDesC& aName)
    {
    iContactName = aName;

    _LIT( KBreaks, "\n" );
    TBuf <100> bufMessage;
    bufMessage.Append(iContactName); // Contact name
    bufMessage.Append(KNotifyMes0); // is sending handshake. Do you want to accept?
    bufMessage.Append(KBreaks);
    bufMessage.Append(KNotifyMes1); // 0 No
    bufMessage.Append(KBreaks);
    bufMessage.Append(KNotifyMes2); // 1 Yes
    bufMessage.Append(KBreaks);
    bufMessage.Append(KNotifyMes3); // Reply?
    }


    I'm using the above code and it's working for notes. i just wondering if i can use the same code as message.
    Yes, You can use this descriptor format to send message.

    Regards.
    Kiran.

  3. #3
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    246

    Talking Re: Text formatting

    Hi,

    Thanks Kiran ;)
    Regards,
    Nini

  4. #4
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    246

    Re: Text formatting

    Hi,

    I want to send notification message to recipient after adding recipient details in database. No compilation error but program crash once i click menu. When I check the database, the data was adding successfully but crash while passing data for sending message.

    Code:
    void CSMSExampleAddressContainer::CreateRecordL(TDesC& aName, TDesC& aPhone, TDesC& aKey)
    {
        iContactName = aName;
        iContactNumber = aPhone;
        iContactPK = aKey;
    
        iEngine->SetName( iContactName );
        iEngine->SetPublicKey( iContactPK );
        iEngine->SetPhone( iContactNumber );
    
        // Now create the record
        iEngine->AddRecordL();
        // Send notofication message
        SendNotificationL(iContactName, iContactNumber);
    }
    
    void CSMSExampleAddressContainer::SendNotificationL(TDesC& aName, TDesC& aPhone)
    {
        iContactName = aName;
        iContactNumber = aPhone;
    
        _LIT( KBreaks, "\n" );
        TBuf <100> bufMessage;
        bufMessage.Append(iContactName);      // Contact name
        bufMessage.Append(KNotifyMes0);       // is sending handshake. Do you want to accept?
        bufMessage.Append(KBreaks);
        bufMessage.Append(KNotifyMes1);       // 0 No
        bufMessage.Append(KBreaks);
        bufMessage.Append(KNotifyMes2);       // 1 Yes
        bufMessage.Append(KBreaks);
        bufMessage.Append(KNotifyMes3);       // Reply?
    
        iSMSEngine->CreateAndSendMessage(iContactNumber, bufMessage);
    }
    ****

    Code:
    void CSMSExampleAppUi::CreateAndSendMessage(const TDesC& aAdd, const TDesC& aSms)
        {
            // Create a new SMS to outbox
            iAddress = aAdd;
            iMessage = aSms;
            iEngine->CreateSMSMessageL( iAddress, iMessage );
    
            // Validate it before sending
            if ( iEngine->ValidateCreatedSMS() )
            {
                iEngine->SendSMSL();      // Now send
            }
            else
            {
                NotifyMessageInvalidL(KInvalidMessageResend);    // Showing error notes
            }
        }
    Anybody have any idea... what's wrong with the code?
    Thanks...
    Regards,
    Nini

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,335

    Smile Re: Text formatting

    Hi Nini,
    Quote Originally Posted by ninidotnet
    Hi,
    I want to send notification message to recipient after adding recipient details in database. No compilation error but program crash once i click menu. When I check the database, the data was adding successfully but crash while passing data for sending message.
    ...
    Anybody have any idea... what's wrong with the code?
    Thanks...
    What panic code do you get on crash?
    And exactly which line is causing this crash?

    Regards.
    Kiran.

  6. #6
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    246

    Re: Text formatting

    Hi Kiran,

    Thanks for your reply.. I found the solution.
    I'm using

    CSMSExampleAppUi *iappui=(CSMSExampleAppUi *)CEikonEnv::Static()->EikAppUi();
    iappui->SaveMessageInFolder(iContactNumber, bufMessage);

    instead of

    iSMSEngine->CreateAndSendMessage(iContactNumber, bufMessage);



    I have one more question. How to get sender's name? In the message should be sender's name not recipient name.
    Thanks...
    Regards,
    Nini

  7. #7
    Registered User
    Join Date
    Feb 2006
    Posts
    17

    Re: Text formatting

    Hi,

    Sender number will be available in SMS header. Try this

    CSmsHeader& header = static_cast <CSmsClientMtm *>(iMtm)->SmsHeader();
    TPtrC iSender(header.FromAddress());

    Regards,
    Vidya

  8. #8
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    246

    Re: Text formatting

    Hi,
    I'm trying that code but program stopped at the blue line. I'm trying to get sender's name or phone number and it will be part of the message.

    Code:
    void CSMSExampleAddressContainer::SendNotificationL(TDesC& aPhone)
    {
        TBuf <160> bufMessage;
        TBuf <15> iSenderName;
        
        iContactNumber = aPhone;
        iSenderName = iSender->GetSender();
    
        _LIT( KBreaks, "\n" );
        bufMessage.Append(iSenderName);      // Sender's name
        bufMessage.Append(KNotifyMes0);       // is sending handshake. Do you want to accept?
        bufMessage.Append(KBreaks);
        bufMessage.Append(KNotifyMes1);       // 0 No
        bufMessage.Append(KBreaks);
        bufMessage.Append(KNotifyMes2);       // 1 Yes
        bufMessage.Append(KBreaks);
        bufMessage.Append(KNotifyMes3);       // Reply?
    
        CSMSExampleAppUi *iappui=(CSMSExampleAppUi*)CEikonEnv::Static()->EikAppUi();
        iappui->SaveMessageInFolder(iContactNumber, bufMessage);
     
    }
    Code:
    TDesC& CSMSExampleMtmsEngine::GetSender()
    {
        TBuf<15> iSender;
        CSmsHeader& header = static_cast <CSmsClientMtm*>(iSmsMtm)->SmsHeader();  // STOP HERE!
        //TPtrC iSender(header.FromAddress());
        iSender.Append( header.FromAddress() );
        return iSender;
    }

    When debugging, I got this message:
    Stopped at exception c0000005: access violation at 0x0f8c74c3: read of address 0x0000001c

    What should i do? Thanks...
    Regards,
    Nini

  9. #9
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,335

    Smile Re: Text formatting

    Hi Nini,

    Quote Originally Posted by ninidotnet
    I have one more question. How to get sender's name? In the message should be sender's name not recipient name.
    Thanks...
    EDIT: Do you want Sender's Name or Number?
    Because FromAddress() would always give you Number, not a Name.

    Regards.
    Kiran.
    Last edited by kiran10182; 2006-12-07 at 04:56.

  10. #10
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    246

    Re: Text formatting

    Hi,

    I just try to use code given by vidyamg. It is good if I can use sender's name in the message. Do you know how to do it Kiran? I'm sure sender's name is based on what recipient saved in their phone right?

    Thanks...
    Regards,
    Nini

  11. #11
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,335

    Smile Re: Text formatting

    Hi,
    Quote Originally Posted by ninidotnet
    Hi,

    I just try to use code given by vidyamg. It is good if I can use sender's name in the message. Do you know how to do it Kiran? I'm sure sender's name is based on what recipient saved in their phone right?

    Thanks...
    Yes. Sure. You can use iDetails to get the name of Sender if it's saved in the Phonebook. Otherwise it will give you a Number instead of Name(apparently).

    Regards.
    Kiran.

  12. #12
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,335

    Question Re: Text formatting

    Hi Nini,
    Quote Originally Posted by ninidotnet
    Hi,

    I just try to use code given by vidyamg. It is good if I can use sender's name in the message. Do you know how to do it Kiran? I'm sure sender's name is based on what recipient saved in their phone right?

    Thanks...
    Now thing to ask you:
    Do you want to retrieve the number/name of Sender when Message arrives?

    Regards.
    Kiran.

  13. #13
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    246

    Re: Text formatting

    Hi again,

    I want to use name of sender.
    Regards,
    Nini

  14. #14
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,335

    Smile Re: Text formatting

    Hi Nini,
    Quote Originally Posted by ninidotnet
    Hi again,

    I want to use name of sender.
    I understood your question but i want to ask that: Are you listening to incoming messages from your application? If yes then it would be easy to get Name/Number of Sender. Please make me clear.

    Regards.
    Kiran.

  15. #15
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    246

    Re: Text formatting

    Hi,

    Yes, I'm listening to incoming messages.
    Regards,
    Nini

Similar Threads

  1. formatting text in a listbox
    By ajaykapur in forum Symbian User Interface
    Replies: 9
    Last Post: 2007-10-18, 17:43
  2. MMS: Formatting Text Files
    By brianwestendorf in forum General Messaging
    Replies: 3
    Last Post: 2005-11-22, 04:49
  3. Replies: 0
    Last Post: 2004-11-24, 18:49
  4. TAGMA, the low-level text formatting engine for EPOC
    By lelilja in forum Symbian User Interface
    Replies: 0
    Last Post: 2003-07-31, 10:22
  5. text formatting in series 60
    By s60 in forum Symbian User Interface
    Replies: 1
    Last Post: 2003-02-18, 07:55

Posting Permissions

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