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

tdeprint

  • tdeprint
  • lpr
lprsettings.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001,2002 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 "lprsettings.h"
21 #include "kmmanager.h"
22 #include "kmfactory.h"
23 
24 #include <tdeconfig.h>
25 #include <tqfile.h>
26 #include <tqtextstream.h>
27 
28 #define LPDCONF "/etc/lpd.conf"
29 #define PRINTCAP "/etc/printcap"
30 
31 LprSettings* LprSettings::m_self = 0;
32 
33 LprSettings::LprSettings(TQObject *parent, const char *name)
34 : TQObject(parent, name), KPReloadObject(true)
35 {
36  init();
37 }
38 
39 LprSettings::~LprSettings()
40 {
41  m_self = 0;
42 }
43 
44 LprSettings* LprSettings::self()
45 {
46  if (!m_self)
47  {
48  m_self = new LprSettings(KMManager::self(), "LprSettings");
49  }
50  return m_self;
51 }
52 
53 void LprSettings::init()
54 {
55  // LPR/LPRng mode
56  TDEConfig *conf = KMFactory::self()->printConfig();
57  conf->setGroup("LPR");
58  TQString modestr = conf->readEntry("Mode");
59  if (modestr == "LPRng")
60  m_mode = LPRng;
61  else if (modestr == "LPR")
62  m_mode = LPR;
63  else
64  {
65  // try to guess
66  if (TQFile::exists(LPDCONF))
67  m_mode = LPRng;
68  else
69  m_mode = LPR;
70  }
71 
72  // Printcap file
73  m_printcapfile = TQString();
74  m_local = true;
75 
76  // Spool directory
77  m_spooldir = "/var/spool/lpd";
78 }
79 
80 TQString LprSettings::printcapFile()
81 {
82  if (m_printcapfile.isEmpty())
83  {
84  // default value
85  m_printcapfile = PRINTCAP;
86  if (m_mode == LPRng)
87  {
88  // look into /etc/lpd/conf file
89  TQFile cf(LPDCONF);
90  if (cf.open(IO_ReadOnly))
91  {
92  TQTextStream t(&cf);
93  TQString line;
94  while (!t.atEnd())
95  {
96  line = t.readLine().stripWhiteSpace();
97  if (line.startsWith("printcap_path"))
98  {
99  TQString filename = line.mid(14).stripWhiteSpace();
100  if (filename[0] != '|')
101  m_printcapfile = filename;
102  else
103  {
104  // should download the printcap file
105  // and set m_local to false
106  }
107  }
108  }
109  }
110  }
111  }
112  return m_printcapfile;
113 }
114 
115 TQString LprSettings::defaultRemoteHost()
116 {
117  if (m_defaultremotehost.isEmpty())
118  {
119  m_defaultremotehost = "localhost";
120  TQFile cf(LPDCONF);
121  if (cf.open(IO_ReadOnly))
122  {
123  TQTextStream t(&cf);
124  TQString line;
125  while (!t.atEnd())
126  {
127  line = t.readLine().stripWhiteSpace();
128  if (line.startsWith("default_remote_host"))
129  {
130  TQString hostname = line.mid(20).stripWhiteSpace();
131  m_defaultremotehost = hostname;
132  }
133  }
134  }
135  }
136  return m_defaultremotehost;
137 }
138 
139 void LprSettings::reload()
140 {
141 }
142 
143 void LprSettings::configChanged()
144 {
145  init();
146 }

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.8.8
This website is maintained by Timothy Pearson.