PPageSubDB.cpp

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 // PPageSubDB.cpp : implementation file
00023 //
00024 
00025 #include "stdafx.h"
00026 #include "mplayerc.h"
00027 #include "MainFrm.h"
00028 #include "PPageSubDB.h"
00029 #include "ISDb.h"
00030 
00031 // CPPageSubDB dialog
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 // CPPageSubDB message handlers
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;  // return TRUE unless you set the focus to a control
00073         // EXCEPTION: OCX Property Pages should return FALSE
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 }

Generated on Tue Dec 13 14:47:02 2005 for guliverkli by  doxygen 1.4.5