Example #1
0
void XaLibWs::Setup() {

	LOG.Write("INF",__FILE__,__FUNCTION__,__LINE__,"Ws Setup");

	ReqType=HTTP.GetHttpParam("ReqType");
	Encoding=HTTP.GetHttpParam("Encoding");
	Encryption=HTTP.GetHttpParam("Encryption");
	ConsumerId=HTTP.GetHttpParam("ConsumerId");
	ResType=HTTP.GetHttpParam("ResType");
	ResLang=HTTP.GetHttpParam("ResLang");
	Data=HTTP.GetHttpParam("Data");

	CheckRequired();

	/*
	* Encrypted - Encoded
	*/
	if (Encryption=="yes") {

		LOG.Write("INF", __FILE__,__FUNCTION__,__LINE__,"WS Requested Encrypted");

		if (Encoding=="no") {

			LOG.Write("ERR", __FILE__,__FUNCTION__,__LINE__,"WS Requested Encrypted But No Encoded");
			throw 107;

		} else {

			LOG.Write("INF", __FILE__,__FUNCTION__,__LINE__,"WS Requested Encrypted And Encoded");
			GetEncodedData();
			GetConsumer();
			GetDecryptedData();
		}

	/*
	* No Encrypted - Encoded
	*/
	} else if(Encryption=="no" && Encoding=="B64") {

		LOG.Write("INF", __FILE__,__FUNCTION__,__LINE__,"WS Requested No Encrypted And Encoded");
		GetEncodedData();
		GetConsumer();

	/*
	* No Encrypted - No Encoded
	*/
	} else if (Encryption=="no" && Encoding=="no") {

		LOG.Write("INF", __FILE__,__FUNCTION__,__LINE__,"WS Requested No Encrypted And No Encoded");
		GetConsumer();
	}

	ExtractData();
	
	if (SETTINGS["WsEnableLog"]=="yes") {

		AddRequestLog();
	}
};
Example #2
0
inline bool decodeAgile(std::string& decData, const std::string& encryptedPackage, const EncryptionInfo& info, const std::string& pass, std::string& secretKey)
{
	const CipherParam& keyData = info.keyData;
	const CipherParam& encryptedKey = info.encryptedKey;
	if (secretKey.empty()) {
		if (!getAgileSecretKey(secretKey, info, pass)) return false;
		if (putSecretKeyInstance()) {
			printf("secretKey = "); ms::dump(secretKey, false);
		}

		if (!VerifyIntegrity(encryptedPackage, keyData, secretKey, keyData.saltValue, info.encryptedHmacKey, info.encryptedHmacValue)) {
			printf("warning : mac err : data may be broken\n");
//			return false;
		}
	}

	std::string encData;
	const uint64_t decodeSize = GetEncodedData(encData, encryptedPackage);

	// decode
	normalizeKey(secretKey, encryptedKey.keyBits / 8);
	DecContent(decData, encData, encryptedKey, secretKey, keyData.saltValue);
	decData.resize(decodeSize);
	return true;
}
bool COMXImage::CreateThumbnailFromSurface(unsigned char* buffer, unsigned int width, unsigned int height, 
    unsigned int format, unsigned int pitch, const CStdString& destFile)
{
  if(format != XB_FMT_A8R8G8B8 || !buffer) {
    CLog::Log(LOGDEBUG, "%s::%s : %s failed format=0x%x\n", CLASSNAME, __func__, destFile.c_str(), format);
    return false;
  }

  if(!Encode(buffer, height * pitch, width, height, pitch)) {
    CLog::Log(LOGDEBUG, "%s::%s : %s encode failed\n", CLASSNAME, __func__, destFile.c_str());
    return false;
  }

  XFILE::CFile file;
  if (file.OpenForWrite(destFile, true))
  {
    CLog::Log(LOGDEBUG, "%s::%s : %s width %d height %d\n", CLASSNAME, __func__, destFile.c_str(), width, height);

    file.Write(GetEncodedData(), GetEncodedSize());
    file.Close();
    return true;
  }

  return false;
}
Example #4
0
bool COMXImage::CreateThumbnailFromSurface(unsigned char* buffer, unsigned int width, unsigned int height, 
    unsigned int format, unsigned int pitch, const CStdString& destFile)
{
  if(format != XB_FMT_A8R8G8B8 || !buffer)
    return false;

  // the omx encoder needs alligned sizes
  if(width%16 || height%16)
  {
    unsigned int new_width = (width + 15)&~15;
    unsigned int new_height = (height + 15)&~15;
    unsigned int new_pitch = new_width * 4;

    unsigned int size = new_height * new_pitch;
    unsigned char *dstBuffer = (unsigned char *)malloc(size);
    unsigned char *dst = dstBuffer;
    unsigned char *src = buffer;

    if(!dstBuffer)
      return false;

    memset(dst, 0x0, size);

    for(unsigned int y = 0; y < height; y++)
    {
      memcpy(dst, src, pitch);
      src += pitch;
      dst += new_pitch;
    }
    if(!Encode(dstBuffer, size, new_width, new_height))
    {
      free(dstBuffer);
      return false;
    }
    free(dstBuffer);
  }
  else
  {
    if(!Encode(buffer, height * pitch, width, height))
      return false;
  }

  XFILE::CFile file;
  if (file.OpenForWrite(destFile, true))
  {
    CLog::Log(LOGDEBUG, "%s::%s : %s width %d height %d\n", CLASSNAME, __func__, destFile.c_str(), width, height);

    file.Write(GetEncodedData(), GetEncodedSize());
    file.Close();
    return true;
  }

  return false;
}