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