author | llornkcor <llornkcor> | 2002-03-17 01:20:09 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-17 01:20:09 (UTC) |
commit | 2fe80a98551e89b45798369f1bf91f0368382ba6 (patch) (unidiff) | |
tree | a09d8dd51306563faf3496a05cbaca987665b365 | |
parent | 6fa31a92ee5ae6b4e9df2713b0ed7b8fb39fff49 (diff) | |
download | opie-2fe80a98551e89b45798369f1bf91f0368382ba6.zip opie-2fe80a98551e89b45798369f1bf91f0368382ba6.tar.gz opie-2fe80a98551e89b45798369f1bf91f0368382ba6.tar.bz2 |
fixed problem with remote directory not being listed after an upload, and fixed
problem with temp file poop with strewn throughout the local filesystem.
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 79 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.h | 6 |
2 files changed, 53 insertions, 32 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 042ed59..6a3a64d 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -1,846 +1,867 @@ | |||
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 | setCaption( tr( "OpieFtp" ) ); | 65 | setCaption( tr( "OpieFtp" ) ); |
66 | 66 | ||
67 | QGridLayout *layout = new QGridLayout( this ); | 67 | QGridLayout *layout = new QGridLayout( this ); |
68 | layout->setSpacing( 2); | 68 | layout->setSpacing( 2); |
69 | layout->setMargin( 2); | 69 | layout->setMargin( 2); |
70 | 70 | ||
71 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 71 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
72 | 72 | ||
73 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 73 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
74 | connectionMenu = new QPopupMenu( this ); | 74 | connectionMenu = new QPopupMenu( this ); |
75 | localMenu = new QPopupMenu( this ); | 75 | localMenu = new QPopupMenu( this ); |
76 | remoteMenu = new QPopupMenu( this ); | 76 | remoteMenu = new QPopupMenu( this ); |
77 | tabMenu = new QPopupMenu( this ); | 77 | tabMenu = new QPopupMenu( this ); |
78 | 78 | ||
79 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); | 79 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); |
80 | 80 | ||
81 | menuBar->insertItem( tr( "Connection" ), connectionMenu); | 81 | menuBar->insertItem( tr( "Connection" ), connectionMenu); |
82 | menuBar->insertItem( tr( "Local" ), localMenu); | 82 | menuBar->insertItem( tr( "Local" ), localMenu); |
83 | menuBar->insertItem( tr( "Remote" ), remoteMenu); | 83 | menuBar->insertItem( tr( "Remote" ), remoteMenu); |
84 | menuBar->insertItem( tr( "View" ), tabMenu); | 84 | menuBar->insertItem( tr( "View" ), tabMenu); |
85 | 85 | ||
86 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 86 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
87 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 87 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
88 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 88 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
89 | 89 | ||
90 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 90 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
91 | localMenu->insertSeparator(); | 91 | localMenu->insertSeparator(); |
92 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 92 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
93 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 93 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
94 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 94 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
95 | localMenu->insertSeparator(); | 95 | localMenu->insertSeparator(); |
96 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 96 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
97 | 97 | ||
98 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 98 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
99 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 99 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
100 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 100 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
101 | remoteMenu->insertSeparator(); | 101 | remoteMenu->insertSeparator(); |
102 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 102 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
103 | 103 | ||
104 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 104 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
105 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 105 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
106 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); | 106 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); |
107 | 107 | ||
108 | TabWidget = new QTabWidget( this, "TabWidget" ); | 108 | TabWidget = new QTabWidget( this, "TabWidget" ); |
109 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); | 109 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); |
110 | 110 | ||
111 | TabWidget->setTabShape(QTabWidget::Triangular); | 111 | TabWidget->setTabShape(QTabWidget::Triangular); |
112 | 112 | ||
113 | tab = new QWidget( TabWidget, "tab" ); | 113 | tab = new QWidget( TabWidget, "tab" ); |
114 | tabLayout = new QGridLayout( tab ); | 114 | tabLayout = new QGridLayout( tab ); |
115 | tabLayout->setSpacing( 2); | 115 | tabLayout->setSpacing( 2); |
116 | tabLayout->setMargin( 2); | 116 | tabLayout->setMargin( 2); |
117 | 117 | ||
118 | Local_View = new QListView( tab, "Local_View" ); | 118 | Local_View = new QListView( tab, "Local_View" ); |
119 | // Local_View->setResizePolicy( QListView::AutoOneFit ); | 119 | // Local_View->setResizePolicy( QListView::AutoOneFit ); |
120 | Local_View->addColumn( "File",120); | 120 | Local_View->addColumn( "File",120); |
121 | Local_View->addColumn( "Size",-1); | 121 | Local_View->addColumn( "Size",-1); |
122 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 122 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
123 | Local_View->addColumn( "Date",-1); | 123 | Local_View->addColumn( "Date",-1); |
124 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 124 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
125 | Local_View->setAllColumnsShowFocus(TRUE); | 125 | Local_View->setAllColumnsShowFocus(TRUE); |
126 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 126 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
127 | 127 | ||
128 | tabLayout->addWidget( Local_View, 0, 0 ); | 128 | tabLayout->addWidget( Local_View, 0, 0 ); |
129 | 129 | ||
130 | connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), | 130 | connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), |
131 | this,SLOT( localListClicked(QListViewItem *)) ); | 131 | this,SLOT( localListClicked(QListViewItem *)) ); |
132 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 132 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
133 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 133 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
134 | 134 | ||
135 | TabWidget->insertTab( tab, tr( "Local" ) ); | 135 | TabWidget->insertTab( tab, tr( "Local" ) ); |
136 | 136 | ||
137 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 137 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
138 | tabLayout_2 = new QGridLayout( tab_2 ); | 138 | tabLayout_2 = new QGridLayout( tab_2 ); |
139 | tabLayout_2->setSpacing( 2); | 139 | tabLayout_2->setSpacing( 2); |
140 | tabLayout_2->setMargin( 2); | 140 | tabLayout_2->setMargin( 2); |
141 | 141 | ||
142 | Remote_View = new QListView( tab_2, "Remote_View" ); | 142 | Remote_View = new QListView( tab_2, "Remote_View" ); |
143 | Remote_View->addColumn( "File",120); | 143 | Remote_View->addColumn( "File",120); |
144 | Remote_View->addColumn( "Size",-1); | 144 | Remote_View->addColumn( "Size",-1); |
145 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 145 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
146 | Remote_View->addColumn( "Date",-1); | 146 | Remote_View->addColumn( "Date",-1); |
147 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 147 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
148 | Remote_View->setAllColumnsShowFocus(TRUE); | 148 | Remote_View->setAllColumnsShowFocus(TRUE); |
149 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 149 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
150 | 150 | ||
151 | connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)), | 151 | connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)), |
152 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 152 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
153 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 153 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
154 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 154 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
155 | 155 | ||
156 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 156 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
157 | 157 | ||
158 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); | 158 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); |
159 | 159 | ||
160 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 160 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
161 | tabLayout_3 = new QGridLayout( tab_3 ); | 161 | tabLayout_3 = new QGridLayout( tab_3 ); |
162 | tabLayout_3->setSpacing( 2); | 162 | tabLayout_3->setSpacing( 2); |
163 | tabLayout_3->setMargin( 2); | 163 | tabLayout_3->setMargin( 2); |
164 | 164 | ||
165 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); | 165 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); |
166 | TextLabel1->setText( tr( "Username" ) ); | 166 | TextLabel1->setText( tr( "Username" ) ); |
167 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); | 167 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); |
168 | 168 | ||
169 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); | 169 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); |
170 | UsernameComboBox->setEditable(TRUE); | 170 | UsernameComboBox->setEditable(TRUE); |
171 | // UsernameComboBox->lineEdit()->setText("anonymous"); | 171 | // UsernameComboBox->lineEdit()->setText("anonymous"); |
172 | UsernameComboBox->lineEdit()->setText("root"); | 172 | UsernameComboBox->lineEdit()->setText("root"); |
173 | // UsernameComboBox->lineEdit()->setText("llornkcor"); | 173 | // UsernameComboBox->lineEdit()->setText("llornkcor"); |
174 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); | 174 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); |
175 | 175 | ||
176 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 176 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
177 | TextLabel2->setText( tr( "Password" ) ); | 177 | TextLabel2->setText( tr( "Password" ) ); |
178 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); | 178 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); |
179 | 179 | ||
180 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); | 180 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); |
181 | PasswordEdit->setEchoMode(QLineEdit::Password); | 181 | PasswordEdit->setEchoMode(QLineEdit::Password); |
182 | // PasswordEdit->setText( tr( "me@opieftp.org" ) ); | 182 | // PasswordEdit->setText( tr( "me@opieftp.org" ) ); |
183 | // PasswordEdit->setText( tr( "" ) ); | 183 | // PasswordEdit->setText( tr( "" ) ); |
184 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); | 184 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); |
185 | 185 | ||
186 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); | 186 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); |
187 | TextLabel3->setText( tr( "Remote server" ) ); | 187 | TextLabel3->setText( tr( "Remote server" ) ); |
188 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); | 188 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); |
189 | 189 | ||
190 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); | 190 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); |
191 | ServerComboBox->setEditable(TRUE); | 191 | ServerComboBox->setEditable(TRUE); |
192 | ServerComboBox->lineEdit()->setText( tr( "" ) ); | 192 | ServerComboBox->lineEdit()->setText( tr( "" ) ); |
193 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); | 193 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); |
194 | // ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); | 194 | // ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); |
195 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 195 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); |
196 | 196 | ||
197 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); | 197 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); |
198 | TextLabel5->setText( tr( "Remote path" ) ); | 198 | TextLabel5->setText( tr( "Remote path" ) ); |
199 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); | 199 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); |
200 | 200 | ||
201 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 201 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
202 | remotePath->setText( currentRemoteDir = "/"); | 202 | remotePath->setText( currentRemoteDir = "/"); |
203 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | 203 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); |
204 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); | 204 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); |
205 | 205 | ||
206 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 206 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
207 | TextLabel4->setText( tr( "Port" ) ); | 207 | TextLabel4->setText( tr( "Port" ) ); |
208 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); | 208 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); |
209 | 209 | ||
210 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); | 210 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); |
211 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 211 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
212 | PortSpinBox->setMaxValue(32786); | 212 | PortSpinBox->setMaxValue(32786); |
213 | PortSpinBox->setValue( 4242); | 213 | PortSpinBox->setValue( 4242); |
214 | // PortSpinBox->setValue( 21); | 214 | // PortSpinBox->setValue( 21); |
215 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); | 215 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); |
216 | 216 | ||
217 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 217 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
218 | tabLayout_3->addItem( spacer, 5, 0 ); | 218 | tabLayout_3->addItem( spacer, 5, 0 ); |
219 | 219 | ||
220 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 220 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
221 | 221 | ||
222 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 222 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
223 | this,SLOT(tabChanged(QWidget*))); | 223 | this,SLOT(tabChanged(QWidget*))); |
224 | 224 | ||
225 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 225 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
226 | currentDir.setPath( QDir::currentDirPath()); | 226 | currentDir.setPath( QDir::currentDirPath()); |
227 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 227 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
228 | currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); | 228 | currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); |
229 | layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); | 229 | layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); |
230 | 230 | ||
231 | currentPathEdit->setText( currentDir.canonicalPath()); | 231 | currentPathEdit->setText( currentDir.canonicalPath()); |
232 | connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); | 232 | connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); |
233 | 233 | ||
234 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 234 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
235 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); | 235 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); |
236 | 236 | ||
237 | filterStr="*"; | 237 | filterStr="*"; |
238 | populateLocalView(); | 238 | populateLocalView(); |
239 | } | 239 | } |
240 | 240 | ||
241 | OpieFtp::~OpieFtp() | 241 | OpieFtp::~OpieFtp() |
242 | { | 242 | { |
243 | } | 243 | } |
244 | 244 | ||
245 | void OpieFtp::cleanUp() | 245 | void OpieFtp::cleanUp() |
246 | { | 246 | { |
247 | if(conn) | 247 | if(conn) |
248 | FtpQuit(conn); | 248 | FtpQuit(conn); |
249 | QFile f("./._temp"); | 249 | QString sfile=QDir::homeDirPath(); |
250 | if(f.exists()) | 250 | if(sfile.right(1) != "/") |
251 | f. remove(); | 251 | sfile+="/._temp"; |
252 | else | ||
253 | sfile+="._temp"; | ||
254 | QFile file( sfile); | ||
255 | if(file.exists()) | ||
256 | file.remove(); | ||
252 | } | 257 | } |
253 | 258 | ||
254 | void OpieFtp::tabChanged(QWidget *w) | 259 | void OpieFtp::tabChanged(QWidget *w) |
255 | { | 260 | { |
256 | if (TabWidget->currentPageIndex() == 0) { | 261 | if (TabWidget->currentPageIndex() == 0) { |
257 | currentPathEdit->setText( currentDir.canonicalPath()); | 262 | currentPathEdit->setText( currentDir.canonicalPath()); |
258 | } | 263 | } |
259 | if (TabWidget->currentPageIndex() == 1) { | 264 | if (TabWidget->currentPageIndex() == 1) { |
260 | currentPathEdit->setText( currentRemoteDir ); | 265 | currentPathEdit->setText( currentRemoteDir ); |
261 | } | 266 | } |
262 | if (TabWidget->currentPageIndex() == 2) { | 267 | if (TabWidget->currentPageIndex() == 2) { |
263 | } | 268 | } |
264 | } | 269 | } |
265 | 270 | ||
266 | void OpieFtp::localUpload() | 271 | void OpieFtp::localUpload() |
267 | { | 272 | { |
268 | int fsz; | 273 | int fsz; |
269 | QCopEnvelope ( "QPE/System", "busy()" ); | 274 | QCopEnvelope ( "QPE/System", "busy()" ); |
270 | qApp->processEvents(); | 275 | qApp->processEvents(); |
271 | QString strItem = Local_View->currentItem()->text(0); | 276 | QString strItem = Local_View->currentItem()->text(0); |
272 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 277 | QString localFile = currentDir.canonicalPath()+"/"+strItem; |
273 | QString remoteFile= currentRemoteDir+strItem; | 278 | QString remoteFile= currentRemoteDir+strItem; |
274 | QFileInfo fi(localFile); | 279 | QFileInfo fi(localFile); |
275 | if( !fi.isDir()) { | 280 | if( !fi.isDir()) { |
276 | fsz=fi.size(); | 281 | fsz=fi.size(); |
277 | ProgressBar->setTotalSteps(fsz); | 282 | ProgressBar->setTotalSteps(fsz); |
278 | 283 | ||
279 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 284 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
280 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 285 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
281 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 286 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
282 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 287 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
283 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); | 288 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); |
284 | 289 | ||
285 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 290 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
286 | QString msg; | 291 | QString msg; |
287 | msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn)); | 292 | msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn)); |
288 | msg.replace(QRegExp(":"),"\n"); | 293 | msg.replace(QRegExp(":"),"\n"); |
289 | QMessageBox::message("Note",msg); | 294 | QMessageBox::message("Note",msg); |
290 | // FtpQuit(conn); | 295 | // FtpQuit(conn); |
291 | } | 296 | } |
292 | ProgressBar->reset(); | 297 | ProgressBar->reset(); |
293 | nullifyCallBack(); | 298 | nullifyCallBack(); |
294 | } else { | 299 | } else { |
295 | QMessageBox::message("Note","Cannot upload directories"); | 300 | QMessageBox::message("Note","Cannot upload directories"); |
296 | } | 301 | } |
297 | TabWidget->setCurrentPage(1); | 302 | TabWidget->setCurrentPage(1); |
298 | populateRemoteView(); | 303 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
299 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 304 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
300 | } | 305 | } |
301 | 306 | ||
302 | void OpieFtp::nullifyCallBack() | 307 | void OpieFtp::nullifyCallBack() |
303 | { | 308 | { |
304 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); | 309 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); |
305 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); | 310 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); |
306 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); | 311 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); |
307 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); | 312 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); |
308 | 313 | ||
309 | } | 314 | } |
310 | 315 | ||
311 | void OpieFtp::remoteDownload() | 316 | void OpieFtp::remoteDownload() |
312 | { | 317 | { |
313 | int fsz; | 318 | int fsz; |
314 | QCopEnvelope ( "QPE/System", "busy()" ); | 319 | QCopEnvelope ( "QPE/System", "busy()" ); |
315 | qApp->processEvents(); | 320 | qApp->processEvents(); |
316 | QString strItem = Remote_View->currentItem()->text(0); | 321 | QString strItem = Remote_View->currentItem()->text(0); |
317 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 322 | QString localFile = currentDir.canonicalPath()+"/"+strItem; |
318 | QString remoteFile= currentRemoteDir+strItem; | 323 | QString remoteFile= currentRemoteDir+strItem; |
319 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 324 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
320 | fsz = 0; | 325 | fsz = 0; |
321 | QString temp; | 326 | QString temp; |
322 | temp.sprintf( remoteFile+" "+" %dkb", fsz); | 327 | temp.sprintf( remoteFile+" "+" %dkb", fsz); |
323 | 328 | ||
324 | ProgressBar->setTotalSteps(fsz); | 329 | ProgressBar->setTotalSteps(fsz); |
325 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 330 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
326 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 331 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
327 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 332 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
328 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 333 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
329 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); | 334 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); |
330 | 335 | ||
331 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 336 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
332 | QString msg; | 337 | QString msg; |
333 | msg.sprintf("Unable to download \n%s",FtpLastResponse(conn)); | 338 | msg.sprintf("Unable to download \n%s",FtpLastResponse(conn)); |
334 | msg.replace(QRegExp(":"),"\n"); | 339 | msg.replace(QRegExp(":"),"\n"); |
335 | QMessageBox::message("Note",msg); | 340 | QMessageBox::message("Note",msg); |
336 | // FtpQuit(conn); | 341 | // FtpQuit(conn); |
337 | } | 342 | } |
338 | ProgressBar->reset(); | 343 | ProgressBar->reset(); |
339 | nullifyCallBack(); | 344 | nullifyCallBack(); |
340 | TabWidget->setCurrentPage(0); | 345 | TabWidget->setCurrentPage(0); |
341 | populateLocalView(); | 346 | populateLocalView(); |
342 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 347 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
343 | } | 348 | } |
344 | 349 | ||
345 | 350 | ||
346 | void OpieFtp::newConnection() | 351 | void OpieFtp::newConnection() |
347 | { | 352 | { |
348 | TabWidget->setCurrentPage(2); | 353 | TabWidget->setCurrentPage(2); |
349 | } | 354 | } |
350 | 355 | ||
351 | void OpieFtp::connector() | 356 | void OpieFtp::connector() |
352 | { | 357 | { |
353 | QCopEnvelope ( "QPE/System", "busy()" ); | 358 | QCopEnvelope ( "QPE/System", "busy()" ); |
354 | qApp->processEvents(); | 359 | qApp->processEvents(); |
355 | currentRemoteDir=remotePath->text(); | 360 | currentRemoteDir=remotePath->text(); |
356 | if(ServerComboBox->currentText().isEmpty()) { | 361 | if(ServerComboBox->currentText().isEmpty()) { |
357 | QMessageBox::warning(this,"Ftp","Please set the server info","Ok",0,0); | 362 | QMessageBox::warning(this,"Ftp","Please set the server info","Ok",0,0); |
358 | TabWidget->setCurrentPage(2); | 363 | TabWidget->setCurrentPage(2); |
359 | ServerComboBox->setFocus(); | 364 | ServerComboBox->setFocus(); |
360 | return; | 365 | return; |
361 | } | 366 | } |
362 | FtpInit(); | 367 | FtpInit(); |
363 | TabWidget->setCurrentPage(1); | 368 | TabWidget->setCurrentPage(1); |
364 | QString ftp_host = ServerComboBox->currentText(); | 369 | QString ftp_host = ServerComboBox->currentText(); |
365 | QString ftp_user = UsernameComboBox->currentText(); | 370 | QString ftp_user = UsernameComboBox->currentText(); |
366 | QString ftp_pass = PasswordEdit->text(); | 371 | QString ftp_pass = PasswordEdit->text(); |
367 | QString port=PortSpinBox->cleanText(); | 372 | QString port=PortSpinBox->cleanText(); |
368 | port.stripWhiteSpace(); | 373 | port.stripWhiteSpace(); |
369 | 374 | ||
370 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) | 375 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) |
371 | ftp_host=ftp_host.right(ftp_host.length()-6); | 376 | ftp_host=ftp_host.right(ftp_host.length()-6); |
372 | ftp_host+=":"+port; | 377 | ftp_host+=":"+port; |
373 | if (!FtpConnect( ftp_host.latin1(), &conn)) { | 378 | if (!FtpConnect( ftp_host.latin1(), &conn)) { |
374 | QMessageBox::message("Note","Unable to connect to\n"+ftp_host); | 379 | QMessageBox::message("Note","Unable to connect to\n"+ftp_host); |
375 | return ; | 380 | return ; |
376 | } | 381 | } |
377 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { | 382 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { |
378 | QString msg; | 383 | QString msg; |
379 | msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); | 384 | msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); |
380 | msg.replace(QRegExp(":"),"\n"); | 385 | msg.replace(QRegExp(":"),"\n"); |
381 | QMessageBox::message("Note",msg); | 386 | QMessageBox::message("Note",msg); |
382 | FtpQuit(conn); | 387 | FtpQuit(conn); |
383 | return ; | 388 | return ; |
384 | } | 389 | } |
385 | remoteDirList("/") ; | 390 | remoteDirList("/") ; |
386 | setCaption(ftp_host); | 391 | setCaption(ftp_host); |
387 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 392 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
388 | } | 393 | } |
389 | 394 | ||
390 | void OpieFtp::disConnector() | 395 | void OpieFtp::disConnector() |
391 | { | 396 | { |
392 | FtpQuit(conn); | 397 | FtpQuit(conn); |
393 | setCaption("OpieFtp"); | 398 | setCaption("OpieFtp"); |
394 | currentRemoteDir="/"; | 399 | currentRemoteDir="/"; |
395 | Remote_View->clear(); | 400 | Remote_View->clear(); |
396 | } | 401 | } |
397 | 402 | ||
398 | bool OpieFtp::remoteDirList(const QString &dir) | 403 | bool OpieFtp::remoteDirList(const QString &dir) |
399 | { | 404 | { |
405 | QString tmp = QDir::homeDirPath(); | ||
406 | if(tmp.right(1) != "/") | ||
407 | tmp+="/._temp"; | ||
408 | else | ||
409 | tmp+="._temp"; | ||
410 | // qDebug("Listing remote dir "+tmp); | ||
400 | QCopEnvelope ( "QPE/System", "busy()" ); | 411 | QCopEnvelope ( "QPE/System", "busy()" ); |
401 | if (!FtpDir( "./._temp", dir.latin1(), conn) ) { | 412 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { |
402 | QString msg; | 413 | QString msg; |
403 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) ); | 414 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) ); |
404 | msg.replace(QRegExp(":"),"\n"); | 415 | msg.replace(QRegExp(":"),"\n"); |
405 | QMessageBox::message("Note",msg); | 416 | QMessageBox::message("Note",msg); |
406 | // FtpQuit(conn); | 417 | // FtpQuit(conn); |
407 | return false; | 418 | return false; |
408 | } | 419 | } |
409 | populateRemoteView(); | 420 | populateRemoteView() ; |
410 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 421 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
411 | return true; | 422 | return true; |
412 | } | 423 | } |
413 | 424 | ||
414 | bool OpieFtp::remoteChDir(const QString &dir) | 425 | bool OpieFtp::remoteChDir(const QString &dir) |
415 | { | 426 | { |
416 | QCopEnvelope ( "QPE/System", "busy()" ); | 427 | QCopEnvelope ( "QPE/System", "busy()" ); |
417 | if (!FtpChdir( dir.latin1(), conn )) { | 428 | if (!FtpChdir( dir.latin1(), conn )) { |
418 | QString msg; | 429 | QString msg; |
419 | msg.sprintf("Unable to change directories\n"+dir+"\n%s",FtpLastResponse(conn)); | 430 | msg.sprintf("Unable to change directories\n"+dir+"\n%s",FtpLastResponse(conn)); |
420 | msg.replace(QRegExp(":"),"\n"); | 431 | msg.replace(QRegExp(":"),"\n"); |
421 | QMessageBox::message("Note",msg); | 432 | QMessageBox::message("Note",msg); |
422 | qDebug(msg); | 433 | qDebug(msg); |
423 | // FtpQuit(conn); | 434 | // FtpQuit(conn); |
424 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 435 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
425 | return FALSE; | 436 | return FALSE; |
426 | } | 437 | } |
427 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 438 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
428 | return TRUE; | 439 | return TRUE; |
429 | } | 440 | } |
430 | 441 | ||
431 | void OpieFtp::populateLocalView() | 442 | void OpieFtp::populateLocalView() |
432 | { | 443 | { |
433 | Local_View->clear(); | 444 | Local_View->clear(); |
434 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 445 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
435 | currentDir.setMatchAllDirs(TRUE); | 446 | currentDir.setMatchAllDirs(TRUE); |
436 | currentDir.setNameFilter(filterStr); | 447 | currentDir.setNameFilter(filterStr); |
437 | QString fileL, fileS, fileDate; | 448 | QString fileL, fileS, fileDate; |
438 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 449 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
439 | QFileInfoListIterator it(*list); | 450 | QFileInfoListIterator it(*list); |
440 | QFileInfo *fi; | 451 | QFileInfo *fi; |
441 | while ( (fi=it.current()) ) { | 452 | while ( (fi=it.current()) ) { |
442 | if (fi->isSymLink() ){ | 453 | if (fi->isSymLink() ){ |
443 | QString symLink=fi->readLink(); | 454 | QString symLink=fi->readLink(); |
444 | // qDebug("Symlink detected "+symLink); | 455 | // qDebug("Symlink detected "+symLink); |
445 | QFileInfo sym( symLink); | 456 | QFileInfo sym( symLink); |
446 | fileS.sprintf( "%10li", sym.size() ); | 457 | fileS.sprintf( "%10li", sym.size() ); |
447 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 458 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
448 | fileDate = sym.lastModified().toString(); | 459 | fileDate = sym.lastModified().toString(); |
449 | } else { | 460 | } else { |
450 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 461 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
451 | fileS.sprintf( "%10li", fi->size() ); | 462 | fileS.sprintf( "%10li", fi->size() ); |
452 | fileL.sprintf( "%s",fi->fileName().data() ); | 463 | fileL.sprintf( "%s",fi->fileName().data() ); |
453 | fileDate= fi->lastModified().toString(); | 464 | fileDate= fi->lastModified().toString(); |
454 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 465 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
455 | fileL+="/"; | 466 | fileL+="/"; |
456 | // qDebug( fileL); | 467 | // qDebug( fileL); |
457 | } | 468 | } |
458 | } | 469 | } |
459 | item= new QListViewItem( Local_View,fileL,fileS, fileDate); | 470 | item= new QListViewItem( Local_View,fileL,fileS, fileDate); |
460 | ++it; | 471 | ++it; |
461 | } | 472 | } |
462 | Local_View->setSorting( 3,FALSE); | 473 | Local_View->setSorting( 3,FALSE); |
463 | currentPathEdit->setText( currentDir.canonicalPath() ); | 474 | currentPathEdit->setText( currentDir.canonicalPath() ); |
464 | } | 475 | } |
465 | 476 | ||
466 | bool OpieFtp::populateRemoteView() | 477 | bool OpieFtp::populateRemoteView( ) |
467 | { | 478 | { |
479 | // qDebug("populate remoteview"); | ||
480 | QString sfile=QDir::homeDirPath(); | ||
481 | if(sfile.right(1) != "/") | ||
482 | sfile+="/._temp"; | ||
483 | else | ||
484 | sfile+="._temp"; | ||
485 | QFile file( sfile); | ||
468 | Remote_View->clear(); | 486 | Remote_View->clear(); |
469 | QFile tmp("./._temp"); | ||
470 | QString s, File_Name; | 487 | QString s, File_Name; |
471 | QString fileL, fileS, fileDate; | 488 | QString fileL, fileS, fileDate; |
472 | new QListViewItem( Remote_View, "../"); | 489 | new QListViewItem( Remote_View, "../"); |
473 | if (tmp.open(IO_ReadOnly)) { | 490 | if ( file.open(IO_ReadOnly)) { |
474 | QTextStream t( &tmp ); // use a text stream | 491 | QTextStream t( &file ); // use a text stream |
475 | while ( !t.eof()) { | 492 | while ( !t.eof()) { |
476 | s = t.readLine(); | 493 | s = t.readLine(); |
477 | fileL = s.right(s.length()-55); | 494 | fileL = s.right(s.length()-55); |
478 | fileL = fileL.stripWhiteSpace(); | 495 | fileL = fileL.stripWhiteSpace(); |
479 | if(s.left(1) == "d") | 496 | if(s.left(1) == "d") |
480 | fileL = fileL+"/"; | 497 | fileL = fileL+"/"; |
481 | fileS = s.mid( 30, 42-30); | 498 | fileS = s.mid( 30, 42-30); |
482 | fileS = fileS.stripWhiteSpace(); | 499 | fileS = fileS.stripWhiteSpace(); |
483 | fileDate = s.mid( 42, 55-42); | 500 | fileDate = s.mid( 42, 55-42); |
484 | fileDate = fileDate.stripWhiteSpace(); | 501 | fileDate = fileDate.stripWhiteSpace(); |
485 | if(fileL.find("total",0,TRUE) == -1) | 502 | if(fileL.find("total",0,TRUE) == -1) |
486 | new QListViewItem( Remote_View, fileL, fileS, fileDate); | 503 | new QListViewItem( Remote_View, fileL, fileS, fileDate); |
487 | } | 504 | } |
488 | tmp.close(); | 505 | file.close(); |
506 | if( file.exists()) | ||
507 | file. remove(); | ||
489 | } else | 508 | } else |
490 | qDebug("temp file not opened successfullly"); | 509 | qDebug("temp file not opened successfullly "+sfile); |
510 | |||
491 | return true; | 511 | return true; |
492 | } | 512 | } |
493 | 513 | ||
494 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 514 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
495 | { | 515 | { |
496 | QCopEnvelope ( "QPE/System", "busy()" ); | 516 | QCopEnvelope ( "QPE/System", "busy()" ); |
497 | QString oldRemoteCurrentDir = currentRemoteDir; | 517 | QString oldRemoteCurrentDir = currentRemoteDir; |
498 | QString strItem=selectedItem->text(0); | 518 | QString strItem=selectedItem->text(0); |
499 | strItem=strItem.simplifyWhiteSpace(); | 519 | strItem=strItem.simplifyWhiteSpace(); |
500 | if(strItem == "../") { // the user wants to go ^ | 520 | if(strItem == "../") { // the user wants to go ^ |
501 | if( FtpCDUp( conn) == 0) { | 521 | if( FtpCDUp( conn) == 0) { |
502 | QString msg; | 522 | QString msg; |
503 | msg.sprintf("Unable to cd up\n%s",FtpLastResponse(conn)); | 523 | msg.sprintf("Unable to cd up\n%s",FtpLastResponse(conn)); |
504 | msg.replace(QRegExp(":"),"\n"); | 524 | msg.replace(QRegExp(":"),"\n"); |
505 | QMessageBox::message("Note",msg); | 525 | QMessageBox::message("Note",msg); |
506 | qDebug(msg); | 526 | qDebug(msg); |
507 | } | 527 | } |
508 | char path[256]; | 528 | char path[256]; |
509 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 529 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
510 | QString msg; | 530 | QString msg; |
511 | msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn)); | 531 | msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn)); |
512 | msg.replace(QRegExp(":"),"\n"); | 532 | msg.replace(QRegExp(":"),"\n"); |
513 | QMessageBox::message("Note",msg); | 533 | QMessageBox::message("Note",msg); |
514 | qDebug(msg); | 534 | qDebug(msg); |
515 | } | 535 | } |
516 | currentRemoteDir=path; | 536 | currentRemoteDir=path; |
517 | } else { | 537 | } else { |
518 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 538 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
519 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 539 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
520 | strItem = strItem.stripWhiteSpace(); | 540 | strItem = strItem.stripWhiteSpace(); |
521 | currentRemoteDir = strItem; | 541 | currentRemoteDir = strItem; |
522 | if( !remoteChDir( (const QString &)strItem)) { | 542 | if( !remoteChDir( (const QString &)strItem)) { |
523 | currentRemoteDir = oldRemoteCurrentDir; | 543 | currentRemoteDir = oldRemoteCurrentDir; |
524 | strItem=""; | 544 | strItem=""; |
525 | populateRemoteView(); | ||
526 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 545 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
527 | } | 546 | } |
528 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 547 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
529 | qDebug("trying directory"); | 548 | qDebug("trying directory"); |
530 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 549 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
531 | currentRemoteDir = oldRemoteCurrentDir; | 550 | currentRemoteDir = oldRemoteCurrentDir; |
532 | strItem=""; | 551 | strItem=""; |
533 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 552 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
534 | 553 | ||
535 | populateRemoteView(); | ||
536 | } else { | 554 | } else { |
537 | currentRemoteDir = currentRemoteDir+strItem; | 555 | currentRemoteDir = currentRemoteDir+strItem; |
538 | } | 556 | } |
539 | } else { | 557 | } else { |
540 | qDebug("download "+strItem); | 558 | qDebug("download "+strItem); |
541 | } | 559 | } |
542 | } | 560 | } |
561 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | ||
543 | if(currentRemoteDir.right(1) !="/") | 562 | if(currentRemoteDir.right(1) !="/") |
544 | currentRemoteDir +="/"; | 563 | currentRemoteDir +="/"; |
545 | currentPathEdit->setText( currentRemoteDir ); | 564 | currentPathEdit->setText( currentRemoteDir ); |
546 | remoteDirList( (const QString &)currentRemoteDir); | ||
547 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 565 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
548 | } | 566 | } |
549 | 567 | ||
550 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 568 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
551 | { | 569 | { |
552 | QString strItem=selectedItem->text(0); | 570 | QString strItem=selectedItem->text(0); |
553 | QString strSize=selectedItem->text(1); | 571 | QString strSize=selectedItem->text(1); |
554 | strSize=strSize.stripWhiteSpace(); | 572 | strSize=strSize.stripWhiteSpace(); |
555 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 573 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
556 | // is symlink | 574 | // is symlink |
557 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 575 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
558 | if(QDir(strItem2).exists() ) { | 576 | if(QDir(strItem2).exists() ) { |
559 | currentDir.cd(strItem2, TRUE); | 577 | currentDir.cd(strItem2, TRUE); |
560 | populateLocalView(); | 578 | populateLocalView(); |
561 | } | 579 | } |
562 | } else { // not a symlink | 580 | } else { // not a symlink |
563 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 581 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
564 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 582 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
565 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 583 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
566 | currentDir.cd(strItem,FALSE); | 584 | currentDir.cd(strItem,FALSE); |
567 | populateLocalView(); | 585 | populateLocalView(); |
568 | } else { | 586 | } else { |
569 | currentDir.cdUp(); | 587 | currentDir.cdUp(); |
570 | populateLocalView(); | 588 | populateLocalView(); |
571 | } | 589 | } |
572 | if(QDir(strItem).exists()){ | 590 | if(QDir(strItem).exists()){ |
573 | currentDir.cd(strItem, TRUE); | 591 | currentDir.cd(strItem, TRUE); |
574 | populateLocalView(); | 592 | populateLocalView(); |
575 | } | 593 | } |
576 | } else { | 594 | } else { |
577 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 595 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
578 | if( QFile::exists(strItem ) ) { | 596 | if( QFile::exists(strItem ) ) { |
579 | qDebug("upload "+strItem); | 597 | qDebug("upload "+strItem); |
580 | } | 598 | } |
581 | } //end not symlink | 599 | } //end not symlink |
582 | chdir(strItem.latin1()); | 600 | chdir(strItem.latin1()); |
583 | } | 601 | } |
584 | } | 602 | } |
585 | 603 | ||
586 | void OpieFtp::doLocalCd() | 604 | void OpieFtp::doLocalCd() |
587 | { | 605 | { |
588 | localListClicked( Local_View->currentItem()); | 606 | localListClicked( Local_View->currentItem()); |
589 | } | 607 | } |
590 | 608 | ||
591 | void OpieFtp:: doRemoteCd() | 609 | void OpieFtp:: doRemoteCd() |
592 | { | 610 | { |
593 | remoteListClicked( Remote_View->currentItem()); | 611 | remoteListClicked( Remote_View->currentItem()); |
594 | 612 | ||
595 | } | 613 | } |
596 | 614 | ||
597 | void OpieFtp::showHidden() | 615 | void OpieFtp::showHidden() |
598 | { | 616 | { |
599 | if (!b) { | 617 | if (!b) { |
600 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 618 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
601 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 619 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
602 | b=TRUE; | 620 | b=TRUE; |
603 | 621 | ||
604 | } else { | 622 | } else { |
605 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 623 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
606 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 624 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
607 | b=FALSE; | 625 | b=FALSE; |
608 | } | 626 | } |
609 | populateLocalView(); | 627 | populateLocalView(); |
610 | } | 628 | } |
611 | 629 | ||
612 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 630 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
613 | { | 631 | { |
614 | switch (mouse) { | 632 | switch (mouse) { |
615 | case 1: | 633 | case 1: |
616 | break; | 634 | break; |
617 | case 2: | 635 | case 2: |
618 | showLocalMenu(item); | 636 | showLocalMenu(item); |
619 | break; | 637 | break; |
620 | }; | 638 | }; |
621 | } | 639 | } |
622 | 640 | ||
623 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 641 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
624 | { | 642 | { |
625 | switch (mouse) { | 643 | switch (mouse) { |
626 | case 1: | 644 | case 1: |
627 | break; | 645 | break; |
628 | case 2: | 646 | case 2: |
629 | showRemoteMenu(item); | 647 | showRemoteMenu(item); |
630 | break; | 648 | break; |
631 | }; | 649 | }; |
632 | } | 650 | } |
633 | 651 | ||
634 | void OpieFtp::showRemoteMenu(QListViewItem * item) | 652 | void OpieFtp::showRemoteMenu(QListViewItem * item) |
635 | { | 653 | { |
636 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 654 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
637 | if(item->text(0).right(1) == "/") | 655 | if(item->text(0).right(1) == "/") |
638 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 656 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
639 | else | 657 | else |
640 | m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 658 | m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
641 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 659 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
642 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 660 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
643 | m.insertSeparator(); | 661 | m.insertSeparator(); |
644 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 662 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
645 | m.exec( QCursor::pos() ); | 663 | m.exec( QCursor::pos() ); |
646 | } | 664 | } |
647 | 665 | ||
648 | void OpieFtp::showLocalMenu(QListViewItem * item) | 666 | void OpieFtp::showLocalMenu(QListViewItem * item) |
649 | { | 667 | { |
650 | QPopupMenu m; | 668 | QPopupMenu m; |
651 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 669 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
652 | m.insertSeparator(); | 670 | m.insertSeparator(); |
653 | if(item->text(0).right(1) == "/") | 671 | if(item->text(0).right(1) == "/") |
654 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 672 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
655 | else | 673 | else |
656 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 674 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
657 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 675 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
658 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 676 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
659 | m.insertSeparator(); | 677 | m.insertSeparator(); |
660 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 678 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
661 | m.exec( QCursor::pos() ); | 679 | m.exec( QCursor::pos() ); |
662 | } | 680 | } |
663 | 681 | ||
664 | void OpieFtp::localMakDir() | 682 | void OpieFtp::localMakDir() |
665 | { | 683 | { |
666 | InputDialog *fileDlg; | 684 | InputDialog *fileDlg; |
667 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 685 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
668 | fileDlg->exec(); | 686 | fileDlg->exec(); |
669 | if( fileDlg->result() == 1 ) { | 687 | if( fileDlg->result() == 1 ) { |
670 | QString filename = fileDlg->LineEdit1->text(); | 688 | QString filename = fileDlg->LineEdit1->text(); |
671 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 689 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
672 | } | 690 | } |
673 | populateLocalView(); | 691 | populateLocalView(); |
674 | } | 692 | } |
675 | 693 | ||
676 | void OpieFtp::localDelete() | 694 | void OpieFtp::localDelete() |
677 | { | 695 | { |
678 | QString f = Local_View->currentItem()->text(0); | 696 | QString f = Local_View->currentItem()->text(0); |
679 | if(QDir(f).exists() ) { | 697 | if(QDir(f).exists() ) { |
680 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ | 698 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ |
681 | " ?\nIt must be empty","Yes","No",0,0,1) ) { | 699 | " ?\nIt must be empty","Yes","No",0,0,1) ) { |
682 | case 0: { | 700 | case 0: { |
683 | f=currentDir.canonicalPath()+"/"+f; | 701 | f=currentDir.canonicalPath()+"/"+f; |
684 | QString cmd="rmdir "+f; | 702 | QString cmd="rmdir "+f; |
685 | system( cmd.latin1()); | 703 | system( cmd.latin1()); |
686 | populateLocalView(); | 704 | populateLocalView(); |
687 | } | 705 | } |
688 | break; | 706 | break; |
689 | case 1: | 707 | case 1: |
690 | // exit | 708 | // exit |
691 | break; | 709 | break; |
692 | }; | 710 | }; |
693 | 711 | ||
694 | } else { | 712 | } else { |
695 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f | 713 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f |
696 | +" ?","Yes","No",0,0,1) ) { | 714 | +" ?","Yes","No",0,0,1) ) { |
697 | case 0: { | 715 | case 0: { |
698 | f=currentDir.canonicalPath()+"/"+f; | 716 | f=currentDir.canonicalPath()+"/"+f; |
699 | QString cmd="rm "+f; | 717 | QString cmd="rm "+f; |
700 | system( cmd.latin1()); | 718 | system( cmd.latin1()); |
701 | populateLocalView(); | 719 | populateLocalView(); |
702 | } | 720 | } |
703 | break; | 721 | break; |
704 | case 1: | 722 | case 1: |
705 | // exit | 723 | // exit |
706 | break; | 724 | break; |
707 | }; | 725 | }; |
708 | } | 726 | } |
709 | } | 727 | } |
710 | 728 | ||
711 | void OpieFtp::remoteMakDir() | 729 | void OpieFtp::remoteMakDir() |
712 | { | 730 | { |
713 | InputDialog *fileDlg; | 731 | InputDialog *fileDlg; |
714 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 732 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
715 | fileDlg->exec(); | 733 | fileDlg->exec(); |
716 | if( fileDlg->result() == 1 ) { | 734 | if( fileDlg->result() == 1 ) { |
717 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; | 735 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; |
718 | QString tmp=currentRemoteDir+filename; | 736 | QString tmp=currentRemoteDir+filename; |
719 | QCopEnvelope ( "QPE/System", "busy()" ); | 737 | QCopEnvelope ( "QPE/System", "busy()" ); |
720 | if(FtpMkdir( tmp.latin1(), conn) == 0) { | 738 | if(FtpMkdir( tmp.latin1(), conn) == 0) { |
721 | QString msg; | 739 | QString msg; |
722 | msg.sprintf("Unable to make directory\n%s",FtpLastResponse(conn)); | 740 | msg.sprintf("Unable to make directory\n%s",FtpLastResponse(conn)); |
723 | msg.replace(QRegExp(":"),"\n"); | 741 | msg.replace(QRegExp(":"),"\n"); |
724 | QMessageBox::message("Note",msg); | 742 | QMessageBox::message("Note",msg); |
725 | } | 743 | } |
726 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 744 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
745 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | ||
727 | } | 746 | } |
728 | populateRemoteView(); | ||
729 | } | 747 | } |
730 | 748 | ||
731 | void OpieFtp::remoteDelete() | 749 | void OpieFtp::remoteDelete() |
732 | { | 750 | { |
733 | QString f = Remote_View->currentItem()->text(0); | 751 | QString f = Remote_View->currentItem()->text(0); |
734 | QCopEnvelope ( "QPE/System", "busy()" ); | 752 | QCopEnvelope ( "QPE/System", "busy()" ); |
735 | if( f.right(1) =="/") { | 753 | if( f.right(1) =="/") { |
736 | QString path= currentRemoteDir+f; | 754 | QString path= currentRemoteDir+f; |
737 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?" | 755 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?" |
738 | ,"Yes","No",0,0,1) ) { | 756 | ,"Yes","No",0,0,1) ) { |
739 | case 0: { | 757 | case 0: { |
740 | f=currentDir.canonicalPath()+"/"+f; | 758 | f=currentDir.canonicalPath()+"/"+f; |
741 | if(FtpRmdir( path.latin1(), conn) ==0) { | 759 | if(FtpRmdir( path.latin1(), conn) ==0) { |
742 | QString msg; | 760 | QString msg; |
743 | msg.sprintf("Unable to remove directory\n%s",FtpLastResponse(conn)); | 761 | msg.sprintf("Unable to remove directory\n%s",FtpLastResponse(conn)); |
744 | msg.replace(QRegExp(":"),"\n"); | 762 | msg.replace(QRegExp(":"),"\n"); |
745 | QMessageBox::message("Note",msg); | 763 | QMessageBox::message("Note",msg); |
746 | } | 764 | } |
765 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | ||
766 | |||
747 | } | 767 | } |
748 | break; | 768 | break; |
749 | }; | 769 | }; |
750 | } else { | 770 | } else { |
751 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?" | 771 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?" |
752 | ,"Yes","No",0,0,1) ) { | 772 | ,"Yes","No",0,0,1) ) { |
753 | case 0: { | 773 | case 0: { |
754 | QString path= currentRemoteDir+f; | 774 | QString path= currentRemoteDir+f; |
755 | if(FtpDelete( path.latin1(), conn)==0) { | 775 | if(FtpDelete( path.latin1(), conn)==0) { |
756 | QString msg; | 776 | QString msg; |
757 | msg.sprintf("Unable to delete file\n%s",FtpLastResponse(conn)); | 777 | msg.sprintf("Unable to delete file\n%s",FtpLastResponse(conn)); |
758 | msg.replace(QRegExp(":"),"\n"); | 778 | msg.replace(QRegExp(":"),"\n"); |
759 | QMessageBox::message("Note",msg); | 779 | QMessageBox::message("Note",msg); |
760 | } | 780 | } |
781 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | ||
761 | } | 782 | } |
762 | break; | 783 | break; |
763 | }; | 784 | }; |
764 | } | 785 | } |
765 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 786 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
766 | } | 787 | } |
767 | 788 | ||
768 | void OpieFtp::remoteRename() | 789 | void OpieFtp::remoteRename() |
769 | { | 790 | { |
770 | QString curFile = Remote_View->currentItem()->text(0); | 791 | QString curFile = Remote_View->currentItem()->text(0); |
771 | InputDialog *fileDlg; | 792 | InputDialog *fileDlg; |
772 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | 793 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
773 | fileDlg->inputText = curFile; | 794 | fileDlg->inputText = curFile; |
774 | fileDlg->exec(); | 795 | fileDlg->exec(); |
775 | if( fileDlg->result() == 1 ) { | 796 | if( fileDlg->result() == 1 ) { |
776 | QString oldName = currentRemoteDir +"/"+ curFile; | 797 | QString oldName = currentRemoteDir +"/"+ curFile; |
777 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; | 798 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; |
778 | QCopEnvelope ( "QPE/System", "busy()" ); | 799 | QCopEnvelope ( "QPE/System", "busy()" ); |
779 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { | 800 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { |
780 | QString msg; | 801 | QString msg; |
781 | msg.sprintf("Unable to rename file\n%s",FtpLastResponse(conn)); | 802 | msg.sprintf("Unable to rename file\n%s",FtpLastResponse(conn)); |
782 | msg.replace(QRegExp(":"),"\n"); | 803 | msg.replace(QRegExp(":"),"\n"); |
783 | QMessageBox::message("Note",msg); | 804 | QMessageBox::message("Note",msg); |
784 | } | 805 | } |
785 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 806 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
807 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | ||
786 | } | 808 | } |
787 | populateRemoteView(); | ||
788 | } | 809 | } |
789 | 810 | ||
790 | void OpieFtp::localRename() | 811 | void OpieFtp::localRename() |
791 | { | 812 | { |
792 | QString curFile = Local_View->currentItem()->text(0); | 813 | QString curFile = Local_View->currentItem()->text(0); |
793 | InputDialog *fileDlg; | 814 | InputDialog *fileDlg; |
794 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | 815 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
795 | fileDlg->inputText = curFile; | 816 | fileDlg->inputText = curFile; |
796 | fileDlg->exec(); | 817 | fileDlg->exec(); |
797 | if( fileDlg->result() == 1 ) { | 818 | if( fileDlg->result() == 1 ) { |
798 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 819 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
799 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 820 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
800 | if( rename(oldname.latin1(), newName.latin1())== -1) | 821 | if( rename(oldname.latin1(), newName.latin1())== -1) |
801 | QMessageBox::message("Note","Could not rename"); | 822 | QMessageBox::message("Note","Could not rename"); |
802 | } | 823 | } |
803 | populateLocalView(); | 824 | populateLocalView(); |
804 | } | 825 | } |
805 | 826 | ||
806 | void OpieFtp::currentPathEditChanged() | 827 | void OpieFtp::currentPathEditChanged() |
807 | { | 828 | { |
808 | QString oldRemoteCurrentDir = currentRemoteDir; | 829 | QString oldRemoteCurrentDir = currentRemoteDir; |
809 | qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 830 | qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); |
810 | if (TabWidget->currentPageIndex() == 0) { | 831 | if (TabWidget->currentPageIndex() == 0) { |
811 | if(QDir( currentPathEdit->text()).exists()) { | 832 | if(QDir( currentPathEdit->text()).exists()) { |
812 | currentDir.setPath( currentPathEdit->text() ); | 833 | currentDir.setPath( currentPathEdit->text() ); |
813 | populateLocalView(); | 834 | populateLocalView(); |
814 | } else { | 835 | } else { |
815 | QMessageBox::message("Note","That directory does not exist"); | 836 | QMessageBox::message("Note","That directory does not exist"); |
816 | } | 837 | } |
817 | } | 838 | } |
818 | if (TabWidget->currentPageIndex() == 1) { | 839 | if (TabWidget->currentPageIndex() == 1) { |
819 | currentRemoteDir = currentPathEdit->text(); | 840 | currentRemoteDir = currentPathEdit->text(); |
820 | if(currentRemoteDir.right(1) !="/") { | 841 | if(currentRemoteDir.right(1) !="/") { |
821 | currentRemoteDir = currentRemoteDir +"/"; | 842 | currentRemoteDir = currentRemoteDir +"/"; |
822 | currentPathEdit->setText( currentRemoteDir ); | 843 | currentPathEdit->setText( currentRemoteDir ); |
823 | } | 844 | } |
824 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 845 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
825 | currentRemoteDir = oldRemoteCurrentDir; | 846 | currentRemoteDir = oldRemoteCurrentDir; |
826 | currentPathEdit->setText( currentRemoteDir ); | 847 | currentPathEdit->setText( currentRemoteDir ); |
827 | } | 848 | } |
828 | 849 | ||
829 | remoteDirList( (const QString &)currentRemoteDir); | 850 | remoteDirList( (const QString &)currentRemoteDir); |
830 | } | 851 | } |
831 | } | 852 | } |
832 | 853 | ||
833 | void OpieFtp::switchToLocalTab() | 854 | void OpieFtp::switchToLocalTab() |
834 | { | 855 | { |
835 | TabWidget->setCurrentPage(0); | 856 | TabWidget->setCurrentPage(0); |
836 | } | 857 | } |
837 | 858 | ||
838 | void OpieFtp::switchToRemoteTab() | 859 | void OpieFtp::switchToRemoteTab() |
839 | { | 860 | { |
840 | TabWidget->setCurrentPage(1); | 861 | TabWidget->setCurrentPage(1); |
841 | } | 862 | } |
842 | 863 | ||
843 | void OpieFtp::switchToConfigTab() | 864 | void OpieFtp::switchToConfigTab() |
844 | { | 865 | { |
845 | TabWidget->setCurrentPage(2); | 866 | TabWidget->setCurrentPage(2); |
846 | } | 867 | } |
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h index e3ff334..1e5fffa 100644 --- a/noncore/net/opieftp/opieftp.h +++ b/noncore/net/opieftp/opieftp.h | |||
@@ -1,103 +1,103 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | opieftp.h | 2 | opieftp.h |
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 | #ifndef OPIEFTP_H | 12 | #ifndef OPIEFTP_H |
13 | #define OPIEFTP_H | 13 | #define OPIEFTP_H |
14 | 14 | ||
15 | #include <qvariant.h> | 15 | #include <qvariant.h> |
16 | #include <qdialog.h> | 16 | #include <qdialog.h> |
17 | #include <qmainwindow.h> | 17 | #include <qmainwindow.h> |
18 | #include <qdir.h> | 18 | #include <qdir.h> |
19 | #include <qstring.h> | 19 | #include <qstring.h> |
20 | #include <qpoint.h> | 20 | #include <qpoint.h> |
21 | 21 | ||
22 | class QVBoxLayout; | 22 | class QVBoxLayout; |
23 | class QHBoxLayout; | 23 | class QHBoxLayout; |
24 | class QGridLayout; | 24 | class QGridLayout; |
25 | class QComboBox; | 25 | class QComboBox; |
26 | class QListView; | 26 | class QListView; |
27 | class QListviewItem; | 27 | class QListviewItem; |
28 | class QLabel; | 28 | class QLabel; |
29 | class QProgressBar; | 29 | class QProgressBar; |
30 | class QSpinBox; | 30 | class QSpinBox; |
31 | class QTabWidget; | 31 | class QTabWidget; |
32 | class QWidget; | 32 | class QWidget; |
33 | class QPEToolBar; | 33 | class QPEToolBar; |
34 | class QPEMenuBar; | 34 | class QPEMenuBar; |
35 | class QPopupMenu; | 35 | class QPopupMenu; |
36 | class QFile; | 36 | class QFile; |
37 | class QListViewItem; | 37 | class QListViewItem; |
38 | class QLineEdit; | 38 | class QLineEdit; |
39 | 39 | ||
40 | class OpieFtp : public QMainWindow | 40 | class OpieFtp : public QMainWindow |
41 | { | 41 | { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | 43 | ||
44 | public: | 44 | public: |
45 | OpieFtp( ); | 45 | OpieFtp( ); |
46 | ~OpieFtp(); | 46 | ~OpieFtp(); |
47 | 47 | ||
48 | QTabWidget *TabWidget; | 48 | QTabWidget *TabWidget; |
49 | QWidget *tab, *tab_2, *tab_3; | 49 | QWidget *tab, *tab_2, *tab_3; |
50 | QListView *Local_View, *Remote_View; | 50 | QListView *Local_View, *Remote_View; |
51 | 51 | ||
52 | QComboBox *UsernameComboBox, *ServerComboBox; | 52 | QComboBox *UsernameComboBox, *ServerComboBox; |
53 | QLineEdit *PasswordEdit, *remotePath, *currentPathEdit; | 53 | QLineEdit *PasswordEdit, *remotePath, *currentPathEdit; |
54 | QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;; | 54 | QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;; |
55 | QSpinBox* PortSpinBox; | 55 | QSpinBox* PortSpinBox; |
56 | QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu; | 56 | QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu; |
57 | QDir currentDir; | 57 | QDir currentDir; |
58 | QString currentRemoteDir; | 58 | QString currentRemoteDir; |
59 | QString filterStr; | 59 | QString filterStr; |
60 | QListViewItem * item; | 60 | QListViewItem * item; |
61 | bool b; | 61 | bool b; |
62 | 62 | ||
63 | protected slots: | 63 | protected slots: |
64 | void showLocalMenu( QListViewItem *); | 64 | void showLocalMenu( QListViewItem *); |
65 | void showRemoteMenu( QListViewItem *); | 65 | void showRemoteMenu( QListViewItem *); |
66 | void doLocalCd(); | 66 | void doLocalCd(); |
67 | void doRemoteCd(); | 67 | void doRemoteCd(); |
68 | void localUpload(); | 68 | void localUpload(); |
69 | void remoteDownload(); | 69 | void remoteDownload(); |
70 | void newConnection(); | 70 | void newConnection(); |
71 | void connector(); | 71 | void connector(); |
72 | void disConnector(); | 72 | void disConnector(); |
73 | void populateLocalView(); | 73 | void populateLocalView(); |
74 | bool populateRemoteView(); | 74 | bool populateRemoteView(); |
75 | void showHidden(); | 75 | void showHidden(); |
76 | 76 | ||
77 | void localListClicked(QListViewItem *); | 77 | void localListClicked(QListViewItem *); |
78 | void remoteListClicked(QListViewItem *); | 78 | void remoteListClicked(QListViewItem *); |
79 | void ListPressed( int, QListViewItem *, const QPoint&, int); | 79 | void ListPressed( int, QListViewItem *, const QPoint&, int); |
80 | void RemoteListPressed( int, QListViewItem *, const QPoint&, int); | 80 | void RemoteListPressed( int, QListViewItem *, const QPoint&, int); |
81 | void localMakDir(); | 81 | void localMakDir(); |
82 | void localDelete(); | 82 | void localDelete(); |
83 | void remoteMakDir(); | 83 | void remoteMakDir(); |
84 | void remoteDelete(); | 84 | void remoteDelete(); |
85 | bool remoteDirList(const QString &); | 85 | bool remoteDirList(const QString &); |
86 | bool remoteChDir(const QString &); | 86 | bool remoteChDir(const QString &); |
87 | void tabChanged(QWidget*); | 87 | void tabChanged(QWidget*); |
88 | void cleanUp(); | 88 | void cleanUp(); |
89 | void remoteRename(); | 89 | void remoteRename(); |
90 | void localRename(); | 90 | void localRename(); |
91 | void currentPathEditChanged(); | 91 | void currentPathEditChanged(); |
92 | void switchToLocalTab(); | 92 | void switchToLocalTab(); |
93 | void switchToRemoteTab(); | 93 | void switchToRemoteTab(); |
94 | void switchToConfigTab(); | 94 | void switchToConfigTab(); |
95 | protected: | 95 | protected: |
96 | void nullifyCallBack(); | 96 | void nullifyCallBack(); |
97 | QGridLayout* tabLayout; | 97 | QGridLayout* tabLayout; |
98 | QGridLayout* tabLayout_2; | 98 | QGridLayout* tabLayout_2; |
99 | QGridLayout* tabLayout_3; | 99 | QGridLayout* tabLayout_3; |
100 | 100 | ||
101 | }; | 101 | }; |
102 | 102 | ||
103 | #endif // OPIEFTP_H | 103 | #endif // OPIEFTP_H |