OSSP CVS Repository

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

Check-in Number: 3968
Date: 2003-Jan-30 17:51:45 (local)
2003-Jan-30 16:51:45 (UTC)
User:ms
Branch:
Comment: Use a new aggregate class User to prefer user data from environment to that of underlying system.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/ChangeLog      1.18 -> 1.19     1 inserted, 0 deleted
ossp-pkg/as/as-gui/Makefile.in      1.38 -> 1.39     2 inserted, 2 deleted
ossp-pkg/as/as-gui/TODO      1.64 -> 1.65     1 inserted, 1 deleted
ossp-pkg/as/as-gui/as_assist.cpp      1.89 -> 1.90     5 inserted, 37 deleted
ossp-pkg/as/as-gui/as_const.h      1.38 -> 1.39     4 inserted, 0 deleted
ossp-pkg/as/as-gui/as_user.cpp      added-> 1.1
ossp-pkg/as/as-gui/as_user.h      added-> 1.1

ossp-pkg/as/as-gui/ChangeLog 1.18 -> 1.19

--- ChangeLog    2003/01/30 14:36:00     1.18
+++ ChangeLog    2003/01/30 16:51:45     1.19
@@ -2,6 +2,7 @@
 
 030130 Made day date section focus the default value
        Remove hackful zero date value, replace with current date
+       Added aggregate class User, and prefer user data from environment
 
 030129 Fixed the autoscroll before show bug, causing wrong data position
 


ossp-pkg/as/as-gui/Makefile.in 1.38 -> 1.39

--- Makefile.in  2003/01/27 18:20:49     1.38
+++ Makefile.in  2003/01/30 16:51:45     1.39
@@ -72,9 +72,9 @@
 TARGET_PROGS    = as-gui
 TARGET_MANS     = as-gui.1 as-gui.conf.5
 
-SRCS            = as_main.cpp as_gui.cpp as_assist.cpp as_slot.cpp as_dataop.cpp as_except.cpp as_generic.cpp as_amount.cpp as_table.cpp as_pref.cpp as_rand.cpp as_uuid.cpp as_version.cpp
+SRCS            = as_main.cpp as_gui.cpp as_assist.cpp as_slot.cpp as_dataop.cpp as_except.cpp as_generic.cpp as_amount.cpp as_table.cpp as_pref.cpp as_user.cpp as_rand.cpp as_uuid.cpp as_version.cpp
 
-OBJS            = as_main.o as_gui.o as_assist.o as_slot.o as_dataop.o as_except.o as_generic.o as_amount.o as_table.o as_pref.o as_rand.o as_uuid.o as_version.o
+OBJS            = as_main.o as_gui.o as_assist.o as_slot.o as_dataop.o as_except.o as_generic.o as_amount.o as_table.o as_pref.o as_user.o as_rand.o as_uuid.o as_version.o
 
 GRAFX           = gfx/ossplogo.xpm
 


ossp-pkg/as/as-gui/TODO 1.64 -> 1.65

--- TODO 2003/01/30 16:26:02     1.64
+++ TODO 2003/01/30 16:51:45     1.65
@@ -31,13 +31,13 @@
 Solve problem with nonorthogonal ' ' '-' '=' data token separators
 Use namespace 'AS' or unique identifier 'AS' for all classnames
 Unify class mycl = class(), class mycl(), class *pMycl, auto_ptr<class *>
+Win32 code in User class is only half written, and incomplete homedir
 
 For immediate release
 ---------------------
 Name changes to as-gui throughout
 Allow non alphanumerics in Remarks
 Write a magic cookie on new document generation
-Prefer environment variables to system passwd for user data
 
 Bugs (? = unverified)
 ---------------------


ossp-pkg/as/as-gui/as_assist.cpp 1.89 -> 1.90

--- as_assist.cpp        2003/01/30 14:36:00     1.89
+++ as_assist.cpp        2003/01/30 16:51:45     1.90
@@ -29,14 +29,6 @@
 //  titassist.cpp: ISO C++ implementation
 //
 
-// For username research
-#if defined(Q_OS_WIN32)
-#include <lmcons.h>
-#else
-#include <pwd.h>
-#include <unistd.h>
-#endif // #if defined(Q_OS_WIN32)
-
 // Qt style headers
 #include <qcdestyle.h>
 #include <qsgistyle.h>
@@ -57,6 +49,7 @@
 // User interface
 #include "as_gui.h"             // Main classes
 #include "as_amount.h"          // AmountBox class
+#include "as_user.h"            // User class
 
 // Icon pixel maps
 #include "as_gfx/filenew.xpm"   // static const char *s_kpcFilenew_xpm[]
@@ -90,35 +83,10 @@
 //
 void Titraqform::setupPrefs(void)
 {
-    QString Username, Homedir;
-
-// Start the show by getting the username
-#if defined(Q_OS_WIN32)
-    {
-        DWORD dwWinusernamesize = sizeof(dwWinusernamesize);
-#if defined(UNICODE)
-        TCHAR szWinusername[UNLEN + 1];   // UNLEN is defined in lmcons.h
-        GetUserName(szWinusername, &dwWinusernamesize);
-        Username = qt_winQString(szWinusername);
-#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
-    {
-//#include <stdio.h>
-//        char *szUser = NULL;
-//        szUser = cuserid();
-//        Username = QString::fromLocal8Bit(szUser);
-        char *szLogin = getlogin();
-        passwd *pUserpwd = getpwnam(szLogin);
-
-        Homedir = QString::fromLocal8Bit(pUserpwd->pw_dir);
-        Username = QString::fromLocal8Bit(szLogin);
-    }
-#endif  // #if defined(Q_OS_WIN32)
+    // Can't bootstrap until we know who is using our tool, so find out
+    User Localuser   = User();
+    QString Username = Localuser.getName();
+    QString Homedir  = Localuser.getHomedir();
 
     // Bootstrap a user preferences object from operating system info
     m_pPrefs = new Preferences(Homedir + QChar('/') +


ossp-pkg/as/as-gui/as_const.h 1.38 -> 1.39

--- as_const.h   2003/01/30 14:36:01     1.38
+++ as_const.h   2003/01/30 16:51:45     1.39
@@ -55,6 +55,10 @@
 #define TITRAQ_PREFLOCALLOG     "loglocal"
 #define TITRAQ_DEFLOCALLOG      "no"
 
+// Environment strings
+#define TITRAQ_ENVUSERNAME      "LOGNAME"
+#define TITRAQ_ENVHOMEDIR       "HOMEDIR"
+
 // Column show preferences
 #define TITRAQ_PREFSTATCOLON    "statcolshow"
 #define TITRAQ_DEFSTATCOLON     true


ossp-pkg/as/as-gui/as_user.cpp -> 1.1

*** /dev/null    Sat Nov 23 06:16:06 2024
--- -    Sat Nov 23 06:16:14 2024
***************
*** 0 ****
--- 1,85 ----
+ //
+ //  OSSP asgui - Accounting system graphical user interface
+ //  Copyright (c) 2002-2003 The OSSP Project (http://www.ossp.org/)
+ //  Copyright (c) 2002-2003 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ //  Copyright (c) 2002-2003 Ralf S. Engelschall <rse@engelschall.com>
+ //  Copyright (c) 2002-2003 Michael Schloh von Bennewitz <michael@schloh.com>
+ //
+ //  This file is part of OSSP asgui, an accounting system graphical user
+ //  interface which can be found at http://www.ossp.org/pkg/tool/asgui/.
+ //
+ //  Permission to use, copy, modify, and distribute this software for
+ //  any purpose with or without fee is hereby granted, provided that
+ //  the above copyright notice and this permission notice appear in all
+ //  copies.
+ //
+ //  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ //  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ //  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ //  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ //  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ //  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ //  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ //  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ //  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ //  SUCH DAMAGE.
+ //
+ //  as_user.cpp: ISO C++ implementation
+ //
+ 
+ // For username research
+ #if defined(Q_OS_WIN32)
+ #include <lmcons.h>
+ #else
+ #include <pwd.h>
+ #include <unistd.h>
+ #endif // #if defined(Q_OS_WIN32)
+ 
+ // Local class definitions
+ #include "as_user.h"
+ #include "as_const.h"
+ 
+ 
+ // Constructor
+ User::User(void)
+ {
+ // Start the show by getting the username
+ #if defined(Q_OS_WIN32)
+     {
+         DWORD dwWinusernamesize = sizeof(dwWinusernamesize);
+ #if defined(UNICODE)
+         TCHAR szWinusername[UNLEN + 1];   // UNLEN is defined in lmcons.h
+         GetUserName(szWinusername, &dwWinusernamesize);
+         m_Name = qt_winQString(szWinusername);
+ #else   // Not unicode
+         char szWinusername[UNLEN + 1];    // UNLEN is defined in lmcons.h
+         GetUserNameA(szWinusername, &dwWinusernamesize);
+         this->setName(szWinusername);
+     }
+ #endif  // #if defined(UNICODE)
+ #else   // Not windows
+     {
+ //#include <stdio.h>
+ //        char *szUser = NULL;
+ //        szUser = cuserid();
+ //        m_Name = QString::fromLocal8Bit(szUser);
+ 
+         // Get the user name from the environment
+         char *szLogin = getenv(TITRAQ_ENVUSERNAME);
+         if (szLogin == NULL)        // Is the user name in the environment?
+             szLogin = getlogin();   // No, so fetch it from the system
+ 
+         // Get the home directory from the environment
+         char *szHomedir = getenv(TITRAQ_ENVHOMEDIR);
+         if (szHomedir == NULL) {    // Is the home directory in the environment?
+             passwd *pUserpwd = getpwnam(szLogin); // No, so fetch it from the system
+             szHomedir = pUserpwd->pw_dir;         // Drill into the password struct
+         }
+ 
+         this->setName(szLogin);
+         this->setHomedir(szHomedir);
+     }
+ #endif  // #if defined(Q_OS_WIN32)
+ }


ossp-pkg/as/as-gui/as_user.h -> 1.1

*** /dev/null    Sat Nov 23 06:16:06 2024
--- -    Sat Nov 23 06:16:14 2024
***************
*** 0 ****
--- 1,60 ----
+ //
+ //  OSSP asgui - Accounting system graphical user interface
+ //  Copyright (c) 2002-2003 The OSSP Project (http://www.ossp.org/)
+ //  Copyright (c) 2002-2003 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ //  Copyright (c) 2002-2003 Ralf S. Engelschall <rse@engelschall.com>
+ //  Copyright (c) 2002-2003 Michael Schloh von Bennewitz <michael@schloh.com>
+ //
+ //  This file is part of OSSP asgui, an accounting system graphical user
+ //  interface which can be found at http://www.ossp.org/pkg/tool/asgui/.
+ //
+ //  Permission to use, copy, modify, and distribute this software for
+ //  any purpose with or without fee is hereby granted, provided that
+ //  the above copyright notice and this permission notice appear in all
+ //  copies.
+ //
+ //  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ //  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ //  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ //  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ //  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ //  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ //  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ //  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ //  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ //  SUCH DAMAGE.
+ //
+ //  as_user.h: ISO C++ interface
+ //
+ 
+ #ifndef USER_H
+ #define USER_H
+ 
+ // System headers
+ #include <string>
+ 
+ using std::string;
+ 
+ 
+ class User
+ {
+ private:
+     string m_Name;      // Holds the user name
+     string m_Homedir;   // Holds the user homedir
+ 
+ public:
+     User(void);
+ 
+     // Accessors
+     string getName(void) const {return m_Name;};
+     string getHomedir(void) const {return m_Homedir;};
+ 
+ protected:
+     // Accessors
+     void setName(const string Namein) {m_Name = Namein;};
+     void setHomedir(const string Dirin) {m_Homedir = Dirin;};
+ };
+ 
+ #endif // USER_H

CVSTrac 2.0.1