00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdafx.h"
00026 #include "mplayerc.h"
00027 #include "MainFrm.h"
00028 #include "PPageSubDB.h"
00029 #include "ISDb.h"
00030
00031
00032
00033 IMPLEMENT_DYNAMIC(CPPageSubDB, CPPageBase)
00034 CPPageSubDB::CPPageSubDB()
00035 : CPPageBase(CPPageSubDB::IDD, CPPageSubDB::IDD)
00036 , m_ISDb(_T(""))
00037 {
00038 }
00039
00040 CPPageSubDB::~CPPageSubDB()
00041 {
00042 }
00043
00044 void CPPageSubDB::DoDataExchange(CDataExchange* pDX)
00045 {
00046 __super::DoDataExchange(pDX);
00047 DDX_Control(pDX, IDC_COMBO1, m_ISDbCombo);
00048 DDX_CBString(pDX, IDC_COMBO1, m_ISDb);
00049 }
00050
00051 BEGIN_MESSAGE_MAP(CPPageSubDB, CPPageBase)
00052 ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
00053 ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1)
00054 END_MESSAGE_MAP()
00055
00056
00057
00058
00059 BOOL CPPageSubDB::OnInitDialog()
00060 {
00061 __super::OnInitDialog();
00062
00063 AppSettings& s = AfxGetAppSettings();
00064
00065 m_ISDb = s.ISDb;
00066 m_ISDbCombo.AddString(m_ISDb);
00067 if(m_ISDb.CompareNoCase(_T("sub.sytes.net")))
00068 m_ISDbCombo.AddString(_T("sub.sytes.net"));
00069
00070 UpdateData(FALSE);
00071
00072 return TRUE;
00073
00074 }
00075
00076 BOOL CPPageSubDB::OnApply()
00077 {
00078 UpdateData();
00079
00080 AppSettings& s = AfxGetAppSettings();
00081
00082 s.ISDb = m_ISDb;
00083 s.ISDb.TrimRight('/');
00084
00085 return __super::OnApply();
00086 }
00087
00088 void CPPageSubDB::OnBnClickedButton1()
00089 {
00090 CString ISDb, ver, msg, str;
00091
00092 m_ISDbCombo.GetWindowText(ISDb);
00093 ISDb.TrimRight('/');
00094
00095 ver.Format(_T("ISDb v%d"), ISDb_PROTOCOL_VERSION);
00096
00097 CWebTextFile wtf;
00098 if(wtf.Open(_T("http://") + ISDb + _T("/test.php")) && wtf.ReadString(str) && str == ver)
00099 {
00100 msg = _T("The URL appears to be correct!");
00101 }
00102 else if(str.Find(_T("ISDb v")) == 0)
00103 {
00104 msg = _T("Protocol version mismatch, please upgrade your player or choose a different address!");
00105 }
00106 else
00107 {
00108 msg = _T("Bad URL, could not locate subtitle database there!");
00109 }
00110
00111 AfxMessageBox(msg, MB_OK);
00112 }
00113
00114 void CPPageSubDB::OnUpdateButton1(CCmdUI* pCmdUI)
00115 {
00116 pCmdUI->Enable(m_ISDbCombo.GetWindowTextLength() > 0);
00117 }