-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 | |||
@@ -20,5 +20,6 @@ | |||
20 | /* */ | 20 | /* */ |
21 | /***************************************************************************/ | 21 | /***************************************************************************/ |
22 | 22 | // changes made by Lorn Potter <llornkcor@handhelds.org> | |
23 | // | ||
23 | #if defined(__unix__) || defined(__VMS) | 24 | #if defined(__unix__) || defined(__VMS) |
24 | #include <unistd.h> | 25 | #include <unistd.h> |
@@ -27,4 +28,5 @@ | |||
27 | #include <windows.h> | 28 | #include <windows.h> |
28 | #endif | 29 | #endif |
30 | |||
29 | #include <stdio.h> | 31 | #include <stdio.h> |
30 | #include <stdlib.h> | 32 | #include <stdlib.h> |
@@ -32,5 +34,10 @@ | |||
32 | #include <errno.h> | 34 | #include <errno.h> |
33 | #include <ctype.h> | 35 | #include <ctype.h> |
36 | |||
34 | #if defined(__unix__) | 37 | #if defined(__unix__) |
38 | |||
39 | #include <sys/types.h> | ||
40 | #include <unistd.h> | ||
41 | #include <fcntl.h> | ||
35 | #include <sys/time.h> | 42 | #include <sys/time.h> |
36 | #include <sys/types.h> | 43 | #include <sys/types.h> |
@@ -39,5 +46,7 @@ | |||
39 | #include <netdb.h> | 46 | #include <netdb.h> |
40 | #include <arpa/inet.h> | 47 | #include <arpa/inet.h> |
48 | |||
41 | #elif defined(VMS) | 49 | #elif defined(VMS) |
50 | |||
42 | #include <types.h> | 51 | #include <types.h> |
43 | #include <socket.h> | 52 | #include <socket.h> |
@@ -45,6 +54,9 @@ | |||
45 | #include <netdb.h> | 54 | #include <netdb.h> |
46 | #include <inet.h> | 55 | #include <inet.h> |
56 | |||
47 | #elif defined(_WIN32) | 57 | #elif defined(_WIN32) |
58 | |||
48 | #include <winsock.h> | 59 | #include <winsock.h> |
60 | |||
49 | #endif | 61 | #endif |
50 | 62 | ||
@@ -59,5 +71,5 @@ | |||
59 | 71 | ||
60 | #define FTPLIB_BUFSIZ 8192 | 72 | #define FTPLIB_BUFSIZ 8192 |
61 | #define ACCEPT_TIMEOUT 15 | 73 | #define ACCEPT_TIMEOUT 10 |
62 | 74 | ||
63 | #define FTPLIB_CONTROL 0 | 75 | #define FTPLIB_CONTROL 0 |
@@ -383,5 +395,5 @@ GLOBALDEF char *FtpLastResponse(netbuf *nControl) | |||
383 | GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) | 395 | GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) |
384 | { | 396 | { |
385 | int sControl; | 397 | int sControl, stat, flags, oldflags; |
386 | struct sockaddr_in sin; | 398 | struct sockaddr_in sin; |
387 | struct hostent *phe; | 399 | struct hostent *phe; |
@@ -391,4 +403,6 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) | |||
391 | char *lhost; | 403 | char *lhost; |
392 | char *pnum; | 404 | char *pnum; |
405 | struct timeval tv; | ||
406 | fd_set wr; | ||
393 | 407 | ||
394 | memset(&sin,0,sizeof(sin)); | 408 | memset(&sin,0,sizeof(sin)); |
@@ -427,7 +441,10 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) | |||
427 | return 0; | 441 | return 0; |
428 | } | 442 | } |
443 | |||
429 | memcpy((char *)&sin.sin_addr, phe->h_addr, phe->h_length); | 444 | memcpy((char *)&sin.sin_addr, phe->h_addr, phe->h_length); |
445 | |||
430 | } | 446 | } |
431 | free(lhost); | 447 | free(lhost); |
448 | |||
432 | sControl = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); | 449 | sControl = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); |
433 | if (sControl == -1) | 450 | if (sControl == -1) |
@@ -436,4 +453,5 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) | |||
436 | return 0; | 453 | return 0; |
437 | } | 454 | } |
455 | |||
438 | if (setsockopt(sControl,SOL_SOCKET,SO_REUSEADDR, | 456 | if (setsockopt(sControl,SOL_SOCKET,SO_REUSEADDR, |
439 | SETSOCKOPT_OPTVAL_TYPE &on, sizeof(on)) == -1) | 457 | SETSOCKOPT_OPTVAL_TYPE &on, sizeof(on)) == -1) |
@@ -443,5 +461,14 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) | |||
443 | return 0; | 461 | return 0; |
444 | } | 462 | } |
445 | if (connect(sControl, (struct sockaddr *)&sin, sizeof(sin)) == -1) | 463 | |
464 | //set nonblocking for connection timeout | ||
465 | flags = fcntl( sControl, F_GETFL,0); | ||
466 | oldflags=flags; | ||
467 | fcntl( sControl, F_SETFL, O_NONBLOCK|flags); | ||
468 | |||
469 | stat=connect( sControl, (struct sockaddr *)&sin, sizeof(sin)); | ||
470 | if (stat < 0) | ||
471 | { | ||
472 | if (errno != EWOULDBLOCK && errno != EINPROGRESS) | ||
446 | { | 473 | { |
447 | perror("connect"); | 474 | perror("connect"); |
@@ -449,4 +476,28 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl) | |||
449 | return 0; | 476 | return 0; |
450 | } | 477 | } |
478 | } | ||
479 | |||
480 | FD_ZERO(&wr); | ||
481 | FD_SET( sControl, &wr); | ||
482 | |||
483 | tv.tv_sec = ACCEPT_TIMEOUT; | ||
484 | tv.tv_usec = 0; | ||
485 | |||
486 | stat = select(sControl+1, 0, &wr, 0, &tv); | ||
487 | |||
488 | if (stat < 1) | ||
489 | { | ||
490 | // time out has expired, | ||
491 | // or an error has ocurred | ||
492 | perror("timeout"); | ||
493 | net_close(sControl); | ||
494 | return 0; | ||
495 | } | ||
496 | |||
497 | printf("connected\n"); | ||
498 | |||
499 | //set original flags | ||
500 | fcntl( sControl, F_SETFL, oldflags); | ||
501 | |||
451 | ctrl = calloc(1,sizeof(netbuf)); | 502 | ctrl = calloc(1,sizeof(netbuf)); |
452 | if (ctrl == NULL) | 503 | if (ctrl == NULL) |
@@ -738,4 +789,5 @@ static int FtpAcceptConnection(netbuf *nData, netbuf *nControl) | |||
738 | tv.tv_usec = 0; | 789 | tv.tv_usec = 0; |
739 | tv.tv_sec = ACCEPT_TIMEOUT; | 790 | tv.tv_sec = ACCEPT_TIMEOUT; |
791 | printf("<<<<<<<<<<<<<<<<%d\n",ACCEPT_TIMEOUT); | ||
740 | i = nControl->handle; | 792 | i = nControl->handle; |
741 | if (i < nData->handle) | 793 | if (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 @@ | |||
1 | Files: $QTDIR/lib/libftplib.* | ||
2 | Priority: optional | ||
3 | Section: Communications | ||
4 | Maintainer: L.J. Potter <ljp@llornkcor.com> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-$SUB_VERSION | ||
7 | Depends: opie-base ($QPE_VERSION) | ||
8 | Description: Libftp | ||
9 | 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 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG = qt warn_on release | ||
3 | HEADERS = ftplib.h | ||
4 | SOURCES = ftplib.c | ||
5 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | ||
6 | 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 | |||
@@ -5,5 +5,5 @@ Maintainer: L.J. Potter <ljp@llornkcor.com> | |||
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION), ftplib |
8 | Description: OpieFtp | 8 | Description: OpieFtp |
9 | The ftp client for the Opie environment. | 9 | 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 | |||
@@ -15,5 +15,5 @@ | |||
15 | 15 | ||
16 | extern "C" { | 16 | extern "C" { |
17 | #include "ftplib.h" | 17 | #include "../ftplib/ftplib.h" |
18 | } | 18 | } |
19 | 19 | ||
@@ -1511,2 +1511,6 @@ void OpieFtp::serverListClicked( const QString &item) { | |||
1511 | } | 1511 | } |
1512 | } | 1512 | } |
1513 | |||
1514 | void OpieFtp::timerOut() { | ||
1515 | |||
1516 | } | ||
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 | |||
@@ -40,4 +40,5 @@ class QToolButton; | |||
40 | class QStringList; | 40 | class QStringList; |
41 | class QListBox; | 41 | class QListBox; |
42 | class QTimer; | ||
42 | 43 | ||
43 | class OpieFtp : public QMainWindow | 44 | class OpieFtp : public QMainWindow |
@@ -68,4 +69,5 @@ public: | |||
68 | int currentServerConfig; | 69 | int currentServerConfig; |
69 | protected slots: | 70 | protected slots: |
71 | void timerOut(); | ||
70 | void upDir(); | 72 | void upDir(); |
71 | void homeButtonPushed(); | 73 | void homeButtonPushed(); |
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 | |||
@@ -2,10 +2,10 @@ TEMPLATE = app | |||
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS = opieftp.h inputDialog.h ftplib.h | 3 | HEADERS = opieftp.h inputDialog.h ftplib.h |
4 | SOURCES = opieftp.cpp inputDialog.cpp ftplib.c main.cpp | 4 | SOURCES = opieftp.cpp inputDialog.cpp main.cpp |
5 | TARGET = opieftp | 5 | TARGET = opieftp |
6 | DESTDIR = $(OPIEDIR)/bin | 6 | DESTDIR = $(OPIEDIR)/bin |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 8 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe | 9 | LIBS += -lqpe -lftplib |
10 | 10 | ||
11 | TRANSLATIONS = ../../../i18n/de/opieftp.ts \ | 11 | TRANSLATIONS = ../../../i18n/de/opieftp.ts \ |