コード例 #1
0
void CPPgNTService::LoadSettings(void)
{
	if(m_hWnd)
	{
		if(thePrefs.GetServiceStartupMode()==2) 
		{
			CheckDlgButton(IDC_SVC_RUNBROWSER   ,BST_UNCHECKED );
			CheckDlgButton(IDC_SVC_REPLACESERVICE, BST_CHECKED);
		}
		else
		{
			CheckDlgButton(IDC_SVC_RUNBROWSER   ,BST_CHECKED );
			CheckDlgButton(IDC_SVC_REPLACESERVICE, BST_UNCHECKED);
		}

		//MORPH START - Added by Stulle, Adjustable NT Service Strings
		GetDlgItem(IDC_SERVICE_NAME)->SetWindowText(thePrefs.GetServiceName());
		GetDlgItem(IDC_SERVICE_DISP_NAME)->SetWindowText(thePrefs.GetServiceDispName());
		GetDlgItem(IDC_SERVICE_DESCR)->SetWindowText(thePrefs.GetServiceDescr());
		//MORPH END   - Added by Stulle, Adjustable NT Service Strings


    	FillStatus();
		m_bIsInit = true;
	}
}
コード例 #2
0
void CPPgNTService::OnBnClickedUnInstall()
{
	if (CmdRemoveService()==0) {
		FillStatus();
		SetModified();
	}
	else
		SetDlgItemText(IDC_SVC_CURRENT_STATUS,GetResString(IDS_SVC_UNINSTALLFAILED)); 

}
コード例 #3
0
ファイル: AgentExecutor.cpp プロジェクト: Skier/vault_repo
bool AgentExecutor::RequestStatus() {
    if (!IsConnected() ) {
		if ( !Login() ) {
			return false;
        }
    }      
        
	while ( true ) {
		try {
			std::auto_ptr<EdiResponse> res(GetAgent().GetStatus());

			if ( res->GetCode() == ADVPCS_STATUS_OK - ADVPCS_BASE ) {
				FillStatus(res.get());
				return true;
			}

			if ( res->GetCode() == ADVPCS_STATUS_NOT_AVAILABLE_ERR - ADVPCS_BASE ) {
				return false;
			}

			::wxMessageBox(wxString::Format("[%ld] %s", res->GetCode(), res->GetMessage()), 
									   ADVPCS_ERROR_TITLE, 
									   wxOK | wxCENTRE | wxICON_ERROR);

			if ( res->GetCode() == ADVPCS_LOGIN_AUTH_ERR - ADVPCS_BASE ) {
//				|| res->GetCode() == ADVPCS_STATUS_AUTH_ERR - ADVPCS_BASE ) {
				m_connected = false;
                if ( !Login() ) {
					return false;
				} else {
					continue;
				}
			}
			m_connected = false;
			return false;

		} catch ( CXmlLoadException&  ) {
			wxMessageBox(ADVPCS_UNEXPECTED_REPLY_MSG, ADVPCS_ERROR_TITLE,
						  wxOK | wxCENTRE | wxICON_ERROR );
			m_connected = false;
			return false;
		} catch ( CAtfException& ex) {
			wxMessageBox((const char*)ex.GetText(), ADVPCS_ERROR_TITLE,
						  wxOK | wxCENTRE | wxICON_ERROR );
			m_connected = false;
			return false;
		};
	};
};
コード例 #4
0
void CPPgNTService::OnBnClickedInstall()
{
	OnApply(); // MORPH - Added by Stulle, Adjustable NT Service Strings
	if (CmdInstallService((IsDlgButtonChecked(IDC_SVC_STARTWITHSYSTEM))==BST_CHECKED )==0)
	{
		FillStatus();
		if(AfxMessageBox(GetResString(IDS_APPLY_SETTINGS),MB_YESNO) == IDYES)
			OnBnAllSettings();
		SetModified();
		if (thePrefs.m_nCurrentUserDirMode == 0) // my documents and running as a service is not a good idea. but leave it to user
			AfxMessageBox(GetResString(IDS_CHANGEUSERASSERVICE),MB_OK);
	}
	else
		SetDlgItemText(IDC_SVC_CURRENT_STATUS,GetResString(IDS_SVC_INSTALLFAILED)); 
}
コード例 #5
0
ファイル: AgentExecutor.cpp プロジェクト: Skier/vault_repo
bool AgentExecutor::Login(){
	m_connected = false;

	LoginFrame* login = new LoginFrame(::wxTheApp->GetTopWindow(), m_logon);
    while (true) {
		if ( !(wxID_OK == login->ShowModal()) ) {
			 return false;
		}
		try {
			std::auto_ptr<EdiResponse> res(GetAgent().Login(m_logon.GetLogin(), m_logon.GetPassword()));
			if ( res->GetCode() == ADVPCS_LOGIN_OK - ADVPCS_BASE ) {
				FillStatus(res.get());
				m_connected = true;
				return true;
			}

			::wxMessageBox(wxString::Format("[%ld] %s", res->GetCode(), res->GetMessage()), 
						   ADVPCS_ERROR_TITLE, 
						   wxOK | wxCENTRE | wxICON_ERROR);

			if ( res->GetCode() == ADVPCS_LOGIN_PSWD_EXPIRED_ERR - ADVPCS_BASE ) {
				return ChangePassword();
			}
			if ( res->GetCode() != ADVPCS_LOGIN_AUTH_ERR - ADVPCS_BASE ) {
				m_connected = false;
				return false;
			}

		} catch ( CXmlLoadException& ) {
			::wxMessageBox(ADVPCS_UNEXPECTED_REPLY_MSG, ADVPCS_ERROR_TITLE,
						  wxOK | wxCENTRE | wxICON_ERROR );
			return false;
		} catch (CAtfException& ex) {
			::wxMessageBox((const char*)ex.GetText(), ADVPCS_ERROR_TITLE,
						 wxOK | wxCENTRE | wxICON_ERROR );
			return false;
		}
	};
    wxDELETE(login);
    return false;
};
コード例 #6
0
ファイル: AgentExecutor.cpp プロジェクト: Skier/vault_repo
bool AgentExecutor::ChangePassword() {
    PassUpdateFrame* passwd = new PassUpdateFrame(wxTheApp->GetTopWindow(), m_logon);
    try {
		while(true) {
			if ( !(wxID_OK == passwd->ShowModal()) ) {
				return false;
			}
#if 0
			if ( !Login(m_logon.GetLogin(), m_logon.GetPassword()) ) {
				continue;
			}
#else
			if ( !IsConnected() ) {
				std::auto_ptr<EdiResponse> res(GetAgent().Login(m_logon.GetLogin(), m_logon.GetPassword()));
				if ( res->GetCode() == ADVPCS_LOGIN_OK - ADVPCS_BASE ) {
					m_connected = true;
				}
				if ( res->GetCode() == ADVPCS_LOGIN_AUTH_ERR - ADVPCS_BASE ) {
					::wxMessageBox(wxString::Format("[%ld] %s", res->GetCode(), res->GetMessage()), 
								   ADVPCS_ERROR_TITLE, 
								   wxOK | wxCENTRE | wxICON_ERROR);
					continue;
				}
				if ( !( res->GetCode() == ADVPCS_LOGIN_PSWD_EXPIRED_ERR - ADVPCS_BASE 
				    || res->GetCode() == ADVPCS_LOGIN_OK - ADVPCS_BASE ) ) 
				{
					::wxMessageBox(wxString::Format("[%ld] %s", res->GetCode(), res->GetMessage()), 
								   ADVPCS_ERROR_TITLE, 
								   wxOK | wxCENTRE | wxICON_ERROR);
					return false;
				}
			}
#endif
			std::auto_ptr<EdiResponse> res(GetAgent().ChangePassword(m_logon.GetLogin(), m_logon.GetPassword(), m_logon.GetNewPassword()));

    		if ( res->GetCode() == ADVPCS_PSWD_OK - ADVPCS_BASE ) {
				FillStatus(res.get());
				m_connected = true;
				::wxMessageBox(ADVPCS_CHANGE_PSWD_OK);
				return true;
			}
 		    ::wxMessageBox(wxString::Format("[%ld] %s", res->GetCode(), res->GetMessage()), 
						   ADVPCS_ERROR_TITLE, 
						   wxOK | wxCENTRE | wxICON_ERROR);
			if ( res->GetCode() == ADVPCS_PSWD_INVALID_ERR - ADVPCS_BASE 
				|| res->GetCode() == ADVPCS_PSWD_DUPLICATE_ERR - ADVPCS_BASE ) 
			{
				continue;
			}
			if ( res->GetCode() == ADVPCS_LOGIN_AUTH_ERR - ADVPCS_BASE  ) {
				m_connected = false;
				continue;
			}
			return false;
		}
	} catch ( CXmlLoadException&  ) {
		wxMessageBox(ADVPCS_UNEXPECTED_REPLY_MSG, ADVPCS_ERROR_TITLE,
					 wxOK | wxCENTRE | wxICON_ERROR );
			return false;
	} catch (CAtfException& ex) {
		wxMessageBox((const char*)ex.GetText(), ADVPCS_ERROR_TITLE,
					 wxOK | wxCENTRE | wxICON_ERROR );
			return false;
	}
	wxDELETE(passwd);
	return false;
};
コード例 #7
0
BOOL CPPgNTService::OnApply()
{
	if(m_bModified)
	{
		int b_installed;
		int  i_startupmode;
		int rights;
		// Startup with system, store in service.
		NTServiceGet(b_installed,i_startupmode,	rights);

		//MORPH START - Added by Stulle, Adjustable NT Service Strings
		CString strServiceName, strServiceDispName, strServiceDescr;
		GetDlgItem(IDC_SERVICE_NAME)->GetWindowText(strServiceName);
		GetDlgItem(IDC_SERVICE_DISP_NAME)->GetWindowText(strServiceDispName);
		GetDlgItem(IDC_SERVICE_DESCR)->GetWindowText(strServiceDescr);

		int iChangedStr = 0; // nothing changed
		if(strServiceName.Compare(thePrefs.GetServiceName()) != 0)
			iChangedStr = 1; // name under which we install changed, this is important!
		else if((strServiceDispName.Compare(thePrefs.GetServiceDispName()) != 0) || (strServiceDescr.Compare(thePrefs.GetServiceDescr()) != 0))
			iChangedStr = 2; // only visual strings changed, not so important...

		if(iChangedStr>0)
		{
			if(b_installed == 0)
			{
				thePrefs.SetServiceName(strServiceName);
				thePrefs.SetServiceDispName(strServiceDispName);
				thePrefs.SetServiceDescr(strServiceDescr);
				FillStatus();
			}
			else
			{
				int iResult = IDCANCEL;
				if(iChangedStr == 1)
					iResult = MessageBox(GetResString(IDS_SERVICE_NAME_CHANGED),GetResString(IDS_SERVICE_STR_CHANGED),MB_YESNOCANCEL|MB_ICONQUESTION|MB_DEFBUTTON3);
				else if(iChangedStr == 2)
				{
					if(NTServiceChangeDisplayStrings(strServiceDispName,strServiceDescr) != 0)
					{
						if(MessageBox(GetResString(IDS_SERVICE_DISP_CHANGE_FAIL),GetResString(IDS_SERVICE_STR_CHANGE_FAIL),MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2) == IDYES)
						{
							iChangedStr = 1;
							iResult = IDYES;
						}
					}
					else
						iResult = IDNO;
				}

				if(iChangedStr == 1 && iResult == IDYES) // reinstall service
				{
					if(CmdRemoveService()==0)
					{
						thePrefs.SetServiceName(strServiceName);
						thePrefs.SetServiceDispName(strServiceDispName);
						thePrefs.SetServiceDescr(strServiceDescr);
						if(CmdInstallService(i_startupmode == 1) != 0)
							MessageBox(GetResString(IDS_SERVICE_INSTALL_FAIL), GetResString(IDS_SERVICE_INSTALL_TITLE), MB_OK|MB_ICONWARNING);
					}
					else
					{
						MessageBox(GetResString(IDS_SERVICE_UNINSTALL_FAIL),GetResString(IDS_SERVICE_UNINSTALL_TITLE),MB_OK|MB_ICONWARNING);
						GetDlgItem(IDC_SERVICE_NAME)->SetWindowText(thePrefs.GetServiceName());
						GetDlgItem(IDC_SERVICE_DISP_NAME)->SetWindowText(thePrefs.GetServiceDispName());
						GetDlgItem(IDC_SERVICE_DESCR)->SetWindowText(thePrefs.GetServiceDescr());
					}
					FillStatus();
				}
				else if(iResult == IDNO) // just save settings
				{
					thePrefs.SetServiceName(strServiceName);
					thePrefs.SetServiceDispName(strServiceDispName);
					thePrefs.SetServiceDescr(strServiceDescr);
					FillStatus();
				}
				else // revert settings
				{
					GetDlgItem(IDC_SERVICE_NAME)->SetWindowText(thePrefs.GetServiceName());
					GetDlgItem(IDC_SERVICE_DISP_NAME)->SetWindowText(thePrefs.GetServiceDispName());
					GetDlgItem(IDC_SERVICE_DESCR)->SetWindowText(thePrefs.GetServiceDescr());
				}
			}
		}
		//MORPH END   - Added by Stulle, Adjustable NT Service Strings

		if (b_installed==1 && 
				(i_startupmode ==0 && (IsDlgButtonChecked(IDC_SVC_STARTWITHSYSTEM)==BST_CHECKED))||
				(i_startupmode ==1 && (IsDlgButtonChecked(IDC_SVC_MANUALSTART)==BST_CHECKED)))
			NTServiceSetStartupMode(IsDlgButtonChecked(IDC_SVC_STARTWITHSYSTEM)==BST_CHECKED);
	   // TODO: Apply setting 
		if ( IsDlgButtonChecked(IDC_SVC_RUNBROWSER)==BST_CHECKED)
		   thePrefs.m_iServiceStartupMode=1;
		else 
		   thePrefs.m_iServiceStartupMode=2;

		int iSel = m_cbOptLvl.GetCurSel();
		thePrefs.m_iServiceOptLvl = m_cbOptLvl.GetItemData(iSel);

		SetModified(FALSE);
		LoadSettings();
	}
	return CPropertyPage::OnApply();
}