Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

DlgDiscoveryService.cpp

Go to the documentation of this file.
00001 //
00002 // DlgDiscoveryService.cpp
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #include "StdAfx.h"
00023 #include "Shareaza.h"
00024 #include "Settings.h"
00025 #include "Network.h"
00026 #include "DiscoveryServices.h"
00027 #include "DlgDiscoveryService.h"
00028 
00029 #ifdef _DEBUG
00030 #define new DEBUG_NEW
00031 #undef THIS_FILE
00032 static char THIS_FILE[] = __FILE__;
00033 #endif
00034 
00035 BEGIN_MESSAGE_MAP(CDiscoveryServiceDlg, CSkinDialog)
00036         //{{AFX_MSG_MAP(CDiscoveryServiceDlg)
00037         ON_EN_CHANGE(IDC_ADDRESS, OnChangeAddress)
00038         ON_CBN_SELCHANGE(IDC_SERVICE_TYPE, OnSelChangeServiceType)
00039         //}}AFX_MSG_MAP
00040 END_MESSAGE_MAP()
00041 
00042 
00044 // CDiscoveryServiceDlg dialog
00045 
00046 CDiscoveryServiceDlg::CDiscoveryServiceDlg(CWnd* pParent, CDiscoveryService* pService) : CSkinDialog(CDiscoveryServiceDlg::IDD, pParent)
00047 {
00048         //{{AFX_DATA_INIT(CDiscoveryServiceDlg)
00049         m_sAddress = _T("");
00050         m_nType = -1;
00051         //}}AFX_DATA_INIT
00052         m_pService      = pService;
00053         m_bNew          = FALSE;
00054 }
00055 
00056 CDiscoveryServiceDlg::~CDiscoveryServiceDlg()
00057 {
00058         if ( m_pService && m_bNew ) delete m_pService;
00059 }
00060 
00061 void CDiscoveryServiceDlg::DoDataExchange(CDataExchange* pDX)
00062 {
00063         CSkinDialog::DoDataExchange(pDX);
00064         //{{AFX_DATA_MAP(CDiscoveryServiceDlg)
00065         DDX_Control(pDX, IDOK, m_wndOK);
00066         DDX_Text(pDX, IDC_ADDRESS, m_sAddress);
00067         DDX_CBIndex(pDX, IDC_SERVICE_TYPE, m_nType);
00068         //}}AFX_DATA_MAP
00069 }
00070 
00072 // CDiscoveryServiceDlg message handlers
00073 
00074 BOOL CDiscoveryServiceDlg::OnInitDialog()
00075 {
00076         CSkinDialog::OnInitDialog();
00077 
00078         SkinMe( _T("CDiscoveryServiceDlg"), IDR_DISCOVERYFRAME );
00079 
00080         CSingleLock pLock( &Network.m_pSection, TRUE );
00081 
00082         m_bNew = ! DiscoveryServices.Check( m_pService );
00083         if ( m_bNew ) m_pService = new CDiscoveryService();
00084 
00085         m_sAddress      = m_pService->m_sAddress;
00086         m_nType         = m_pService->m_nType - 1;
00087 
00088         if ( m_bNew ) m_nType = 1;
00089 
00090         pLock.Unlock();
00091 
00092         UpdateData( FALSE );
00093 
00094         OnChangeAddress();
00095 
00096         return TRUE;
00097 }
00098 
00099 void CDiscoveryServiceDlg::OnChangeAddress()
00100 {
00101         UpdateData();
00102 
00103         m_wndOK.EnableWindow( m_nType ?
00104                 _tcsncmp( m_sAddress, _T("http://"), 7 ) == 0 :
00105                 _tcschr( m_sAddress, '.' ) != NULL );
00106 }
00107 
00108 void CDiscoveryServiceDlg::OnSelChangeServiceType()
00109 {
00110         OnChangeAddress();
00111 }
00112 
00113 void CDiscoveryServiceDlg::OnOK()
00114 {
00115         UpdateData();
00116 
00117         CSingleLock pLock( &Network.m_pSection, TRUE );
00118 
00119         if ( ! m_bNew && ! DiscoveryServices.Check( m_pService ) )
00120                 m_pService = new CDiscoveryService();
00121 
00122         m_pService->m_sAddress  = m_sAddress;
00123         m_pService->m_nType             = m_nType + 1;
00124 
00125         DiscoveryServices.Add( m_pService );
00126         m_pService = NULL;
00127 
00128         pLock.Unlock();
00129 
00130         CSkinDialog::OnOK();
00131 }

Generated on Thu Dec 15 10:39:39 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2