Hi Dave, PFA the updated patch. [Please check my inline answers.]
On Mon, Jul 12, 2010 at 4:37 PM, Dave Page <dp...@pgadmin.org> wrote: > On Mon, Jul 12, 2010 at 11:39 AM, Ashesh Vashi > <ashesh.va...@enterprisedb.com> wrote: > > Hi Dave, > > Please find the patch for the same. > > Thanks. This looks good to me following some quick testing, but I > uncovered some other issues - could you look at them please? > > - We seem to stop populating the server combo box as soon as we find > the one we're currently connected to. This happens at ~ line 286 in > dlgSelectConnection.cpp, where we set foundServer = true. I can't see > why we do this, but it seems fairly deliberate. Any guesses? Should we > just remove that? > My mistake - I introduced that variable in the previous patch. > > - It seems like we ignore sslmode when we create new connections. We > need to honour the server config. > Done. > > Note that I haven't tested to ensure this doesn't break anything in > command line startup mode (eg. with -q). Can you please ensure this > mode is unaffected? > Tested. * --** **Thanks & Regards,** **Ashesh Vashi** **EnterpriseDB INDIA:* Enterprise Postgres Company<http://www.enterprisedb.com> > > Thanks. > > -- > Dave Page > EnterpriseDB UK: http://www.enterprisedb.com > The Enterprise Postgres Company >
Index: pgAdmin3.cpp =================================================================== --- pgAdmin3.cpp (revision 8466) +++ pgAdmin3.cpp (working copy) @@ -448,7 +448,8 @@ int rc=dlg.Go(conn, NULL); if (rc != wxID_OK) return false; - conn = dlg.CreateConn(applicationname); + bool dummyRes; + conn = dlg.CreateConn(applicationname, dummyRes); } else if (cmdParser.Found(wxT("Sc"), &connstr)) { @@ -539,7 +540,8 @@ int rc=dlg.Go(conn, NULL); if (rc != wxID_OK) return false; - conn = dlg.CreateConn(applicationname); + bool dummyRes; + conn = dlg.CreateConn(applicationname, dummyRes); } else if (cmdParser.Found(wxT("qc"), &connstr)) { Index: include/dlg/dlgSelectConnection.h =================================================================== --- include/dlg/dlgSelectConnection.h (revision 8466) +++ include/dlg/dlgSelectConnection.h (working copy) @@ -24,7 +24,7 @@ ~dlgSelectConnection(); wxString GetHelpPage() const; pgServer *GetServer() { return remoteServer; } - pgConn *CreateConn(wxString& applicationame); + pgConn *CreateConn(wxString& applicationame, bool& createdNew); pgConn *CreateConn(wxString& server, wxString& dbname, wxString& username, int port, int sslmode, wxString& applicationame, bool writeMRU = false); wxString GetServerName(); wxString GetDatabase(); Index: frm/frmQuery.cpp =================================================================== --- frm/frmQuery.cpp (revision 8466) +++ frm/frmQuery.cpp (working copy) @@ -981,9 +981,10 @@ int rc=dlg.Go(conn, cbConnection); if (rc == wxID_OK) { + bool createdNewConn; wxString applicationname = _("pgAdmin - Query Tool"); - conn = dlg.CreateConn(applicationname); - if (conn) + conn = dlg.CreateConn(applicationname, createdNewConn); + if (conn && createdNewConn) { cbConnection->Insert(conn->GetName(), CreateBitmap(GetServerColour()), sel, (void*)conn); cbConnection->SetSelection(sel); Index: dlg/dlgSelectConnection.cpp =================================================================== --- dlg/dlgSelectConnection.cpp (revision 8466) +++ dlg/dlgSelectConnection.cpp (working copy) @@ -84,6 +84,7 @@ return; cbDatabase->Clear(); + cbUsername->Clear(); int sel=cbServer->GetCurrentSelection(); if (sel >= 0) @@ -169,12 +170,14 @@ EndModal(wxID_CANCEL); } -pgConn *dlgSelectConnection::CreateConn(wxString& applicationname) +pgConn *dlgSelectConnection::CreateConn(wxString& applicationname, bool& createdNew) { /* gcc requires that we store this in temporary variables for some reason... */ wxString serv = cbServer->GetValue(); wxString db = cbDatabase->GetValue(); + createdNew = true; + long port = 0; if (serv.Find(':') > 0) { @@ -188,7 +191,28 @@ wxString user = cbUsername->GetValue(); - return CreateConn(serv, db, user, port, 0, applicationname, true); + if (cbConnection) + { + /* Check if selected combination already exists */ + for (unsigned int index = 0; index < cbConnection->GetCount() - 1; index++) + { + pgConn* conn = (pgConn*)cbConnection->GetClientData(index); + if (conn && + conn->GetHost() == serv && + conn->GetPort() == port && + conn->GetUser() == user && + conn->GetDbname() == db) + { + createdNew = false; + return conn; + } + } + } + + + int sslmode = remoteServer ? remoteServer->GetSSL() : 0; + + return CreateConn(serv, db, user, port, sslmode, applicationname, true); } pgConn *dlgSelectConnection::CreateConn(wxString& server, wxString& dbname, wxString& username, int port, int sslmode, wxString& applicationname, bool writeMRU) @@ -231,6 +255,7 @@ int dlgSelectConnection::Go(pgConn *conn, wxBitmapComboBox *cb) { + bool foundServer = false; cbConnection=cb; if (mainForm != NULL) { @@ -259,6 +284,7 @@ { cbServer->SetSelection(cbServer->GetCount()-1); remoteServer = server; + foundServer = true; } } serveritem = browser->GetNextChild(folderitem, servercookie); @@ -266,12 +292,35 @@ } folderitem = browser->GetNextChild(browser->GetRootItem(), foldercookie); } - cbServer->SetFocus(); } + cbServer->SetFocus(); + wxCommandEvent ev; OnChangeServer(ev); + if (foundServer) + { + + unsigned int index = 0; + for (;index < cbDatabase->GetCount(); index++) + { + if (cbDatabase->GetString(index) == conn->GetDbname()) + { + cbDatabase->SetSelection(index); + break; + } + } + for (index = 0;index < cbUsername->GetCount(); index++) + { + if (cbUsername->GetString(index) == conn->GetUser()) + { + cbUsername->SetSelection(index); + break; + } + } + } + return ShowModal(); }
-- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers