summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-21 13:59:50 (UTC)
committer llornkcor <llornkcor>2002-03-21 13:59:50 (UTC)
commit60c9126183ea72c08ad5cb77b8939812627aae17 (patch) (unidiff)
tree60852886d3352fbca6a52bc5c0fb88e521d08145
parent9030459d54a67bd2e6201e0c1641c1f23d9af0ec (diff)
downloadopie-60c9126183ea72c08ad5cb77b8939812627aae17.zip
opie-60c9126183ea72c08ad5cb77b8939812627aae17.tar.gz
opie-60c9126183ea72c08ad5cb77b8939812627aae17.tar.bz2
added some combo stuff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp175
-rw-r--r--noncore/net/opieftp/opieftp.h7
2 files changed, 170 insertions, 12 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 82776d0..eed133e 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,506 +1,536 @@
1/*************************************************************************** 1/***************************************************************************
2 opieftp.cpp 2 opieftp.cpp
3 ------------------- 3 -------------------
4** Created: Sat Mar 9 23:33:09 2002 4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12//#define DEVELOPER_VERSION
12 13
13#include "opieftp.h" 14#include "opieftp.h"
14#include "ftplib.h" 15#include "ftplib.h"
15#include "inputDialog.h" 16#include "inputDialog.h"
16 17
17#include <qpe/qpemenubar.h> 18#include <qpe/qpemenubar.h>
18#include <qpe/qpetoolbar.h> 19#include <qpe/qpetoolbar.h>
19#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
20#include <qpe/resource.h> 21#include <qpe/resource.h>
21#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/config.h>
22 24
23#include <qtextstream.h> 25#include <qtextstream.h>
26#include <qpushbutton.h>
24#include <qtoolbutton.h> 27#include <qtoolbutton.h>
25#include <qdatetime.h> 28#include <qdatetime.h>
26#include <qdir.h> 29#include <qdir.h>
27#include <qfile.h> 30#include <qfile.h>
28#include <qstring.h> 31#include <qstring.h>
29#include <qcombobox.h> 32#include <qcombobox.h>
30#include <qpopupmenu.h> 33#include <qpopupmenu.h>
31#include <qlistview.h> 34#include <qlistview.h>
32#include <qmainwindow.h> 35#include <qmainwindow.h>
33#include <qlabel.h> 36#include <qlabel.h>
34#include <qprogressbar.h> 37#include <qprogressbar.h>
35#include <qspinbox.h> 38#include <qspinbox.h>
36#include <qtabwidget.h> 39#include <qtabwidget.h>
37#include <qwidget.h> 40#include <qwidget.h>
38#include <qlayout.h> 41#include <qlayout.h>
39#include <qimage.h> 42#include <qimage.h>
40#include <qpixmap.h> 43#include <qpixmap.h>
41#include <qmessagebox.h> 44#include <qmessagebox.h>
42#include <qlineedit.h> 45#include <qlineedit.h>
43#include <qregexp.h> 46#include <qregexp.h>
44 47
45#include <unistd.h> 48#include <unistd.h>
46#include <stdlib.h> 49#include <stdlib.h>
47 50
48 51
49QProgressBar *ProgressBar; 52QProgressBar *ProgressBar;
50static netbuf *conn=NULL; 53static netbuf *conn=NULL;
51 54
52static int log_progress(netbuf *ctl, int xfered, void *arg) 55static int log_progress(netbuf *ctl, int xfered, void *arg)
53{ 56{
54 int fsz = *(int *)arg; 57 int fsz = *(int *)arg;
55 int pct = (xfered * 100) / fsz; 58 int pct = (xfered * 100) / fsz;
56// printf("%3d%%\r", pct); 59// printf("%3d%%\r", pct);
57// fflush(stdout); 60// fflush(stdout);
58 ProgressBar->setProgress(xfered); 61 ProgressBar->setProgress(xfered);
59 qApp->processEvents(); 62 qApp->processEvents();
60 return 1; 63 return 1;
61} 64}
62 65
63OpieFtp::OpieFtp( ) 66OpieFtp::OpieFtp( )
64 : QMainWindow( ) 67 : QMainWindow( )
65{ 68{
66 setCaption( tr( "OpieFtp" ) ); 69 setCaption( tr( "OpieFtp" ) );
67 70
68 QGridLayout *layout = new QGridLayout( this ); 71 QGridLayout *layout = new QGridLayout( this );
69 layout->setSpacing( 2); 72 layout->setSpacing( 2);
70 layout->setMargin( 2); 73 layout->setMargin( 2);
71 74
72 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 75 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
73 76
74 QPEMenuBar *menuBar = new QPEMenuBar(this); 77 QPEMenuBar *menuBar = new QPEMenuBar(this);
75 connectionMenu = new QPopupMenu( this ); 78 connectionMenu = new QPopupMenu( this );
76 localMenu = new QPopupMenu( this ); 79 localMenu = new QPopupMenu( this );
77 remoteMenu = new QPopupMenu( this ); 80 remoteMenu = new QPopupMenu( this );
78 tabMenu = new QPopupMenu( this ); 81 tabMenu = new QPopupMenu( this );
79 82
80 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); 83 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 );
81 84
82 menuBar->insertItem( tr( "Connection" ), connectionMenu); 85 menuBar->insertItem( tr( "Connection" ), connectionMenu);
83 menuBar->insertItem( tr( "Local" ), localMenu); 86 menuBar->insertItem( tr( "Local" ), localMenu);
84 menuBar->insertItem( tr( "Remote" ), remoteMenu); 87 menuBar->insertItem( tr( "Remote" ), remoteMenu);
85 menuBar->insertItem( tr( "View" ), tabMenu); 88 menuBar->insertItem( tr( "View" ), tabMenu);
86 89
87 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 90 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
88 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 91 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
89 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 92 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
90 93
91 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 94 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
92 localMenu->insertSeparator(); 95 localMenu->insertSeparator();
93 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 96 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
94 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 97 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
95 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 98 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
96 localMenu->insertSeparator(); 99 localMenu->insertSeparator();
97 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 100 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
98 localMenu->setCheckable(TRUE); 101 localMenu->setCheckable(TRUE);
99 102
100 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 103 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
101 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 104 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
102 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 105 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
103 remoteMenu->insertSeparator(); 106 remoteMenu->insertSeparator();
104 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 107 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
105 108
106 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 109 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
107 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 110 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
108 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); 111 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
109 tabMenu->setCheckable(TRUE); 112 tabMenu->setCheckable(TRUE);
110 113
111 TabWidget = new QTabWidget( this, "TabWidget" ); 114 TabWidget = new QTabWidget( this, "TabWidget" );
112 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); 115 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 );
113 116
114 TabWidget->setTabShape(QTabWidget::Triangular); 117 TabWidget->setTabShape(QTabWidget::Triangular);
115 118
116 tab = new QWidget( TabWidget, "tab" ); 119 tab = new QWidget( TabWidget, "tab" );
117 tabLayout = new QGridLayout( tab ); 120 tabLayout = new QGridLayout( tab );
118 tabLayout->setSpacing( 2); 121 tabLayout->setSpacing( 2);
119 tabLayout->setMargin( 2); 122 tabLayout->setMargin( 2);
120 123
121 Local_View = new QListView( tab, "Local_View" ); 124 Local_View = new QListView( tab, "Local_View" );
122// Local_View->setResizePolicy( QListView::AutoOneFit ); 125// Local_View->setResizePolicy( QListView::AutoOneFit );
123 Local_View->addColumn( tr("File"),120); 126 Local_View->addColumn( tr("File"),120);
124 Local_View->addColumn( tr("Size"),-1); 127 Local_View->addColumn( tr("Size"),-1);
125 Local_View->setColumnAlignment(1,QListView::AlignRight); 128 Local_View->setColumnAlignment(1,QListView::AlignRight);
126 Local_View->addColumn( tr("Date"),-1); 129 Local_View->addColumn( tr("Date"),-1);
127 Local_View->setColumnAlignment(2,QListView::AlignRight); 130 Local_View->setColumnAlignment(2,QListView::AlignRight);
128 Local_View->setAllColumnsShowFocus(TRUE); 131 Local_View->setAllColumnsShowFocus(TRUE);
129 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 132 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
130 133
131 tabLayout->addWidget( Local_View, 0, 0 ); 134 tabLayout->addWidget( Local_View, 0, 0 );
132 135
133 connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), 136 connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
134 this,SLOT( localListClicked(QListViewItem *)) ); 137 this,SLOT( localListClicked(QListViewItem *)) );
135 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 138 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
136 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 139 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
137 140
138 TabWidget->insertTab( tab, tr( "Local" ) ); 141 TabWidget->insertTab( tab, tr( "Local" ) );
139 142
140 tab_2 = new QWidget( TabWidget, "tab_2" ); 143 tab_2 = new QWidget( TabWidget, "tab_2" );
141 tabLayout_2 = new QGridLayout( tab_2 ); 144 tabLayout_2 = new QGridLayout( tab_2 );
142 tabLayout_2->setSpacing( 2); 145 tabLayout_2->setSpacing( 2);
143 tabLayout_2->setMargin( 2); 146 tabLayout_2->setMargin( 2);
144 147
145 Remote_View = new QListView( tab_2, "Remote_View" ); 148 Remote_View = new QListView( tab_2, "Remote_View" );
146 Remote_View->addColumn( tr("File"),120); 149 Remote_View->addColumn( tr("File"),120);
147 Remote_View->addColumn( tr("Size"),-1); 150 Remote_View->addColumn( tr("Size"),-1);
148 Remote_View->setColumnAlignment(1,QListView::AlignRight); 151 Remote_View->setColumnAlignment(1,QListView::AlignRight);
149 Remote_View->addColumn( tr("Date"),-1); 152 Remote_View->addColumn( tr("Date"),-1);
150 Remote_View->setColumnAlignment(2,QListView::AlignRight); 153 Remote_View->setColumnAlignment(2,QListView::AlignRight);
151 Remote_View->setAllColumnsShowFocus(TRUE); 154 Remote_View->setAllColumnsShowFocus(TRUE);
152 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 155 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
153 156
154 connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)), 157 connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)),
155 this,SLOT( remoteListClicked(QListViewItem *)) ); 158 this,SLOT( remoteListClicked(QListViewItem *)) );
156 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 159 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
157 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 160 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
158 161
159 tabLayout_2->addWidget( Remote_View, 0, 0 ); 162 tabLayout_2->addWidget( Remote_View, 0, 0 );
160 163
161 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 164 TabWidget->insertTab( tab_2, tr( "Remote" ) );
162 165
163 tab_3 = new QWidget( TabWidget, "tab_3" ); 166 tab_3 = new QWidget( TabWidget, "tab_3" );
164 tabLayout_3 = new QGridLayout( tab_3 ); 167 tabLayout_3 = new QGridLayout( tab_3 );
165 tabLayout_3->setSpacing( 2); 168 tabLayout_3->setSpacing( 2);
166 tabLayout_3->setMargin( 2); 169 tabLayout_3->setMargin( 2);
167 170
168 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 171 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
169 TextLabel1->setText( tr( "Username" ) ); 172 TextLabel1->setText( tr( "Username" ) );
170 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 173 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
171 174
172 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 175 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
173 UsernameComboBox->setEditable(TRUE); 176 UsernameComboBox->setEditable(TRUE);
174 UsernameComboBox->lineEdit()->setText("anonymous"); 177// UsernameComboBox->lineEdit()->setText("anonymous");
175// UsernameComboBox->lineEdit()->setText("root");
176// UsernameComboBox->lineEdit()->setText("llornkcor");
177 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 178 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
178 179
179 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 180 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
180 TextLabel2->setText( tr( "Password" ) ); 181 TextLabel2->setText( tr( "Password" ) );
181 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 182 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
182 183
183 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 184 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
184 PasswordEdit->setEchoMode(QLineEdit::Password); 185 PasswordEdit->setEchoMode(QLineEdit::Password);
185 PasswordEdit->setText( tr( "me@opieftp.org" ) ); 186// PasswordEdit->setText( tr( "me@opieftp.org" ) );
186// PasswordEdit->setText( tr( "" ) );
187 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 187 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
188 188
189 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 189 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
190 TextLabel3->setText( tr( "Remote server" ) ); 190 TextLabel3->setText( tr( "Remote server" ) );
191 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 191 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
192 192
193 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 193 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
194 ServerComboBox->setEditable(TRUE); 194 ServerComboBox->setEditable(TRUE);
195 ServerComboBox->lineEdit()->setText( tr( "" ) ); 195// ServerComboBox->lineEdit()->setText( tr( "" ) );
196 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 196 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
197// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); 197
198// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 198 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
199 199
200 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 200 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
201 TextLabel5->setText( tr( "Remote path" ) ); 201 TextLabel5->setText( tr( "Remote path" ) );
202 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 202 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
203 203
204 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 204 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
205 remotePath->setText( currentRemoteDir = "/"); 205 remotePath->setText( currentRemoteDir = "/");
206// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
207 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 206 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
208 207
209 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 208 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
210 TextLabel4->setText( tr( "Port" ) ); 209 TextLabel4->setText( tr( "Port" ) );
211 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 210 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
212 211
213 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 212 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
214 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 213 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
215 PortSpinBox->setMaxValue(32786); 214 PortSpinBox->setMaxValue(32786);
216// PortSpinBox->setValue( 4242);
217 PortSpinBox->setValue( 21); 215 PortSpinBox->setValue( 21);
218 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 216 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
219 217
218 QPushButton *deleteServerBtn;
219 deleteServerBtn = new QPushButton( "Delete Server",this, "OpenButton" );
220 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
221
222 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
223
224 QPushButton *connectServerBtn;
225 connectServerBtn = new QPushButton( "Connect",this, "ConnectButton" );
226 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
227 connect(connectServerBtn,SIGNAL( clicked()),SLOT( connector() ));
228
229
220 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 230 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
221 tabLayout_3->addItem( spacer, 5, 0 ); 231 tabLayout_3->addItem( spacer, 5, 0 );
222 232
223 TabWidget->insertTab( tab_3, tr( "Config" ) ); 233 TabWidget->insertTab( tab_3, tr( "Config" ) );
224 234
225 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 235 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
226 this,SLOT(tabChanged(QWidget*))); 236 this,SLOT(tabChanged(QWidget*)));
227 237
228 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 238 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
229 currentDir.setPath( QDir::currentDirPath()); 239 currentDir.setPath( QDir::currentDirPath());
230// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 240// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
231 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); 241 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" );
232 layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); 242 layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 );
233 243
234 currentPathEdit->setText( currentDir.canonicalPath()); 244 currentPathEdit->setText( currentDir.canonicalPath());
235 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); 245 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged()));
236 246
237 ProgressBar = new QProgressBar( this, "ProgressBar" ); 247 ProgressBar = new QProgressBar( this, "ProgressBar" );
238 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 248 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
239 249
250 serverComboSelected(0);
251#ifdef DEVELOPER_VERSION
252// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
253 ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
254 UsernameComboBox->lineEdit()->setText("root");
255// UsernameComboBox->lineEdit()->setText("llornkcor");
256 PortSpinBox->setValue( 4242);
257 remotePath->setText( currentRemoteDir = "/");
258 PasswordEdit->setText( tr( "" ) );
259
260#endif
261 fillCombos();
240 filterStr="*"; 262 filterStr="*";
241 b=FALSE; 263 b=FALSE;
242 populateLocalView(); 264 populateLocalView();
265 TabWidget->setCurrentPage(2);
243} 266}
244 267
245OpieFtp::~OpieFtp() 268OpieFtp::~OpieFtp()
246{ 269{
247} 270}
248 271
249void OpieFtp::cleanUp() 272void OpieFtp::cleanUp()
250{ 273{
251 if(conn) 274 if(conn)
252 FtpQuit(conn); 275 FtpQuit(conn);
253 QString sfile=QDir::homeDirPath(); 276 QString sfile=QDir::homeDirPath();
254 if(sfile.right(1) != "/") 277 if(sfile.right(1) != "/")
255 sfile+="/._temp"; 278 sfile+="/._temp";
256 else 279 else
257 sfile+="._temp"; 280 sfile+="._temp";
258 QFile file( sfile); 281 QFile file( sfile);
259 if(file.exists()) 282 if(file.exists())
260 file.remove(); 283 file.remove();
261} 284}
262 285
263void OpieFtp::tabChanged(QWidget *w) 286void OpieFtp::tabChanged(QWidget *w)
264{ 287{
265 if (TabWidget->currentPageIndex() == 0) { 288 if (TabWidget->currentPageIndex() == 0) {
266 currentPathEdit->setText( currentDir.canonicalPath()); 289 currentPathEdit->setText( currentDir.canonicalPath());
267 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 290 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
268 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 291 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
269 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 292 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
270 } 293 }
271 if (TabWidget->currentPageIndex() == 1) { 294 if (TabWidget->currentPageIndex() == 1) {
272 currentPathEdit->setText( currentRemoteDir ); 295 currentPathEdit->setText( currentRemoteDir );
273 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 296 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
274 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 297 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
275 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 298 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
276 } 299 }
277 if (TabWidget->currentPageIndex() == 2) { 300 if (TabWidget->currentPageIndex() == 2) {
278 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 301 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
279 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 302 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
280 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 303 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
281 } 304 }
282} 305}
283 306
284void OpieFtp::localUpload() 307void OpieFtp::localUpload()
285{ 308{
286 int fsz; 309 int fsz;
287 QCopEnvelope ( "QPE/System", "busy()" ); 310 QCopEnvelope ( "QPE/System", "busy()" );
288 qApp->processEvents(); 311 qApp->processEvents();
289 QString strItem = Local_View->currentItem()->text(0); 312 QString strItem = Local_View->currentItem()->text(0);
290 QString localFile = currentDir.canonicalPath()+"/"+strItem; 313 QString localFile = currentDir.canonicalPath()+"/"+strItem;
291 QString remoteFile= currentRemoteDir+strItem; 314 QString remoteFile= currentRemoteDir+strItem;
292 QFileInfo fi(localFile); 315 QFileInfo fi(localFile);
293 if( !fi.isDir()) { 316 if( !fi.isDir()) {
294 fsz=fi.size(); 317 fsz=fi.size();
295 ProgressBar->setTotalSteps(fsz); 318 ProgressBar->setTotalSteps(fsz);
296 319
297 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 320 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
298 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 321 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
299 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 322 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
300 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 323 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
301 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 324 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
302 325
303 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 326 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
304 QString msg; 327 QString msg;
305 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 328 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
306 msg.replace(QRegExp(":"),"\n"); 329 msg.replace(QRegExp(":"),"\n");
307 QMessageBox::message(tr("Note"),msg); 330 QMessageBox::message(tr("Note"),msg);
308// FtpQuit(conn); 331// FtpQuit(conn);
309 } 332 }
310 ProgressBar->reset(); 333 ProgressBar->reset();
311 nullifyCallBack(); 334 nullifyCallBack();
312 } else { 335 } else {
313 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 336 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
314 } 337 }
315 TabWidget->setCurrentPage(1); 338 TabWidget->setCurrentPage(1);
316 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 339 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
317 QCopEnvelope ( "QPE/System", "notBusy()" ); 340 QCopEnvelope ( "QPE/System", "notBusy()" );
318} 341}
319 342
320void OpieFtp::nullifyCallBack() 343void OpieFtp::nullifyCallBack()
321{ 344{
322 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 345 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
323 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 346 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
324 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 347 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
325 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 348 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
326 349
327} 350}
328 351
329void OpieFtp::remoteDownload() 352void OpieFtp::remoteDownload()
330{ 353{
331 int fsz; 354 int fsz;
332 QCopEnvelope ( "QPE/System", "busy()" ); 355 QCopEnvelope ( "QPE/System", "busy()" );
333 qApp->processEvents(); 356 qApp->processEvents();
334 QString strItem = Remote_View->currentItem()->text(0); 357 QString strItem = Remote_View->currentItem()->text(0);
335// strItem=strItem.right(strItem.length()-1); 358// strItem=strItem.right(strItem.length()-1);
336 359
337 QString localFile = currentDir.canonicalPath(); 360 QString localFile = currentDir.canonicalPath();
338 if(localFile.right(1).find("/",0,TRUE) == -1) 361 if(localFile.right(1).find("/",0,TRUE) == -1)
339 localFile += "/"; 362 localFile += "/";
340 localFile += strItem; 363 localFile += strItem;
341// QString localFile = currentDir.canonicalPath()+"/"+strItem; 364// QString localFile = currentDir.canonicalPath()+"/"+strItem;
342 QString remoteFile= currentRemoteDir+strItem; 365 QString remoteFile= currentRemoteDir+strItem;
343 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 366 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
344 fsz = 0; 367 fsz = 0;
345 QString temp; 368 QString temp;
346 temp.sprintf( remoteFile+" "+" %dkb", fsz); 369 temp.sprintf( remoteFile+" "+" %dkb", fsz);
347 370
348 ProgressBar->setTotalSteps(fsz); 371 ProgressBar->setTotalSteps(fsz);
349 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 372 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
350 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 373 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
351 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 374 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
352 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 375 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
353 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 376 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
354 377
355 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 378 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
356 QString msg; 379 QString msg;
357 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 380 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
358 msg.replace(QRegExp(":"),"\n"); 381 msg.replace(QRegExp(":"),"\n");
359 QMessageBox::message(tr("Note"),msg); 382 QMessageBox::message(tr("Note"),msg);
360// FtpQuit(conn); 383// FtpQuit(conn);
361 } 384 }
362 ProgressBar->reset(); 385 ProgressBar->reset();
363 nullifyCallBack(); 386 nullifyCallBack();
364 TabWidget->setCurrentPage(0); 387 TabWidget->setCurrentPage(0);
365 populateLocalView(); 388 populateLocalView();
366 QCopEnvelope ( "QPE/System", "notBusy()" ); 389 QCopEnvelope ( "QPE/System", "notBusy()" );
367} 390}
368 391
369 392
370void OpieFtp::newConnection() 393void OpieFtp::newConnection()
371{ 394{
372 TabWidget->setCurrentPage(2); 395 UsernameComboBox->lineEdit()->setText("");
396 PasswordEdit->setText( "" );
397 ServerComboBox->lineEdit()->setText( "");
398 remotePath->setText( currentRemoteDir = "/");
399 PortSpinBox->setValue( 21);
400 TabWidget->setCurrentPage(2);
401
373} 402}
374 403
375void OpieFtp::connector() 404void OpieFtp::connector()
376{ 405{
377 QCopEnvelope ( "QPE/System", "busy()" ); 406 QCopEnvelope ( "QPE/System", "busy()" );
378 qApp->processEvents(); 407 qApp->processEvents();
379 currentRemoteDir=remotePath->text(); 408 currentRemoteDir=remotePath->text();
380 if(ServerComboBox->currentText().isEmpty()) { 409 if(ServerComboBox->currentText().isEmpty()) {
381 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 410 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
382 TabWidget->setCurrentPage(2); 411 TabWidget->setCurrentPage(2);
383 ServerComboBox->setFocus(); 412 ServerComboBox->setFocus();
384 return; 413 return;
385 } 414 }
386 FtpInit(); 415 FtpInit();
387 TabWidget->setCurrentPage(1); 416 TabWidget->setCurrentPage(1);
388 QString ftp_host = ServerComboBox->currentText(); 417 QString ftp_host = ServerComboBox->currentText();
389 QString ftp_user = UsernameComboBox->currentText(); 418 QString ftp_user = UsernameComboBox->currentText();
390 QString ftp_pass = PasswordEdit->text(); 419 QString ftp_pass = PasswordEdit->text();
391 QString port=PortSpinBox->cleanText(); 420 QString port=PortSpinBox->cleanText();
392 port.stripWhiteSpace(); 421 port.stripWhiteSpace();
393 422
394 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 423 if(ftp_host.find("ftp://",0, TRUE) != -1 )
395 ftp_host=ftp_host.right(ftp_host.length()-6); 424 ftp_host=ftp_host.right(ftp_host.length()-6);
396 ftp_host+=":"+port; 425 ftp_host+=":"+port;
397 if (!FtpConnect( ftp_host.latin1(), &conn)) { 426 if (!FtpConnect( ftp_host.latin1(), &conn)) {
398 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 427 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
399 return ; 428 return ;
400 } 429 }
401 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 430 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
402 QString msg; 431 QString msg;
403 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 432 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
404 msg.replace(QRegExp(":"),"\n"); 433 msg.replace(QRegExp(":"),"\n");
405 QMessageBox::message(tr("Note"),msg); 434 QMessageBox::message(tr("Note"),msg);
406 FtpQuit(conn); 435 FtpQuit(conn);
407 return ; 436 return ;
408 } 437 }
409 remoteDirList("/") ; 438 remoteDirList("/") ;
410 setCaption(ftp_host); 439 setCaption(ftp_host);
440 writeConfig();
411 QCopEnvelope ( "QPE/System", "notBusy()" ); 441 QCopEnvelope ( "QPE/System", "notBusy()" );
412} 442}
413 443
414void OpieFtp::disConnector() 444void OpieFtp::disConnector()
415{ 445{
416 FtpQuit(conn); 446 FtpQuit(conn);
417 setCaption("OpieFtp"); 447 setCaption("OpieFtp");
418 currentRemoteDir="/"; 448 currentRemoteDir="/";
419 Remote_View->clear(); 449 Remote_View->clear();
420} 450}
421 451
422bool OpieFtp::remoteDirList(const QString &dir) 452bool OpieFtp::remoteDirList(const QString &dir)
423{ 453{
424 QString tmp = QDir::homeDirPath(); 454 QString tmp = QDir::homeDirPath();
425 if(tmp.right(1) != "/") 455 if(tmp.right(1) != "/")
426 tmp+="/._temp"; 456 tmp+="/._temp";
427 else 457 else
428 tmp+="._temp"; 458 tmp+="._temp";
429// qDebug("Listing remote dir "+tmp); 459// qDebug("Listing remote dir "+tmp);
430 QCopEnvelope ( "QPE/System", "busy()" ); 460 QCopEnvelope ( "QPE/System", "busy()" );
431 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 461 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
432 QString msg; 462 QString msg;
433 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 463 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
434 msg.replace(QRegExp(":"),"\n"); 464 msg.replace(QRegExp(":"),"\n");
435 QMessageBox::message(tr("Note"),msg); 465 QMessageBox::message(tr("Note"),msg);
436// FtpQuit(conn); 466// FtpQuit(conn);
437 return false; 467 return false;
438 } 468 }
439 populateRemoteView() ; 469 populateRemoteView() ;
440 QCopEnvelope ( "QPE/System", "notBusy()" ); 470 QCopEnvelope ( "QPE/System", "notBusy()" );
441 return true; 471 return true;
442} 472}
443 473
444bool OpieFtp::remoteChDir(const QString &dir) 474bool OpieFtp::remoteChDir(const QString &dir)
445{ 475{
446 QCopEnvelope ( "QPE/System", "busy()" ); 476 QCopEnvelope ( "QPE/System", "busy()" );
447 if (!FtpChdir( dir.latin1(), conn )) { 477 if (!FtpChdir( dir.latin1(), conn )) {
448 QString msg; 478 QString msg;
449 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 479 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
450 msg.replace(QRegExp(":"),"\n"); 480 msg.replace(QRegExp(":"),"\n");
451 QMessageBox::message(tr("Note"),msg); 481 QMessageBox::message(tr("Note"),msg);
452 qDebug(msg); 482 qDebug(msg);
453// FtpQuit(conn); 483// FtpQuit(conn);
454 QCopEnvelope ( "QPE/System", "notBusy()" ); 484 QCopEnvelope ( "QPE/System", "notBusy()" );
455 return FALSE; 485 return FALSE;
456 } 486 }
457 QCopEnvelope ( "QPE/System", "notBusy()" ); 487 QCopEnvelope ( "QPE/System", "notBusy()" );
458 return TRUE; 488 return TRUE;
459} 489}
460 490
461void OpieFtp::populateLocalView() 491void OpieFtp::populateLocalView()
462{ 492{
463 Local_View->clear(); 493 Local_View->clear();
464 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 494 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
465 currentDir.setMatchAllDirs(TRUE); 495 currentDir.setMatchAllDirs(TRUE);
466 currentDir.setNameFilter(filterStr); 496 currentDir.setNameFilter(filterStr);
467 QString fileL, fileS, fileDate; 497 QString fileL, fileS, fileDate;
468 bool isDir=FALSE; 498 bool isDir=FALSE;
469 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 499 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
470 QFileInfoListIterator it(*list); 500 QFileInfoListIterator it(*list);
471 QFileInfo *fi; 501 QFileInfo *fi;
472 while ( (fi=it.current()) ) { 502 while ( (fi=it.current()) ) {
473 if (fi->isSymLink() ){ 503 if (fi->isSymLink() ){
474 QString symLink=fi->readLink(); 504 QString symLink=fi->readLink();
475// qDebug("Symlink detected "+symLink); 505// qDebug("Symlink detected "+symLink);
476 QFileInfo sym( symLink); 506 QFileInfo sym( symLink);
477 fileS.sprintf( "%10li", sym.size() ); 507 fileS.sprintf( "%10li", sym.size() );
478 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 508 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
479 fileDate = sym.lastModified().toString(); 509 fileDate = sym.lastModified().toString();
480 } else { 510 } else {
481// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 511// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
482 fileS.sprintf( "%10li", fi->size() ); 512 fileS.sprintf( "%10li", fi->size() );
483 fileL.sprintf( "%s",fi->fileName().data() ); 513 fileL.sprintf( "%s",fi->fileName().data() );
484 fileDate= fi->lastModified().toString(); 514 fileDate= fi->lastModified().toString();
485 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 515 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
486 fileL+="/"; 516 fileL+="/";
487 isDir=TRUE; 517 isDir=TRUE;
488// qDebug( fileL); 518// qDebug( fileL);
489 } 519 }
490 } 520 }
491 if(fileL !="./") { 521 if(fileL !="./") {
492 item = new QListViewItem( Local_View,fileL,fileS, fileDate); 522 item = new QListViewItem( Local_View,fileL,fileS, fileDate);
493 if(isDir || fileL.find("/",0,TRUE) != -1) 523 if(isDir || fileL.find("/",0,TRUE) != -1)
494 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 524 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
495 else 525 else
496 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 526 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
497 } 527 }
498 isDir=FALSE; 528 isDir=FALSE;
499 ++it; 529 ++it;
500 } 530 }
501 Local_View->setSorting( 3,FALSE); 531 Local_View->setSorting( 3,FALSE);
502 currentPathEdit->setText( currentDir.canonicalPath() ); 532 currentPathEdit->setText( currentDir.canonicalPath() );
503} 533}
504 534
505bool OpieFtp::populateRemoteView( ) 535bool OpieFtp::populateRemoteView( )
506{ 536{
@@ -824,96 +854,219 @@ void OpieFtp::remoteDelete()
824 ,tr("Yes"),tr("No"),0,0,1) ) { 854 ,tr("Yes"),tr("No"),0,0,1) ) {
825 case 0: { 855 case 0: {
826 QString path= currentRemoteDir+f; 856 QString path= currentRemoteDir+f;
827 if(FtpDelete( path.latin1(), conn)==0) { 857 if(FtpDelete( path.latin1(), conn)==0) {
828 QString msg; 858 QString msg;
829 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); 859 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
830 msg.replace(QRegExp(":"),"\n"); 860 msg.replace(QRegExp(":"),"\n");
831 QMessageBox::message(tr("Note"),msg); 861 QMessageBox::message(tr("Note"),msg);
832 } 862 }
833 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 863 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
834 } 864 }
835 break; 865 break;
836 }; 866 };
837 } 867 }
838 QCopEnvelope ( "QPE/System", "notBusy()" ); 868 QCopEnvelope ( "QPE/System", "notBusy()" );
839} 869}
840 870
841void OpieFtp::remoteRename() 871void OpieFtp::remoteRename()
842{ 872{
843 QString curFile = Remote_View->currentItem()->text(0); 873 QString curFile = Remote_View->currentItem()->text(0);
844 InputDialog *fileDlg; 874 InputDialog *fileDlg;
845 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 875 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
846 fileDlg->inputText = curFile; 876 fileDlg->inputText = curFile;
847 fileDlg->exec(); 877 fileDlg->exec();
848 if( fileDlg->result() == 1 ) { 878 if( fileDlg->result() == 1 ) {
849 QString oldName = currentRemoteDir +"/"+ curFile; 879 QString oldName = currentRemoteDir +"/"+ curFile;
850 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; 880 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
851 QCopEnvelope ( "QPE/System", "busy()" ); 881 QCopEnvelope ( "QPE/System", "busy()" );
852 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { 882 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
853 QString msg; 883 QString msg;
854 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); 884 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn));
855 msg.replace(QRegExp(":"),"\n"); 885 msg.replace(QRegExp(":"),"\n");
856 QMessageBox::message(tr("Note"),msg); 886 QMessageBox::message(tr("Note"),msg);
857 } 887 }
858 QCopEnvelope ( "QPE/System", "notBusy()" ); 888 QCopEnvelope ( "QPE/System", "notBusy()" );
859 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 889 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
860 } 890 }
861} 891}
862 892
863void OpieFtp::localRename() 893void OpieFtp::localRename()
864{ 894{
865 QString curFile = Local_View->currentItem()->text(0); 895 QString curFile = Local_View->currentItem()->text(0);
866 InputDialog *fileDlg; 896 InputDialog *fileDlg;
867 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 897 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
868 fileDlg->inputText = curFile; 898 fileDlg->inputText = curFile;
869 fileDlg->exec(); 899 fileDlg->exec();
870 if( fileDlg->result() == 1 ) { 900 if( fileDlg->result() == 1 ) {
871 QString oldname = currentDir.canonicalPath() + "/" + curFile; 901 QString oldname = currentDir.canonicalPath() + "/" + curFile;
872 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 902 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
873 if( rename(oldname.latin1(), newName.latin1())== -1) 903 if( rename(oldname.latin1(), newName.latin1())== -1)
874 QMessageBox::message(tr("Note"),tr("Could not rename")); 904 QMessageBox::message(tr("Note"),tr("Could not rename"));
875 } 905 }
876 populateLocalView(); 906 populateLocalView();
877} 907}
878 908
879void OpieFtp::currentPathEditChanged() 909void OpieFtp::currentPathEditChanged()
880{ 910{
881 QString oldRemoteCurrentDir = currentRemoteDir; 911 QString oldRemoteCurrentDir = currentRemoteDir;
882// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); 912// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir);
883 if (TabWidget->currentPageIndex() == 0) { 913 if (TabWidget->currentPageIndex() == 0) {
884 if(QDir( currentPathEdit->text()).exists()) { 914 if(QDir( currentPathEdit->text()).exists()) {
885 currentDir.setPath( currentPathEdit->text() ); 915 currentDir.setPath( currentPathEdit->text() );
886 populateLocalView(); 916 populateLocalView();
887 } else { 917 } else {
888 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 918 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
889 } 919 }
890 } 920 }
891 if (TabWidget->currentPageIndex() == 1) { 921 if (TabWidget->currentPageIndex() == 1) {
892 currentRemoteDir = currentPathEdit->text(); 922 currentRemoteDir = currentPathEdit->text();
893 if(currentRemoteDir.right(1) !="/") { 923 if(currentRemoteDir.right(1) !="/") {
894 currentRemoteDir = currentRemoteDir +"/"; 924 currentRemoteDir = currentRemoteDir +"/";
895 currentPathEdit->setText( currentRemoteDir ); 925 currentPathEdit->setText( currentRemoteDir );
896 } 926 }
897 if( !remoteChDir( (const QString &)currentRemoteDir) ) { 927 if( !remoteChDir( (const QString &)currentRemoteDir) ) {
898 currentRemoteDir = oldRemoteCurrentDir; 928 currentRemoteDir = oldRemoteCurrentDir;
899 currentPathEdit->setText( currentRemoteDir ); 929 currentPathEdit->setText( currentRemoteDir );
900 } 930 }
901 931
902 remoteDirList( (const QString &)currentRemoteDir); 932 remoteDirList( (const QString &)currentRemoteDir);
903 } 933 }
904} 934}
905 935
906void OpieFtp::switchToLocalTab() 936void OpieFtp::switchToLocalTab()
907{ 937{
908 TabWidget->setCurrentPage(0); 938 TabWidget->setCurrentPage(0);
909} 939}
910 940
911void OpieFtp::switchToRemoteTab() 941void OpieFtp::switchToRemoteTab()
912{ 942{
913 TabWidget->setCurrentPage(1); 943 TabWidget->setCurrentPage(1);
914} 944}
915 945
916void OpieFtp::switchToConfigTab() 946void OpieFtp::switchToConfigTab()
917{ 947{
918 TabWidget->setCurrentPage(2); 948 TabWidget->setCurrentPage(2);
919} 949}
950
951void OpieFtp::readConfig() {
952
953 Config cfg("opieftp");
954 cfg.setGroup("Server");
955 QString username, remoteServer, remotePathStr, password, port, temp;
956 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
957 for (int i = 0; i <= numberOfEntries; i++) {
958 temp.setNum(i+1);
959 cfg.setGroup("Server");
960 remoteServer = cfg.readEntry( temp,"");
961 ServerComboBox->insertItem( remoteServer );
962 cfg.setGroup(temp);
963
964 remotePathStr = cfg.readEntry(remoteServer,"");
965 int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
966 port = remoteServer.right( divider+1);
967 bool ok;
968 PortSpinBox->setValue( port.toInt(&ok,10));
969
970 remoteServer = remoteServer.left(divider - 1);
971 remotePath->setText( remotePathStr);
972 username = cfg.readEntry(temp);
973 UsernameComboBox->insertItem(username);
974 password = cfg.readEntryCrypt(username,"");
975 PasswordEdit->setText(password);
976
977 }
978
979}
980
981void OpieFtp::writeConfig() {
982
983 Config cfg("opieftp");
984 cfg.setGroup("Server");
985 QString temp;
986 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
987 temp.setNum(numberOfEntries+1);
988 cfg.setGroup("Server");
989 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() );
990 cfg.setGroup(temp);
991 cfg.writeEntry("RemotePath", remotePath->text());
992 cfg.writeEntry("Username", UsernameComboBox->currentText());
993 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text());
994 cfg.setGroup("Server");
995 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
996
997}
998
999void OpieFtp::fillCombos() {
1000 Config cfg("opieftp");
1001 cfg.setGroup("Server");
1002 QString username, remoteServerStr, remotePathStr, password, port, temp;
1003 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1004 for (int i = 1; i <= numberOfEntries; i++) {
1005 temp.setNum(i);
1006 cfg.setGroup("Server");
1007 remoteServerStr = cfg.readEntry( temp,"");
1008 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1009 port = remoteServerStr.right( divider - 1);
1010 bool ok;
1011 PortSpinBox->setValue( port.toInt(&ok,10));
1012
1013 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1014 ServerComboBox->insertItem( remoteServerStr );
1015// cfg.setGroup(temp);
1016
1017// remotePathStr = cfg.readEntry(remoteServer,"");
1018// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
1019// port = remoteServer.right( divider+1);
1020// PortSpinBox->setValue( port);
1021
1022// remoteServer = remoteServer.left(divider - 1);
1023// remotePath->setText( remotePathStr);
1024
1025// username = cfg.readEntry(temp);
1026// UsernameComboBox->insertItem(username);
1027// password = cfg.readEntryCrypt(username,"");
1028// PasswordEdit->setText(password);
1029
1030 }
1031
1032}
1033
1034
1035void OpieFtp::serverComboSelected(int index) {
1036
1037 QString username, remoteServerStr, remotePathStr, password, port, temp;
1038// remoteServerStr = ServerComboBox->text(index);
1039 Config cfg("opieftp");
1040 cfg.setGroup("Server");
1041 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1042
1043// for (int i = 0; i <= numberOfEntries; i++) {
1044 temp.setNum(index+1);
1045 remoteServerStr = cfg.readEntry( temp,"");
1046 // if( remoteServerStr.find( ServerComboBox->text(index),0,TRUE) != -1 ) {
1047 cfg.setGroup(temp);
1048 qDebug(temp);
1049 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1050 port = remoteServerStr.right( divider - 1);
1051 bool ok;
1052 PortSpinBox->setValue( port.toInt(&ok,10));
1053
1054 remotePath->setText(cfg.readEntry("RemotePath", ""));
1055 username = cfg.readEntry("Username", "");
1056 UsernameComboBox->lineEdit()->setText(username);
1057 PasswordEdit->setText(cfg.readEntryCrypt(username, ""));
1058
1059// }
1060
1061 // }
1062 update();
1063}
1064// UsernameComboBox->lineEdit()->setText("root");
1065// PasswordEdit->setText( tr( "" ) );
1066// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
1067// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
1068// PortSpinBox->setValue( 4242);
1069
1070void OpieFtp::deleteServer() {
1071
1072}
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index 1e5fffa..c88a15b 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -1,103 +1,108 @@
1/*************************************************************************** 1/***************************************************************************
2 opieftp.h 2 opieftp.h
3 ------------------- 3 -------------------
4** Created: Sat Mar 9 23:33:09 2002 4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#ifndef OPIEFTP_H 12#ifndef OPIEFTP_H
13#define OPIEFTP_H 13#define OPIEFTP_H
14 14
15#include <qvariant.h> 15#include <qvariant.h>
16#include <qdialog.h> 16#include <qdialog.h>
17#include <qmainwindow.h> 17#include <qmainwindow.h>
18#include <qdir.h> 18#include <qdir.h>
19#include <qstring.h> 19#include <qstring.h>
20#include <qpoint.h> 20#include <qpoint.h>
21 21
22class QVBoxLayout; 22class QVBoxLayout;
23class QHBoxLayout; 23class QHBoxLayout;
24class QGridLayout; 24class QGridLayout;
25class QComboBox; 25class QComboBox;
26class QListView; 26class QListView;
27class QListviewItem; 27class QListviewItem;
28class QLabel; 28class QLabel;
29class QProgressBar; 29class QProgressBar;
30class QSpinBox; 30class QSpinBox;
31class QTabWidget; 31class QTabWidget;
32class QWidget; 32class QWidget;
33class QPEToolBar; 33class QPEToolBar;
34class QPEMenuBar; 34class QPEMenuBar;
35class QPopupMenu; 35class QPopupMenu;
36class QFile; 36class QFile;
37class QListViewItem; 37class QListViewItem;
38class QLineEdit; 38class QLineEdit;
39 39
40class OpieFtp : public QMainWindow 40class OpieFtp : public QMainWindow
41{ 41{
42 Q_OBJECT 42 Q_OBJECT
43 43
44public: 44public:
45 OpieFtp( ); 45 OpieFtp( );
46 ~OpieFtp(); 46 ~OpieFtp();
47 47
48 QTabWidget *TabWidget; 48 QTabWidget *TabWidget;
49 QWidget *tab, *tab_2, *tab_3; 49 QWidget *tab, *tab_2, *tab_3;
50 QListView *Local_View, *Remote_View; 50 QListView *Local_View, *Remote_View;
51 51
52 QComboBox *UsernameComboBox, *ServerComboBox; 52 QComboBox *UsernameComboBox, *ServerComboBox;
53 QLineEdit *PasswordEdit, *remotePath, *currentPathEdit; 53 QLineEdit *PasswordEdit, *remotePath, *currentPathEdit;
54 QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;; 54 QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;;
55 QSpinBox* PortSpinBox; 55 QSpinBox* PortSpinBox;
56 QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu; 56 QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu;
57 QDir currentDir; 57 QDir currentDir;
58 QString currentRemoteDir; 58 QString currentRemoteDir;
59 QString filterStr; 59 QString filterStr;
60 QListViewItem * item; 60 QListViewItem * item;
61 bool b; 61 bool b;
62 62
63protected slots: 63protected slots:
64 void showLocalMenu( QListViewItem *); 64 void showLocalMenu( QListViewItem *);
65 void showRemoteMenu( QListViewItem *); 65 void showRemoteMenu( QListViewItem *);
66 void doLocalCd(); 66 void doLocalCd();
67 void doRemoteCd(); 67 void doRemoteCd();
68 void localUpload(); 68 void localUpload();
69 void remoteDownload(); 69 void remoteDownload();
70 void newConnection(); 70 void newConnection();
71 void connector(); 71 void connector();
72 void disConnector(); 72 void disConnector();
73 void populateLocalView(); 73 void populateLocalView();
74 bool populateRemoteView(); 74 bool populateRemoteView();
75 void showHidden(); 75 void showHidden();
76 76 void writeConfig();
77 void readConfig();
77 void localListClicked(QListViewItem *); 78 void localListClicked(QListViewItem *);
78 void remoteListClicked(QListViewItem *); 79 void remoteListClicked(QListViewItem *);
79 void ListPressed( int, QListViewItem *, const QPoint&, int); 80 void ListPressed( int, QListViewItem *, const QPoint&, int);
80 void RemoteListPressed( int, QListViewItem *, const QPoint&, int); 81 void RemoteListPressed( int, QListViewItem *, const QPoint&, int);
81 void localMakDir(); 82 void localMakDir();
82 void localDelete(); 83 void localDelete();
83 void remoteMakDir(); 84 void remoteMakDir();
84 void remoteDelete(); 85 void remoteDelete();
85 bool remoteDirList(const QString &); 86 bool remoteDirList(const QString &);
86 bool remoteChDir(const QString &); 87 bool remoteChDir(const QString &);
87 void tabChanged(QWidget*); 88 void tabChanged(QWidget*);
88 void cleanUp(); 89 void cleanUp();
89 void remoteRename(); 90 void remoteRename();
90 void localRename(); 91 void localRename();
91 void currentPathEditChanged(); 92 void currentPathEditChanged();
92 void switchToLocalTab(); 93 void switchToLocalTab();
93 void switchToRemoteTab(); 94 void switchToRemoteTab();
94 void switchToConfigTab(); 95 void switchToConfigTab();
96 void fillCombos();
97 void serverComboSelected(int);
98 void deleteServer();
99
95protected: 100protected:
96 void nullifyCallBack(); 101 void nullifyCallBack();
97 QGridLayout* tabLayout; 102 QGridLayout* tabLayout;
98 QGridLayout* tabLayout_2; 103 QGridLayout* tabLayout_2;
99 QGridLayout* tabLayout_3; 104 QGridLayout* tabLayout_3;
100 105
101}; 106};
102 107
103#endif // OPIEFTP_H 108#endif // OPIEFTP_H