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