• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
  • cups
kmwippselect.cpp
1/*
2 * This file is part of the KDE libraries
3 * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License version 2 as published by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 **/
19
20#include "kmwippselect.h"
21#include "kmwizard.h"
22#include "kmprinter.h"
23#include "cupsinfos.h"
24#include "ipprequest.h"
25
26#include <tdelistbox.h>
27#include <tqlayout.h>
28#include <tdelocale.h>
29#include <kdebug.h>
30#include <kiconloader.h>
31
32#include "config.h"
33
34KMWIppSelect::KMWIppSelect(TQWidget *parent, const char *name)
35: KMWizardPage(parent,name)
36{
37 m_ID = KMWizard::IPPSelect;
38 m_title = i18n("Remote IPP Printer Selection");
39 m_nextpage = KMWizard::Driver;
40
41 m_list = new TDEListBox(this);
42
43 TQVBoxLayout *lay = new TQVBoxLayout(this, 0, 0);
44 lay->addWidget(m_list);
45}
46
47bool KMWIppSelect::isValid(TQString& msg)
48{
49 if (m_list->currentItem() == -1)
50 {
51 msg = i18n("You must select a printer.");
52 return false;
53 }
54 return true;
55}
56
57void KMWIppSelect::initPrinter(KMPrinter *p)
58{
59 // storage variables
60 TQString host, login, password;
61 int port;
62
63 // save config
64 host = CupsInfos::self()->host();
65 login = CupsInfos::self()->login();
66 password = CupsInfos::self()->password();
67 port = CupsInfos::self()->port();
68
69 m_list->clear();
70
71 // retrieve printer list
72 KURL url = p->device();
73 CupsInfos::self()->setHost(url.host());
74 CupsInfos::self()->setLogin(url.user());
75 CupsInfos::self()->setPassword(url.pass());
76 CupsInfos::self()->setPort(url.port());
77 IppRequest req;
78 TQString uri;
79 req.setOperation(CUPS_GET_PRINTERS);
80 uri = TQString::fromLatin1("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr());
81 req.addURI(IPP_TAG_OPERATION,"printer-uri",uri);
82 req.addKeyword(IPP_TAG_OPERATION,"requested-attributes",TQString::fromLatin1("printer-name"));
83 if (req.doRequest("/printers/"))
84 {
85 ipp_attribute_t *attr = req.first();
86 while (attr)
87 {
88#ifdef HAVE_CUPS_1_6
89 if (ippGetName(attr) && strcmp(ippGetName(attr),"printer-name") == 0)
90 m_list->insertItem(SmallIcon("tdeprint_printer"),TQString::fromLatin1(ippGetString(attr, 0, NULL)));
91 attr = ippNextAttribute(req.request());
92#else // HAVE_CUPS_1_6
93 if (attr->name && strcmp(attr->name,"printer-name") == 0)
94 m_list->insertItem(SmallIcon("tdeprint_printer"),TQString::fromLatin1(attr->values[0].string.text));
95 attr = attr->next;
96#endif // HAVE_CUPS_1_6
97 }
98 m_list->sort();
99 }
100
101 // restore config
102 CupsInfos::self()->setHost(host);
103 CupsInfos::self()->setLogin(login);
104 CupsInfos::self()->setPassword(password);
105 CupsInfos::self()->setPort(port);
106}
107
108void KMWIppSelect::updatePrinter(KMPrinter *p)
109{
110 KURL url = p->device();
111 TQString path = m_list->currentText();
112 path.prepend("/printers/");
113 url.setPath(path);
114 p->setDevice(url.url());
115kdDebug(500) << url.url() << endl;
116}

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.9.4
This website is maintained by Timothy Pearson.