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