OSSP CVS Repository

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

Check-in Number: 3822
Date: 2002-Dec-03 19:46:25 (local)
2002-Dec-03 18:46:25 (UTC)
User:ms
Branch:
Comment: Add windows and unix logic to retreive current user name, and apply it in preferences, loading, and saving data.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/as_assist.cpp      1.39 -> 1.40     29 inserted, 1 deleted
ossp-pkg/as/as-gui/as_const.h      1.10 -> 1.11     2 inserted, 0 deleted
ossp-pkg/as/as-gui/as_dataop.cpp      1.11 -> 1.12     2 inserted, 1 deleted

ossp-pkg/as/as-gui/as_assist.cpp 1.39 -> 1.40

--- as_assist.cpp        2002/12/03 17:05:11     1.39
+++ as_assist.cpp        2002/12/03 18:46:25     1.40
@@ -29,6 +29,13 @@
 //  titassist.cpp: ISO C++ implementation
 //
 
+// For username research
+#if defined(Q_WS_WIN)
+#include <lmcons.h>
+#else
+#include <unistd.h>
+#endif
+
 // Qt style headers
 #include <qcdestyle.h>
 #include <qsgistyle.h>
@@ -68,8 +75,29 @@
 //
 void Titraqform::setupPrefs(void)
 {
+    QString Username;
+
+// Start the show by getting the username
+#if defined(Q_WS_WIN)
+    DWORD winUserNameSize = sizeof(winUserName);
+#if defined(UNICODE)
+    TCHAR winUserName[UNLEN + 1];   // UNLEN is defined in lmcons.h
+    GetUserName(winUserName, &winUserNameSize);
+    userName = qt_winQString(winUserName);
+#endif // #if defined(UNICODE)
+    char winUserName[UNLEN + 1];    // UNLEN is defined in lmcons.h
+    GetUserNameA(winUserName, &winUserNameSize);
+    userName = QString::fromLocal8Bit(winUserName);
+#else // #if defined(Q_WS_WIN)
+    Username = QString::fromLocal8Bit(getlogin());
+#endif
+
     m_pPrefs = new Preferences(TITRAQ_PREFNAME, TITRAQ_APPTITLE, TITRAQ_PREFVER);
-    if (!m_pPrefs->fileState()) { // No file was found, so assume a null state
+    if (!m_pPrefs->fileState()) {   // No file was found, so assume a null state
+        if (!Username.isEmpty())
+            m_pPrefs->setString(TITRAQ_PREFUSER, Username);
+        else
+            m_pPrefs->setString(TITRAQ_PREFUSER, TITRAQ_DEFUSER);
         m_pPrefs->setString(TITRAQ_PREFASFILE, TITRAQ_DEFASFILE);
         m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE);
         m_pPrefs->setString(TITRAQ_PREFVIEW, TITRAQ_DEFVIEW);


ossp-pkg/as/as-gui/as_const.h 1.10 -> 1.11

--- as_const.h   2002/12/03 17:05:11     1.10
+++ as_const.h   2002/12/03 18:46:25     1.11
@@ -37,6 +37,8 @@
 #define TITRAQ_PREFNAME         "as_gui.conf"
 #define TITRAQ_APPTITLE         "AS Gui"
 #define TITRAQ_PREFVER          "0.5"
+#define TITRAQ_PREFUSER         "user"
+#define TITRAQ_DEFUSER          "username"
 #define TITRAQ_PREFASFILE       "asfile"
 #define TITRAQ_DEFASFILE        "/e/dev/as"
 #define TITRAQ_PREFSTYLE        "uistyle"


ossp-pkg/as/as-gui/as_dataop.cpp 1.11 -> 1.12

--- as_dataop.cpp        2002/12/03 17:34:19     1.11
+++ as_dataop.cpp        2002/12/03 18:46:25     1.12
@@ -160,7 +160,8 @@
         else
             bValid = false;
 
-        Tstream << trUtf8(" ") << trUtf8("user");   // Save user field text
+        // Save user field text
+        Tstream << trUtf8(" ") << m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER);
 
         Tempfield = m_pMaintable->text(nIter, 1);   // Load start field text
         if (Tempfield != NULL)

CVSTrac 2.0.1