Tizen::Base::String FormatPrice(const T & type, bool aWithCurrency) { Tizen::Base::String sRetval; Tizen::Base::String sPrice; if (type.GetCurrencyUnitHasPenny()) { sPrice.Format(255, L"%.2f", type.GetItemPrice()); } else { sPrice.Format(255, L"%.0f", type.GetItemPrice()); } if (aWithCurrency) { if (type.GetCurrencyUnitPrecedes()) { sRetval = type.GetCurrencyUnit() + sPrice; } else { sRetval = sPrice + type.GetCurrencyUnit(); } } else { sRetval = sPrice; } return sRetval; }
void Chatting::OnPushServiceRegistered(RequestId reqId, const Tizen::Base::String& registrationId, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMsg) { if (r == E_SUCCESS) { // The registrationId may change in some cases. // If the registrationId changes, the application should send the registrationId to the application server. AppLog("####### Push registration is successful. #######"); AppLog( "####### registrationId = %S #######", registrationId.GetPointer()); if (registrationId.Equals(regIdList[0])) { resultRegId = "04a1a6b9f06851233d3392efe419021613dbcec57ba833da007a5fe87ba59d5963eb0f943802ab188b06014c3fc034fcb70e"; } else { resultRegId = "04a173e35ebec95baab94ae8d77a84a76903911ea65dcf67cf2570b9649bef4c8e3f0710ae2f5f2b6969c6b8b119de9c78f7"; } } else { AppLog( "####### Push registration is failed with result[%s]. #######", GetErrorMessage(r)); } }
string GetTizenLocale() { Tizen::Base::String languageCode; Tizen::System::SettingInfo::GetValue(L"http://tizen.org/setting/locale.language", languageCode); Tizen::Base::String languageCode_truncated; languageCode.SubString(0, 3, languageCode_truncated); return CodeFromISO369_2to_1(FromTizenString(languageCode_truncated)); }
Tizen::Base::String FormatSMSString(Tizen::Base::String message, Tizen::Base::String const & url) { message.Replace("%1$s", url); String s2 = "http://ge0.me/"; String s3; url.SubString(6, s3); s2.Append(s3); message.Replace("%2$s", s2); return message; }
Tizen::Base::Object* CantataNode::Run(void) { char *argv2[2]; Tizen::Base::String appName = Tizen::App::App::GetInstance()->GetAppRootPath() + Tizen::App::App::GetInstance()->GetAppName(); Tizen::Base::String resPath = Tizen::App::App::GetInstance()->GetAppResourcePath(); char app_path[512]; char js_path[512]; char node_path[512]; int ret = 0; sprintf(app_path, "%ls", (const wchar_t*) appName.GetPointer()); sprintf(node_path, "%ls%s", resPath.GetPointer(), NODE_EXECUTABLE); sprintf(js_path, "%ls%s", resPath.GetPointer(), JS_SCRIPT); argv2[0] = strdup(app_path); argv2[1] = strdup(js_path); isRunningThread = true; ret = cantata_main(2, argv2); if (app_path != NULL) { free(app_path); } if (app_path != NULL) { free(js_path); } #if 0 /* handle = dlopen(node_path, RTLD_LAZY); if (handle == NULL) { AppLog("load error %s: %s\n", node_path, dlerror()); return null; } AppLog("Calling main func"); // TODO: how to stop node thread? call_nodejs = (void (*)(int, char**))dlsym(handle, "cantata_main"); if((error = dlerror()) != NULL) { AppLog("dlsym error %s: %s\n", node_path, error); dlclose(handle); return null; } AppLog("Calling node"); call_nodejs(2, argv2); dlclose(handle); */ #endif return null; }
void LoginForm::loginPlayerFinished(Tizen::Base::String statusCode) { AppLogDebug("STAUS : %S",statusCode.GetPointer()); MessageBox msgBox; int modalResult; SceneManager* pSceneManager = SceneManager::GetInstance(); AppAssert(pSceneManager); ArrayList* pList = new (std::nothrow)ArrayList; AppAssert(pList); pList->Construct(); if(statusCode != "0") // (로그인 성공 시) 로그인, 개인페이지로 이동 { String playerKey = statusCode; pList->Add( new Tizen::Base::String(playerKey) ); // playerId pSceneManager->GoForward(ForwardSceneTransition(SCENE_PLAYER, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_HISTORY_OPTION_NO_HISTORY), pList); } else // (로그인 실패 시) 로그인 실패 팝업 { msgBox.Construct(L"Login", L"LOGIN fail", MSGBOX_STYLE_OK); msgBox.ShowAndWait(modalResult); } }
void CropForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, const Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pResultList) { if (appId.Equals(L"tizen.filemanager", true) && operationId.Equals(L"http://tizen.org/appcontrol/operation/pick", true)) { AppCtrlResult selectResult = appControlResult; if (selectResult == APP_CTRL_RESULT_SUCCEEDED) { //Get the file name result r ; String filename; String* pFilePath ; pFilePath = (String*)(Tizen::Base::String*)pResultList->GetValue(String(L"path")); LoadImage(pFilePath); } else { result r; Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame(); Form *pForm = (Form*)pFrame->GetControl(MAIN_FORM_NAME, false); if(pForm) { r = pFrame->SetCurrentForm(*pForm); pForm->Draw(); pForm->Show(); pFrame->RemoveControl(*this); } } } }
bool LocationMapForm::OnLoadingRequested(const Tizen::Base::String& url, WebNavigationType type) { AppLog("%S",url.GetPointer()); SetUrl(url); return false; }
void UsersPanel::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index) { AppLog("OnFastScrollIndexSelected %ls", index.GetPointer()); String upperLetter; index.ToUpper(upperLetter); AppLog("Upper letter %ls", index.GetPointer()); Integer * pos = static_cast<Integer *>(_pLetterNav->GetValue(upperLetter)); if (pos != null) { int item = pos->ToInt(); AppLog("Found at %d.", item); _pTableView->ScrollToItem(item, -1); Invalidate(true); } else { AppLog("Pointer is null..."); } }
result UserGroup::Construct(const Tizen::Base::String & groupName, const JsonArray * usersArray) { result r = E_SUCCESS; AppLog("Adding %d items to array, named %ls", usersArray->GetCount(), groupName.GetPointer()); _pGroupName = new String(groupName); delete _pUserList; _pUserList = usersArray->CloneN(); // _pUserList->AddItems(*usersArray); return r; }
string FileUtilsTizen::getWritablePath() { UiApp* pApp = UiApp::GetInstance(); if (!pApp) { return null; } string path(""); AsciiEncoding ascii; Tizen::Base::String dataPath = pApp->GetAppDataPath(); if (!dataPath.IsEmpty()) { ByteBuffer* buffer = ascii.GetBytesN(dataPath); path.append((const char*)buffer->GetPointer()); delete buffer; } return path; }
bool FileUtilsTizen::init() { UiApp* pApp = UiApp::GetInstance(); if (!pApp) { return false; } Tizen::Base::String resPath = pApp->GetAppResourcePath(); if (resPath.IsEmpty()) { return false; } AsciiEncoding ascii; ByteBuffer* buffer = ascii.GetBytesN(resPath); _defaultResRootPath = (const char *)buffer->GetPointer(); delete buffer; return FileUtils::init(); }
int BookMarkManager::AddCategory(Tizen::Base::String const & sName) const { if (!sName.IsEmpty()) { Framework * pFW = GetFramework(); int i = pFW->AddCategory(FromTizenString(sName)); pFW->GetBmCategory(i)->SaveToKMLFile(); return i; } return -1; }
void GHPlayerListItemEventListener::OnListViewItemStateChanged (Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) { if (status == Tizen::Ui::Controls::LIST_ITEM_STATUS_SELECTED) { if(index < list.GetCount()) { Tizen::Base::String playerId = ((GHPlayer*)(list.GetAt(index)))->getId(); Tizen::Base::Collection::ArrayList* pList = new (std::nothrow)Tizen::Base::Collection::ArrayList; AppAssert(pList); pList->Construct(); pList->Add( playerId ); // playerId // Scene 이동 SceneManager* pSceneManager = SceneManager::GetInstance(); SceneId sceneId = (playerId.Equals(GHSharedAuthData::getSharedInstance().getPlayerId()) ? SCENE_PLAYER : SCENE_PLAYERFRIEND); pSceneManager->GoForward(ForwardSceneTransition(sceneId, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList); } } }
void LocationMapForm::SetUrl(const Tizen::Base::String& url) { result r = E_SUCCESS; if (url.GetLength() ) { TryReturnVoid(r == E_SUCCESS, "Fail to update URL in the EditField."); this->RequestRedraw (true); } else { AppLog("The length of the URL exceeds the limit of the length of text in this EditField."); } }
result RoundedAvatar::Construct(const Tizen::Graphics::Rectangle & rect, const Tizen::Base::String &avatarPath) { result r = E_SUCCESS; imageUrl = avatarPath; AppLog("construct rounded avatar based on url: %ls", avatarPath.GetPointer()); Panel::Construct(rect, GROUP_STYLE_NONE); if (imageUrl.GetLength() != 0) { Bitmap *bitmap = VKUApp::GetInstance()->GetBitmapCache()->TakeBitmap(imageUrl, this); if(bitmap != null) { pAvatar = bitmap; } } return r; }
string FromTizenString(Tizen::Base::String const & str_tizen) { string utf8Str; if (str_tizen.GetLength() == 0) return utf8Str; Tizen::Base::ByteBuffer * pBuffer = Tizen::Base::Utility::StringUtil::StringToUtf8N(str_tizen); if (pBuffer) { int byteCount = pBuffer->GetLimit() - 1; // Don't copy Zero at the end if (byteCount > 0) { vector<char> chBuf(byteCount); pBuffer->GetArray((byte *)&chBuf[0], 0, byteCount); utf8Str.assign(chBuf.begin(), chBuf.end()); } delete pBuffer; } return utf8Str; }
void GHPlayerController::OnTransactionReadyToRead(Tizen::Base::String apiCode, Tizen::Base::String statusCode, Tizen::Web::Json::IJsonValue* data) { AppLogDebug("[DEBUG] apiCode : %S", apiCode.GetPointer() ); AppLogDebug("[DEBUG] statusCode : %S", statusCode.GetPointer()); if(pProgressPopup->IsVisible()) { pProgressPopup->SetShowState(false); } if(apiCode.Equals(PLAYER_LOGIN)) { // 정상적으로 결과를 반환했을 때 if(statusCode != "0") { // Save AppRegistry Data(Email, Password)---------- appReg.put(appReg.email, playerEmail); appReg.put(appReg.pwd, playerPwd); //------------------------------------------------ GHSharedAuthData & sharedInstance = GHSharedAuthData::getSharedInstance(); sharedInstance.setPlayerId(statusCode); if(this->currentListener != null) this->currentListener->loginPlayerFinished(statusCode); } else { // 에러가 발생했을 때 } } else if(apiCode.Equals(PLAYER_PLAYERDATA)) { // PLAYER_PLAYERDATA GHPlayer *player; // 정상적으로 결과를 반환했을 때 if(statusCode == "1") { JsonObject *pJsonOject = static_cast<JsonObject*>(data); AppLogDebug("---------------------------2-----------------------"); String* pkeyId = new String(L"player_id"); String* pkeyEmail = new String(L"email"); String* pkeyName = new String(L"name"); String* pkeyImgUrl = new String(L"img_url"); String* pkeyIsFriend= new String(L"is_friend"); String sId = getStringByKey(pJsonOject, pkeyId); String sEmail = getStringByKey(pJsonOject, pkeyEmail); String sName = getStringByKey(pJsonOject, pkeyName); String sImgUrl = getStringByKey(pJsonOject, pkeyImgUrl); bool bIsFriend = getBoolByKey(pJsonOject, pkeyIsFriend); AppLogDebug("--------------------------------------------------"); player = new GHPlayer(sId, sEmail, sName, sImgUrl); player->setIsFriend(bIsFriend); // KEY NAME DELETE delete pkeyId; delete pkeyEmail; delete pkeyName; delete pkeyImgUrl; delete pkeyIsFriend; } else { // 에러가 발생했을 때 player = null; } if(this->currentListener != null) this->currentListener->loadPlayerDataFinished(player); } else if(apiCode.Equals(PLAYER_GAMELIST)) { ArrayList *gameList; // 정상적으로 결과를 반환했을 때 if(statusCode == "1") { JsonArray* pJsonArray = static_cast<JsonArray*>(data); int arrNum = pJsonArray->GetCount(); gameList = new ArrayList(); // KEY NAME String* pKeyGameId = new String(L"game_id"); String* pKeyGameTitle = new String(L"title"); String* pkeyGameImgUrl = new String(L"img_url"); String* pKeyGameDesc = new String(L"description"); AppLogDebug("[DEBUG] arrNum : %d", arrNum ); for(int i=0; i<arrNum; i++) { JsonObject *pJsonOject = getJsonObjectByIndex(pJsonArray, i); // 데이터 파싱 String sGameId = getStringByKey(pJsonOject, pKeyGameId); String sGameTitle = getStringByKey(pJsonOject, pKeyGameTitle); String sGameImgUrl = getStringByKey(pJsonOject, pkeyGameImgUrl); String sGameDesc = getStringByKey(pJsonOject, pKeyGameDesc); // 리스트에 추가 gameList->Add( new GHGame(sGameId, "", sGameTitle, sGameDesc, sGameImgUrl, 0, 0, 0, false, false) ); } // KEY NAME DELETE delete pKeyGameId; delete pKeyGameTitle; delete pkeyGameImgUrl; } else { // 에러가 발생했을 때 gameList = null; } if(this->currentListener != null) this->currentListener->loadPlayerGamesFinished(gameList); } else if(apiCode.Equals(PLAYER_SEARCHFRIEND)) { ArrayList *friendList; if(statusCode == "1") { JsonObject *pJsonOject = static_cast<JsonObject*>(data); friendList = new ArrayList(); // KEY NAME String* pKeyPlayerId = new String(L"player_id"); String* pKeyPlayerEmail = new String(L"email"); String* pkeyPlayerName = new String(L"name"); String* pkeyPlayerImgUrl= new String(L"img_url"); // 데이터 파싱 String sPlayerId = getStringByKey(pJsonOject, pKeyPlayerId); String sPlayerEmail = getStringByKey(pJsonOject, pKeyPlayerEmail); String sPlayerName = getStringByKey(pJsonOject, pkeyPlayerName); String sPlayerImgUrl = getStringByKey(pJsonOject, pkeyPlayerImgUrl); // 리스트에 추가 friendList->Add( new GHPlayer(sPlayerId, sPlayerEmail, sPlayerName, sPlayerImgUrl) ); // KEY NAME DELETE delete pKeyPlayerId; delete pKeyPlayerEmail; delete pkeyPlayerName; delete pkeyPlayerImgUrl; } else { // 에러가 발생했을 때 friendList = null; } if(this->currentListener != null) this->currentListener->searchFriendFinished(friendList); } else if(apiCode.Equals(PLAYER_ADDFRIEND)) { if(this->currentListener != null) this->currentListener->addFriendFinished(statusCode); } else if(apiCode.Equals(PLAYER_LOADFRIENDS)) // 친구 목록 불러오기 { ArrayList *friendList; if(statusCode == "1") { JsonArray* pJsonArray = static_cast<JsonArray*>(data); int arrNum = pJsonArray->GetCount(); friendList = new ArrayList(); // KEY NAME String* pKeyPlayer = new String(L"player_id"); String* pKeyPlayerName = new String(L"name"); String* pkeyPlayerImgUrl= new String(L"img_url"); AppLogDebug("[DEBUG] arrNum : %d", arrNum ); for(int i=0; i<arrNum; i++) { JsonObject *pJsonOject = getJsonObjectByIndex(pJsonArray, i); // 데이터 파싱 String sPlayerId = getStringByKey(pJsonOject, pKeyPlayer); String sPlayerName = getStringByKey(pJsonOject, pKeyPlayerName); String sPlayerImgUrl = getStringByKey(pJsonOject, pkeyPlayerImgUrl); // 리스트에 추가 friendList->Add( new GHPlayer(sPlayerId, sPlayerName, sPlayerImgUrl) ); } // KEY NAME DELETE delete pKeyPlayer; delete pKeyPlayerName; delete pkeyPlayerImgUrl; } else { // 에러가 발생했을 때 friendList = null; } if(this->currentListener != null) this->currentListener->loadPlayerFriendsFinished(friendList); } else //PLAYER_LOGIN ,PLAYER_GAMEJOIN { // if(this->currentListener != null) this->currentListener->doPlayerFinished(statusCode); } }
void RoundedAvatar::SetUrl(const Tizen::Base::String & str) { imageUrl = str; if (str.GetLength() != 0) VKUApp::GetInstance()->GetBitmapCache()->TakeBitmap(imageUrl, this); }
void PartnerListForm::OnFastScrollIndexSelected(Control& source, Tizen::Base::String& index) { if( !index.CompareTo(L"A" )) { if(ITEM_COUNT[0]>0) { __pList->ScrollToItem(Group_Scroll[0], -1); } } else if( !index.CompareTo(L"B")) { if(ITEM_COUNT[1]>0) { __pList->ScrollToItem(Group_Scroll[1], -1); } } else if( !index.CompareTo(L"C")) { if(ITEM_COUNT[2]>0) { __pList->ScrollToItem(Group_Scroll[2], -1); } } else if( !index.CompareTo(L"D")) { if(ITEM_COUNT[3]>0) { __pList->ScrollToItem(Group_Scroll[3], -1); } } else if( !index.CompareTo(L"E")) { if(ITEM_COUNT[4]>0) { __pList->ScrollToItem(Group_Scroll[4], -1); } } else if( !index.CompareTo(L"F")) { if(ITEM_COUNT[5]>0) { __pList->ScrollToItem(Group_Scroll[5], -1); } } else if( !index.CompareTo(L"G")) { if(ITEM_COUNT[6]>0) { __pList->ScrollToItem(Group_Scroll[6], -1); } } else if( !index.CompareTo(L"H")) { if(ITEM_COUNT[7]>0) { __pList->ScrollToItem(Group_Scroll[7], -1); } } else if( !index.CompareTo(L"I")) { if(ITEM_COUNT[8]>0) { __pList->ScrollToItem(Group_Scroll[8], -1); } } else if( !index.CompareTo(L"J")) { if(ITEM_COUNT[9]>0) { __pList->ScrollToItem(Group_Scroll[9], -1); } } else if( !index.CompareTo(L"K")) { if(ITEM_COUNT[10]>0) { __pList->ScrollToItem(Group_Scroll[10], -1); } } else if( !index.CompareTo(L"L")) { if(ITEM_COUNT[11]>0) { __pList->ScrollToItem(Group_Scroll[11], -1); } } else if( !index.CompareTo(L"M")) { if(ITEM_COUNT[12]>0) { __pList->ScrollToItem(Group_Scroll[12], -1); } } else if( !index.CompareTo(L"N")) { if(ITEM_COUNT[13]>0) { __pList->ScrollToItem(Group_Scroll[13], -1); } } else if( !index.CompareTo(L"O")) { if(ITEM_COUNT[14]>0) { __pList->ScrollToItem(Group_Scroll[14], -1); } } else if( !index.CompareTo(L"P")) { if(ITEM_COUNT[15]>0) { __pList->ScrollToItem(Group_Scroll[15], -1); } } else if( !index.CompareTo(L"Q")) { if(ITEM_COUNT[16]>0) { __pList->ScrollToItem(Group_Scroll[16], -1); } } else if( !index.CompareTo(L"R")) { if(ITEM_COUNT[17]>0) { __pList->ScrollToItem(Group_Scroll[17], -1); } } else if( !index.CompareTo(L"S")) { if(ITEM_COUNT[18]>0) { __pList->ScrollToItem(Group_Scroll[18], -1); } } else if( !index.CompareTo(L"T")) { if(ITEM_COUNT[19]>0) { __pList->ScrollToItem(Group_Scroll[19], -1); } } else if( !index.CompareTo(L"U")) { if(ITEM_COUNT[20]>0) { __pList->ScrollToItem(Group_Scroll[20], -1); } } else if( !index.CompareTo(L"V")) { if(ITEM_COUNT[21]>0) { __pList->ScrollToItem(Group_Scroll[21], -1); } } else if( !index.CompareTo(L"W")) { if(ITEM_COUNT[22]>0) { __pList->ScrollToItem(Group_Scroll[22], -1); } } else if( !index.CompareTo(L"X")) { if(ITEM_COUNT[23]>0) { __pList->ScrollToItem(Group_Scroll[23], -1); } } else if( !index.CompareTo(L"Y")) { if(ITEM_COUNT[24]>0) { __pList->ScrollToItem(Group_Scroll[24], -1); } } else if( !index.CompareTo(L"Z")) { if(ITEM_COUNT[25]>0) { __pList->ScrollToItem(Group_Scroll[25], -1); } } Invalidate(true); }
void ProfileListForm::SaveUsingmodeProfile(Tizen::Base::String title, int year, int month, int day, int hour, int minute, int year2, int month2, int day2, int hour2, int minute2, double latitude, double longitude, int volume, int wifi, Tizen::Base::String memo) { AppLog("%s, %s", title.GetPointer(), memo.GetPointer()); DbStatement* pStmt; DbEnumerator* pEnum; long long id; Tizen::System::SystemTime::GetTicks(id); __pProfileDatabase->BeginTransaction(); if (__isUpdateMode) { pStmt = __pProfileDatabase->CreateStatementN(L"UPDATE profile SET title = ?, " "year = ?, month = ?, day = ?, hour = ?, minute = ?, " "year2 = ?, month2 = ?, day2 = ?, hour2 = ?, minute2 = ?, " "latitude = ?, longitude = ?, volume = ?, wifi = ?, memo = ? WHERE id = ?"); pStmt->BindString(0, title); pStmt->BindInt(1, year); pStmt->BindInt(2, month); pStmt->BindInt(3, day); pStmt->BindInt(4, hour); pStmt->BindInt(5, minute); pStmt->BindInt(6, year); pStmt->BindInt(7, month); pStmt->BindInt(8, day); pStmt->BindInt(9, hour); pStmt->BindInt(10, minute); pStmt->BindDouble(11, latitude); pStmt->BindDouble(12, longitude); pStmt->BindInt(13, volume); pStmt->BindInt(14, wifi); pStmt->BindString(15, memo); Integer* itemId = static_cast<Integer*>(__pIndexList.GetAt(__currentIndex)); pStmt->BindInt(16, itemId->ToInt()); __isUpdateMode = false; } else { AppLog("Normal Save"); pStmt = __pProfileDatabase->CreateStatementN(L"INSERT INTO profile (id, title, " "year, month, day, hour, minute, " "year2, month2, day2, hour2, minute2, " "latitude, longitude, volume, wifi, memo) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); pStmt->BindInt(0, id); pStmt->BindString(1, title); pStmt->BindInt(2, year); pStmt->BindInt(3, month); pStmt->BindInt(4, day); pStmt->BindInt(5, hour); pStmt->BindInt(6, minute); pStmt->BindInt(7, year2); pStmt->BindInt(8, month2); pStmt->BindInt(9, day2); pStmt->BindInt(10, hour2); pStmt->BindInt(11, minute2); pStmt->BindDouble(12, latitude); pStmt->BindDouble(13, longitude); pStmt->BindInt(14, volume); pStmt->BindInt(15, wifi); pStmt->BindString(16, memo); } pEnum = __pProfileDatabase->ExecuteStatementN(*pStmt); __pProfileDatabase->CommitTransaction(); delete pStmt; delete pEnum; ListUpdate(); }