summaryrefslogtreecommitdiffstats
path: root/src/util/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/util.cpp')
-rwxr-xr-xsrc/util/util.cpp50
1 files changed, 13 insertions, 37 deletions
diff --git a/src/util/util.cpp b/src/util/util.cpp
index 05a209f..0fcfa84 100755
--- a/src/util/util.cpp
+++ b/src/util/util.cpp
@@ -7,10 +7,6 @@
#include <QStringList>
#include <iostream>
#include <QDir>
-#ifdef __WIN32__
- #include <windows.h>
- #include <Lmcons.h>
-#endif //__WIN32__
PVSServerEntry::PVSServerEntry(QString name)
{
@@ -49,11 +45,7 @@ int getRandom(int min, int max)
if (init)
{
init = false;
- #ifndef __WIN32__
srand ( time(NULL) + getpid() );
- #else
- srand ( time(NULL) ); /*might be solved by another random factor*/
- #endif
}
if (min >= max) return rand();
return rand() % (max-min+1) + min;
@@ -193,24 +185,10 @@ QString colonSplitter(QString line, bool first)
QString getUserName()
{
QString username;
- #ifdef __WIN32__
- WCHAR* lpszSystemInfo; // pointer to system information
- DWORD cchBuff = 256; // size of user name
- WCHAR tchBuffer[UNLEN + 1]; // buffer for expanded string
+ struct passwd* passUser = getpwuid(getuid());
+ if (passUser)
+ username = QString(passUser->pw_name);
- lpszSystemInfo = tchBuffer;
-
- // Get and display the user name.
- GetUserNameW(lpszSystemInfo, &cchBuff);
-
- //Unicode string needs to be converted
- username = QString::fromWCharArray(lpszSystemInfo);
- #else
- struct passwd* passUser = getpwuid(getuid());
- if (passUser)
- username = QString(passUser->pw_name);
-
- #endif //#ifdef __WIN32__
if (username.isEmpty())
{
qDebug("USERNAME COULDNT BE RETRIEVED!");
@@ -223,21 +201,19 @@ QString getUserName()
QString getFullUsername()
{
QString fullname = getUserName();
- #ifndef __WIN32__
- struct passwd *pd;
+ struct passwd *pd;
- if (NULL == (pd = getpwuid(getuid())))
- {ConsoleLog writeError("getpwuid() error.");}
- else
+ if (NULL == (pd = getpwuid(getuid())))
+ {ConsoleLog writeError("getpwuid() error.");}
+ else
+ {
+ QString tmp = pd->pw_gecos;
+ QStringList userData = tmp.split(",");
+ if(userData[0].length() > 0 )
{
- QString tmp = pd->pw_gecos;
- QStringList userData = tmp.split(",");
- if(userData[0].length() > 0 )
- {
- fullname = userData[0];
- }
+ fullname = userData[0];
}
- #endif //__WIN32__ //might be completed some time to a full solution for WIN32
+ }
return fullname;
}