/*****************************************************************************
* Copyright (c) 2000 Digi International Inc., All Rights Reserved
* 
* This software contains proprietary and confidential information of Digi
* International Inc.  By accepting transfer of this copy, Recipient agrees
* to retain this software in confidence, to prevent disclosure to others, 
* and to make no use of this software other than that for which it was
* delivered.  This is an unpublished copyrighted work of Digi International
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
* prohibited.
* 
* Restricted Rights Legend
*
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
* Technical Data and Computer Software clause at DFARS 252.227-7031 or
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -
* Restricted Rights at 48 CFR 52.227-19, as applicable.
*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
*
*****************************************************************************/

// PropPageUpdateAdapter.cpp : implementation file
//

#include "stdafx.h"
#include "CustomApp.h"
#include "PropPageUpdateAdapter.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPropPageUpdateAdapter property page

IMPLEMENT_DYNCREATE(CPropPageUpdateAdapter, CPropertyPageEx)
CPropPageUpdateAdapter::CPropPageUpdateAdapter() : CPropertyPageEx(CPropPageUpdateAdapter::IDD,0,IDS_TitleUpdateAdapter,IDS_SubTitleUpdateAdapter)
{
   //{{AFX_DATA_INIT(CPropPageUpdateAdapter)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CPropPageUpdateAdapter::~CPropPageUpdateAdapter()
{
}

void CPropPageUpdateAdapter::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPageEx::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPropPageUpdateAdapter)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPropPageUpdateAdapter, CPropertyPageEx)
	//{{AFX_MSG_MAP(CPropPageUpdateAdapter)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPropPageUpdateAdapter message handlers

BOOL CPropPageUpdateAdapter::OnSetActive() 
{
   CPropertySheetEx* psheet = (CPropertySheetEx*) GetParent();
   // Only enable [Next], [Back] has no meaning for us
   psheet->SetWizardButtons(PSWIZB_NEXT);
	
	return CPropertyPageEx::OnSetActive();
}

LRESULT CPropPageUpdateAdapter::OnWizardNext() 
{
   LRESULT Result;
   CWaitCursor Wait;

   // Don't want the user forever clicking while this is going...
   CPropertySheetEx* psheet = (CPropertySheetEx*) GetParent();
   psheet->SetWizardButtons(0);

   // This runs the mondo update, all PCI IDs will be checked...
   if (((CCustomAppApp *)(AfxGetApp()))->UpdateExistingAdapters())
   {
      ((CCustomAppApp *)(AfxGetApp()))->UpdateDriverVersion();
      ((CCustomAppApp *)(AfxGetApp()))->SetUpdatedAdapter(TRUE);

      // Install PAM if any adapters were updated, this ensures that the
      // PAM version, FEP and driver will be the same
      ((CCustomAppApp *)(AfxGetApp()))->InstallPamA();

      Result = ((CCustomAppApp *)(AfxGetApp()))->GetPropPageFinishedIdent();
   }
   else
   {
      Result = ((CCustomAppApp *)(AfxGetApp()))->GetPropPageUpdateDriverIdent();
   }


   return Result;
}
