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