diff --git a/platform/tizen_utils.cpp b/platform/tizen_utils.cpp index 4e45100b98..6141ecd40a 100644 --- a/platform/tizen_utils.cpp +++ b/platform/tizen_utils.cpp @@ -1,8 +1,8 @@ #include "tizen_utils.hpp" #include "../../std/vector.hpp" - #include "../../tizen/inc/FBase.hpp" #include "../base/logging.hpp" +#include "../base/macros.hpp" #include @@ -14,9 +14,7 @@ string FromTizenString(Tizen::Base::String const & str_tizen) Tizen::Base::ByteBuffer * pBuffer = Tizen::Base::Utility::StringUtil::StringToUtf8N(str_tizen); if (pBuffer) { - int byteCount = pBuffer->GetLimit(); - - byteCount--; // Don't copy Zero at the end + int byteCount = pBuffer->GetLimit() - 1; // Don't copy Zero at the end if (byteCount > 0) { vector chBuf(byteCount); @@ -37,9 +35,9 @@ string GetTizenLocale() return CodeFromISO369_2to_1(FromTizenString(languageCode_truncated)); } -string CodeFromISO369_2to_1(string const & code_ISO_639_2) +string CodeFromISO369_2to_1(string const & code) { - static const string ar [] = + static char const * ar [] = { "aar", "aa", "abk", "ab", @@ -246,13 +244,13 @@ string CodeFromISO369_2to_1(string const & code_ISO_639_2) "zho", "zh", "zul", "zu" }; - for (size_t i = 0; i < sizeof(ar)/sizeof(ar[0]); i += 2) + for (size_t i = 0; i < ARRAY_SIZE(ar); i += 2) { - if (code_ISO_639_2 == ar[i]) + if (code == ar[i]) { return ar[i + 1]; } } - LOG(LDEBUG, ("Language not found", code_ISO_639_2)); + LOG(LDEBUG, ("Language not found", code)); return "en"; } diff --git a/platform/tizen_utils.hpp b/platform/tizen_utils.hpp index 41332ff53e..7d20d89518 100644 --- a/platform/tizen_utils.hpp +++ b/platform/tizen_utils.hpp @@ -13,7 +13,7 @@ namespace Tizen //Convert from Tizen string to std::string string FromTizenString(Tizen::Base::String const & str_tizen); -string CodeFromISO369_2to_1(string const & code_ISO_639_2); +string CodeFromISO369_2to_1(string const & code); string GetTizenLocale(); #endif diff --git a/tizen/MapsWithMe/inc/DownloadCountryForm.hpp b/tizen/MapsWithMe/inc/DownloadCountryForm.hpp index 9f4d3c26b8..7c8abcdd87 100644 --- a/tizen/MapsWithMe/inc/DownloadCountryForm.hpp +++ b/tizen/MapsWithMe/inc/DownloadCountryForm.hpp @@ -1,5 +1,4 @@ #pragma once -#pragma once #include #include "../../../std/map.hpp" @@ -10,7 +9,8 @@ namespace storage class Storage; } -namespace Tizen{namespace Graphics{ +namespace Tizen{namespace Graphics +{ class Bitmap; }} @@ -55,17 +55,20 @@ private: void OnCountryDownloaded(storage::TIndex const & country); void OnCountryDowloadProgres(storage::TIndex const & index, pair const & p); - static const int ID_FORMAT_STRING = 500; - static const int ID_FORMAT_FLAG = 501; - static const int ID_FORMAT_STATUS = 502; - static const int ID_FORMAT_DOWNLOADING_PROGR = 503; + enum + { + ID_FORMAT_STRING = 500, + ID_FORMAT_FLAG = 501, + ID_FORMAT_STATUS = 502, + ID_FORMAT_DOWNLOADING_PROGR = 503 + } EEventIDs; - map m_Flags; + map m_flags; Tizen::Graphics::Bitmap const * m_downloadedBitmap; Tizen::Graphics::Bitmap const * m_updateBitmap; - storage::TIndex m_group_index; - Tizen::Base::String m_form_id; - int m_DowloadStatusSlot; - map > m_lastDownload_value; + storage::TIndex m_groupIndex; + Tizen::Base::String m_fromId; + int m_dowloadStatusSlot; + map > m_lastDownloadValue; }; diff --git a/tizen/MapsWithMe/src/DownloadCountryForm.cpp b/tizen/MapsWithMe/src/DownloadCountryForm.cpp index 059ba2247c..75dba56843 100644 --- a/tizen/MapsWithMe/src/DownloadCountryForm.cpp +++ b/tizen/MapsWithMe/src/DownloadCountryForm.cpp @@ -5,11 +5,13 @@ #include "Framework.hpp" #include "Utils.hpp" #include "FormFactory.hpp" -#include "../../../std/bind.hpp" -#include "../../../base/logging.hpp" + +#include "../../../map/framework.hpp" #include "../../../platform/settings.hpp" #include "../../../platform/tizen_utils.hpp" -#include "../../../map/framework.hpp" +#include "../../../base/logging.hpp" +#include "../../../std/bind.hpp" + #include #include #include @@ -25,10 +27,9 @@ using namespace Tizen::Graphics; using namespace storage; DownloadCountryForm::DownloadCountryForm() -: m_downloadedBitmap(0), - m_updateBitmap(0) + : m_downloadedBitmap(0), m_updateBitmap(0) { - m_DowloadStatusSlot = Storage().Subscribe(bind(&DownloadCountryForm::OnCountryDownloaded, this, _1), + m_dowloadStatusSlot = Storage().Subscribe(bind(&DownloadCountryForm::OnCountryDownloaded, this, _1), bind(&DownloadCountryForm::OnCountryDowloadProgres, this, _1, _2)); AppResource * pAppResource = Application::GetInstance()->GetAppResource(); @@ -42,7 +43,7 @@ DownloadCountryForm::~DownloadCountryForm(void) delete (m_downloadedBitmap); if (m_updateBitmap) delete (m_updateBitmap); - Storage().Unsubscribe(m_DowloadStatusSlot); + Storage().Unsubscribe(m_dowloadStatusSlot); } bool DownloadCountryForm::Initialize(void) @@ -53,7 +54,7 @@ bool DownloadCountryForm::Initialize(void) result DownloadCountryForm::OnInitializing(void) { - m_group_index = -1; + m_groupIndex = -1; SetFormBackEventListener(this); return E_SUCCESS; @@ -77,22 +78,22 @@ storage::Storage & DownloadCountryForm::Storage() const Tizen::Graphics::Bitmap const * DownloadCountryForm::GetFlag(storage::TIndex const & country) { - if (m_Flags.count(country) == 0) + if (m_flags.count(country) == 0) { AppResource * pAppResource = Application::GetInstance()->GetAppResource(); String sFlagName = "flags/"; sFlagName += Storage().CountryFlag(country).c_str(); sFlagName += ".png"; - m_Flags[country] = pAppResource->GetBitmapN(sFlagName); + m_flags[country] = pAppResource->GetBitmapN(sFlagName); } - return m_Flags[country]; + return m_flags[country]; } Tizen::Ui::Controls::ListItemBase * DownloadCountryForm::CreateItem(int index, float itemWidth) { TIndex country = GetIndex(index); FloatDimension itemDimension(itemWidth, 120.0f); - CustomItem* pItem = new (std::nothrow) CustomItem(); + CustomItem * pItem = new CustomItem(); String sName = Storage().CountryName(country).c_str(); bool bNeedFlag = GetFlag(country) != 0; @@ -135,8 +136,8 @@ Tizen::Ui::Controls::ListItemBase * DownloadCountryForm::CreateItem(int index, f { int pr = 0; - if (m_lastDownload_value.count(country) > 0) - pr = 100 * m_lastDownload_value[country].first / m_lastDownload_value[country].second; + if (m_lastDownloadValue.count(country) > 0) + pr = 100 * m_lastDownloadValue[country].first / m_lastDownloadValue[country].second; String s; s.Append(pr); s.Append("%"); @@ -156,34 +157,35 @@ bool DownloadCountryForm::DeleteItem(int index, Tizen::Ui::Controls::ListItemBas { delete pItem; pItem = null; - if (m_Flags.count(GetIndex(index)) != 0) - delete m_Flags[GetIndex(index)]; - m_Flags.erase(GetIndex(index)); + TIndex const ind = GetIndex(index); + if (m_flags.count(ind) != 0) + delete m_flags[ind]; + m_flags.erase(ind); return true; } int DownloadCountryForm::GetItemCount(void) { - return Storage().CountriesCount(m_group_index); + return Storage().CountriesCount(m_groupIndex); } void DownloadCountryForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) { - m_form_id = SceneManager::GetInstance()->GetCurrentScene()->GetFormId(); + m_fromId = SceneManager::GetInstance()->GetCurrentScene()->GetFormId(); if (pArgs != null) { if (pArgs->GetCount() == 2) { Integer * pGroup = dynamic_cast(pArgs->GetAt(0)); Integer * pCountry = dynamic_cast(pArgs->GetAt(1)); - m_group_index.m_group = pGroup->value; - m_group_index.m_country = pCountry->value; - m_group_index.m_region = TIndex::INVALID; + m_groupIndex.m_group = pGroup->value; + m_groupIndex.m_country = pCountry->value; + m_groupIndex.m_region = TIndex::INVALID; } - ListView * __pList = static_cast(GetControl(IDC_DOWNLOAD_LISTVIEW)); - __pList->SetItemProvider(*this); - __pList->AddListViewItemEventListener(*this); + ListView *pList = static_cast(GetControl(IDC_DOWNLOAD_LISTVIEW)); + pList->SetItemProvider(*this); + pList->AddListViewItemEventListener(*this); pArgs->RemoveAll(true); delete pArgs; } @@ -203,19 +205,19 @@ bool DownloadCountryForm::IsGroup(storage::TIndex const & index) const TIndex DownloadCountryForm::GetIndex(int const ind) const { - TIndex res = m_group_index; - if (m_form_id == FORM_DOWNLOAD_GROUP) + TIndex res = m_groupIndex; + if (m_fromId == FORM_DOWNLOAD_GROUP) res.m_group = ind; - if (m_form_id == FORM_DOWNLOAD_COUNTRY) + if (m_fromId == FORM_DOWNLOAD_COUNTRY) res.m_country = ind; - else if (m_form_id == FORM_DOWNLOAD_REGION) + else if (m_fromId == FORM_DOWNLOAD_REGION) res.m_region = ind; return res; } wchar_t const * DownloadCountryForm::GetNextScene() const { - if (m_form_id == FORM_DOWNLOAD_GROUP) + if (m_fromId == FORM_DOWNLOAD_GROUP) return SCENE_DOWNLOAD_COUNTRY; return SCENE_DOWNLOAD_REGION; } @@ -226,10 +228,10 @@ void DownloadCountryForm::OnListViewItemStateChanged(ListView & listView, int in TIndex country = GetIndex(index); if (IsGroup(country)) { - ArrayList * pList = new (std::nothrow) ArrayList; + ArrayList * pList = new ArrayList; pList->Construct(); - pList->Add(*(new (std::nothrow) Integer(country.m_group))); - pList->Add(*(new (std::nothrow) Integer(country.m_country))); + pList->Add(new Integer(country.m_group)); + pList->Add(new Integer(country.m_country)); SceneManager * pSceneManager = SceneManager::GetInstance(); pSceneManager->GoForward( @@ -238,6 +240,7 @@ void DownloadCountryForm::OnListViewItemStateChanged(ListView & listView, int in } else { + String name = Storage().CountryName(country).c_str(); TStatus status = Storage().CountryStatusEx(country); if (status == ENotDownloaded || status == EDownloadFailed) { @@ -247,16 +250,16 @@ void DownloadCountryForm::OnListViewItemStateChanged(ListView & listView, int in msg.Append(int((size.second - size.first) >> 20)); msg.Append(GetString(IDS_MB)); - if (MessageBoxAsk(Storage().CountryName(country).c_str(), msg)) + if (MessageBoxAsk(name, msg)) Storage().DownloadCountry(country); } else if (status == EDownloading || status == EInQueue) { - if (MessageBoxAsk(String(Storage().CountryName(country).c_str()), GetString(IDS_CANCEL_DOWNLOAD))) - if (MessageBoxAsk(String(Storage().CountryName(country).c_str()), GetString(IDS_ARE_YOU_SURE))) + if (MessageBoxAsk(name, GetString(IDS_CANCEL_DOWNLOAD))) + if (MessageBoxAsk(name, GetString(IDS_ARE_YOU_SURE))) { Storage().DeleteFromDownloader(country); - m_lastDownload_value.erase(country); + m_lastDownloadValue.erase(country); } } else if (status == EOnDisk) @@ -265,8 +268,8 @@ void DownloadCountryForm::OnListViewItemStateChanged(ListView & listView, int in msg.Append(" "); msg.Append(int(Storage().CountrySizeInBytes(country).first >> 20)); msg.Append(GetString(IDS_MB)); - if (MessageBoxAsk(String(Storage().CountryName(country).c_str()), msg)) - if (MessageBoxAsk(String(Storage().CountryName(country).c_str()), GetString(IDS_ARE_YOU_SURE))) + if (MessageBoxAsk(name, msg)) + if (MessageBoxAsk(name, GetString(IDS_ARE_YOU_SURE))) tizen::Framework::GetInstance()->DeleteCountry(country); } UpdateList(); @@ -275,13 +278,13 @@ void DownloadCountryForm::OnListViewItemStateChanged(ListView & listView, int in void DownloadCountryForm::UpdateList() { - ListView * __pList = static_cast(GetControl(IDC_DOWNLOAD_LISTVIEW)); - __pList->UpdateList(); + ListView * pList = static_cast(GetControl(IDC_DOWNLOAD_LISTVIEW)); + pList->UpdateList(); } void DownloadCountryForm::OnCountryDownloaded(TIndex const & country) { - if (m_form_id != SceneManager::GetInstance()->GetCurrentScene()->GetFormId()) + if (m_fromId != SceneManager::GetInstance()->GetCurrentScene()->GetFormId()) return; if (Storage().CountryStatusEx(country) == EDownloadFailed) { @@ -293,9 +296,9 @@ void DownloadCountryForm::OnCountryDownloaded(TIndex const & country) void DownloadCountryForm::OnCountryDowloadProgres(TIndex const & index, pair const & p) { - if (m_form_id != SceneManager::GetInstance()->GetCurrentScene()->GetFormId()) + if (m_fromId != SceneManager::GetInstance()->GetCurrentScene()->GetFormId()) return; - m_lastDownload_value[index] = p; + m_lastDownloadValue[index] = p; UpdateList(); } diff --git a/tizen/MapsWithMe/src/FormFactory.cpp b/tizen/MapsWithMe/src/FormFactory.cpp index 78c6c61bd5..aa06d70c08 100644 --- a/tizen/MapsWithMe/src/FormFactory.cpp +++ b/tizen/MapsWithMe/src/FormFactory.cpp @@ -35,20 +35,20 @@ Tizen::Ui::Controls::Form * FormFactory::CreateFormN(String const & formId, Scen static MapsWithMeForm * pMWMForm = 0; if (formId == FORM_MAP) { - pMWMForm = new (std::nothrow) MapsWithMeForm(); + pMWMForm = new MapsWithMeForm(); pMWMForm->Initialize(); pMWMForm->AddTouchEventListener(*pMWMForm); pNewForm = pMWMForm; } else if (formId == FORM_SETTINGS) { - SettingsForm * pForm = new (std::nothrow) SettingsForm(pMWMForm); + SettingsForm * pForm = new SettingsForm(pMWMForm); pForm->Initialize(); pNewForm = pForm; } else if (formId == FORM_ABOUT) { - AboutForm * pForm = new (std::nothrow) AboutForm(); + AboutForm * pForm = new AboutForm(); pForm->Initialize(); pNewForm = pForm; } @@ -56,7 +56,7 @@ Tizen::Ui::Controls::Form * FormFactory::CreateFormN(String const & formId, Scen formId == FORM_DOWNLOAD_COUNTRY || formId == FORM_DOWNLOAD_REGION) { - DownloadCountryForm * pForm = new (std::nothrow) DownloadCountryForm(); + DownloadCountryForm * pForm = new DownloadCountryForm(); pForm->Initialize(); pSceneManager->AddSceneEventListener(sceneId, *pForm); pNewForm = pForm; diff --git a/tizen/MapsWithMe/src/MapsWithMeApp.cpp b/tizen/MapsWithMe/src/MapsWithMeApp.cpp index fd2c9dd40b..7926bd9e82 100644 --- a/tizen/MapsWithMe/src/MapsWithMeApp.cpp +++ b/tizen/MapsWithMe/src/MapsWithMeApp.cpp @@ -13,7 +13,7 @@ MapsWithMeApp::MapsWithMeApp(void) {} MapsWithMeApp::~MapsWithMeApp(void) {} -UiApp * MapsWithMeApp::CreateInstance(void) {return new (std::nothrow) MapsWithMeApp();} +UiApp * MapsWithMeApp::CreateInstance(void) {return new MapsWithMeApp();} bool MapsWithMeApp::OnAppInitializing(AppRegistry& appRegistry) { @@ -28,7 +28,7 @@ bool MapsWithMeApp::OnAppInitializing(AppRegistry& appRegistry) // Create the application frame. - MapsWithMeFrame* pMapsWithMeFrame = new (std::nothrow) MapsWithMeFrame; + MapsWithMeFrame* pMapsWithMeFrame = new MapsWithMeFrame; TryReturn(pMapsWithMeFrame != null, false, "The memory is insufficient."); pMapsWithMeFrame->Construct(); pMapsWithMeFrame->SetName(L"MapsWithMe"); diff --git a/tizen/MapsWithMe/src/MapsWithMeEntry.cpp b/tizen/MapsWithMe/src/MapsWithMeEntry.cpp index baebf78e8f..d7d617b7f8 100644 --- a/tizen/MapsWithMe/src/MapsWithMeEntry.cpp +++ b/tizen/MapsWithMe/src/MapsWithMeEntry.cpp @@ -22,7 +22,7 @@ _EXPORT_ int OspMain(int argc, char* pArgv[]) args.Construct(); for (int i = 0; i < argc; i++) { - args.Add(new (std::nothrow) String(pArgv[i])); + args.Add(new String(pArgv[i])); } result r = Tizen::App::UiApp::Execute(MapsWithMeApp::CreateInstance, &args); diff --git a/tizen/MapsWithMe/src/MapsWithMeForm.cpp b/tizen/MapsWithMe/src/MapsWithMeForm.cpp index d6e58393d8..f4b6986c04 100644 --- a/tizen/MapsWithMe/src/MapsWithMeForm.cpp +++ b/tizen/MapsWithMe/src/MapsWithMeForm.cpp @@ -58,13 +58,13 @@ result MapsWithMeForm::OnInitializing(void) width = GetClientAreaBounds().width; height = GetClientAreaBounds().height; // Create a Label - m_pLabel = new (std::nothrow) Label(); + m_pLabel = new Label(); m_pLabel->Construct(Rectangle(width / 4, 10, width *3/4, 120), L"GPS off"); m_pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); m_pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); AddControl(m_pLabel); // Create a Button GPS - m_pButtonGPS = new (std::nothrow) Button(); + m_pButtonGPS = new Button(); m_pButtonGPS->Construct(Rectangle(50, height -150, 100, 100)); m_pButtonGPS->SetText(L"GPS\noff"); m_pButtonGPS->SetActionId(ID_BUTTON_GPS); @@ -72,7 +72,7 @@ result MapsWithMeForm::OnInitializing(void) AddControl(m_pButtonGPS); // Create a Button Settings - m_pButtonSettings = new (std::nothrow) Button(); + m_pButtonSettings = new Button(); m_pButtonSettings->Construct(Rectangle(width - 150, height -150, 100, 100)); m_pButtonSettings->SetText(L"Set\ntings"); m_pButtonSettings->SetActionId(ID_BUTTON_SETTINGS); @@ -80,21 +80,21 @@ result MapsWithMeForm::OnInitializing(void) AddControl(m_pButtonSettings); // Create a Button Download - Button * pButtonDownload = new (std::nothrow) Button(); + Button * pButtonDownload = new Button(); pButtonDownload->Construct(Rectangle(width - 270, height -150, 100, 100)); pButtonDownload->SetText(L"Down\nload"); pButtonDownload->SetActionId(ID_BUTTON_DOWNLOAD); pButtonDownload->AddActionEventListener(*this); AddControl(pButtonDownload); - m_pButtonScalePlus = new (std::nothrow) Button(); + m_pButtonScalePlus = new Button(); m_pButtonScalePlus->Construct(Rectangle(width - 150, height / 2, 100, 100)); m_pButtonScalePlus->SetText(L"+"); m_pButtonScalePlus->SetActionId(ID_BUTTON_SCALE_PLUS); m_pButtonScalePlus->AddActionEventListener(*this); AddControl(m_pButtonScalePlus); - m_pButtonScaleMinus = new (std::nothrow) Button(); + m_pButtonScaleMinus = new Button(); m_pButtonScaleMinus->Construct(Rectangle(width - 150,( height / 2) + 120, 100, 100)); m_pButtonScaleMinus->SetText(L"-"); m_pButtonScaleMinus->SetActionId(ID_BUTTON_SCALE_MINUS); @@ -158,10 +158,10 @@ void MapsWithMeForm::OnActionPerformed(Tizen::Ui::Control const & source, int ac } case ID_BUTTON_DOWNLOAD: { - ArrayList * pList = new (std::nothrow) ArrayList; + ArrayList * pList = new ArrayList; pList->Construct(); - pList->Add(*(new (std::nothrow) Integer(storage::TIndex::INVALID))); - pList->Add(*(new (std::nothrow) Integer(storage::TIndex::INVALID))); + pList->Add(new Integer(storage::TIndex::INVALID)); + pList->Add(new Integer(storage::TIndex::INVALID)); SceneManager * pSceneManager = SceneManager::GetInstance(); pSceneManager->GoForward(ForwardSceneTransition(SCENE_DOWNLOAD_GROUP,