Exemplo n.º 1
0
void CCommandProcessor::OnPingClientResp(BYTE *pBuffer, size_t bufLen)
{
	PINGCLIENTRESP pcr = {0};
	GetBody(pBuffer, &pcr, sizeof PINGCLIENTRESP);

	CString strTermID = CA2W(pcr.termId);
	CString strIP = CA2W(pcr.termIp);

	INT_PTR nIndex = m_lpLocalServer->ComputerList.Find(strTermID, strIP);

	if (nIndex >= 0)
	{
		CComputerInfo& computer = m_lpLocalServer->ComputerList.GetComputer(nIndex);

		if (computer.GetComputerStatus() == CComputerInfo::ECS_THIEF)
		{
			if (0 == pcr.cCode) //不通
			{
				computer.SetComputerStatus(CComputerInfo::ECS_OFFLINE);
			}
		}
		else if (computer.GetComputerStatus() == CComputerInfo::ECS_OFFLINE)
		{
			if (1 == pcr.cCode) //通
			{
				computer.SetComputerStatus(CComputerInfo::ECS_THIEF);
			}
		}

		m_lpLocalServer->ComputerList.UpdateComputer(nIndex, computer);
		m_lpLocalServer->GetComputerListView()->Refresh(FALSE);
	}
}
Exemplo n.º 2
0
void CCommandProcessor::OnTermUnLock(BYTE *pBuffer, size_t bufLen)
{
	MANAGER_COMPUT_INFO ci = {0};

	GetBody(pBuffer, &ci, sizeof(ci));

	CString strTermID = CA2W(ci.termID);
	CString strIP = CA2W(ci.IPAddr);

	INT_PTR nIndex = m_lpLocalServer->ComputerList.Find(strTermID, strIP);

	if (nIndex >= 0)
	{
		CComputerInfo& computer = m_lpLocalServer->ComputerList.GetComputer(nIndex);
		computer.Attach(ci);

		if (5 == ci.dwIDOStatus) //解锁完毕
		{
			computer.ClearUserInfo();
		}

		computer.SetComputerStatus(7 == ci.dwIDOStatus ? CComputerInfo::ECS_UNLOCK : CComputerInfo::ECS_LOCKED);

		m_lpLocalServer->ComputerList.UpdateComputer(nIndex, computer);
		m_lpLocalServer->GetComputerListView()->Refresh(FALSE);
	}

	if (7 == ci.dwIDOStatus) //解锁
	{
		NS_TTS::CIBATTS::GetInstance()->SpeakUnlock();
	}
}
Exemplo n.º 3
0
ECDRIVER_API HRESULT EncConverterConvertStringA(LPCSTR lpszConverterName, LPCSTR lpszInput, LPSTR lpszOutput, int nOutputLen)
{
    CStringW strConverterName = CA2W(lpszConverterName, 65001);
    CSilEncConverter* pEC = GetEncConverter(strConverterName);
	if (!(*pEC))
		pEC->Initialize(pEC->ConverterName, pEC->DirectionForward, pEC->NormalizeOutput);

	if (!(*pEC))
		return /*NameNotFound*/ -7;

	int nCodePage = (pEC->IsInputLegacy()) ? pEC->CodePageInput() : /* UTF8 */ 65001;

	// EncConverter's interface is easiest when wide
	CStringW strInput = CA2W(lpszInput, nCodePage);

	CStringW strOutputW;
    HRESULT hr = pEC->Convert(strInput, strOutputW);
    if (hr < 0)
        return hr;

	nCodePage = (pEC->IsOutputLegacy()) ? pEC->CodePageOutput() : /* UTF8 */ 65001;

	CStringA strOutput = CW2A(strOutputW, nCodePage);

	strncpy(lpszOutput, (LPCSTR)strOutput, nOutputLen);
	return S_OK;
}
Exemplo n.º 4
0
/**
* FUNCTION OnInitDialog
*
* @brief 
*
* @version 1.0 
*
* @author David Libby
* @date 8/2/2013 11:38:34 AM
*
* @param uMsg 
* @param wParam 
* @param lParam 
* @param bHandled 
*
* @return LRESULT 
*/
LRESULT LaserStatusDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	//SetWindowPos(HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

	GetWindowRect(&m_LargeRect);

	m_SmallRect=m_LargeRect;
	m_SmallRect.right-=SHRINK_SIZE;
	SetWindowSmall();

	GetDlgItem(IDC_STATIC_TEMP).GetClientRect(&m_StaticTempRectangle);
	GetDlgItem(IDC_STATIC_TEMP).MapWindowPoints(this->m_hWnd,(LPPOINT)&m_StaticTempRectangle,2);

	GetDlgItem(IDC_STATIC_LASER_STATUS).GetClientRect(&m_StaticLaserStatusRectangle);
	GetDlgItem(IDC_STATIC_LASER_STATUS).MapWindowPoints(this->m_hWnd,(LPPOINT)&m_StaticLaserStatusRectangle,2);


	m_Button_Start_Stop=GetDlgItem(ID_START_STOP);

	SetStartStopStatusText();



	//Prep out degrees per Pix
	int recHeight=m_StaticTempRectangle.bottom-m_StaticTempRectangle.top;
	double temprange = TOP_TEMP_C - BOTTOM_TEMP_C;
	m_dDegreesCPerPix = (double)recHeight/temprange;

	std::string WindowText="Laser Dialog ( 488 nm )";
	this->SetWindowTextW(CA2W(WindowText.c_str()).m_szBuffer);

	//HFONT MyOldTextFont = GetDlgItem(IDC_STATIC_LASER_NM).GetFont();
	//LOGFONT MyNewFontFont;
	//GetObject ( MyOldTextFont, sizeof(LOGFONT), &MyNewFontFont );
	//MyNewFontFont.lfHeight = 24 ;                    // request a 12-pixel-height font
	//_tcsncpy_s(MyNewFontFont.lfFaceName, LF_FACESIZE,  _T("Arial"), 7);
	//HFONT hCustomFont = CreateFontIndirect ( &MyNewFontFont );


	std::string Power_mW="50";
	m_Edit_Power=GetDlgItem(IDC_EDIT_POWER_MW);
	m_Edit_Power.SetWindowTextW(CA2W(Power_mW.c_str()).m_szBuffer);

	//GetDlgItem(IDC_STATIC_LASER_NM).SetFont(hCustomFont);


	if(m_OnTop)
	{
		SetWindowPos(HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
	}else
	{		
		SetWindowPos(HWND_BOTTOM,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
	}
			//::SetForegroundWindow(GetDlgItem(IDD_DIALOG_PROGRESS));
			::SetWindowPos(this->m_hWnd,HWND_TOPMOST,0,0,0,0,SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);

	return 1;
};
Exemplo n.º 5
0
void CFoosballDlg::OnTimer(UINT_PTR nIDEvent)
{
	char Count[32];
	UpdateData(TRUE);				// get tthe latest m_PositionSelection value
	GetEncoderCount(m_PositionSelection, MOVE_MOTOR, Count);
	SetDlgItemText(IDC_STATIC_MOVE_COUNT, CA2W(Count));
	GetEncoderCount(m_PositionSelection, KICK_MOTOR, Count);
	SetDlgItemText(IDC_STATIC_KICK_COUNT, CA2W(Count));
	__super::OnTimer(nIDEvent);
}
Exemplo n.º 6
0
void LaserStatusDialog::DrawTempatureScaleText(HDC &hdc,RECT DrawArea,std::string TempString)
{
	
	//DrawArea.top-=19;

	HFONT hFont, hOldFont; 

	// Retrieve a handle to the variable stock font.  
	hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); 

	LOGFONT LargeFont,SmallFont;
	GetObject ( hFont, sizeof(LOGFONT), &LargeFont );
	LargeFont.lfHeight = 20 ;                    // request a 12-pixel-height font
	_tcsncpy_s(LargeFont.lfFaceName, LF_FACESIZE,  _T("Arial"), 7);
	SmallFont=LargeFont;
	
	HFONT hCustomLargeFont = CreateFontIndirect ( &LargeFont );
	HFONT hCustomSmallFont = CreateFontIndirect ( &SmallFont );

	int gray=110;
	COLORREF OldCOlor = SetTextColor(hdc, RGB(gray,gray,gray));
	
	hOldFont = (HFONT)SelectObject(hdc, hCustomLargeFont);

	//Build a 1 pix Gray border by drawing the text sihfted in all 4 directions 
	int oldCkgroundMode = SetBkMode(hdc, TRANSPARENT);
	int pixAtound =1;
	DrawArea.top-=pixAtound;
	DrawText(hdc,CA2W(TempString.c_str()).m_szBuffer,TempString.size(),&DrawArea,DT_CENTER);
	DrawArea.top+=pixAtound;
	DrawArea.left-=pixAtound;
	DrawText(hdc,CA2W(TempString.c_str()).m_szBuffer,TempString.size(),&DrawArea,DT_CENTER);
	DrawArea.bottom+=pixAtound;
	DrawArea.left+=pixAtound;
	DrawText(hdc,CA2W(TempString.c_str()).m_szBuffer,TempString.size(),&DrawArea,DT_CENTER);
	DrawArea.bottom-=pixAtound;
	DrawArea.right+=pixAtound;
	DrawText(hdc,CA2W(TempString.c_str()).m_szBuffer,TempString.size(),&DrawArea,DT_CENTER);	
	DrawArea.right-=pixAtound;
	
	//Now draw the font black Centered.
	SetTextColor(hdc, RGB(0,0,0));
	SelectObject(hdc, hCustomSmallFont);
	DrawText(hdc,CA2W(TempString.c_str()).m_szBuffer,TempString.size(),&DrawArea,DT_CENTER);

	SetBkMode(hdc, oldCkgroundMode  );

	// Restore the original font.        
	SelectObject(hdc, hOldFont); 
	// Restore the original Color.        
	SetTextColor(hdc, OldCOlor);



}
Exemplo n.º 7
0
BOOL CFoosballDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	VERIFY(m_Exit.AutoLoad(IDEXIT, this));
	WINDOWPLACEMENT lpwndpl;
	GetWindowPlacement(&lpwndpl);
	MainWnd = this;
	ImageDC = GetDlgItem(IDC_DISPLAY)->GetDC();
	ParentWnd = GetDlgItem(IDC_DISPLAY);
	ParentWnd->GetWindowPlacement(&lpwndpl);
	ImageRect = lpwndpl.rcNormalPosition;

	// initialization must be done in this order.  cannot be changed
	Init(); 
	m_ColorTool.ColorToolInit(ParentWnd->GetDC(), ImageRect, DigSizeX, DigSizeY);
	ReadSysConfiguration();
	SetFieldPlayerMask();
	ConnectToControllers();
	for (int i = 0; i < ROWS_PLAYER; i++) {
		GetDlgItem(IDC_FORWARD + i)->EnableWindow(Device[DeviceMap[i]].IsConnected());
	}

	char Str[8];
	m_SliderMove.SetRange(-1000, 1000, TRUE);
	m_SliderKick.SetRange(-1000, 1000, TRUE);
	m_SliderPlayer.SetRange(0, 255, TRUE);
	m_SliderBall.SetRange(0, 255, TRUE);
	m_SliderMove.SetPos(0);	sprintf_s(Str, "%d", 0);	SetDlgItemText(IDC_STATIC_MOVE, CA2W(Str));
	m_SliderKick.SetPos(0);	sprintf_s(Str, "%d", 0);	SetDlgItemText(IDC_STATIC_KICK, CA2W(Str));
	m_SliderPlayer.SetPos(SC.PlayerThreshold); sprintf_s(Str, "%d", SC.PlayerThreshold);	SetDlgItemText(IDC_STATIC_PLAYER, CA2W(Str));
	m_SliderBall.SetPos(SC.BallThreshold); sprintf_s(Str, "%d", SC.BallThreshold);	SetDlgItemText(IDC_STATIC_BALL, CA2W(Str));

	m_UpdateImage = UpdateImage;
	m_UpdateGraphics = UpdateGraphics;
	m_DisplaySelection = DisplaySelection;
	m_Acquisition = Acquisition;

	// only for testing
	m_PositionSelection = BACKFIELD_ROW;

	m_MoveMotorMode = MotorMode[MOVE_MOTOR][m_PositionSelection];
	m_KickMotorMode = MotorMode[KICK_MOTOR][m_PositionSelection];
	UpdateData(FALSE);
	SetTimer(0, 200, NULL);		// Run timer to update encoder count
	return TRUE;  // return TRUE  unless you set the focus to a control
}
Exemplo n.º 8
0
void CFoosballDlg::OnBnClickedSaveImage()
{
//	OnBnClickedStop();
	char	DirectoryName[128];
	char	Filter[128];
	sprintf_s(Filter, "Bitmap Image (*.bmp)|*.bmp|| | TIFF Document (*.tif)|*.tif");
	sprintf_s(DirectoryName, "%sImages\\*.bmp", APP_DIRECTORY);
	CFileDialog dlg(FALSE, L"bmp", CA2W(DirectoryName), OFN_PATHMUSTEXIST, CA2W(Filter), NULL);
	if (dlg.DoModal() == IDOK) {
		char	FileName[512];
		strcpy_s(FileName, CT2A(dlg.GetPathName()));
		imwrite(FileName, DispBuf);
	}
}
Exemplo n.º 9
0
void CLoginWnd::ShowLoginResult(const char *szLog, ...)
{
	va_list va;
	va_start(va, szLog);
	char buffer[MAX_BUF] = { 0 };
	vsprintf(buffer, szLog, va);
	va_end(va);

	CLabelUI *pLabel = (CLabelUI *)m_PaintManager.FindControl(L"loginMsg");
	if (pLabel)
	{
		pLabel->SetText(CA2W(buffer));
		pLabel->SetToolTip(CA2W(buffer));
	}
}
Exemplo n.º 10
0
void CCommandProcessor::OnGetNewNotice(BYTE *pBuffer, size_t bufLen)
{
	CIBALog::GetInstance()->Write(_T("获取公告成功"));

	TNewNotice newNotice = {0};
	GetBody(pBuffer, &newNotice, sizeof TNewNotice);

	CString strTitle = CA2W(newNotice.cNoticeTitle);
	CString strInfo = CA2W(newNotice.cNoticeInfo);
	CString strLink = CA2W(newNotice.cNoticeLink);
	BOOL bShouldSign = BOOL(newNotice.nNoticeFlag);

	((CMainFrame*)theApp.GetMainWnd())->ShowNotice(strTitle,strInfo,strLink,bShouldSign);

}
Exemplo n.º 11
0
ECDRIVER_API HRESULT EncConverterInitializeConverterA(LPCSTR lpszConverterName, BOOL bDirectionForward, int eNormOutputForm)
{
    CStringW strConverterName = CA2W(lpszConverterName, 65001);
    CSilEncConverter* pEC = GetEncConverter(strConverterName);
    ATLASSERT(pEC != 0);
	return pEC->Initialize(strConverterName, bDirectionForward, eNormOutputForm);
}
Exemplo n.º 12
0
bool ImgConfig::parse()
{
    Json::Value value;
    LOAD_CONFIG(ConfigFile::ImgConfigPath, value);

    Json::Value jsonRoot = value["resimg"];

    if (jsonRoot == Json::nullValue)
    {
        return false;
    }

    csResPath = CA2W(jsonRoot["res_path"].asCString(), CP_UTF8).m_psz;

//     CStringA strPath;
//     int nImgId = 0;
//     int nSize = jsonRoot.size();
// 
//     for (int nIndex = 0; nIndex < nSize; ++nIndex)
//     {
//         Json::Value jsonIndexValue = jsonRoot[nIndex];
// 
//         if (jsonIndexValue == Json::nullValue)
//         {
//             continue;
//         }
// 
//         nImgId = jsonIndexValue["img_id"].asInt();
//         strPath = jsonIndexValue["img_path"].asCString();
//         mapResImg[nImgId] = CA2W(strPath, CP_UTF8).m_psz;
//         nImgId = 0;
//     }

    return true;
}
Exemplo n.º 13
0
// S_OK : 성공
// S_FALSE : 데이터는 가져왔지만 Consumer가 원하는 데이터가 아님
// E_FAIL : 실패
static HRESULT FetchData(int hReq, CTablesInfoRow &tirData, int table_type)
{
	char *value;
	int int_value;
	int ind, res;
	T_CCI_ERROR err_buf;
	
	res = cci_fetch(hReq, &err_buf);
	if(res<0) return RaiseError(E_FAIL, 1, __uuidof(IDBSchemaRowset), err_buf.err_msg);

	res = cci_get_data(hReq, 1, CCI_A_TYPE_STR, &value, &ind);
	if(res<0) return RaiseError(E_FAIL, 0, __uuidof(IDBSchemaRowset));
	wcscpy(tirData.m_szTableName, CA2W(value));
	
	res = cci_get_data(hReq, 2, CCI_A_TYPE_INT, &int_value, &ind);
	if(res<0) return RaiseError(E_FAIL, 0, __uuidof(IDBSchemaRowset));

	if (table_type >= 0 && table_type != int_value)
		return S_FALSE;

	if (int_value == 2)
		wcscpy(tirData.m_szTableType, L"TABLE");
	else if (int_value == 1)
		wcscpy(tirData.m_szTableType, L"VIEW");
	else if (int_value == 0)
		wcscpy(tirData.m_szTableType, L"SYSTEM TABLE");

	tirData.m_bBookmarks = ATL_VARIANT_TRUE;
	tirData.m_bBookmarkType = DBPROPVAL_BMK_NUMERIC;
	tirData.m_bBookmarkDatatype = DBTYPE_BYTES;
	tirData.m_bBookmarkMaximumLength = sizeof(DBROWCOUNT);

	return S_OK;
}
Exemplo n.º 14
0
void CCommandProcessor::OnLogin(BYTE* pBuffer, size_t bufLen)
{
	const CString strMinVer(_T("3.1.1.4"));

	NET_HEAD_MAN head = {0};
	GetHead(pBuffer, &head);

	if (head.Length > 0)
	{
		MANAGER_LOGIN_RESP Login_Resp = {0};
		GetBody(pBuffer, &Login_Resp, sizeof Login_Resp);

		CString strVer = CA2W(Login_Resp.szServerVer);

		if (strVer >= strMinVer)
		{
			m_lpLocalServer->LocalGetPCClassMap();
			m_lpLocalServer->LocalGetComputerList();
			return;
		}
	}

	CString strTmp;

	strTmp.Format(IDS_ISERVERLOWVER, strMinVer);

	AfxMessageBox(strTmp, MB_ICONINFORMATION);
	
	TerminateProcess(GetCurrentProcess(), 0);
}
int DocumentHost::AddCookie(const std::string& cookie) {
  LOG(TRACE) << "Entering DocumentHost::AddCookie";

  CComBSTR cookie_bstr(CA2W(cookie.c_str(), CP_UTF8));

  CComPtr<IHTMLDocument2> doc;
  this->GetDocument(&doc);

  if (!doc) {
    LOG(WARN) << "Unable to get document";
    return EUNHANDLEDERROR;
  }

  if (!this->IsHtmlPage(doc)) {
    LOG(WARN) << "Unable to add cookie, document does not appear to be an HTML page";
    return ENOSUCHDOCUMENT;
  }

  HRESULT hr = doc->put_cookie(cookie_bstr);
  if (FAILED(hr)) {
    LOGHR(WARN, hr) << "Unable to put cookie to document, call to IHTMLDocument2::put_cookie failed";
    return EUNHANDLEDERROR;
  }

  return SUCCESS;
}
void CBkInfoDownloadManager::NotifyCoreBankCtrlDLFinish(LPSTR lpBankID)
{
	ATLASSERT (NULL != lpBankID);
	if (NULL == lpBankID)
		return;

	std::string strBkID;
	strBkID = lpBankID;

	CListManager::_()->AddANewFavBank ((LPWSTR)CA2W(strBkID.c_str ()), false);
	CListManager::_()->UpdateHMac ();

	CFavBankOperator* pOper = CListManager::_()->GetFavBankOper();
	ATLASSERT (NULL != pOper);
	if (NULL == pOper)
		return;
	pOper->UpDateFavBankID (strBkID);

	CListManager::_()->CheckCom(strBkID);//尝试创建该对象,以确定是否已经将控件正确加入

	//int nTp;
	//CFavBankOperator::MyTranslateBetweenBankIDAndInt (strBkID, nTp);// 第三参数默认为true,表示将bankID转换成int

		// 用于通知主框架,用户添加收藏银行
	//SendMessage(g_hMainFrame, WM_FAV_BANK_CHANGE, 0, (LPARAM)nTp); // gao 通知框架用户收藏银行发生变化
}
Exemplo n.º 17
0
int Alert::SendKeys(std::string keys) {
  LOG(TRACE) << "Entering Alert::SendKeys";
  HWND text_box_handle = NULL;
  // Alert present, find the OK button.
  // Retry up to 10 times to find the dialog.
  int max_wait = 10;
  while ((text_box_handle == NULL) && --max_wait) {
    ::EnumChildWindows(this->alert_handle_,
                       &Alert::FindTextBox,
                       reinterpret_cast<LPARAM>(&text_box_handle));
    if (text_box_handle == NULL) {
      ::Sleep(50);
    }
  }

  if (text_box_handle == NULL) {
    LOG(WARN) << "Text box not found on alert";
    return EELEMENTNOTDISPLAYED;
  } else {
    LOG(DEBUG) << "Sending keystrokes to alert using SendMessage";
    std::wstring text = CA2W(keys.c_str(), CP_UTF8);
    ::SendMessage(text_box_handle,
                  WM_SETTEXT,
                  NULL,
                  reinterpret_cast<LPARAM>(text.c_str()));
  }
  return SUCCESS;
}
Exemplo n.º 18
0
int Element::GetAttributeValue(const std::string& attribute_name,
                               std::string* attribute_value,
                               bool* value_is_null) {
  LOG(TRACE) << "Entering Element::GetAttributeValue";

  std::wstring wide_attribute_name = CA2W(attribute_name.c_str(), CP_UTF8);
  int status_code = SUCCESS;

  // The atom is just the definition of an anonymous
  // function: "function() {...}"; Wrap it in another function so we can
  // invoke it with our arguments without polluting the current namespace.
  std::wstring script_source(L"(function() { return (");
  script_source += atoms::asString(atoms::GET_ATTRIBUTE);
  script_source += L")})();";

  CComPtr<IHTMLDocument2> doc;
  this->GetContainingDocument(false, &doc);
  Script script_wrapper(doc, script_source, 2);
  script_wrapper.AddArgument(this->element_);
  script_wrapper.AddArgument(wide_attribute_name);
  status_code = script_wrapper.Execute();
  
  CComVariant value_variant;
  if (status_code == SUCCESS) {
    *value_is_null = !script_wrapper.ConvertResultToString(attribute_value);
  } else {
    LOG(WARN) << "Failed to determine element attribute";
  }

  return SUCCESS;
}
Exemplo n.º 19
0
HRESULT ScreenshotCapture::GetBase64Data(std::wstring& data)
{
  if (m_pImage == NULL) {
    // CImage was not initialized.
    return E_POINTER;
  }
  CComPtr<IStream> stream;
  HRESULT hr = ::CreateStreamOnHGlobal(NULL, TRUE, &stream);
  if (FAILED(hr)) {
    LOG(WARN) << "Error creating IStream" << hr;
    return hr;
  }
  hr = m_pImage->Save(stream, Gdiplus::ImageFormatPNG);
  if (FAILED(hr)) {
    LOG(WARN) << "Saving image failed" << hr;
    return hr;
  }
  // Get the size of the stream.
  STATSTG statstg;
  hr = stream->Stat(&statstg, STATFLAG_DEFAULT);
  if (FAILED(hr)) {
    LOG(WARN) << "No stat on stream" << hr;
    return hr;
  }
  HGLOBAL hGlobal = NULL;
  hr = ::GetHGlobalFromStream(stream, &hGlobal);
  if (FAILED(hr)) {
    LOG(WARN) << "No HGlobal in stream" << hr;
    return hr;
  }
  // TODO: What if the file is bigger than max_int?
  LOG(INFO) << "Size of stream: " << statstg.cbSize.QuadPart;
  int length = Base64EncodeGetRequiredLength(
      statstg.cbSize.QuadPart,
      ATL_BASE64_FLAG_NOCRLF);
  if (length <= 0) {
    LOG(WARN) << "Got zero or negative length from base64 required length";
    return E_FAIL;
  }
  char *array = new char[length + 1];
  if (!::Base64Encode(
        reinterpret_cast<BYTE*>(::GlobalLock(hGlobal)),
        statstg.cbSize.QuadPart,
        array,
        &length,
        ATL_BASE64_FLAG_NOCRLF)) {
    delete array;
    ::GlobalUnlock(hGlobal);
    LOG(WARN) << "Failure encoding to base64";
    return E_FAIL;
  }
  array[length] = '\0';
  data = CA2W(array);

  delete array;
  ::GlobalUnlock(hGlobal);

  return S_OK;
}
Exemplo n.º 20
0
void CFoosballDlg::OnBnClickedLoadImage()
{
//	OnBnClickedStop();
	char	DirectoryName[128];
	char	Filter[128];
	sprintf_s(Filter, "Bitmap Image (*.bmp)|*.bmp|| | TIFF Document (*.tif)|*.tif");
	sprintf_s(DirectoryName, "%sImages\\*.bmp", APP_DIRECTORY);
	CFileDialog dlg(TRUE, NULL, CA2W(DirectoryName), OFN_PATHMUSTEXIST, CA2W(Filter), NULL);
	if (dlg.DoModal() == IDOK) {
		char	FileName[512];
		strcpy_s(FileName, CT2A(dlg.GetPathName()));
		//AfxMessageBox(FileName);
		AcqBuf = imread(FileName, -1);
		AcqBuf.copyTo(DispBuf);
		DisplayImage(DispBuf, FALSE);
	}
}
Exemplo n.º 21
0
void SearchBox::downloadSubtitle(std::string& downloadLink, std::wstring& outBuffer) 
{
	// Download the subtitle
	std::string buffer;
	
	int size = Net::download(downloadLink, &buffer);
	// Decompress the subtitle
	char buff[1024];
	std::string subBuff;
	z_stream infstream;
	infstream.zalloc = Z_NULL;
	infstream.zfree = Z_NULL;
	infstream.opaque = Z_NULL;
	infstream.avail_in = (uInt)size; // size of input
	infstream.next_in = (Bytef *)buffer.c_str(); // input char array
	infstream.avail_out = 0;//(uInt)1024; // size of output
	infstream.next_out = (Bytef *)buff; // output char array
	inflateInit2(&infstream, 16+MAX_WBITS);
	while (infstream.avail_out == 0) {
		infstream.next_out = (Bytef *)buff;
		infstream.avail_out = (uInt)1023;
		inflate(&infstream, Z_NO_FLUSH);
		subBuff.append(buff, 1023-infstream.avail_out);
	}
	inflateEnd(&infstream);

	// Encodage detection
	if (subBuff.substr(0, 3) == "") {
		outBuffer.append(CA2W(subBuff.c_str(), CP_UTF8));
	} else {
		CComPtr<IMultiLanguage2> spMLang;
 
		DetectEncodingInfo lpInfo[1];
		INT nScore = 1;
		INT nlen = subBuff.length();

		spMLang.CoCreateInstance(CLSID_CMultiLanguage);
		UINT  codePage = CP_UTF8;
		DWORD err = spMLang->DetectInputCodepage(MLDETECTCP_NONE, 0, (CHAR*)subBuff.c_str(), &nlen, lpInfo, &nScore);
		if (err == S_OK) {
			codePage = lpInfo[0].nCodePage;
		}
		outBuffer.append(CA2W(subBuff.c_str(), codePage));
	}
	boost::replace_all(outBuffer, "\r\n", "\n");
}
Exemplo n.º 22
0
CString CUtils::CalcFileP2PID( const CString& strFilePath )
{
    CString strFileP2PID;
    if (PathFileExists(strFilePath))
    {
        strFileP2PID = CA2W(GetFileP2PID(strFilePath));
    }
    return strFileP2PID;
}
Exemplo n.º 23
0
int CloURLCode::UrlDecode(std::wstring& strOut,const char* lpBuff,size_t len)
{
	strOut = L"";
	std::string outA;
	UrlDecodeA(outA, lpBuff , len);

	strOut = CA2W( outA.c_str() );
	return 0;
}
Exemplo n.º 24
0
HANDLE WINAPI MyDetourCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
                                  DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
    if (lpFileName == NULL)
        return MyOldCreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);

    CString strFileName = CA2W(lpFileName);//= CHistoryManager::GetInstance()->Redirect(CStringA(lpFileName));
    return MyDetourCreateFileW(strFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
}
Exemplo n.º 25
0
void toWStr(CTagBase::WStrT& sOutStr, TagLib::String& sInStr)
{
	if (sInStr.isEmpty())
	{
		sOutStr.clear();
		return;
	}

	if (sInStr.isAscii() || sInStr.isLatin1())
	{
		sOutStr = CA2W(sInStr.toCString());
	}
	else
	{
		sOutStr = CA2W(sInStr.toCString(true), CP_UTF8);
	}

}
Exemplo n.º 26
0
std::wstring WebDriverResponse::Serialize(void) {
	Json::Value json_object;
	json_object["status"] = this->status_code_;
	json_object["sessionId"] = this->session_id_;
	json_object["value"] = this->m_value;
	Json::FastWriter writer;
	std::string output(writer.write(json_object));
	std::wstring response(CA2W(output.c_str(), CP_UTF8));
	return response;
}
Exemplo n.º 27
0
LRESULT CLoginWnd::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	LRESULT lRes = 0;
	bHandled = FALSE;

	switch (uMsg)
	{
	case WM_SHOW_LOGIN_RESULT:
	{
		if (wParam)
		{
			LoginResult *res = (LoginResult *)wParam;

			CString str;
			str.Format(L"错误码:%d,登录失败原因:%s", lParam, CA2W(res->szMsg));
			CLabelUI *pLabel = (CLabelUI *)m_PaintManager.FindControl(L"loginMsg");
			if (pLabel)
			{
				pLabel->SetText(str);
				pLabel->SetToolTip(str);
			}

			SAFE_DELETE(res);
		}
		break;
	}
	case WM_LOGIN_SCAN_QRCODE:
		ScanQrcode(uMsg, (LoginResult *)wParam, lParam, bHandled);
		break;
	case WM_LOGIN_SUCC:
	{
		ShowLoginResult("登陆成功!");
		
		//登录成功,隐藏登录窗口,显示主窗口
		ShowWindow(SW_HIDE);
		pMainWnd->Create(NULL, _T("MicroChat"), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
		pMainWnd->ShowModal();
		delete pMainWnd;

		//准备退出主程序
		Close();

		break;
	}
	case WM_MOBILE_VERIFY:
	{
		MobileVerify(uMsg, (MobileVerifyResult *)wParam, lParam, bHandled);
		break;
	}
		
	}


	return 0;
}
Exemplo n.º 28
0
int CLDEditTxtFile::_fgets(CSimpleArray<CString>& arrFileItems)
{
	int nRet = -1;
	USES_CONVERSION;
	arrFileItems.RemoveAll();
	HANDLE hFile = INVALID_HANDLE_VALUE;
	hFile = CreateFile(m_strTxtFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if (INVALID_HANDLE_VALUE == hFile)
		return nRet;
	char *pszFileBuffer = NULL;

	do 
	{
		DWORD dwFileSize = 0;
		dwFileSize = ::GetFileSize(hFile, NULL);
		if (0 == dwFileSize || dwFileSize > 1*1024*1024)//大于1M的文件默认任务失败
			break;

		dwFileSize += 1;
		pszFileBuffer = new char[dwFileSize];
		ZeroMemory(pszFileBuffer, dwFileSize);
		DWORD dwRetSize = 0;
		if (FALSE == ReadFile(hFile, pszFileBuffer, dwFileSize, &dwRetSize, NULL) || 0 == dwRetSize)
			break;
		int nFind = -1;
		CString strValue;//(CA2W(pszFileBuffer));
		strValue = CA2W(pszFileBuffer);
		if (FALSE == strValue.IsEmpty())
			strValue += TEXT("\r\n");

		nFind = strValue.Find('\n');
		while(nFind >= 0)
		{
			if (NULL != m_pStop && TRUE == *m_pStop)
				break;

			CString strTmp;
			strTmp = strValue.Left(nFind+1);
			arrFileItems.Add(strTmp);
			strValue = strValue.Mid(nFind+1);
			nFind = -1;
			nFind = strValue.Find('\n');
		}
		nRet = 0;

	} while (FALSE);

	if (INVALID_HANDLE_VALUE != hFile)
		CloseHandle(hFile);

	hFile = NULL;
	SAFE_DELETE_ARRAY_PTR(pszFileBuffer);

	return nRet;
}
Exemplo n.º 29
0
void CCommandProcessor::OnClientDisconnect(BYTE *pBuffer, size_t bufLen)
{
	MANAGER_CLIENT_DISCONNECT mcd = {0};

	GetBody(pBuffer, &mcd, sizeof(mcd));

	CString strTermID = CA2W(mcd.termID);
	CString strIP = CA2W(mcd.termIP);

	INT_PTR nIndex = m_lpLocalServer->ComputerList.Find(strTermID, strIP);

	if (nIndex >= 0)
	{
		CComputerInfo& computer = m_lpLocalServer->ComputerList.GetComputer(nIndex);
	
		if (computer.GetMemberID() > 0) //电脑失去连接了
		{
			CActiveMember ActiveMember;

			if (m_lpLocalServer->ActiveMemberList.GetActiveMember(computer.GetMemberID(), ActiveMember))
			{
				ActiveMember.SetActive(FALSE);
				m_lpLocalServer->ActiveMemberList.UpdateActiveMember(ActiveMember, TRUE);
			}

			m_lpLocalServer->GetActiveMemberView()->Refresh(FALSE);
		}
		
		computer.SetComputerStatus(CComputerInfo::ECS_LOCKED);
		computer.SetComputerStatus(CComputerInfo::ECS_OFFLINE);
		
		if (computer.GetAvailavleBalance() == 0) //余额为0则清空用户信息
		{
			//computer.ClearUserInfo();
		}

		m_lpLocalServer->ComputerList.UpdateComputer(nIndex, computer);
		m_lpLocalServer->GetComputerListView()->Refresh(FALSE);
	}

	TRACE("OnClientDisconnect\r\n");
}
Exemplo n.º 30
-1
void CSetupsDlg::LoadFromSurveyXml()
{
	if (m_xml.surveyXml == NULL)
	{
		if (m_xml.xmlDocument.LoadFile(CW2A(m_xml.filename)))
		{
			const TiXmlElement *root = m_xml.xmlDocument.RootElement();
			if (root)
				m_xml.surveyXml = root->FirstChildElement("Survey");
		}
		else
		{
		LPCSTR error = m_xml.xmlDocument.ErrorDesc();
		MessageBox(CA2W(error), _T("Error"));
		}
	}

	if (m_xml.surveyXml)
	{
		int nSetups = 0;
		const TiXmlElement *setup = m_xml.surveyXml->FirstChildElement("InstrumentSetup");
		while (setup)
		{
			const char *sz1 = setup->Attribute("id");
			const char *sz2 = setup->Attribute("stationName");
			const char *sz3 = setup->Attribute("instrumentHeight");
			const char *sz4 = setup->Attribute("orientationAzimuth");
			InsertItem(nSetups, CA2W(sz1), CA2W(sz2), CA2W(sz3), CA2W(sz4));

			setup = setup->NextSiblingElement("InstrumentSetup");
			++nSetups;
		}
	}
}