Пример #1
0
BOOL CWndPromptManager::SetEditPrompt(HWND hwndEdit, LPCTSTR szPrompt)
{
	if (!CWinClasses::IsEditControl(hwndEdit))
		return FALSE;

	return SetPrompt(hwndEdit, szPrompt, WM_GETTEXTLENGTH);
}
Пример #2
0
void UBSocket::SwitchEditors()
{
    if(!m_popeditor && !m_nexteditor)
        return;

    if(m_popeditor && m_nexteditor)
    {
        Global::Get()->bug("UBSocket::SwitchEditors() was called, but we don't have both a new editor and we want to pop one?!");
        Send("Something went wrong, somehow you are switching to another editor but you're also deleting the top one?!\n");
        Send("Closing your connection now.\n");
        SetCloseAndDelete();
        return;
    }

    if(m_popeditor || m_popLast)
    {
        if(m_editors.empty()) // should never happen
        {
            Global::Get()->bug("UBSocket::SwitchEditors() was called, but we don't have a current editor?!");
            Send("Something went wrong, somehow you are switching to another editor but you don't have one set?!\n");
            Send("Closing your connection now.\n");
            SetCloseAndDelete();
            return;
        }

        delete m_editors.top();
        m_editors.pop();
        m_popeditor = false;
        m_popLast = false;
        SetPrompt(m_editors.top()->prompt());
    }

    if(m_nexteditor)
    {
        m_editors.push(m_nexteditor);
        m_nexteditor = NULL;
        SetPrompt(m_editors.top()->prompt());
    }

    m_editors.top()->OnFocus();

    if(m_nexteditor)
        SwitchEditors();
    else
        SendPrompt();
}
Пример #3
0
TDSPInt::TDSPInt(const char* appClassName, 
		 int* argc, char** argv,
		 void* options, 
		 int numOptions,
		 Bool_t noLogo) : TRint(appClassName, argc, argv, options, numOptions, kTRUE) {

  SetPrompt("tdsp [%d] > ");
  if (!noLogo) PrintLogo();
}
Пример #4
0
BOOL CWndPromptManager::SetComboEditPrompt(HWND hwndCombo, LPCTSTR szPrompt)
{
	CString sClass = CWinClasses::GetClass(hwndCombo);

	if (!CWinClasses::IsClass(sClass, WC_COMBOBOX) && 
		!CWinClasses::IsClass(sClass, WC_COMBOBOXEX))
		return FALSE;

	return SetPrompt(1001, hwndCombo, szPrompt, WM_GETTEXTLENGTH);
}
Пример #5
0
void UBSocket::PopEditor()
{
    if(m_popeditor)
    {
        Global::Get()->bug("UBSocket::PopEditor() was called, but the top editor is already being popped?!");
        Send("Something went wrong, somehow you are popping the top editor but it was already being popped?!\n");
        Send("Closing your connection now.\n");
        SetCloseAndDelete();
        return;
    }

    m_popeditor = true;
    SetPrompt();
}
Пример #6
0
void UBSocket::SetEditor(Editor* edit, bool popLast)
{
    if(m_nexteditor)
    {
        Global::Get()->bug("UBSocket::SetEditor() was called while we are already waiting to switch to a next editor!\n");
        Send("Something went wrong, somehow you are switching to another editor while you were already doing just that!\n");
        Send("Closing your connection now.\n");
        SetCloseAndDelete();
        return;
    }

    SetPrompt();
    m_nexteditor = edit;
    m_popLast = popLast;
    return;
}
Пример #7
0
BOOL CFileServerDlg::OnInitDialog()
{
	try
	{
		CBaseDlg::OnInitDialog();

		SetControlThread(&m_ControlThread);
		m_ControlThread.SetServerSocket(&m_ServerCtrlSocket);
		m_ControlThread.m_MSGNotifyWnd = m_MsgNotifyWnd;
		m_ControlThread.m_nQuitMessageID = m_nQuitMessageID;
		BuildConnect(m_nCtrlPort);

		if(StrCmp(gl_strLanguageId, CHINESE) == 0)
			SetWindowText(szFileTransferText_CH);
		else
			SetWindowText(szFileTransferText_EN);
		m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
		SetIcon(m_hIcon, TRUE);			// Set big icon
		SetIcon(m_hIcon, FALSE);		// Set small icon

		// TODO:  在此添加额外的初始化

		if(StrCmp(gl_strLanguageId, CHINESE) == 0)
			m_UIHelper = new CUIHelper(IDR_GIFMAP_SSBK);
		else
			m_UIHelper = new CUIHelper(IDR_GIFMAP_SSBKEN);

		this->InitUI();
		this->InitList();
		SetPrompt(false,m_hWnd);
		SetForegroundWindow();

		SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);

		SetTimer(1, 500, NULL);

		if (gl_pLogger)
			gl_pLogger->log_info("CFileServerDlg::OnInitDialog");
		return TRUE;  // return TRUE unless you set the focus to a control
	}
	catch(...)
	{
		if (gl_pLogger) gl_pLogger->log_error("CFileServerDlg::OnInitDialog unknown exception.");
	}
	return FALSE;
	// 异常: OCX 属性页应返回 FALSE
}
Пример #8
0
BOOL CWndPromptManager::SetComboPrompt(HWND hwndCombo, LPCTSTR szPrompt)
{
	CString sClass = CWinClasses::GetClass(hwndCombo);

	if (!CWinClasses::IsClass(sClass, WC_COMBOBOX) && 
		!CWinClasses::IsClass(sClass, WC_COMBOBOXEX))
		return FALSE;

	// if the combo has an edit field then this is where the 
	// prompt must be set
	UINT nStyle = GetWindowLong(hwndCombo, GWL_STYLE);

	if ((nStyle & 0xf) != CBS_DROPDOWNLIST)
		return SetComboEditPrompt(hwndCombo, szPrompt);
	
	// else
	return SetPrompt(hwndCombo, szPrompt, WM_GETTEXTLENGTH);
}
Пример #9
0
	void CEditUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
	{
		if( _tcscmp(pstrName, _T("readonly")) == 0 ) SetReadOnly(_tcscmp(pstrValue, _T("true")) == 0);
		else if( _tcscmp(pstrName, _T("numberonly")) == 0 ) SetNumberOnly(_tcscmp(pstrValue, _T("true")) == 0);
		else if( _tcscmp(pstrName, _T("password")) == 0 ) SetPasswordMode(_tcscmp(pstrValue, _T("true")) == 0);
		else if( _tcscmp(pstrName, _T("maxchar")) == 0 ) SetMaxChar(_ttoi(pstrValue));
		else if( _tcscmp(pstrName, _T("normalimage")) == 0 ) SetNormalImage(pstrValue);
		else if( _tcscmp(pstrName, _T("hotimage")) == 0 ) SetHotImage(pstrValue);
		else if( _tcscmp(pstrName, _T("focusedimage")) == 0 ) SetFocusedImage(pstrValue);
		else if( _tcscmp(pstrName, _T("disabledimage")) == 0 ) SetDisabledImage(pstrValue);
		else if( _tcscmp(pstrName, _T("nativebkcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetNativeEditBkColor(clrColor);
		}
		else if( _tcscmp(pstrName, _T("prompt")) ==0 ) SetPrompt(pstrValue);
		else CLabelUI::SetAttribute(pstrName, pstrValue);
	}
Пример #10
0
void CFrmLogin::slotClientError(CClient::ERROR_TYPE e)
{
    QString szMsg;
    switch (e)
    {
    case CClient::NetworkError:
        szMsg = tr("Network error");
        break;
    case CClient::KeepAliveError:
        szMsg = tr("Keep active error");
        break;
    case CClient::LoginFail:
        szMsg = tr("Login fail");
        break;
    case CClient::NotAuthorized:
        szMsg = tr("Username or Password error");
        break;
    default:
        break;
    }
    SetPrompt(szMsg);
}
Пример #11
0
bool CFileServer::ResponseS2C()
{
	try
	{
		FileRequest filerequest;
		bool bResult = m_pServerSocket->ReadExact(m_pServerSocket->GetWorkingSocket(), (char*)(&filerequest), sizeof(filerequest));
		if(!bResult)
			return false;

		FileToSend fileInfo;
		if (!m_pServerSocket->ReadExact(m_pServerSocket->GetWorkingSocket(), (char*)(&fileInfo), sizeof(fileInfo)))
		{
			return false;
		}

		//gl_llSize = fileInfo.llStart;
		gl_mapllSize[m_hWnd] = fileInfo.llStart;
		bool bSending, bReceive;
		SendMessage(m_hWnd, WM_GETSENDING, (WPARAM)&bSending, 0);
		SendMessage(m_hWnd, WM_GETRECEIVE, (WPARAM)&bReceive, 0);
		if(bSending || bReceive)
		{
			return PackAndSendHeader(m_pServerSocket->GetWorkingSocket(), CMD_REJECTWHENNOTFREE, false);
		}

		CString strPath = filerequest.FilePath;
		CString strPathName = filerequest.FileName;
		if(strPath.Right(1) != _T("\\"))
			strPath = strPath + _T("\\");
		strPathName = strPath + strPathName;
		BasicFileInfo info;
		CString strFileName = strPathName;
		strcpy_s(info.FileName, sizeof(info.FileName), strFileName);
		info.Size = 0;
		CFile file;
		if(file.Open(strPathName, CFile::modeRead))
		{
			info.Size = file.GetLength();
			file.Close();
		}
		State state;
		state = State::RequestGet;
		SendMessage(m_hWnd, WM_ADDLISTITEM, (WPARAM)&info, (LPARAM)&state);
		SendMessage(m_hWnd, WM_SETSENDING, 1, 0);

		this->m_strSendFileName = fileInfo.FileName;

		CString strMsg = GetAskMessage(false, filerequest.FilePath, filerequest.FileName);
		//This code is different from rising version.
		//if(IDYES == MessageBox(NULL, strMsg, _T("询问提示"), MB_YESNO))
		CPromptDlg dlg;
		dlg.SetHwnd(m_hWnd);
		SetPrompt(true,m_hWnd);
		dlg.SetMsgText(strMsg);

		bool bAccept = gl_bAutoControl ? true : (IDOK == dlg.DoModal());
		if(bAccept)
		{
			PostMessage(m_hWnd, WM_CLOSEPROMPTDLG, 0, 0);
			m_strSendPath = filerequest.FilePath;
			SetPrompt(false,m_hWnd);
			return PackAndSendRequest(CMD_PARAM_TRANSFILE_S2C_ACEEPT);
		}
		else
		{
			State state;
			state = State::RejectGet;
			SendMessage(m_hWnd, WM_SETLISTITEM, (WPARAM)&fileInfo, (LPARAM)&state);
			SendMessage(m_hWnd, WM_SETSENDING, 0, 0);
			SetPrompt(false,m_hWnd);
			PostMessage(m_hWnd, WM_CLOSEPROMPTDLG, 0, 0);
			return PackAndSendRequest(CMD_PARAM_TRANSFILE_S2C_REJECT);
		}
		return true;
	}
	catch(...)
	{
		if (gl_pLogger)
			gl_pLogger->log_info("CFileServer::ResponseS2C() unkown exception.");
	}
	return false;
}
Пример #12
0
bool CFileServer::ResponseC2S()
{
	try
	{
		FileRequest filerequest;
		bool bResult = m_pServerSocket->ReadExact(m_pServerSocket->GetWorkingSocket(), (char*)(&filerequest), sizeof(filerequest));
		if(!bResult)
			return false;

		BasicFileInfo fileInfo;
		if (!m_pServerSocket->ReadExact(m_pServerSocket->GetWorkingSocket(), (char*)(&fileInfo), sizeof(BasicFileInfo)))
		{
			return false;
		}
		this->m_strRecFileName = fileInfo.FileName;
		//gl_bOverWrite = fileInfo.bOverWrite;
		gl_mapOverWrite[m_hWnd] = fileInfo.bOverWrite;
		bool bSending, bReceive;
		SendMessage(m_hWnd, WM_GETSENDING, (WPARAM)&bSending, 0);
		SendMessage(m_hWnd, WM_GETRECEIVE, (WPARAM)&bReceive, 0);
		if(bSending || bReceive)
		{
			return PackAndSendHeader(m_pServerSocket->GetWorkingSocket(), CMD_REJECTWHENNOTFREE, false);
		}

		State state;
		state = State::CRequestSend;

		BasicFileInfo info;
		info.bOverWrite = fileInfo.bOverWrite;
		info.CreationTime = fileInfo.CreationTime;

		CString strPath = this->m_strReceivePath;
		if (strPath.Right(1) != _T("\\"))
			strPath = strPath + _T("\\");
		strPath = strPath + fileInfo.FileName;
		lstrcpy(info.FileName, strPath);
		info.Size = fileInfo.Size;

		SendMessage(m_hWnd, WM_ADDLISTITEM, (WPARAM)&info, (LPARAM)&state);
		SendMessage(m_hWnd, WM_SETRECEIVE, 1, 0);
		m_FileInfo = fileInfo;

		CString strMsg = GetAskMessage(true, filerequest.FilePath, m_strRecFileName);
		CPromptDlg dlg;
		dlg.SetMsgText(strMsg);
		dlg.SetHwnd(m_hWnd);
		SetPrompt(true,m_hWnd);
		bool bAccept = gl_bAutoControl ? true : (IDOK == dlg.DoModal());
		if(bAccept)
		{
			PostMessage(m_hWnd, WM_CLOSEPROMPTDLG, 0, 0);
			SetPrompt(false,m_hWnd);
			//don't need to show ask dialog.
			PostMessage(m_hWnd, WM_CLOSEPROMPTDLG, 0, 0);
			bool bRes = PackAndSendRequest(CMD_PARAM_TRANSFILE_C2S_ACEEPT);
			if (!bRes)
				return false;

			bool bOverWrite = false;
			if (gl_mapOverWrite.find(m_hWnd) != gl_mapOverWrite.end())
			{
				bOverWrite = gl_mapOverWrite[m_hWnd];
			}
			else
			{
				bOverWrite = false;
			}

			//if (!gl_bOverWrite)
			if (!bOverWrite)
			{
				CString strFileName = filerequest.FilePath;
				strFileName = strFileName + _T("\\");
				strFileName = strFileName + m_strRecFileName;
				CFile file;
				if (!file.Open(strFileName, CFile::modeRead))
					//gl_llSize = 0;
					gl_mapllSize[m_hWnd] = 0;
				else
				{
					//gl_llSize = file.GetLength();
					gl_mapllSize[m_hWnd] = file.GetLength();
					file.Close();
				}
			}
			else
				//gl_llSize = 0;
				gl_mapllSize[m_hWnd] = 0;
			FileTransProgress progress;
			ULONGLONG ullSize = 0;
			if (gl_mapllSize.find(m_hWnd) != gl_mapllSize.end())
			{
				ullSize = gl_mapllSize[m_hWnd];
			}
			progress.uDataRead = ullSize;
			if (!m_pServerSocket->WriteExact(m_pServerSocket->GetWorkingSocket(), (char*)(&progress), sizeof(FileTransProgress)))
			{
				return false;
			}
			return true;
		}
		else
		{
			SetPrompt(false,m_hWnd);
			PostMessage(m_hWnd, WM_CLOSEPROMPTDLG, 0, 0);
			SendMessage(m_hWnd, WM_SETRECEIVE, 0, 0);
			State state;
			state = State::SRejectReceive;
			SendMessage(m_hWnd, WM_SETLISTITEM, (WPARAM)&fileInfo, (LPARAM)&state);
			PostMessage(m_hWnd, WM_CLOSEPROMPTDLG, 0, 0);
			return PackAndSendRequest(CMD_PARAM_TRANSFILE_C2S_REJECT);
		}
		return false;

		//

		while(1)
		{
			CFileAskDlg askdlg;
			askdlg.SetRapperHwnd(m_hWnd);
			CString strMsg = GetAskMessage(true, filerequest.FilePath, m_strRecFileName);
			askdlg.SetMsgText(strMsg);
			askdlg.m_strDistinationFolder = filerequest.FilePath;
			askdlg.m_strFileName = m_strRecFileName;
			SetPrompt(true,m_hWnd);

			bool bAccept = gl_bAutoControl ? true : (IDOK == askdlg.DoModal());
			if(bAccept)
			{
				m_strReceivePath = askdlg.m_strDistinationFolder; 
				SetPrompt(false,m_hWnd);
				PostMessage(m_hWnd, WM_CLOSEPROMPTDLG, 0, 0);
				return PackAndSendRequest(CMD_PARAM_TRANSFILE_C2S_ACEEPT);
			}
			else
			{
				SetPrompt(false,m_hWnd);
				PostMessage(m_hWnd, WM_CLOSEPROMPTDLG, 0, 0);
				SendMessage(m_hWnd, WM_SETRECEIVE, 0, 0);
				State state;
				state = State::SRejectReceive;
				SendMessage(m_hWnd, WM_SETLISTITEM, (WPARAM)&fileInfo, (LPARAM)&state);
				return PackAndSendRequest(CMD_PARAM_TRANSFILE_C2S_REJECT);
			}
		}
		return true;
	}
	catch(...)
	{
		if (gl_pLogger)
			gl_pLogger->log_info("CFileServer::ResponseC2S() unkown exception.");
	}
	return false;
}
Пример #13
0
_bool ExecuteInternal( char** command, char** varlist )
{
    _bool isShellCMD = FALSE;

    /* is a comment, ignore following */
    if ( command[0][0] == '%' ){
        isShellCMD = TRUE;
        return isShellCMD;
    }

    if ( strcmp( command[0], "setvar" ) == 0 ){
        isShellCMD = TRUE;

        if ( command[1] == NULL ||
             command[2] == NULL ){

            printf("\tUnable to set variable, missing argument\n");
            return isShellCMD;
        }

        //snprintf( *varlist[0], sizeof(char) * ( BUFFER_LENGTH ),  "%s", command[1] );
        //snprintf( varlist->value[index], sizeof varlist->value[index], "%s", command[2] );
    }

    /* set prompt string */
    if ( strcmp( command[0], "setprompt" ) == 0 ){
        isShellCMD = TRUE;

        if ( command[1] == NULL ){
            printf("\tUnable to set prompt, missing argument\n");
            return isShellCMD;
        }

        SetPrompt( command[1] );
    }

    if ( strcmp( command[0], "echocmd" ) == 0 ){
        isShellCMD = TRUE;

        if ( command[1] == NULL ){
            printf("\tUnable to set echocmd, missing argument\n");
            return isShellCMD;
        }

        if ( strcmp( command[1], "on" ) == 0 ){
            echo = TRUE;

            printf("\tcommand echoing enabled\n");
        }

        if ( strcmp( command[1], "off" ) == 0 ){
            echo = FALSE;

            printf("\tcommand echoing disabled\n");
        }
    }

    if ( strcmp( command[0], "parsecmd" ) == 0 ){
        isShellCMD = TRUE;

        if ( command[1] == NULL ){
            printf("\tUnable to set parsecmd, missing argument\n");
            return isShellCMD;
        }

        if ( strcmp( command[1], "on" ) == 0 ){
            parse = TRUE;

            printf("\tcommand parsing enabled\n");
        }

        if ( strcmp( command[1], "off" ) == 0 ){
            parse = FALSE;

            printf("\tcommand parsing disabled\n");
        }
    }

    if ( strcmp( command[0], "showchild" ) == 0 ){
        isShellCMD = TRUE;

        if ( command[1] == NULL ){
            printf("\tUnable to set showchild, missing argument\n");
            return isShellCMD;
        }

        if ( strcmp( command[1], "on" ) == 0 ){
            child = TRUE;

            printf("\tchild info enabled\n");
        }

        if ( strcmp( command[1], "off" ) == 0 ){
            child = FALSE;

            printf("\tchild info disabled\n");
        }
    }

    if ( strcmp( command[0], "cd" ) == 0 ){
        isShellCMD = TRUE;

        if ( command[1] == NULL ){
            printf("\tUnable to change directory, missing destination\n");
            return isShellCMD;
        }

        if ( chdir( command[1] ) == 0 ){
            if ( DEBUG_LEVEL > 0 ){
                printf("\tDIRECTORY CHANGED TO: %s\n", command[1] );
            }
        } else {
            printf("\tERROR: directory change failed\n");
        }
    }

    if ( strcmp( command[0], "exit" ) == 0 ||
         strcmp( command[0], "EOF" ) == 0 ){

        isShellCMD = TRUE;
        EXIT_STATUS = 1;
    }

    if ( DEBUG_LEVEL > 0 && isShellCMD ){
        printf("SHELL COMMAND EXECUTED: %s\n", command[0]);
    }

    return isShellCMD;
}
Пример #14
0
BOOL CWndPromptManager::SetPrompt(UINT nIDCtrl, HWND hwndParent, UINT nIDPrompt, UINT nCheckMsg, 
								  LRESULT lRes, int nVertOffset)
{
	return SetPrompt(nIDCtrl, hwndParent, CEnString(nIDPrompt), nCheckMsg, lRes, nVertOffset);
}
Пример #15
0
BOOL CWndPromptManager::SetPrompt(UINT nIDCtrl, HWND hwndParent, LPCTSTR szPrompt, UINT nCheckMsg, 
								  LRESULT lRes, int nVertOffset)
{
	return SetPrompt(GetDlgItem(hwndParent, nIDCtrl), szPrompt, nCheckMsg, lRes, nVertOffset);
}
Пример #16
0
BOOL CWndPromptManager::SetPrompt(HWND hWnd, UINT nIDPrompt, UINT nCheckMsg, LRESULT lRes, int nVertOffset)
{
	return SetPrompt(hWnd, CEnString(nIDPrompt), nCheckMsg, lRes, nVertOffset);
}