A Fast Bresenham Type Algorithm For Drawing Ellipses by John Kennedy
[xy_vsfilter.git] / src / apps / mplayerc / AuthDlg.cpp
blob204d678167906f972fc1f5b3b0465096c8be74e8
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
23 // AuthDlg.cpp : implementation file
26 #include "stdafx.h"
27 #include "mplayerc.h"
28 #include "AuthDlg.h"
30 // CAuthDlg dialog
32 IMPLEMENT_DYNAMIC(CAuthDlg, CDialog)
33 CAuthDlg::CAuthDlg(CWnd* pParent /*=NULL*/)
34 : CDialog(CAuthDlg::IDD, pParent)
35 , m_username(_T(""))
36 , m_password(_T(""))
37 , m_remember(FALSE)
41 CAuthDlg::~CAuthDlg()
45 void CAuthDlg::DoDataExchange(CDataExchange* pDX)
47 CDialog::DoDataExchange(pDX);
48 DDX_Control(pDX, IDC_COMBO1, m_usernamectrl);
49 DDX_Text(pDX, IDC_COMBO1, m_username);
50 DDX_Text(pDX, IDC_EDIT3, m_password);
51 DDX_Check(pDX, IDC_CHECK1, m_remember);
54 CString CAuthDlg::DEncrypt(CString str)
56 for(int i = 0; i < str.GetLength(); i++)
57 str.SetAt(i, str[i]^5);
58 return str;
62 BEGIN_MESSAGE_MAP(CAuthDlg, CDialog)
63 ON_BN_CLICKED(IDOK, OnBnClickedOk)
64 ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
65 ON_EN_SETFOCUS(IDC_EDIT3, OnEnSetfocusEdit3)
66 END_MESSAGE_MAP()
69 // CAuthDlg message handlers
71 BOOL CAuthDlg::OnInitDialog()
73 CDialog::OnInitDialog();
75 CWinApp* pApp = AfxGetApp();
77 if(pApp->m_pszRegistryKey)
79 CRegKey hSecKey(pApp->GetSectionKey(ResStr(IDS_R_LOGINS)));
80 if(hSecKey)
82 int i = 0;
83 TCHAR username[256], password[256];
84 while(1)
86 DWORD unlen = countof(username);
87 DWORD pwlen = sizeof(password);
88 DWORD type = REG_SZ;
89 if(ERROR_SUCCESS == RegEnumValue(
90 hSecKey, i++, username, &unlen, 0, &type, (BYTE*)password, &pwlen))
92 m_logins[username] = DEncrypt(password);
93 m_usernamectrl.AddString(username);
95 else
97 break;
102 else
104 CAutoVectorPtr<TCHAR> buff;
105 buff.Allocate(32767/sizeof(TCHAR));
107 DWORD len = GetPrivateProfileSection(
108 ResStr(IDS_R_LOGINS), buff, 32767/sizeof(TCHAR), pApp->m_pszProfileName);
110 TCHAR* p = buff;
111 while(*p && len > 0)
113 CString str = p;
114 p += str.GetLength()+1;
115 len -= str.GetLength()+1;
116 CAtlList<CString> sl;
117 Explode(str, sl, '=', 2);
118 if(sl.GetCount() == 2)
120 m_logins[sl.GetHead()] = DEncrypt(sl.GetTail());
121 m_usernamectrl.AddString(sl.GetHead());
126 m_usernamectrl.SetFocus();
128 return TRUE; // return TRUE unless you set the focus to a control
129 // EXCEPTION: OCX Property Pages should return FALSE
132 void CAuthDlg::OnBnClickedOk()
134 UpdateData();
136 if(!m_username.IsEmpty())
138 CWinApp* pApp = AfxGetApp();
139 pApp->WriteProfileString(ResStr(IDS_R_LOGINS), m_username, m_remember ? DEncrypt(m_password) : _T(""));
142 OnOK();
146 void CAuthDlg::OnCbnSelchangeCombo1()
148 CString username;
149 m_usernamectrl.GetLBText(m_usernamectrl.GetCurSel(), username);
151 CString password;
152 if(m_logins.Lookup(username, password))
154 m_password = password;
155 m_remember = TRUE;
156 UpdateData(FALSE);
160 void CAuthDlg::OnEnSetfocusEdit3()
162 UpdateData();
164 CString password;
165 if(m_logins.Lookup(m_username, password))
167 m_password = password;
168 m_remember = TRUE;
169 UpdateData(FALSE);