|
Lines 45-56
Link Here
|
| 45 |
#include <klocale.h> |
45 |
#include <klocale.h> |
| 46 |
#include <kconfig.h> |
46 |
#include <kconfig.h> |
| 47 |
#include <kstandarddirs.h> |
47 |
#include <kstandarddirs.h> |
|
|
48 |
#include <ksocketbase.h> |
| 48 |
#include <klibloader.h> |
49 |
#include <klibloader.h> |
| 49 |
#include <kmessagebox.h> |
50 |
#include <kmessagebox.h> |
| 50 |
#include <kaction.h> |
51 |
#include <kaction.h> |
| 51 |
#include <kdialogbase.h> |
52 |
#include <kdialogbase.h> |
| 52 |
#include <kextendedsocket.h> |
53 |
#include <kextendedsocket.h> |
| 53 |
#include <kprocess.h> |
54 |
#include <kprocess.h> |
|
|
55 |
#include <kbufferedsocket.h> |
| 54 |
#include <kfilterdev.h> |
56 |
#include <kfilterdev.h> |
| 55 |
#include <cups/cups.h> |
57 |
#include <cups/cups.h> |
| 56 |
#include <cups/ppd.h> |
58 |
#include <cups/ppd.h> |
|
Lines 88-94
static int trials = 5;
Link Here
|
| 88 |
|
90 |
|
| 89 |
KMCupsManager::~KMCupsManager() |
91 |
KMCupsManager::~KMCupsManager() |
| 90 |
{ |
92 |
{ |
| 91 |
//delete m_socket; |
93 |
delete m_socket; |
| 92 |
} |
94 |
} |
| 93 |
|
95 |
|
| 94 |
QString KMCupsManager::driverDbCreationProgram() |
96 |
QString KMCupsManager::driverDbCreationProgram() |
|
Lines 135-141
bool KMCupsManager::createPrinter(KMPrin
Link Here
|
| 135 |
{ |
137 |
{ |
| 136 |
req.setOperation(CUPS_ADD_CLASS); |
138 |
req.setOperation(CUPS_ADD_CLASS); |
| 137 |
QStringList members = p->members(), uris; |
139 |
QStringList members = p->members(), uris; |
| 138 |
QString s = QString::fromLocal8Bit("ipp://%1:%2/printers/").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port()); |
140 |
QString s; |
|
|
141 |
s = QString::fromLocal8Bit("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr()); |
| 139 |
for (QStringList::ConstIterator it=members.begin(); it!=members.end(); ++it) |
142 |
for (QStringList::ConstIterator it=members.begin(); it!=members.end(); ++it) |
| 140 |
uris.append(s+(*it)); |
143 |
uris.append(s+(*it)); |
| 141 |
req.addURI(IPP_TAG_PRINTER,"member-uris",uris); |
144 |
req.addURI(IPP_TAG_PRINTER,"member-uris",uris); |
|
Lines 907-931
void KMCupsManager::ippReport(IppRequest
Link Here
|
| 907 |
|
910 |
|
| 908 |
QString KMCupsManager::stateInformation() |
911 |
QString KMCupsManager::stateInformation() |
| 909 |
{ |
912 |
{ |
| 910 |
return QString("%1: %2:%3") |
913 |
return QString("%1: %2") |
| 911 |
.arg(i18n("Server")) |
914 |
.arg(i18n("Server")) |
| 912 |
.arg(CupsInfos::self()->host()) |
915 |
.arg(CupsInfos::self()->hostaddr()); |
| 913 |
.arg(CupsInfos::self()->port()); |
|
|
| 914 |
} |
916 |
} |
| 915 |
|
917 |
|
| 916 |
void KMCupsManager::checkUpdatePossibleInternal() |
918 |
void KMCupsManager::checkUpdatePossibleInternal() |
| 917 |
{ |
919 |
{ |
| 918 |
kdDebug(500) << "Checking for update possible" << endl; |
920 |
kdDebug(500) << "Checking for update possible" << endl; |
| 919 |
delete m_socket; |
921 |
delete m_socket; |
| 920 |
/*m_socket = new KExtendedSocket( CupsInfos::self()->host(), CupsInfos::self()->port() ); |
922 |
m_socket = new KNetwork::KBufferedSocket; |
| 921 |
connect( m_socket, SIGNAL( connectionSuccess() ), SLOT( slotConnectionSuccess() ) ); |
923 |
m_socket->setTimeout( 1 ); |
| 922 |
connect( m_socket, SIGNAL( connectionFailed( int ) ), SLOT( slotConnectionFailed( int ) ) ); |
924 |
connect( m_socket, SIGNAL( connected(const KResolverEntry&) ), |
| 923 |
m_socket->setTimeout( 1 );*/ |
925 |
SLOT( slotConnectionSuccess() ) ); |
| 924 |
m_socket = new QSocket( this ); |
926 |
connect( m_socket, SIGNAL( gotError( int ) ), SLOT( slotConnectionFailed( int ) ) ); |
| 925 |
connect( m_socket, SIGNAL( connected() ), SLOT( slotConnectionSuccess() ) ); |
927 |
|
| 926 |
connect( m_socket, SIGNAL( error( int ) ), SLOT( slotConnectionFailed( int ) ) ); |
928 |
trials = 5; |
| 927 |
trials = 5; |
929 |
QTimer::singleShot( 1, this, SLOT( slotAsyncConnect() ) ); |
| 928 |
QTimer::singleShot( 1, this, SLOT( slotAsyncConnect() ) ); |
|
|
| 929 |
} |
930 |
} |
| 930 |
|
931 |
|
| 931 |
void KMCupsManager::slotConnectionSuccess() |
932 |
void KMCupsManager::slotConnectionSuccess() |
|
Lines 959-965
void KMCupsManager::slotAsyncConnect()
Link Here
|
| 959 |
{ |
960 |
{ |
| 960 |
kdDebug(500) << "Starting async connect" << endl; |
961 |
kdDebug(500) << "Starting async connect" << endl; |
| 961 |
//m_socket->startAsyncConnect(); |
962 |
//m_socket->startAsyncConnect(); |
| 962 |
m_socket->connectToHost( CupsInfos::self()->host(), CupsInfos::self()->port() ); |
963 |
if (CupsInfos::self()->host().startsWith("/")) |
|
|
964 |
m_socket->connect( QString(), CupsInfos::self()->host()); |
| 965 |
else |
| 966 |
m_socket->connectToHost( CupsInfos::self()->host(), CupsInfos::self()->port() ); |
| 963 |
} |
967 |
} |
| 964 |
|
968 |
|
| 965 |
void KMCupsManager::slotConnectionFailed( int errcode ) |
969 |
void KMCupsManager::slotConnectionFailed( int errcode ) |
|
Lines 975-983
void KMCupsManager::slotConnectionFailed
Link Here
|
| 975 |
return; |
979 |
return; |
| 976 |
} |
980 |
} |
| 977 |
|
981 |
|
| 978 |
setErrorMsg( i18n( "Connection to CUPS server failed. Check that the CUPS server is correctly installed and running. " |
982 |
QString einfo; |
| 979 |
"Error: %1." ).arg( errcode == QSocket::ErrConnectionRefused ? i18n( "connection refused" ) : i18n( "host not found" ) ) ); |
983 |
|
| 980 |
setUpdatePossible( false ); |
984 |
switch (errcode) { |
|
|
985 |
case KNetwork::KSocketBase::ConnectionRefused: |
| 986 |
case KNetwork::KSocketBase::ConnectionTimedOut: |
| 987 |
einfo = i18n("connection refused") + QString(" (%1)").arg(errcode); |
| 988 |
break; |
| 989 |
case KNetwork::KSocketBase::LookupFailure: |
| 990 |
einfo = i18n("host not found") + QString(" (%1)").arg(errcode); |
| 991 |
break; |
| 992 |
case KNetwork::KSocketBase::WouldBlock: |
| 993 |
default: |
| 994 |
einfo = i18n("read failed (%1)").arg(errcode); |
| 995 |
break; |
| 996 |
} |
| 997 |
|
| 998 |
setErrorMsg( i18n( "Connection to CUPS server failed. Check that the CUPS server is correctly installed and running. " |
| 999 |
"Error: %2: %1." ).arg( einfo, CupsInfos::self()->host())); |
| 1000 |
setUpdatePossible( false ); |
| 981 |
} |
1001 |
} |
| 982 |
|
1002 |
|
| 983 |
void KMCupsManager::hostPingSlot() { |
1003 |
void KMCupsManager::hostPingSlot() { |
|
Lines 1014-1020
QString printerURI(KMPrinter *p, bool us
Link Here
|
| 1014 |
if (use && !p->uri().isEmpty()) |
1034 |
if (use && !p->uri().isEmpty()) |
| 1015 |
uri = p->uri().prettyURL(); |
1035 |
uri = p->uri().prettyURL(); |
| 1016 |
else |
1036 |
else |
| 1017 |
uri = QString("ipp://%1:%2/%4/%3").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port()).arg(p->printerName()).arg((p->isClass(false) ? "classes" : "printers")); |
1037 |
uri = QString("ipp://%1/%3/%2").arg(CupsInfos::self()->hostaddr()).arg(p->printerName()).arg((p->isClass(false) ? "classes" : "printers")); |
| 1018 |
return uri; |
1038 |
return uri; |
| 1019 |
} |
1039 |
} |
| 1020 |
|
1040 |
|