diff -r cfea66083b62 -r baacf668fe89 phoneapp/phonestringloader/src/stringloader.cpp --- a/phoneapp/phonestringloader/src/stringloader.cpp Mon Oct 04 16:06:10 2010 +0300 +++ b/phoneapp/phonestringloader/src/stringloader.cpp Fri Oct 15 12:58:46 2010 +0300 @@ -18,22 +18,10 @@ #include // must be before e32base.h so uncaught_exception gets defined #include #include "phoneresourceadapter.h" -#include "phoneaction.h" // ============================ MEMBER FUNCTIONS =============================== // ----------------------------------------------------------------------------- -// StringLoader::StringLoader -// ----------------------------------------------------------------------------- -// -/* -StringLoader::StringLoader( ) - { - - } -*/ - -// ----------------------------------------------------------------------------- // StringLoader::Load // ----------------------------------------------------------------------------- // @@ -43,12 +31,8 @@ CCoeEnv * aLoaderEnv ) { Q_UNUSED (aLoaderEnv); - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - aDest.Copy (text->text ().utf16 ()); - delete text; - } + QString text = PhoneResourceAdapter::Instance()->convert(aResourceId); + aDest.Copy(text.utf16()); } // ----------------------------------------------------------------------------- @@ -59,19 +43,8 @@ TInt aResourceId, CCoeEnv * aLoaderEnv ) { - Q_UNUSED (aLoaderEnv); - HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewL (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::New (1); - } + HBufC *buf = LoadLC(aResourceId, aLoaderEnv); + CleanupStack::Pop(buf); return buf; } @@ -85,19 +58,8 @@ TInt aInt, CCoeEnv * aLoaderEnv ) { - Q_UNUSED (aLoaderEnv); - HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, aInt); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewL (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::New (1); - } + HBufC *buf = LoadLC(aResourceId, aInt, aLoaderEnv); + CleanupStack::Pop(buf); return buf; } @@ -111,19 +73,8 @@ const TDesC & aString, CCoeEnv * aLoaderEnv ) { - Q_UNUSED (aLoaderEnv); - HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aString); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewL (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::New (1); - } + HBufC *buf = LoadLC(aResourceId, aString, aLoaderEnv); + CleanupStack::Pop(buf); return buf; } @@ -138,19 +89,8 @@ TInt aInt, CCoeEnv * aLoaderEnv ) { - Q_UNUSED (aLoaderEnv); - HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aString, aInt); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewL (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::New (1); - } + HBufC *buf = LoadLC(aResourceId, aString, aInt, aLoaderEnv); + CleanupStack::Pop(buf); return buf; } @@ -164,19 +104,8 @@ const CArrayFix & aInts, CCoeEnv * aLoaderEnv ) { - Q_UNUSED (aLoaderEnv); - HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aInts); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewL (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::New (1); - } + HBufC *buf = LoadLC(aResourceId, aInts, aLoaderEnv); + CleanupStack::Pop(buf); return buf; } @@ -190,19 +119,8 @@ const MDesCArray & aStrings, CCoeEnv * aLoaderEnv ) { - Q_UNUSED (aLoaderEnv); - HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aStrings); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewL (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::New (1); - } + HBufC *buf = LoadLC(aResourceId, aStrings, aLoaderEnv); + CleanupStack::Pop(buf); return buf; } @@ -217,19 +135,8 @@ const CArrayFix & aInts, CCoeEnv * aLoaderEnv ) { - Q_UNUSED (aLoaderEnv); - HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aStrings, &aInts); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewL (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::New (1); - } + HBufC *buf = LoadLC(aResourceId, aStrings, aInts, aLoaderEnv); + CleanupStack::Pop(buf); return buf; } @@ -244,17 +151,9 @@ { Q_UNUSED (aLoaderEnv); HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewLC (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::NewLC (1); - } + QString text = PhoneResourceAdapter::Instance()->convert(aResourceId); + buf = HBufC::NewLC(text.size()); + *buf = text.utf16(); return buf; } @@ -270,17 +169,9 @@ { Q_UNUSED (aLoaderEnv); HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, aInt); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewLC (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::NewLC (1); - } + QString text = PhoneResourceAdapter::Instance()->convert(aResourceId, aInt); + buf = HBufC::NewLC(text.size()); + *buf = text.utf16(); return buf; } @@ -296,17 +187,9 @@ { Q_UNUSED (aLoaderEnv); HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aString); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewLC (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::NewLC (1); - } + QString text = PhoneResourceAdapter::Instance()->convert(aResourceId, &aString); + buf = HBufC::NewLC(text.size()); + *buf = text.utf16(); return buf; } @@ -323,17 +206,9 @@ { Q_UNUSED (aLoaderEnv); HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aString, aInt); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewLC (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::NewLC (1); - } + QString text = PhoneResourceAdapter::Instance()->convert(aResourceId, &aString, aInt); + buf = HBufC::NewLC(text.size()); + *buf = text.utf16(); return buf; } @@ -350,17 +225,9 @@ { Q_UNUSED (aLoaderEnv); HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aInts); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewLC (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::NewLC (1); - } + QString text = PhoneResourceAdapter::Instance()->convert(aResourceId, &aInts); + buf = HBufC::NewLC(text.size()); + *buf = text.utf16(); return buf; } @@ -376,17 +243,9 @@ { Q_UNUSED (aLoaderEnv); HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aStrings); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewLC (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::NewLC (1); - } + QString text = PhoneResourceAdapter::Instance()->convert(aResourceId, &aStrings); + buf = HBufC::NewLC(text.size()); + *buf = text.utf16(); return buf; } @@ -403,16 +262,8 @@ { Q_UNUSED (aLoaderEnv); HBufC *buf; - QMap map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aStrings, &aInts); - if (map.contains (PhoneAction::Text)) { - PhoneAction *text = map [PhoneAction::Text]; - buf = HBufC::NewLC (text->text ().size ()); - *buf = text->text ().utf16 (); - delete text; - } else { - // TODO: this else branch MUST be removed after all strings are localized! - // now here only to prevent crashing - buf = HBufC::NewLC (1); - } + QString text = PhoneResourceAdapter::Instance()->convert(aResourceId, &aStrings, &aInts); + buf = HBufC::NewLC(text.size()); + *buf = text.utf16(); return buf; }