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)
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
28 #include "PPageSubDB.h"
33 IMPLEMENT_DYNAMIC(CPPageSubDB
, CPPageBase
)
34 CPPageSubDB::CPPageSubDB()
35 : CPPageBase(CPPageSubDB::IDD
, CPPageSubDB::IDD
)
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
)
57 // CPPageSubDB message handlers
59 BOOL
CPPageSubDB::OnInitDialog()
61 __super::OnInitDialog();
63 AppSettings
& s
= AfxGetAppSettings();
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"));
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()
80 AppSettings
& s
= AfxGetAppSettings();
83 s
.ISDb
.TrimRight('/');
85 return __super::OnApply();
88 void CPPageSubDB::OnBnClickedButton1()
90 CString ISDb
, ver
, msg
, str
;
92 m_ISDbCombo
.GetWindowText(ISDb
);
95 ver
.Format(_T("ISDb v%d"), ISDb_PROTOCOL_VERSION
);
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!");
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);