summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/ftplib/ftplib.c (renamed from noncore/net/opieftp/ftplib.c)60
-rw-r--r--noncore/net/ftplib/ftplib.control9
-rw-r--r--noncore/net/ftplib/ftplib.h (renamed from noncore/net/opieftp/ftplib.h)0
-rw-r--r--noncore/net/ftplib/ftplib.pro6
-rw-r--r--noncore/net/opieftp/opieftp.control2
-rw-r--r--noncore/net/opieftp/opieftp.cpp6
-rw-r--r--noncore/net/opieftp/opieftp.h2
-rw-r--r--noncore/net/opieftp/opieftp.pro4
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
@@ -10,64 +10,76 @@
/* */
/* This library is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* Library General Public License for more details. */
/* */
/* You should have received a copy of the GNU Library General Public */
/* License along with this progam; if not, write to the */
/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */
/* 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
#include "ftplib.h"
#if defined(_WIN32)
#define SETSOCKOPT_OPTVAL_TYPE (const char *)
#else
#define SETSOCKOPT_OPTVAL_TYPE (void *)
#endif
#define FTPLIB_BUFSIZ 8192
-#define ACCEPT_TIMEOUT 15
+#define ACCEPT_TIMEOUT 10
#define FTPLIB_CONTROL 0
#define FTPLIB_READ 1
#define FTPLIB_WRITE 2
#if !defined FTPLIB_DEFMODE
#define FTPLIB_DEFMODE FTPLIB_PASSIVE
#endif
struct NetBuf {
char *cput,*cget;
int handle;
@@ -373,32 +385,34 @@ GLOBALDEF char *FtpLastResponse(netbuf *nControl)
if ((nControl) && (nControl->dir == FTPLIB_CONTROL))
return nControl->response;
return NULL;
}
/*
* FtpConnect - connect to remote server
*
* return 1 if connected, 0 if not
*/
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;
int on=1;
netbuf *ctrl;
char *lhost;
char *pnum;
+ struct timeval tv;
+ fd_set wr;
memset(&sin,0,sizeof(sin));
sin.sin_family = AF_INET;
lhost = strdup(host);
pnum = strchr(lhost,':');
if (pnum == NULL)
{
#if defined(VMS)
sin.sin_port = htons(21);
#else
if ((pse = getservbyname("ftp","tcp")) == NULL)
{
@@ -417,46 +431,83 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
{
pse = getservbyname(pnum,"tcp");
sin.sin_port = pse->s_port;
}
}
if ((sin.sin_addr.s_addr = inet_addr(lhost)) == -1)
{
if ((phe = gethostbyname(lhost)) == NULL)
{
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)
{
perror("setsockopt");
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)
{
perror("calloc");
net_close(sControl);
return 0;
}
ctrl->buf = malloc(FTPLIB_BUFSIZ);
if (ctrl->buf == NULL)
{
perror("calloc");
net_close(sControl);
@@ -728,24 +779,25 @@ static int FtpAcceptConnection(netbuf *nData, netbuf *nControl)
struct sockaddr addr;
unsigned int l;
int i;
struct timeval tv;
fd_set mask;
int rv;
FD_ZERO(&mask);
FD_SET(nControl->handle, &mask);
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;
i = select(i+1, &mask, NULL, NULL, &tv);
if (i == -1)
{
strncpy(nControl->response, strerror(errno),
sizeof(nControl->response));
net_close(nData->handle);
nData->handle = 0;
rv = 0;
}
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
@@ -1,9 +1,9 @@
Files: bin/opieftp pics/opieftp apps/Applications/opieftp.desktop
Priority: optional
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
@@ -5,25 +5,25 @@
copyright : (C) 2002 by ljp
email : ljp@llornkcor.com
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
//#define DEVELOPERS_VERSION
#include "opieftp.h"
extern "C" {
-#include "ftplib.h"
+#include "../ftplib/ftplib.h"
}
#include "inputDialog.h"
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/config.h>
#include <qpe/mimetype.h>
#include <qpe/qpemessagebox.h>
@@ -1501,12 +1501,16 @@ void OpieFtp::NewServer() {
void OpieFtp::serverListClicked( const QString &item) {
if(item.isEmpty()) return;
Config cfg("opieftp");
qDebug("highltined "+item);
int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
for (int i = 1; i <= numberOfEntries; i++) {
cfg.setGroup(QString::number(i));
if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack)
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
@@ -30,24 +30,25 @@ class QProgressBar;
class QSpinBox;
class QTabWidget;
class QWidget;
class QPEToolBar;
class QPEMenuBar;
class QPopupMenu;
class QFile;
class QLineEdit;
class QPushButton;
class QToolButton;
class QStringList;
class QListBox;
+class QTimer;
class OpieFtp : public QMainWindow
{
Q_OBJECT
public:
OpieFtp( );
~OpieFtp();
QTabWidget *TabWidget;
QWidget *tab, *tab_2, *tab_3;
QListView *Local_View, *Remote_View;
@@ -58,24 +59,25 @@ public:
QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;;
QSpinBox* PortSpinBox;
QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu, *aboutMenu;
QDir currentDir;
QString currentRemoteDir;
QString filterStr;
QListViewItem * item;
QPushButton *connectServerBtn, *newServerButton;//
QToolButton *cdUpButton, *homeButton, *docButton;
bool b;
int currentServerConfig;
protected slots:
+ void timerOut();
void upDir();
void homeButtonPushed();
void docButtonPushed();
void doAbout();
void serverComboEdited(const QString & );
void UsernameComboBoxEdited(const QString & );
void PasswordEditEdited(const QString & );
void showLocalMenu( QListViewItem *);
void showRemoteMenu( QListViewItem *);
void doLocalCd();
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,21 +1,21 @@
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 \
../../../i18n/es/opieftp.ts \
../../../i18n/fr/opieftp.ts \
../../../i18n/hu/opieftp.ts \
../../../i18n/ja/opieftp.ts \
../../../i18n/ko/opieftp.ts \
../../../i18n/no/opieftp.ts \
../../../i18n/pl/opieftp.ts \
../../../i18n/pt/opieftp.ts \
../../../i18n/pt_BR/opieftp.ts \