OSSP CVS Repository

ossp - Check-in [3882]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3882
Date: 2002-Dec-16 15:07:59 (local)
2002-Dec-16 14:07:59 (UTC)
User:ms
Branch:
Comment: Now read preferences from a configuration file in the current user's home directory by default.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/TODO      1.45 -> 1.46     5 inserted, 1 deleted
ossp-pkg/as/as-gui/as_assist.cpp      1.70 -> 1.71     20 inserted, 6 deleted
ossp-pkg/as/as-gui/as_const.h      1.25 -> 1.26     3 inserted, 1 deleted

ossp-pkg/as/as-gui/TODO 1.45 -> 1.46

--- TODO 2002/12/16 12:11:40     1.45
+++ TODO 2002/12/16 14:07:59     1.46
@@ -31,7 +31,7 @@
 Write M4 macro for detecting cuserid, and prefer cuserid in ac_assist when present
 Krass date block data shading keyed to sort function
 Does resetting data clean make sense after closeEvent?
-Change default config location to homedir, with --confgen option
+Read config location from optional --confgen autoconf location
 Rework start/new/open/close/quit logic with disabled/enabled widgets
 IDs in as_const.h much better choosing, so they make sense
 Make edit control window optional through preferences
@@ -56,6 +56,10 @@
   Zufug Reihe
 </macro name = 'Append'>
 
+Win32
+-----
+Rework username, homedir, and confdaten (hive) logic
+
 Bugs
 ----
 Sometimes a click on add or delete toolbar button is ignored?


ossp-pkg/as/as-gui/as_assist.cpp 1.70 -> 1.71

--- as_assist.cpp        2002/12/16 12:11:40     1.70
+++ as_assist.cpp        2002/12/16 14:07:59     1.71
@@ -33,6 +33,7 @@
 #if defined(Q_OS_WIN32)
 #include <lmcons.h>
 #else
+#include <pwd.h>
 #include <unistd.h>
 #endif // #if defined(Q_OS_WIN32)
 
@@ -79,7 +80,7 @@
 //
 void Titraqform::setupPrefs(void)
 {
-    QString Username;
+    QString Username, Homedir;
 
 // Start the show by getting the username
 #if defined(Q_OS_WIN32)
@@ -89,24 +90,36 @@
         TCHAR szWinusername[UNLEN + 1];   // UNLEN is defined in lmcons.h
         GetUserName(szWinusername, &dwWinusernamesize);
         Username = qt_winQString(szWinusername);
-#else   // not unicode
+#else   // Not unicode
         char szWinusername[UNLEN + 1];    // UNLEN is defined in lmcons.h
         GetUserNameA(szWinusername, &dwWinusernamesize);
         Username = QString::fromLocal8Bit(szWinusername);
     }
 #endif  // #if defined(UNICODE)
-#else   // not windows
+#else   // Not windows
     {
 //#include <stdio.h>
 //        char *szUser = NULL;
 //        szUser = cuserid();
 //        Username = QString::fromLocal8Bit(szUser);
-        Username = QString::fromLocal8Bit(getlogin());
+        char *szLogin = getlogin();
+        passwd *pUserpwd = getpwnam(szLogin);
+
+        Homedir = QString::fromLocal8Bit(pUserpwd->pw_dir);
+        Username = QString::fromLocal8Bit(szLogin);
     }
 #endif  // #if defined(Q_OS_WIN32)
 
-    m_pPrefs = new Preferences(TITRAQ_PREFNAME, TITRAQ_APPTITLE, TITRAQ_PREFVER);
+    // Bootstrap a user preferences object from operating system info
+    m_pPrefs = new Preferences(Homedir + QChar('/') +
+                               QString::fromLocal8Bit(TITRAQ_PREFNAME),
+                               QString::fromLocal8Bit(TITRAQ_APPTITLE),
+                               QString::fromLocal8Bit(TITRAQ_PREFVER));
     if (!m_pPrefs->fileState()) {   // No file was found, so assume a null state
+        if (!Homedir.isEmpty())
+            m_pPrefs->setString(TITRAQ_PREFHOME, Homedir);
+        else
+            m_pPrefs->setString(TITRAQ_PREFHOME, TITRAQ_DEFUSER);
         if (!Username.isEmpty())
             m_pPrefs->setString(TITRAQ_PREFUSER, Username);
         else
@@ -119,7 +132,7 @@
         m_pPrefs->setString(TITRAQ_PREFLOCALLOG, TITRAQ_DEFLOCALLOG);
         m_pPrefs->flush();  // Write the new conf file
         QTextStream cerr(stderr, IO_WriteOnly);
-        cerr << trUtf8("Created new preferences file ./") << trUtf8(TITRAQ_PREFNAME) << endl;
+        cerr << trUtf8("Created new preferences file ") << Homedir + QChar('/') + QString::fromLocal8Bit(TITRAQ_PREFNAME) << endl;
     }
 
     // Use the preferred configuration values to initialize titraq
@@ -536,6 +549,7 @@
     connect(m_pMaintable, SIGNAL(doubleClicked(int, int, int, const QPoint&)), this, SLOT(inplaceEdit(int, int, int, const QPoint&)));
     connect(m_pTablehead, SIGNAL(sizeChange(int, int, int)), this, SLOT(updSizes(int, int, int)));
     connect(m_pMaintable, SIGNAL(valueChanged(int, int)), this, SLOT(dataChanged(void)));
+    connect(m_pMaintable, SIGNAL(valueChanged(int, int)), this, SLOT(validateData(int, int)));
     connect(m_pMaintable, SIGNAL(textEdited(void)), this, SLOT(dataChanged(void)));
 }
 


ossp-pkg/as/as-gui/as_const.h 1.25 -> 1.26

--- as_const.h   2002/12/16 12:11:40     1.25
+++ as_const.h   2002/12/16 14:07:59     1.26
@@ -37,12 +37,14 @@
 #define TITRAQ_PREFNAME         ".asgui"
 #define TITRAQ_APPTITLE         "AS Gui"
 #define TITRAQ_PREFVER          "0.5"
+#define TITRAQ_PREFHOME         "homedir"
+#define TITRAQ_DEFHOME          "."
 #define TITRAQ_PREFUSER         "user"
 #define TITRAQ_DEFUSER          "username"
 #define TITRAQ_PREFASFILE       "asfile"
 #define TITRAQ_DEFASFILE        "/e/dev/as"
 #define TITRAQ_PREFACCOUNTS     "accounts"
-#define TITRAQ_DEFACCOUNTS      "dis.txt"
+#define TITRAQ_DEFACCOUNTS      "/e/dev/as/accounts.txt"
 #define TITRAQ_PREFSTYLE        "uistyle"
 #define TITRAQ_PREFVIEW         "view"
 #define TITRAQ_DEFVIEW          "normal"

CVSTrac 2.0.1