-rw-r--r-- | noncore/net/ftplib/ftplib.c (renamed from noncore/net/opieftp/ftplib.c) | 60 | ||||
-rw-r--r-- | noncore/net/ftplib/ftplib.control | 9 | ||||
-rw-r--r-- | noncore/net/ftplib/ftplib.h (renamed from noncore/net/opieftp/ftplib.h) | 0 | ||||
-rw-r--r-- | noncore/net/ftplib/ftplib.pro | 6 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.control | 2 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 6 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.h | 2 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.pro | 4 |
8 files changed, 81 insertions, 8 deletions
diff --git a/noncore/net/opieftp/ftplib.c b/noncore/net/ftplib/ftplib.c index 5116170..421f855 100644 --- a/noncore/net/opieftp/ftplib.c +++ b/noncore/net/ftplib/ftplib.c @@ -19,33 +19,45 @@ /* Boston, MA 02111-1307, USA. */ /* */ /***************************************************************************/ - +// changes made by Lorn Potter <llornkcor@handhelds.org> +// #if defined(__unix__) || defined(__VMS) #include <unistd.h> #endif #if defined(_WIN32) #include <windows.h> #endif + #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <ctype.h> + #if defined(__unix__) + +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <arpa/inet.h> + #elif defined(VMS) + #include <types.h> #include <socket.h> #include <in.h> #include <netdb.h> #include <inet.h> + #elif defined(_WIN32) + #include <winsock.h> + #endif #define BUILDING_LIBRARY @@ -58,7 +70,7 @@ #endif #define FTPLIB_BUFSIZ 8192 -#define ACCEPT_TIMEOUT 15 +#define ACCEPT_TIMEOUT 10 #define FTPLIB_CONTROL 0 #define FTPLIB_READ 1 @@ -382,7 +394,7 @@ GLOBALDEF char *FtpLastResponse(netbuf *nControl) */ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) { - int sControl; + int sControl, stat, flags, oldflags; struct sockaddr_in sin; struct hostent *phe; struct servent *pse; @@ -390,6 +402,8 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) netbuf *ctrl; char *lhost; char *pnum; + struct timeval tv; + fd_set wr; memset(&sin,0,sizeof(sin)); sin.sin_family = AF_INET; @@ -426,15 +440,19 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) perror("gethostbyname"); return 0; } + memcpy((char *)&sin.sin_addr, phe->h_addr, phe->h_length); + } free(lhost); + sControl = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sControl == -1) { perror("socket"); return 0; } + if (setsockopt(sControl,SOL_SOCKET,SO_REUSEADDR, SETSOCKOPT_OPTVAL_TYPE &on, sizeof(on)) == -1) { @@ -442,12 +460,45 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) net_close(sControl); return 0; } - if (connect(sControl, (struct sockaddr *)&sin, sizeof(sin)) == -1) + + //set nonblocking for connection timeout + flags = fcntl( sControl, F_GETFL,0); + oldflags=flags; + fcntl( sControl, F_SETFL, O_NONBLOCK|flags); + + stat=connect( sControl, (struct sockaddr *)&sin, sizeof(sin)); + if (stat < 0) + { + if (errno != EWOULDBLOCK && errno != EINPROGRESS) { perror("connect"); net_close(sControl); return 0; } + } + + FD_ZERO(&wr); + FD_SET( sControl, &wr); + + tv.tv_sec = ACCEPT_TIMEOUT; + tv.tv_usec = 0; + + stat = select(sControl+1, 0, &wr, 0, &tv); + + if (stat < 1) + { + // time out has expired, + // or an error has ocurred + perror("timeout"); + net_close(sControl); + return 0; + } + + printf("connected\n"); + + //set original flags + fcntl( sControl, F_SETFL, oldflags); + ctrl = calloc(1,sizeof(netbuf)); if (ctrl == NULL) { @@ -737,6 +788,7 @@ static int FtpAcceptConnection(netbuf *nData, netbuf *nControl) FD_SET(nData->handle, &mask); tv.tv_usec = 0; tv.tv_sec = ACCEPT_TIMEOUT; + printf("<<<<<<<<<<<<<<<<%d\n",ACCEPT_TIMEOUT); i = nControl->handle; if (i < nData->handle) i = nData->handle; diff --git a/noncore/net/ftplib/ftplib.control b/noncore/net/ftplib/ftplib.control new file mode 100644 index 0000000..67765ad --- a/dev/null +++ b/noncore/net/ftplib/ftplib.control @@ -0,0 +1,9 @@ +Files: $QTDIR/lib/libftplib.* +Priority: optional +Section: Communications +Maintainer: L.J. Potter <ljp@llornkcor.com> +Architecture: arm +Version: $QPE_VERSION-$SUB_VERSION +Depends: opie-base ($QPE_VERSION) +Description: Libftp + The ftp library for the Opie environment. diff --git a/noncore/net/opieftp/ftplib.h b/noncore/net/ftplib/ftplib.h index 75a90ae..75a90ae 100644 --- a/noncore/net/opieftp/ftplib.h +++ b/noncore/net/ftplib/ftplib.h diff --git a/noncore/net/ftplib/ftplib.pro b/noncore/net/ftplib/ftplib.pro new file mode 100644 index 0000000..9ee3605 --- a/dev/null +++ b/noncore/net/ftplib/ftplib.pro @@ -0,0 +1,6 @@ +TEMPLATE = lib +CONFIG = qt warn_on release +HEADERS = ftplib.h +SOURCES = ftplib.c +DESTDIR = $(QTDIR)/lib$(PROJMAK) +INTERFACES = diff --git a/noncore/net/opieftp/opieftp.control b/noncore/net/opieftp/opieftp.control index 18ec80f..42590bd 100644 --- a/noncore/net/opieftp/opieftp.control +++ b/noncore/net/opieftp/opieftp.control @@ -4,6 +4,6 @@ Section: Communications Maintainer: L.J. Potter <ljp@llornkcor.com> Architecture: arm Version: $QPE_VERSION-$SUB_VERSION -Depends: opie-base ($QPE_VERSION) +Depends: opie-base ($QPE_VERSION), ftplib Description: OpieFtp The ftp client for the Opie environment. diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 292cc9d..7c83223 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -14,7 +14,7 @@ #include "opieftp.h" extern "C" { -#include "ftplib.h" +#include "../ftplib/ftplib.h" } #include "inputDialog.h" @@ -1510,3 +1510,7 @@ void OpieFtp::serverListClicked( const QString &item) { serverComboSelected(i-1); } } + +void OpieFtp::timerOut() { + +} diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h index 2aa691a..109b5f8 100644 --- a/noncore/net/opieftp/opieftp.h +++ b/noncore/net/opieftp/opieftp.h @@ -39,6 +39,7 @@ class QPushButton; class QToolButton; class QStringList; class QListBox; +class QTimer; class OpieFtp : public QMainWindow { @@ -67,6 +68,7 @@ public: bool b; int currentServerConfig; protected slots: + void timerOut(); void upDir(); void homeButtonPushed(); void docButtonPushed(); diff --git a/noncore/net/opieftp/opieftp.pro b/noncore/net/opieftp/opieftp.pro index 6d88530..ae72ff3 100644 --- a/noncore/net/opieftp/opieftp.pro +++ b/noncore/net/opieftp/opieftp.pro @@ -1,12 +1,12 @@ TEMPLATE = app CONFIG += qt warn_on release HEADERS = opieftp.h inputDialog.h ftplib.h -SOURCES = opieftp.cpp inputDialog.cpp ftplib.c main.cpp +SOURCES = opieftp.cpp inputDialog.cpp main.cpp TARGET = opieftp DESTDIR = $(OPIEDIR)/bin INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -lftplib TRANSLATIONS = ../../../i18n/de/opieftp.ts \ ../../../i18n/en/opieftp.ts \ |