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;
}
result Enrollment::SendData() {
	String data = "";
	ByteBuffer* pTxBuffer = null;
	ByteBuffer buffer;
	result res = E_SUCCESS;

	for (int i = 0; i < 4; i++) {
		data.Append(__pWorkList[i]->GetText());
		data.Append("\n");
	}
	if (data.IsEmpty()) {
		AppLog("There is no data to send");
		return E_SUCCESS;
	}

	pTxBuffer = Tizen::Base::Utility::StringUtil::StringToUtf8N(data);
	TryReturn(pTxBuffer != null, E_OUT_OF_MEMORY,
			"Failed to allocate ByteBuffer");
	AppLog("Text Length %d", pTxBuffer->GetLimit());

	buffer.Construct(pTxBuffer->GetLimit());
	buffer.CopyFrom(*pTxBuffer);
	buffer.Flip();

	delete pTxBuffer;

	res = __pSocket->SendTo(buffer, *__pUdpEndpoint);
	if (res != E_SUCCESS && res != E_WOULD_BLOCK)
		AppLog("Error sending data");

	buffer.Clear();
	return res;
}
int trueStringLength(const char *str, int len){
    Tizen::Base:: String bada_str;
    ByteBuffer buffer;
    buffer.Construct(len + 1);
    buffer.SetArray(( byte*)str, 0, len);
    buffer.SetByte( '\0');
    buffer.Flip();
    Tizen::Text::Utf8Encoding utf8;
    int charCount;
    utf8.GetCharCount(buffer, charCount);
  return charCount;
}
void ZLbadaPaintContext::drawString(int x, int y, const char *str, int len, bool rtl){
	Tizen::Base::String bada_str;
    ByteBuffer buffer;
    buffer.Construct(len + 1);
    buffer.SetArray((byte*)str, 0, len);
    buffer.SetByte('\0');
    buffer.Flip();
//AppLog("ZLbadaPaintContext::drawString %s",(const char *)str);
//	StringUtil::Utf8ToString((const char *)buffer.GetPointer(), bada_str);
    Utf8Encoding utf8;
    int charCount;
    utf8.GetCharCount(buffer, charCount);
    utf8.GetString(buffer, bada_str);
 //   AppLog("charCount = %d : len = %d", charCount,len);
 //   DrawEnrichedTex(x, y-myFont->GetMaxHeight(),bada_str );
 //   AppLog("myStoredSize = %d ", myStoredSize);
 //   AppLog("myFont->GetMaxHeight() = %d ", myFont->GetMaxHeight());
    //Tizen::Graphics::Color clr = Tizen::Graphics::Color::COLOR_GREEN;

	if ((myFont!=0)&&(pCanvas!=0))  {
	//	AppLog("pCanvas->SetFont(*myFont)");
	//	pCanvas->SetFont(*myFont);

	 if (myStoredItalic)
		 pCanvas->DrawText(Point(x, y - myFont->GetMaxHeight()+ deltaItalic), bada_str);
	 else
		 pCanvas->DrawText(Point(x, y - myFont->GetMaxHeight()), bada_str);
}
//	AppLog("ZLbadaPaintContext::drawString end");
 /*
 if (!myStoredItalic) pCanvas->DrawText(Point(x, y-myFont->GetMaxHeight()), bada_str);
 else{
	 int startX = x;
	 int startY= y-myFont->GetMaxHeight();
	 mchar ch;
	 for (int i=0; i<charCount; i++){
	     bada_str.GetCharAt(i, ch);
	     int rb;
	     myFont->GetRightBear(ch, rb);
	     int lb;
	     myFont->GetLeftBear(ch, lb);
	     pCanvas->DrawText(Point(startX, startY), ch);
	     startX = startX + rb;
	     }
 	 }

*/
	//pCanvas->DrawText(Point(x, y-myFont->GetMaxHeight()), bada_str, Tizen::Graphics::Color::COLOR_WHITE);
//	pCanvas->DrawText(Point(x, y-myFont->GetMaxHeight()), bada_str, charCount);
//	pCanvas->DrawText(Point(x, y), bada_str,charCount);
}
示例#5
0
void FBReader::openLinkInBrowser(const std::string &url) const {
	if (url.empty()) {
		return;
	}
	AppLog("openLinkInBrowser url=%s",url.c_str());

   int len = url.length();
   String bada_str;
   ByteBuffer buffer;
   buffer.Construct(len + 1);
   buffer.SetArray((const byte*)url.data(), 0, len);
   buffer.SetByte( '\0');
   buffer.Flip();
   Utf8Encoding utf8;
   int charCount;
   utf8.GetCharCount(buffer, charCount);
   utf8.GetString(buffer, bada_str);

	ArrayList* pDataList = null;
	pDataList = new ArrayList();
	pDataList->Construct();
	String* pData = null;

	pData = new String(L"url:" + bada_str);
	//pData = new String(L"url:http://www.bada.com");
	pDataList->Add(*pData);
	//APPCONTROL_BROWSER
	//TODO Tizen
	AppControl* pAc;// rem  TIZEN !!!!!!!!!= AppManager::FindAppControlN(APPCONTROL_BROWSER, OPERATION_VIEW);
	//AppControl* pAc = AppManager::FindAppControlN(APPCONTROL_PROVIDER_BROWSER, APPCONTROL_OPERATION_VIEW);
	if (pAc)    {       pAc->Start(pDataList, null);       delete pAc;    }
	pDataList->RemoveAll(true);
	delete pDataList;

	/*
	shared_ptr<ProgramCollection> collection = webBrowserCollection();
	if (collection.isNull()) {
		return;
	}
	shared_ptr<Program> program = collection->currentProgram();
	if (program.isNull()) {
		return;
	}
	std::string copy = url;
//	NetworkLinkCollection::Instance().rewriteUrl(copy, true);
	ZLLogger::Instance().println("URL", copy);
	program->run("openLink", copy);*/
}
int ZLbadaPaintContext::stringWidth(const char *str, int len, bool) const {
	Tizen::Base::String bada_str;
    ByteBuffer buffer;
    buffer.Construct(len + 1);
    buffer.SetArray((byte*)str, 0, len);
    buffer.SetByte('\0');
    buffer.Flip();
//	AppLog("ZLbadaPaintContext::stringWidth %s",(const char *)buffer.GetPointer());
//	StringUtil::Utf8ToString((const char *)buffer.GetPointer(), bada_str);
    Utf8Encoding utf8;
    int charCount;
    utf8.GetCharCount(buffer, charCount);
    utf8.GetString(buffer, bada_str);

    Dimension dim;


	 //if (!myStoredItalic) {
		 myFont->GetTextExtent(bada_str, charCount, dim);
	//	AppLog("dim.width %d",dim.width);
		 return dim.width;// + charCount*(myFont->GetCharSpace());
	 /*}
	 else{
		 int width = 0;
		 //int startY = y-myFont->GetMaxHeight();
		 mchar ch;
		 for (int i=0; i<charCount; i++){
		     bada_str.GetCharAt(i, ch);
		     int rb;
		     myFont->GetRightBear(ch, rb);
		    // int lb;
		    // myFont->GetLeftBear(ch, lb);
		    // pCanvas->DrawText(Point(startX, startY), ch);
		     AppLog("width %d",width);
		     width = width + rb;
		     }
		 return width;
	 	 }*/


}
result Enrollment::SendDataCommand(String command) {
	ByteBuffer* pTxBuffer = null;
	ByteBuffer buffer;
	result res = E_SUCCESS;

	TryReturn(__isTcp == false, E_SYSTEM,
			"Sending Command not required for TCP connection");
	pTxBuffer = Tizen::Base::Utility::StringUtil::StringToUtf8N(command);
	TryReturn(pTxBuffer != null, E_OUT_OF_MEMORY,
			"Failed to allocate ByteBuffer");

	buffer.Construct(1024);
	buffer.CopyFrom(*pTxBuffer);
	delete pTxBuffer;

	buffer.Flip();
	do {
		if (__pUdpEndpoint != null) {
			res = __pSocket->SendTo(buffer, *__pUdpEndpoint);
		}
		if (res == E_WOULD_BLOCK) {
			AppLog("Would block for data sending will try to retransmit");
			Tizen::Base::Runtime::Thread::Sleep(500);
		} else if (res != E_SUCCESS) {
			AppLog("Error sending data");
			break;
		} else {
			AppLog("Command successfully sent");
			break;
		}
	} while (1);

	AppLog("Loop completed");
	buffer.Clear();

	return res;
}