void Chatting::OnTransactionReadyToRead( Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, int availableBodyLen) { AppLog("OnTransactionReadyToRead"); HttpResponse* pHttpResponse = httpTransaction.GetResponse(); if (pHttpResponse->GetHttpStatusCode() == HTTP_STATUS_OK) { HttpHeader* pHttpHeader = pHttpResponse->GetHeader(); if (pHttpHeader != null) { String* tempHeaderString = pHttpHeader->GetRawHeaderN(); ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); AppLog((const char*)pBuffer->GetPointer()); String str((const char*) (pBuffer->GetPointer())); // IJsonValue* pJson = JsonParser::ParseN(*pBuffer); // // JsonObject *pObject = static_cast<JsonObject*>(pJson); // // JsonString *userName = new JsonString("username"); // IJsonValue *pValName = null; // // JsonString *dates = new JsonString("date"); // IJsonValue *pValDate = null; // // // pObject->GetValue(userName, pValName); // pObject->GetValue(dates,pValDate); // // // JsonString* pName = static_cast<JsonString*>(pValName); // JsonString* pDate= static_cast<JsonString*>(pValDate); // // String text(L"이름: "); // text.Append(*pName); // text.Append("\n날짜: "); // text.Append(*pDate); // String text(str); // text.Append(availableBodyLen); // __pEditArea->SetText(text); Draw(); delete tempHeaderString; delete pBuffer; } } }
void ZLbadaPaintContext::fillFamiliesList(std::vector<std::string> &families) const { AppLog( "fillFamiliesList"); Tizen::Base::Collection::IList* FontList; FontList = Tizen::Graphics::Font::GetSystemFontListN(); int Count = FontList->GetCount(); AppLog( "fillFamiliesList %d", Count); badaFonts.clear(); for (int i =0; i<Count; i++) { Tizen::Base::String* f = (Tizen::Base::String*)FontList->GetAt(i); Utf8Encoding utf8; ByteBuffer* pBB = utf8.GetBytesN(*f); std::string family(( const char*)pBB->GetPointer());//,f->GetLength()); AppLog( "family name = %s",family.c_str()) ; delete pBB; bool check = false; for (std::vector<std::string>::const_iterator it = families.begin(); it != families.end(); ++it) { if (*it == family) { check = true; break; } } if (!check) { families.push_back(family); badaFonts.push_back(family); } } FontList->RemoveAll(true); for (std::vector<ZLFont*>::const_iterator it=fontsList.begin() ; it != fontsList.end(); it++ ){ ZLFont* f = *it; //std::string family(f.family); families.push_back(f->family); AppLog( "myFontsList = %s",f->family.c_str()) ; } }
// // converts a bada (wchar) String into a scummVM (char) string // Common::String fromString(const Osp::Base::String &in) { ByteBuffer *buf = StringUtil::StringToUtf8N(in); Common::String result((const char*)buf->GetPointer()); delete buf; return result; }
result Enrollment::DisplayText(ByteBuffer& txBuffer, unsigned long buflen) { String data; char* pBuffer = null; result res = E_SUCCESS; txBuffer.Flip(); pBuffer = (char*) (txBuffer.GetPointer()); data.SetCapacity(buflen + 20); res = data.Append(pBuffer); TryReturn(res == E_SUCCESS, res, "Append Failed"); txBuffer.Clear(); if (data == L"__HELLO__") { EnableControl(true); __isConnected = true; return res; } if (__isConnected == false) { AppLog( "Server hasn't received Initial message so all incoming content is discarded"); // Remove created NetEndPoint delete __pUdpEndpoint; __pUdpEndpoint = null; return res; } if (data == L"__CLOSE__") { SceneManager* pSceneManager = SceneManager::GetInstance(); AppAssert(pSceneManager); pSceneManager->GoBackward(BackwardSceneTransition(SCENE_CALENDAR)); OnClose(); return res; } int i = 0; if (data.Contains(__pWorkList[i]->GetText())) { __pWorkList[i++]->SetSelected(true); } if (data.Contains(__pWorkList[i]->GetText())) { __pWorkList[i++]->SetSelected(true); } if (data.Contains(__pWorkList[i]->GetText())) { __pWorkList[i++]->SetSelected(true); } if (data.Contains(__pWorkList[i]->GetText())) { __pWorkList[i++]->SetSelected(true); } TryReturn(res == E_SUCCESS, res, "AppendText Failed"); for (int k = 0; k < MAX_WORK_COUNT; k++) { __pWorkList[k]->RequestRedraw(); } return res; }
void ZLbadaPaintContext::printFaceName(Tizen::Graphics::Font* font){ ByteBuffer* bb; Tizen::Base::String fontFaceName; fontFaceName=font->GetFaceName(); bb = Tizen::Base::Utility::StringUtil:: StringToUtf8N(fontFaceName); AppLog( "fontFaceName2 %s",(char *)bb->GetPointer()); delete bb; }
void HttpThread::OnHttpDownloadInProgress(HttpSession & /*httpSession*/, Tizen::Net::Http::HttpTransaction & httpTransaction, int64_t currentLength, int64_t totalLength) { HttpResponse * pResponse = httpTransaction.GetResponse(); if (pResponse->GetHttpStatusCode() == HTTP_STATUS_OK || pResponse->GetHttpStatusCode() == HTTP_STATUS_PARTIAL_CONTENT) { ByteBuffer * pBuffer = 0; pBuffer = pResponse->ReadBodyN(); int const chunkSize = pBuffer->GetLimit(); m_downloadedBytes += chunkSize; m_callback.OnWrite(m_begRange + m_downloadedBytes - chunkSize, pBuffer->GetPointer(), chunkSize); delete pBuffer; } else LOG(LERROR, ("OnHttpDownloadInProgress ERROR", FromTizenString(pResponse->GetStatusText()))); }
// Implements an ITextEventListener void StringOptionView::OnTextValueChanged(const Control& source) { // Todo: AppLog("OnTextValueChanged"); CustomListItem* pItem = new OptionListItem(this); pItem->Construct(100); pItem->SetItemFormat(*myTab->form()->__pStringViewListItemFormat); pItem->SetElement(ID_LIST_TEXT_TITLE,String((ZLOptionView::name()).c_str())); pItem->SetElement(ID_LIST_TEXT_SUBTITLE, __pKeypad->GetText()); myTab->form()->__pCustomList->SetItemAt(groupIndex,itemIndex, *pItem, ID_LIST_ITEM); ByteBuffer* bb = Tizen::Base::Utility::StringUtil:: StringToUtf8N(__pKeypad->GetText()); myValue = std::string((char *)bb->GetPointer()); AppLog( "pKeypad->GetText %s",myValue.c_str()); }
void ZLbadaPaintContext::collectFiles(std::map<std::string, std::string> &names, const char* path ) { //TODO collectFiles AppLog("ZLbadaPaintContext::collectFiles") ; Directory dir; DirEnumerator *pDirEnum = null; result r = E_SUCCESS; // Opens the directory r = dir.Construct(path); AppLog(" dir.Construct %s",path) ; if(IsFailed(r)) AppLog("IsFailed"); //goto CATCH; // Reads all the directory entries pDirEnum = dir.ReadN(); // if(!pDirEnum) // goto CATCH; while(pDirEnum->MoveNext() == E_SUCCESS) { DirEntry dirEntry = pDirEnum->GetCurrentDirEntry(); Tizen::Base::String str = dirEntry.GetName(); // AppLog("dirEntry name Length = %d",str.GetLength()) ; Utf8Encoding utf8; ByteBuffer* pBB = utf8.GetBytesN(str); std::string shortName((const char*)pBB->GetPointer());//,str.GetLength()); AppLog("dirEntry name = %s",shortName.c_str()) ; if (shortName !="." && shortName !="..") { std::string fullName; fullName = path + shortName; AppLog("fullName = %s",fullName.c_str()); names.insert(std::make_pair(shortName,fullName)); } delete pBB; // names.push_back(shortName); } // Deletes the enumerator delete pDirEnum; AppLog("Succeeded"); }
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(); }
// IAPIRequestListener void VideoviewForm::OnResponseN(RequestId requestId, Tizen::Web::Json::JsonObject *object) { if(requestId != REQUEST_GET_VIDEO) { return; } result r; JsonObject *response; JsonObject *files; String videoUrl; ByteBuffer buffer; JsonWriter::Compose(object, buffer); AppLog("response: %s", buffer.GetPointer()); r = JsonParseUtils::GetObject(object, L"response", response); TryCatch(r == E_SUCCESS, , "failed to get response from object"); r = JsonParseUtils::GetObject(response, L"files", files); TryCatch(r == E_SUCCESS, , "failed to get files from response"); if(JsonParseUtils::GetString(*files, L"mp4_360", videoUrl) == E_SUCCESS) { PlayUrl(videoUrl); return; } if(JsonParseUtils::GetString(*files, L"mp4_240", videoUrl) == E_SUCCESS) { PlayUrl(videoUrl); return; } if(JsonParseUtils::GetString(*files, L"mp4_480", videoUrl) == E_SUCCESS) { PlayUrl(videoUrl); return; } r = E_FILE_NOT_FOUND; CATCH: AppLogException("failed to play video: %s", GetErrorMessage(r)); return; }
// Implement an ITextEventListener void CCEGLView::OnTextValueChanged(const Control& source) { // clear textinput text std::string strOldText = CCIMEDispatcher::sharedDispatcher()->getContentText(); for (int i = 0; i < strOldText.length(); i++) { CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); } String str = m_pKeypad->GetText(); if (str.GetLength() <= 0) { CCIMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1); } else { Utf8Encoding utf8; ByteBuffer* pBuffer = utf8.GetBytesN(str); if (pBuffer != null) { const char* pszText = (const char*)pBuffer->GetPointer(); if (pszText != NULL) { int len = strlen(pszText); if (pszText[len-1] != '\n') { std::string strText = pszText; strText.append("\n"); CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(strText.c_str(), strText.length()); } } delete pBuffer; } } }
void IRailConnection::OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen) { //LEZEN werkt ! ArrayListT<Connection> connections; connections.Construct(10); HttpResponse* resp = httpTransaction.GetResponse(); ByteBuffer* buf = (resp->ReadBodyN()); xmlDocPtr doc = xmlParseMemory((char*) (buf->GetPointer()), buf->GetLimit()); if (doc != null) { xmlNodePtr connection = null; xmlNodePtr pRoot = xmlDocGetRootElement(doc); for (connection = pRoot->children; connection; connection = connection->next) { xmlNodePtr child = null; Connection con; for (child = connection->children; child; child = child->next) { if (child->type == XML_ELEMENT_NODE) { String nodeName; Osp::Base::Utility::StringUtil::Utf8ToString( (char*) child->name, nodeName); if (nodeName.CompareTo("departure") == 0) { xmlNodePtr child1 = null; for (child1 = child->children; child1; child1 = child1->next) { if (child1->type == XML_ELEMENT_NODE) { String nodeName1; Osp::Base::Utility::StringUtil::Utf8ToString( (char*) child1->name, nodeName1); if (nodeName1.CompareTo("time") == 0) { xmlAttrPtr isoTime = child1->properties; if (isoTime != null && isoTime->type == XML_ATTRIBUTE_NODE) { String time; Osp::Base::Utility::StringUtil::Utf8ToString( (char*) isoTime->children->content, time); con.setFromTime(time); } } else if (nodeName1.CompareTo("station") == 0) { String station; Osp::Base::Utility::StringUtil::Utf8ToString( (char*) child1->children->content, station); con.setFromStation(station); } } } } else if (nodeName.CompareTo("arrival") == 0) { xmlNodePtr child1 = null; for (child1 = child->children; child1; child1 = child1->next) { if (child1->type == XML_ELEMENT_NODE) { String nodeName1; Osp::Base::Utility::StringUtil::Utf8ToString( (char*) child1->name, nodeName1); if (nodeName1.CompareTo("time") == 0) { xmlAttrPtr isoTime = child1->properties; if (isoTime != null && isoTime->type == XML_ATTRIBUTE_NODE) { String time; Osp::Base::Utility::StringUtil::Utf8ToString( (char*) isoTime->children->content, time); con.setToTime(time); } } else if (nodeName1.CompareTo("station") == 0) { String station; Osp::Base::Utility::StringUtil::Utf8ToString( (char*) child1->children->content, station); con.setToStation(station); } } } } else if (nodeName.CompareTo("duration") == 0) { String duration_; Osp::Base::Utility::StringUtil::Utf8ToString( (char*) child->children->content, duration_); int duration; Integer::Parse(duration_, duration); con.setDuration(duration); } } } if(con != null) { connections.Add(con); } } xmlFreeDoc(doc); this->pTrainsResultsForm->setConnections(connections); } else { AppLog("parsing internet file failed"); } }