SVN Commit by andreas: r4794 - in trunk/pgadmin3: . src/base src/include/base src/schema - Mailing list pgadmin-hackers

From svn@pgadmin.org
Subject SVN Commit by andreas: r4794 - in trunk/pgadmin3: . src/base src/include/base src/schema
Date
Msg-id 200512061300.jB6D0lfQ027303@developer.pgadmin.org
Whole thread Raw
List pgadmin-hackers
Author: andreas
Date: 2005-12-06 13:00:46 +0000 (Tue, 06 Dec 2005)
New Revision: 4794

Modified:
   trunk/pgadmin3/CHANGELOG.txt
   trunk/pgadmin3/src/base/pgConnBase.cpp
   trunk/pgadmin3/src/include/base/pgConnBase.h
   trunk/pgadmin3/src/schema/pgServer.cpp
Log:
store UTF8 connect info in pgpass.conf if necessary

Modified: trunk/pgadmin3/CHANGELOG.txt
===================================================================
--- trunk/pgadmin3/CHANGELOG.txt    2005-12-05 16:57:56 UTC (rev 4793)
+++ trunk/pgadmin3/CHANGELOG.txt    2005-12-06 13:00:46 UTC (rev 4794)
@@ -18,6 +18,7 @@
 </ul>
 <br>
 <ul>
+    <li>2005-12-06 AP  1.4.1  store UTF8 connect info in pgpass.conf if necessary
     <li>2005-12-03 AP  1.4.1  Major fix for wx2.6.2 API changes (comboboxes)
     <li>2005-12-02 DP  1.4.1  Drop constraints on columns before the columns themselves [Miha Radej]
     <li>2005-12-01 AP  1.4.1  Deal with incompatible wx2.6.2 API changes (comboboxes)

Modified: trunk/pgadmin3/src/base/pgConnBase.cpp
===================================================================
--- trunk/pgadmin3/src/base/pgConnBase.cpp    2005-12-05 16:57:56 UTC (rev 4793)
+++ trunk/pgadmin3/src/base/pgConnBase.cpp    2005-12-06 13:00:46 UTC (rev 4794)
@@ -74,6 +74,7 @@

     conv = &wxConvLibc;
     needColQuoting = false;
+    utfConnectString = false;

     // Check the hostname/ipaddress
     struct hostent *host;
@@ -172,7 +173,9 @@
 #if wxUSE_UNICODE
     wxCharBuffer cstrUTF=connstr.mb_str(wxConvUTF8);
     conn = PQconnectdb(cstrUTF);
-    if (PQstatus(conn) != CONNECTION_OK)
+    if (PQstatus(conn) == CONNECTION_OK)
+        utfConnectString = true;
+    else
     {
         wxCharBuffer cstrLibc=connstr.mb_str(wxConvLibc);
         if (strcmp(cstrUTF, cstrLibc))

Modified: trunk/pgadmin3/src/include/base/pgConnBase.h
===================================================================
--- trunk/pgadmin3/src/include/base/pgConnBase.h    2005-12-05 16:57:56 UTC (rev 4793)
+++ trunk/pgadmin3/src/include/base/pgConnBase.h    2005-12-06 13:00:46 UTC (rev 4794)
@@ -71,6 +71,7 @@
     wxString GetHost() const { return dbHost; }
     wxString GetDbname() const { return dbname; }
     wxString GetName() const;
+    bool GetNeedUtfConnectString() { return utfConnectString; }
     int GetPort() const { return atoi(PQport(conn)); };
     wxString GetTTY() const { return wxString(PQtty(conn), *conv); }
     wxString GetOptions() const { return wxString(PQoptions(conn), *conv); }
@@ -97,7 +98,7 @@

     int connStatus;
     wxMBConv *conv;
-    bool needColQuoting;
+    bool needColQuoting, utfConnectString;
     wxString dbHost, dbname;
     OID lastSystemOID;
     OID dbOid;

Modified: trunk/pgadmin3/src/schema/pgServer.cpp
===================================================================
--- trunk/pgadmin3/src/schema/pgServer.cpp    2005-12-05 16:57:56 UTC (rev 4793)
+++ trunk/pgadmin3/src/schema/pgServer.cpp    2005-12-06 13:00:46 UTC (rev 4794)
@@ -472,15 +472,31 @@
     if (file.IsOpened())
     {
         wxString before;
+        wxString after;
+
+        wxString passwd;
+        wxString seekStr;
+
+#if wxUSE_UNICODE
+        if (GetConnection()->GetNeedUtfConnectString())
+        {
+            passwd = wxString(password.mb_str(wxConvUTF8), wxConvLibc);
+            seekStr = wxString(GetName().mb_str(wxConvUTF8), wxConvLibc) + wxT(":")
+                    + NumToStr((long)GetPort()) + wxT(":*:")
+                    + wxString(username.mb_str(wxConvUTF8), wxConvLibc) + wxT(":") ;
+        }
+        else
+#endif
+        {
+            passwd = password;
+            seekStr = GetName() + wxT(":")
+                    + NumToStr((long)GetPort()) + wxT(":*:")
+                    + username + wxT(":") ;
+        }
+
         file.Read(before);
-
         wxStringTokenizer lines(before, wxT("\n\r"));

-        wxString seekStr= GetName() + wxT(":")
-                        + NumToStr((long)GetPort()) + wxT(":*:")
-                        + username + wxT(":") ;
-        wxString after;
-
         file.Seek(0);
         bool found=false;
         while (lines.HasMoreTokens())
@@ -491,13 +507,13 @@
                 // entry found
                 found=true;
                 if (storePwd)
-                    file.Write(seekStr + password + END_OF_LINE);
+                    file.Write(seekStr + passwd + END_OF_LINE);
             }
             else
                 file.Write(str + END_OF_LINE);
         }
         if (!found && storePwd)
-            file.Write(seekStr + password + END_OF_LINE);
+            file.Write(seekStr + passwd + END_OF_LINE);

         file.Close();
     }
@@ -508,6 +524,8 @@
 {
     wxLogInfo(wxT("Attempting to create a connection object..."));

+    bool storePassword = false;
+
     if (!conn || conn->GetStatus() != PGCONN_OK)
     {
         if (conn)
@@ -540,7 +558,7 @@

                 iSetStorePwd(dlg.GetStorePwd());
                 password = dlg.GetPassword();
-                StorePassword();
+                storePassword = true;
             }
         }
         else
@@ -620,6 +638,8 @@
                 settings->Write(wxT("Updates/UseSSL"), true);

             UpdateIcon(form->GetBrowser());
+            if (storePassword)
+                StorePassword();
         }
         else
         {


pgadmin-hackers by date:

Previous
From: "Marcos Alves T. de Azevedo"
Date:
Subject: New Brazilian Translator/Maintaner.
Next
From: svn@pgadmin.org
Date:
Subject: SVN Commit by andreas: r4795 - in branches/REL-1_4_0_PATCHES/pgadmin3/src: base include/base schema