void Network::Run(const String& command) { if (!command.IsEmpty()) { String args; String delim(L"/"); command.SubString(String(L"gap://").GetLength(), args); StringTokenizer strTok(args, delim); if(strTok.GetTokenCount() < 3) { AppLogDebug("Not enough params"); return; } String method; String hostAddr; strTok.GetNextToken(method); strTok.GetNextToken(callbackId); strTok.GetNextToken(hostAddr); // URL decoding Uri uri; uri.SetUri(hostAddr); AppLogDebug("Method %S, callbackId %S, hostAddr %S URI %S", method.GetPointer(), callbackId.GetPointer(), hostAddr.GetPointer(), uri.ToString().GetPointer()); if(method == L"org.apache.cordova.Network.isReachable") { IsReachable(uri.ToString()); } AppLogDebug("Network command %S completed", command.GetPointer()); } else { AppLogDebug("Can't run empty command"); } }
void GeoLocation::Run(const String& command) { if(!command.IsEmpty()) { Uri commandUri; commandUri.SetUri(command); String method = commandUri.GetHost(); StringTokenizer strTok(commandUri.GetPath(), L"/"); if(strTok.GetTokenCount() > 1) { strTok.GetNextToken(callbackId); AppLogDebug("Method %S, CallbackId: %S", method.GetPointer(), callbackId.GetPointer()); } AppLogDebug("Method %S, Callback: %S", method.GetPointer(), callbackId.GetPointer()); // used to determine callback ID if(method == L"com.phonegap.Geolocation.watchPosition" && !callbackId.IsEmpty() && !IsWatching()) { AppLogDebug("watching position..."); StartWatching(); } if(method == L"com.phonegap.Geolocation.stop" && IsWatching()) { AppLogDebug("stop watching position..."); StopWatching(); } if(method == L"com.phonegap.Geolocation.getCurrentPosition" && !callbackId.IsEmpty() && !IsWatching()) { AppLogDebug("getting current position..."); GetLastKnownLocation(); } AppLogDebug("GeoLocation command %S completed", command.GetPointer()); } }
void Form2::SaveConfig() { Config *cfg = (Config *) pCfg; String s; s = pHostname->GetText(); wcstombs(cfg->host, s.GetPointer(), sizeof(cfg->host)); s = pPortnumber->GetText(); Integer::Parse(s, cfg->port); if (cfg->port <= 0 || cfg->port > 65535) cfg->port = 22; s = pUsername->GetText(); wcstombs(cfg->username, s.GetPointer(), sizeof(cfg->username)); s = pPublickey->GetText(); wcstombs(cfg->keyfile.path, s.GetPointer(), sizeof(cfg->keyfile.path)); cfg->font.height = pFontsize->GetValue(); save_settings("lite", cfg); init_fonts(0, cfg->font.height); term_size(term, screen_height/font_height, screen_width/font_width, cfg->savelines); }
void ProjectGiraffeTab4::OnAppControlCompleteResponseReceived(const AppId &appId, const String &operationId, AppCtrlResult appControlResult, const IMap *extraData) { AppLogTag("camera1", "appid %ls opid %ls", appId.GetPointer(), operationId.GetPointer()); if (appId.Equals(L"tizen.filemanager", true) && operationId.Equals(L"http://tizen.org/appcontrol/operation/pick", true)) { if (appControlResult == APP_CTRL_RESULT_SUCCEEDED) { AppLogTag("camera1", "Media list success."); String pathKey = L"path"; String *filePath = (String *)extraData->GetValue(pathKey); AppLogTag("camera1", "filepath: %ls", filePath->GetPointer()); HttpMultipartEntity* userParameters = new HttpMultipartEntity(); userParameters->Construct(); userParameters->AddFilePart(L"avatar", *filePath); HttpConnection *connection = HttpConnection::userUpdatePutConnection(this, userParameters); connection->begin(); // TODO: figure out when to free // delete userParameters; } else if (appControlResult == APP_CTRL_RESULT_CANCELED) { AppLogTag("camera1", "Media list canceled."); } else if (appControlResult == APP_CTRL_RESULT_FAILED) { AppLogTag("camera1", "Media list failed."); } } else if (appId.Equals(L"tizen.camera", true) && operationId.Equals(L"http://tizen.org/appcontrol/operation/createcontent", true)) { AppLogTag("camera1", "camcam"); if (appControlResult == APP_CTRL_RESULT_SUCCEEDED) { AppLogTag("camera1", "Camera capture success."); String pathKey = L"path"; String *filePath = (String *)extraData->GetValue(pathKey); AppLogTag("camera1", "filepath: %ls", filePath->GetPointer()); HttpMultipartEntity* userParameters = new HttpMultipartEntity(); userParameters->Construct(); userParameters->AddFilePart(L"avatar", *filePath); HttpConnection *connection = HttpConnection::userUpdatePutConnection(this, userParameters); connection->begin(); // TODO: figure out when to free // delete userParameters; } else if (appControlResult == APP_CTRL_RESULT_CANCELED) { AppLogTag("camera1", "Camera capture canceled."); } else if (appControlResult == APP_CTRL_RESULT_FAILED) { AppLogTag("camera1", "Camera capture failed."); } else if (appControlResult == APP_CTRL_RESULT_TERMINATED) { AppLogTag("camera1", "Camera capture terminated."); } else if (appControlResult == APP_CTRL_RESULT_ABORTED) { AppLogTag("camera1", "Camera capture aborted."); } } }
void Compass::Run(const String& command) { if (!command.IsEmpty()) { String args; String delim(L"/"); command.SubString(String(L"gap://").GetLength(), args); StringTokenizer strTok(args, delim); if(strTok.GetTokenCount() < 2) { AppLogDebug("Not Enough Params"); return; } String method; strTok.GetNextToken(method); // Getting callbackId strTok.GetNextToken(callbackId); AppLogDebug("Method %S, callbackId: %S", method.GetPointer(), callbackId.GetPointer()); // used to determine callback ID if(method == L"com.phonegap.Compass.watchHeading" && !callbackId.IsEmpty() && !IsStarted()) { AppLogDebug("watching compass..."); StartSensor(); } if(method == L"com.phonegap.Compass.clearWatch" && !callbackId.IsEmpty() && IsStarted()) { AppLogDebug("stop watching compass..."); StopSensor(); } if(method == L"com.phonegap.Compass.getCurrentHeading" && !callbackId.IsEmpty() && !IsStarted()) { AppLogDebug("getting current compass..."); GetLastHeading(); } AppLogDebug("Compass command %S completed", command.GetPointer()); } else { AppLogDebug("Can't run empty command"); } }
void Accelerometer::Run(const String& command) { if (!command.IsEmpty()) { Uri commandUri; commandUri.SetUri(command); String method = commandUri.GetHost(); StringTokenizer strTok(commandUri.GetPath(), L"/"); if(strTok.GetTokenCount() == 1) { strTok.GetNextToken(callbackId); AppLogDebug("Method %S, CallbackId: %S", method.GetPointer(), callbackId.GetPointer()); } if(method == L"com.cordova.Accelerometer.watchAcceleration" && !callbackId.IsEmpty() && !IsStarted()) { StartSensor(); } if(method == L"com.cordova.Accelerometer.clearWatch" && IsStarted()) { StopSensor(); } if(method == L"com.cordova.Accelerometer.getCurrentAcceleration" && !callbackId.IsEmpty() && !IsStarted()) { GetLastAcceleration(); } AppLogDebug("Acceleration command %S completed", command.GetPointer()); } else { AppLogDebug("Can't run empty command"); } }
void RemoveSubscriber(Control *control) { result r; r = _subscribers.Remove(*control); if(r != E_SUCCESS) { AppLog("BITMAPCACHE WARNING: %ls unsubscribe unsubscribed!!!!!!!!!!!!!!", _url.GetPointer()); } if(_state == CACHE_ENTRY_STATE_MEMORY && _subscribers.GetCount() == 0) { AppLog("BITMAPCACHE: free memory %ls", _url.GetPointer()); delete _bitmap; _state = CACHE_ENTRY_STATE_FILE; } }
void Kamera::OnAppControlCompleted (const String &appControlId, const String &operationId, const IList *pResultList) { //This method is invoked when an application control callback event occurs. String* pCaptureResult = null; if (appControlId.Equals(APPCONTROL_CAMERA) && operationId.Equals(OPERATION_CAPTURE)) { pCaptureResult = (Osp::Base::String*)pResultList->GetAt(0); if (pCaptureResult->Equals(String(APPCONTROL_RESULT_SUCCEEDED))) { String eval; AppLog("Camera capture success."); String* pCapturePath = (String*)pResultList->GetAt(1); // copying to app Home Folder String homeFilename; homeFilename.Format(128, L"/Home/%S", File::GetFileName(*pCapturePath).GetPointer()); result r = File::Copy(*pCapturePath, homeFilename, true); if(IsFailed(r)) { AppLogException("Could not copy picture"); eval.Format(512, L"PhoneGap.callbacks['%S'].fail('Could not copy picture')", callbackId.GetPointer()); AppLogDebug("%S", eval.GetPointer()); pWeb->EvaluateJavascriptN(eval); } // Uri imageUri; // imageUri.setUri(homeFilename); eval.Clear(); eval.Format(512, L"PhoneGap.callbacks['%S'].success('file://%S')", callbackId.GetPointer(), homeFilename.GetPointer()); AppLogDebug("%S", eval.GetPointer()); pWeb->EvaluateJavascriptN(eval); } else if (pCaptureResult->Equals(String(APPCONTROL_RESULT_CANCELED))) { AppLog("Camera capture canceled."); String eval; eval.Format(512, L"PhoneGap.callbacks['%S'].fail('Camera capture canceled')", callbackId.GetPointer()); pWeb->EvaluateJavascriptN(eval); } else if (pCaptureResult->Equals(String(APPCONTROL_RESULT_FAILED))) { AppLog("Camera capture failed."); String eval; eval.Format(512, L"PhoneGap.callbacks['%S'].fail('Camera capture failed')", callbackId.GetPointer()); pWeb->EvaluateJavascriptN(eval); } } }
String TimeAndPlace::GetReadableTime(void) { LocaleManager localeManager; localeManager.Construct(); Locale locale = localeManager.GetSystemLocale(); TimeZone timeZone = localeManager.GetSystemTimeZone(); AppLog("GMT Time Zone id is %S", timeZone.GetGmtTimeZone().GetId().GetPointer()); AppLog("Time Zone is %S", timeZone.GetId().GetPointer()); AppLog("Time Zone offset is %d", timeZone.GetRawOffset()); AppLog("Time Zone DST is %d", timeZone.GetDstSavings()); String customizedPattern = L"HH:mm:ss"; String readableDateTime; DateTimeFormatter* formatter = DateTimeFormatter::CreateDateFormatterN(); formatter -> ApplyPattern(customizedPattern); DateTime standardOffsetDateTime = timeZone.UtcTimeToStandardTime(*dateTime, timeZone.GetRawOffset()); formatter -> Format(standardOffsetDateTime, readableDateTime); AppLog("Standard Local Time is %S", readableDateTime.GetPointer()); readableDateTime.Append("\n"); readableDateTime.Append(timeZone.GetId()); return readableDateTime; }
bool SimpleCache::GetFileForIndex(int index, ByteBuffer & data) { String filePath; BuildPathForFileInCache(index, filePath); if (!File::IsFileExist(filePath)) { return false; } AppLog("Reading data from cached file at %S", filePath.GetPointer()); File cachedFile; cachedFile.Construct(filePath, L"r+"); if (IsFailed(GetLastResult())) { AppLog("Error opening destination file in cache"); return false; } FileAttributes fAttributes; File::GetAttributes(filePath, fAttributes); data.Construct(fAttributes.GetFileSize()); cachedFile.Read(data); AppLog("Read cache: %d bytes", data.GetCapacity()); if (IsFailed(GetLastResult())) { AppLog("Error reading from cached file"); return false; } return true; }
void LocationMapForm::HandleJavaScriptRequestN (Tizen::Web::Json::IJsonValue *pArg) { AppLog("PathFinder:: HandleJavaScriptRequestN"); result r = E_SUCCESS; JsonObject* pJsonObject = static_cast< JsonObject* >(pArg); IJsonValue* pValue = null; JsonString* pJsonStringValue = null; String key(L"data"); r = pJsonObject->GetValue(&key, pValue); pJsonStringValue = static_cast< JsonString* >(pValue); const wchar_t* mapPointString = pJsonStringValue->GetPointer(); AppLog("data: %ls\n", mapPointString); String *tmpString = new String(mapPointString); Float x , y; int idx = 0; tmpString->IndexOf(' ' , 0 , idx); String *tmpString2 = new String ( mapPointString + idx + 1 ); const wchar_t* tmpChar = tmpString->GetPointer(); wchar_t* tmpChar3 = const_cast<wchar_t*>(tmpChar); tmpChar3[idx] = '\0'; const wchar_t* tmpChar2 = tmpString2->GetPointer(); x.Parse(tmpChar3 , this->__latitude ); y.Parse(tmpChar2 , this->__longitude ); }
result VKUMessagesListItemProvider::ProcessChatUsers(const JsonObject * chatJson) { AppLog("VKUMessagesListItemProvider::ProcessChatUsers"); result r = E_SUCCESS; JsonArray *chatUsers; JsonParseUtils::GetArray(chatJson, L"users", chatUsers); _pUserIdAvatarMap = new HashMap(SingleObjectDeleter); _pUserIdAvatarMap->Construct(chatUsers->GetCount(), 1); for (int i=0; i<chatUsers->GetCount(); i++) { JsonObject *userJson; JsonParseUtils::GetObject(chatUsers, i, userJson); int userId; String avatarUrl; JsonParseUtils::GetInteger(*userJson, L"id", userId); JsonParseUtils::GetString(*userJson, L"photo_100", avatarUrl); AppLog("Adding avatar for %d : %ls", userId, avatarUrl.GetPointer()); _pUserIdAvatarMap->Add(new Integer(userId), new String(avatarUrl)); } return r; }
bool ShoppingListMainForm::Initialize(void) { result r = E_SUCCESS; pDb = new DbAccess(); r = pDb->Construct(); if (IsFailed(r)) { AppLogDebug("ERROR: cannot construct DbAccess! [%s]", GetErrorMessage(r)); return r; } String strDbName = "lists.sqlite"; r = pDb->Connect(strDbName); if (IsFailed(r)) { AppLogDebug("ERROR: cannot connect %S! [%s]", strDbName.GetPointer(), GetErrorMessage(r)); return r; } r = Construct(IDL_FORM); TryReturn(r == E_SUCCESS, false, "Failed to construct form"); return true; }
void Notification::Run(const String& command) { if(!command.IsEmpty()) { Uri commandUri; commandUri.SetUri(command); String method = commandUri.GetHost(); StringTokenizer strTok(commandUri.GetPath(), L"/"); if(strTok.GetTokenCount() < 1) { AppLogException("Not enough params"); return; } if((method == L"com.phonegap.Notification.alert" || method == L"com.phonegap.Notification.confirm")) { strTok.GetNextToken(callbackId); AppLogDebug("%S %S", method.GetPointer(), callbackId.GetPointer()); if(!callbackId.IsEmpty()) { Dialog(); } } else if(method == L"com.phonegap.Notification.vibrate") { long duration; String durationStr; strTok.GetNextToken(durationStr); AppLogDebug("%S %S", method.GetPointer(), durationStr.GetPointer()); // Parsing duration result r = Long::Parse(durationStr, duration); if(IsFailed(r)) { AppLogException("Could not parse duration"); return; } Vibrate(duration); } else if(method == L"com.phonegap.Notification.beep") { int count; String countStr; strTok.GetNextToken(countStr); AppLogDebug("%S %S", method.GetPointer(), countStr.GetPointer()); // Parsing count result r = Integer::Parse(countStr, count); if(IsFailed(r)) { AppLogException("Could not parse count"); return; } Beep(count); } } }
DateTime* TimeAndPlace::GetStandardDateTime(void) { LocaleManager localeManager; localeManager.Construct(); Locale locale = localeManager.GetSystemLocale(); TimeZone timeZone = localeManager.GetSystemTimeZone(); AppLog("GMT Time Zone id is %S", timeZone.GetGmtTimeZone().GetId().GetPointer()); AppLog("Time Zone is %S", timeZone.GetId().GetPointer()); AppLog("Time Zone offset is %d", timeZone.GetRawOffset()); AppLog("Time Zone DST is %d", timeZone.GetDstSavings()); result r; String customizedPattern = L"HH:mm:ss zzz"; String readableDateTime; DateTimeFormatter* formatter = DateTimeFormatter::CreateDateFormatterN(); r = formatter -> ApplyPattern(customizedPattern); AppLog("formatter -> ApplyPattern(customizedPattern) result is %s", GetErrorMessage(r)); DateTime standardOffsetDateTime = timeZone.UtcTimeToStandardTime(*dateTime, timeZone.GetRawOffset()); r = formatter -> Format(standardOffsetDateTime, readableDateTime); AppLog("Standard Local Time is %S", readableDateTime.GetPointer()); readableDateTime.Clear(); DateTime standardDateTime = timeZone.UtcTimeToStandardTime(*dateTime); r = formatter -> Format(standardDateTime, readableDateTime); AppLog("Standard Time is %S", readableDateTime.GetPointer()); readableDateTime.Clear(); DateTime wallDateTime = timeZone.UtcTimeToWallTime(*dateTime); r = formatter -> Format(wallDateTime, readableDateTime); AppLog("Wall Time is %S", readableDateTime.GetPointer()); readableDateTime.Clear(); r = formatter -> Format(*dateTime, readableDateTime); AppLog("UTC Time is %S", readableDateTime.GetPointer()); readableDateTime.Clear(); // Calendar* calendar = Calendar::CreateInstanceN(timeZone, CALENDAR_GREGORIAN); // DateTime localTime1 = calendar -> GetTime(); // r = formatter -> Format(localTime1, readableDateTime); // AppLog("Local Time is %S", readableDateTime.GetPointer()); return localDateTime; }
void Network::OnTransactionAborted (HttpSession &httpSession, HttpTransaction &httpTransaction, result r) { AppLogDebug("Transaction Aborted"); String res; res.Format(128, L"Cordova.callbacks['%S'].fail({code:%d,message:'%s'});", callbackId.GetPointer(), r, GetErrorMessage(r)); AppLogDebug("%S", res.GetPointer()); pWeb->EvaluateJavascriptN(res); }
void Network::IsReachable(const String& hostAddr) { String* pProxyAddr = null; //String hostAddr = L"http://localhost:port"; AppLogDebug("Trying to reach...%S", hostAddr.GetPointer()); __pHttpSession = new HttpSession(); __pHttpSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr, hostAddr, null); HttpTransaction* pHttpTransaction = __pHttpSession->OpenTransactionN(); pHttpTransaction->AddHttpTransactionListener(*this); HttpRequest* pHttpRequest = pHttpTransaction->GetRequest(); pHttpRequest->SetMethod(NET_HTTP_METHOD_GET); pHttpRequest->SetUri(hostAddr); pHttpTransaction->Submit(); }
v8::Handle<v8::Value> Contacts::isExistCategory(const v8::Arguments& args) { AppLogTag("Contacts", "Entered Contacts::isExistCategory (args: length:%d)", args.Length()); if (args.Length() < 1 || Util::isArgumentNull(args[0])) { AppLog("Bad parameters"); return v8::ThrowException(v8::String::New("Bad parameters")); } String name = null; v8::HandleScope scope; if(args[0]->IsString()) { name = UNWRAP_STRING(args[0]).c_str(); AppLogTag("Contacts","check Category:%ls", name.GetPointer()); } if(name == null) { AppLogTag("Contacts","category name is null"); return scope.Close(v8::Boolean::New(false)); } AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance(); Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID); IList* pCategoryList = pAddressbook->GetAllCategoriesN(); result r = GetLastResult(); if (IsFailed(r)) { AppLog("Failed to get addressbook: %s", GetErrorMessage(r)); return scope.Close(v8::Boolean::New(false)); } if (pCategoryList != null && pCategoryList->GetCount() > 0) { IEnumerator* pCategoryEnum = pCategoryList->GetEnumeratorN(); Category* pCategory = null; while (pCategoryEnum->MoveNext() == E_SUCCESS) { pCategory = static_cast<Category*>(pCategoryEnum->GetCurrent()); if (pCategory->GetName().Equals(name)) { AppLog("It is existed category"); return scope.Close(v8::Boolean::New(true)); } } } AppLog("Non-exist category"); return scope.Close(v8::Boolean::New(false)); }
void Network::OnTransactionCompleted (HttpSession &httpSession, HttpTransaction &httpTransaction) { HttpResponse* pHttpResponse = httpTransaction.GetResponse(); NetHttpStatusCode statusCode = pHttpResponse->GetStatusCode(); int status = 1; // Default is DATA NETWORK // FIXME: Bada has no standard/apparent way of knowing the current network type // We have to get the network type from the system info // ...and if Wifi is enabled we override the setting to Wifi String key(L"NetworkType"); String networkType; result r = SystemInfo::GetValue(key, networkType); if(r == E_SUCCESS && networkType != L"NoService" && networkType != L"Emergency") { AppLogDebug("Data Enabled, Network Type %S, Status Code: %d", networkType.GetPointer(), statusCode); status = 1; } Wifi::WifiManager manager; if(manager.IsActivated() && manager.IsConnected()) { AppLogDebug("Wifi Enabled"); status = 2; } String res; res.Format(256, L"navigator.network.updateReachability({code:%d,http_code:%d});", status, statusCode); AppLogDebug("%S", res.GetPointer()); pWeb->EvaluateJavascriptN(res); res.Format(128, L"Cordova.callbacks['%S'].success({code:%d,http_code:%d});", callbackId.GetPointer(), status, statusCode); AppLogDebug("%S", res.GetPointer()); pWeb->EvaluateJavascriptN(res); }
void LocationForm::OnLocationUpdated(Osp::Locations::Location& location) { AppLog("Location Updated\n"); const QualifiedCoordinates* coordinates = location.GetQualifiedCoordinates(); // String str; if (coordinates != 0) { AppLog("Coordinates taken lon %f lat %f \n", coordinates->GetLongitude(), coordinates->GetLatitude()); __pActionAttemptLabel -> SetText("Coordinates taken"); __pActionAttemptLabel -> RequestRedraw(true); String locationStr; locationStr.Format(22, L"%S\n%S", (DegreeToGrad(coordinates->GetLatitude(), "N", "S")->GetPointer()), (DegreeToGrad(coordinates->GetLongitude(), "E", "W")->GetPointer())); __pGpsProviderStatusLabel->SetText(locationStr.GetPointer()); __pGpsProviderStatusLabel -> RequestRedraw(true); locProvider -> CancelLocationUpdates(); TimeAndPlace::SetSiderialTime(coordinates->GetLatitude(), coordinates->GetLongitude(), new DateTime()); AppLog("1"); //Osp::App::AppRegistry* appRegistry = Osp::App::AppRegistry::GetInstance(); - for 2.0 API only! Osp::App::AppRegistry* appRegistry = Osp::App::Application::GetInstance()->GetAppRegistry(); AppLog("2"); result r = E_SUCCESS; r = appRegistry -> Set("LAST_LONGITUDE", coordinates->GetLongitude()); if (r == E_KEY_NOT_FOUND) { appRegistry -> Add("LAST_LONGITUDE", coordinates->GetLongitude()); } r = appRegistry -> Set("LAST_LATITUDE", coordinates->GetLatitude()); if (r == E_KEY_NOT_FOUND) { appRegistry -> Add("LAST_LATITUDE", coordinates->GetLatitude()); } AppLog("3"); appRegistry -> Save(); AppLog("4"); Osp::App::Application::GetInstance() -> SendUserEvent(LOCATION_SET, null); AppLog("5"); } else if (attemptsCounter < maxAttempts){ attemptsCounter++; Osp::Base::String str("Attempt #"); str.Append(attemptsCounter); __pActionAttemptLabel -> SetText(str); __pActionAttemptLabel -> RequestRedraw(true); } else { attemptsCounter = 0; locProvider -> CancelLocationUpdates(); Osp::App::Application::GetInstance() -> SendUserEvent(LOCATION_FAILED, null); } }
void Game::Warp(const String& mapName, int x, int y) { Level* newLevel = new Level(this); if(!newLevel->Load(mapName.GetPointer())) { delete newLevel; return; } delete _level; _level = newLevel; _player->SetXY(x, y); _player->SetLevel(_level); _level->PlayBGM(); }
void UserProfileForm::OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool rs) { HttpResponse* pHttpResponse = httpTransaction.GetResponse(); if(pHttpResponse == null) return; HttpHeader* pHttpHeader = pHttpResponse->GetHeader(); if(pHttpHeader != null) { String* tempHeaderString = pHttpHeader->GetRawHeaderN(); AppLog("HeaderString=%ls\n",tempHeaderString->GetPointer()); } AppLog("OnTransactionHeaderCompleted\n"); }
result BitmapCache::Construct() { result r; String cacheDir; AppLog("constructor"); bitmapCache = new (std::nothrow) HashMap(SingleObjectDeleter); TryCatch(bitmapCache != null, r = E_FAILURE, "failed to allocate bitmap cache hashmap"); r = bitmapCache->Construct(); TryCatch(r == E_SUCCESS, , "Failed to construct hashMap"); cacheDir = VKUApp::GetInstance()->GetCacheDir(); AppLog("cache dir: %ls", cacheDir.GetPointer()); if(!File::IsFileExist(cacheDir)) { r = Directory::Create(cacheDir); TryCatch(r == E_SUCCESS, , "Failed to create cache dir"); }
result LoginForm::OnInitializing(void) { result r = E_SUCCESS; // TODO: Add your initialization code here // Setup back event listener SetFormBackEventListener(this); // Get a button via resource ID Button* pButtonLogin = static_cast< Button* >(GetControl(IDC_LOGIN_BUTTON_SIGN)); if (pButtonLogin != null) { pButtonLogin->SetActionId(IDA_BUTTON_LOGIN); pButtonLogin->AddActionEventListener(*this); } Button* pButtonJoin = static_cast< Button* >(GetControl(IDC_LOGIN_BUTTON_JOIN)); if (pButtonJoin != null) { pButtonJoin->SetActionId(IDA_BUTTON_JOIN); pButtonJoin->AddActionEventListener(*this); } pTextEmail = static_cast< EditField* >(GetControl(IDC_LOGIN_EDITTEXT_EMAIL)); pTextPw = static_cast< EditField* >(GetControl(IDC_LOGIN_EDITTEXT_PW)); // Get Player Info from AppRegistry ---------------------------- String strEmail; String strPw; appReg.get(appReg.email, strEmail); appReg.get(appReg.pwd, strPw); if(strEmail != NULL && strPw != NULL) { AppLogDebug("AppRegistry Name value1 [%S]", strEmail.GetPointer()); pTextEmail->SetText(strEmail); pTextPw->SetText(strPw); // doLogin(); } //------------------------------------------------------ return r; }
// 사용자 로그인 void GHPlayerController::playerLogin(GHPlayerLoggedinListener* listener) { String email; String pwd; appReg.get(appReg.email, email); appReg.get(appReg.pwd, pwd); if(email != NULL && pwd != NULL) { AppLogDebug("%S", email.GetPointer()); if(email != "") { playerLogin(email, pwd, listener); return ; } } getLoginPopup(listener); return ; }
void UserProfileForm::SendRequestGet(String requestUrl) { result r = E_SUCCESS; HttpRequest* pRequest = null; String hostAddr(L"https://graph.facebook.com"); if(__pSession == null) { __pSession = new HttpSession(); r = __pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null); if (IsFailed(r)) { AppLog("Fail to HttpSession::Construct. [%s]", GetErrorMessage(r)); return; } __pSession->SetAutoRedirectionEnabled(true); } __pTransaction = __pSession->OpenTransactionN(); if (__pTransaction) { result r = __pTransaction->AddHttpTransactionListener(*this); pRequest = __pTransaction->GetRequest(); if (pRequest) { pRequest->SetUri(requestUrl); pRequest->SetMethod(NET_HTTP_METHOD_GET); r = __pTransaction->Submit(); AppLog("RequestUrl is =%ls",requestUrl.GetPointer()); if(IsFailed(r)) { AppLog("Fail to HttpRequest::Submit. [%s]", GetErrorMessage(r)); } } else { delete __pTransaction; __pTransaction = null; } } }
BadaFileStream *BadaFileStream::makeFromPath(const String &path, bool writeMode) { File *ioFile = new File(); String filePath = path; if (writeMode && (path[0] != '.' && path[0] != '/')) { filePath.Insert(PATH_HOME_X, 0); } AppLog("Open file %S", filePath.GetPointer()); result r = ioFile->Construct(filePath, writeMode ? L"w" : L"r", writeMode); if (r == E_SUCCESS) { return new BadaFileStream(ioFile, writeMode); } AppLog("Failed to open file"); delete ioFile; return 0; }
void DebugConsole::Log(String& statement, String& logLevel) { if(!statement.IsEmpty()) { if(logLevel == L"INFO" || logLevel == L"WARN") { AppLog("[%S] %S", logLevel.GetPointer(), statement.GetPointer()); } else if(logLevel == "DEBUG") { AppLogDebug("[%S] %S", logLevel.GetPointer(), statement.GetPointer()); } else if(logLevel == L"ERROR") { AppLogException("[%S] %S", logLevel.GetPointer(), statement.GetPointer()); } } }
result UserProfileForm::OnInitializing(void) { BaseForm::OnInitializing(); AppResource* pAppResource = Application::GetInstance()->GetAppResource(); __pLeftItemBitmap = pAppResource->GetBitmapN(L"facebook_icon1.png"); ButtonItem buttonLeftItem; buttonLeftItem.Construct(BUTTON_ITEM_STYLE_ICON,NULL); buttonLeftItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, __pLeftItemBitmap); Header* pHeader = GetHeader(); pHeader->SetStyle(HEADER_STYLE_TITLE); pHeader->SetButton(BUTTON_POSITION_LEFT, buttonLeftItem); pHeader->SetTitleText(L"Your Profile Page"); result r = E_SUCCESS; //Read Access Token Registry reg; r = reg.Construct(L"/Home/FacebookReg.ini", false ); String token; String section = L"Facebook"; String entry = L"AccessToken"; r = reg.GetValue(section, entry , token); if(r == E_SUCCESS) AppLog("token is %ls",token.GetPointer()); else AppLog("Reading failed: %s", GetErrorMessage(r)); __accessToken =token; String profileurl; profileurl.Append(L"https://graph.facebook.com/me?"); profileurl.Append(L"access_token="); profileurl.Append(__accessToken); SendRequestGet(profileurl); return r; }
void WebForm::LaunchBrowser(const String& url) { ArrayList* pDataList = null; pDataList = new ArrayList(); pDataList->Construct(); String* pData = null; pData = new String(L"url:"); pData->Append(url); AppLogDebug("Launching Stock Browser with %S", pData->GetPointer()); pDataList->Add(*pData); AppControl* pAc = AppManager::FindAppControlN(APPCONTROL_BROWSER, ""); if(pAc) { pAc->Start(pDataList, null); delete pAc; } pDataList->RemoveAll(true); delete pDataList; }