author | llornkcor <llornkcor> | 2002-03-12 02:40:58 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-12 02:40:58 (UTC) |
commit | c10fa05d94418620a08f25fc8d1436a2787f1446 (patch) (unidiff) | |
tree | 8cd2509ff5579cd577e557a3f9696951be8c8f33 | |
parent | 2b32b2dee7955b6be3fd58de9a84304405f74a40 (diff) | |
download | opie-c10fa05d94418620a08f25fc8d1436a2787f1446.zip opie-c10fa05d94418620a08f25fc8d1436a2787f1446.tar.gz opie-c10fa05d94418620a08f25fc8d1436a2787f1446.tar.bz2 |
added kludge for handling symlinks on remote server
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 151be84..e1dd582 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -1,719 +1,728 @@ | |||
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 | 12 | ||
13 | #include "opieftp.h" | 13 | #include "opieftp.h" |
14 | #include "ftplib.h" | 14 | #include "ftplib.h" |
15 | #include "inputDialog.h" | 15 | #include "inputDialog.h" |
16 | 16 | ||
17 | #include <qpe/qpemenubar.h> | 17 | #include <qpe/qpemenubar.h> |
18 | #include <qpe/qpetoolbar.h> | 18 | #include <qpe/qpetoolbar.h> |
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
22 | 22 | ||
23 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
24 | #include <qtoolbutton.h> | 24 | #include <qtoolbutton.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qstring.h> | 28 | #include <qstring.h> |
29 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
30 | #include <qpopupmenu.h> | 30 | #include <qpopupmenu.h> |
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | #include <qmainwindow.h> | 32 | #include <qmainwindow.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qprogressbar.h> | 34 | #include <qprogressbar.h> |
35 | #include <qspinbox.h> | 35 | #include <qspinbox.h> |
36 | #include <qtabwidget.h> | 36 | #include <qtabwidget.h> |
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qimage.h> | 39 | #include <qimage.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qmessagebox.h> | 41 | #include <qmessagebox.h> |
42 | #include <qlineedit.h> | 42 | #include <qlineedit.h> |
43 | 43 | ||
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | 46 | ||
47 | QProgressBar *ProgressBar; | 47 | QProgressBar *ProgressBar; |
48 | static netbuf *conn=NULL; | 48 | static netbuf *conn=NULL; |
49 | 49 | ||
50 | static int log_progress(netbuf *ctl, int xfered, void *arg) | 50 | static int log_progress(netbuf *ctl, int xfered, void *arg) |
51 | { | 51 | { |
52 | int fsz = *(int *)arg; | 52 | int fsz = *(int *)arg; |
53 | int pct = (xfered * 100) / fsz; | 53 | int pct = (xfered * 100) / fsz; |
54 | // printf("%3d%%\r", pct); | 54 | // printf("%3d%%\r", pct); |
55 | // fflush(stdout); | 55 | // fflush(stdout); |
56 | ProgressBar->setProgress(xfered); | 56 | ProgressBar->setProgress(xfered); |
57 | qApp->processEvents(); | 57 | qApp->processEvents(); |
58 | return 1; | 58 | return 1; |
59 | } | 59 | } |
60 | 60 | ||
61 | OpieFtp::OpieFtp( ) | 61 | OpieFtp::OpieFtp( ) |
62 | : QMainWindow( ) | 62 | : QMainWindow( ) |
63 | { | 63 | { |
64 | resize( 236, 290 ); | 64 | resize( 236, 290 ); |
65 | setMaximumSize( QSize( 240, 320 ) ); | 65 | setMaximumSize( QSize( 240, 320 ) ); |
66 | setCaption( tr( "OpieFtp" ) ); | 66 | setCaption( tr( "OpieFtp" ) ); |
67 | 67 | ||
68 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 68 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
69 | 69 | ||
70 | QPEMenuBar *menuBar = new QPEMenuBar( this ); | 70 | QPEMenuBar *menuBar = new QPEMenuBar( this ); |
71 | connectionMenu = new QPopupMenu( this ); | 71 | connectionMenu = new QPopupMenu( this ); |
72 | localMenu = new QPopupMenu( this ); | 72 | localMenu = new QPopupMenu( this ); |
73 | remoteMenu = new QPopupMenu( this ); | 73 | remoteMenu = new QPopupMenu( this ); |
74 | menuBar->insertItem( tr( "Connection" ), connectionMenu); | 74 | menuBar->insertItem( tr( "Connection" ), connectionMenu); |
75 | menuBar->insertItem( tr( "Local" ), localMenu); | 75 | menuBar->insertItem( tr( "Local" ), localMenu); |
76 | menuBar->insertItem( tr( "Remote" ), remoteMenu); | 76 | menuBar->insertItem( tr( "Remote" ), remoteMenu); |
77 | 77 | ||
78 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 78 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
79 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 79 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
80 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 80 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
81 | 81 | ||
82 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 82 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
83 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 83 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
84 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 84 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
85 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 85 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
86 | localMenu->insertSeparator(); | 86 | localMenu->insertSeparator(); |
87 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 87 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
88 | 88 | ||
89 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 89 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
90 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 90 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
91 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 91 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
92 | remoteMenu->insertSeparator(); | 92 | remoteMenu->insertSeparator(); |
93 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 93 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
94 | 94 | ||
95 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 95 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
96 | ProgressBar->setGeometry( QRect( 5, 268, 231, 15 ) ); | 96 | ProgressBar->setGeometry( QRect( 5, 268, 231, 15 ) ); |
97 | 97 | ||
98 | TabWidget = new QTabWidget( this, "TabWidget2" ); | 98 | TabWidget = new QTabWidget( this, "TabWidget2" ); |
99 | TabWidget->setGeometry( QRect( 3, 25, 240, 220 ) ); | 99 | TabWidget->setGeometry( QRect( 3, 25, 240, 220 ) ); |
100 | TabWidget->setTabShape(QTabWidget::Triangular); | 100 | TabWidget->setTabShape(QTabWidget::Triangular); |
101 | 101 | ||
102 | tab = new QWidget( TabWidget, "tab" ); | 102 | tab = new QWidget( TabWidget, "tab" ); |
103 | 103 | ||
104 | Local_View = new QListView( tab, "Local_View" ); | 104 | Local_View = new QListView( tab, "Local_View" ); |
105 | Local_View->setGeometry( QRect( 3, 2, 225, 195 ) ); | 105 | Local_View->setGeometry( QRect( 3, 2, 225, 195 ) ); |
106 | Local_View->addColumn( "File",120); | 106 | Local_View->addColumn( "File",120); |
107 | Local_View->addColumn( "Size",-1); | 107 | Local_View->addColumn( "Size",-1); |
108 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 108 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
109 | Local_View->addColumn( "Date",-1); | 109 | Local_View->addColumn( "Date",-1); |
110 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 110 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
111 | Local_View->setAllColumnsShowFocus(TRUE); | 111 | Local_View->setAllColumnsShowFocus(TRUE); |
112 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 112 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
113 | 113 | ||
114 | connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), | 114 | connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), |
115 | this,SLOT( localListClicked(QListViewItem *)) ); | 115 | this,SLOT( localListClicked(QListViewItem *)) ); |
116 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 116 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
117 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 117 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
118 | 118 | ||
119 | TabWidget->insertTab( tab, tr( "Local" ) ); | 119 | TabWidget->insertTab( tab, tr( "Local" ) ); |
120 | 120 | ||
121 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 121 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
122 | 122 | ||
123 | Remote_View = new QListView( tab_2, "Remote_View" ); | 123 | Remote_View = new QListView( tab_2, "Remote_View" ); |
124 | Remote_View->setGeometry( QRect( 3, 2, 225, 195 ) ); | 124 | Remote_View->setGeometry( QRect( 3, 2, 225, 195 ) ); |
125 | Remote_View->addColumn( "File",120); | 125 | Remote_View->addColumn( "File",120); |
126 | Remote_View->addColumn( "Size",-1); | 126 | Remote_View->addColumn( "Size",-1); |
127 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 127 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
128 | Remote_View->addColumn( "Date",-1); | 128 | Remote_View->addColumn( "Date",-1); |
129 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 129 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
130 | Remote_View->setAllColumnsShowFocus(TRUE); | 130 | Remote_View->setAllColumnsShowFocus(TRUE); |
131 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 131 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
132 | 132 | ||
133 | connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)), | 133 | connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)), |
134 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 134 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
135 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 135 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
136 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 136 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
137 | 137 | ||
138 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); | 138 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); |
139 | 139 | ||
140 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 140 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
141 | 141 | ||
142 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); | 142 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); |
143 | TextLabel1->setGeometry( QRect( 10, 10, 60, 16 ) ); | 143 | TextLabel1->setGeometry( QRect( 10, 10, 60, 16 ) ); |
144 | TextLabel1->setText( tr( "Username" ) ); | 144 | TextLabel1->setText( tr( "Username" ) ); |
145 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); | 145 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); |
146 | UsernameComboBox->setGeometry( QRect( 10, 25, 196, 21 ) ); | 146 | UsernameComboBox->setGeometry( QRect( 10, 25, 196, 21 ) ); |
147 | UsernameComboBox->setEditable(TRUE); | 147 | UsernameComboBox->setEditable(TRUE); |
148 | UsernameComboBox->lineEdit()->setText("root"); | 148 | UsernameComboBox->lineEdit()->setText("root"); |
149 | 149 | ||
150 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 150 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
151 | TextLabel2->setGeometry( QRect( 10, 50, 65, 16 ) ); | 151 | TextLabel2->setGeometry( QRect( 10, 50, 65, 16 ) ); |
152 | TextLabel2->setText( tr( "Password" ) ); | 152 | TextLabel2->setText( tr( "Password" ) ); |
153 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); | 153 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); |
154 | PasswordEdit->setGeometry( QRect( 10, 65, 195, 16 ) ); | 154 | PasswordEdit->setGeometry( QRect( 10, 65, 195, 16 ) ); |
155 | PasswordEdit->setEchoMode(QLineEdit::Password); | 155 | PasswordEdit->setEchoMode(QLineEdit::Password); |
156 | 156 | ||
157 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); | 157 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); |
158 | TextLabel3->setGeometry( QRect( 10, 90, 95, 16 ) ); | 158 | TextLabel3->setGeometry( QRect( 10, 90, 95, 16 ) ); |
159 | TextLabel3->setText( tr( "Remote server" ) ); | 159 | TextLabel3->setText( tr( "Remote server" ) ); |
160 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); | 160 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); |
161 | ServerComboBox->setGeometry( QRect( 10, 105, 195, 21 ) ); | 161 | ServerComboBox->setGeometry( QRect( 10, 105, 195, 21 ) ); |
162 | ServerComboBox->setEditable(TRUE); | 162 | ServerComboBox->setEditable(TRUE); |
163 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 163 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); |
164 | 164 | ||
165 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); | 165 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); |
166 | TextLabel5->setGeometry( QRect( 10, 130, 95, 16 ) ); | 166 | TextLabel5->setGeometry( QRect( 10, 130, 95, 16 ) ); |
167 | TextLabel5->setText( tr( "Remote path" ) ); | 167 | TextLabel5->setText( tr( "Remote path" ) ); |
168 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 168 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
169 | remotePath->setGeometry( QRect( 10, 145, 195, 16 ) ); | 169 | remotePath->setGeometry( QRect( 10, 145, 195, 16 ) ); |
170 | remotePath->setText( currentRemoteDir = "/"); | 170 | remotePath->setText( currentRemoteDir = "/"); |
171 | 171 | ||
172 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 172 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
173 | TextLabel4->setGeometry( QRect( 10, 170, 30, 21 ) ); | 173 | TextLabel4->setGeometry( QRect( 10, 170, 30, 21 ) ); |
174 | TextLabel4->setText( tr( "Port" ) ); | 174 | TextLabel4->setText( tr( "Port" ) ); |
175 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); | 175 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); |
176 | PortSpinBox->setGeometry( QRect( 40, 175, 75, 20 ) ); | 176 | PortSpinBox->setGeometry( QRect( 40, 175, 75, 20 ) ); |
177 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 177 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
178 | PortSpinBox->setMaxValue(32786); | 178 | PortSpinBox->setMaxValue(32786); |
179 | PortSpinBox->setValue( 4242 ); | 179 | PortSpinBox->setValue( 4242 ); |
180 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 180 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
181 | 181 | ||
182 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 182 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
183 | this,SLOT(tabChanged(QWidget*))); | 183 | this,SLOT(tabChanged(QWidget*))); |
184 | 184 | ||
185 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 185 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
186 | currentDir.setPath( QDir::currentDirPath()); | 186 | currentDir.setPath( QDir::currentDirPath()); |
187 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 187 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
188 | currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); | 188 | currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); |
189 | currentPathEdit->setGeometry( QRect( 5, 248, 220, 18 ) ); | 189 | currentPathEdit->setGeometry( QRect( 5, 248, 220, 18 ) ); |
190 | currentPathEdit->setText( currentDir.canonicalPath()); | 190 | currentPathEdit->setText( currentDir.canonicalPath()); |
191 | connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); | 191 | connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); |
192 | 192 | ||
193 | filterStr="*"; | 193 | filterStr="*"; |
194 | populateLocalView(); | 194 | populateLocalView(); |
195 | } | 195 | } |
196 | 196 | ||
197 | OpieFtp::~OpieFtp() | 197 | OpieFtp::~OpieFtp() |
198 | { | 198 | { |
199 | } | 199 | } |
200 | 200 | ||
201 | void OpieFtp::cleanUp() | 201 | void OpieFtp::cleanUp() |
202 | { | 202 | { |
203 | if(conn) | 203 | if(conn) |
204 | FtpQuit(conn); | 204 | FtpQuit(conn); |
205 | QFile f("./._temp"); | 205 | QFile f("./._temp"); |
206 | if(f.exists()) | 206 | if(f.exists()) |
207 | f. remove(); | 207 | f. remove(); |
208 | } | 208 | } |
209 | 209 | ||
210 | void OpieFtp::tabChanged(QWidget *w) | 210 | void OpieFtp::tabChanged(QWidget *w) |
211 | { | 211 | { |
212 | if (TabWidget->currentPageIndex() == 0) { | 212 | if (TabWidget->currentPageIndex() == 0) { |
213 | currentPathEdit->setText( currentDir.canonicalPath()); | 213 | currentPathEdit->setText( currentDir.canonicalPath()); |
214 | } else if (TabWidget->currentPageIndex() == 1) { | 214 | } else if (TabWidget->currentPageIndex() == 1) { |
215 | currentPathEdit->setText( currentRemoteDir ); | 215 | currentPathEdit->setText( currentRemoteDir ); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | void OpieFtp::localUpload() | 219 | void OpieFtp::localUpload() |
220 | { | 220 | { |
221 | int fsz; | 221 | int fsz; |
222 | QCopEnvelope ( "QPE/System", "busy()" ); | 222 | QCopEnvelope ( "QPE/System", "busy()" ); |
223 | qApp->processEvents(); | 223 | qApp->processEvents(); |
224 | QString strItem = Local_View->currentItem()->text(0); | 224 | QString strItem = Local_View->currentItem()->text(0); |
225 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 225 | QString localFile = currentDir.canonicalPath()+"/"+strItem; |
226 | QString remoteFile= currentRemoteDir+strItem; | 226 | QString remoteFile= currentRemoteDir+strItem; |
227 | QFileInfo fi(localFile); | 227 | QFileInfo fi(localFile); |
228 | if( !fi.isDir()) { | 228 | if( !fi.isDir()) { |
229 | fsz=fi.size(); | 229 | fsz=fi.size(); |
230 | ProgressBar->setTotalSteps(fsz); | 230 | ProgressBar->setTotalSteps(fsz); |
231 | 231 | ||
232 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 232 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
233 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 233 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
234 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 234 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
235 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 235 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
236 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); | 236 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); |
237 | 237 | ||
238 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 238 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
239 | QString msg; | 239 | QString msg; |
240 | msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn)); | 240 | msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn)); |
241 | QMessageBox::message("Note",msg); | 241 | QMessageBox::message("Note",msg); |
242 | FtpQuit(conn); | 242 | FtpQuit(conn); |
243 | } | 243 | } |
244 | ProgressBar->reset(); | 244 | ProgressBar->reset(); |
245 | } else { | 245 | } else { |
246 | QMessageBox::message("Note","Cannot upload directories"); | 246 | QMessageBox::message("Note","Cannot upload directories"); |
247 | } | 247 | } |
248 | TabWidget->setCurrentPage(1); | 248 | TabWidget->setCurrentPage(1); |
249 | populateRemoteView(); | 249 | populateRemoteView(); |
250 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 250 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
251 | } | 251 | } |
252 | 252 | ||
253 | void OpieFtp::remoteDownload() | 253 | void OpieFtp::remoteDownload() |
254 | { | 254 | { |
255 | int fsz; | 255 | int fsz; |
256 | QCopEnvelope ( "QPE/System", "busy()" ); | 256 | QCopEnvelope ( "QPE/System", "busy()" ); |
257 | qApp->processEvents(); | 257 | qApp->processEvents(); |
258 | QString strItem = Remote_View->currentItem()->text(0); | 258 | QString strItem = Remote_View->currentItem()->text(0); |
259 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 259 | QString localFile = currentDir.canonicalPath()+"/"+strItem; |
260 | QString remoteFile= currentRemoteDir+strItem; | 260 | QString remoteFile= currentRemoteDir+strItem; |
261 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 261 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
262 | fsz = 0; | 262 | fsz = 0; |
263 | QString temp; | 263 | QString temp; |
264 | temp.sprintf( remoteFile+" "+" %dkb", fsz); | 264 | temp.sprintf( remoteFile+" "+" %dkb", fsz); |
265 | 265 | ||
266 | ProgressBar->setTotalSteps(fsz); | 266 | ProgressBar->setTotalSteps(fsz); |
267 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 267 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
268 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 268 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
269 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 269 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
270 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 270 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
271 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); | 271 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); |
272 | 272 | ||
273 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 273 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
274 | QString msg; | 274 | QString msg; |
275 | msg.sprintf("Unable to download \n%s",FtpLastResponse(conn)); | 275 | msg.sprintf("Unable to download \n%s",FtpLastResponse(conn)); |
276 | QMessageBox::message("Note",msg); | 276 | QMessageBox::message("Note",msg); |
277 | FtpQuit(conn); | 277 | FtpQuit(conn); |
278 | } | 278 | } |
279 | ProgressBar->reset(); | 279 | ProgressBar->reset(); |
280 | TabWidget->setCurrentPage(0); | 280 | TabWidget->setCurrentPage(0); |
281 | populateLocalView(); | 281 | populateLocalView(); |
282 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 282 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
283 | } | 283 | } |
284 | 284 | ||
285 | 285 | ||
286 | void OpieFtp::newConnection() | 286 | void OpieFtp::newConnection() |
287 | { | 287 | { |
288 | TabWidget->setCurrentPage(2); | 288 | TabWidget->setCurrentPage(2); |
289 | } | 289 | } |
290 | 290 | ||
291 | void OpieFtp::connector() | 291 | void OpieFtp::connector() |
292 | { | 292 | { |
293 | QCopEnvelope ( "QPE/System", "busy()" ); | 293 | QCopEnvelope ( "QPE/System", "busy()" ); |
294 | qApp->processEvents(); | 294 | qApp->processEvents(); |
295 | currentRemoteDir=remotePath->text(); | 295 | currentRemoteDir=remotePath->text(); |
296 | if(ServerComboBox->currentText().isEmpty()) { | 296 | if(ServerComboBox->currentText().isEmpty()) { |
297 | QMessageBox::warning(this,"Ftp","Please set the server info","Ok",0,0); | 297 | QMessageBox::warning(this,"Ftp","Please set the server info","Ok",0,0); |
298 | TabWidget->setCurrentPage(2); | 298 | TabWidget->setCurrentPage(2); |
299 | ServerComboBox->setFocus(); | 299 | ServerComboBox->setFocus(); |
300 | return; | 300 | return; |
301 | } | 301 | } |
302 | FtpInit(); | 302 | FtpInit(); |
303 | TabWidget->setCurrentPage(1); | 303 | TabWidget->setCurrentPage(1); |
304 | QString ftp_host = ServerComboBox->currentText(); | 304 | QString ftp_host = ServerComboBox->currentText(); |
305 | QString ftp_user = UsernameComboBox->currentText(); | 305 | QString ftp_user = UsernameComboBox->currentText(); |
306 | QString ftp_pass = PasswordEdit->text(); | 306 | QString ftp_pass = PasswordEdit->text(); |
307 | QString port=PortSpinBox->cleanText(); | 307 | QString port=PortSpinBox->cleanText(); |
308 | port.stripWhiteSpace(); | 308 | port.stripWhiteSpace(); |
309 | 309 | ||
310 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) | 310 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) |
311 | ftp_host=ftp_host.right(ftp_host.length()-6); | 311 | ftp_host=ftp_host.right(ftp_host.length()-6); |
312 | ftp_host+=":"+port; | 312 | ftp_host+=":"+port; |
313 | if (!FtpConnect( ftp_host.latin1(), &conn)) { | 313 | if (!FtpConnect( ftp_host.latin1(), &conn)) { |
314 | QMessageBox::message("Note","Unable to connect to\n"+ftp_host); | 314 | QMessageBox::message("Note","Unable to connect to\n"+ftp_host); |
315 | return ; | 315 | return ; |
316 | } | 316 | } |
317 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { | 317 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { |
318 | QString msg; | 318 | QString msg; |
319 | msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); | 319 | msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); |
320 | QMessageBox::message("Note",msg); | 320 | QMessageBox::message("Note",msg); |
321 | FtpQuit(conn); | 321 | FtpQuit(conn); |
322 | return ; | 322 | return ; |
323 | } | 323 | } |
324 | remoteDirList("/") ; | 324 | remoteDirList("/") ; |
325 | setCaption(ftp_host); | 325 | setCaption(ftp_host); |
326 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 326 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
327 | } | 327 | } |
328 | 328 | ||
329 | void OpieFtp::disConnector() | 329 | void OpieFtp::disConnector() |
330 | { | 330 | { |
331 | FtpQuit(conn); | 331 | FtpQuit(conn); |
332 | setCaption("OpieFtp"); | 332 | setCaption("OpieFtp"); |
333 | currentRemoteDir="/"; | 333 | currentRemoteDir="/"; |
334 | Remote_View->clear(); | 334 | Remote_View->clear(); |
335 | } | 335 | } |
336 | 336 | ||
337 | bool OpieFtp::remoteDirList(const QString &dir) | 337 | bool OpieFtp::remoteDirList(const QString &dir) |
338 | { | 338 | { |
339 | QCopEnvelope ( "QPE/System", "busy()" ); | 339 | QCopEnvelope ( "QPE/System", "busy()" ); |
340 | if (!FtpDir( "./._temp", dir.latin1(), conn) ) { | 340 | if (!FtpDir( "./._temp", dir.latin1(), conn) ) { |
341 | QString msg; | 341 | QString msg; |
342 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) ); | 342 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) ); |
343 | QMessageBox::message("Note",msg); | 343 | QMessageBox::message("Note",msg); |
344 | FtpQuit(conn); | 344 | FtpQuit(conn); |
345 | return false; | 345 | return false; |
346 | } | 346 | } |
347 | populateRemoteView(); | 347 | populateRemoteView(); |
348 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 348 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
349 | return true; | 349 | return true; |
350 | } | 350 | } |
351 | 351 | ||
352 | bool OpieFtp::remoteChDir(const QString &dir) | 352 | bool OpieFtp::remoteChDir(const QString &dir) |
353 | { | 353 | { |
354 | QCopEnvelope ( "QPE/System", "busy()" ); | 354 | QCopEnvelope ( "QPE/System", "busy()" ); |
355 | if (!FtpChdir( dir.latin1(), conn )) { | 355 | if (!FtpChdir( dir.latin1(), conn )) { |
356 | QString msg; | 356 | QString msg; |
357 | msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); | 357 | msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); |
358 | QMessageBox::message("Note",msg); | 358 | QMessageBox::message("Note",msg); |
359 | FtpQuit(conn); | 359 | FtpQuit(conn); |
360 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 360 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
361 | return FALSE; | 361 | return FALSE; |
362 | } | 362 | } |
363 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 363 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
364 | return TRUE; | 364 | return TRUE; |
365 | } | 365 | } |
366 | 366 | ||
367 | void OpieFtp::populateLocalView() | 367 | void OpieFtp::populateLocalView() |
368 | { | 368 | { |
369 | Local_View->clear(); | 369 | Local_View->clear(); |
370 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 370 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
371 | currentDir.setMatchAllDirs(TRUE); | 371 | currentDir.setMatchAllDirs(TRUE); |
372 | currentDir.setNameFilter(filterStr); | 372 | currentDir.setNameFilter(filterStr); |
373 | QString fileL, fileS, fileDate; | 373 | QString fileL, fileS, fileDate; |
374 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 374 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
375 | QFileInfoListIterator it(*list); | 375 | QFileInfoListIterator it(*list); |
376 | QFileInfo *fi; | 376 | QFileInfo *fi; |
377 | while ( (fi=it.current()) ) { | 377 | while ( (fi=it.current()) ) { |
378 | if (fi->isSymLink() ){ | 378 | if (fi->isSymLink() ){ |
379 | QString symLink=fi->readLink(); | 379 | QString symLink=fi->readLink(); |
380 | // qDebug("Symlink detected "+symLink); | 380 | // qDebug("Symlink detected "+symLink); |
381 | QFileInfo sym( symLink); | 381 | QFileInfo sym( symLink); |
382 | fileS.sprintf( "%10li", sym.size() ); | 382 | fileS.sprintf( "%10li", sym.size() ); |
383 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 383 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
384 | fileDate = sym.lastModified().toString(); | 384 | fileDate = sym.lastModified().toString(); |
385 | } else { | 385 | } else { |
386 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 386 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
387 | fileS.sprintf( "%10li", fi->size() ); | 387 | fileS.sprintf( "%10li", fi->size() ); |
388 | fileL.sprintf( "%s",fi->fileName().data() ); | 388 | fileL.sprintf( "%s",fi->fileName().data() ); |
389 | fileDate= fi->lastModified().toString(); | 389 | fileDate= fi->lastModified().toString(); |
390 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 390 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
391 | fileL+="/"; | 391 | fileL+="/"; |
392 | // qDebug( fileL); | 392 | // qDebug( fileL); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | item= new QListViewItem( Local_View,fileL,fileS, fileDate); | 395 | item= new QListViewItem( Local_View,fileL,fileS, fileDate); |
396 | ++it; | 396 | ++it; |
397 | } | 397 | } |
398 | Local_View->setSorting( 3,FALSE); | 398 | Local_View->setSorting( 3,FALSE); |
399 | currentPathEdit->setText( currentDir.canonicalPath() ); | 399 | currentPathEdit->setText( currentDir.canonicalPath() ); |
400 | } | 400 | } |
401 | 401 | ||
402 | bool OpieFtp::populateRemoteView() | 402 | bool OpieFtp::populateRemoteView() |
403 | { | 403 | { |
404 | Remote_View->clear(); | 404 | Remote_View->clear(); |
405 | QFile tmp("./._temp"); | 405 | QFile tmp("./._temp"); |
406 | QString s, File_Name; | 406 | QString s, File_Name; |
407 | QString fileL, fileS, fileDate; | 407 | QString fileL, fileS, fileDate; |
408 | new QListViewItem( Remote_View, "../"); | 408 | new QListViewItem( Remote_View, "../"); |
409 | if (tmp.open(IO_ReadOnly)) { | 409 | if (tmp.open(IO_ReadOnly)) { |
410 | QTextStream t( &tmp ); // use a text stream | 410 | QTextStream t( &tmp ); // use a text stream |
411 | while ( !t.eof()) { | 411 | while ( !t.eof()) { |
412 | s = t.readLine(); | 412 | s = t.readLine(); |
413 | fileL = s.right(s.length()-55); | 413 | fileL = s.right(s.length()-55); |
414 | fileL = fileL.stripWhiteSpace(); | 414 | fileL = fileL.stripWhiteSpace(); |
415 | if(s.left(1) == "d") | 415 | if(s.left(1) == "d") |
416 | fileL = fileL+"/"; | 416 | fileL = fileL+"/"; |
417 | fileS = s.mid( 30, 42-30); | 417 | fileS = s.mid( 30, 42-30); |
418 | fileS = fileS.stripWhiteSpace(); | 418 | fileS = fileS.stripWhiteSpace(); |
419 | fileDate = s.mid( 42, 55-42); | 419 | fileDate = s.mid( 42, 55-42); |
420 | fileDate = fileDate.stripWhiteSpace(); | 420 | fileDate = fileDate.stripWhiteSpace(); |
421 | if(fileL.find("total",0,TRUE) == -1) | 421 | if(fileL.find("total",0,TRUE) == -1) |
422 | new QListViewItem( Remote_View, fileL, fileS, fileDate); | 422 | new QListViewItem( Remote_View, fileL, fileS, fileDate); |
423 | } | 423 | } |
424 | tmp.close(); | 424 | tmp.close(); |
425 | } | 425 | } |
426 | return true; | 426 | return true; |
427 | } | 427 | } |
428 | 428 | ||
429 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 429 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
430 | { | 430 | { |
431 | QCopEnvelope ( "QPE/System", "busy()" ); | 431 | QCopEnvelope ( "QPE/System", "busy()" ); |
432 | QString strItem=selectedItem->text(0); | 432 | QString strItem=selectedItem->text(0); |
433 | strItem=strItem.simplifyWhiteSpace(); | 433 | strItem=strItem.simplifyWhiteSpace(); |
434 | if(strItem == "../") { | 434 | if(strItem == "../") { |
435 | if( FtpCDUp( conn) == 0) { | 435 | if( FtpCDUp( conn) == 0) { |
436 | QString msg; | 436 | QString msg; |
437 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); | 437 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); |
438 | QMessageBox::message("Note",msg); | 438 | QMessageBox::message("Note",msg); |
439 | } | 439 | } |
440 | char path[256]; | 440 | char path[256]; |
441 | if( FtpPwd( path,sizeof(path),conn) == 0) { | 441 | if( FtpPwd( path,sizeof(path),conn) == 0) { |
442 | QString msg; | 442 | QString msg; |
443 | msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn)); | 443 | msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn)); |
444 | QMessageBox::message("Note",msg); | 444 | QMessageBox::message("Note",msg); |
445 | } | 445 | } |
446 | currentRemoteDir=path; | 446 | currentRemoteDir=path; |
447 | } else { | 447 | } else { |
448 | if(strItem.find("/",0,TRUE) != -1) { | 448 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
449 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE)-3 ); | ||
450 | strItem = strItem.stripWhiteSpace(); | ||
451 | currentRemoteDir = strItem; | ||
452 | if( remoteChDir( (const QString &)strItem) ==0) { | ||
453 | QString msg; | ||
454 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); | ||
455 | QMessageBox::message("Note",msg); | ||
456 | } | ||
457 | } else if(strItem.find("/",0,TRUE) != -1) { | ||
449 | if( remoteChDir( (const QString &)currentRemoteDir+strItem) ==0) { | 458 | if( remoteChDir( (const QString &)currentRemoteDir+strItem) ==0) { |
450 | QString msg; | 459 | QString msg; |
451 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); | 460 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); |
452 | QMessageBox::message("Note",msg); | 461 | QMessageBox::message("Note",msg); |
453 | } | 462 | } |
454 | currentRemoteDir = currentRemoteDir+strItem; | 463 | currentRemoteDir = currentRemoteDir+strItem; |
455 | } else { | 464 | } else { |
456 | qDebug("download "+strItem); | 465 | qDebug("download "+strItem); |
457 | } | 466 | } |
458 | } | 467 | } |
459 | if(currentRemoteDir.right(1) !="/") | 468 | if(currentRemoteDir.right(1) !="/") |
460 | currentRemoteDir +="/"; | 469 | currentRemoteDir +="/"; |
461 | currentPathEdit->setText( currentRemoteDir ); | 470 | currentPathEdit->setText( currentRemoteDir ); |
462 | remoteDirList( (const QString &)currentRemoteDir); | 471 | remoteDirList( (const QString &)currentRemoteDir); |
463 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 472 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
464 | } | 473 | } |
465 | 474 | ||
466 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 475 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
467 | { | 476 | { |
468 | QString strItem=selectedItem->text(0); | 477 | QString strItem=selectedItem->text(0); |
469 | QString strSize=selectedItem->text(1); | 478 | QString strSize=selectedItem->text(1); |
470 | strSize=strSize.stripWhiteSpace(); | 479 | strSize=strSize.stripWhiteSpace(); |
471 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 480 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
472 | // is symlink | 481 | // is symlink |
473 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 482 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
474 | if(QDir(strItem2).exists() ) { | 483 | if(QDir(strItem2).exists() ) { |
475 | currentDir.cd(strItem2, TRUE); | 484 | currentDir.cd(strItem2, TRUE); |
476 | populateLocalView(); | 485 | populateLocalView(); |
477 | } | 486 | } |
478 | } else { // not a symlink | 487 | } else { // not a symlink |
479 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 488 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
480 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 489 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
481 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 490 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
482 | currentDir.cd(strItem,FALSE); | 491 | currentDir.cd(strItem,FALSE); |
483 | populateLocalView(); | 492 | populateLocalView(); |
484 | } else { | 493 | } else { |
485 | currentDir.cdUp(); | 494 | currentDir.cdUp(); |
486 | populateLocalView(); | 495 | populateLocalView(); |
487 | } | 496 | } |
488 | if(QDir(strItem).exists()){ | 497 | if(QDir(strItem).exists()){ |
489 | currentDir.cd(strItem, TRUE); | 498 | currentDir.cd(strItem, TRUE); |
490 | populateLocalView(); | 499 | populateLocalView(); |
491 | } | 500 | } |
492 | } else { | 501 | } else { |
493 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 502 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
494 | if( QFile::exists(strItem ) ) { | 503 | if( QFile::exists(strItem ) ) { |
495 | qDebug("upload "+strItem); | 504 | qDebug("upload "+strItem); |
496 | } | 505 | } |
497 | } //end not symlink | 506 | } //end not symlink |
498 | chdir(strItem.latin1()); | 507 | chdir(strItem.latin1()); |
499 | } | 508 | } |
500 | } | 509 | } |
501 | 510 | ||
502 | void OpieFtp::showHidden() | 511 | void OpieFtp::showHidden() |
503 | { | 512 | { |
504 | if (!b) { | 513 | if (!b) { |
505 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 514 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
506 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 515 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
507 | b=TRUE; | 516 | b=TRUE; |
508 | 517 | ||
509 | } else { | 518 | } else { |
510 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 519 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
511 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 520 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
512 | b=FALSE; | 521 | b=FALSE; |
513 | } | 522 | } |
514 | populateLocalView(); | 523 | populateLocalView(); |
515 | } | 524 | } |
516 | 525 | ||
517 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 526 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
518 | { | 527 | { |
519 | switch (mouse) { | 528 | switch (mouse) { |
520 | case 1: | 529 | case 1: |
521 | break; | 530 | break; |
522 | case 2: | 531 | case 2: |
523 | showLocalMenu(); | 532 | showLocalMenu(); |
524 | break; | 533 | break; |
525 | }; | 534 | }; |
526 | } | 535 | } |
527 | 536 | ||
528 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 537 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
529 | { | 538 | { |
530 | switch (mouse) { | 539 | switch (mouse) { |
531 | case 1: | 540 | case 1: |
532 | break; | 541 | break; |
533 | case 2: | 542 | case 2: |
534 | showRemoteMenu(); | 543 | showRemoteMenu(); |
535 | break; | 544 | break; |
536 | }; | 545 | }; |
537 | } | 546 | } |
538 | 547 | ||
539 | void OpieFtp::showRemoteMenu() | 548 | void OpieFtp::showRemoteMenu() |
540 | { | 549 | { |
541 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 550 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
542 | m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 551 | m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
543 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 552 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
544 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 553 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
545 | m.insertSeparator(); | 554 | m.insertSeparator(); |
546 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 555 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
547 | m.exec( QCursor::pos() ); | 556 | m.exec( QCursor::pos() ); |
548 | } | 557 | } |
549 | 558 | ||
550 | void OpieFtp::showLocalMenu() | 559 | void OpieFtp::showLocalMenu() |
551 | { | 560 | { |
552 | QPopupMenu m; | 561 | QPopupMenu m; |
553 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 562 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
554 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 563 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
555 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 564 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
556 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 565 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
557 | m.insertSeparator(); | 566 | m.insertSeparator(); |
558 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 567 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
559 | m.exec( QCursor::pos() ); | 568 | m.exec( QCursor::pos() ); |
560 | } | 569 | } |
561 | 570 | ||
562 | void OpieFtp::localMakDir() | 571 | void OpieFtp::localMakDir() |
563 | { | 572 | { |
564 | InputDialog *fileDlg; | 573 | InputDialog *fileDlg; |
565 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 574 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
566 | fileDlg->exec(); | 575 | fileDlg->exec(); |
567 | if( fileDlg->result() == 1 ) { | 576 | if( fileDlg->result() == 1 ) { |
568 | QString filename = fileDlg->LineEdit1->text(); | 577 | QString filename = fileDlg->LineEdit1->text(); |
569 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 578 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
570 | } | 579 | } |
571 | populateLocalView(); | 580 | populateLocalView(); |
572 | } | 581 | } |
573 | 582 | ||
574 | void OpieFtp::localDelete() | 583 | void OpieFtp::localDelete() |
575 | { | 584 | { |
576 | QString f = Local_View->currentItem()->text(0); | 585 | QString f = Local_View->currentItem()->text(0); |
577 | if(QDir(f).exists() ) { | 586 | if(QDir(f).exists() ) { |
578 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ | 587 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ |
579 | " ?\nIt must be empty","Yes","No",0,0,1) ) { | 588 | " ?\nIt must be empty","Yes","No",0,0,1) ) { |
580 | case 0: { | 589 | case 0: { |
581 | f=currentDir.canonicalPath()+"/"+f; | 590 | f=currentDir.canonicalPath()+"/"+f; |
582 | QString cmd="rmdir "+f; | 591 | QString cmd="rmdir "+f; |
583 | system( cmd.latin1()); | 592 | system( cmd.latin1()); |
584 | populateLocalView(); | 593 | populateLocalView(); |
585 | } | 594 | } |
586 | break; | 595 | break; |
587 | case 1: | 596 | case 1: |
588 | // exit | 597 | // exit |
589 | break; | 598 | break; |
590 | }; | 599 | }; |
591 | 600 | ||
592 | } else { | 601 | } else { |
593 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f | 602 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f |
594 | +" ?","Yes","No",0,0,1) ) { | 603 | +" ?","Yes","No",0,0,1) ) { |
595 | case 0: { | 604 | case 0: { |
596 | f=currentDir.canonicalPath()+"/"+f; | 605 | f=currentDir.canonicalPath()+"/"+f; |
597 | QString cmd="rm "+f; | 606 | QString cmd="rm "+f; |
598 | system( cmd.latin1()); | 607 | system( cmd.latin1()); |
599 | populateLocalView(); | 608 | populateLocalView(); |
600 | } | 609 | } |
601 | break; | 610 | break; |
602 | case 1: | 611 | case 1: |
603 | // exit | 612 | // exit |
604 | break; | 613 | break; |
605 | }; | 614 | }; |
606 | } | 615 | } |
607 | } | 616 | } |
608 | 617 | ||
609 | void OpieFtp::remoteMakDir() | 618 | void OpieFtp::remoteMakDir() |
610 | { | 619 | { |
611 | InputDialog *fileDlg; | 620 | InputDialog *fileDlg; |
612 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 621 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
613 | fileDlg->exec(); | 622 | fileDlg->exec(); |
614 | if( fileDlg->result() == 1 ) { | 623 | if( fileDlg->result() == 1 ) { |
615 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; | 624 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; |
616 | QString tmp=currentRemoteDir+filename; | 625 | QString tmp=currentRemoteDir+filename; |
617 | QCopEnvelope ( "QPE/System", "busy()" ); | 626 | QCopEnvelope ( "QPE/System", "busy()" ); |
618 | if(FtpMkdir( tmp.latin1(), conn) == 0) { | 627 | if(FtpMkdir( tmp.latin1(), conn) == 0) { |
619 | QString msg; | 628 | QString msg; |
620 | msg.sprintf("Unable to make directory\n%s",FtpLastResponse(conn)); | 629 | msg.sprintf("Unable to make directory\n%s",FtpLastResponse(conn)); |
621 | QMessageBox::message("Note",msg); | 630 | QMessageBox::message("Note",msg); |
622 | } | 631 | } |
623 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 632 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
624 | } | 633 | } |
625 | populateRemoteView(); | 634 | populateRemoteView(); |
626 | } | 635 | } |
627 | 636 | ||
628 | void OpieFtp::remoteDelete() | 637 | void OpieFtp::remoteDelete() |
629 | { | 638 | { |
630 | QString f = Remote_View->currentItem()->text(0); | 639 | QString f = Remote_View->currentItem()->text(0); |
631 | QCopEnvelope ( "QPE/System", "busy()" ); | 640 | QCopEnvelope ( "QPE/System", "busy()" ); |
632 | if( f.right(1) =="/") { | 641 | if( f.right(1) =="/") { |
633 | QString path= currentRemoteDir+f; | 642 | QString path= currentRemoteDir+f; |
634 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?" | 643 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?" |
635 | ,"Yes","No",0,0,1) ) { | 644 | ,"Yes","No",0,0,1) ) { |
636 | case 0: { | 645 | case 0: { |
637 | f=currentDir.canonicalPath()+"/"+f; | 646 | f=currentDir.canonicalPath()+"/"+f; |
638 | if(FtpRmdir( path.latin1(), conn) ==0) { | 647 | if(FtpRmdir( path.latin1(), conn) ==0) { |
639 | QString msg; | 648 | QString msg; |
640 | msg.sprintf("Unable to remove directory\n%s",FtpLastResponse(conn)); | 649 | msg.sprintf("Unable to remove directory\n%s",FtpLastResponse(conn)); |
641 | QMessageBox::message("Note",msg); | 650 | QMessageBox::message("Note",msg); |
642 | } | 651 | } |
643 | } | 652 | } |
644 | break; | 653 | break; |
645 | }; | 654 | }; |
646 | } else { | 655 | } else { |
647 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?" | 656 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?" |
648 | ,"Yes","No",0,0,1) ) { | 657 | ,"Yes","No",0,0,1) ) { |
649 | case 0: { | 658 | case 0: { |
650 | QString path= currentRemoteDir+f; | 659 | QString path= currentRemoteDir+f; |
651 | if(FtpDelete( path.latin1(), conn)==0) { | 660 | if(FtpDelete( path.latin1(), conn)==0) { |
652 | QString msg; | 661 | QString msg; |
653 | msg.sprintf("Unable to delete file\n%s",FtpLastResponse(conn)); | 662 | msg.sprintf("Unable to delete file\n%s",FtpLastResponse(conn)); |
654 | QMessageBox::message("Note",msg); | 663 | QMessageBox::message("Note",msg); |
655 | } | 664 | } |
656 | } | 665 | } |
657 | break; | 666 | break; |
658 | }; | 667 | }; |
659 | } | 668 | } |
660 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 669 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
661 | } | 670 | } |
662 | 671 | ||
663 | void OpieFtp::remoteRename() | 672 | void OpieFtp::remoteRename() |
664 | { | 673 | { |
665 | QString curFile = Remote_View->currentItem()->text(0); | 674 | QString curFile = Remote_View->currentItem()->text(0); |
666 | InputDialog *fileDlg; | 675 | InputDialog *fileDlg; |
667 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | 676 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
668 | fileDlg->inputText = curFile; | 677 | fileDlg->inputText = curFile; |
669 | fileDlg->exec(); | 678 | fileDlg->exec(); |
670 | if( fileDlg->result() == 1 ) { | 679 | if( fileDlg->result() == 1 ) { |
671 | QString oldName = currentRemoteDir +"/"+ curFile; | 680 | QString oldName = currentRemoteDir +"/"+ curFile; |
672 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; | 681 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; |
673 | QCopEnvelope ( "QPE/System", "busy()" ); | 682 | QCopEnvelope ( "QPE/System", "busy()" ); |
674 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { | 683 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { |
675 | QString msg; | 684 | QString msg; |
676 | msg.sprintf("Unable to rename file\n%s",FtpLastResponse(conn)); | 685 | msg.sprintf("Unable to rename file\n%s",FtpLastResponse(conn)); |
677 | QMessageBox::message("Note",msg); | 686 | QMessageBox::message("Note",msg); |
678 | } | 687 | } |
679 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 688 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
680 | } | 689 | } |
681 | populateRemoteView(); | 690 | populateRemoteView(); |
682 | } | 691 | } |
683 | 692 | ||
684 | void OpieFtp::localRename() | 693 | void OpieFtp::localRename() |
685 | { | 694 | { |
686 | QString curFile = Local_View->currentItem()->text(0); | 695 | QString curFile = Local_View->currentItem()->text(0); |
687 | InputDialog *fileDlg; | 696 | InputDialog *fileDlg; |
688 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | 697 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
689 | fileDlg->inputText = curFile; | 698 | fileDlg->inputText = curFile; |
690 | fileDlg->exec(); | 699 | fileDlg->exec(); |
691 | if( fileDlg->result() == 1 ) { | 700 | if( fileDlg->result() == 1 ) { |
692 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 701 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
693 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 702 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
694 | if( rename(oldname.latin1(), newName.latin1())== -1) | 703 | if( rename(oldname.latin1(), newName.latin1())== -1) |
695 | QMessageBox::message("Note","Could not rename"); | 704 | QMessageBox::message("Note","Could not rename"); |
696 | } | 705 | } |
697 | populateLocalView(); | 706 | populateLocalView(); |
698 | } | 707 | } |
699 | 708 | ||
700 | void OpieFtp::currentPathEditChanged() | 709 | void OpieFtp::currentPathEditChanged() |
701 | { | 710 | { |
702 | if (TabWidget->currentPageIndex() == 0) { | 711 | if (TabWidget->currentPageIndex() == 0) { |
703 | if(QDir( currentPathEdit->text()).exists()) { | 712 | if(QDir( currentPathEdit->text()).exists()) { |
704 | currentDir.setPath( currentPathEdit->text() ); | 713 | currentDir.setPath( currentPathEdit->text() ); |
705 | populateLocalView(); | 714 | populateLocalView(); |
706 | } else { | 715 | } else { |
707 | QMessageBox::message("Note","That directory does not exist"); | 716 | QMessageBox::message("Note","That directory does not exist"); |
708 | } | 717 | } |
709 | } | 718 | } |
710 | if (TabWidget->currentPageIndex() == 1) { | 719 | if (TabWidget->currentPageIndex() == 1) { |
711 | currentRemoteDir = currentPathEdit->text(); | 720 | currentRemoteDir = currentPathEdit->text(); |
712 | if(currentRemoteDir.right(1) !="/") { | 721 | if(currentRemoteDir.right(1) !="/") { |
713 | currentRemoteDir = currentRemoteDir +"/"; | 722 | currentRemoteDir = currentRemoteDir +"/"; |
714 | currentPathEdit->setText( currentRemoteDir ); | 723 | currentPathEdit->setText( currentRemoteDir ); |
715 | } | 724 | } |
716 | remoteChDir( (const QString &)currentRemoteDir); | 725 | remoteChDir( (const QString &)currentRemoteDir); |
717 | remoteDirList( (const QString &)currentRemoteDir); | 726 | remoteDirList( (const QString &)currentRemoteDir); |
718 | } | 727 | } |
719 | } | 728 | } |