Sending a Unicode SMS message

Login to reply to this topic.
Fri, 2007-09-07 12:35
Joined: 2007-04-18
Forum posts: 10

Hi,
I have been struggling for some days now with trying to send
UCS2 SMS messages, with no success.
All the forums say that just setting the correct character set
will make the MTM send in UCS2. I have had no success at all.

I am using the Series60_v21_CW SDK, and Carbide

1) If I set any of bits 15->7 in any message character,
the MTM sends the message in UTF-8, with no special
action by my app.

2) If I set either the send options or the user options
to 8-bit alphabet, the MTM sends in 8-BIT.

3) If I set the alphabet to UCS2, the MTM sends in ISO-8859-1.

Could one of you brighter people correct my error?????

My code is listed below

Richard

void CSMSEngineR::CreateDraftSMSL(const TDesC& aAddress,const TDesC& aMessage,TBool data)
{
// Set attributes on index entry
TMsvEntry indexEntry;
TInt result = 0;
TInt type;

indexEntry.SetInPreparation(ETrue);
indexEntry.iMtm = KUidMsgTypeSMS;
indexEntry.iType = KUidMsvMessageEntry;
indexEntry.iServiceId = iSmsMtmS->ServiceId();
indexEntry.iDate.HomeTime();
#ifdef __DEV__
p.Format(KSending,&aMessage);SendToDisplay(p);SendNLToDisplay();
#endif
// Create entry from this index entry
TRAP(result,iSmsMtmS->SwitchCurrentEntryL(KMsvDraftEntryId));
if (result != 0)
{
p.Format(_L("fail on switch %d,%d"),result,KMsvDraftEntryId);SendToDisplay(p);SendNLToDisplay();
return;
}

TRAP(result,iSmsMtmS->RestoreServiceAndSettingsL());
if (result != 0)
{
p.Format(_L("fail to restore %d"),result);SendToDisplay(p); SendNLToDisplay();
}

TRAP(result,iSmsMtmS->Entry().CreateL(indexEntry));
if (result != 0)
{
p.Format(_L("fail on create %d"),result);SendToDisplay(p);SendNLToDisplay();
return;
}
// Set the MTM's active context to the new message
iSentMessageId = indexEntry.Id();
iSentMessageId = iSentMessageId; // for queueing action
TRAP(result,iSmsMtmS->SwitchCurrentEntryL(iSentMessageId));
if (result != 0)
{
p.Format(_L("fail on switch %d, %d"),result,iSentMessageId);SendToDisplay(p);SendNLToDisplay();
return;
}

CSmsHeader& header = iSmsMtmS->SmsHeader();
CSmsSettings& serviceSettings = iSmsMtmS->ServiceSettings();

CSmsSettings* sendOptions = CSmsSettings::NewL();
CleanupStack::PushL(sendOptions);
TRAP(result,sendOptions->CopyL(serviceSettings)); // restore existing settings
if (result != 0)
{
p.Format(_L("fail copy options %d"),result);SendToDisplay(p);SendNLToDisplay();
}
// set send options
if (data)
{
//sendOptions->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet8Bit);
sendOptions->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabetUCS2);
}

sendOptions->SetDelivery(ESmsDeliveryImmediately); // set to be delivered immediately
TRAP(result,header.SetSmsSettingsL(*sendOptions));
if (result != 0)
{
p.Format(_L("fail set options %d"),result);SendToDisplay(p);SendNLToDisplay();
}
CleanupStack::PopAndDestroy(sendOptions);

if (data)
{
CSmsMessage& msg = header.Message();
TSmsUserDataSettings smsSettings;
//smsSettings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet8Bit);
smsSettings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabetUCS2);
smsSettings.SetTextCompressed(EFalse);
TRAP(result,msg.SetUserDataSettingsL(smsSettings));
if (result != 0)
{
p.Format(_L("fail set user options %d"),result);SendToDisplay(p);SendNLToDisplay();
}
}

// Add body
CRichText& body = iSmsMtmS->Body();
body.Reset();
TRAP(result,body.InsertL(0, aMessage));
if (result != 0)
{
p.Format(_L("fail on InsertL %d, %d"),result,iSentMessageId);SendToDisplay(p);SendNLToDisplay();
return;
}
indexEntry.iDescription.Set(aMessage);

// Add addressee
TRAP(result,iSmsMtmS->AddAddresseeL(aAddress));
if (result != 0)
{
p.Format(_L("fail on addaddress %d, %d"),result,iSentMessageId);SendToDisplay(p);SendNLToDisplay();
return;
}
indexEntry.iDetails.Set(aAddress);
// Update index entry
TRAP(result,iSmsMtmS->Entry().ChangeL(indexEntry));
if (result != 0)
{
p.Format(_L("fail on ChangeL %d, %d"),result,iSentMessageId);SendToDisplay(p);SendNLToDisplay();
return;
}
// Update store entry
TRAP(result,iSmsMtmS->SaveMessageL());
if (result != 0)
{
p.Format(_L("fail on savemessagel %d, %d"),result,iSentMessageId);SendToDisplay(p);SendNLToDisplay();
}
}


Wed, 2007-09-12 11:10
Joined: 2007-06-20
Forum posts: 1
Re: Sending a Unicode SMS message

Don't convert message to utf8,keep it is unicode,
then u code will work fine!

CSmsHeader& header = smsMtm->SmsHeader();
CSmsSettings* sendOptions = CSmsSettings::NewL();
CleanupStack::PushL(sendOptions);
sendOptions->CopyL(smsMtm->ServiceSettings()); // restore existing settings

// set send options
sendOptions->SetDelivery(ESmsDeliveryImmediately); // set to be delivered immediately
// here we modified the character set
sendOptions->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabetUCS2) ;
// end
header.SetSmsSettingsL(*sendOptions);

  • Login to reply to this topic.