KDECore
k3socks.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2001 George Staikos <staikos@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 #ifndef _KSOCKS_H_ 00019 #define _KSOCKS_H_ 00020 00021 #if defined(I_KNOW_KSOCKS_ISNT_PUBLIC) 00022 /* "ksocks.h is not public API" */ 00023 00024 #include <kdecore_export.h> 00025 00026 #include <QtCore/QStringList> 00027 #include <sys/types.h> 00028 #include <sys/socket.h> 00029 #include <sys/time.h> 00030 #include <unistd.h> 00031 00032 #ifdef Q_OS_UNIX 00033 00034 class KConfigGroup; 00035 struct sockaddr; 00036 00037 00049 class KDECORE_EXPORT KSocks { 00050 public: 00051 00057 static KSocks *self(); 00058 00063 static bool activated(); 00064 00068 void disableSocks(); 00069 00073 void enableSocks(); 00074 00079 bool usingSocks(); 00080 00085 bool hasSocks(); 00086 00091 bool hasWorkingAsyncConnect(); 00092 00093 /* 00094 ** REIMPLEMENTATIONS OF LIBC SOCKET FUNCTIONS 00095 **/ 00100 int connect (int sockfd, const sockaddr *serv_addr, 00101 kde_socklen_t addrlen); 00106 signed long int read (int fd, void *buf, unsigned long int count); 00111 signed long int write (int fd, const void *buf, unsigned long int count); 00116 int recvfrom (int s, void *buf, unsigned long int len, int flags, 00117 sockaddr *from, kde_socklen_t *fromlen); 00122 int sendto (int s, const void *msg, unsigned long int len, int flags, 00123 const sockaddr *to, kde_socklen_t tolen); 00128 int recv (int s, void *buf, unsigned long int len, int flags); 00133 int send (int s, const void *msg, unsigned long int len, int flags); 00138 int getsockname (int s, sockaddr *name, kde_socklen_t *namelen); 00143 int getpeername (int s, sockaddr *name, kde_socklen_t *namelen); 00148 int accept (int s, sockaddr *addr, kde_socklen_t *addrlen); 00153 int select (int n, fd_set *readfds, fd_set *writefds, 00154 fd_set *exceptfds, struct timeval *timeout); 00159 int listen (int s, int backlog); 00160 00165 int bind (int sockfd, sockaddr *my_addr, 00166 kde_socklen_t addrlen); 00167 int bind (int sockfd, const sockaddr *my_addr, 00168 kde_socklen_t addrlen); 00169 00175 void die(); 00176 00181 static void disable(); 00182 00187 static void setConfig(const KConfigGroup *config); 00188 00189 private: 00190 explicit KSocks(const KConfigGroup *config); 00191 ~KSocks(); 00192 00193 void stopSocks(); 00194 00195 static KSocks *_me; 00196 static bool _disabled; 00197 00198 00199 class KSocksPrivate; 00200 KSocksPrivate * const d; 00201 }; 00202 00203 #endif //Q_OS_UNIX 00204 00205 #endif 00206 #endif //_KSOCKS_H_
KDE 4.6 API Reference