X64 transport [Part 5] (Update plugins.cpp)
[xy_vsfilter.git] / src / apps / mplayerc / PPageSubDB.cpp
blobe05027b777677e28907b5664dbc7c8d98883cc62
1 /*
2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 // PPageSubDB.cpp : implementation file
25 #include "stdafx.h"
26 #include "mplayerc.h"
27 #include "MainFrm.h"
28 #include "PPageSubDB.h"
29 #include "ISDb.h"
31 // CPPageSubDB dialog
33 IMPLEMENT_DYNAMIC(CPPageSubDB, CPPageBase)
34 CPPageSubDB::CPPageSubDB()
35 : CPPageBase(CPPageSubDB::IDD, CPPageSubDB::IDD)
36 , m_ISDb(_T(""))
40 CPPageSubDB::~CPPageSubDB()
44 void CPPageSubDB::DoDataExchange(CDataExchange* pDX)
46 __super::DoDataExchange(pDX);
47 DDX_Control(pDX, IDC_COMBO1, m_ISDbCombo);
48 DDX_CBString(pDX, IDC_COMBO1, m_ISDb);
51 BEGIN_MESSAGE_MAP(CPPageSubDB, CPPageBase)
52 ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
53 ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
54 END_MESSAGE_MAP()
57 // CPPageSubDB message handlers
59 BOOL CPPageSubDB::OnInitDialog()
61 __super::OnInitDialog();
63 AppSettings& s = AfxGetAppSettings();
65 m_ISDb = s.ISDb;
66 m_ISDbCombo.AddString(m_ISDb);
67 if(m_ISDb.CompareNoCase(_T("www.opensubtitles.org/isdb")))
68 m_ISDbCombo.AddString(_T("www.opensubtitles.org/isdb"));
70 UpdateData(FALSE);
72 return TRUE; // return TRUE unless you set the focus to a control
73 // EXCEPTION: OCX Property Pages should return FALSE
76 BOOL CPPageSubDB::OnApply()
78 UpdateData();
80 AppSettings& s = AfxGetAppSettings();
82 s.ISDb = m_ISDb;
83 s.ISDb.TrimRight('/');
85 return __super::OnApply();
88 void CPPageSubDB::OnBnClickedButton1()
90 CString ISDb, ver, msg, str;
92 m_ISDbCombo.GetWindowText(ISDb);
93 ISDb.TrimRight('/');
95 ver.Format(_T("ISDb v%d"), ISDb_PROTOCOL_VERSION);
97 CWebTextFile wtf;
98 if(wtf.Open(_T("http://") + ISDb + _T("/test.php")) && wtf.ReadString(str) && str == ver)
100 msg = _T("The URL appears to be correct!");
102 else if(str.Find(_T("ISDb v")) == 0)
104 msg = _T("Protocol version mismatch, please upgrade your player or choose a different address!");
106 else
108 msg = _T("Bad URL, could not locate subtitle database there!");
111 AfxMessageBox(msg, MB_OK);
114 void CPPageSubDB::OnUpdateButton1(CCmdUI* pCmdUI)
116 pCmdUI->Enable(m_ISDbCombo.GetWindowTextLength() > 0);