Example #1
0
LRESULT CMainDlg::OnOpenUpdate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	CUpdateDlg *updlg = new CUpdateDlg;
	updlg->Create(m_hWnd);
	updlg->ShowWindow(SW_SHOW);
	return 0;
}
DWORD WINAPI LoadUpdate (LPVOID param)
{
  CUpdateDlg* dlg = (CUpdateDlg*) param;

  if (dlg->autoCheck)
    UpdateVersion (NULL);

  char buf[2048];
  sprintf (buf, "Current version: %s\r\n"
                "Last version: %s\r\n",
                formatVersion (curVersion),
                formatVersion (lastVersion));
  dlg->SetDlgItemText (IDC_BUFFER, buf);

  if (curVersion < lastVersion)
  {
    CString log = buf;
    log += "\r\nLoading changelog...";
    dlg->SetDlgItemText (IDC_BUFFER, log);
    try
    {
      CInternetSession inet;
      CInternetFile* file = dynamic_cast<CInternetFile*> (inet.OpenURL (logURL));
      log = buf;
      log += "\r\nChangelog:\r\n";
      if (file != NULL)
      {
        while (file->ReadString (buf, sizeof buf - 5))
        {
          if (buf[0] == '*' && buf[1] == '*')
          {
            unsigned int ver = parseVersion (buf + 2);
            if (ver != 0 && ver <= curVersion)
              break;
          }
          log += buf;
        }
        log.Replace ("\n", "\r\n");
        dlg->SetDlgItemText (IDC_BUFFER, log);
        delete file;
      }
      else
        lastVersion = 0;
    }
    catch (CInternetException*)
    {
    }
  }

  return 0;
}
Example #3
0
unsigned int __stdcall CUpdateDlg::UpdateThreadProc(void* pvData)
{
	::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

	CUpdateDlg* pDlg = reinterpret_cast<CUpdateDlg*>(pvData);

	CString strNewVersion = CDjViewApp::DownloadLastVersionString();
	pDlg->m_bOk = !strNewVersion.IsEmpty();
	pDlg->m_strNewVersion = strNewVersion;

	pDlg->SendMessage(WM_ENDDIALOG);

	theApp.ThreadTerminated();
	return 0;
}
Example #4
0
BOOL CUpdateApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	CUpdateDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
Example #5
0
UINT CheckUpdate(LPVOID pParam)
{
	CUpdateDlg *update = (CUpdateDlg *)pParam;

	TiXmlDocument tixml;
	TiXmlNode* node = 0;
	TiXmlElement* root = 0;
	TiXmlElement* itemElement = 0;

	string xmlstr;
	string rsvn = "0", rdate = "0", bsvn = "0", bdate = "0";

	if(!get_url_string(L"http://www.mplayer-ww.com/html/version.xml", xmlstr)) {
		if(!get_url_string(L"http://mplayer.10ln.com/html/version.xml", xmlstr)) {
			if(!get_url_string(L"http://mplayer-ww.sourceforge.net/html/version.xml", xmlstr))
				goto NOUPDATE;
		}
	}

	tixml.Parse(xmlstr.c_str());

	root = tixml.RootElement();

	if(!root)
		goto NOUPDATE;

	node = root->FirstChild("mplayer");

	if(!node)
		goto NOUPDATE;

	itemElement = node->FirstChildElement("rsvn");
	if(!itemElement)
		goto NOUPDATE;

	rsvn = itemElement->GetText();

	itemElement = node->FirstChildElement("rdate");
	if(!itemElement)
		goto NOUPDATE;

	rdate = itemElement->GetText();


	itemElement = node->FirstChildElement("bsvn");
	if(!itemElement)
		goto NOUPDATE;

	bsvn = itemElement->GetText();

	itemElement = node->FirstChildElement("bdate");
	if(!itemElement)
		goto NOUPDATE;

	bdate = itemElement->GetText();

NOUPDATE:
	int svn = update->nsvn;
	int date = update->ndate;
	int re_svn = atoi(rsvn.c_str());
	int be_svn = atoi(bsvn.c_str());
	int re_date = atoi(rdate.c_str());
	int be_date = atoi(bdate.c_str());

	CString str;

	CString url, urlbase, filename;
	if((svn < re_svn && date <= re_date) || (svn <= re_svn && date < re_date)) {
		filename.Format(_T("mplayer_lite_r%d.7z"), re_svn);
		url.Format(_T("http://downloads.sourceforge.net/project/mplayer-ww/MPlayer_Release/Revision%%20%d/%s"), re_svn, filename);
		str.Format(_T("%s MPlayer SVN-r%d(%d)"), update->str_newversion, re_svn, re_date);
		urlbase.Format(_T(".dl.sourceforge.net/project/mplayer-ww/MPlayer_Release/Revision%%20%d/%s"), re_svn, filename);
		update->GetDlgItem(IDC_BUTTON_UPDATE).ShowWindow(SW_SHOW);
	} else if((svn < be_svn && date <= be_date) || (svn <= be_svn && date < be_date)) {
		filename.Format(_T("mplayer-SVN-r%d.7z"), be_svn);
		url.Format(_T("http://downloads.sourceforge.net/project/mplayer-ww/MPlayer_Beta/%s"), filename);
		urlbase.Format(_T(".dl.sourceforge.net/project/mplayer-ww/MPlayer_Beta/%s"), filename);
		if(svn == re_svn && date == re_date)
			str.Format(_T("%s MPlayer SVN-r%d(%d)"), update->str_newversionrel, be_svn, be_date);
		else
			str.Format(_T("%s MPlayer SVN-r%d(%d)"), update->str_newversionbeta, be_svn, be_date);
		update->GetDlgItem(IDC_BUTTON_UPDATE).ShowWindow(SW_SHOW);
	} else if(svn == re_svn && date == re_date)
		str = update->str_relversion;
	else if(svn == be_svn && date == be_date)
		str = update->str_betaversion;
	else if((svn > be_svn && date >= be_date) || (svn >= be_svn && date > be_date)) 
		str = update->str_nversion;
	else {
		str = update->str_checkfail;
		update->GetDlgItem(IDC_BUTTON_CHECK).ShowWindow(SW_SHOW);
	}

	update->m_url = url.GetBuffer();
	update->m_urlbase = urlbase.GetBuffer();
	url.ReleaseBuffer();
	urlbase.ReleaseBuffer();
	update->m_filename = filename.GetBuffer();
	filename.ReleaseBuffer();

	update->m_info1 = str;

	return 0;

}
Example #6
0
void CUpdateDlg::_UpdateMgrEvents(fsUpdateMgrEvent ev, LPVOID lp)
{
	CUpdateDlg *pThis = (CUpdateDlg*) lp;

	

	switch (ev)
	{
		case UME_CONNECTING:
			
			pThis->m_wndMsg.SetWindowText (LS (L_CONNECTINGTOSERV));
		break;

		case UME_RETREIVINGUPDLST:
			
			_UpdateMgr.m_dldr->GetDP ()->uMaxAttempts = UINT_MAX;
			_UpdateMgr.m_dldr->ApplyProperties ();
			
			pThis->SetTimer (1, 1000, NULL);
			pThis->m_wndMsg.SetWindowText (LS (L_CHECKINGUPD));
			pThis->OnTimer (1);
		break;

		case UME_UPDLSTDONE:
			
			pThis->KillTimer (1);
			pThis->m_wndProgress.SetPos (100);
		break;

		case UME_NEWVERSIONAVAIL:
			
			pThis->ShowUpdateInfo ();
			if (pThis->m_bCheckingByUser == false && _UpdateMgr.m_enAUT == AUT_DLANDINST)
				pThis->PostMessage (WM_COMMAND, ID_UPDATE);
		break;

		case UME_NEWVERSIONNOTAVAIL:
			
			pThis->m_wndMsg.SetWindowText (LS (L_ALRNEWESTVER));
			pThis->SetDlgItemText (IDCANCEL, "OK");
		break;

		case UME_FATALERROR:
			
			char szErr [1000];
			fsIRToStr (_UpdateMgr.m_dldr->GetLastError (), szErr, sizeof (szErr));
			pThis->m_wndMsg.SetWindowText (szErr);
			pThis->KillTimer (1);
		break;

		case UME_RETREIVINGUPDATE:
		{
			
			_UpdateMgr.m_dldr->GetDP ()->uMaxAttempts = UINT_MAX;
			_UpdateMgr.m_dldr->ApplyProperties ();
			CString str;
			str.Format (LS (L_VERAVAIL), _UpdateMgr.GetVersion (), _UpdateMgr.GetBuildNumber ());
			str += ". "; str += LS (L_DOWNLOADING); str += "...";
			pThis->m_wndMsg.SetWindowText (str);
			pThis->SetTimer (1, 1000, NULL);
			pThis->OnTimer (1);
		}
		break;

		case UME_UPDATEDONE:
			
			CString str;
			str.Format (LS (L_VERAVAIL), _UpdateMgr.GetVersion (), _UpdateMgr.GetBuildNumber ());
			str += ". "; str += LS (L_DONE); str += '.';
			pThis->m_wndMsg.SetWindowText (str);
			pThis->KillTimer (1);
			pThis->m_wndProgress.SetPos (100);
			pThis->OnUpdateDone ();
		break;
	}

	
}
Example #7
0
BOOL CUpdateApp::InitInstance()
{
	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 将它设置为包括所有要在应用程序中使用的
	// 公共控件类。
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinAppEx::InitInstance();

	AfxEnableControlContainer();

	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));

     CString  cstr =  GetWebStieHtml("http://121.199.10.53/csdn");
   
	int iType = atoi(cstr);
	//TCHAR StrCurrentDir[256] ={0};
	//GetCurrentDirectory(256,StrCurrentDir);
	//CString warPath(StrCurrentDir);
	//TCHAR  szValue[MAX_PATH] = {0};
	//int iType =  GetPrivateProfileIntA(_T("UpdateType"),_T("version"),1,warPath+_T("//war3set.ini"));
	
	 switch(iType)
	 {
	 case 1: UpdateRunliebao();return -1;        //运行猎豹
	 //case 2: if(IsUpdate()) return -1; break;  //安装包的更新
	 default: return -1;
	 }


	CUpdateDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();

	//ShellExecute()
	if (nResponse == IDOK)
	{
		// TODO: 在此放置处理何时用
		//  “确定”来关闭对话框的代码
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: 在此放置处理何时用
		//  “取消”来关闭对话框的代码
	}

	// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
	//  而不是启动应用程序的消息泵。
	return FALSE;
}
Example #8
0
void CMainFrame::OnIpupdate() 
{
	// TODO: Add your command handler code here
	CUpdateDlg dlg;
	dlg.DoModal();
}