예제 #1
0
void CI8SkinPack::LoadSkin(CI8SkinBitmap& clBitmap, const stdex::tString& sFile, BOOL bCheckExist)
{
    HBITMAP& hBitmap = m_clBitmapLib[sFile.c_str()];
    if (hBitmap == NULL)
    {
        hBitmap = LoadBitmapFromZip(sFile.c_str());
        if (hBitmap == NULL && bCheckExist)
        {
            assert(0 && "皮肤图片无法加载。");
        }
    }
    clBitmap.Set(hBitmap, FALSE);
}
예제 #2
0
stdex::tString WZDlgClient::_GetGonggao(const stdex::tString &text)
{
	if(utility::IsEmpty(text.c_str()))
		return text;

	std::string src = CT2A(text.c_str());
	int len = ATL::Base64DecodeGetRequiredLength(src.length());
	std::vector<byte> vec(len + 1);

	ATL::Base64Decode(src.data(), len, &vec[0], &len);

	stdex::tString savePath(CA2T((char *)&(vec[0])));
	return savePath;
}
예제 #3
0
void WZDlgServers::OnLvnGetdispinfoListServerInfo(NMHDR *pNMHDR, LRESULT *pResult)
{
	NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
	*pResult = 0;

	LV_ITEM *pItem = &(pDispInfo)->item;
	int itemIndex = pItem->iItem;
	if( static_cast<size_t>(itemIndex) >= curservers_.size() )
		return;
	using namespace i8desk::data_helper;
	const ServerTraits::ValueType &val = curservers_[itemIndex];

	static stdex::tString text;
	if( pItem->mask & LVIF_TEXT )
	{
		switch(pItem->iSubItem)
		{
		case MASK_SERVER_NAME:
			text = val->SvrName ;
			break;
		case MASK_SERVER_DEFAULT_IP:
			text = i8desk::IP2String(val->SvrIP);
			break;
		case MASK_SERVER_AREAMODE:
			val->BalanceType == BALANCE_POLL ? text = RT_DISTRIBUTE :  text = RT_PRIORITY_AREA ;
			break;
		}

		utility::Strcpy(pItem->pszText, pItem->cchTextMax, text.c_str());
	}

}
		inline buffer download_file(const stdex::tString &url, const CallbackT &callback)
		{
			using namespace WinInet;
			CInternetSession session;

			// 建立连接,并下载
			CHttpFile httpFile(session, url.c_str(), 0, -1, 
				INTERNET_FLAG_RELOAD | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_NO_CACHE_WRITE);
			if( httpFile == NULL )
				throw std::runtime_error(detail::http_error<0>(::GetLastError()));

			DWORD dwLength = 0;
			httpFile.QueryInfo(HTTP_QUERY_CONTENT_LENGTH, dwLength);

			buffer buf = make_buffer(dwLength + 1);

			DWORD dwSize = 0;
			const size_t readLen = 512;
			CHttpFile::CInfo info(dwLength);
			while( dwSize != dwLength )
			{
				DWORD nSize = 0;
				if( !httpFile.Read(buf.first.get() + dwSize, readLen, nSize, info) )
					throw std::runtime_error(detail::http_error<0>(::GetLastError()));

				if( callback(buf.first.get() + dwSize, nSize, info) )
					throw std::logic_error("终止下载");

				dwSize += nSize;
			}

			return buf;
		}
예제 #5
0
		void _Thread(long gid)
		{
			Log(LM_INFO, _T("开始下载插件"));

			stdex::tOstringstream os;
			os << _T("http://211.154.172.139/temp/") << gid << _T(".zip");
			stdex::tString url = os.str();

			const static stdex::tString plugin = utility::GetAppPath() + _T("plugin_tools/"); 
			if( !::PathFileExists(plugin.c_str()) )
				::CreateDirectory(plugin.c_str(), NULL);

			http::Buffer buf;

			try
			{
				// 下载文件
				using namespace std::tr1::placeholders;
				buf = http::DownloadFile(url, std::tr1::bind(&DownloadEngine::_Check, engine_, gid, _1, _2, _3));
								
				stdex::tOstringstream osPath;
				osPath << plugin.c_str() << gid;

				const stdex::tString unZipPath = osPath.str() + _T("/");
				utility::mkpath(unZipPath);

				if( !http::UnZip(buf, unZipPath) )
					throw std::runtime_error("解压失败!");

				// 处理文件
#ifdef _DEBUG
				stdex::tString zipPath = osPath.str() + _T(".zip");
				std::ofstream out(zipPath.c_str(), std::ios::binary | std::ios::out);
				out.write(buf.first.get(), buf.second - 1);
#endif
			
				// 下载完成回调
				engine_->OnComplate(gid);
			}
			catch(std::exception &e)
			{
				Log(LM_ERROR, _T("下载插件: %d 出错"), gid);
			}
			
			Log(LM_INFO, _T("下载插件: %d 完成"), gid);
		}
예제 #6
0
	ini::ini(const stdex::tString &path)
	{
		stdex::tIfstream in;

		in.imbue(std::locale("chs"));
		in.open(path.c_str());

		assert(in.good());
		if( !in )
			return;

		detail::parse(std::move(in), ini_maps_);
	}
예제 #7
0
void WZDlgClient::_SetGonggao( const stdex::tString &text)
{
	std::string src = CT2A(text.c_str());
	int len = ATL::Base64EncodeGetRequiredLength(src.length());
	std::vector<char> vec;
	vec.resize(len + 1);

	ATL::Base64Encode((const byte *)src.c_str(), src.length(), &vec[0], &len);

	stdex::tString val = CA2T(&vec[0]);

	i8desk::GetDataMgr().SetOptVal(OPT_M_GGMSG,  val);
}
예제 #8
0
				void operator()(const stdex::tString &path)
				{
                    ::SetFileAttributes(path.c_str(), FILE_ATTRIBUTE_NORMAL);
					::DeleteFile(path.c_str());
				}