kmwsocketutil.h
00001 /* 00002 * This file is part of the KDE libraries 00003 * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License version 2 as published by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 **/ 00019 00020 #ifndef KMWSOCKETUTIL_H 00021 #define KMWSOCKETUTIL_H 00022 00023 #include <qstring.h> 00024 #include <qptrlist.h> 00025 #include <kdialogbase.h> 00026 00027 struct SocketInfo 00028 { 00029 QString IP; 00030 QString Name; 00031 int Port; 00032 }; 00033 00034 class QProgressBar; 00035 class QLineEdit; 00036 class QComboBox; 00037 class KMWSocketUtil; 00038 00039 class SocketConfig : public KDialogBase 00040 { 00041 friend class KMWSocketUtil; 00042 Q_OBJECT 00043 public: 00044 SocketConfig(KMWSocketUtil *util, QWidget *parent = 0, const char *name = 0); 00045 ~SocketConfig(); 00046 00047 protected slots: 00048 void slotOk(); 00049 00050 private: 00051 QLineEdit *mask_, *tout_; 00052 QComboBox *port_; 00053 }; 00054 00055 class KMWSocketUtil 00056 { 00057 friend class SocketConfig; 00058 00059 public: 00060 KMWSocketUtil(); 00061 00062 bool checkPrinter(const QString& host, int port, QString* hostname = 0); 00063 00064 const QPtrList<SocketInfo>* printerList() { return &printerlist_; } 00065 bool scanNetwork(QProgressBar *bar = 0); 00066 void configureScan(QWidget *parent = 0); 00067 void setDefaultPort(int p) { port_ = p; } 00068 00069 private: 00070 QPtrList<SocketInfo> printerlist_; 00071 QString root_; 00072 int port_; 00073 int timeout_; // in milliseconds 00074 }; 00075 00076 #endif