The we:offset application allows consumers to offset the carbon footprint of their travel using their mobile device. The application includes a "share with a friend" feature accessed from the left soft key and used to allow consumers to encourage their friends to download the application. Here is the code behind that feature:
void CEcoFlyerContainerBase::ShareWithFriendsL()
{
CSendUi* sendUi = CSendUi::NewLC();
CMessageData* data = CMessageData::NewL();
CleanupStack::PushL( data );
HBufC* text = HBufC::NewLC( 512 );
text->Des().AppendFormat( *StringLoader::LoadLC( R_LOC_SMS_SHARING), &KEcoFlyerDownloadLink, &_L( "" ) );
CleanupStack::PopAndDestroy();
CRichText* richText = CRichText::NewL(
iEikonEnv->SystemParaFormatLayerL(), iEikonEnv->SystemCharFormatLayerL() );
CleanupStack::PushL( richText );
richText->InsertL( 0, text->Des() );
data->SetBodyTextL( richText );
sendUi->CreateAndSendMessageL( KUidMsgTypeSMS, data );
CleanupStack::PopAndDestroy( 4 );
}
This example looks good, however, it would be great if some more information was added to it describing e.g. what R_LOC_SMS_SHARING and KEcoFlyerDownloadLink are, making comments on what we're getting off from the clean-up stack.