summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-28 13:39:25 (UTC)
committer llornkcor <llornkcor>2002-03-28 13:39:25 (UTC)
commitcd6f89bfab7e609705e8013d50413e1cae929d8a (patch) (unidiff)
tree58de5a24abe2dc9640aa92fdb9db4512ff3c5c01
parentfea05ec0241de3f3476696584e4a11dab045f91e (diff)
downloadopie-cd6f89bfab7e609705e8013d50413e1cae929d8a.zip
opie-cd6f89bfab7e609705e8013d50413e1cae929d8a.tar.gz
opie-cd6f89bfab7e609705e8013d50413e1cae929d8a.tar.bz2
fixed somthing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index efcaf84..36de842 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,467 +1,455 @@
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#include <qpe/mimetype.h> 24#include <qpe/mimetype.h>
25 25
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtoolbutton.h> 29#include <qtoolbutton.h>
30#include <qdatetime.h> 30#include <qdatetime.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qlistview.h> 36#include <qlistview.h>
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qlabel.h> 38#include <qlabel.h>
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
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 164
165 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 165 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
166 166
167 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 167 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
168 this,SLOT( remoteListClicked(QListViewItem *)) ); 168 this,SLOT( remoteListClicked(QListViewItem *)) );
169 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 169 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
170 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 170 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
171 171
172 tabLayout_2->addWidget( Remote_View, 0, 0 ); 172 tabLayout_2->addWidget( Remote_View, 0, 0 );
173 173
174 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 174 TabWidget->insertTab( tab_2, tr( "Remote" ) );
175 175
176 tab_3 = new QWidget( TabWidget, "tab_3" ); 176 tab_3 = new QWidget( TabWidget, "tab_3" );
177 tabLayout_3 = new QGridLayout( tab_3 ); 177 tabLayout_3 = new QGridLayout( tab_3 );
178 tabLayout_3->setSpacing( 2); 178 tabLayout_3->setSpacing( 2);
179 tabLayout_3->setMargin( 2); 179 tabLayout_3->setMargin( 2);
180 180
181 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 181 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
182 TextLabel1->setText( tr( "Username" ) ); 182 TextLabel1->setText( tr( "Username" ) );
183 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 183 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
184 184
185 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 185 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
186 UsernameComboBox->setEditable(TRUE); 186 UsernameComboBox->setEditable(TRUE);
187 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 187 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
188 188
189 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 189 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
190 TextLabel2->setText( tr( "Password" ) ); 190 TextLabel2->setText( tr( "Password" ) );
191 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 191 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
192 192
193 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 193 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
194 PasswordEdit->setEchoMode(QLineEdit::Password); 194 PasswordEdit->setEchoMode(QLineEdit::Password);
195 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 195 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
196 196
197 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 197 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
198 TextLabel3->setText( tr( "Remote server" ) ); 198 TextLabel3->setText( tr( "Remote server" ) );
199 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 199 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
200 200
201 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 201 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
202 ServerComboBox->setEditable(TRUE); 202 ServerComboBox->setEditable(TRUE);
203 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 203 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
204 204
205 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); 205 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
206 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); 206 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) ));
207 207
208 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 208 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
209 TextLabel5->setText( tr( "Remote path" ) ); 209 TextLabel5->setText( tr( "Remote path" ) );
210 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 210 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
211 211
212 212
213 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 213 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
214 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 214 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
215 215
216 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 216 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
217 TextLabel4->setText( tr( "Port" ) ); 217 TextLabel4->setText( tr( "Port" ) );
218 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 218 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
219 219
220 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 220 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
221 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 221 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
222 PortSpinBox->setMaxValue(32786); 222 PortSpinBox->setMaxValue(32786);
223 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 223 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
224 224
225 QPushButton *deleteServerBtn; 225 QPushButton *deleteServerBtn;
226 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); 226 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" );
227 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); 227 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
228 228
229 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 229 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
230 230
231 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); 231 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
232 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); 232 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
233 connectServerBtn->setToggleButton(TRUE); 233 connectServerBtn->setToggleButton(TRUE);
234 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); 234 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
235 235
236 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 236 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
237 tabLayout_3->addItem( spacer, 5, 0 ); 237 tabLayout_3->addItem( spacer, 5, 0 );
238 238
239 TabWidget->insertTab( tab_3, tr( "Config" ) ); 239 TabWidget->insertTab( tab_3, tr( "Config" ) );
240 240
241 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 241 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
242 this,SLOT(tabChanged(QWidget*))); 242 this,SLOT(tabChanged(QWidget*)));
243 243
244 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 244 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
245 currentDir.setPath( QDir::currentDirPath()); 245 currentDir.setPath( QDir::currentDirPath());
246// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 246// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
247 247
248 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); 248 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
249 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 ); 249 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 );
250 currentPathCombo->setEditable(TRUE); 250 currentPathCombo->setEditable(TRUE);
251 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 251 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
252 252
253 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 253 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
254 this, SLOT( currentPathComboActivated( const QString & ) ) ); 254 this, SLOT( currentPathComboActivated( const QString & ) ) );
255 255
256 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 256 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
257 this,SLOT(currentPathComboChanged())); 257 this,SLOT(currentPathComboChanged()));
258 258
259 ProgressBar = new QProgressBar( this, "ProgressBar" ); 259 ProgressBar = new QProgressBar( this, "ProgressBar" );
260 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 260 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
261 261
262// fillCombos(); 262// fillCombos();
263 263
264#ifdef DEVELOPERS_VERSION
265 ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
266 UsernameComboBox->lineEdit()->setText("root");
267 PortSpinBox->setValue( 4242);
268 remotePath->setText( currentRemoteDir = "/");
269// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
270// UsernameComboBox->lineEdit()->setText("llornkcor");
271// PortSpinBox->setValue( 21);
272// remotePath->setText( currentRemoteDir = "/home/llornkcor");
273 PasswordEdit->setText( tr( "" ) );
274#endif
275
276 filterStr="*"; 264 filterStr="*";
277 b=FALSE; 265 b=FALSE;
278 populateLocalView(); 266 populateLocalView();
279 readConfig(); 267 readConfig();
280 ServerComboBox->setCurrentItem(currentServerConfig); 268 ServerComboBox->setCurrentItem(currentServerConfig);
281 TabWidget->setCurrentPage(2); 269 TabWidget->setCurrentPage(2);
282} 270}
283 271
284OpieFtp::~OpieFtp() 272OpieFtp::~OpieFtp()
285{ 273{
286} 274}
287 275
288void OpieFtp::cleanUp() 276void OpieFtp::cleanUp()
289{ 277{
290 if(conn) 278 if(conn)
291 FtpQuit(conn); 279 FtpQuit(conn);
292 QString sfile=QDir::homeDirPath(); 280 QString sfile=QDir::homeDirPath();
293 if(sfile.right(1) != "/") 281 if(sfile.right(1) != "/")
294 sfile+="/._temp"; 282 sfile+="/._temp";
295 else 283 else
296 sfile+="._temp"; 284 sfile+="._temp";
297 QFile file( sfile); 285 QFile file( sfile);
298 if(file.exists()) 286 if(file.exists())
299 file.remove(); 287 file.remove();
300} 288}
301 289
302void OpieFtp::tabChanged(QWidget *w) 290void OpieFtp::tabChanged(QWidget *w)
303{ 291{
304 if (TabWidget->currentPageIndex() == 0) { 292 if (TabWidget->currentPageIndex() == 0) {
305 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 293 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
306 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 294 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
307 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 295 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
308 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 296 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
309 } 297 }
310 if (TabWidget->currentPageIndex() == 1) { 298 if (TabWidget->currentPageIndex() == 1) {
311 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 299 currentPathCombo->lineEdit()->setText( currentRemoteDir );
312 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 300 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
313 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 301 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
314 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 302 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
315 } 303 }
316 if (TabWidget->currentPageIndex() == 2) { 304 if (TabWidget->currentPageIndex() == 2) {
317 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 305 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
318 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 306 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
319 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 307 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
320 } 308 }
321} 309}
322 310
323void OpieFtp::newConnection() 311void OpieFtp::newConnection()
324{ 312{
325 UsernameComboBox->lineEdit()->setText(""); 313 UsernameComboBox->lineEdit()->setText("");
326 PasswordEdit->setText( "" ); 314 PasswordEdit->setText( "" );
327 ServerComboBox->lineEdit()->setText( ""); 315 ServerComboBox->lineEdit()->setText( "");
328 remotePath->setText( currentRemoteDir = "/"); 316 remotePath->setText( currentRemoteDir = "/");
329 PortSpinBox->setValue( 21); 317 PortSpinBox->setValue( 21);
330 TabWidget->setCurrentPage(2); 318 TabWidget->setCurrentPage(2);
331 currentServerConfig = -1; 319 currentServerConfig = -1;
332} 320}
333 321
334void OpieFtp::serverComboEdited(const QString & edit) { 322void OpieFtp::serverComboEdited(const QString & edit) {
335 if( !edit.isEmpty() ) { 323 if( !edit.isEmpty() ) {
336 currentServerConfig = -1; 324 currentServerConfig = -1;
337// qDebug("comboedited"); 325// qDebug("comboedited");
338 } 326 }
339} 327}
340 328
341void OpieFtp::connectorBtnToggled(bool On) 329void OpieFtp::connectorBtnToggled(bool On)
342{ 330{
343 if(On) { 331 if(On) {
344 connector(); 332 connector();
345 } else { 333 } else {
346 disConnector(); 334 disConnector();
347 } 335 }
348 336
349} 337}
350 338
351void OpieFtp::connector() 339void OpieFtp::connector()
352{ 340{
353 QCopEnvelope ( "QPE/System", "busy()" ); 341 QCopEnvelope ( "QPE/System", "busy()" );
354// qApp->processEvents(); 342// qApp->processEvents();
355 currentRemoteDir=remotePath->text(); 343 currentRemoteDir=remotePath->text();
356 if(ServerComboBox->currentText().isEmpty()) { 344 if(ServerComboBox->currentText().isEmpty()) {
357 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 345 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
358 TabWidget->setCurrentPage(2); 346 TabWidget->setCurrentPage(2);
359 ServerComboBox->setFocus(); 347 ServerComboBox->setFocus();
360 connectServerBtn->setOn(FALSE); 348 connectServerBtn->setOn(FALSE);
361 connectServerBtn->setText( tr("Connect")); 349 connectServerBtn->setText( tr("Connect"));
362 return; 350 return;
363 } 351 }
364 FtpInit(); 352 FtpInit();
365 TabWidget->setCurrentPage(1); 353 TabWidget->setCurrentPage(1);
366 QString ftp_host = ServerComboBox->currentText(); 354 QString ftp_host = ServerComboBox->currentText();
367 QString ftp_user = UsernameComboBox->currentText(); 355 QString ftp_user = UsernameComboBox->currentText();
368 QString ftp_pass = PasswordEdit->text(); 356 QString ftp_pass = PasswordEdit->text();
369 QString port=PortSpinBox->cleanText(); 357 QString port=PortSpinBox->cleanText();
370 port.stripWhiteSpace(); 358 port.stripWhiteSpace();
371 359
372 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 360 if(ftp_host.find("ftp://",0, TRUE) != -1 )
373 ftp_host=ftp_host.right(ftp_host.length()-6); 361 ftp_host=ftp_host.right(ftp_host.length()-6);
374 ftp_host+=":"+port; 362 ftp_host+=":"+port;
375 if (!FtpConnect( ftp_host.latin1(), &conn)) { 363 if (!FtpConnect( ftp_host.latin1(), &conn)) {
376 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 364 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
377 connectServerBtn->setOn(FALSE); 365 connectServerBtn->setOn(FALSE);
378 connectServerBtn->setText( tr("Connect")); 366 connectServerBtn->setText( tr("Connect"));
379 return ; 367 return ;
380 } 368 }
381 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 369 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
382 QString msg; 370 QString msg;
383 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 371 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
384 msg.replace(QRegExp(":"),"\n"); 372 msg.replace(QRegExp(":"),"\n");
385 QMessageBox::message(tr("Note"),msg); 373 QMessageBox::message(tr("Note"),msg);
386 if(conn) 374 if(conn)
387 FtpQuit(conn); 375 FtpQuit(conn);
388 connectServerBtn->setOn(FALSE); 376 connectServerBtn->setOn(FALSE);
389 connectServerBtn->setText( tr("Connect")); 377 connectServerBtn->setText( tr("Connect"));
390 return ; 378 return ;
391 } 379 }
392 remoteDirList("/") ; 380 remoteDirList("/") ;
393 setCaption(ftp_host); 381 setCaption(ftp_host);
394 writeConfig(); 382 writeConfig();
395 connectServerBtn->setText( tr("Disconnect")); 383 connectServerBtn->setText( tr("Disconnect"));
396 QCopEnvelope ( "QPE/System", "notBusy()" ); 384 QCopEnvelope ( "QPE/System", "notBusy()" );
397} 385}
398 386
399void OpieFtp::disConnector() 387void OpieFtp::disConnector()
400{ 388{
401 if(conn) 389 if(conn)
402 FtpQuit(conn); 390 FtpQuit(conn);
403 setCaption("OpieFtp"); 391 setCaption("OpieFtp");
404 currentRemoteDir="/"; 392 currentRemoteDir="/";
405 Remote_View->clear(); 393 Remote_View->clear();
406 connectServerBtn->setText( tr("Connect")); 394 connectServerBtn->setText( tr("Connect"));
407 connectServerBtn->setOn(FALSE); 395 connectServerBtn->setOn(FALSE);
408 396
409} 397}
410 398
411void OpieFtp::localUpload() 399void OpieFtp::localUpload()
412{ 400{
413 int fsz; 401 int fsz;
414 QCopEnvelope ( "QPE/System", "busy()" ); 402 QCopEnvelope ( "QPE/System", "busy()" );
415// qApp->processEvents(); 403// qApp->processEvents();
416 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 404 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
417 QListViewItemIterator it( Local_View ); 405 QListViewItemIterator it( Local_View );
418 for ( ; it.current(); ++it ) { 406 for ( ; it.current(); ++it ) {
419 if ( it.current()->isSelected() ) { 407 if ( it.current()->isSelected() ) {
420 QString strItem = it.current()->text(0); 408 QString strItem = it.current()->text(0);
421 QString localFile = currentDir.canonicalPath()+"/"+strItem; 409 QString localFile = currentDir.canonicalPath()+"/"+strItem;
422 QString remoteFile= currentRemoteDir+strItem; 410 QString remoteFile= currentRemoteDir+strItem;
423 QFileInfo fi(localFile); 411 QFileInfo fi(localFile);
424 if( !fi.isDir()) { 412 if( !fi.isDir()) {
425 fsz=fi.size(); 413 fsz=fi.size();
426 ProgressBar->setTotalSteps(fsz); 414 ProgressBar->setTotalSteps(fsz);
427 415
428 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 416 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
429 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 417 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
430 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 418 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
431 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 419 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
432 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 420 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
433 421
434 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 422 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
435 QString msg; 423 QString msg;
436 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 424 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
437 msg.replace(QRegExp(":"),"\n"); 425 msg.replace(QRegExp(":"),"\n");
438 QMessageBox::message(tr("Note"),msg); 426 QMessageBox::message(tr("Note"),msg);
439 } 427 }
440 } else { 428 } else {
441 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 429 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
442 } 430 }
443 ProgressBar->reset(); 431 ProgressBar->reset();
444 nullifyCallBack(); 432 nullifyCallBack();
445 it.current()->setSelected(FALSE); 433 it.current()->setSelected(FALSE);
446 } //end currentSelected 434 } //end currentSelected
447 } 435 }
448 TabWidget->setCurrentPage(1); 436 TabWidget->setCurrentPage(1);
449 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 437 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
450 QCopEnvelope ( "QPE/System", "notBusy()" ); 438 QCopEnvelope ( "QPE/System", "notBusy()" );
451} 439}
452 440
453void OpieFtp::nullifyCallBack() 441void OpieFtp::nullifyCallBack()
454{ 442{
455 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 443 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
456 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 444 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
457 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 445 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
458 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 446 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
459} 447}
460 448
461void OpieFtp::remoteDownload() 449void OpieFtp::remoteDownload()
462{ 450{
463// qApp->processEvents(); 451// qApp->processEvents();
464 int fsz; 452 int fsz;
465 QCopEnvelope ( "QPE/System", "busy()" ); 453 QCopEnvelope ( "QPE/System", "busy()" );
466 454
467 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 455 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
@@ -534,487 +522,487 @@ bool OpieFtp::remoteChDir(const QString &dir)
534 msg.replace(QRegExp(":"),"\n"); 522 msg.replace(QRegExp(":"),"\n");
535 QMessageBox::message(tr("Note"),msg); 523 QMessageBox::message(tr("Note"),msg);
536 qDebug(msg); 524 qDebug(msg);
537 QCopEnvelope ( "QPE/System", "notBusy()" ); 525 QCopEnvelope ( "QPE/System", "notBusy()" );
538 return FALSE; 526 return FALSE;
539 } 527 }
540 QCopEnvelope ( "QPE/System", "notBusy()" ); 528 QCopEnvelope ( "QPE/System", "notBusy()" );
541 return TRUE; 529 return TRUE;
542} 530}
543 531
544void OpieFtp::populateLocalView() 532void OpieFtp::populateLocalView()
545{ 533{
546 Local_View->clear(); 534 Local_View->clear();
547 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 535 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
548 currentDir.setMatchAllDirs(TRUE); 536 currentDir.setMatchAllDirs(TRUE);
549 currentDir.setNameFilter(filterStr); 537 currentDir.setNameFilter(filterStr);
550 QString fileL, fileS, fileDate; 538 QString fileL, fileS, fileDate;
551 bool isDir=FALSE; 539 bool isDir=FALSE;
552 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 540 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
553 QFileInfoListIterator it(*list); 541 QFileInfoListIterator it(*list);
554 QFileInfo *fi; 542 QFileInfo *fi;
555 while ( (fi=it.current()) ) { 543 while ( (fi=it.current()) ) {
556 if (fi->isSymLink() ){ 544 if (fi->isSymLink() ){
557 QString symLink=fi->readLink(); 545 QString symLink=fi->readLink();
558// qDebug("Symlink detected "+symLink); 546// qDebug("Symlink detected "+symLink);
559 QFileInfo sym( symLink); 547 QFileInfo sym( symLink);
560 fileS.sprintf( "%10li", sym.size() ); 548 fileS.sprintf( "%10li", sym.size() );
561 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 549 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
562 fileDate = sym.lastModified().toString(); 550 fileDate = sym.lastModified().toString();
563 } else { 551 } else {
564// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 552// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
565 fileS.sprintf( "%10li", fi->size() ); 553 fileS.sprintf( "%10li", fi->size() );
566 fileL.sprintf( "%s",fi->fileName().data() ); 554 fileL.sprintf( "%s",fi->fileName().data() );
567 fileDate= fi->lastModified().toString(); 555 fileDate= fi->lastModified().toString();
568 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 556 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
569 fileL+="/"; 557 fileL+="/";
570 isDir=TRUE; 558 isDir=TRUE;
571// qDebug( fileL); 559// qDebug( fileL);
572 } 560 }
573 } 561 }
574 if(fileL !="./" && fi->exists()) { 562 if(fileL !="./" && fi->exists()) {
575 item= new QListViewItem( Local_View,fileL,fileS , fileDate); 563 item= new QListViewItem( Local_View,fileL,fileS , fileDate);
576 QPixmap pm; 564 QPixmap pm;
577 565
578 if(isDir || fileL.find("/",0,TRUE) != -1) { 566 if(isDir || fileL.find("/",0,TRUE) != -1) {
579 if( !QDir( fi->filePath() ).isReadable()) 567 if( !QDir( fi->filePath() ).isReadable())
580 pm = Resource::loadPixmap( "lockedfolder" ); 568 pm = Resource::loadPixmap( "lockedfolder" );
581 else 569 else
582 pm= Resource::loadPixmap( "folder" ); 570 pm= Resource::loadPixmap( "folder" );
583 item->setPixmap( 0,pm ); 571 item->setPixmap( 0,pm );
584 } else { 572 } else {
585 if( !fi->isReadable() ) 573 if( !fi->isReadable() )
586 pm = Resource::loadPixmap( "locked" ); 574 pm = Resource::loadPixmap( "locked" );
587 else { 575 else {
588 MimeType mt(fi->filePath()); 576 MimeType mt(fi->filePath());
589 pm=mt.pixmap(); //sets the correct pixmap for mimetype 577 pm=mt.pixmap(); //sets the correct pixmap for mimetype
590 if(pm.isNull()) 578 if(pm.isNull())
591 pm = Resource::loadPixmap( "UnknownDocument-14" ); 579 pm = Resource::loadPixmap( "UnknownDocument-14" );
592 item->setPixmap( 0,pm); 580 item->setPixmap( 0,pm);
593 } 581 }
594 } 582 }
595 if( fileL.find("->",0,TRUE) != -1) { 583 if( fileL.find("->",0,TRUE) != -1) {
596 // overlay link image 584 // overlay link image
597 pm= Resource::loadPixmap( "folder" ); 585 pm= Resource::loadPixmap( "folder" );
598 QPixmap lnk = Resource::loadPixmap( "symlink" ); 586 QPixmap lnk = Resource::loadPixmap( "symlink" );
599 QPainter painter( &pm ); 587 QPainter painter( &pm );
600 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 588 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
601 pm.setMask( pm.createHeuristicMask( FALSE ) ); 589 pm.setMask( pm.createHeuristicMask( FALSE ) );
602 item->setPixmap( 0, pm); 590 item->setPixmap( 0, pm);
603 } 591 }
604 } 592 }
605 isDir=FALSE; 593 isDir=FALSE;
606 ++it; 594 ++it;
607 } 595 }
608 Local_View->setSorting( 3,FALSE); 596 Local_View->setSorting( 3,FALSE);
609 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 597 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
610 fillCombo( (const QString &)currentDir); 598 fillCombo( (const QString &)currentDir);
611} 599}
612 600
613bool OpieFtp::populateRemoteView( ) 601bool OpieFtp::populateRemoteView( )
614{ 602{
615// qDebug("populate remoteview"); 603// qDebug("populate remoteview");
616 QString sfile=QDir::homeDirPath(); 604 QString sfile=QDir::homeDirPath();
617 if(sfile.right(1) != "/") 605 if(sfile.right(1) != "/")
618 sfile+="/._temp"; 606 sfile+="/._temp";
619 else 607 else
620 sfile+="._temp"; 608 sfile+="._temp";
621 QFile file( sfile); 609 QFile file( sfile);
622 Remote_View->clear(); 610 Remote_View->clear();
623 QString s, File_Name; 611 QString s, File_Name;
624 QListViewItem *itemDir=NULL, *itemFile=NULL; 612 QListViewItem *itemDir=NULL, *itemFile=NULL;
625 QString fileL, fileS, fileDate; 613 QString fileL, fileS, fileDate;
626 if ( file.open(IO_ReadOnly)) { 614 if ( file.open(IO_ReadOnly)) {
627 QTextStream t( &file ); // use a text stream 615 QTextStream t( &file ); // use a text stream
628 while ( !t.eof()) { 616 while ( !t.eof()) {
629 s = t.readLine(); 617 s = t.readLine();
630 fileL = s.right(s.length()-55); 618 fileL = s.right(s.length()-55);
631 fileL = fileL.stripWhiteSpace(); 619 fileL = fileL.stripWhiteSpace();
632 if(s.left(1) == "d") 620 if(s.left(1) == "d")
633 fileL = fileL+"/"; 621 fileL = fileL+"/";
634// fileL = "/"+fileL+"/"; 622// fileL = "/"+fileL+"/";
635 fileS = s.mid( 30, 42-30); 623 fileS = s.mid( 30, 42-30);
636 fileS = fileS.stripWhiteSpace(); 624 fileS = fileS.stripWhiteSpace();
637 fileDate = s.mid( 42, 55-42); 625 fileDate = s.mid( 42, 55-42);
638 fileDate = fileDate.stripWhiteSpace(); 626 fileDate = fileDate.stripWhiteSpace();
639 if(fileL.find("total",0,TRUE) == -1) { 627 if(fileL.find("total",0,TRUE) == -1) {
640 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 628 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
641 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); 629 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d");
642 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 630 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
643// if(itemDir) 631// if(itemDir)
644 item->moveItem(itemDir); 632 item->moveItem(itemDir);
645 itemDir=item; 633 itemDir=item;
646 } else { 634 } else {
647 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); 635 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f");
648 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 636 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
649// if(itemFile) 637// if(itemFile)
650 item->moveItem(itemDir); 638 item->moveItem(itemDir);
651 item->moveItem(itemFile); 639 item->moveItem(itemFile);
652 itemFile=item; 640 itemFile=item;
653 } 641 }
654 } 642 }
655 } 643 }
656 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 644 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
657 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 645 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
658 file.close(); 646 file.close();
659 if( file.exists()) 647 if( file.exists())
660 file. remove(); 648 file. remove();
661 } else 649 } else
662 qDebug("temp file not opened successfullly "+sfile); 650 qDebug("temp file not opened successfullly "+sfile);
663 Remote_View->setSorting( 4,TRUE); 651 Remote_View->setSorting( 4,TRUE);
664 return true; 652 return true;
665} 653}
666 654
667void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 655void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
668{ 656{
669 if(item) { 657 if(item) {
670 QCopEnvelope ( "QPE/System", "busy()" ); 658 QCopEnvelope ( "QPE/System", "busy()" );
671 QString oldRemoteCurrentDir = currentRemoteDir; 659 QString oldRemoteCurrentDir = currentRemoteDir;
672 QString strItem=selectedItem->text(0); 660 QString strItem=selectedItem->text(0);
673 strItem=strItem.simplifyWhiteSpace(); 661 strItem=strItem.simplifyWhiteSpace();
674 if(strItem == "../") { // the user wants to go ^ 662 if(strItem == "../") { // the user wants to go ^
675 if( FtpCDUp( conn) == 0) { 663 if( FtpCDUp( conn) == 0) {
676 QString msg; 664 QString msg;
677 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 665 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
678 msg.replace(QRegExp(":"),"\n"); 666 msg.replace(QRegExp(":"),"\n");
679 QMessageBox::message(tr("Note"),msg); 667 QMessageBox::message(tr("Note"),msg);
680 qDebug(msg); 668 qDebug(msg);
681 } 669 }
682 char path[256]; 670 char path[256];
683 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 671 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
684 QString msg; 672 QString msg;
685 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 673 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
686 msg.replace(QRegExp(":"),"\n"); 674 msg.replace(QRegExp(":"),"\n");
687 QMessageBox::message(tr("Note"),msg); 675 QMessageBox::message(tr("Note"),msg);
688 qDebug(msg); 676 qDebug(msg);
689 } 677 }
690 currentRemoteDir=path; 678 currentRemoteDir=path;
691 } else { 679 } else {
692 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 680 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
693 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 681 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
694 strItem = strItem.stripWhiteSpace(); 682 strItem = strItem.stripWhiteSpace();
695 currentRemoteDir = strItem; 683 currentRemoteDir = strItem;
696 if( !remoteChDir( (const QString &)strItem)) { 684 if( !remoteChDir( (const QString &)strItem)) {
697 currentRemoteDir = oldRemoteCurrentDir; 685 currentRemoteDir = oldRemoteCurrentDir;
698 strItem=""; 686 strItem="";
699 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 687 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
700 } 688 }
701 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 689 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
702 qDebug("trying directory"); 690 qDebug("trying directory");
703 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 691 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
704 currentRemoteDir = oldRemoteCurrentDir; 692 currentRemoteDir = oldRemoteCurrentDir;
705 strItem=""; 693 strItem="";
706 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 694 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
707 695
708 } else { 696 } else {
709 currentRemoteDir = currentRemoteDir+strItem; 697 currentRemoteDir = currentRemoteDir+strItem;
710 } 698 }
711 } else { 699 } else {
712 qDebug("download "+strItem); 700 qDebug("download "+strItem);
713 } 701 }
714 } 702 }
715 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 703 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
716 if(currentRemoteDir.right(1) !="/") 704 if(currentRemoteDir.right(1) !="/")
717 currentRemoteDir +="/"; 705 currentRemoteDir +="/";
718 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 706 currentPathCombo->lineEdit()->setText( currentRemoteDir );
719 fillRemoteCombo( (const QString &)currentDir); 707 fillRemoteCombo( (const QString &)currentDir);
720 QCopEnvelope ( "QPE/System", "notBusy()" ); 708 QCopEnvelope ( "QPE/System", "notBusy()" );
721 } 709 }
722} 710}
723 711
724void OpieFtp::localListClicked(QListViewItem *selectedItem) 712void OpieFtp::localListClicked(QListViewItem *selectedItem)
725{ 713{
726 if(item) { 714// qDebug(selectedItem->text(0));
727 QString strItem=selectedItem->text(0); 715 if(item!= NULL) {
716
717 QString strItem=selectedItem->text(0);
728 QString strSize=selectedItem->text(1); 718 QString strSize=selectedItem->text(1);
729 strSize=strSize.stripWhiteSpace(); 719 strSize=strSize.stripWhiteSpace();
730 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 720 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
731 // is symlink 721 // is symlink
732 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 722 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
733 if(QDir(strItem2).exists() ) { 723 if(QDir(strItem2).exists() ) {
734 currentDir.cd(strItem2, TRUE); 724 currentDir.cd(strItem2, TRUE);
735 populateLocalView(); 725 populateLocalView();
736 } 726 }
737 } else { // not a symlink 727 } else { // not a symlink
738 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 728 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
739 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 729 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
740 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 730 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
741 currentDir.cd(strItem,FALSE); 731 currentDir.cd(strItem,FALSE);
742 populateLocalView(); 732 populateLocalView();
743 } else { 733 } else {
744 currentDir.cdUp(); 734 currentDir.cdUp();
745 populateLocalView(); 735 populateLocalView();
746 } 736 }
747 if(QDir(strItem).exists()){ 737 if(QDir(strItem).exists()){
748 currentDir.cd(strItem, TRUE); 738 currentDir.cd(strItem, TRUE);
749 populateLocalView(); 739 populateLocalView();
750 } 740 }
751 } else { 741 } else {
752 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 742 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
753 if( QFile::exists(strItem ) ) { 743 if( QFile::exists(strItem ) ) {
754 // qDebug("upload "+strItem); 744 // qDebug("upload "+strItem);
755 } 745 }
756 } //end not symlink 746 } //end not symlink
757 chdir(strItem.latin1()); 747 chdir(strItem.latin1());
758 } 748 }
759 } 749 }
760} 750}
761 751
762void OpieFtp::doLocalCd() 752void OpieFtp::doLocalCd()
763{ 753{
764 localListClicked( Local_View->currentItem()); 754 localListClicked( Local_View->currentItem());
765} 755}
766 756
767void OpieFtp:: doRemoteCd() 757void OpieFtp:: doRemoteCd()
768{ 758{
769 remoteListClicked( Remote_View->currentItem()); 759 remoteListClicked( Remote_View->currentItem());
770 760
771} 761}
772 762
773void OpieFtp::showHidden() 763void OpieFtp::showHidden()
774{ 764{
775 if (!b) { 765 if (!b) {
776 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 766 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
777 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 767 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
778// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 768// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
779 b=TRUE; 769 b=TRUE;
780 770
781 } else { 771 } else {
782 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 772 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
783 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 773 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
784// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 774// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
785 b=FALSE; 775 b=FALSE;
786 } 776 }
787 populateLocalView(); 777 populateLocalView();
788} 778}
789 779
790void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 780void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
791{ 781{
792 switch (mouse) { 782// if(item)
793 case 1: 783if (mouse == 2) {
794 break;
795 case 2:
796 showLocalMenu(item); 784 showLocalMenu(item);
797 break; 785 }
798 };
799} 786}
800 787
801void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 788void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
802{ 789{
803 switch (mouse) { 790 switch (mouse) {
804 case 1: 791 case 1:
805 break; 792 break;
806 case 2: 793 case 2:
807 showRemoteMenu(item); 794 showRemoteMenu(item);
808 break; 795 break;
809 }; 796 };
810} 797}
811 798
812void OpieFtp::showRemoteMenu(QListViewItem * item) 799void OpieFtp::showRemoteMenu(QListViewItem * item)
813{ 800{
814 QPopupMenu m;// = new QPopupMenu( Local_View ); 801 QPopupMenu m;// = new QPopupMenu( Local_View );
815 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 802 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
816 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 803 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
817 else 804 else
818 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 805 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
819 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 806 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
820 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 807 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
821 m.insertSeparator(); 808 m.insertSeparator();
822 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 809 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
823 m.exec( QCursor::pos() ); 810 m.exec( QCursor::pos() );
824} 811}
825 812
826void OpieFtp::showLocalMenu(QListViewItem * item) 813void OpieFtp::showLocalMenu(QListViewItem * item)
827{ 814{
828 QPopupMenu m; 815
816 QPopupMenu m;
829 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 817 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
830 m.insertSeparator(); 818 m.insertSeparator();
831 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 819 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
832 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 820 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
833 else 821 else
834 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 822 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
835 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 823 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
836 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 824 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
837 m.insertSeparator(); 825 m.insertSeparator();
838 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 826 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
839 m.setCheckable(TRUE); 827 m.setCheckable(TRUE);
840 if (b) 828 if (b)
841 m.setItemChecked(m.idAt(0),TRUE); 829 m.setItemChecked(m.idAt(0),TRUE);
842 else 830 else
843 m.setItemChecked(m.idAt(0),FALSE); 831 m.setItemChecked(m.idAt(0),FALSE);
844 832
845 m.exec( QCursor::pos() ); 833 m.exec( QCursor::pos() );
846} 834}
847 835
848void OpieFtp::localMakDir() 836void OpieFtp::localMakDir()
849{ 837{
850 InputDialog *fileDlg; 838 InputDialog *fileDlg;
851 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 839 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
852 fileDlg->exec(); 840 fileDlg->exec();
853 if( fileDlg->result() == 1 ) { 841 if( fileDlg->result() == 1 ) {
854 QString filename = fileDlg->LineEdit1->text(); 842 QString filename = fileDlg->LineEdit1->text();
855 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 843 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
856 } 844 }
857 populateLocalView(); 845 populateLocalView();
858} 846}
859 847
860void OpieFtp::localDelete() 848void OpieFtp::localDelete()
861{ 849{
862 QString f = Local_View->currentItem()->text(0); 850 QString f = Local_View->currentItem()->text(0);
863 if(QDir(f).exists() ) { 851 if(QDir(f).exists() ) {
864 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 852 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
865 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 853 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
866 case 0: { 854 case 0: {
867 f=currentDir.canonicalPath()+"/"+f; 855 f=currentDir.canonicalPath()+"/"+f;
868 QString cmd="rmdir "+f; 856 QString cmd="rmdir "+f;
869 system( cmd.latin1()); 857 system( cmd.latin1());
870 populateLocalView(); 858 populateLocalView();
871 } 859 }
872 break; 860 break;
873 case 1: 861 case 1:
874 // exit 862 // exit
875 break; 863 break;
876 }; 864 };
877 865
878 } else { 866 } else {
879 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 867 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
880 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 868 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
881 case 0: { 869 case 0: {
882 f=currentDir.canonicalPath()+"/"+f; 870 f=currentDir.canonicalPath()+"/"+f;
883 QString cmd="rm "+f; 871 QString cmd="rm "+f;
884 system( cmd.latin1()); 872 system( cmd.latin1());
885 populateLocalView(); 873 populateLocalView();
886 } 874 }
887 break; 875 break;
888 case 1: 876 case 1:
889 // exit 877 // exit
890 break; 878 break;
891 }; 879 };
892 } 880 }
893} 881}
894 882
895void OpieFtp::remoteMakDir() 883void OpieFtp::remoteMakDir()
896{ 884{
897 InputDialog *fileDlg; 885 InputDialog *fileDlg;
898 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 886 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
899 fileDlg->exec(); 887 fileDlg->exec();
900 if( fileDlg->result() == 1 ) { 888 if( fileDlg->result() == 1 ) {
901 QString filename = fileDlg->LineEdit1->text();//+".playlist"; 889 QString filename = fileDlg->LineEdit1->text();//+".playlist";
902 QString tmp=currentRemoteDir+filename; 890 QString tmp=currentRemoteDir+filename;
903 QCopEnvelope ( "QPE/System", "busy()" ); 891 QCopEnvelope ( "QPE/System", "busy()" );
904 if(FtpMkdir( tmp.latin1(), conn) == 0) { 892 if(FtpMkdir( tmp.latin1(), conn) == 0) {
905 QString msg; 893 QString msg;
906 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); 894 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn));
907 msg.replace(QRegExp(":"),"\n"); 895 msg.replace(QRegExp(":"),"\n");
908 QMessageBox::message(tr("Note"),msg); 896 QMessageBox::message(tr("Note"),msg);
909 } 897 }
910 QCopEnvelope ( "QPE/System", "notBusy()" ); 898 QCopEnvelope ( "QPE/System", "notBusy()" );
911 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 899 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
912 } 900 }
913} 901}
914 902
915void OpieFtp::remoteDelete() 903void OpieFtp::remoteDelete()
916{ 904{
917 QString f = Remote_View->currentItem()->text(0); 905 QString f = Remote_View->currentItem()->text(0);
918 QCopEnvelope ( "QPE/System", "busy()" ); 906 QCopEnvelope ( "QPE/System", "busy()" );
919 if( f.right(1) =="/") { 907 if( f.right(1) =="/") {
920 QString path= currentRemoteDir+f; 908 QString path= currentRemoteDir+f;
921 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 909 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
922 ,tr("Yes"),tr("No"),0,0,1) ) { 910 ,tr("Yes"),tr("No"),0,0,1) ) {
923 case 0: { 911 case 0: {
924 f=currentDir.canonicalPath()+"/"+f; 912 f=currentDir.canonicalPath()+"/"+f;
925 if(FtpRmdir( path.latin1(), conn) ==0) { 913 if(FtpRmdir( path.latin1(), conn) ==0) {
926 QString msg; 914 QString msg;
927 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); 915 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn));
928 msg.replace(QRegExp(":"),"\n"); 916 msg.replace(QRegExp(":"),"\n");
929 QMessageBox::message(tr("Note"),msg); 917 QMessageBox::message(tr("Note"),msg);
930 } 918 }
931 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 919 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
932 } 920 }
933 break; 921 break;
934 }; 922 };
935 } else { 923 } else {
936 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 924 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
937 ,tr("Yes"),tr("No"),0,0,1) ) { 925 ,tr("Yes"),tr("No"),0,0,1) ) {
938 case 0: { 926 case 0: {
939 QString path= currentRemoteDir+f; 927 QString path= currentRemoteDir+f;
940 if(FtpDelete( path.latin1(), conn)==0) { 928 if(FtpDelete( path.latin1(), conn)==0) {
941 QString msg; 929 QString msg;
942 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); 930 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
943 msg.replace(QRegExp(":"),"\n"); 931 msg.replace(QRegExp(":"),"\n");
944 QMessageBox::message(tr("Note"),msg); 932 QMessageBox::message(tr("Note"),msg);
945 } 933 }
946 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 934 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
947 } 935 }
948 break; 936 break;
949 }; 937 };
950 } 938 }
951 QCopEnvelope ( "QPE/System", "notBusy()" ); 939 QCopEnvelope ( "QPE/System", "notBusy()" );
952} 940}
953 941
954void OpieFtp::remoteRename() 942void OpieFtp::remoteRename()
955{ 943{
956 QString curFile = Remote_View->currentItem()->text(0); 944 QString curFile = Remote_View->currentItem()->text(0);
957 InputDialog *fileDlg; 945 InputDialog *fileDlg;
958 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 946 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
959 fileDlg->inputText = curFile; 947 fileDlg->inputText = curFile;
960 fileDlg->exec(); 948 fileDlg->exec();
961 if( fileDlg->result() == 1 ) { 949 if( fileDlg->result() == 1 ) {
962 QString oldName = currentRemoteDir +"/"+ curFile; 950 QString oldName = currentRemoteDir +"/"+ curFile;
963 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; 951 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
964 QCopEnvelope ( "QPE/System", "busy()" ); 952 QCopEnvelope ( "QPE/System", "busy()" );
965 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { 953 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
966 QString msg; 954 QString msg;
967 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); 955 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn));
968 msg.replace(QRegExp(":"),"\n"); 956 msg.replace(QRegExp(":"),"\n");
969 QMessageBox::message(tr("Note"),msg); 957 QMessageBox::message(tr("Note"),msg);
970 } 958 }
971 QCopEnvelope ( "QPE/System", "notBusy()" ); 959 QCopEnvelope ( "QPE/System", "notBusy()" );
972 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 960 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
973 } 961 }
974} 962}
975 963
976void OpieFtp::localRename() 964void OpieFtp::localRename()
977{ 965{
978 QString curFile = Local_View->currentItem()->text(0); 966 QString curFile = Local_View->currentItem()->text(0);
979 InputDialog *fileDlg; 967 InputDialog *fileDlg;
980 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 968 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
981 fileDlg->inputText = curFile; 969 fileDlg->inputText = curFile;
982 fileDlg->exec(); 970 fileDlg->exec();
983 if( fileDlg->result() == 1 ) { 971 if( fileDlg->result() == 1 ) {
984 QString oldname = currentDir.canonicalPath() + "/" + curFile; 972 QString oldname = currentDir.canonicalPath() + "/" + curFile;
985 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 973 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
986 if( rename(oldname.latin1(), newName.latin1())== -1) 974 if( rename(oldname.latin1(), newName.latin1())== -1)
987 QMessageBox::message(tr("Note"),tr("Could not rename")); 975 QMessageBox::message(tr("Note"),tr("Could not rename"));
988 } 976 }
989 populateLocalView(); 977 populateLocalView();
990} 978}
991 979
992void OpieFtp::currentPathComboActivated(const QString & currentPath) { 980void OpieFtp::currentPathComboActivated(const QString & currentPath) {
993 if (TabWidget->currentPageIndex() == 0) { 981 if (TabWidget->currentPageIndex() == 0) {
994 chdir( currentPath.latin1() ); 982 chdir( currentPath.latin1() );
995 currentDir.cd( currentPath, TRUE); 983 currentDir.cd( currentPath, TRUE);
996 populateLocalView(); 984 populateLocalView();
997 update(); 985 update();
998 } else { 986 } else {
999// chdir( currentPath.latin1() ); 987// chdir( currentPath.latin1() );
1000// currentDir.cd( currentPath, TRUE); 988// currentDir.cd( currentPath, TRUE);
1001// populateList(); 989// populateList();
1002// update(); 990// update();
1003 991
1004 } 992 }
1005} 993}
1006 994
1007void OpieFtp::fillCombo(const QString &currentPath) { 995void OpieFtp::fillCombo(const QString &currentPath) {
1008 996
1009 currentPathCombo->lineEdit()->setText(currentPath); 997 currentPathCombo->lineEdit()->setText(currentPath);
1010 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 998 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1011 currentPathCombo->clear(); 999 currentPathCombo->clear();
1012 localDirPathStringList.prepend(currentPath ); 1000 localDirPathStringList.prepend(currentPath );
1013 currentPathCombo->insertStringList( localDirPathStringList,-1); 1001 currentPathCombo->insertStringList( localDirPathStringList,-1);
1014 } 1002 }
1015 currentPathCombo->lineEdit()->setText(currentPath); 1003 currentPathCombo->lineEdit()->setText(currentPath);
1016 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1004 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1017 currentPathCombo->clear(); 1005 currentPathCombo->clear();
1018 remoteDirPathStringList.prepend(currentPath ); 1006 remoteDirPathStringList.prepend(currentPath );
1019 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 1007 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
1020 } 1008 }