summaryrefslogtreecommitdiff
path: root/noncore/net/opieftp/opieftp.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieftp/opieftp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp89
1 files changed, 43 insertions, 46 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 3e13466..956409f 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -39,583 +39,584 @@
39#include <qprogressbar.h> 39#include <qprogressbar.h>
40#include <qspinbox.h> 40#include <qspinbox.h>
41#include <qtabwidget.h> 41#include <qtabwidget.h>
42#include <qwidget.h> 42#include <qwidget.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qimage.h> 44#include <qimage.h>
45#include <qpixmap.h> 45#include <qpixmap.h>
46#include <qmessagebox.h> 46#include <qmessagebox.h>
47#include <qlineedit.h> 47#include <qlineedit.h>
48#include <qregexp.h> 48#include <qregexp.h>
49 49
50#include <unistd.h> 50#include <unistd.h>
51#include <stdlib.h> 51#include <stdlib.h>
52 52
53 53
54QProgressBar *ProgressBar; 54QProgressBar *ProgressBar;
55static netbuf *conn=NULL; 55static netbuf *conn=NULL;
56 56
57static int log_progress(netbuf *ctl, int xfered, void *arg) 57static int log_progress(netbuf *ctl, int xfered, void *arg)
58{ 58{
59 int fsz = *(int *)arg; 59 int fsz = *(int *)arg;
60 int pct = (xfered * 100) / fsz; 60 int pct = (xfered * 100) / fsz;
61// printf("%3d%%\r", pct); 61// printf("%3d%%\r", pct);
62// fflush(stdout); 62// fflush(stdout);
63 ProgressBar->setProgress(xfered); 63 ProgressBar->setProgress(xfered);
64 qApp->processEvents(); 64 qApp->processEvents();
65 return 1; 65 return 1;
66} 66}
67 67
68OpieFtp::OpieFtp( ) 68OpieFtp::OpieFtp( )
69 : QMainWindow( ) 69 : QMainWindow( )
70{ 70{
71 setCaption( tr( "OpieFtp" ) ); 71 setCaption( tr( "OpieFtp" ) );
72 72
73 QGridLayout *layout = new QGridLayout( this ); 73 QGridLayout *layout = new QGridLayout( this );
74 layout->setSpacing( 2); 74 layout->setSpacing( 2);
75 layout->setMargin( 2); 75 layout->setMargin( 2);
76 76
77 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 77 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
78 78
79 QPEMenuBar *menuBar = new QPEMenuBar(this); 79 QPEMenuBar *menuBar = new QPEMenuBar(this);
80 connectionMenu = new QPopupMenu( this ); 80 connectionMenu = new QPopupMenu( this );
81 localMenu = new QPopupMenu( this ); 81 localMenu = new QPopupMenu( this );
82 remoteMenu = new QPopupMenu( this ); 82 remoteMenu = new QPopupMenu( this );
83 tabMenu = new QPopupMenu( this ); 83 tabMenu = new QPopupMenu( this );
84 84
85 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); 85 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 );
86 86
87 menuBar->insertItem( tr( "Connection" ), connectionMenu); 87 menuBar->insertItem( tr( "Connection" ), connectionMenu);
88 menuBar->insertItem( tr( "Local" ), localMenu); 88 menuBar->insertItem( tr( "Local" ), localMenu);
89 menuBar->insertItem( tr( "Remote" ), remoteMenu); 89 menuBar->insertItem( tr( "Remote" ), remoteMenu);
90 menuBar->insertItem( tr( "View" ), tabMenu); 90 menuBar->insertItem( tr( "View" ), tabMenu);
91 91
92 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 92 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
93 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 93 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
94 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 94 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
95 95
96 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 96 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
97 localMenu->insertSeparator(); 97 localMenu->insertSeparator();
98 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 98 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
99 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 99 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
100 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 100 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
101 localMenu->insertSeparator(); 101 localMenu->insertSeparator();
102 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 102 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
103 localMenu->setCheckable(TRUE); 103 localMenu->setCheckable(TRUE);
104 104
105 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 105 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
106 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 106 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
107 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 107 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
108 remoteMenu->insertSeparator(); 108 remoteMenu->insertSeparator();
109 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 109 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
110 110
111 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 111 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
112 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 112 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
113 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); 113 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
114 tabMenu->setCheckable(TRUE); 114 tabMenu->setCheckable(TRUE);
115 115
116 TabWidget = new QTabWidget( this, "TabWidget" ); 116 TabWidget = new QTabWidget( this, "TabWidget" );
117 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); 117 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 );
118 118
119 TabWidget->setTabShape(QTabWidget::Triangular); 119 TabWidget->setTabShape(QTabWidget::Triangular);
120 120
121 tab = new QWidget( TabWidget, "tab" ); 121 tab = new QWidget( TabWidget, "tab" );
122 tabLayout = new QGridLayout( tab ); 122 tabLayout = new QGridLayout( tab );
123 tabLayout->setSpacing( 2); 123 tabLayout->setSpacing( 2);
124 tabLayout->setMargin( 2); 124 tabLayout->setMargin( 2);
125 125
126 Local_View = new QListView( tab, "Local_View" ); 126 Local_View = new QListView( tab, "Local_View" );
127// Local_View->setResizePolicy( QListView::AutoOneFit ); 127// Local_View->setResizePolicy( QListView::AutoOneFit );
128 Local_View->addColumn( tr("File"),150); 128 Local_View->addColumn( tr("File"),150);
129 Local_View->addColumn( tr("Size"),-1); 129 Local_View->addColumn( tr("Size"),-1);
130 Local_View->setColumnAlignment(1,QListView::AlignRight); 130 Local_View->setColumnAlignment(1,QListView::AlignRight);
131 Local_View->addColumn( tr("Date"),-1); 131 Local_View->addColumn( tr("Date"),-1);
132 Local_View->setColumnAlignment(2,QListView::AlignRight); 132 Local_View->setColumnAlignment(2,QListView::AlignRight);
133 Local_View->setAllColumnsShowFocus(TRUE); 133 Local_View->setAllColumnsShowFocus(TRUE);
134 Local_View->setMultiSelection( TRUE ); 134 Local_View->setMultiSelection( TRUE );
135 135 Local_View->setSelectionMode(QlistView::Extended);
136 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 136 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
137 137
138 tabLayout->addWidget( Local_View, 0, 0 ); 138 tabLayout->addWidget( Local_View, 0, 0 );
139 139
140 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 140 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
141 this,SLOT( localListClicked(QListViewItem *)) ); 141 this,SLOT( localListClicked(QListViewItem *)) );
142// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), 142// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
143// this,SLOT( localListClicked(QListViewItem *)) ); 143// this,SLOT( localListClicked(QListViewItem *)) );
144 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 144 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
145 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 145 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
146 146
147 TabWidget->insertTab( tab, tr( "Local" ) ); 147 TabWidget->insertTab( tab, tr( "Local" ) );
148 148
149 tab_2 = new QWidget( TabWidget, "tab_2" ); 149 tab_2 = new QWidget( TabWidget, "tab_2" );
150 tabLayout_2 = new QGridLayout( tab_2 ); 150 tabLayout_2 = new QGridLayout( tab_2 );
151 tabLayout_2->setSpacing( 2); 151 tabLayout_2->setSpacing( 2);
152 tabLayout_2->setMargin( 2); 152 tabLayout_2->setMargin( 2);
153 153
154 Remote_View = new QListView( tab_2, "Remote_View" ); 154 Remote_View = new QListView( tab_2, "Remote_View" );
155 Remote_View->addColumn( tr("File"),150); 155 Remote_View->addColumn( tr("File"),150);
156 Remote_View->addColumn( tr("Size"),-1); 156 Remote_View->addColumn( tr("Size"),-1);
157 Remote_View->setColumnAlignment(1,QListView::AlignRight); 157 Remote_View->setColumnAlignment(1,QListView::AlignRight);
158 Remote_View->addColumn( tr("Date"),-1); 158 Remote_View->addColumn( tr("Date"),-1);
159 Remote_View->setColumnAlignment(2,QListView::AlignRight); 159 Remote_View->setColumnAlignment(2,QListView::AlignRight);
160 Remote_View->addColumn( tr("Dir"),-1); 160 Remote_View->addColumn( tr("Dir"),-1);
161 Remote_View->setColumnAlignment(4,QListView::AlignRight); 161 Remote_View->setColumnAlignment(4,QListView::AlignRight);
162 Remote_View->setAllColumnsShowFocus(TRUE); 162 Remote_View->setAllColumnsShowFocus(TRUE);
163 Remote_View->setMultiSelection( TRUE ); 163 Remote_View->setMultiSelection( TRUE );
164 Remote_View->setSelectionMode(QlistView::Extended);
164 165
165 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 166 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
166 167
167 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 168 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
168 this,SLOT( remoteListClicked(QListViewItem *)) ); 169 this,SLOT( remoteListClicked(QListViewItem *)) );
169 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 170 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
170 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 171 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
171 172
172 tabLayout_2->addWidget( Remote_View, 0, 0 ); 173 tabLayout_2->addWidget( Remote_View, 0, 0 );
173 174
174 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 175 TabWidget->insertTab( tab_2, tr( "Remote" ) );
175 176
176 tab_3 = new QWidget( TabWidget, "tab_3" ); 177 tab_3 = new QWidget( TabWidget, "tab_3" );
177 tabLayout_3 = new QGridLayout( tab_3 ); 178 tabLayout_3 = new QGridLayout( tab_3 );
178 tabLayout_3->setSpacing( 2); 179 tabLayout_3->setSpacing( 2);
179 tabLayout_3->setMargin( 2); 180 tabLayout_3->setMargin( 2);
180 181
181 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 182 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
182 TextLabel1->setText( tr( "Username" ) ); 183 TextLabel1->setText( tr( "Username" ) );
183 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 184 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
184 185
185 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 186 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
186 UsernameComboBox->setEditable(TRUE); 187 UsernameComboBox->setEditable(TRUE);
187 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 188 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
188 189
189 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 190 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
190 TextLabel2->setText( tr( "Password" ) ); 191 TextLabel2->setText( tr( "Password" ) );
191 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 192 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
192 193
193 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 194 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
194 PasswordEdit->setEchoMode(QLineEdit::Password); 195 PasswordEdit->setEchoMode(QLineEdit::Password);
195 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 196 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
196 197
197 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 198 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
198 TextLabel3->setText( tr( "Remote server" ) ); 199 TextLabel3->setText( tr( "Remote server" ) );
199 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 200 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
200 201
201 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 202 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
202 ServerComboBox->setEditable(TRUE); 203 ServerComboBox->setEditable(TRUE);
203 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 204 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
204 205
205 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); 206 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
206 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); 207 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) ));
207 208
208 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 209 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
209 TextLabel5->setText( tr( "Remote path" ) ); 210 TextLabel5->setText( tr( "Remote path" ) );
210 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 211 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
211 212
212 213
213 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 214 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
214 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 215 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
215 216
216 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 217 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
217 TextLabel4->setText( tr( "Port" ) ); 218 TextLabel4->setText( tr( "Port" ) );
218 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 219 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
219 220
220 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 221 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
221 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 222 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
222 PortSpinBox->setMaxValue(32786); 223 PortSpinBox->setMaxValue(32786);
223 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 224 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
224 225
225 QPushButton *deleteServerBtn; 226 QPushButton *deleteServerBtn;
226 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); 227 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" );
227 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); 228 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
228 229
229 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 230 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
230 231
231 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); 232 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
232 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); 233 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
233 connectServerBtn->setToggleButton(TRUE); 234 connectServerBtn->setToggleButton(TRUE);
234 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); 235 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
235 236
236 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 237 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
237 tabLayout_3->addItem( spacer, 5, 0 ); 238 tabLayout_3->addItem( spacer, 5, 0 );
238 239
239 TabWidget->insertTab( tab_3, tr( "Config" ) ); 240 TabWidget->insertTab( tab_3, tr( "Config" ) );
240 241
241 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 242 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
242 this,SLOT(tabChanged(QWidget*))); 243 this,SLOT(tabChanged(QWidget*)));
243 244
244 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 245 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
245 currentDir.setPath( QDir::currentDirPath()); 246 currentDir.setPath( QDir::currentDirPath());
246// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 247// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
247 248
248 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); 249 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
249 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 ); 250 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 );
250 currentPathCombo->setEditable(TRUE); 251 currentPathCombo->setEditable(TRUE);
251 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 252 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
252 253
253 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 254 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
254 this, SLOT( currentPathComboActivated( const QString & ) ) ); 255 this, SLOT( currentPathComboActivated( const QString & ) ) );
255 256
256 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 257 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
257 this,SLOT(currentPathComboChanged())); 258 this,SLOT(currentPathComboChanged()));
258 259
259 ProgressBar = new QProgressBar( this, "ProgressBar" ); 260 ProgressBar = new QProgressBar( this, "ProgressBar" );
260 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 261 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
261 262
262// fillCombos(); 263// fillCombos();
263 264
264 filterStr="*"; 265 filterStr="*";
265 b=FALSE; 266 b=FALSE;
266 populateLocalView(); 267 populateLocalView();
267 readConfig(); 268 readConfig();
268 ServerComboBox->setCurrentItem(currentServerConfig); 269 ServerComboBox->setCurrentItem(currentServerConfig);
269 TabWidget->setCurrentPage(2); 270 TabWidget->setCurrentPage(2);
270} 271}
271 272
272OpieFtp::~OpieFtp() 273OpieFtp::~OpieFtp()
273{ 274{
274} 275}
275 276
276void OpieFtp::cleanUp() 277void OpieFtp::cleanUp()
277{ 278{
278 if(conn) 279 if(conn)
279 FtpQuit(conn); 280 FtpQuit(conn);
280 QString sfile=QDir::homeDirPath(); 281 QString sfile=QDir::homeDirPath();
281 if(sfile.right(1) != "/") 282 if(sfile.right(1) != "/")
282 sfile+="/._temp"; 283 sfile+="/._temp";
283 else 284 else
284 sfile+="._temp"; 285 sfile+="._temp";
285 QFile file( sfile); 286 QFile file( sfile);
286 if(file.exists()) 287 if(file.exists())
287 file.remove(); 288 file.remove();
289 exit(0);
288} 290}
289 291
290void OpieFtp::tabChanged(QWidget *w) 292void OpieFtp::tabChanged(QWidget *w)
291{ 293{
292 if (TabWidget->currentPageIndex() == 0) { 294 if (TabWidget->currentPageIndex() == 0) {
293 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 295 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
294 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 296 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
295 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 297 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
296 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 298 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
297 } 299 }
298 if (TabWidget->currentPageIndex() == 1) { 300 if (TabWidget->currentPageIndex() == 1) {
299 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 301 currentPathCombo->lineEdit()->setText( currentRemoteDir );
300 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 302 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
301 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 303 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
302 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 304 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
303 } 305 }
304 if (TabWidget->currentPageIndex() == 2) { 306 if (TabWidget->currentPageIndex() == 2) {
305 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 307 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
306 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 308 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
307 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 309 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
308 } 310 }
309} 311}
310 312
311void OpieFtp::newConnection() 313void OpieFtp::newConnection()
312{ 314{
313 UsernameComboBox->lineEdit()->setText(""); 315 UsernameComboBox->lineEdit()->setText("");
314 PasswordEdit->setText( "" ); 316 PasswordEdit->setText( "" );
315 ServerComboBox->lineEdit()->setText( ""); 317 ServerComboBox->lineEdit()->setText( "");
316 remotePath->setText( currentRemoteDir = "/"); 318 remotePath->setText( currentRemoteDir = "/");
317 PortSpinBox->setValue( 21); 319 PortSpinBox->setValue( 21);
318 TabWidget->setCurrentPage(2); 320 TabWidget->setCurrentPage(2);
319 currentServerConfig = -1; 321 currentServerConfig = -1;
320} 322}
321 323
322void OpieFtp::serverComboEdited(const QString & edit) 324void OpieFtp::serverComboEdited(const QString & edit)
323{ 325{
324 if( !edit.isEmpty() ) { 326 if( !edit.isEmpty() ) {
325 currentServerConfig = -1; 327 currentServerConfig = -1;
326// qDebug("comboedited"); 328// qDebug("comboedited");
327 } 329 }
328} 330}
329 331
330void OpieFtp::connectorBtnToggled(bool On) 332void OpieFtp::connectorBtnToggled(bool On)
331{ 333{
332 if(On) { 334 if(On) {
333 connector(); 335 connector();
334 } else { 336 } else {
335 disConnector(); 337 disConnector();
336 } 338 }
337 339
338} 340}
339 341
340void OpieFtp::connector() 342void OpieFtp::connector()
341{ 343{
342 QCopEnvelope ( "QPE/System", "busy()" ); 344 QCopEnvelope ( "QPE/System", "busy()" );
343// qApp->processEvents(); 345// qApp->processEvents();
344 currentRemoteDir=remotePath->text(); 346 currentRemoteDir=remotePath->text();
345 if(ServerComboBox->currentText().isEmpty()) { 347 if(ServerComboBox->currentText().isEmpty()) {
346 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 348 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
347 TabWidget->setCurrentPage(2); 349 TabWidget->setCurrentPage(2);
348 ServerComboBox->setFocus(); 350 ServerComboBox->setFocus();
349 connectServerBtn->setOn(FALSE); 351 connectServerBtn->setOn(FALSE);
350 connectServerBtn->setText( tr("Connect")); 352 connectServerBtn->setText( tr("Connect"));
351 return; 353 return;
352 } 354 }
353 FtpInit(); 355 FtpInit();
354 TabWidget->setCurrentPage(1); 356 TabWidget->setCurrentPage(1);
355 QString ftp_host = ServerComboBox->currentText(); 357 QString ftp_host = ServerComboBox->currentText();
356 QString ftp_user = UsernameComboBox->currentText(); 358 QString ftp_user = UsernameComboBox->currentText();
357 QString ftp_pass = PasswordEdit->text(); 359 QString ftp_pass = PasswordEdit->text();
358 QString port=PortSpinBox->cleanText(); 360 QString port=PortSpinBox->cleanText();
359 port.stripWhiteSpace(); 361 port.stripWhiteSpace();
360 362
361 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 363 if(ftp_host.find("ftp://",0, TRUE) != -1 )
362 ftp_host=ftp_host.right(ftp_host.length()-6); 364 ftp_host=ftp_host.right(ftp_host.length()-6);
363 ftp_host+=":"+port; 365 ftp_host+=":"+port;
364 if (!FtpConnect( ftp_host.latin1(), &conn)) { 366 if (!FtpConnect( ftp_host.latin1(), &conn)) {
365 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 367 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
366 connectServerBtn->setOn(FALSE); 368 connectServerBtn->setOn(FALSE);
367 connectServerBtn->setText( tr("Connect")); 369 connectServerBtn->setText( tr("Connect"));
368 return ; 370 return ;
369 } 371 }
370 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 372 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
371 QString msg; 373 QString msg;
372 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 374 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
373 msg.replace(QRegExp(":"),"\n"); 375 msg.replace(QRegExp(":"),"\n");
374 QMessageBox::message(tr("Note"),msg); 376 QMessageBox::message(tr("Note"),msg);
375 if(conn) 377 if(conn)
376 FtpQuit(conn); 378 FtpQuit(conn);
377 connectServerBtn->setOn(FALSE); 379 connectServerBtn->setOn(FALSE);
378 connectServerBtn->setText( tr("Connect")); 380 connectServerBtn->setText( tr("Connect"));
379 return ; 381 return ;
380 } 382 }
381 remoteDirList("/") ; 383 remoteDirList("/") ;
382 setCaption(ftp_host); 384 setCaption(ftp_host);
383 writeConfig(); 385 writeConfig();
384 connectServerBtn->setText( tr("Disconnect")); 386 connectServerBtn->setText( tr("Disconnect"));
385 QCopEnvelope ( "QPE/System", "notBusy()" ); 387 QCopEnvelope ( "QPE/System", "notBusy()" );
386} 388}
387 389
388void OpieFtp::disConnector() 390void OpieFtp::disConnector()
389{ 391{
390 if(conn) 392 if(conn)
391 FtpQuit(conn); 393 FtpQuit(conn);
392 setCaption("OpieFtp"); 394 setCaption("OpieFtp");
393 currentRemoteDir="/"; 395 currentRemoteDir="/";
394 Remote_View->clear(); 396 Remote_View->clear();
395 connectServerBtn->setText( tr("Connect")); 397 connectServerBtn->setText( tr("Connect"));
396 connectServerBtn->setOn(FALSE); 398 connectServerBtn->setOn(FALSE);
397
398} 399}
399 400
400void OpieFtp::localUpload() 401void OpieFtp::localUpload()
401{ 402{
402 int fsz; 403 int fsz;
403 QCopEnvelope ( "QPE/System", "busy()" ); 404 QCopEnvelope ( "QPE/System", "busy()" );
404// qApp->processEvents(); 405// qApp->processEvents();
405 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 406 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
406 QListViewItemIterator it( Local_View ); 407 QListViewItemIterator it( Local_View );
407 for ( ; it.current(); ++it ) { 408 for ( ; it.current(); ++it ) {
408 if ( it.current()->isSelected() ) { 409 if ( it.current()->isSelected() ) {
409 QString strItem = it.current()->text(0); 410 QString strItem = it.current()->text(0);
410 QString localFile = currentDir.canonicalPath()+"/"+strItem; 411 QString localFile = currentDir.canonicalPath()+"/"+strItem;
411 QString remoteFile= currentRemoteDir+strItem; 412 QString remoteFile= currentRemoteDir+strItem;
412 QFileInfo fi(localFile); 413 QFileInfo fi(localFile);
413 if( !fi.isDir()) { 414 if( !fi.isDir()) {
414 fsz=fi.size(); 415 fsz=fi.size();
415 ProgressBar->setTotalSteps(fsz); 416 ProgressBar->setTotalSteps(fsz);
416 417
417 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 418 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
418 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 419 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
419 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 420 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
420 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 421 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
421 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 422 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
422 423
423 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 424 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
424 QString msg; 425 QString msg;
425 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 426 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
426 msg.replace(QRegExp(":"),"\n"); 427 msg.replace(QRegExp(":"),"\n");
427 QMessageBox::message(tr("Note"),msg); 428 QMessageBox::message(tr("Note"),msg);
428 }
429 } else {
430 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
431 } 429 }
432 ProgressBar->reset(); 430 } else {
433 nullifyCallBack(); 431 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
434 it.current()->setSelected(FALSE); 432 }
435 } //end currentSelected 433 ProgressBar->reset();
436 } 434 nullifyCallBack();
437 TabWidget->setCurrentPage(1); 435 it.current()->setSelected(FALSE);
438 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 436 } //end currentSelected
439 QCopEnvelope ( "QPE/System", "notBusy()" ); 437 }
438 TabWidget->setCurrentPage(1);
439 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
440 QCopEnvelope ( "QPE/System", "notBusy()" );
440} 441}
441 442
442void OpieFtp::nullifyCallBack() 443void OpieFtp::nullifyCallBack()
443{ 444{
444 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 445 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
445 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 446 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
446 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 447 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
447 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 448 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
448} 449}
449 450
450void OpieFtp::remoteDownload() 451void OpieFtp::remoteDownload()
451{ 452{
452// qApp->processEvents(); 453// qApp->processEvents();
453 int fsz; 454 int fsz;
454 QCopEnvelope ( "QPE/System", "busy()" ); 455 QCopEnvelope ( "QPE/System", "busy()" );
455 456
456 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 457 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
457 QListViewItemIterator it( Remote_View ); 458 QListViewItemIterator it( Remote_View );
458 for ( ; it.current(); ++it ) { 459 for ( ; it.current(); ++it ) {
459 if ( it.current()->isSelected() ) { 460 if ( it.current()->isSelected() ) {
460 QString strItem = it.current()->text(0); 461 QString strItem = it.current()->text(0);
461// strItem=strItem.right(strItem.length()-1); 462// strItem=strItem.right(strItem.length()-1);
462 QString localFile = currentDir.canonicalPath(); 463 QString localFile = currentDir.canonicalPath();
463 if(localFile.right(1).find("/",0,TRUE) == -1) 464 if(localFile.right(1).find("/",0,TRUE) == -1)
464 localFile += "/"; 465 localFile += "/";
465 localFile += strItem; 466 localFile += strItem;
466// QString localFile = currentDir.canonicalPath()+"/"+strItem; 467// QString localFile = currentDir.canonicalPath()+"/"+strItem;
467 QString remoteFile= currentRemoteDir+strItem; 468 QString remoteFile= currentRemoteDir+strItem;
468 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 469 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
469 fsz = 0; 470 fsz = 0;
470 QString temp; 471 QString temp;
471 temp.sprintf( remoteFile+" "+" %dkb", fsz); 472 temp.sprintf( remoteFile+" "+" %dkb", fsz);
472 473
473 ProgressBar->setTotalSteps(fsz); 474 ProgressBar->setTotalSteps(fsz);
474 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 475 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
475 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 476 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
476 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 477 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
477 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 478 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
478 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 479 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
479 480
480 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 481 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
481 QString msg; 482 QString msg;
482 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 483 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
483 msg.replace(QRegExp(":"),"\n"); 484 msg.replace(QRegExp(":"),"\n");
484 QMessageBox::message(tr("Note"),msg); 485 QMessageBox::message(tr("Note"),msg);
485 } 486 }
486 ProgressBar->reset(); 487 ProgressBar->reset();
487 nullifyCallBack(); 488 nullifyCallBack();
488 it.current()->setSelected(FALSE); 489 it.current()->setSelected(FALSE);
489 } 490 }
490 } 491 }
491 TabWidget->setCurrentPage(0); 492 TabWidget->setCurrentPage(0);
492 populateLocalView(); 493 populateLocalView();
493 QCopEnvelope ( "QPE/System", "notBusy()" ); 494 QCopEnvelope ( "QPE/System", "notBusy()" );
494} 495}
495 496
496bool OpieFtp::remoteDirList(const QString &dir) 497bool OpieFtp::remoteDirList(const QString &dir)
497{ 498{
498 QString tmp = QDir::homeDirPath(); 499 QString tmp = QDir::homeDirPath();
499 if(tmp.right(1) != "/") 500 if(tmp.right(1) != "/")
500 tmp+="/._temp"; 501 tmp+="/._temp";
501 else 502 else
502 tmp+="._temp"; 503 tmp+="._temp";
503// qDebug("Listing remote dir "+tmp); 504// qDebug("Listing remote dir "+tmp);
504 QCopEnvelope ( "QPE/System", "busy()" ); 505 QCopEnvelope ( "QPE/System", "busy()" );
505 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 506 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
506 QString msg; 507 QString msg;
507 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 508 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
508 msg.replace(QRegExp(":"),"\n"); 509 msg.replace(QRegExp(":"),"\n");
509 QMessageBox::message(tr("Note"),msg); 510 QMessageBox::message(tr("Note"),msg);
510 return false; 511 return false;
511 } 512 }
512 populateRemoteView() ; 513 populateRemoteView() ;
513 QCopEnvelope ( "QPE/System", "notBusy()" ); 514 QCopEnvelope ( "QPE/System", "notBusy()" );
514 return true; 515 return true;
515} 516}
516 517
517bool OpieFtp::remoteChDir(const QString &dir) 518bool OpieFtp::remoteChDir(const QString &dir)
518{ 519{
519 QCopEnvelope ( "QPE/System", "busy()" ); 520 QCopEnvelope ( "QPE/System", "busy()" );
520 if (!FtpChdir( dir.latin1(), conn )) { 521 if (!FtpChdir( dir.latin1(), conn )) {
521 QString msg; 522 QString msg;
522 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 523 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
523 msg.replace(QRegExp(":"),"\n"); 524 msg.replace(QRegExp(":"),"\n");
524 QMessageBox::message(tr("Note"),msg); 525 QMessageBox::message(tr("Note"),msg);
525 qDebug(msg); 526 qDebug(msg);
526 QCopEnvelope ( "QPE/System", "notBusy()" ); 527 QCopEnvelope ( "QPE/System", "notBusy()" );
527 return FALSE; 528 return FALSE;
528 } 529 }
529 QCopEnvelope ( "QPE/System", "notBusy()" ); 530 QCopEnvelope ( "QPE/System", "notBusy()" );
530 return TRUE; 531 return TRUE;
531} 532}
532 533
533void OpieFtp::populateLocalView() 534void OpieFtp::populateLocalView()
534{ 535{
535 Local_View->clear(); 536 Local_View->clear();
536 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 537 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
537 currentDir.setMatchAllDirs(TRUE); 538 currentDir.setMatchAllDirs(TRUE);
538 currentDir.setNameFilter(filterStr); 539 currentDir.setNameFilter(filterStr);
539 QString fileL, fileS, fileDate; 540 QString fileL, fileS, fileDate;
540 bool isDir=FALSE; 541 bool isDir=FALSE;
541 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 542 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
542 QFileInfoListIterator it(*list); 543 QFileInfoListIterator it(*list);
543 QFileInfo *fi; 544 QFileInfo *fi;
544 while ( (fi=it.current()) ) { 545 while ( (fi=it.current()) ) {
545 if (fi->isSymLink() ){ 546 if (fi->isSymLink() ){
546 QString symLink=fi->readLink(); 547 QString symLink=fi->readLink();
547// qDebug("Symlink detected "+symLink); 548// qDebug("Symlink detected "+symLink);
548 QFileInfo sym( symLink); 549 QFileInfo sym( symLink);
549 fileS.sprintf( "%10li", sym.size() ); 550 fileS.sprintf( "%10li", sym.size() );
550 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 551 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
551 fileDate = sym.lastModified().toString(); 552 fileDate = sym.lastModified().toString();
552 } else { 553 } else {
553// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 554// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
554 fileS.sprintf( "%10li", fi->size() ); 555 fileS.sprintf( "%10li", fi->size() );
555 fileL.sprintf( "%s",fi->fileName().data() ); 556 fileL.sprintf( "%s",fi->fileName().data() );
556 fileDate= fi->lastModified().toString(); 557 fileDate= fi->lastModified().toString();
557 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 558 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
558 fileL+="/"; 559 fileL+="/";
559 isDir=TRUE; 560 isDir=TRUE;
560// qDebug( fileL); 561// qDebug( fileL);
561 } 562 }
562 } 563 }
563 if(fileL !="./" && fi->exists()) { 564 if(fileL !="./" && fi->exists()) {
564 item= new QListViewItem( Local_View,fileL,fileS , fileDate); 565 item= new QListViewItem( Local_View,fileL,fileS , fileDate);
565 QPixmap pm; 566 QPixmap pm;
566 567
567 if(isDir || fileL.find("/",0,TRUE) != -1) { 568 if(isDir || fileL.find("/",0,TRUE) != -1) {
568 if( !QDir( fi->filePath() ).isReadable()) 569 if( !QDir( fi->filePath() ).isReadable())
569 pm = Resource::loadPixmap( "lockedfolder" ); 570 pm = Resource::loadPixmap( "lockedfolder" );
570 else 571 else
571 pm= Resource::loadPixmap( "folder" ); 572 pm= Resource::loadPixmap( "folder" );
572 item->setPixmap( 0,pm ); 573 item->setPixmap( 0,pm );
573 } else { 574 } else {
574 if( !fi->isReadable() ) 575 if( !fi->isReadable() )
575 pm = Resource::loadPixmap( "locked" ); 576 pm = Resource::loadPixmap( "locked" );
576 else { 577 else {
577 MimeType mt(fi->filePath()); 578 MimeType mt(fi->filePath());
578 pm=mt.pixmap(); //sets the correct pixmap for mimetype 579 pm=mt.pixmap(); //sets the correct pixmap for mimetype
579 if(pm.isNull()) 580 if(pm.isNull())
580 pm = Resource::loadPixmap( "UnknownDocument-14" ); 581 pm = Resource::loadPixmap( "UnknownDocument-14" );
581 item->setPixmap( 0,pm); 582 item->setPixmap( 0,pm);
582 } 583 }
583 } 584 }
584 if( fileL.find("->",0,TRUE) != -1) { 585 if( fileL.find("->",0,TRUE) != -1) {
585 // overlay link image 586 // overlay link image
586 pm= Resource::loadPixmap( "folder" ); 587 pm= Resource::loadPixmap( "folder" );
587 QPixmap lnk = Resource::loadPixmap( "symlink" ); 588 QPixmap lnk = Resource::loadPixmap( "symlink" );
588 QPainter painter( &pm ); 589 QPainter painter( &pm );
589 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 590 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
590 pm.setMask( pm.createHeuristicMask( FALSE ) ); 591 pm.setMask( pm.createHeuristicMask( FALSE ) );
591 item->setPixmap( 0, pm); 592 item->setPixmap( 0, pm);
592 } 593 }
593 } 594 }
594 isDir=FALSE; 595 isDir=FALSE;
595 ++it; 596 ++it;
596 } 597 }
597 Local_View->setSorting( 3,FALSE); 598 Local_View->setSorting( 3,FALSE);
598 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 599 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
599 fillCombo( (const QString &)currentDir); 600 fillCombo( (const QString &)currentDir);
600} 601}
601 602
602bool OpieFtp::populateRemoteView( ) 603bool OpieFtp::populateRemoteView( )
603{ 604{
604// qDebug("populate remoteview"); 605// qDebug("populate remoteview");
605 QString sfile=QDir::homeDirPath(); 606 QString sfile=QDir::homeDirPath();
606 if(sfile.right(1) != "/") 607 if(sfile.right(1) != "/")
607 sfile+="/._temp"; 608 sfile+="/._temp";
608 else 609 else
609 sfile+="._temp"; 610 sfile+="._temp";
610 QFile file( sfile); 611 QFile file( sfile);
611 Remote_View->clear(); 612 Remote_View->clear();
612 QString s, File_Name; 613 QString s, File_Name;
613 QListViewItem *itemDir=NULL, *itemFile=NULL; 614 QListViewItem *itemDir=NULL, *itemFile=NULL;
614 QString fileL, fileS, fileDate; 615 QString fileL, fileS, fileDate;
615 if ( file.open(IO_ReadOnly)) { 616 if ( file.open(IO_ReadOnly)) {
616 QTextStream t( &file ); // use a text stream 617 QTextStream t( &file ); // use a text stream
617 while ( !t.eof()) { 618 while ( !t.eof()) {
618 s = t.readLine(); 619 s = t.readLine();
619 fileL = s.right(s.length()-55); 620 fileL = s.right(s.length()-55);
620 fileL = fileL.stripWhiteSpace(); 621 fileL = fileL.stripWhiteSpace();
621 if(s.left(1) == "d") 622 if(s.left(1) == "d")
@@ -687,206 +688,202 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
687 strItem=""; 688 strItem="";
688 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 689 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
689 } 690 }
690 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 691 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
691 qDebug("trying directory"); 692 qDebug("trying directory");
692 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 693 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
693 currentRemoteDir = oldRemoteCurrentDir; 694 currentRemoteDir = oldRemoteCurrentDir;
694 strItem=""; 695 strItem="";
695 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 696 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
696 697
697 } else { 698 } else {
698 currentRemoteDir = currentRemoteDir+strItem; 699 currentRemoteDir = currentRemoteDir+strItem;
699 } 700 }
700 } else { 701 } else {
701 qDebug("download "+strItem); 702 qDebug("download "+strItem);
702 } 703 }
703 } 704 }
704 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 705 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
705 if(currentRemoteDir.right(1) !="/") 706 if(currentRemoteDir.right(1) !="/")
706 currentRemoteDir +="/"; 707 currentRemoteDir +="/";
707 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 708 currentPathCombo->lineEdit()->setText( currentRemoteDir );
708 fillRemoteCombo( (const QString &)currentDir); 709 fillRemoteCombo( (const QString &)currentDir);
709 QCopEnvelope ( "QPE/System", "notBusy()" ); 710 QCopEnvelope ( "QPE/System", "notBusy()" );
710 } 711 }
711} 712}
712 713
713void OpieFtp::localListClicked(QListViewItem *selectedItem) 714void OpieFtp::localListClicked(QListViewItem *selectedItem)
714{ 715{
715 if(selectedItem!= NULL) { 716 if(selectedItem!= NULL) {
716 717
717 QString strItem=selectedItem->text(0); 718 QString strItem=selectedItem->text(0);
718 QString strSize=selectedItem->text(1); 719 QString strSize=selectedItem->text(1);
719 strSize=strSize.stripWhiteSpace(); 720 strSize=strSize.stripWhiteSpace();
720 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 721 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
721 // is symlink 722 // is symlink
722 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 723 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
723 if(QDir(strItem2).exists() ) { 724 if(QDir(strItem2).exists() ) {
724 currentDir.cd(strItem2, TRUE); 725 currentDir.cd(strItem2, TRUE);
725 populateLocalView(); 726 populateLocalView();
726 } 727 }
727 } else { // not a symlink 728 } else { // not a symlink
728 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 729 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
729 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 730 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
730 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 731 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
731 currentDir.cd(strItem,FALSE); 732 currentDir.cd(strItem,FALSE);
732 populateLocalView(); 733 populateLocalView();
733 } else { 734 } else {
734 currentDir.cdUp(); 735 currentDir.cdUp();
735 populateLocalView(); 736 populateLocalView();
736 } 737 }
737 if(QDir(strItem).exists()){ 738 if(QDir(strItem).exists()){
738 currentDir.cd(strItem, TRUE); 739 currentDir.cd(strItem, TRUE);
739 populateLocalView(); 740 populateLocalView();
740 } 741 }
741 } else { 742 } else {
742 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 743 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
743 if( QFile::exists(strItem ) ) { 744 if( QFile::exists(strItem ) ) {
744 // qDebug("upload "+strItem); 745 // qDebug("upload "+strItem);
745 } 746 }
746 } //end not symlink 747 } //end not symlink
747 chdir(strItem.latin1()); 748 chdir(strItem.latin1());
748 } 749 }
749 } 750 }
750} 751}
751 752
752void OpieFtp::doLocalCd() 753void OpieFtp::doLocalCd()
753{ 754{
754 localListClicked( Local_View->currentItem()); 755 localListClicked( Local_View->currentItem());
755} 756}
756 757
757void OpieFtp:: doRemoteCd() 758void OpieFtp:: doRemoteCd()
758{ 759{
759 remoteListClicked( Remote_View->currentItem()); 760 remoteListClicked( Remote_View->currentItem());
760 761
761} 762}
762 763
763void OpieFtp::showHidden() 764void OpieFtp::showHidden()
764{ 765{
765 if (!b) { 766 if (!b) {
766 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 767 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
767 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 768 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
768// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 769// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
769 b=TRUE; 770 b=TRUE;
770 771
771 } else { 772 } else {
772 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 773 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
773 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 774 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
774// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 775// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
775 b=FALSE; 776 b=FALSE;
776 } 777 }
777 populateLocalView(); 778 populateLocalView();
778} 779}
779 780
780void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 781void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
781{ 782{
782// if(item) 783// if(item)
783if (mouse == 2) { 784 if (mouse == 2) {
784 showLocalMenu(item); 785 showLocalMenu(item);
785 } 786 }
786} 787}
787 788
788void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 789void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
789{ 790{
790 switch (mouse) { 791 if(mouse == 2) {
791 case 1: 792 showRemoteMenu(item);
792 break; 793 }
793 case 2:
794 showRemoteMenu(item);
795 break;
796 };
797} 794}
798 795
799void OpieFtp::showRemoteMenu(QListViewItem * item) 796void OpieFtp::showRemoteMenu(QListViewItem * item)
800{ 797{
801 QPopupMenu m;// = new QPopupMenu( Local_View ); 798 QPopupMenu m;// = new QPopupMenu( Local_View );
802 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 799 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
803 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 800 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
804 else 801 else
805 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 802 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
806 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 803 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
807 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 804 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
808 m.insertSeparator(); 805 m.insertSeparator();
809 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 806 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
810 m.exec( QCursor::pos() ); 807 m.exec( QCursor::pos() );
811} 808}
812 809
813void OpieFtp::showLocalMenu(QListViewItem * item) 810void OpieFtp::showLocalMenu(QListViewItem * item)
814{ 811{
815 812
816 QPopupMenu m; 813 QPopupMenu m;
817 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 814 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
818 m.insertSeparator(); 815 m.insertSeparator();
819 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 816 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
820 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 817 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
821 else 818 else
822 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 819 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
823 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 820 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
824 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 821 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
825 m.insertSeparator(); 822 m.insertSeparator();
826 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 823 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
827 m.setCheckable(TRUE); 824 m.setCheckable(TRUE);
828 if (b) 825 if (b)
829 m.setItemChecked(m.idAt(0),TRUE); 826 m.setItemChecked(m.idAt(0),TRUE);
830 else 827 else
831 m.setItemChecked(m.idAt(0),FALSE); 828 m.setItemChecked(m.idAt(0),FALSE);
832 829
833 m.exec( QCursor::pos() ); 830 m.exec( QCursor::pos() );
834} 831}
835 832
836void OpieFtp::localMakDir() 833void OpieFtp::localMakDir()
837{ 834{
838 InputDialog *fileDlg; 835 InputDialog *fileDlg;
839 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 836 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
840 fileDlg->exec(); 837 fileDlg->exec();
841 if( fileDlg->result() == 1 ) { 838 if( fileDlg->result() == 1 ) {
842 QString filename = fileDlg->LineEdit1->text(); 839 QString filename = fileDlg->LineEdit1->text();
843 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 840 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
844 } 841 }
845 populateLocalView(); 842 populateLocalView();
846} 843}
847 844
848void OpieFtp::localDelete() 845void OpieFtp::localDelete()
849{ 846{
850 QString f = Local_View->currentItem()->text(0); 847 QString f = Local_View->currentItem()->text(0);
851 if(QDir(f).exists() ) { 848 if(QDir(f).exists() ) {
852 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 849 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
853 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 850 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
854 case 0: { 851 case 0: {
855 f=currentDir.canonicalPath()+"/"+f; 852 f=currentDir.canonicalPath()+"/"+f;
856 QString cmd="rmdir "+f; 853 QString cmd="rmdir "+f;
857 system( cmd.latin1()); 854 system( cmd.latin1());
858 populateLocalView(); 855 populateLocalView();
859 } 856 }
860 break; 857 break;
861 case 1: 858 case 1:
862 // exit 859 // exit
863 break; 860 break;
864 }; 861 };
865 862
866 } else { 863 } else {
867 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 864 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
868 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 865 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
869 case 0: { 866 case 0: {
870 f=currentDir.canonicalPath()+"/"+f; 867 f=currentDir.canonicalPath()+"/"+f;
871 QString cmd="rm "+f; 868 QString cmd="rm "+f;
872 system( cmd.latin1()); 869 system( cmd.latin1());
873 populateLocalView(); 870 populateLocalView();
874 } 871 }
875 break; 872 break;
876 case 1: 873 case 1:
877 // exit 874 // exit
878 break; 875 break;
879 }; 876 };
880 } 877 }
881} 878}
882 879
883void OpieFtp::remoteMakDir() 880void OpieFtp::remoteMakDir()
884{ 881{
885 InputDialog *fileDlg; 882 InputDialog *fileDlg;
886 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 883 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
887 fileDlg->exec(); 884 fileDlg->exec();
888 if( fileDlg->result() == 1 ) { 885 if( fileDlg->result() == 1 ) {
889 QString filename = fileDlg->LineEdit1->text();//+".playlist"; 886 QString filename = fileDlg->LineEdit1->text();//+".playlist";
890 QString tmp=currentRemoteDir+filename; 887 QString tmp=currentRemoteDir+filename;
891 QCopEnvelope ( "QPE/System", "busy()" ); 888 QCopEnvelope ( "QPE/System", "busy()" );
892 if(FtpMkdir( tmp.latin1(), conn) == 0) { 889 if(FtpMkdir( tmp.latin1(), conn) == 0) {