summaryrefslogtreecommitdiffstats
path: root/src/maingui/printergui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/maingui/printergui.cpp')
-rw-r--r--src/maingui/printergui.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/maingui/printergui.cpp b/src/maingui/printergui.cpp
index 90d4731..5e2ba39 100644
--- a/src/maingui/printergui.cpp
+++ b/src/maingui/printergui.cpp
@@ -3,6 +3,7 @@
#include <QMessageBox>
#include <unistd.h>
#include <QTimer>
+#include <pwd.h>
// ____________________________________________________________________________
PrinterGui::PrinterGui(char *argv[], QWidget *parent) :
@@ -13,10 +14,11 @@ PrinterGui::PrinterGui(char *argv[], QWidget *parent) :
// When called it is guaranteed that argv has (at least) 3 elements
// Set username
- char buf[200];
- if (getlogin_r(buf, 200) == 0) {
+ // Do not use getlogin[_r] as it doesn't fucking work!
+ struct passwd *pw = getpwuid(getuid());
+ if (pw != NULL && pw->pw_name != NULL) {
// Detect real name
- this->user = strdup(buf);
+ this->user = strdup(pw->pw_name);
} else {
// Fallback to what command line says
this->user = strdup(argv[1]);
@@ -90,6 +92,7 @@ void PrinterGui::initializeUI()
QRect desktopRect = QApplication::desktop()->screenGeometry(this);
this->move( desktopRect.width()/2-this->width()/2,
desktopRect.height()/2-this->height()/2);
+ this->setWindowTitle(QString::fromUtf8("Drucken - %1").arg(this->user));
}
// ____________________________________________________________________________
@@ -215,7 +218,7 @@ void PrinterGui::on_buttonPrint_clicked()
cupsSetUser(this->user);
char jobtitle[100];
- snprintf(jobtitle, 100, "gui-%d", (int)getpid());
+ snprintf(jobtitle, 100, "gui-%d-%s", (int)getpid(), this->user);
// Drucken
if( 0 == cupsPrintFile(dest->name,
@@ -239,7 +242,7 @@ void PrinterGui::on_bgTimer_timeout()
}
if (++this->bgTimeout > 4) {
// Job was sent, GUI is invisible, quit after a few seconds
- QCoreApplication::instance()->quit();
+ QCoreApplication::instance()->exit(0);
}
}