1
//////////////////////////////////////////////////////////////////////////
3
// pgAdmin III - PostgreSQL Tools
4
// RCS-ID: $Id: frmPassword.cpp 4874 2006-01-06 17:33:27Z dpage $
5
// Copyright (C) 2002 - 2006, The pgAdmin Development Team
6
// This software is released under the Artistic Licence
8
// frmPassword.cpp - Change password
10
//////////////////////////////////////////////////////////////////////////
14
#include <wx/xrc/xmlres.h>
19
#include "frmPassword.h"
22
#include "images/connect.xpm"
24
#define txtCurrent CTRL_TEXT("txtCurrent")
25
#define txtNew CTRL_TEXT("txtNew")
26
#define txtConfirm CTRL_TEXT("txtConfirm")
29
BEGIN_EVENT_TABLE(frmPassword, pgDialog)
30
EVT_BUTTON (wxID_HELP, frmPassword::OnHelp)
31
EVT_BUTTON (wxID_OK, frmPassword::OnOK)
32
EVT_BUTTON (wxID_CANCEL, frmPassword::OnCancel)
36
frmPassword::frmPassword(wxFrame *parent, pgObject *obj)
38
wxLogInfo(wxT("Creating a change password dialogue"));
40
wxWindowBase::SetFont(settings->GetSystemFont());
41
LoadResource(parent, wxT("frmPassword"));
43
server = obj->GetServer();
45
SetIcon(wxIcon(connect_xpm));
49
frmPassword::~frmPassword()
51
wxLogInfo(wxT("Destroying a change password dialogue"));
55
void frmPassword::OnHelp(wxCommandEvent &ev)
57
DisplayHelp(this, wxT("password"));
61
void frmPassword::OnOK(wxCommandEvent& event)
64
// Is the old password right?
65
if (txtCurrent->GetValue() != server->GetPassword()) {
66
wxLogError(__("Incorrect password!"));
70
// Did we confirm the password OK?
71
if (txtNew->GetValue() != txtConfirm->GetValue()) {
72
wxLogError(__("Passwords do not match!"));
76
// Set the new password
77
if (!server->SetPassword(txtNew->GetValue()))
79
wxLogError(__("The password could not be changed!"));
83
// All must have gone well!
84
wxLogMessage(__("Password successfully changed!"));
89
void frmPassword::OnCancel(wxCommandEvent& event)
95
passwordFactory::passwordFactory(menuFactoryList *list, wxMenu *mnu, wxToolBar *toolbar) : actionFactory(list)
97
mnu->Append(id, _("C&hange password..."), _("Change your password."));
101
wxWindow *passwordFactory::StartDialog(frmMain *form, pgObject *obj)
103
frmPassword *frm=new frmPassword((pgFrame*)form, obj);
109
bool passwordFactory::CheckEnable(pgObject *obj)
113
pgServer *server = obj->GetServer();
114
return server && server->GetConnected();