void VKURequestData::OnTransactionReadyToRead(HttpSession& httpSession, 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(); String text(L"Read Body Length: "); text.Append(availableBodyLen); AppLog("len: %ls", text.GetPointer()); data.CopyFrom(*pBuffer); //delete tempHeaderString; delete pBuffer; } } return; }
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 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()))); }
void RouteRequestManager::OnTransactionReadyToRead(Osp::Net::Http::HttpSession& httpSession, Osp::Net::Http::HttpTransaction& httpTransaction, int availableBodyLen){ AppLogDebug("http ready called"); HttpResponse* resp = httpTransaction.GetResponse(); //String status = resp->GetStatusText(); //AppLog("status: %S",status); ByteBuffer* buffer = (resp->ReadBodyN()); char data[buffer->GetLimit()+1]; buffer->SetPosition(0); buffer->GetArray((byte*)data, 0, buffer->GetLimit()); data[buffer->GetLimit()] ='\0'; String test(data); AppLogDebug("%S",test.GetPointer()); AppLogDebug("\n\n"); ArrayListT<Trip*>* trips=null; IRailAPI h; if(AppData::GetInstance()->getCurrentRequest() != null){ trips = h.createTripList(buffer); } if(trips != null){ if(!addToResults) AppData::GetInstance()->getCurrentRequest()->clearTrips(); AppData::GetInstance()->getCurrentRequest()->getTrips()->AddItems(*trips); //AppLog("parsing succesfull"); Controller::GetInstance()->switchToRoutePlannerResults(); } else{ //AppLogDebug("parsing failed"); Controller::GetInstance()->showServerErrorMessage(); } //write to file /* File f; int fileIndex = getRoutePlannerRegistryIndex(); f.Construct(L"/Home/history/RP"+ Integer::ToString(fileIndex) + ".xml",L"w+",false); f.Write(*buffer); */ }
void UserProfileForm::OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen) { AppLogDebug("OnTransactionReadyToRead,..availableBodyLen=%d",availableBodyLen); count++; HttpResponse* pHttpResponse = httpTransaction.GetResponse(); if(pHttpResponse->GetHttpStatusCode() == HTTP_STATUS_OK) { __pBuffer = pHttpResponse->ReadBodyN(); } if(__pProfileName==NULL) { ParseJsonData(); Label *pLabel = new Label(); String labelText(L"Welcome "); labelText.Append(*__pProfileName); AppLog("labelText is =%ls",labelText.GetPointer()); pLabel->Construct(Rectangle(05, 50, 500, 100), labelText); AddControl(*pLabel); Draw(); Show(); __pSession->CloseTransaction(httpTransaction); delete __pSession; __pSession = null; } //Get Profile Picture String imageurl; imageurl.Append(L"https://graph.facebook.com/me"); imageurl.Append(L"/picture?"); imageurl.Append(L"access_token="); imageurl.Append(__accessToken); SendRequestGet(imageurl); __pProfileImage = new Image(); __pProfileImage->Construct(); Bitmap *pBitmap; pBitmap=__pProfileImage->DecodeN(*__pBuffer,IMG_FORMAT_JPG,BITMAP_PIXEL_FORMAT_ARGB8888,150,150); Label *pImageLabel = new Label(); pImageLabel->Construct(Rectangle(150,150, 150, 150),""); pImageLabel->SetBackgroundBitmap(*pBitmap); AddControl(*pImageLabel); Button* pGetFriends = new Button(); pGetFriends->Construct(Rectangle(30,330, 350, 70), L"Get Friends"); pGetFriends->SetActionId(ID_BUTTON_FRIENDS_CLICKED); pGetFriends->AddActionEventListener(*this); AddControl(*pGetFriends); Button* pLogout = new Button(); pLogout->Construct(Rectangle(30,430, 350, 70), L"Logout"); pLogout->SetActionId(ID_BUTTON_LOGOUT_CLICKED); pLogout->AddActionEventListener(*this); AddControl(*pLogout); Draw(); Show(); }
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"); } }
void ProjectGiraffeTab1::OnTransactionReadyToRead (HttpSession &httpSession, HttpTransaction &httpTransaction, int availableBodyLen) { HttpResponse* pHttpResponse = httpTransaction.GetResponse(); HttpHeader* pHttpHeader = null; AppLog("Checking HTTP Status Code"); if (pHttpResponse->GetHttpStatusCode() == HTTP_STATUS_OK) { // MessageBox msgBox; // msgBox.Construct(L"HTTP STATUS", L"HTTP Request OK", MSGBOX_STYLE_NONE, 3000); // int modalresult = 0; // msgBox.ShowAndWait(modalresult); ByteBuffer* pBody = null; String statusText = pHttpResponse->GetStatusText(); String version = pHttpResponse->GetVersion(); pHttpHeader = pHttpResponse->GetHeader(); pBody = pHttpResponse->ReadBodyN(); //delete pBody; //Parses from ByteBuffer IJsonValue* pValue = JsonParser::ParseN(*pBody); AppLog("Received HTTP response."); AppLog("Before traverse %d", _tableView->GetItemCount()); _pJsonKeyList->RemoveAll(true); _pValueList->RemoveAll(true); _items->RemoveAll(true); // Populate the panel TraverseFunction(pValue); AppLog("After traverse"); //clean up allocated jsonValues if (pValue->GetType() == JSON_TYPE_OBJECT) { // Converts the pValue to JsonObject JsonObject* pObject = static_cast< JsonObject* >(pValue); pObject->RemoveAll(true); } else if (pValue->GetType() == JSON_TYPE_ARRAY) { // Converts the pValue to JsonArray JsonArray* pArray = static_cast< JsonArray* >(pValue); pArray->RemoveAll(true); } delete pBody; delete pValue; _tableView->ScrollToItem(0); }else{ AppLog("HTTP Status not OK"); } //Remove load icon here. //_loadingPopupThread->Quit(); //_loadingPopupThread->Join(); }