Index: ossp-pkg/as/as-gui/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/ChangeLog,v rcsdiff -q -kk '-r1.18' '-r1.19' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/ChangeLog,v' 2>/dev/null --- 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 Index: ossp-pkg/as/as-gui/Makefile.in RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/Makefile.in,v rcsdiff -q -kk '-r1.38' '-r1.39' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/Makefile.in,v' 2>/dev/null --- 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 Index: ossp-pkg/as/as-gui/TODO RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/TODO,v rcsdiff -q -kk '-r1.64' '-r1.65' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/TODO,v' 2>/dev/null --- 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 +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) --------------------- Index: ossp-pkg/as/as-gui/as_assist.cpp RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_assist.cpp,v rcsdiff -q -kk '-r1.89' '-r1.90' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_assist.cpp,v' 2>/dev/null --- 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 -#else -#include -#include -#endif // #if defined(Q_OS_WIN32) - // Qt style headers #include #include @@ -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 -// 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('/') + Index: ossp-pkg/as/as-gui/as_const.h RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_const.h,v rcsdiff -q -kk '-r1.38' '-r1.39' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_const.h,v' 2>/dev/null --- 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 Index: ossp-pkg/as/as-gui/as_user.cpp RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_user.cpp,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/as/as-gui/as_user.cpp,v' | diff -u /dev/null - -L'ossp-pkg/as/as-gui/as_user.cpp' 2>/dev/null --- ossp-pkg/as/as-gui/as_user.cpp +++ - 2025-04-18 21:27:52.957302322 +0200 @@ -0,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 +// Copyright (c) 2002-2003 Michael Schloh von Bennewitz +// +// 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 +#else +#include +#include +#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 +// 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) +} Index: ossp-pkg/as/as-gui/as_user.h RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_user.h,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/as/as-gui/as_user.h,v' | diff -u /dev/null - -L'ossp-pkg/as/as-gui/as_user.h' 2>/dev/null --- ossp-pkg/as/as-gui/as_user.h +++ - 2025-04-18 21:27:52.960048988 +0200 @@ -0,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 +// Copyright (c) 2002-2003 Michael Schloh von Bennewitz +// +// 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 + +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