[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/print-manager
From: Daniel Nicoletti <dantti85-kde () yahoo ! com ! br>
Date: 2010-06-08 2:28:57
Message-ID: 20100608022857.E9823AC8CE () svn ! kde ! org
[Download RAW message or body]
SVN commit 1135730 by dantti:
Commiting the rest of the changes...
M +1 -0 CMakeLists.txt
M +3 -2 cmake/modules/PkgConfigGetVar.cmake
M +3 -3 libqcups/ClassListWidget.cpp
M +4 -4 libqcups/ClassListWidget.h
M +1 -0 libqcups/ModifyPrinter.cpp
M +32 -0 libqcups/QCups.cpp
M +2 -0 libqcups/QCups.h
M +13 -10 libqcups/cupsActions.cpp
M +0 -1 libqcups/cupsActions.h
M +2 -3 printer-manager-kcm/PrinterDescription.cpp
--- trunk/playground/base/print-manager/CMakeLists.txt #1135729:1135730
@@ -5,6 +5,7 @@
find_package(KDE4 REQUIRED)
find_package(CUPS "1.4" REQUIRED)
+include(FindPkgConfig)
include(KDE4Defaults)
add_definitions(${QT_DEFINITIONS} ${KDE_DEFINITIONS})
--- trunk/playground/base/print-manager/cmake/modules/PkgConfigGetVar.cmake \
#1135729:1135730 @@ -20,12 +20,13 @@
ENDMACRO(PKGCONFIG_GETVAR _package _var _output_variable)
macro(dbus_add_activation_service _sources)
- PKGCONFIG_GETVAR(dbus-1 session_bus_services_dir _install_dir)
+ #PKGCONFIG_GETVAR(dbus-1 session_bus_services_dir _install_dir)
foreach (_i ${_sources})
get_filename_component(_service_file ${_i} ABSOLUTE)
string(REGEX REPLACE "\\.service.*$" ".service" _output_file ${_i})
set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_output_file})
configure_file(${_service_file} ${_target})
- install(FILES ${_target} DESTINATION ${_install_dir})
+ install(FILES ${_target} DESTINATION ${DBUS_SERVICES_INSTALL_DIR} )
+ #install(FILES ${_target} DESTINATION ${_install_dir})
endforeach (_i ${ARGN})
endmacro(dbus_add_activation_service _sources)
--- trunk/playground/base/print-manager/libqcups/ClassListWidget.cpp #1135729:1135730
@@ -31,8 +31,8 @@
using namespace QCups;
-ClassListWidget::ClassListWidget(const QString &destName, QWidget *parent)
- : QListView(parent), m_destName(destName)
+ClassListWidget::ClassListWidget(QWidget *parent)
+ : QListView(parent)
{
m_model = new QStandardItemModel(this);
setModel(m_model);
@@ -45,7 +45,7 @@
{
}
-void ClassListWidget::reload(const QStringList &memberNames)
+void ClassListWidget::reload(const QString &m_destName, const QStringList \
&memberNames) {
ReturnArguments dests;
// Ask just these attributes
--- trunk/playground/base/print-manager/libqcups/ClassListWidget.h #1135729:1135730
@@ -23,20 +23,21 @@
#include <QStandardItemModel>
#include <QListView>
+#include <kdemacros.h>
namespace QCups {
-class ClassListWidget : public QListView
+class KDE_EXPORT ClassListWidget : public QListView
{
Q_OBJECT
public:
- explicit ClassListWidget(const QString &destName, QWidget *parent = 0);
+ explicit ClassListWidget(QWidget *parent = 0);
~ClassListWidget();
bool hasChanges();
QStringList selectedDests() const;
- void reload(const QStringList &memberNames);
+ void reload(const QString &destName, const QStringList &memberNames = \
QStringList());
signals:
void changed(bool changed);
@@ -44,7 +45,6 @@
void modelChanged();
private:
- QString m_destName;
QStringList m_selectedDests;
bool m_changed;
QStandardItemModel *m_model;
--- trunk/playground/base/print-manager/libqcups/ModifyPrinter.cpp #1135729:1135730
@@ -50,6 +50,7 @@
membersL->setVisible(isClass);
membersLV->setVisible(isClass);
+ // TODO remove this member code and use the class list widget
m_model = new QStandardItemModel(membersLV);
membersLV->setModel(m_model);
--- trunk/playground/base/print-manager/libqcups/QCups.cpp #1135729:1135730
@@ -228,6 +228,7 @@
}
ipp_op_e op;
+ // TODO this seems weird now.. review this code..
if (isClass && values.contains("member-uris")) {
op = CUPS_ADD_CLASS;
} else {
@@ -455,6 +456,37 @@
return result;
}
+Result* QCups::addClass(const QHash<QString, QVariant> &values)
+{
+ if (values.isEmpty()) {
+ return 0;
+ }
+
+ QHash<QString, QVariant> request(values);
+ request["printer-is-class"] = true;
+ request["printer-is-accepting-jobs"] = true;
+ request["printer-state"] = IPP_PRINTER_IDLE;
+
+ ipp_op_e op = CUPS_ADD_CLASS;;
+// if (isClass && values.contains("member-uris")) {
+// op = CUPS_ADD_CLASS;
+// } else {
+// op = isClass ? CUPS_ADD_MODIFY_CLASS : CUPS_ADD_MODIFY_PRINTER;
+// }
+
+ Result *result = new Result(NCups::instance());
+ QMetaObject::invokeMethod(NCups::instance()->request(),
+ "request",
+ Qt::QueuedConnection,
+ Q_ARG(Result*, result),
+ Q_ARG(ipp_op_e, op),
+ Q_ARG(QString, "/admin/"),
+ Q_ARG(Arguments, request),
+ Q_ARG(bool, false));
+
+ return result;
+}
+
Result* QCups::Dest::getAttributes(const QString &destName, bool isClass, const \
QStringList &requestedAttr) {
Arguments request;
--- trunk/playground/base/print-manager/libqcups/QCups.h #1135729:1135730
@@ -105,6 +105,8 @@
KDE_EXPORT Result* getDests(int mask, const QStringList &requestedAttr = \
QStringList());
KDE_EXPORT Result* getJobs(const QString &destName, bool myJobs, int whichJobs, \
const QStringList &requestedAttr = QStringList());
+ KDE_EXPORT Result* addClass(const QHash<QString, QVariant> &values);
+
/*
The result will be in hashStrStr()
*/
--- trunk/playground/base/print-manager/libqcups/cupsActions.cpp #1135729:1135730
@@ -59,7 +59,7 @@
return request;
}
-static uint password_retries = 0;
+static int password_retries = 0;
const char * thread_password_cb(const char *prompt, http_t *http, const char \
*method, const char *resource, void *user_data) {
Q_UNUSED(prompt)
@@ -70,14 +70,14 @@
kDebug() << QThread::currentThreadId()
<< "-----------thread_password_cb------"<< "password_retries" << \
password_retries;
- if (password_retries == 3) {
+ if (++password_retries > 3) {
// cancel the authentication
cupsSetUser(NULL);
return NULL;
}
bool showErrorMessage = false;
- if (password_retries) {
+ if (password_retries > 1) {
showErrorMessage = true;
}
@@ -98,7 +98,7 @@
QObject *response = loop;
if (response->property("canceled").toBool()) {
// the dialog was canceled
- password_retries = 3;
+ password_retries = -1;
cupsSetUser(NULL);
return NULL;
} else {
@@ -138,16 +138,14 @@
bool Request::retry()
{
-// http_t *http = CUPS_HTTP_DEFAULT;
kDebug() << "cupsLastErrorString()" << cupsLastErrorString() << cupsLastError() \
<< IPP_FORBIDDEN;
-// kDebug() << http->digest_tries;
if (cupsLastError() == IPP_FORBIDDEN ||
cupsLastError() == IPP_NOT_AUTHORIZED ||
cupsLastError() == IPP_NOT_AUTHENTICATED) {
if (password_retries == 0) {
// try to authenticate as the root user
cupsSetUser("root");
- } else if (password_retries >= 3) {
+ } else if (password_retries > 3 || password_retries == -1) {
// the authentication failed 3 times
// OR the dialog was canceld (-1)
// reset to 0 and quit the do-while loop
@@ -157,9 +155,7 @@
// force authentication
kDebug() << "cupsDoAuthentication" << password_retries;
- if (cupsDoAuthentication(CUPS_HTTP_DEFAULT, "POST", "/") == -1) {
- }
- password_retries++;
+ cupsDoAuthentication(CUPS_HTTP_DEFAULT, "POST", "/");
// tries to do the action again
// sometimes just trying to be root works
return true;
@@ -337,13 +333,20 @@
while (i != values.constEnd()) {
switch (i.value().type()) {
case QVariant::Bool:
+ if (i.key() == "printer-is-accepting-jobs") {
+ ippAddBoolean(request, IPP_TAG_PRINTER, \
"printer-is-accepting-jobs", i.value().toBool()); + } else {
ippAddBoolean(request, IPP_TAG_OPERATION,
i.key().toUtf8(), i.value().toBool());
+ }
break;
case QVariant::Int:
if (i.key() == "job-id") {
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER,
"job-id", i.value().toInt());
+ } else if (i.key() == "printer-state") {
+ ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM,
+ "printer-state", IPP_PRINTER_IDLE);
} else {
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM,
i.key().toUtf8(), i.value().toInt());
--- trunk/playground/base/print-manager/libqcups/cupsActions.h #1135729:1135730
@@ -61,7 +61,6 @@
private:
void run();
-
};
};
--- trunk/playground/base/print-manager/printer-manager-kcm/PrinterDescription.cpp \
#1135729:1135730 @@ -34,11 +34,11 @@
PrinterDescription::PrinterDescription(QWidget *parent)
: QWidget(parent),
- m_markerChangeTime(0)
+ m_markerChangeTime(0),
+ m_isClass(false)
{
setupUi(this);
-// // setup default options
// loads the standard key icon
m_printerIcon = KIconLoader::global()->loadIcon("printer",
KIconLoader::NoGroup,
@@ -110,7 +110,6 @@
void PrinterDescription::setDestName(const QString &name, const QString \
&description, bool isClass) {
- m_isClass = isClass;
m_destName = name;
m_markerData.clear();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic