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('/') +
|
|