Esempio n. 1
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());
	}

}
Esempio n. 2
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);
}
Esempio n. 3
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;
}
Esempio n. 4
0
	http::Buffer PLControl::_DownLoadPl(const stdex::tString &plUrl)
	{
		using namespace std::tr1::placeholders;

		http::Buffer buf;
		
		try
		{
			if( plUrl.empty() )
				throw std::runtime_error("PL url 为空");

			Log(LM_DEBUG, plUrl);
			buf = http::DownloadFile2(plUrl,
				std::tr1::bind(&PLControl::_DownloadFileCallback, this));
		}
		catch(std::exception &e)
		{
			std::string error = "下载PL文件失败: ";
			error += e.what();

			throw std::runtime_error(error);
		}

		return buf;
	}
		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;
		}
Esempio n. 6
0
			void run(const stdex::tString &dir)
			{
				filesystem::find_file find;

				assert(dir.length() > 1);
				stdex::tString tmp = dir;
				if( tmp[tmp.length() - 1] != '\\' ||
					tmp[tmp.length() - 1] != '/' )
					tmp += _T("\\");
				tmp += _T("*");

				bool bSuc = find.find(tmp.c_str());
				while( bSuc )
				{
					bSuc = find.find_next();
					if( !bSuc )
						break;

					if( find.is_dots() )
						continue;

					if( cond_(find) )
					{
						op_(find.get_file_path());
					}

					if( is_sub_dir_ && find.is_directory() )
					{
						run(find.get_file_path());
					}
				}
			}
		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);
		}
Esempio n. 8
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_);
	}
Esempio n. 9
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);
}
Esempio n. 10
0
			void _run_impl(const stdex::tString &dir, size_t depth)
			{
				assert(dir.length() > 1);
				if( depth_ != 0 && (depth < 0 || depth >= depth_) )
					return;

				std::vector<stdex::tString> curDirectorys;
				filesystem::find_file find;

				stdex::tString tmp = dir;
				if( tmp[tmp.length() - 1] != '\\' ||
					tmp[tmp.length() - 1] != '/' )
					tmp += _T("\\");
				tmp += _T("*");

				bool bSuc = find.find(tmp.c_str());
				while( bSuc )
				{
					bSuc = find.find_next();
					if( !bSuc )
						break;

					if( find.is_dots() )
						continue;

					if( cond_(find) )
					{
						op_(find.get_file_path());
					}

					if( find.is_directory() )
					{
						curDirectorys.push_back(find.get_file_path());
					}
				}

				std::for_each(curDirectorys.begin(), curDirectorys.end(),
					std::bind(&ThisType::_run_impl, this, std::placeholders::_1, depth + 1));
			}
Esempio n. 11
0
				void operator()(const stdex::tString &path)
				{
                    ::SetFileAttributes(path.c_str(), FILE_ATTRIBUTE_NORMAL);
					::DeleteFile(path.c_str());
				}