summaryrefslogtreecommitdiffstats
path: root/src/maingui
diff options
context:
space:
mode:
authorSimon Rettberg2014-02-07 20:11:48 +0100
committerSimon Rettberg2014-02-07 20:11:48 +0100
commit2350016aeee4c71c9afad94c32ceaa73d92b8f24 (patch)
treecc6bbc82c76363d77d8c877a22e30ab12aae5b83 /src/maingui
parentForgot header (diff)
downloadprintergui-2350016aeee4c71c9afad94c32ceaa73d92b8f24.tar.gz
printergui-2350016aeee4c71c9afad94c32ceaa73d92b8f24.tar.xz
printergui-2350016aeee4c71c9afad94c32ceaa73d92b8f24.zip
Finally make it work as intended.
There's probably some debug code and debug output left in some places that needs to be replaced. TODO: - Focus should be in password box when showing pwgui - Pressing return should be clicking OK - Pressing escape should be clicking Cancel
Diffstat (limited to 'src/maingui')
-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);
}
}