summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-24 17:03:37 (UTC)
committer llornkcor <llornkcor>2002-03-24 17:03:37 (UTC)
commit6ce8bbff9eb16e0d731755010bda63e7fb43f70b (patch) (unidiff)
tree0f3cf5476398743f86fa6d884d86751a7251df3e
parent368d5032f4ff4566dea1e99aa2bb782300e0bfd5 (diff)
downloadopie-6ce8bbff9eb16e0d731755010bda63e7fb43f70b.zip
opie-6ce8bbff9eb16e0d731755010bda63e7fb43f70b.tar.gz
opie-6ce8bbff9eb16e0d731755010bda63e7fb43f70b.tar.bz2
config last server on startup
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp46
1 files changed, 17 insertions, 29 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index e2a6cad..e97a9bf 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,1116 +1,1104 @@
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 DEVELOPERS_VERSION 12//#define DEVELOPERS_VERSION
13 13
14#include "opieftp.h" 14#include "opieftp.h"
15#include "ftplib.h" 15#include "ftplib.h"
16#include "inputDialog.h" 16#include "inputDialog.h"
17 17
18#include <qpe/qpemenubar.h> 18#include <qpe/qpemenubar.h>
19#include <qpe/qpetoolbar.h> 19#include <qpe/qpetoolbar.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24 24
25#include <qtextstream.h> 25#include <qtextstream.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qtoolbutton.h> 27#include <qtoolbutton.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33#include <qpopupmenu.h> 33#include <qpopupmenu.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qmainwindow.h> 35#include <qmainwindow.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qprogressbar.h> 37#include <qprogressbar.h>
38#include <qspinbox.h> 38#include <qspinbox.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qwidget.h> 40#include <qwidget.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qimage.h> 42#include <qimage.h>
43#include <qpixmap.h> 43#include <qpixmap.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qlineedit.h> 45#include <qlineedit.h>
46#include <qregexp.h> 46#include <qregexp.h>
47 47
48#include <unistd.h> 48#include <unistd.h>
49#include <stdlib.h> 49#include <stdlib.h>
50 50
51 51
52QProgressBar *ProgressBar; 52QProgressBar *ProgressBar;
53static netbuf *conn=NULL; 53static netbuf *conn=NULL;
54 54
55static int log_progress(netbuf *ctl, int xfered, void *arg) 55static int log_progress(netbuf *ctl, int xfered, void *arg)
56{ 56{
57 int fsz = *(int *)arg; 57 int fsz = *(int *)arg;
58 int pct = (xfered * 100) / fsz; 58 int pct = (xfered * 100) / fsz;
59// printf("%3d%%\r", pct); 59// printf("%3d%%\r", pct);
60// fflush(stdout); 60// fflush(stdout);
61 ProgressBar->setProgress(xfered); 61 ProgressBar->setProgress(xfered);
62 qApp->processEvents(); 62 qApp->processEvents();
63 return 1; 63 return 1;
64} 64}
65 65
66OpieFtp::OpieFtp( ) 66OpieFtp::OpieFtp( )
67 : QMainWindow( ) 67 : QMainWindow( )
68{ 68{
69 setCaption( tr( "OpieFtp" ) ); 69 setCaption( tr( "OpieFtp" ) );
70 70
71 QGridLayout *layout = new QGridLayout( this ); 71 QGridLayout *layout = new QGridLayout( this );
72 layout->setSpacing( 2); 72 layout->setSpacing( 2);
73 layout->setMargin( 2); 73 layout->setMargin( 2);
74 74
75 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 75 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
76 76
77 QPEMenuBar *menuBar = new QPEMenuBar(this); 77 QPEMenuBar *menuBar = new QPEMenuBar(this);
78 connectionMenu = new QPopupMenu( this ); 78 connectionMenu = new QPopupMenu( this );
79 localMenu = new QPopupMenu( this ); 79 localMenu = new QPopupMenu( this );
80 remoteMenu = new QPopupMenu( this ); 80 remoteMenu = new QPopupMenu( this );
81 tabMenu = new QPopupMenu( this ); 81 tabMenu = new QPopupMenu( this );
82 82
83 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); 83 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 );
84 84
85 menuBar->insertItem( tr( "Connection" ), connectionMenu); 85 menuBar->insertItem( tr( "Connection" ), connectionMenu);
86 menuBar->insertItem( tr( "Local" ), localMenu); 86 menuBar->insertItem( tr( "Local" ), localMenu);
87 menuBar->insertItem( tr( "Remote" ), remoteMenu); 87 menuBar->insertItem( tr( "Remote" ), remoteMenu);
88 menuBar->insertItem( tr( "View" ), tabMenu); 88 menuBar->insertItem( tr( "View" ), tabMenu);
89 89
90 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 90 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
91 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 91 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
92 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 92 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
93 93
94 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 94 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
95 localMenu->insertSeparator(); 95 localMenu->insertSeparator();
96 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 96 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
97 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 97 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
98 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 98 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
99 localMenu->insertSeparator(); 99 localMenu->insertSeparator();
100 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 100 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
101 localMenu->setCheckable(TRUE); 101 localMenu->setCheckable(TRUE);
102 102
103 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 103 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
104 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 104 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
105 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 105 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
106 remoteMenu->insertSeparator(); 106 remoteMenu->insertSeparator();
107 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 107 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
108 108
109 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 109 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
110 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 110 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
111 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); 111 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
112 tabMenu->setCheckable(TRUE); 112 tabMenu->setCheckable(TRUE);
113 113
114 TabWidget = new QTabWidget( this, "TabWidget" ); 114 TabWidget = new QTabWidget( this, "TabWidget" );
115 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); 115 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 );
116 116
117 TabWidget->setTabShape(QTabWidget::Triangular); 117 TabWidget->setTabShape(QTabWidget::Triangular);
118 118
119 tab = new QWidget( TabWidget, "tab" ); 119 tab = new QWidget( TabWidget, "tab" );
120 tabLayout = new QGridLayout( tab ); 120 tabLayout = new QGridLayout( tab );
121 tabLayout->setSpacing( 2); 121 tabLayout->setSpacing( 2);
122 tabLayout->setMargin( 2); 122 tabLayout->setMargin( 2);
123 123
124 Local_View = new QListView( tab, "Local_View" ); 124 Local_View = new QListView( tab, "Local_View" );
125// Local_View->setResizePolicy( QListView::AutoOneFit ); 125// Local_View->setResizePolicy( QListView::AutoOneFit );
126 Local_View->addColumn( tr("File"),120); 126 Local_View->addColumn( tr("File"),120);
127 Local_View->addColumn( tr("Size"),-1); 127 Local_View->addColumn( tr("Size"),-1);
128 Local_View->setColumnAlignment(1,QListView::AlignRight); 128 Local_View->setColumnAlignment(1,QListView::AlignRight);
129 Local_View->addColumn( tr("Date"),-1); 129 Local_View->addColumn( tr("Date"),-1);
130 Local_View->setColumnAlignment(2,QListView::AlignRight); 130 Local_View->setColumnAlignment(2,QListView::AlignRight);
131 Local_View->setAllColumnsShowFocus(TRUE); 131 Local_View->setAllColumnsShowFocus(TRUE);
132 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 132 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
133 133
134 tabLayout->addWidget( Local_View, 0, 0 ); 134 tabLayout->addWidget( Local_View, 0, 0 );
135 135
136 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 136 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
137 this,SLOT( localListClicked(QListViewItem *)) ); 137 this,SLOT( localListClicked(QListViewItem *)) );
138 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 138 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
139 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 139 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
140 140
141 TabWidget->insertTab( tab, tr( "Local" ) ); 141 TabWidget->insertTab( tab, tr( "Local" ) );
142 142
143 tab_2 = new QWidget( TabWidget, "tab_2" ); 143 tab_2 = new QWidget( TabWidget, "tab_2" );
144 tabLayout_2 = new QGridLayout( tab_2 ); 144 tabLayout_2 = new QGridLayout( tab_2 );
145 tabLayout_2->setSpacing( 2); 145 tabLayout_2->setSpacing( 2);
146 tabLayout_2->setMargin( 2); 146 tabLayout_2->setMargin( 2);
147 147
148 Remote_View = new QListView( tab_2, "Remote_View" ); 148 Remote_View = new QListView( tab_2, "Remote_View" );
149 Remote_View->addColumn( tr("File"),120); 149 Remote_View->addColumn( tr("File"),120);
150 Remote_View->addColumn( tr("Size"),-1); 150 Remote_View->addColumn( tr("Size"),-1);
151 Remote_View->setColumnAlignment(1,QListView::AlignRight); 151 Remote_View->setColumnAlignment(1,QListView::AlignRight);
152 Remote_View->addColumn( tr("Date"),-1); 152 Remote_View->addColumn( tr("Date"),-1);
153 Remote_View->setColumnAlignment(2,QListView::AlignRight); 153 Remote_View->setColumnAlignment(2,QListView::AlignRight);
154 Remote_View->addColumn( tr("Dir"),-1);
155 Remote_View->setColumnAlignment(4,QListView::AlignRight);
154 Remote_View->setAllColumnsShowFocus(TRUE); 156 Remote_View->setAllColumnsShowFocus(TRUE);
155 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 157 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
156 158
157 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 159 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
158 this,SLOT( remoteListClicked(QListViewItem *)) ); 160 this,SLOT( remoteListClicked(QListViewItem *)) );
159 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 161 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
160 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 162 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
161 163
162 tabLayout_2->addWidget( Remote_View, 0, 0 ); 164 tabLayout_2->addWidget( Remote_View, 0, 0 );
163 165
164 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 166 TabWidget->insertTab( tab_2, tr( "Remote" ) );
165 167
166 tab_3 = new QWidget( TabWidget, "tab_3" ); 168 tab_3 = new QWidget( TabWidget, "tab_3" );
167 tabLayout_3 = new QGridLayout( tab_3 ); 169 tabLayout_3 = new QGridLayout( tab_3 );
168 tabLayout_3->setSpacing( 2); 170 tabLayout_3->setSpacing( 2);
169 tabLayout_3->setMargin( 2); 171 tabLayout_3->setMargin( 2);
170 172
171 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 173 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
172 TextLabel1->setText( tr( "Username" ) ); 174 TextLabel1->setText( tr( "Username" ) );
173 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 175 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
174 176
175 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 177 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
176 UsernameComboBox->setEditable(TRUE); 178 UsernameComboBox->setEditable(TRUE);
177 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 179 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
178 180
179 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 181 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
180 TextLabel2->setText( tr( "Password" ) ); 182 TextLabel2->setText( tr( "Password" ) );
181 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 183 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
182 184
183 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 185 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
184 PasswordEdit->setEchoMode(QLineEdit::Password); 186 PasswordEdit->setEchoMode(QLineEdit::Password);
185 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 187 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
186 188
187 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 189 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
188 TextLabel3->setText( tr( "Remote server" ) ); 190 TextLabel3->setText( tr( "Remote server" ) );
189 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 191 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
190 192
191 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 193 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
192 ServerComboBox->setEditable(TRUE); 194 ServerComboBox->setEditable(TRUE);
193 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 195 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
194 196
195 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); 197 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
196 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); 198 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) ));
197 199
198 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 200 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
199 TextLabel5->setText( tr( "Remote path" ) ); 201 TextLabel5->setText( tr( "Remote path" ) );
200 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 202 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
201 203
202 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 204 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
203 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 205 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
204 206
205 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 207 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
206 TextLabel4->setText( tr( "Port" ) ); 208 TextLabel4->setText( tr( "Port" ) );
207 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 209 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
208 210
209 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 211 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
210 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 212 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
211 PortSpinBox->setMaxValue(32786); 213 PortSpinBox->setMaxValue(32786);
212 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 214 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
213 215
214 QPushButton *deleteServerBtn; 216 QPushButton *deleteServerBtn;
215 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); 217 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" );
216 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); 218 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
217 219
218 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 220 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
219 221
220 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); 222 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
221 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); 223 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
222 connectServerBtn->setToggleButton(TRUE); 224 connectServerBtn->setToggleButton(TRUE);
223 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); 225 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
224 226
225 227
226 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 228 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
227 tabLayout_3->addItem( spacer, 5, 0 ); 229 tabLayout_3->addItem( spacer, 5, 0 );
228 230
229 TabWidget->insertTab( tab_3, tr( "Config" ) ); 231 TabWidget->insertTab( tab_3, tr( "Config" ) );
230 232
231 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 233 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
232 this,SLOT(tabChanged(QWidget*))); 234 this,SLOT(tabChanged(QWidget*)));
233 235
234 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 236 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
235 currentDir.setPath( QDir::currentDirPath()); 237 currentDir.setPath( QDir::currentDirPath());
236// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 238// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
237 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); 239 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" );
238 layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); 240 layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 );
239 241
240 currentPathEdit->setText( currentDir.canonicalPath()); 242 currentPathEdit->setText( currentDir.canonicalPath());
241 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); 243 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged()));
242 244
243 ProgressBar = new QProgressBar( this, "ProgressBar" ); 245 ProgressBar = new QProgressBar( this, "ProgressBar" );
244 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 246 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
245 247
246 serverComboSelected(0); 248// fillCombos();
247 fillCombos();
248 249
249#ifdef DEVELOPERS_VERSION 250#ifdef DEVELOPERS_VERSION
250 ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 251 ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
251 UsernameComboBox->lineEdit()->setText("root"); 252 UsernameComboBox->lineEdit()->setText("root");
252 PortSpinBox->setValue( 4242); 253 PortSpinBox->setValue( 4242);
253 remotePath->setText( currentRemoteDir = "/"); 254 remotePath->setText( currentRemoteDir = "/");
254// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); 255// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
255// UsernameComboBox->lineEdit()->setText("llornkcor"); 256// UsernameComboBox->lineEdit()->setText("llornkcor");
256// PortSpinBox->setValue( 21); 257// PortSpinBox->setValue( 21);
257// remotePath->setText( currentRemoteDir = "/home/llornkcor"); 258// remotePath->setText( currentRemoteDir = "/home/llornkcor");
258 PasswordEdit->setText( tr( "" ) ); 259 PasswordEdit->setText( tr( "" ) );
259#endif 260#endif
260 filterStr="*"; 261 filterStr="*";
261 b=FALSE; 262 b=FALSE;
262 populateLocalView(); 263 populateLocalView();
264 readConfig();
265 ServerComboBox->setCurrentItem(currentServerConfig);
263 TabWidget->setCurrentPage(2); 266 TabWidget->setCurrentPage(2);
264} 267}
265 268
266OpieFtp::~OpieFtp() 269OpieFtp::~OpieFtp()
267{ 270{
268} 271}
269 272
270void OpieFtp::cleanUp() 273void OpieFtp::cleanUp()
271{ 274{
272 if(conn) 275 if(conn)
273 FtpQuit(conn); 276 FtpQuit(conn);
274 QString sfile=QDir::homeDirPath(); 277 QString sfile=QDir::homeDirPath();
275 if(sfile.right(1) != "/") 278 if(sfile.right(1) != "/")
276 sfile+="/._temp"; 279 sfile+="/._temp";
277 else 280 else
278 sfile+="._temp"; 281 sfile+="._temp";
279 QFile file( sfile); 282 QFile file( sfile);
280 if(file.exists()) 283 if(file.exists())
281 file.remove(); 284 file.remove();
282} 285}
283 286
284void OpieFtp::tabChanged(QWidget *w) 287void OpieFtp::tabChanged(QWidget *w)
285{ 288{
286 if (TabWidget->currentPageIndex() == 0) { 289 if (TabWidget->currentPageIndex() == 0) {
287 currentPathEdit->setText( currentDir.canonicalPath()); 290 currentPathEdit->setText( currentDir.canonicalPath());
288 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 291 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
289 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 292 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
290 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 293 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
291 } 294 }
292 if (TabWidget->currentPageIndex() == 1) { 295 if (TabWidget->currentPageIndex() == 1) {
293 currentPathEdit->setText( currentRemoteDir ); 296 currentPathEdit->setText( currentRemoteDir );
294 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 297 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
295 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 298 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
296 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 299 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
297 } 300 }
298 if (TabWidget->currentPageIndex() == 2) { 301 if (TabWidget->currentPageIndex() == 2) {
299 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 302 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
300 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 303 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
301 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 304 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
302 } 305 }
303} 306}
304 307
305void OpieFtp::newConnection() 308void OpieFtp::newConnection()
306{ 309{
307 UsernameComboBox->lineEdit()->setText(""); 310 UsernameComboBox->lineEdit()->setText("");
308 PasswordEdit->setText( "" ); 311 PasswordEdit->setText( "" );
309 ServerComboBox->lineEdit()->setText( ""); 312 ServerComboBox->lineEdit()->setText( "");
310 remotePath->setText( currentRemoteDir = "/"); 313 remotePath->setText( currentRemoteDir = "/");
311 PortSpinBox->setValue( 21); 314 PortSpinBox->setValue( 21);
312 TabWidget->setCurrentPage(2); 315 TabWidget->setCurrentPage(2);
313 currentServerConfig = -1; 316 currentServerConfig = -1;
314} 317}
315 318
316void OpieFtp::serverComboEdited(const QString & edit) { 319void OpieFtp::serverComboEdited(const QString & edit) {
317 if( !edit.isEmpty() ) { 320 if( !edit.isEmpty() ) {
318 currentServerConfig = -1; 321 currentServerConfig = -1;
319 qDebug("comboedited"); 322 qDebug("comboedited");
320 } 323 }
321} 324}
322 325
323void OpieFtp::connectorBtnToggled(bool On) 326void OpieFtp::connectorBtnToggled(bool On)
324{ 327{
325 if(On) { 328 if(On) {
326 connector(); 329 connector();
327 } else { 330 } else {
328 disConnector(); 331 disConnector();
329 } 332 }
330 333
331} 334}
332 335
333void OpieFtp::connector() 336void OpieFtp::connector()
334{ 337{
335 QCopEnvelope ( "QPE/System", "busy()" ); 338 QCopEnvelope ( "QPE/System", "busy()" );
336// qApp->processEvents(); 339// qApp->processEvents();
337 currentRemoteDir=remotePath->text(); 340 currentRemoteDir=remotePath->text();
338 if(ServerComboBox->currentText().isEmpty()) { 341 if(ServerComboBox->currentText().isEmpty()) {
339 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 342 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
340 TabWidget->setCurrentPage(2); 343 TabWidget->setCurrentPage(2);
341 ServerComboBox->setFocus(); 344 ServerComboBox->setFocus();
342 connectServerBtn->setOn(FALSE); 345 connectServerBtn->setOn(FALSE);
343 connectServerBtn->setText( tr("Connect")); 346 connectServerBtn->setText( tr("Connect"));
344 return; 347 return;
345 } 348 }
346 FtpInit(); 349 FtpInit();
347 TabWidget->setCurrentPage(1); 350 TabWidget->setCurrentPage(1);
348 QString ftp_host = ServerComboBox->currentText(); 351 QString ftp_host = ServerComboBox->currentText();
349 QString ftp_user = UsernameComboBox->currentText(); 352 QString ftp_user = UsernameComboBox->currentText();
350 QString ftp_pass = PasswordEdit->text(); 353 QString ftp_pass = PasswordEdit->text();
351 QString port=PortSpinBox->cleanText(); 354 QString port=PortSpinBox->cleanText();
352 port.stripWhiteSpace(); 355 port.stripWhiteSpace();
353 356
354 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 357 if(ftp_host.find("ftp://",0, TRUE) != -1 )
355 ftp_host=ftp_host.right(ftp_host.length()-6); 358 ftp_host=ftp_host.right(ftp_host.length()-6);
356 ftp_host+=":"+port; 359 ftp_host+=":"+port;
357 if (!FtpConnect( ftp_host.latin1(), &conn)) { 360 if (!FtpConnect( ftp_host.latin1(), &conn)) {
358 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 361 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
359 connectServerBtn->setOn(FALSE); 362 connectServerBtn->setOn(FALSE);
360 connectServerBtn->setText( tr("Connect")); 363 connectServerBtn->setText( tr("Connect"));
361 return ; 364 return ;
362 } 365 }
363 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 366 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
364 QString msg; 367 QString msg;
365 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 368 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
366 msg.replace(QRegExp(":"),"\n"); 369 msg.replace(QRegExp(":"),"\n");
367 QMessageBox::message(tr("Note"),msg); 370 QMessageBox::message(tr("Note"),msg);
368 if(conn) 371 if(conn)
369 FtpQuit(conn); 372 FtpQuit(conn);
370 connectServerBtn->setOn(FALSE); 373 connectServerBtn->setOn(FALSE);
371 connectServerBtn->setText( tr("Connect")); 374 connectServerBtn->setText( tr("Connect"));
372 return ; 375 return ;
373 } 376 }
374 remoteDirList("/") ; 377 remoteDirList("/") ;
375 setCaption(ftp_host); 378 setCaption(ftp_host);
376 writeConfig(); 379 writeConfig();
377 connectServerBtn->setText( tr("Disconnect")); 380 connectServerBtn->setText( tr("Disconnect"));
378 QCopEnvelope ( "QPE/System", "notBusy()" ); 381 QCopEnvelope ( "QPE/System", "notBusy()" );
379} 382}
380 383
381void OpieFtp::disConnector() 384void OpieFtp::disConnector()
382{ 385{
383 if(conn) 386 if(conn)
384 FtpQuit(conn); 387 FtpQuit(conn);
385 setCaption("OpieFtp"); 388 setCaption("OpieFtp");
386 currentRemoteDir="/"; 389 currentRemoteDir="/";
387 Remote_View->clear(); 390 Remote_View->clear();
388 connectServerBtn->setText( tr("Connect")); 391 connectServerBtn->setText( tr("Connect"));
389 connectServerBtn->setOn(FALSE); 392 connectServerBtn->setOn(FALSE);
390 393
391} 394}
392 395
393void OpieFtp::localUpload() 396void OpieFtp::localUpload()
394{ 397{
395 int fsz; 398 int fsz;
396 QCopEnvelope ( "QPE/System", "busy()" ); 399 QCopEnvelope ( "QPE/System", "busy()" );
397// qApp->processEvents(); 400// qApp->processEvents();
398 QString strItem = Local_View->currentItem()->text(0); 401 QString strItem = Local_View->currentItem()->text(0);
399 QString localFile = currentDir.canonicalPath()+"/"+strItem; 402 QString localFile = currentDir.canonicalPath()+"/"+strItem;
400 QString remoteFile= currentRemoteDir+strItem; 403 QString remoteFile= currentRemoteDir+strItem;
401 QFileInfo fi(localFile); 404 QFileInfo fi(localFile);
402 if( !fi.isDir()) { 405 if( !fi.isDir()) {
403 fsz=fi.size(); 406 fsz=fi.size();
404 ProgressBar->setTotalSteps(fsz); 407 ProgressBar->setTotalSteps(fsz);
405 408
406 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 409 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
407 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 410 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
408 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 411 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
409 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 412 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
410 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 413 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
411 414
412 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 415 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
413 QString msg; 416 QString msg;
414 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 417 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
415 msg.replace(QRegExp(":"),"\n"); 418 msg.replace(QRegExp(":"),"\n");
416 QMessageBox::message(tr("Note"),msg); 419 QMessageBox::message(tr("Note"),msg);
417 } 420 }
418 ProgressBar->reset(); 421 ProgressBar->reset();
419 nullifyCallBack(); 422 nullifyCallBack();
420 } else { 423 } else {
421 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 424 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
422 } 425 }
423 TabWidget->setCurrentPage(1); 426 TabWidget->setCurrentPage(1);
424 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 427 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
425 QCopEnvelope ( "QPE/System", "notBusy()" ); 428 QCopEnvelope ( "QPE/System", "notBusy()" );
426} 429}
427 430
428void OpieFtp::nullifyCallBack() 431void OpieFtp::nullifyCallBack()
429{ 432{
430 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 433 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
431 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 434 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
432 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 435 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
433 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 436 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
434 437
435} 438}
436 439
437void OpieFtp::remoteDownload() 440void OpieFtp::remoteDownload()
438{ 441{
439// qApp->processEvents(); 442// qApp->processEvents();
440 int fsz; 443 int fsz;
441 QCopEnvelope ( "QPE/System", "busy()" ); 444 QCopEnvelope ( "QPE/System", "busy()" );
442 QString strItem = Remote_View->currentItem()->text(0); 445 QString strItem = Remote_View->currentItem()->text(0);
443// strItem=strItem.right(strItem.length()-1); 446// strItem=strItem.right(strItem.length()-1);
444 447
445 QString localFile = currentDir.canonicalPath(); 448 QString localFile = currentDir.canonicalPath();
446 if(localFile.right(1).find("/",0,TRUE) == -1) 449 if(localFile.right(1).find("/",0,TRUE) == -1)
447 localFile += "/"; 450 localFile += "/";
448 localFile += strItem; 451 localFile += strItem;
449// QString localFile = currentDir.canonicalPath()+"/"+strItem; 452// QString localFile = currentDir.canonicalPath()+"/"+strItem;
450 QString remoteFile= currentRemoteDir+strItem; 453 QString remoteFile= currentRemoteDir+strItem;
451 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 454 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
452 fsz = 0; 455 fsz = 0;
453 QString temp; 456 QString temp;
454 temp.sprintf( remoteFile+" "+" %dkb", fsz); 457 temp.sprintf( remoteFile+" "+" %dkb", fsz);
455 458
456 ProgressBar->setTotalSteps(fsz); 459 ProgressBar->setTotalSteps(fsz);
457 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 460 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
458 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 461 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
459 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 462 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
460 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 463 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
461 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 464 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
462 465
463 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 466 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
464 QString msg; 467 QString msg;
465 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 468 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
466 msg.replace(QRegExp(":"),"\n"); 469 msg.replace(QRegExp(":"),"\n");
467 QMessageBox::message(tr("Note"),msg); 470 QMessageBox::message(tr("Note"),msg);
468 } 471 }
469 ProgressBar->reset(); 472 ProgressBar->reset();
470 nullifyCallBack(); 473 nullifyCallBack();
471 TabWidget->setCurrentPage(0); 474 TabWidget->setCurrentPage(0);
472 populateLocalView(); 475 populateLocalView();
473 QCopEnvelope ( "QPE/System", "notBusy()" ); 476 QCopEnvelope ( "QPE/System", "notBusy()" );
474} 477}
475 478
476bool OpieFtp::remoteDirList(const QString &dir) 479bool OpieFtp::remoteDirList(const QString &dir)
477{ 480{
478 QString tmp = QDir::homeDirPath(); 481 QString tmp = QDir::homeDirPath();
479 if(tmp.right(1) != "/") 482 if(tmp.right(1) != "/")
480 tmp+="/._temp"; 483 tmp+="/._temp";
481 else 484 else
482 tmp+="._temp"; 485 tmp+="._temp";
483// qDebug("Listing remote dir "+tmp); 486// qDebug("Listing remote dir "+tmp);
484 QCopEnvelope ( "QPE/System", "busy()" ); 487 QCopEnvelope ( "QPE/System", "busy()" );
485 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 488 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
486 QString msg; 489 QString msg;
487 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 490 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
488 msg.replace(QRegExp(":"),"\n"); 491 msg.replace(QRegExp(":"),"\n");
489 QMessageBox::message(tr("Note"),msg); 492 QMessageBox::message(tr("Note"),msg);
490 return false; 493 return false;
491 } 494 }
492 populateRemoteView() ; 495 populateRemoteView() ;
493 QCopEnvelope ( "QPE/System", "notBusy()" ); 496 QCopEnvelope ( "QPE/System", "notBusy()" );
494 return true; 497 return true;
495} 498}
496 499
497bool OpieFtp::remoteChDir(const QString &dir) 500bool OpieFtp::remoteChDir(const QString &dir)
498{ 501{
499 QCopEnvelope ( "QPE/System", "busy()" ); 502 QCopEnvelope ( "QPE/System", "busy()" );
500 if (!FtpChdir( dir.latin1(), conn )) { 503 if (!FtpChdir( dir.latin1(), conn )) {
501 QString msg; 504 QString msg;
502 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 505 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
503 msg.replace(QRegExp(":"),"\n"); 506 msg.replace(QRegExp(":"),"\n");
504 QMessageBox::message(tr("Note"),msg); 507 QMessageBox::message(tr("Note"),msg);
505 qDebug(msg); 508 qDebug(msg);
506 QCopEnvelope ( "QPE/System", "notBusy()" ); 509 QCopEnvelope ( "QPE/System", "notBusy()" );
507 return FALSE; 510 return FALSE;
508 } 511 }
509 QCopEnvelope ( "QPE/System", "notBusy()" ); 512 QCopEnvelope ( "QPE/System", "notBusy()" );
510 return TRUE; 513 return TRUE;
511} 514}
512 515
513void OpieFtp::populateLocalView() 516void OpieFtp::populateLocalView()
514{ 517{
515 Local_View->clear(); 518 Local_View->clear();
516 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 519 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
517 currentDir.setMatchAllDirs(TRUE); 520 currentDir.setMatchAllDirs(TRUE);
518 currentDir.setNameFilter(filterStr); 521 currentDir.setNameFilter(filterStr);
519 QString fileL, fileS, fileDate; 522 QString fileL, fileS, fileDate;
520 bool isDir=FALSE; 523 bool isDir=FALSE;
521 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 524 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
522 QFileInfoListIterator it(*list); 525 QFileInfoListIterator it(*list);
523 QFileInfo *fi; 526 QFileInfo *fi;
524 while ( (fi=it.current()) ) { 527 while ( (fi=it.current()) ) {
525 if (fi->isSymLink() ){ 528 if (fi->isSymLink() ){
526 QString symLink=fi->readLink(); 529 QString symLink=fi->readLink();
527// qDebug("Symlink detected "+symLink); 530// qDebug("Symlink detected "+symLink);
528 QFileInfo sym( symLink); 531 QFileInfo sym( symLink);
529 fileS.sprintf( "%10li", sym.size() ); 532 fileS.sprintf( "%10li", sym.size() );
530 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 533 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
531 fileDate = sym.lastModified().toString(); 534 fileDate = sym.lastModified().toString();
532 } else { 535 } else {
533// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 536// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
534 fileS.sprintf( "%10li", fi->size() ); 537 fileS.sprintf( "%10li", fi->size() );
535 fileL.sprintf( "%s",fi->fileName().data() ); 538 fileL.sprintf( "%s",fi->fileName().data() );
536 fileDate= fi->lastModified().toString(); 539 fileDate= fi->lastModified().toString();
537 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 540 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
538 fileL+="/"; 541 fileL+="/";
539 isDir=TRUE; 542 isDir=TRUE;
540// qDebug( fileL); 543// qDebug( fileL);
541 } 544 }
542 } 545 }
543 if(fileL !="./") { 546 if(fileL !="./") {
544 item = new QListViewItem( Local_View,fileL,fileS, fileDate); 547 item = new QListViewItem( Local_View,fileL,fileS, fileDate);
545 if(isDir || fileL.find("/",0,TRUE) != -1) 548 if(isDir || fileL.find("/",0,TRUE) != -1)
546 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 549 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
547 else 550 else
548 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 551 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
549 } 552 }
550 isDir=FALSE; 553 isDir=FALSE;
551 ++it; 554 ++it;
552 } 555 }
553 Local_View->setSorting( 3,FALSE); 556 Local_View->setSorting( 3,FALSE);
554 currentPathEdit->setText( currentDir.canonicalPath() ); 557 currentPathEdit->setText( currentDir.canonicalPath() );
555} 558}
556 559
557bool OpieFtp::populateRemoteView( ) 560bool OpieFtp::populateRemoteView( )
558{ 561{
559// qDebug("populate remoteview"); 562// qDebug("populate remoteview");
560 QString sfile=QDir::homeDirPath(); 563 QString sfile=QDir::homeDirPath();
561 if(sfile.right(1) != "/") 564 if(sfile.right(1) != "/")
562 sfile+="/._temp"; 565 sfile+="/._temp";
563 else 566 else
564 sfile+="._temp"; 567 sfile+="._temp";
565 QFile file( sfile); 568 QFile file( sfile);
566 Remote_View->clear(); 569 Remote_View->clear();
567 QString s, File_Name; 570 QString s, File_Name;
568 QListViewItem *itemDir=NULL, *itemFile=NULL; 571 QListViewItem *itemDir=NULL, *itemFile=NULL;
569 QString fileL, fileS, fileDate; 572 QString fileL, fileS, fileDate;
570 if ( file.open(IO_ReadOnly)) { 573 if ( file.open(IO_ReadOnly)) {
571 QTextStream t( &file ); // use a text stream 574 QTextStream t( &file ); // use a text stream
572 while ( !t.eof()) { 575 while ( !t.eof()) {
573 s = t.readLine(); 576 s = t.readLine();
574 fileL = s.right(s.length()-55); 577 fileL = s.right(s.length()-55);
575 fileL = fileL.stripWhiteSpace(); 578 fileL = fileL.stripWhiteSpace();
576 if(s.left(1) == "d") 579 if(s.left(1) == "d")
577 fileL = fileL+"/"; 580 fileL = fileL+"/";
578// fileL = "/"+fileL+"/"; 581// fileL = "/"+fileL+"/";
579 fileS = s.mid( 30, 42-30); 582 fileS = s.mid( 30, 42-30);
580 fileS = fileS.stripWhiteSpace(); 583 fileS = fileS.stripWhiteSpace();
581 fileDate = s.mid( 42, 55-42); 584 fileDate = s.mid( 42, 55-42);
582 fileDate = fileDate.stripWhiteSpace(); 585 fileDate = fileDate.stripWhiteSpace();
583 if(fileL.find("total",0,TRUE) == -1) { 586 if(fileL.find("total",0,TRUE) == -1) {
584 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate);
585 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 587 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
588 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d");
586 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 589 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
587 if(itemDir) 590// if(itemDir)
588 item->moveItem(itemDir); 591 item->moveItem(itemDir);
589 itemDir=item; 592 itemDir=item;
590 } else { 593 } else {
594 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f");
591 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 595 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
592 if(itemFile) 596// if(itemFile)
597 item->moveItem(itemDir);
593 item->moveItem(itemFile); 598 item->moveItem(itemFile);
594 itemFile=item; 599 itemFile=item;
595 } 600 }
596 } 601 }
597 } 602 }
598 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 603 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
599 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 604 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
600 file.close(); 605 file.close();
601 if( file.exists()) 606 if( file.exists())
602 file. remove(); 607 file. remove();
603 } else 608 } else
604 qDebug("temp file not opened successfullly "+sfile); 609 qDebug("temp file not opened successfullly "+sfile);
605 Remote_View->setSorting( 4,TRUE); 610 Remote_View->setSorting( 4,TRUE);
606
607 return true; 611 return true;
608} 612}
609 613
610void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 614void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
611{ 615{
612 QCopEnvelope ( "QPE/System", "busy()" ); 616 QCopEnvelope ( "QPE/System", "busy()" );
613 QString oldRemoteCurrentDir = currentRemoteDir; 617 QString oldRemoteCurrentDir = currentRemoteDir;
614 QString strItem=selectedItem->text(0); 618 QString strItem=selectedItem->text(0);
615 strItem=strItem.simplifyWhiteSpace(); 619 strItem=strItem.simplifyWhiteSpace();
616 if(strItem == "../") { // the user wants to go ^ 620 if(strItem == "../") { // the user wants to go ^
617 if( FtpCDUp( conn) == 0) { 621 if( FtpCDUp( conn) == 0) {
618 QString msg; 622 QString msg;
619 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 623 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
620 msg.replace(QRegExp(":"),"\n"); 624 msg.replace(QRegExp(":"),"\n");
621 QMessageBox::message(tr("Note"),msg); 625 QMessageBox::message(tr("Note"),msg);
622 qDebug(msg); 626 qDebug(msg);
623 } 627 }
624 char path[256]; 628 char path[256];
625 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 629 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
626 QString msg; 630 QString msg;
627 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 631 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
628 msg.replace(QRegExp(":"),"\n"); 632 msg.replace(QRegExp(":"),"\n");
629 QMessageBox::message(tr("Note"),msg); 633 QMessageBox::message(tr("Note"),msg);
630 qDebug(msg); 634 qDebug(msg);
631 } 635 }
632 currentRemoteDir=path; 636 currentRemoteDir=path;
633 } else { 637 } else {
634 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 638 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
635 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 639 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
636 strItem = strItem.stripWhiteSpace(); 640 strItem = strItem.stripWhiteSpace();
637 currentRemoteDir = strItem; 641 currentRemoteDir = strItem;
638 if( !remoteChDir( (const QString &)strItem)) { 642 if( !remoteChDir( (const QString &)strItem)) {
639 currentRemoteDir = oldRemoteCurrentDir; 643 currentRemoteDir = oldRemoteCurrentDir;
640 strItem=""; 644 strItem="";
641 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 645 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
642 } 646 }
643 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 647 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
644 qDebug("trying directory"); 648 qDebug("trying directory");
645 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 649 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
646 currentRemoteDir = oldRemoteCurrentDir; 650 currentRemoteDir = oldRemoteCurrentDir;
647 strItem=""; 651 strItem="";
648 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 652 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
649 653
650 } else { 654 } else {
651 currentRemoteDir = currentRemoteDir+strItem; 655 currentRemoteDir = currentRemoteDir+strItem;
652 } 656 }
653 } else { 657 } else {
654 qDebug("download "+strItem); 658 qDebug("download "+strItem);
655 } 659 }
656 } 660 }
657 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 661 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
658 if(currentRemoteDir.right(1) !="/") 662 if(currentRemoteDir.right(1) !="/")
659 currentRemoteDir +="/"; 663 currentRemoteDir +="/";
660 currentPathEdit->setText( currentRemoteDir ); 664 currentPathEdit->setText( currentRemoteDir );
661 QCopEnvelope ( "QPE/System", "notBusy()" ); 665 QCopEnvelope ( "QPE/System", "notBusy()" );
662} 666}
663 667
664void OpieFtp::localListClicked(QListViewItem *selectedItem) 668void OpieFtp::localListClicked(QListViewItem *selectedItem)
665{ 669{
666 QString strItem=selectedItem->text(0); 670 QString strItem=selectedItem->text(0);
667 QString strSize=selectedItem->text(1); 671 QString strSize=selectedItem->text(1);
668 strSize=strSize.stripWhiteSpace(); 672 strSize=strSize.stripWhiteSpace();
669 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 673 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
670 // is symlink 674 // is symlink
671 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 675 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
672 if(QDir(strItem2).exists() ) { 676 if(QDir(strItem2).exists() ) {
673 currentDir.cd(strItem2, TRUE); 677 currentDir.cd(strItem2, TRUE);
674 populateLocalView(); 678 populateLocalView();
675 } 679 }
676 } else { // not a symlink 680 } else { // not a symlink
677 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 681 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
678 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 682 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
679 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 683 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
680 currentDir.cd(strItem,FALSE); 684 currentDir.cd(strItem,FALSE);
681 populateLocalView(); 685 populateLocalView();
682 } else { 686 } else {
683 currentDir.cdUp(); 687 currentDir.cdUp();
684 populateLocalView(); 688 populateLocalView();
685 } 689 }
686 if(QDir(strItem).exists()){ 690 if(QDir(strItem).exists()){
687 currentDir.cd(strItem, TRUE); 691 currentDir.cd(strItem, TRUE);
688 populateLocalView(); 692 populateLocalView();
689 } 693 }
690 } else { 694 } else {
691 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 695 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
692 if( QFile::exists(strItem ) ) { 696 if( QFile::exists(strItem ) ) {
693 qDebug("upload "+strItem); 697 qDebug("upload "+strItem);
694 } 698 }
695 } //end not symlink 699 } //end not symlink
696 chdir(strItem.latin1()); 700 chdir(strItem.latin1());
697 } 701 }
698} 702}
699 703
700void OpieFtp::doLocalCd() 704void OpieFtp::doLocalCd()
701{ 705{
702 localListClicked( Local_View->currentItem()); 706 localListClicked( Local_View->currentItem());
703} 707}
704 708
705void OpieFtp:: doRemoteCd() 709void OpieFtp:: doRemoteCd()
706{ 710{
707 remoteListClicked( Remote_View->currentItem()); 711 remoteListClicked( Remote_View->currentItem());
708 712
709} 713}
710 714
711void OpieFtp::showHidden() 715void OpieFtp::showHidden()
712{ 716{
713 if (!b) { 717 if (!b) {
714 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 718 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
715 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 719 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
716// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 720// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
717 b=TRUE; 721 b=TRUE;
718 722
719 } else { 723 } else {
720 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 724 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
721 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 725 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
722// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 726// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
723 b=FALSE; 727 b=FALSE;
724 } 728 }
725 populateLocalView(); 729 populateLocalView();
726} 730}
727 731
728void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 732void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
729{ 733{
730 switch (mouse) { 734 switch (mouse) {
731 case 1: 735 case 1:
732 break; 736 break;
733 case 2: 737 case 2:
734 showLocalMenu(item); 738 showLocalMenu(item);
735 break; 739 break;
736 }; 740 };
737} 741}
738 742
739void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 743void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
740{ 744{
741 switch (mouse) { 745 switch (mouse) {
742 case 1: 746 case 1:
743 break; 747 break;
744 case 2: 748 case 2:
745 showRemoteMenu(item); 749 showRemoteMenu(item);
746 break; 750 break;
747 }; 751 };
748} 752}
749 753
750void OpieFtp::showRemoteMenu(QListViewItem * item) 754void OpieFtp::showRemoteMenu(QListViewItem * item)
751{ 755{
752 QPopupMenu m;// = new QPopupMenu( Local_View ); 756 QPopupMenu m;// = new QPopupMenu( Local_View );
753 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 757 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
754 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 758 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
755 else 759 else
756 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 760 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
757 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 761 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
758 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 762 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
759 m.insertSeparator(); 763 m.insertSeparator();
760 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 764 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
761 m.exec( QCursor::pos() ); 765 m.exec( QCursor::pos() );
762} 766}
763 767
764void OpieFtp::showLocalMenu(QListViewItem * item) 768void OpieFtp::showLocalMenu(QListViewItem * item)
765{ 769{
766 QPopupMenu m; 770 QPopupMenu m;
767 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 771 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
768 m.insertSeparator(); 772 m.insertSeparator();
769 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 773 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
770 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 774 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
771 else 775 else
772 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 776 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
773 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 777 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
774 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 778 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
775 m.insertSeparator(); 779 m.insertSeparator();
776 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 780 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
777 m.setCheckable(TRUE); 781 m.setCheckable(TRUE);
778 if (b) 782 if (b)
779 m.setItemChecked(m.idAt(0),TRUE); 783 m.setItemChecked(m.idAt(0),TRUE);
780 else 784 else
781 m.setItemChecked(m.idAt(0),FALSE); 785 m.setItemChecked(m.idAt(0),FALSE);
782 786
783 m.exec( QCursor::pos() ); 787 m.exec( QCursor::pos() );
784} 788}
785 789
786void OpieFtp::localMakDir() 790void OpieFtp::localMakDir()
787{ 791{
788 InputDialog *fileDlg; 792 InputDialog *fileDlg;
789 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 793 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
790 fileDlg->exec(); 794 fileDlg->exec();
791 if( fileDlg->result() == 1 ) { 795 if( fileDlg->result() == 1 ) {
792 QString filename = fileDlg->LineEdit1->text(); 796 QString filename = fileDlg->LineEdit1->text();
793 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 797 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
794 } 798 }
795 populateLocalView(); 799 populateLocalView();
796} 800}
797 801
798void OpieFtp::localDelete() 802void OpieFtp::localDelete()
799{ 803{
800 QString f = Local_View->currentItem()->text(0); 804 QString f = Local_View->currentItem()->text(0);
801 if(QDir(f).exists() ) { 805 if(QDir(f).exists() ) {
802 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 806 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
803 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 807 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
804 case 0: { 808 case 0: {
805 f=currentDir.canonicalPath()+"/"+f; 809 f=currentDir.canonicalPath()+"/"+f;
806 QString cmd="rmdir "+f; 810 QString cmd="rmdir "+f;
807 system( cmd.latin1()); 811 system( cmd.latin1());
808 populateLocalView(); 812 populateLocalView();
809 } 813 }
810 break; 814 break;
811 case 1: 815 case 1:
812 // exit 816 // exit
813 break; 817 break;
814 }; 818 };
815 819
816 } else { 820 } else {
817 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 821 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
818 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 822 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
819 case 0: { 823 case 0: {
820 f=currentDir.canonicalPath()+"/"+f; 824 f=currentDir.canonicalPath()+"/"+f;
821 QString cmd="rm "+f; 825 QString cmd="rm "+f;
822 system( cmd.latin1()); 826 system( cmd.latin1());
823 populateLocalView(); 827 populateLocalView();
824 } 828 }
825 break; 829 break;
826 case 1: 830 case 1:
827 // exit 831 // exit
828 break; 832 break;
829 }; 833 };
830 } 834 }
831} 835}
832 836
833void OpieFtp::remoteMakDir() 837void OpieFtp::remoteMakDir()
834{ 838{
835 InputDialog *fileDlg; 839 InputDialog *fileDlg;
836 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 840 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
837 fileDlg->exec(); 841 fileDlg->exec();
838 if( fileDlg->result() == 1 ) { 842 if( fileDlg->result() == 1 ) {
839 QString filename = fileDlg->LineEdit1->text();//+".playlist"; 843 QString filename = fileDlg->LineEdit1->text();//+".playlist";
840 QString tmp=currentRemoteDir+filename; 844 QString tmp=currentRemoteDir+filename;
841 QCopEnvelope ( "QPE/System", "busy()" ); 845 QCopEnvelope ( "QPE/System", "busy()" );
842 if(FtpMkdir( tmp.latin1(), conn) == 0) { 846 if(FtpMkdir( tmp.latin1(), conn) == 0) {
843 QString msg; 847 QString msg;
844 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); 848 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn));
845 msg.replace(QRegExp(":"),"\n"); 849 msg.replace(QRegExp(":"),"\n");
846 QMessageBox::message(tr("Note"),msg); 850 QMessageBox::message(tr("Note"),msg);
847 } 851 }
848 QCopEnvelope ( "QPE/System", "notBusy()" ); 852 QCopEnvelope ( "QPE/System", "notBusy()" );
849 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 853 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
850 } 854 }
851} 855}
852 856
853void OpieFtp::remoteDelete() 857void OpieFtp::remoteDelete()
854{ 858{
855 QString f = Remote_View->currentItem()->text(0); 859 QString f = Remote_View->currentItem()->text(0);
856 QCopEnvelope ( "QPE/System", "busy()" ); 860 QCopEnvelope ( "QPE/System", "busy()" );
857 if( f.right(1) =="/") { 861 if( f.right(1) =="/") {
858 QString path= currentRemoteDir+f; 862 QString path= currentRemoteDir+f;
859 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 863 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
860 ,tr("Yes"),tr("No"),0,0,1) ) { 864 ,tr("Yes"),tr("No"),0,0,1) ) {
861 case 0: { 865 case 0: {
862 f=currentDir.canonicalPath()+"/"+f; 866 f=currentDir.canonicalPath()+"/"+f;
863 if(FtpRmdir( path.latin1(), conn) ==0) { 867 if(FtpRmdir( path.latin1(), conn) ==0) {
864 QString msg; 868 QString msg;
865 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); 869 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn));
866 msg.replace(QRegExp(":"),"\n"); 870 msg.replace(QRegExp(":"),"\n");
867 QMessageBox::message(tr("Note"),msg); 871 QMessageBox::message(tr("Note"),msg);
868 } 872 }
869 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 873 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
870 874
871 } 875 }
872 break; 876 break;
873 }; 877 };
874 } else { 878 } else {
875 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 879 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
876 ,tr("Yes"),tr("No"),0,0,1) ) { 880 ,tr("Yes"),tr("No"),0,0,1) ) {
877 case 0: { 881 case 0: {
878 QString path= currentRemoteDir+f; 882 QString path= currentRemoteDir+f;
879 if(FtpDelete( path.latin1(), conn)==0) { 883 if(FtpDelete( path.latin1(), conn)==0) {
880 QString msg; 884 QString msg;
881 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); 885 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
882 msg.replace(QRegExp(":"),"\n"); 886 msg.replace(QRegExp(":"),"\n");
883 QMessageBox::message(tr("Note"),msg); 887 QMessageBox::message(tr("Note"),msg);
884 } 888 }
885 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 889 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
886 } 890 }
887 break; 891 break;
888 }; 892 };
889 } 893 }
890 QCopEnvelope ( "QPE/System", "notBusy()" ); 894 QCopEnvelope ( "QPE/System", "notBusy()" );
891} 895}
892 896
893void OpieFtp::remoteRename() 897void OpieFtp::remoteRename()
894{ 898{
895 QString curFile = Remote_View->currentItem()->text(0); 899 QString curFile = Remote_View->currentItem()->text(0);
896 InputDialog *fileDlg; 900 InputDialog *fileDlg;
897 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 901 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
898 fileDlg->inputText = curFile; 902 fileDlg->inputText = curFile;
899 fileDlg->exec(); 903 fileDlg->exec();
900 if( fileDlg->result() == 1 ) { 904 if( fileDlg->result() == 1 ) {
901 QString oldName = currentRemoteDir +"/"+ curFile; 905 QString oldName = currentRemoteDir +"/"+ curFile;
902 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; 906 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
903 QCopEnvelope ( "QPE/System", "busy()" ); 907 QCopEnvelope ( "QPE/System", "busy()" );
904 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { 908 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
905 QString msg; 909 QString msg;
906 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); 910 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn));
907 msg.replace(QRegExp(":"),"\n"); 911 msg.replace(QRegExp(":"),"\n");
908 QMessageBox::message(tr("Note"),msg); 912 QMessageBox::message(tr("Note"),msg);
909 } 913 }
910 QCopEnvelope ( "QPE/System", "notBusy()" ); 914 QCopEnvelope ( "QPE/System", "notBusy()" );
911 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 915 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
912 } 916 }
913} 917}
914 918
915void OpieFtp::localRename() 919void OpieFtp::localRename()
916{ 920{
917 QString curFile = Local_View->currentItem()->text(0); 921 QString curFile = Local_View->currentItem()->text(0);
918 InputDialog *fileDlg; 922 InputDialog *fileDlg;
919 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 923 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
920 fileDlg->inputText = curFile; 924 fileDlg->inputText = curFile;
921 fileDlg->exec(); 925 fileDlg->exec();
922 if( fileDlg->result() == 1 ) { 926 if( fileDlg->result() == 1 ) {
923 QString oldname = currentDir.canonicalPath() + "/" + curFile; 927 QString oldname = currentDir.canonicalPath() + "/" + curFile;
924 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 928 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
925 if( rename(oldname.latin1(), newName.latin1())== -1) 929 if( rename(oldname.latin1(), newName.latin1())== -1)
926 QMessageBox::message(tr("Note"),tr("Could not rename")); 930 QMessageBox::message(tr("Note"),tr("Could not rename"));
927 } 931 }
928 populateLocalView(); 932 populateLocalView();
929} 933}
930 934
931void OpieFtp::currentPathEditChanged() 935void OpieFtp::currentPathEditChanged()
932{ 936{
933 QString oldRemoteCurrentDir = currentRemoteDir; 937 QString oldRemoteCurrentDir = currentRemoteDir;
934// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); 938// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir);
935 if (TabWidget->currentPageIndex() == 0) { 939 if (TabWidget->currentPageIndex() == 0) {
936 if(QDir( currentPathEdit->text()).exists()) { 940 if(QDir( currentPathEdit->text()).exists()) {
937 currentDir.setPath( currentPathEdit->text() ); 941 currentDir.setPath( currentPathEdit->text() );
938 populateLocalView(); 942 populateLocalView();
939 } else { 943 } else {
940 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 944 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
941 } 945 }
942 } 946 }
943 if (TabWidget->currentPageIndex() == 1) { 947 if (TabWidget->currentPageIndex() == 1) {
944 currentRemoteDir = currentPathEdit->text(); 948 currentRemoteDir = currentPathEdit->text();
945 if(currentRemoteDir.right(1) !="/") { 949 if(currentRemoteDir.right(1) !="/") {
946 currentRemoteDir = currentRemoteDir +"/"; 950 currentRemoteDir = currentRemoteDir +"/";
947 currentPathEdit->setText( currentRemoteDir ); 951 currentPathEdit->setText( currentRemoteDir );
948 } 952 }
949 if( !remoteChDir( (const QString &)currentRemoteDir) ) { 953 if( !remoteChDir( (const QString &)currentRemoteDir) ) {
950 currentRemoteDir = oldRemoteCurrentDir; 954 currentRemoteDir = oldRemoteCurrentDir;
951 currentPathEdit->setText( currentRemoteDir ); 955 currentPathEdit->setText( currentRemoteDir );
952 } 956 }
953 957
954 remoteDirList( (const QString &)currentRemoteDir); 958 remoteDirList( (const QString &)currentRemoteDir);
955 } 959 }
956} 960}
957 961
958void OpieFtp::switchToLocalTab() 962void OpieFtp::switchToLocalTab()
959{ 963{
960 TabWidget->setCurrentPage(0); 964 TabWidget->setCurrentPage(0);
961} 965}
962 966
963void OpieFtp::switchToRemoteTab() 967void OpieFtp::switchToRemoteTab()
964{ 968{
965 TabWidget->setCurrentPage(1); 969 TabWidget->setCurrentPage(1);
966} 970}
967 971
968void OpieFtp::switchToConfigTab() 972void OpieFtp::switchToConfigTab()
969{ 973{
970 TabWidget->setCurrentPage(2); 974 TabWidget->setCurrentPage(2);
971} 975}
972 976
973void OpieFtp::readConfig() 977void OpieFtp::readConfig()
974{ 978{
975 979 fillCombos();
976 Config cfg("opieftp"); 980 Config cfg("opieftp");
977 cfg.setGroup("Server"); 981 cfg.setGroup("Server");
978 QString username, remoteServer, remotePathStr, password, port, temp; 982 currentServerConfig = cfg.readNumEntry("currentServer", -1);
979 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 983 serverComboSelected( currentServerConfig);
980 for (int i = 0; i <= numberOfEntries; i++) {
981 temp.setNum(i+1);
982 cfg.setGroup("Server");
983 remoteServer = cfg.readEntry( temp,"");
984 ServerComboBox->insertItem( remoteServer );
985 cfg.setGroup(temp);
986
987 remotePathStr = cfg.readEntry(remoteServer,"");
988 int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
989 port = remoteServer.right( divider+1);
990 bool ok;
991 PortSpinBox->setValue( port.toInt(&ok,10));
992
993 remoteServer = remoteServer.left(divider - 1);
994 remotePath->setText( remotePathStr);
995 username = cfg.readEntry(temp);
996 UsernameComboBox->insertItem(username);
997 password = cfg.readEntryCrypt(username,"");
998 PasswordEdit->setText(password);
999 }
1000} 984}
1001 985
1002void OpieFtp::writeConfig() 986void OpieFtp::writeConfig()
1003{ 987{
1004 988
1005 Config cfg("opieftp"); 989 Config cfg("opieftp");
1006 cfg.setGroup("Server"); 990 cfg.setGroup("Server");
1007 QString username, remoteServerStr, remotePathStr, password, port, temp; 991 QString username, remoteServerStr, remotePathStr, password, port, temp;
1008 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 992 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1009 if( currentServerConfig == -1) { 993 if( currentServerConfig == -1) {
1010 994
1011 temp.setNum( numberOfEntries + 1); 995 temp.setNum( numberOfEntries + 1);
1012 cfg.setGroup("Server"); 996 cfg.setGroup("Server");
1013 remoteServerStr = cfg.readEntry( temp,""); 997 remoteServerStr = cfg.readEntry( temp,"");
1014 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 998 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1015 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 999 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1016 1000
1017 temp.setNum(numberOfEntries+1); 1001 temp.setNum(numberOfEntries+1);
1018 cfg.setGroup("Server"); 1002 cfg.setGroup("Server");
1019 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); 1003 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() );
1020 cfg.setGroup(temp); 1004 cfg.setGroup(temp);
1021 cfg.writeEntry("RemotePath", remotePath->text()); 1005 cfg.writeEntry("RemotePath", remotePath->text());
1022 cfg.writeEntry("Username", UsernameComboBox->currentText()); 1006 cfg.writeEntry("Username", UsernameComboBox->currentText());
1023 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); 1007 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text());
1024 cfg.setGroup("Server"); 1008 cfg.setGroup("Server");
1025 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); 1009 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
1026 1010
1027 } 1011 }
1028} 1012}
1029 1013
1030void OpieFtp::fillCombos() 1014void OpieFtp::fillCombos()
1031{ 1015{
1032 Config cfg("opieftp"); 1016 Config cfg("opieftp");
1033 cfg.setGroup("Server"); 1017 cfg.setGroup("Server");
1034 QString username, remoteServerStr, remotePathStr, password, port, temp; 1018 QString username, remoteServerStr, remotePathStr, password, port, temp;
1035 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1019 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1036 for (int i = 1; i <= numberOfEntries; i++) { 1020 for (int i = 1; i <= numberOfEntries; i++) {
1037 temp.setNum(i); 1021 temp.setNum(i);
1038 cfg.setGroup("Server"); 1022 cfg.setGroup("Server");
1039 remoteServerStr = cfg.readEntry( temp,""); 1023 remoteServerStr = cfg.readEntry( temp,"");
1040 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1024 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1041 port = remoteServerStr.right( divider - 1); 1025 port = remoteServerStr.right( divider - 1);
1042 bool ok; 1026 bool ok;
1043 PortSpinBox->setValue( port.toInt(&ok,10)); 1027 PortSpinBox->setValue( port.toInt(&ok,10));
1044 1028
1045 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1029 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1046 ServerComboBox->insertItem( remoteServerStr ); 1030 ServerComboBox->insertItem( remoteServerStr );
1047// cfg.setGroup(temp); 1031// cfg.setGroup(temp);
1048 1032
1049// remotePathStr = cfg.readEntry(remoteServer,""); 1033// remotePathStr = cfg.readEntry(remoteServer,"");
1050// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); 1034// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
1051// port = remoteServer.right( divider+1); 1035// port = remoteServer.right( divider+1);
1052// PortSpinBox->setValue( port); 1036// PortSpinBox->setValue( port);
1053 1037
1054// remoteServer = remoteServer.left(divider - 1); 1038// remoteServer = remoteServer.left(divider - 1);
1055// remotePath->setText( remotePathStr); 1039// remotePath->setText( remotePathStr);
1056 1040
1057// username = cfg.readEntry(temp); 1041// username = cfg.readEntry(temp);
1058// UsernameComboBox->insertItem(username); 1042// UsernameComboBox->insertItem(username);
1059// password = cfg.readEntryCrypt(username,""); 1043// password = cfg.readEntryCrypt(username,"");
1060// PasswordEdit->setText(password); 1044// PasswordEdit->setText(password);
1061 } 1045 }
1062} 1046}
1063 1047
1064 1048
1065void OpieFtp::serverComboSelected(int index) 1049void OpieFtp::serverComboSelected(int index)
1066{ 1050{
1067 currentServerConfig = index; 1051 currentServerConfig = index;
1068 QString username, remoteServerStr, remotePathStr, password, port, temp; 1052 QString username, remoteServerStr, remotePathStr, password, port, temp;
1069// remoteServerStr = ServerComboBox->text(index); 1053// remoteServerStr = ServerComboBox->text(index);
1070 Config cfg("opieftp"); 1054 Config cfg("opieftp");
1071 cfg.setGroup("Server"); 1055 cfg.setGroup("Server");
1072 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1056 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1073 1057
1074 temp.setNum(index+1); 1058 temp.setNum(index+1);
1075 remoteServerStr = cfg.readEntry( temp,""); 1059 remoteServerStr = cfg.readEntry( temp,"");
1076 cfg.setGroup(temp); 1060 cfg.setGroup(temp);
1077 qDebug(temp); 1061 qDebug(temp);
1078 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1062 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1079 port = remoteServerStr.right( divider - 1); 1063 port = remoteServerStr.right( divider - 1);
1080 bool ok; 1064 bool ok;
1081 int portInt = port.toInt(&ok,10); 1065 int portInt = port.toInt(&ok,10);
1082 if( portInt == 0) portInt = 21; 1066 if( portInt == 0) portInt = 21;
1083 1067
1084 PortSpinBox->setValue( portInt); 1068 PortSpinBox->setValue( portInt);
1085 1069
1086 remotePath->setText(cfg.readEntry("RemotePath", "/")); 1070 remotePath->setText(cfg.readEntry("RemotePath", "/"));
1087 1071
1088 username = cfg.readEntry("Username", "anonymous"); 1072 username = cfg.readEntry("Username", "anonymous");
1089 UsernameComboBox->lineEdit()->setText(username); 1073 UsernameComboBox->lineEdit()->setText(username);
1090 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); 1074 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org"));
1075
1076 cfg.setGroup("Server");
1077 temp.sprintf("%d",currentServerConfig);
1078 cfg.writeEntry("currentServer", temp);
1091 update(); 1079 update();
1092} 1080}
1093// UsernameComboBox->lineEdit()->setText("root"); 1081// UsernameComboBox->lineEdit()->setText("root");
1094// PasswordEdit->setText( tr( "" ) ); 1082// PasswordEdit->setText( tr( "" ) );
1095// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 1083// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
1096// remotePath->setText( currentRemoteDir = "/home/llornkcor/"); 1084// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
1097// PortSpinBox->setValue( 4242); 1085// PortSpinBox->setValue( 4242);
1098 1086
1099void OpieFtp::deleteServer() 1087void OpieFtp::deleteServer()
1100{ 1088{
1101 QString username, remoteServerStr, remotePathStr, password, port, temp; 1089 QString username, remoteServerStr, remotePathStr, password, port, temp;
1102 remoteServerStr = ServerComboBox->currentText( ); 1090 remoteServerStr = ServerComboBox->currentText( );
1103 username = UsernameComboBox->currentText(); 1091 username = UsernameComboBox->currentText();
1104 Config cfg("opieftp"); 1092 Config cfg("opieftp");
1105 cfg.setGroup("Server"); 1093 cfg.setGroup("Server");
1106 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1094 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1107 for (int i = 0; i <= numberOfEntries; i++) { 1095 for (int i = 0; i <= numberOfEntries; i++) {
1108 temp.setNum(i+1); 1096 temp.setNum(i+1);
1109 cfg.setGroup("Server"); 1097 cfg.setGroup("Server");
1110 if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 1098 if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1
1111 && cfg.readEntry(temp).find(username,0,TRUE) != -1 1099 && cfg.readEntry(temp).find(username,0,TRUE) != -1
1112 && !remoteServerStr.isEmpty()) { 1100 && !remoteServerStr.isEmpty()) {
1113 qDebug(temp); 1101 qDebug(temp);
1114 } 1102 }
1115 } 1103 }
1116} 1104}