summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-28 14:14:32 (UTC)
committer llornkcor <llornkcor>2002-03-28 14:14:32 (UTC)
commit24464bb5e5ffa11961bf1946529d7ebc225b990c (patch) (unidiff)
tree3b3c4dc0d4222f8ad02e43bb30b065bb19e5b271
parentf765ef1807694d2e0c9fc53f65fc6c261a78a7f4 (diff)
downloadopie-24464bb5e5ffa11961bf1946529d7ebc225b990c.zip
opie-24464bb5e5ffa11961bf1946529d7ebc225b990c.tar.gz
opie-24464bb5e5ffa11961bf1946529d7ebc225b990c.tar.bz2
forgot to unjcomment something
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 6be28d6..3e13466 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,657 +1,657 @@
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 filterStr="*"; 264 filterStr="*";
265 b=FALSE; 265 b=FALSE;
266 populateLocalView(); 266 populateLocalView();
267 readConfig(); 267 readConfig();
268 ServerComboBox->setCurrentItem(currentServerConfig); 268 ServerComboBox->setCurrentItem(currentServerConfig);
269 TabWidget->setCurrentPage(2); 269 TabWidget->setCurrentPage(2);
270} 270}
271 271
272OpieFtp::~OpieFtp() 272OpieFtp::~OpieFtp()
273{ 273{
274} 274}
275 275
276void OpieFtp::cleanUp() 276void OpieFtp::cleanUp()
277{ 277{
278 if(conn) 278 if(conn)
279 FtpQuit(conn); 279 FtpQuit(conn);
280 QString sfile=QDir::homeDirPath(); 280 QString sfile=QDir::homeDirPath();
281 if(sfile.right(1) != "/") 281 if(sfile.right(1) != "/")
282 sfile+="/._temp"; 282 sfile+="/._temp";
283 else 283 else
284 sfile+="._temp"; 284 sfile+="._temp";
285 QFile file( sfile); 285 QFile file( sfile);
286 if(file.exists()) 286 if(file.exists())
287 file.remove(); 287 file.remove();
288} 288}
289 289
290void OpieFtp::tabChanged(QWidget *w) 290void OpieFtp::tabChanged(QWidget *w)
291{ 291{
292 if (TabWidget->currentPageIndex() == 0) { 292 if (TabWidget->currentPageIndex() == 0) {
293 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 293 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
294 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 294 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
295 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 295 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
296 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 296 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
297 } 297 }
298 if (TabWidget->currentPageIndex() == 1) { 298 if (TabWidget->currentPageIndex() == 1) {
299 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 299 currentPathCombo->lineEdit()->setText( currentRemoteDir );
300 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 300 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
301 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 301 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
302 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 302 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
303 } 303 }
304 if (TabWidget->currentPageIndex() == 2) { 304 if (TabWidget->currentPageIndex() == 2) {
305 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 305 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
306 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 306 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
307 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 307 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
308 } 308 }
309} 309}
310 310
311void OpieFtp::newConnection() 311void OpieFtp::newConnection()
312{ 312{
313 UsernameComboBox->lineEdit()->setText(""); 313 UsernameComboBox->lineEdit()->setText("");
314 PasswordEdit->setText( "" ); 314 PasswordEdit->setText( "" );
315 ServerComboBox->lineEdit()->setText( ""); 315 ServerComboBox->lineEdit()->setText( "");
316 remotePath->setText( currentRemoteDir = "/"); 316 remotePath->setText( currentRemoteDir = "/");
317 PortSpinBox->setValue( 21); 317 PortSpinBox->setValue( 21);
318 TabWidget->setCurrentPage(2); 318 TabWidget->setCurrentPage(2);
319 currentServerConfig = -1; 319 currentServerConfig = -1;
320} 320}
321 321
322void OpieFtp::serverComboEdited(const QString & edit) 322void OpieFtp::serverComboEdited(const QString & edit)
323{ 323{
324 if( !edit.isEmpty() ) { 324 if( !edit.isEmpty() ) {
325 currentServerConfig = -1; 325 currentServerConfig = -1;
326// qDebug("comboedited"); 326// qDebug("comboedited");
327 } 327 }
328} 328}
329 329
330void OpieFtp::connectorBtnToggled(bool On) 330void OpieFtp::connectorBtnToggled(bool On)
331{ 331{
332 if(On) { 332 if(On) {
333 connector(); 333 connector();
334 } else { 334 } else {
335 disConnector(); 335 disConnector();
336 } 336 }
337 337
338} 338}
339 339
340void OpieFtp::connector() 340void OpieFtp::connector()
341{ 341{
342 QCopEnvelope ( "QPE/System", "busy()" ); 342 QCopEnvelope ( "QPE/System", "busy()" );
343// qApp->processEvents(); 343// qApp->processEvents();
344 currentRemoteDir=remotePath->text(); 344 currentRemoteDir=remotePath->text();
345 if(ServerComboBox->currentText().isEmpty()) { 345 if(ServerComboBox->currentText().isEmpty()) {
346 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 346 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
347 TabWidget->setCurrentPage(2); 347 TabWidget->setCurrentPage(2);
348 ServerComboBox->setFocus(); 348 ServerComboBox->setFocus();
349 connectServerBtn->setOn(FALSE); 349 connectServerBtn->setOn(FALSE);
350 connectServerBtn->setText( tr("Connect")); 350 connectServerBtn->setText( tr("Connect"));
351 return; 351 return;
352 } 352 }
353 FtpInit(); 353 FtpInit();
354 TabWidget->setCurrentPage(1); 354 TabWidget->setCurrentPage(1);
355 QString ftp_host = ServerComboBox->currentText(); 355 QString ftp_host = ServerComboBox->currentText();
356 QString ftp_user = UsernameComboBox->currentText(); 356 QString ftp_user = UsernameComboBox->currentText();
357 QString ftp_pass = PasswordEdit->text(); 357 QString ftp_pass = PasswordEdit->text();
358 QString port=PortSpinBox->cleanText(); 358 QString port=PortSpinBox->cleanText();
359 port.stripWhiteSpace(); 359 port.stripWhiteSpace();
360 360
361 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 361 if(ftp_host.find("ftp://",0, TRUE) != -1 )
362 ftp_host=ftp_host.right(ftp_host.length()-6); 362 ftp_host=ftp_host.right(ftp_host.length()-6);
363 ftp_host+=":"+port; 363 ftp_host+=":"+port;
364 if (!FtpConnect( ftp_host.latin1(), &conn)) { 364 if (!FtpConnect( ftp_host.latin1(), &conn)) {
365 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 365 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
366 connectServerBtn->setOn(FALSE); 366 connectServerBtn->setOn(FALSE);
367 connectServerBtn->setText( tr("Connect")); 367 connectServerBtn->setText( tr("Connect"));
368 return ; 368 return ;
369 } 369 }
370 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 370 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
371 QString msg; 371 QString msg;
372 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 372 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
373 msg.replace(QRegExp(":"),"\n"); 373 msg.replace(QRegExp(":"),"\n");
374 QMessageBox::message(tr("Note"),msg); 374 QMessageBox::message(tr("Note"),msg);
375 if(conn) 375 if(conn)
376 FtpQuit(conn); 376 FtpQuit(conn);
377 connectServerBtn->setOn(FALSE); 377 connectServerBtn->setOn(FALSE);
378 connectServerBtn->setText( tr("Connect")); 378 connectServerBtn->setText( tr("Connect"));
379 return ; 379 return ;
380 } 380 }
381 remoteDirList("/") ; 381 remoteDirList("/") ;
382 setCaption(ftp_host); 382 setCaption(ftp_host);
383 writeConfig(); 383 writeConfig();
384 connectServerBtn->setText( tr("Disconnect")); 384 connectServerBtn->setText( tr("Disconnect"));
385 QCopEnvelope ( "QPE/System", "notBusy()" ); 385 QCopEnvelope ( "QPE/System", "notBusy()" );
386} 386}
387 387
388void OpieFtp::disConnector() 388void OpieFtp::disConnector()
389{ 389{
390 if(conn) 390 if(conn)
391 FtpQuit(conn); 391 FtpQuit(conn);
392 setCaption("OpieFtp"); 392 setCaption("OpieFtp");
393 currentRemoteDir="/"; 393 currentRemoteDir="/";
394 Remote_View->clear(); 394 Remote_View->clear();
395 connectServerBtn->setText( tr("Connect")); 395 connectServerBtn->setText( tr("Connect"));
396 connectServerBtn->setOn(FALSE); 396 connectServerBtn->setOn(FALSE);
397 397
398} 398}
399 399
400void OpieFtp::localUpload() 400void OpieFtp::localUpload()
401{ 401{
402 int fsz; 402 int fsz;
403 QCopEnvelope ( "QPE/System", "busy()" ); 403 QCopEnvelope ( "QPE/System", "busy()" );
404// qApp->processEvents(); 404// qApp->processEvents();
405 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 405 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
406 QListViewItemIterator it( Local_View ); 406 QListViewItemIterator it( Local_View );
407 for ( ; it.current(); ++it ) { 407 for ( ; it.current(); ++it ) {
408 if ( it.current()->isSelected() ) { 408 if ( it.current()->isSelected() ) {
409 QString strItem = it.current()->text(0); 409 QString strItem = it.current()->text(0);
410 QString localFile = currentDir.canonicalPath()+"/"+strItem; 410 QString localFile = currentDir.canonicalPath()+"/"+strItem;
411 QString remoteFile= currentRemoteDir+strItem; 411 QString remoteFile= currentRemoteDir+strItem;
412 QFileInfo fi(localFile); 412 QFileInfo fi(localFile);
413 if( !fi.isDir()) { 413 if( !fi.isDir()) {
414 fsz=fi.size(); 414 fsz=fi.size();
415 ProgressBar->setTotalSteps(fsz); 415 ProgressBar->setTotalSteps(fsz);
416 416
417 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 417 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
418 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 418 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
419 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 419 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
420 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 420 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
421 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 421 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
422 422
423 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 423 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
424 QString msg; 424 QString msg;
425 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 425 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
426 msg.replace(QRegExp(":"),"\n"); 426 msg.replace(QRegExp(":"),"\n");
427 QMessageBox::message(tr("Note"),msg); 427 QMessageBox::message(tr("Note"),msg);
428 } 428 }
429 } else { 429 } else {
430 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 430 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
431 } 431 }
432 ProgressBar->reset(); 432 ProgressBar->reset();
433 nullifyCallBack(); 433 nullifyCallBack();
434 it.current()->setSelected(FALSE); 434 it.current()->setSelected(FALSE);
435 } //end currentSelected 435 } //end currentSelected
436 } 436 }
437 TabWidget->setCurrentPage(1); 437 TabWidget->setCurrentPage(1);
438 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 438 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
439 QCopEnvelope ( "QPE/System", "notBusy()" ); 439 QCopEnvelope ( "QPE/System", "notBusy()" );
440} 440}
441 441
442void OpieFtp::nullifyCallBack() 442void OpieFtp::nullifyCallBack()
443{ 443{
444 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 444 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
445 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 445 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
446 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 446 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
447 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 447 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
448} 448}
449 449
450void OpieFtp::remoteDownload() 450void OpieFtp::remoteDownload()
451{ 451{
452// qApp->processEvents(); 452// qApp->processEvents();
453 int fsz; 453 int fsz;
454 QCopEnvelope ( "QPE/System", "busy()" ); 454 QCopEnvelope ( "QPE/System", "busy()" );
455 455
456 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 456 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
457 QListViewItemIterator it( Remote_View ); 457 QListViewItemIterator it( Remote_View );
458 for ( ; it.current(); ++it ) { 458 for ( ; it.current(); ++it ) {
459 if ( it.current()->isSelected() ) { 459 if ( it.current()->isSelected() ) {
460 QString strItem = it.current()->text(0); 460 QString strItem = it.current()->text(0);
461// strItem=strItem.right(strItem.length()-1); 461// strItem=strItem.right(strItem.length()-1);
462 QString localFile = currentDir.canonicalPath(); 462 QString localFile = currentDir.canonicalPath();
463 if(localFile.right(1).find("/",0,TRUE) == -1) 463 if(localFile.right(1).find("/",0,TRUE) == -1)
464 localFile += "/"; 464 localFile += "/";
465 localFile += strItem; 465 localFile += strItem;
466// QString localFile = currentDir.canonicalPath()+"/"+strItem; 466// QString localFile = currentDir.canonicalPath()+"/"+strItem;
467 QString remoteFile= currentRemoteDir+strItem; 467 QString remoteFile= currentRemoteDir+strItem;
468 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 468 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
469 fsz = 0; 469 fsz = 0;
470 QString temp; 470 QString temp;
471 temp.sprintf( remoteFile+" "+" %dkb", fsz); 471 temp.sprintf( remoteFile+" "+" %dkb", fsz);
472 472
473 ProgressBar->setTotalSteps(fsz); 473 ProgressBar->setTotalSteps(fsz);
474 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 474 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
475 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 475 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
476 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 476 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
477 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 477 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
478 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 478 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
479 479
480 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 480 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
481 QString msg; 481 QString msg;
482 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 482 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
483 msg.replace(QRegExp(":"),"\n"); 483 msg.replace(QRegExp(":"),"\n");
484 QMessageBox::message(tr("Note"),msg); 484 QMessageBox::message(tr("Note"),msg);
485 } 485 }
486 ProgressBar->reset(); 486 ProgressBar->reset();
487 nullifyCallBack(); 487 nullifyCallBack();
488 it.current()->setSelected(FALSE); 488 it.current()->setSelected(FALSE);
489 } 489 }
490 } 490 }
491 TabWidget->setCurrentPage(0); 491 TabWidget->setCurrentPage(0);
492 populateLocalView(); 492 populateLocalView();
493 QCopEnvelope ( "QPE/System", "notBusy()" ); 493 QCopEnvelope ( "QPE/System", "notBusy()" );
494} 494}
495 495
496bool OpieFtp::remoteDirList(const QString &dir) 496bool OpieFtp::remoteDirList(const QString &dir)
497{ 497{
498 QString tmp = QDir::homeDirPath(); 498 QString tmp = QDir::homeDirPath();
499 if(tmp.right(1) != "/") 499 if(tmp.right(1) != "/")
500 tmp+="/._temp"; 500 tmp+="/._temp";
501 else 501 else
502 tmp+="._temp"; 502 tmp+="._temp";
503// qDebug("Listing remote dir "+tmp); 503// qDebug("Listing remote dir "+tmp);
504 QCopEnvelope ( "QPE/System", "busy()" ); 504 QCopEnvelope ( "QPE/System", "busy()" );
505 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 505 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
506 QString msg; 506 QString msg;
507 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 507 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
508 msg.replace(QRegExp(":"),"\n"); 508 msg.replace(QRegExp(":"),"\n");
509 QMessageBox::message(tr("Note"),msg); 509 QMessageBox::message(tr("Note"),msg);
510 return false; 510 return false;
511 } 511 }
512 populateRemoteView() ; 512 populateRemoteView() ;
513 QCopEnvelope ( "QPE/System", "notBusy()" ); 513 QCopEnvelope ( "QPE/System", "notBusy()" );
514 return true; 514 return true;
515} 515}
516 516
517bool OpieFtp::remoteChDir(const QString &dir) 517bool OpieFtp::remoteChDir(const QString &dir)
518{ 518{
519 QCopEnvelope ( "QPE/System", "busy()" ); 519 QCopEnvelope ( "QPE/System", "busy()" );
520 if (!FtpChdir( dir.latin1(), conn )) { 520 if (!FtpChdir( dir.latin1(), conn )) {
521 QString msg; 521 QString msg;
522 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 522 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
523 msg.replace(QRegExp(":"),"\n"); 523 msg.replace(QRegExp(":"),"\n");
524 QMessageBox::message(tr("Note"),msg); 524 QMessageBox::message(tr("Note"),msg);
525 qDebug(msg); 525 qDebug(msg);
526 QCopEnvelope ( "QPE/System", "notBusy()" ); 526 QCopEnvelope ( "QPE/System", "notBusy()" );
527 return FALSE; 527 return FALSE;
528 } 528 }
529 QCopEnvelope ( "QPE/System", "notBusy()" ); 529 QCopEnvelope ( "QPE/System", "notBusy()" );
530 return TRUE; 530 return TRUE;
531} 531}
532 532
533void OpieFtp::populateLocalView() 533void OpieFtp::populateLocalView()
534{ 534{
535 Local_View->clear(); 535 Local_View->clear();
536 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 536 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
537 currentDir.setMatchAllDirs(TRUE); 537 currentDir.setMatchAllDirs(TRUE);
538 currentDir.setNameFilter(filterStr); 538 currentDir.setNameFilter(filterStr);
539 QString fileL, fileS, fileDate; 539 QString fileL, fileS, fileDate;
540 bool isDir=FALSE; 540 bool isDir=FALSE;
541 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 541 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
542 QFileInfoListIterator it(*list); 542 QFileInfoListIterator it(*list);
543 QFileInfo *fi; 543 QFileInfo *fi;
544 while ( (fi=it.current()) ) { 544 while ( (fi=it.current()) ) {
545 if (fi->isSymLink() ){ 545 if (fi->isSymLink() ){
546 QString symLink=fi->readLink(); 546 QString symLink=fi->readLink();
547// qDebug("Symlink detected "+symLink); 547// qDebug("Symlink detected "+symLink);
548 QFileInfo sym( symLink); 548 QFileInfo sym( symLink);
549 fileS.sprintf( "%10li", sym.size() ); 549 fileS.sprintf( "%10li", sym.size() );
550 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 550 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
551 fileDate = sym.lastModified().toString(); 551 fileDate = sym.lastModified().toString();
552 } else { 552 } else {
553// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 553// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
554 fileS.sprintf( "%10li", fi->size() ); 554 fileS.sprintf( "%10li", fi->size() );
555 fileL.sprintf( "%s",fi->fileName().data() ); 555 fileL.sprintf( "%s",fi->fileName().data() );
556 fileDate= fi->lastModified().toString(); 556 fileDate= fi->lastModified().toString();
557 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 557 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
558 fileL+="/"; 558 fileL+="/";
559 isDir=TRUE; 559 isDir=TRUE;
560// qDebug( fileL); 560// qDebug( fileL);
561 } 561 }
562 } 562 }
563 if(fileL !="./" && fi->exists()) { 563 if(fileL !="./" && fi->exists()) {
564 item= new QListViewItem( Local_View,fileL,fileS , fileDate); 564 item= new QListViewItem( Local_View,fileL,fileS , fileDate);
565 QPixmap pm; 565 QPixmap pm;
566 566
567 if(isDir || fileL.find("/",0,TRUE) != -1) { 567 if(isDir || fileL.find("/",0,TRUE) != -1) {
568 if( !QDir( fi->filePath() ).isReadable()) 568 if( !QDir( fi->filePath() ).isReadable())
569 pm = Resource::loadPixmap( "lockedfolder" ); 569 pm = Resource::loadPixmap( "lockedfolder" );
570 else 570 else
571 pm= Resource::loadPixmap( "folder" ); 571 pm= Resource::loadPixmap( "folder" );
572 item->setPixmap( 0,pm ); 572 item->setPixmap( 0,pm );
573 } else { 573 } else {
574 if( !fi->isReadable() ) 574 if( !fi->isReadable() )
575 pm = Resource::loadPixmap( "locked" ); 575 pm = Resource::loadPixmap( "locked" );
576 else { 576 else {
577 MimeType mt(fi->filePath()); 577 MimeType mt(fi->filePath());
578 pm=mt.pixmap(); //sets the correct pixmap for mimetype 578 pm=mt.pixmap(); //sets the correct pixmap for mimetype
579 if(pm.isNull()) 579 if(pm.isNull())
580 pm = Resource::loadPixmap( "UnknownDocument-14" ); 580 pm = Resource::loadPixmap( "UnknownDocument-14" );
581 item->setPixmap( 0,pm); 581 item->setPixmap( 0,pm);
582 } 582 }
583 } 583 }
584 if( fileL.find("->",0,TRUE) != -1) { 584 if( fileL.find("->",0,TRUE) != -1) {
585 // overlay link image 585 // overlay link image
586 pm= Resource::loadPixmap( "folder" ); 586 pm= Resource::loadPixmap( "folder" );
587 QPixmap lnk = Resource::loadPixmap( "symlink" ); 587 QPixmap lnk = Resource::loadPixmap( "symlink" );
588 QPainter painter( &pm ); 588 QPainter painter( &pm );
589 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 589 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
590 pm.setMask( pm.createHeuristicMask( FALSE ) ); 590 pm.setMask( pm.createHeuristicMask( FALSE ) );
591 item->setPixmap( 0, pm); 591 item->setPixmap( 0, pm);
592 } 592 }
593 } 593 }
594 isDir=FALSE; 594 isDir=FALSE;
595 ++it; 595 ++it;
596 } 596 }
597 Local_View->setSorting( 3,FALSE); 597 Local_View->setSorting( 3,FALSE);
598 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 598 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
599 fillCombo( (const QString &)currentDir); 599 fillCombo( (const QString &)currentDir);
600} 600}
601 601
602bool OpieFtp::populateRemoteView( ) 602bool OpieFtp::populateRemoteView( )
603{ 603{
604// qDebug("populate remoteview"); 604// qDebug("populate remoteview");
605 QString sfile=QDir::homeDirPath(); 605 QString sfile=QDir::homeDirPath();
606 if(sfile.right(1) != "/") 606 if(sfile.right(1) != "/")
607 sfile+="/._temp"; 607 sfile+="/._temp";
608 else 608 else
609 sfile+="._temp"; 609 sfile+="._temp";
610 QFile file( sfile); 610 QFile file( sfile);
611 Remote_View->clear(); 611 Remote_View->clear();
612 QString s, File_Name; 612 QString s, File_Name;
613 QListViewItem *itemDir=NULL, *itemFile=NULL; 613 QListViewItem *itemDir=NULL, *itemFile=NULL;
614 QString fileL, fileS, fileDate; 614 QString fileL, fileS, fileDate;
615 if ( file.open(IO_ReadOnly)) { 615 if ( file.open(IO_ReadOnly)) {
616 QTextStream t( &file ); // use a text stream 616 QTextStream t( &file ); // use a text stream
617 while ( !t.eof()) { 617 while ( !t.eof()) {
618 s = t.readLine(); 618 s = t.readLine();
619 fileL = s.right(s.length()-55); 619 fileL = s.right(s.length()-55);
620 fileL = fileL.stripWhiteSpace(); 620 fileL = fileL.stripWhiteSpace();
621 if(s.left(1) == "d") 621 if(s.left(1) == "d")
622 fileL = fileL+"/"; 622 fileL = fileL+"/";
623// fileL = "/"+fileL+"/"; 623// fileL = "/"+fileL+"/";
624 fileS = s.mid( 30, 42-30); 624 fileS = s.mid( 30, 42-30);
625 fileS = fileS.stripWhiteSpace(); 625 fileS = fileS.stripWhiteSpace();
626 fileDate = s.mid( 42, 55-42); 626 fileDate = s.mid( 42, 55-42);
627 fileDate = fileDate.stripWhiteSpace(); 627 fileDate = fileDate.stripWhiteSpace();
628 if(fileL.find("total",0,TRUE) == -1) { 628 if(fileL.find("total",0,TRUE) == -1) {
629 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 629 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
630 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); 630 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d");
631 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 631 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
632// if(itemDir) 632// if(itemDir)
633 item->moveItem(itemDir); 633 item->moveItem(itemDir);
634 itemDir=item; 634 itemDir=item;
635 } else { 635 } else {
636 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); 636 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f");
637 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 637 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
638// if(itemFile) 638// if(itemFile)
639 item->moveItem(itemDir); 639 item->moveItem(itemDir);
640 item->moveItem(itemFile); 640 item->moveItem(itemFile);
641 itemFile=item; 641 itemFile=item;
642 } 642 }
643 } 643 }
644 } 644 }
645 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 645 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
646 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 646 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
647 file.close(); 647 file.close();
648 if( file.exists()) 648 if( file.exists())
649 file. remove(); 649 file. remove();
650 } else 650 } else
651 qDebug("temp file not opened successfullly "+sfile); 651 qDebug("temp file not opened successfullly "+sfile);
652 Remote_View->setSorting( 4,TRUE); 652 Remote_View->setSorting( 4,TRUE);
653 return true; 653 return true;
654} 654}
655 655
656void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 656void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
657{ 657{