-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 4e14946..3d97ecb 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -1,1509 +1,1512 @@ | |||
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 | //#define DEVELOPERS_VERSION | 12 | //#define DEVELOPERS_VERSION |
13 | 13 | ||
14 | #include "opieftp.h" | 14 | #include "opieftp.h" |
15 | 15 | ||
16 | extern "C" { | 16 | extern "C" { |
17 | #include "ftplib.h" | 17 | #include "ftplib.h" |
18 | } | 18 | } |
19 | 19 | ||
20 | #include "inputDialog.h" | 20 | #include "inputDialog.h" |
21 | 21 | ||
22 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/mimetype.h> | 28 | #include <qpe/mimetype.h> |
29 | #include <qpe/qpemessagebox.h> | 29 | #include <qpe/qpemessagebox.h> |
30 | 30 | ||
31 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qtoolbutton.h> | 34 | #include <qtoolbutton.h> |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include <qdir.h> | 36 | #include <qdir.h> |
37 | #include <qfile.h> | 37 | #include <qfile.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qpopupmenu.h> | 40 | #include <qpopupmenu.h> |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | #include <qmainwindow.h> | 42 | #include <qmainwindow.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qprogressbar.h> | 44 | #include <qprogressbar.h> |
45 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
46 | #include <qtabwidget.h> | 46 | #include <qtabwidget.h> |
47 | #include <qwidget.h> | 47 | #include <qwidget.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qimage.h> | 49 | #include <qimage.h> |
50 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qlineedit.h> | 52 | #include <qlineedit.h> |
53 | #include <qregexp.h> | 53 | #include <qregexp.h> |
54 | #include <qlistbox.h> | 54 | #include <qlistbox.h> |
55 | 55 | ||
56 | #include <unistd.h> | 56 | #include <unistd.h> |
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | 58 | ||
59 | 59 | ||
60 | QProgressBar *ProgressBar; | 60 | QProgressBar *ProgressBar; |
61 | static netbuf *conn=NULL; | 61 | static netbuf *conn=NULL; |
62 | 62 | ||
63 | static int log_progress(netbuf *, int xfered, void *) | 63 | static int log_progress(netbuf *, int xfered, void *) |
64 | { | 64 | { |
65 | // int fsz = *(int *)arg; | 65 | // int fsz = *(int *)arg; |
66 | // int pct = (xfered * 100) / fsz; | 66 | // int pct = (xfered * 100) / fsz; |
67 | // printf("%3d%%\r", pct); | 67 | // printf("%3d%%\r", pct); |
68 | // fflush(stdout); | 68 | // fflush(stdout); |
69 | ProgressBar->setProgress(xfered); | 69 | ProgressBar->setProgress(xfered); |
70 | qApp->processEvents(); | 70 | qApp->processEvents(); |
71 | return 1; | 71 | return 1; |
72 | } | 72 | } |
73 | 73 | ||
74 | OpieFtp::OpieFtp( ) | 74 | OpieFtp::OpieFtp( ) |
75 | : QMainWindow( ) | 75 | : QMainWindow( ) |
76 | { | 76 | { |
77 | setCaption( tr( "OpieFtp" ) ); | 77 | setCaption( tr( "OpieFtp" ) ); |
78 | fuckeduphack=FALSE; | 78 | fuckeduphack=FALSE; |
79 | QGridLayout *layout = new QGridLayout( this ); | 79 | QGridLayout *layout = new QGridLayout( this ); |
80 | layout->setSpacing( 2); | 80 | layout->setSpacing( 2); |
81 | layout->setMargin( 2); | 81 | layout->setMargin( 2); |
82 | 82 | ||
83 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 83 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
84 | 84 | ||
85 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 85 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
86 | // QPEToolBar *menuBar = new QPEToolBar(this); | 86 | // QPEToolBar *menuBar = new QPEToolBar(this); |
87 | // menuBar->setHorizontalStretchable( TRUE ); | 87 | // menuBar->setHorizontalStretchable( TRUE ); |
88 | 88 | ||
89 | connectionMenu = new QPopupMenu( this ); | 89 | connectionMenu = new QPopupMenu( this ); |
90 | localMenu = new QPopupMenu( this ); | 90 | localMenu = new QPopupMenu( this ); |
91 | remoteMenu = new QPopupMenu( this ); | 91 | remoteMenu = new QPopupMenu( this ); |
92 | tabMenu = new QPopupMenu( this ); | 92 | tabMenu = new QPopupMenu( this ); |
93 | 93 | ||
94 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); | 94 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); |
95 | 95 | ||
96 | menuBar->insertItem( tr( "Connection" ), connectionMenu); | 96 | menuBar->insertItem( tr( "Connection" ), connectionMenu); |
97 | menuBar->insertItem( tr( "Local" ), localMenu); | 97 | menuBar->insertItem( tr( "Local" ), localMenu); |
98 | menuBar->insertItem( tr( "Remote" ), remoteMenu); | 98 | menuBar->insertItem( tr( "Remote" ), remoteMenu); |
99 | menuBar->insertItem( tr( "View" ), tabMenu); | 99 | menuBar->insertItem( tr( "View" ), tabMenu); |
100 | 100 | ||
101 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 101 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
102 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 102 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
103 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 103 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
104 | 104 | ||
105 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 105 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
106 | localMenu->insertSeparator(); | 106 | localMenu->insertSeparator(); |
107 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 107 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
108 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 108 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
109 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 109 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
110 | localMenu->insertSeparator(); | 110 | localMenu->insertSeparator(); |
111 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 111 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
112 | localMenu->setCheckable(TRUE); | 112 | localMenu->setCheckable(TRUE); |
113 | 113 | ||
114 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 114 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
115 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 115 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
116 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 116 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
117 | remoteMenu->insertSeparator(); | 117 | remoteMenu->insertSeparator(); |
118 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 118 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
119 | 119 | ||
120 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 120 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
121 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 121 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
122 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); | 122 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); |
123 | tabMenu->insertSeparator(); | 123 | tabMenu->insertSeparator(); |
124 | tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 124 | tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
125 | tabMenu->setCheckable(TRUE); | 125 | tabMenu->setCheckable(TRUE); |
126 | 126 | ||
127 | 127 | ||
128 | 128 | ||
129 | cdUpButton = new QToolButton( this,"cdUpButton"); | 129 | cdUpButton = new QToolButton( this,"cdUpButton"); |
130 | cdUpButton->setPixmap(Resource::loadPixmap("up")); | 130 | cdUpButton->setPixmap(Resource::loadPixmap("up")); |
131 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); | 131 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); |
132 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 132 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
133 | layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); | 133 | layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); |
134 | cdUpButton->hide(); | 134 | cdUpButton->hide(); |
135 | 135 | ||
136 | // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 136 | // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
137 | // docButton->setFixedSize( QSize( 20, 20 ) ); | 137 | // docButton->setFixedSize( QSize( 20, 20 ) ); |
138 | // connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 138 | // connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
139 | // docButton->setFlat(TRUE); | 139 | // docButton->setFlat(TRUE); |
140 | // layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); | 140 | // layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
141 | 141 | ||
142 | homeButton = new QToolButton(this,"homeButton"); | 142 | homeButton = new QToolButton(this,"homeButton"); |
143 | homeButton->setPixmap( Resource::loadPixmap("home")); | 143 | homeButton->setPixmap( Resource::loadPixmap("home")); |
144 | homeButton->setFixedSize( QSize( 20, 20 ) ); | 144 | homeButton->setFixedSize( QSize( 20, 20 ) ); |
145 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 145 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
146 | layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); | 146 | layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); |
147 | homeButton->hide(); | 147 | homeButton->hide(); |
148 | 148 | ||
149 | TabWidget = new QTabWidget( this, "TabWidget" ); | 149 | TabWidget = new QTabWidget( this, "TabWidget" ); |
150 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); | 150 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); |
151 | 151 | ||
152 | // TabWidget->setTabShape(QTabWidget::Triangular); | 152 | // TabWidget->setTabShape(QTabWidget::Triangular); |
153 | 153 | ||
154 | tab = new QWidget( TabWidget, "tab" ); | 154 | tab = new QWidget( TabWidget, "tab" ); |
155 | tabLayout = new QGridLayout( tab ); | 155 | tabLayout = new QGridLayout( tab ); |
156 | tabLayout->setSpacing( 2); | 156 | tabLayout->setSpacing( 2); |
157 | tabLayout->setMargin( 2); | 157 | tabLayout->setMargin( 2); |
158 | 158 | ||
159 | Local_View = new QListView( tab, "Local_View" ); | 159 | Local_View = new QListView( tab, "Local_View" ); |
160 | // Local_View->setResizePolicy( QListView::AutoOneFit ); | 160 | // Local_View->setResizePolicy( QListView::AutoOneFit ); |
161 | Local_View->addColumn( tr("File"),150); | 161 | Local_View->addColumn( tr("File"),150); |
162 | Local_View->addColumn( tr("Date"),-1); | 162 | Local_View->addColumn( tr("Date"),-1); |
163 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 163 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
164 | Local_View->addColumn( tr("Size"),-1); | 164 | Local_View->addColumn( tr("Size"),-1); |
165 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 165 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
166 | Local_View->setAllColumnsShowFocus(TRUE); | 166 | Local_View->setAllColumnsShowFocus(TRUE); |
167 | 167 | ||
168 | Local_View->setMultiSelection( TRUE); | 168 | Local_View->setMultiSelection( TRUE); |
169 | Local_View->setSelectionMode(QListView::Extended); | 169 | Local_View->setSelectionMode(QListView::Extended); |
170 | Local_View->setFocusPolicy(QWidget::ClickFocus); | 170 | Local_View->setFocusPolicy(QWidget::ClickFocus); |
171 | 171 | ||
172 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 172 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
173 | 173 | ||
174 | tabLayout->addWidget( Local_View, 0, 0 ); | 174 | tabLayout->addWidget( Local_View, 0, 0 ); |
175 | 175 | ||
176 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 176 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
177 | this,SLOT( localListClicked(QListViewItem *)) ); | 177 | this,SLOT( localListClicked(QListViewItem *)) ); |
178 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), | 178 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), |
179 | // this,SLOT( localListClicked(QListViewItem *)) ); | 179 | // this,SLOT( localListClicked(QListViewItem *)) ); |
180 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 180 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
181 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 181 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
182 | 182 | ||
183 | TabWidget->insertTab( tab, tr( "Local" ) ); | 183 | TabWidget->insertTab( tab, tr( "Local" ) ); |
184 | 184 | ||
185 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 185 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
186 | tabLayout_2 = new QGridLayout( tab_2 ); | 186 | tabLayout_2 = new QGridLayout( tab_2 ); |
187 | tabLayout_2->setSpacing( 2); | 187 | tabLayout_2->setSpacing( 2); |
188 | tabLayout_2->setMargin( 2); | 188 | tabLayout_2->setMargin( 2); |
189 | 189 | ||
190 | Remote_View = new QListView( tab_2, "Remote_View" ); | 190 | Remote_View = new QListView( tab_2, "Remote_View" ); |
191 | Remote_View->addColumn( tr("File"),150); | 191 | Remote_View->addColumn( tr("File"),150); |
192 | Remote_View->addColumn( tr("Date"),-1); | 192 | Remote_View->addColumn( tr("Date"),-1); |
193 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 193 | // Remote_View->setColumnAlignment(1,QListView::AlignRight); |
194 | Remote_View->addColumn( tr("Size"),-1); | 194 | Remote_View->addColumn( tr("Size"),-1); |
195 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 195 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
196 | Remote_View->setColumnAlignment(3,QListView::AlignCenter); | ||
196 | Remote_View->addColumn( tr("Dir"),-1); | 197 | Remote_View->addColumn( tr("Dir"),-1); |
197 | Remote_View->setColumnAlignment(4,QListView::AlignRight); | 198 | Remote_View->setColumnAlignment(4,QListView::AlignRight); |
198 | Remote_View->setAllColumnsShowFocus(TRUE); | 199 | Remote_View->setAllColumnsShowFocus(TRUE); |
199 | 200 | ||
200 | Remote_View->setMultiSelection( FALSE); | 201 | Remote_View->setMultiSelection( FALSE); |
201 | Remote_View->setSelectionMode(QListView::Extended); | 202 | Remote_View->setSelectionMode(QListView::Extended); |
202 | Remote_View->setFocusPolicy(QWidget::ClickFocus); | 203 | Remote_View->setFocusPolicy(QWidget::ClickFocus); |
203 | 204 | ||
204 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 205 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
205 | 206 | ||
206 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 207 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
207 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 208 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
208 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 209 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
209 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 210 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
210 | 211 | ||
211 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 212 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
212 | 213 | ||
213 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); | 214 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); |
214 | 215 | ||
215 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 216 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
216 | tabLayout_3 = new QGridLayout( tab_3 ); | 217 | tabLayout_3 = new QGridLayout( tab_3 ); |
217 | tabLayout_3->setSpacing( 2); | 218 | tabLayout_3->setSpacing( 2); |
218 | tabLayout_3->setMargin( 2); | 219 | tabLayout_3->setMargin( 2); |
219 | 220 | ||
220 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); | 221 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); |
221 | TextLabel1->setText( tr( "Username" ) ); | 222 | TextLabel1->setText( tr( "Username" ) ); |
222 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); | 223 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); |
223 | 224 | ||
224 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); | 225 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); |
225 | UsernameComboBox->setEditable(TRUE); | 226 | UsernameComboBox->setEditable(TRUE); |
226 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); | 227 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); |
227 | 228 | ||
228 | connect( UsernameComboBox,SIGNAL(textChanged(const QString &)),this, | 229 | connect( UsernameComboBox,SIGNAL(textChanged(const QString &)),this, |
229 | SLOT( UsernameComboBoxEdited(const QString & ) )); | 230 | SLOT( UsernameComboBoxEdited(const QString & ) )); |
230 | 231 | ||
231 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 232 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
232 | TextLabel2->setText( tr( "Password" ) ); | 233 | TextLabel2->setText( tr( "Password" ) ); |
233 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); | 234 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); |
234 | 235 | ||
235 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); | 236 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); |
236 | PasswordEdit->setEchoMode(QLineEdit::Password); | 237 | PasswordEdit->setEchoMode(QLineEdit::Password); |
237 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); | 238 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); |
238 | 239 | ||
239 | connect( PasswordEdit,SIGNAL(textChanged(const QString &)),this, | 240 | connect( PasswordEdit,SIGNAL(textChanged(const QString &)),this, |
240 | SLOT( PasswordEditEdited(const QString & ) )); | 241 | SLOT( PasswordEditEdited(const QString & ) )); |
241 | 242 | ||
242 | //PasswordEdit->setFixedWidth(85); | 243 | //PasswordEdit->setFixedWidth(85); |
243 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); | 244 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); |
244 | TextLabel3->setText( tr( "Remote server" ) ); | 245 | TextLabel3->setText( tr( "Remote server" ) ); |
245 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); | 246 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); |
246 | 247 | ||
247 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); | 248 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); |
248 | ServerComboBox->setEditable(TRUE); | 249 | ServerComboBox->setEditable(TRUE); |
249 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); | 250 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); |
250 | 251 | ||
251 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); | 252 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); |
252 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this, | 253 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this, |
253 | SLOT(serverComboEdited(const QString & ) )); | 254 | SLOT(serverComboEdited(const QString & ) )); |
254 | 255 | ||
255 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); | 256 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); |
256 | TextLabel5->setText( tr( "Remote path" ) ); | 257 | TextLabel5->setText( tr( "Remote path" ) ); |
257 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); | 258 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); |
258 | 259 | ||
259 | 260 | ||
260 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 261 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
261 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | 262 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); |
262 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 263 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
263 | TextLabel4->setText( tr( "Port" ) ); | 264 | TextLabel4->setText( tr( "Port" ) ); |
264 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); | 265 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); |
265 | 266 | ||
266 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); | 267 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); |
267 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 268 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
268 | PortSpinBox->setMaxValue(32786); | 269 | PortSpinBox->setMaxValue(32786); |
269 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); | 270 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); |
270 | 271 | ||
271 | serverListView = new QListBox( tab_3, "ServerListView" ); | 272 | serverListView = new QListBox( tab_3, "ServerListView" ); |
272 | tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5); | 273 | tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5); |
273 | 274 | ||
274 | connect( serverListView, SIGNAL( highlighted( const QString &)), | 275 | connect( serverListView, SIGNAL( highlighted( const QString &)), |
275 | this,SLOT( serverListClicked( const QString &) ) ); | 276 | this,SLOT( serverListClicked( const QString &) ) ); |
276 | 277 | ||
277 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); | 278 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); |
278 | tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1); | 279 | tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1); |
279 | connectServerBtn->setToggleButton(TRUE); | 280 | connectServerBtn->setToggleButton(TRUE); |
280 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); | 281 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); |
281 | 282 | ||
282 | newServerButton= new QPushButton( "Add", tab_3 , "NewServerButton" ); | 283 | newServerButton= new QPushButton( "Add", tab_3 , "NewServerButton" ); |
283 | tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2); | 284 | tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2); |
284 | connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() )); | 285 | connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() )); |
285 | 286 | ||
286 | QPushButton *deleteServerBtn; | 287 | QPushButton *deleteServerBtn; |
287 | deleteServerBtn = new QPushButton( "Delete", tab_3 , "OpenButton" ); | 288 | deleteServerBtn = new QPushButton( "Delete", tab_3 , "OpenButton" ); |
288 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3); | 289 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3); |
289 | 290 | ||
290 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); | 291 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); |
291 | 292 | ||
292 | 293 | ||
293 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 294 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
294 | tabLayout_3->addItem( spacer, 5, 0 ); | 295 | tabLayout_3->addItem( spacer, 5, 0 ); |
295 | 296 | ||
296 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 297 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
297 | 298 | ||
298 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 299 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
299 | this,SLOT(tabChanged(QWidget*))); | 300 | this,SLOT(tabChanged(QWidget*))); |
300 | 301 | ||
301 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 302 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
302 | currentDir.setPath( QDir::currentDirPath()); | 303 | currentDir.setPath( QDir::currentDirPath()); |
303 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 304 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
304 | 305 | ||
305 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 306 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
306 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); | 307 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); |
307 | currentPathCombo ->setFixedWidth(220); | 308 | currentPathCombo ->setFixedWidth(220); |
308 | currentPathCombo->setEditable(TRUE); | 309 | currentPathCombo->setEditable(TRUE); |
309 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 310 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
310 | 311 | ||
311 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 312 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
312 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 313 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
313 | 314 | ||
314 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 315 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
315 | this,SLOT(currentPathComboChanged())); | 316 | this,SLOT(currentPathComboChanged())); |
316 | 317 | ||
317 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 318 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
318 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); | 319 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); |
319 | ProgressBar->setMaximumHeight(10); | 320 | ProgressBar->setMaximumHeight(10); |
320 | filterStr="*"; | 321 | filterStr="*"; |
321 | b=FALSE; | 322 | b=FALSE; |
322 | populateLocalView(); | 323 | populateLocalView(); |
323 | readConfig(); | 324 | readConfig(); |
324 | 325 | ||
325 | // ServerComboBox->setCurrentItem(currentServerConfig); | 326 | // ServerComboBox->setCurrentItem(currentServerConfig); |
326 | 327 | ||
327 | TabWidget->setCurrentPage(2); | 328 | TabWidget->setCurrentPage(2); |
328 | } | 329 | } |
329 | 330 | ||
330 | OpieFtp::~OpieFtp() | 331 | OpieFtp::~OpieFtp() |
331 | { | 332 | { |
332 | } | 333 | } |
333 | 334 | ||
334 | void OpieFtp::cleanUp() | 335 | void OpieFtp::cleanUp() |
335 | { | 336 | { |
336 | if(conn) | 337 | if(conn) |
337 | FtpQuit(conn); | 338 | FtpQuit(conn); |
338 | QString sfile=QDir::homeDirPath(); | 339 | QString sfile=QDir::homeDirPath(); |
339 | if(sfile.right(1) != "/") | 340 | if(sfile.right(1) != "/") |
340 | sfile+="/._temp"; | 341 | sfile+="/._temp"; |
341 | else | 342 | else |
342 | sfile+="._temp"; | 343 | sfile+="._temp"; |
343 | QFile file( sfile); | 344 | QFile file( sfile); |
344 | if(file.exists()) | 345 | if(file.exists()) |
345 | file.remove(); | 346 | file.remove(); |
346 | Config cfg("opieftp"); | 347 | Config cfg("opieftp"); |
347 | cfg.setGroup("Server"); | 348 | cfg.setGroup("Server"); |
348 | cfg.writeEntry("currentServer", currentServerConfig); | 349 | cfg.writeEntry("currentServer", currentServerConfig); |
349 | 350 | ||
350 | exit(0); | 351 | exit(0); |
351 | } | 352 | } |
352 | 353 | ||
353 | void OpieFtp::tabChanged(QWidget *) | 354 | void OpieFtp::tabChanged(QWidget *) |
354 | { | 355 | { |
355 | if (TabWidget->currentPageIndex() == 0) { | 356 | if (TabWidget->currentPageIndex() == 0) { |
356 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 357 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
357 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); | 358 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); |
358 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 359 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
359 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 360 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
360 | if(cdUpButton->isHidden()) | 361 | if(cdUpButton->isHidden()) |
361 | cdUpButton->show(); | 362 | cdUpButton->show(); |
362 | if(homeButton->isHidden()) | 363 | if(homeButton->isHidden()) |
363 | homeButton->show(); | 364 | homeButton->show(); |
364 | 365 | ||
365 | } | 366 | } |
366 | if (TabWidget->currentPageIndex() == 1) { | 367 | if (TabWidget->currentPageIndex() == 1) { |
367 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 368 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
368 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); | 369 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); |
369 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 370 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
370 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 371 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
371 | if(cdUpButton->isHidden()) | 372 | if(cdUpButton->isHidden()) |
372 | cdUpButton->show(); | 373 | cdUpButton->show(); |
373 | homeButton->hide(); | 374 | homeButton->hide(); |
374 | 375 | ||
375 | } | 376 | } |
376 | if (TabWidget->currentPageIndex() == 2) { | 377 | if (TabWidget->currentPageIndex() == 2) { |
377 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); | 378 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); |
378 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 379 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
379 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 380 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
380 | cdUpButton->hide(); | 381 | cdUpButton->hide(); |
381 | homeButton->hide(); | 382 | homeButton->hide(); |
382 | } | 383 | } |
383 | } | 384 | } |
384 | 385 | ||
385 | void OpieFtp::newConnection() | 386 | void OpieFtp::newConnection() |
386 | { | 387 | { |
387 | UsernameComboBox->lineEdit()->setText(""); | 388 | UsernameComboBox->lineEdit()->setText(""); |
388 | PasswordEdit->setText( "" ); | 389 | PasswordEdit->setText( "" ); |
389 | ServerComboBox->lineEdit()->setText( ""); | 390 | ServerComboBox->lineEdit()->setText( ""); |
390 | remotePath->setText( currentRemoteDir = "/"); | 391 | remotePath->setText( currentRemoteDir = "/"); |
391 | PortSpinBox->setValue( 21); | 392 | PortSpinBox->setValue( 21); |
392 | TabWidget->setCurrentPage(2); | 393 | TabWidget->setCurrentPage(2); |
393 | } | 394 | } |
394 | 395 | ||
395 | void OpieFtp::serverComboEdited(const QString & ) | 396 | void OpieFtp::serverComboEdited(const QString & ) |
396 | { | 397 | { |
397 | // if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { | 398 | // if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { |
398 | // qDebug("ServerComboEdited"); | 399 | // qDebug("ServerComboEdited"); |
399 | // // currentServerConfig = -1; | 400 | // // currentServerConfig = -1; |
400 | // } | 401 | // } |
401 | } | 402 | } |
402 | 403 | ||
403 | void OpieFtp::UsernameComboBoxEdited(const QString &) { | 404 | void OpieFtp::UsernameComboBoxEdited(const QString &) { |
404 | // currentServerConfig = -1; | 405 | // currentServerConfig = -1; |
405 | } | 406 | } |
406 | 407 | ||
407 | void OpieFtp::PasswordEditEdited(const QString & ) { | 408 | void OpieFtp::PasswordEditEdited(const QString & ) { |
408 | // currentServerConfig = -1; | 409 | // currentServerConfig = -1; |
409 | } | 410 | } |
410 | 411 | ||
411 | void OpieFtp::connectorBtnToggled(bool On) | 412 | void OpieFtp::connectorBtnToggled(bool On) |
412 | { | 413 | { |
413 | if(On) { | 414 | if(On) { |
414 | connector(); | 415 | connector(); |
415 | } else { | 416 | } else { |
416 | disConnector(); | 417 | disConnector(); |
417 | } | 418 | } |
418 | 419 | ||
419 | } | 420 | } |
420 | 421 | ||
421 | void OpieFtp::connector() | 422 | void OpieFtp::connector() |
422 | { | 423 | { |
423 | // QCopEnvelope ( "QPE/System", "busy()" ); | 424 | // QCopEnvelope ( "QPE/System", "busy()" ); |
424 | // qApp->processEvents(); | 425 | // qApp->processEvents(); |
425 | currentRemoteDir=remotePath->text(); | 426 | currentRemoteDir=remotePath->text(); |
426 | 427 | ||
427 | if( ServerComboBox->currentText().isEmpty()) { | 428 | if( ServerComboBox->currentText().isEmpty()) { |
428 | 429 | ||
429 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); | 430 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); |
430 | TabWidget->setCurrentPage(2); | 431 | TabWidget->setCurrentPage(2); |
431 | ServerComboBox->setFocus(); | 432 | ServerComboBox->setFocus(); |
432 | connectServerBtn->setOn(FALSE); | 433 | connectServerBtn->setOn(FALSE); |
433 | connectServerBtn->setText( tr("Connect")); | 434 | connectServerBtn->setText( tr("Connect")); |
434 | return; | 435 | return; |
435 | } | 436 | } |
436 | 437 | ||
437 | FtpInit(); | 438 | FtpInit(); |
438 | 439 | ||
439 | TabWidget->setCurrentPage(1); | 440 | TabWidget->setCurrentPage(1); |
440 | QString ftp_host = ServerComboBox->currentText(); | 441 | QString ftp_host = ServerComboBox->currentText(); |
441 | QString ftp_user = UsernameComboBox->currentText(); | 442 | QString ftp_user = UsernameComboBox->currentText(); |
442 | QString ftp_pass = PasswordEdit->text(); | 443 | QString ftp_pass = PasswordEdit->text(); |
443 | QString port=PortSpinBox->cleanText(); | 444 | QString port=PortSpinBox->cleanText(); |
444 | port.stripWhiteSpace(); | 445 | port.stripWhiteSpace(); |
445 | 446 | ||
446 | Config cfg("opieftp"); | 447 | Config cfg("opieftp"); |
447 | cfg.setGroup("Server"); | 448 | cfg.setGroup("Server"); |
448 | // int current=cfg.readNumEntry("currentServer", 1); | 449 | // int current=cfg.readNumEntry("currentServer", 1); |
449 | 450 | ||
450 | // if(ftp_host!= cfg.readEntry(QString::number( current))) | 451 | // if(ftp_host!= cfg.readEntry(QString::number( current))) |
451 | // currentServerConfig=-1; | 452 | // currentServerConfig=-1; |
452 | // cfg.setGroup(QString::number(current)); | 453 | // cfg.setGroup(QString::number(current)); |
453 | // if( ftp_user != cfg.readEntry("Username")) | 454 | // if( ftp_user != cfg.readEntry("Username")) |
454 | // currentServerConfig=-1; | 455 | // currentServerConfig=-1; |
455 | // if(ftp_pass != cfg.readEntry(cfg.readEntry("Username"))) | 456 | // if(ftp_pass != cfg.readEntry(cfg.readEntry("Username"))) |
456 | // currentServerConfig=-1; | 457 | // currentServerConfig=-1; |
457 | 458 | ||
458 | 459 | ||
459 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) | 460 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) |
460 | ftp_host=ftp_host.right(ftp_host.length()-6); | 461 | ftp_host=ftp_host.right(ftp_host.length()-6); |
461 | ftp_host+=":"+port; | 462 | ftp_host+=":"+port; |
462 | 463 | ||
463 | if (!FtpConnect( ftp_host.latin1(), &conn)) { | 464 | if (!FtpConnect( ftp_host.latin1(), &conn)) { |
464 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); | 465 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); |
465 | connectServerBtn->setOn(FALSE); | 466 | connectServerBtn->setOn(FALSE); |
466 | connectServerBtn->setText( tr("Connect")); | 467 | connectServerBtn->setText( tr("Connect")); |
467 | return ; | 468 | return ; |
468 | } | 469 | } |
469 | 470 | ||
470 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { | 471 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { |
471 | QString msg; | 472 | QString msg; |
472 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); | 473 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); |
473 | msg.replace(QRegExp(":"),"\n"); | 474 | msg.replace(QRegExp(":"),"\n"); |
474 | QMessageBox::message(tr("Note"),msg); | 475 | QMessageBox::message(tr("Note"),msg); |
475 | if(conn) | 476 | if(conn) |
476 | FtpQuit(conn); | 477 | FtpQuit(conn); |
477 | connectServerBtn->setOn(FALSE); | 478 | connectServerBtn->setOn(FALSE); |
478 | connectServerBtn->setText( tr("Connect")); | 479 | connectServerBtn->setText( tr("Connect")); |
479 | return ; | 480 | return ; |
480 | } | 481 | } |
481 | 482 | ||
482 | remoteDirList("/") ; | 483 | remoteDirList("/") ; |
483 | setCaption(ftp_host); | 484 | setCaption(ftp_host); |
484 | if( currentServerConfig == -1) | 485 | if( currentServerConfig == -1) |
485 | writeConfig(); | 486 | writeConfig(); |
486 | connectServerBtn->setText( tr("Disconnect")); | 487 | connectServerBtn->setText( tr("Disconnect")); |
487 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 488 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
488 | } | 489 | } |
489 | 490 | ||
490 | void OpieFtp::disConnector() | 491 | void OpieFtp::disConnector() |
491 | { | 492 | { |
492 | if(conn) | 493 | if(conn) |
493 | FtpQuit(conn); | 494 | FtpQuit(conn); |
494 | setCaption("OpieFtp"); | 495 | setCaption("OpieFtp"); |
495 | currentRemoteDir="/"; | 496 | currentRemoteDir="/"; |
496 | Remote_View->clear(); | 497 | Remote_View->clear(); |
497 | connectServerBtn->setText( tr("Connect")); | 498 | connectServerBtn->setText( tr("Connect")); |
498 | connectServerBtn->setOn(FALSE); | 499 | connectServerBtn->setOn(FALSE); |
499 | setCaption("OpieFtp"); | 500 | setCaption("OpieFtp"); |
500 | } | 501 | } |
501 | 502 | ||
502 | void OpieFtp::localUpload() | 503 | void OpieFtp::localUpload() |
503 | { | 504 | { |
504 | int fsz; | 505 | int fsz; |
505 | // QCopEnvelope ( "QPE/System", "busy()" ); | 506 | // QCopEnvelope ( "QPE/System", "busy()" ); |
506 | // qApp->processEvents(); | 507 | // qApp->processEvents(); |
507 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 508 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
508 | QListViewItemIterator it( Local_View ); | 509 | QListViewItemIterator it( Local_View ); |
509 | for ( ; it.current(); ++it ) { | 510 | for ( ; it.current(); ++it ) { |
510 | if ( it.current()->isSelected() ) { | 511 | if ( it.current()->isSelected() ) { |
511 | QString strItem = it.current()->text(0); | 512 | QString strItem = it.current()->text(0); |
512 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 513 | QString localFile = currentDir.canonicalPath()+"/"+strItem; |
513 | QString remoteFile= currentRemoteDir+strItem; | 514 | QString remoteFile= currentRemoteDir+strItem; |
514 | QFileInfo fi(localFile); | 515 | QFileInfo fi(localFile); |
515 | if( !fi.isDir()) { | 516 | if( !fi.isDir()) { |
516 | fsz=fi.size(); | 517 | fsz=fi.size(); |
517 | ProgressBar->setTotalSteps(fsz); | 518 | ProgressBar->setTotalSteps(fsz); |
518 | 519 | ||
519 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 520 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
520 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 521 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
521 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 522 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
522 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 523 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
523 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); | 524 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); |
524 | 525 | ||
525 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 526 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
526 | QString msg; | 527 | QString msg; |
527 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); | 528 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); |
528 | msg.replace(QRegExp(":"),"\n"); | 529 | msg.replace(QRegExp(":"),"\n"); |
529 | QMessageBox::message(tr("Note"),msg); | 530 | QMessageBox::message(tr("Note"),msg); |
530 | } | 531 | } |
531 | } else { | 532 | } else { |
532 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); | 533 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); |
533 | } | 534 | } |
534 | ProgressBar->reset(); | 535 | ProgressBar->reset(); |
535 | nullifyCallBack(); | 536 | nullifyCallBack(); |
536 | it.current()->setSelected(FALSE); | 537 | it.current()->setSelected(FALSE); |
537 | } //end currentSelected | 538 | } //end currentSelected |
538 | } | 539 | } |
539 | for ( ; it.current(); ++it ) { | 540 | for ( ; it.current(); ++it ) { |
540 | Local_View->clearSelection(); | 541 | Local_View->clearSelection(); |
541 | } | 542 | } |
542 | Local_View->clearFocus(); | 543 | Local_View->clearFocus(); |
543 | TabWidget->setCurrentPage(1); | 544 | TabWidget->setCurrentPage(1); |
544 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 545 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
545 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 546 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
546 | } | 547 | } |
547 | 548 | ||
548 | void OpieFtp::nullifyCallBack() | 549 | void OpieFtp::nullifyCallBack() |
549 | { | 550 | { |
550 | FtpOptions(FTPLIB_CALLBACK, 0, conn); | 551 | FtpOptions(FTPLIB_CALLBACK, 0, conn); |
551 | FtpOptions(FTPLIB_IDLETIME, 0, conn); | 552 | FtpOptions(FTPLIB_IDLETIME, 0, conn); |
552 | FtpOptions(FTPLIB_CALLBACKARG, 0, conn); | 553 | FtpOptions(FTPLIB_CALLBACKARG, 0, conn); |
553 | FtpOptions(FTPLIB_CALLBACKBYTES, 0, conn); | 554 | FtpOptions(FTPLIB_CALLBACKBYTES, 0, conn); |
554 | } | 555 | } |
555 | 556 | ||
556 | void OpieFtp::remoteDownload() | 557 | void OpieFtp::remoteDownload() |
557 | { | 558 | { |
558 | // qApp->processEvents(); | 559 | // qApp->processEvents(); |
559 | int fsz; | 560 | int fsz; |
560 | // QCopEnvelope ( "QPE/System", "busy()" ); | 561 | // QCopEnvelope ( "QPE/System", "busy()" ); |
561 | 562 | ||
562 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 563 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
563 | QListViewItemIterator it( Remote_View ); | 564 | QListViewItemIterator it( Remote_View ); |
564 | for ( ; it.current(); ++it ) { | 565 | for ( ; it.current(); ++it ) { |
565 | if ( it.current()->isSelected() ) { | 566 | if ( it.current()->isSelected() ) { |
566 | QString strItem = it.current()->text(0); | 567 | QString strItem = it.current()->text(0); |
567 | // strItem=strItem.right(strItem.length()-1); | 568 | // strItem=strItem.right(strItem.length()-1); |
568 | QString localFile = currentDir.canonicalPath(); | 569 | QString localFile = currentDir.canonicalPath(); |
569 | if(localFile.right(1).find("/",0,TRUE) == -1) | 570 | if(localFile.right(1).find("/",0,TRUE) == -1) |
570 | localFile += "/"; | 571 | localFile += "/"; |
571 | localFile += strItem; | 572 | localFile += strItem; |
572 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | 573 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; |
573 | QString remoteFile= currentRemoteDir+strItem; | 574 | QString remoteFile= currentRemoteDir+strItem; |
574 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 575 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
575 | fsz = 0; | 576 | fsz = 0; |
576 | QString temp; | 577 | QString temp; |
577 | temp.sprintf( remoteFile+" "+" %dkb", fsz); | 578 | temp.sprintf( remoteFile+" "+" %dkb", fsz); |
578 | 579 | ||
579 | ProgressBar->setTotalSteps(fsz); | 580 | ProgressBar->setTotalSteps(fsz); |
580 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 581 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
581 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 582 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
582 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 583 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
583 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 584 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
584 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); | 585 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); |
585 | 586 | ||
586 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 587 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
587 | QString msg; | 588 | QString msg; |
588 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); | 589 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); |
589 | msg.replace(QRegExp(":"),"\n"); | 590 | msg.replace(QRegExp(":"),"\n"); |
590 | QMessageBox::message(tr("Note"),msg); | 591 | QMessageBox::message(tr("Note"),msg); |
591 | } | 592 | } |
592 | ProgressBar->reset(); | 593 | ProgressBar->reset(); |
593 | nullifyCallBack(); | 594 | nullifyCallBack(); |
594 | it.current()->setSelected(FALSE); | 595 | it.current()->setSelected(FALSE); |
595 | } | 596 | } |
596 | } | 597 | } |
597 | for ( ; it.current(); ++it ) { | 598 | for ( ; it.current(); ++it ) { |
598 | Remote_View->clearSelection(); | 599 | Remote_View->clearSelection(); |
599 | } | 600 | } |
600 | Remote_View->setFocus(); | 601 | Remote_View->setFocus(); |
601 | TabWidget->setCurrentPage(0); | 602 | TabWidget->setCurrentPage(0); |
602 | populateLocalView(); | 603 | populateLocalView(); |
603 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 604 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
604 | } | 605 | } |
605 | 606 | ||
606 | bool OpieFtp::remoteDirList(const QString &dir) | 607 | bool OpieFtp::remoteDirList(const QString &dir) |
607 | { | 608 | { |
608 | QString tmp = QDir::homeDirPath(); | 609 | QString tmp = QDir::homeDirPath(); |
609 | if(tmp.right(1) != "/") | 610 | if(tmp.right(1) != "/") |
610 | tmp+="/._temp"; | 611 | tmp+="/._temp"; |
611 | else | 612 | else |
612 | tmp+="._temp"; | 613 | tmp+="._temp"; |
613 | // qDebug("Listing remote dir "+tmp); | 614 | // qDebug("Listing remote dir "+tmp); |
614 | // QCopEnvelope ( "QPE/System", "busy()" ); | 615 | // QCopEnvelope ( "QPE/System", "busy()" ); |
615 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { | 616 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { |
616 | QString msg; | 617 | QString msg; |
617 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); | 618 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); |
618 | msg.replace(QRegExp(":"),"\n"); | 619 | msg.replace(QRegExp(":"),"\n"); |
619 | QMessageBox::message(tr("Note"),msg); | 620 | QMessageBox::message(tr("Note"),msg); |
620 | return false; | 621 | return false; |
621 | } | 622 | } |
622 | populateRemoteView() ; | 623 | populateRemoteView() ; |
623 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 624 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
624 | return true; | 625 | return true; |
625 | } | 626 | } |
626 | 627 | ||
627 | bool OpieFtp::remoteChDir(const QString &dir) | 628 | bool OpieFtp::remoteChDir(const QString &dir) |
628 | { | 629 | { |
629 | // QCopEnvelope ( "QPE/System", "busy()" ); | 630 | // QCopEnvelope ( "QPE/System", "busy()" ); |
630 | if (!FtpChdir( dir.latin1(), conn )) { | 631 | if (!FtpChdir( dir.latin1(), conn )) { |
631 | QString msg; | 632 | QString msg; |
632 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); | 633 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); |
633 | msg.replace(QRegExp(":"),"\n"); | 634 | msg.replace(QRegExp(":"),"\n"); |
634 | QMessageBox::message(tr("Note"),msg); | 635 | QMessageBox::message(tr("Note"),msg); |
635 | // qDebug(msg); | 636 | // qDebug(msg); |
636 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 637 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
637 | return FALSE; | 638 | return FALSE; |
638 | } | 639 | } |
639 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 640 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
640 | return TRUE; | 641 | return TRUE; |
641 | } | 642 | } |
642 | 643 | ||
643 | void OpieFtp::populateLocalView() | 644 | void OpieFtp::populateLocalView() |
644 | { | 645 | { |
645 | Local_View->clear(); | 646 | Local_View->clear(); |
646 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 647 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
647 | currentDir.setMatchAllDirs(TRUE); | 648 | currentDir.setMatchAllDirs(TRUE); |
648 | currentDir.setNameFilter(filterStr); | 649 | currentDir.setNameFilter(filterStr); |
649 | QString fileL, fileS, fileDate; | 650 | QString fileL, fileS, fileDate; |
650 | bool isDir=FALSE; | 651 | bool isDir=FALSE; |
651 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 652 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
652 | QFileInfoListIterator it(*list); | 653 | QFileInfoListIterator it(*list); |
653 | QFileInfo *fi; | 654 | QFileInfo *fi; |
654 | while ( (fi=it.current()) ) { | 655 | while ( (fi=it.current()) ) { |
655 | if (fi->isSymLink() ){ | 656 | if (fi->isSymLink() ){ |
656 | QString symLink=fi->readLink(); | 657 | QString symLink=fi->readLink(); |
657 | // qDebug("Symlink detected "+symLink); | 658 | // qDebug("Symlink detected "+symLink); |
658 | QFileInfo sym( symLink); | 659 | QFileInfo sym( symLink); |
659 | fileS.sprintf( "%10i", sym.size() ); | 660 | fileS.sprintf( "%10i", sym.size() ); |
660 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 661 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
661 | fileDate = sym.lastModified().toString(); | 662 | fileDate = sym.lastModified().toString(); |
662 | } else { | 663 | } else { |
663 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 664 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
664 | fileS.sprintf( "%10i", fi->size() ); | 665 | fileS.sprintf( "%10i", fi->size() ); |
665 | fileL.sprintf( "%s",fi->fileName().data() ); | 666 | fileL.sprintf( "%s",fi->fileName().data() ); |
666 | fileDate= fi->lastModified().toString(); | 667 | fileDate= fi->lastModified().toString(); |
667 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 668 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
668 | fileL+="/"; | 669 | fileL+="/"; |
669 | isDir=TRUE; | 670 | isDir=TRUE; |
670 | // qDebug( fileL); | 671 | // qDebug( fileL); |
671 | } | 672 | } |
672 | } | 673 | } |
673 | if(fileL !="./" && fi->exists()) { | 674 | if(fileL !="./" && fi->exists()) { |
674 | item = new QListViewItem( Local_View,fileL, fileDate, fileS ); | 675 | item = new QListViewItem( Local_View,fileL, fileDate, fileS ); |
675 | QPixmap pm; | 676 | QPixmap pm; |
676 | 677 | ||
677 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 678 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
678 | if( !QDir( fi->filePath() ).isReadable()) | 679 | if( !QDir( fi->filePath() ).isReadable()) |
679 | pm = Resource::loadPixmap( "lockedfolder" ); | 680 | pm = Resource::loadPixmap( "lockedfolder" ); |
680 | else | 681 | else |
681 | pm= Resource::loadPixmap( "folder" ); | 682 | pm= Resource::loadPixmap( "folder" ); |
682 | item->setPixmap( 0,pm ); | 683 | item->setPixmap( 0,pm ); |
683 | } else { | 684 | } else { |
684 | if( !fi->isReadable() ) | 685 | if( !fi->isReadable() ) |
685 | pm = Resource::loadPixmap( "locked" ); | 686 | pm = Resource::loadPixmap( "locked" ); |
686 | else { | 687 | else { |
687 | MimeType mt(fi->filePath()); | 688 | MimeType mt(fi->filePath()); |
688 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 689 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
689 | if(pm.isNull()) | 690 | if(pm.isNull()) |
690 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 691 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
691 | item->setPixmap( 0,pm); | 692 | item->setPixmap( 0,pm); |
692 | } | 693 | } |
693 | } | 694 | } |
694 | if( fileL.find("->",0,TRUE) != -1) { | 695 | if( fileL.find("->",0,TRUE) != -1) { |
695 | // overlay link image | 696 | // overlay link image |
696 | pm= Resource::loadPixmap( "folder" ); | 697 | pm= Resource::loadPixmap( "folder" ); |
697 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 698 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
698 | QPainter painter( &pm ); | 699 | QPainter painter( &pm ); |
699 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 700 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
700 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 701 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
701 | item->setPixmap( 0, pm); | 702 | item->setPixmap( 0, pm); |
702 | } | 703 | } |
703 | } | 704 | } |
704 | isDir=FALSE; | 705 | isDir=FALSE; |
705 | ++it; | 706 | ++it; |
706 | } | 707 | } |
707 | Local_View->setSorting( 3,FALSE); | 708 | Local_View->setSorting( 3,FALSE); |
708 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); | 709 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); |
709 | fillCombo( (const QString &)currentDir); | 710 | fillCombo( (const QString &)currentDir); |
710 | } | 711 | } |
711 | 712 | ||
712 | bool OpieFtp::populateRemoteView( ) | 713 | bool OpieFtp::populateRemoteView( ) |
713 | { | 714 | { |
714 | // qDebug("populate remoteview"); | 715 | // qDebug("populate remoteview"); |
715 | QString sfile=QDir::homeDirPath(); | 716 | QString sfile=QDir::homeDirPath(); |
716 | if(sfile.right(1) != "/") | 717 | if(sfile.right(1) != "/") |
717 | sfile+="/._temp"; | 718 | sfile+="/._temp"; |
718 | else | 719 | else |
719 | sfile+="._temp"; | 720 | sfile+="._temp"; |
720 | QFile file( sfile); | 721 | QFile file( sfile); |
721 | Remote_View->clear(); | 722 | Remote_View->clear(); |
722 | QString s, File_Name; | 723 | QString s, File_Name; |
723 | QListViewItem *itemDir=NULL, *itemFile=NULL; | 724 | QListViewItem *itemDir=NULL, *itemFile=NULL; |
725 | QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); | ||
724 | QString fileL, fileS, fileDate; | 726 | QString fileL, fileS, fileDate; |
725 | if ( file.open(IO_ReadOnly)) { | 727 | if ( file.open(IO_ReadOnly)) { |
726 | QTextStream t( &file ); // use a text stream | 728 | QTextStream t( &file ); // use a text stream |
727 | while ( !t.eof()) { | 729 | while ( !t.eof()) { |
728 | s = t.readLine(); | 730 | s = t.readLine(); |
729 | fileL = s.right(s.length()-55); | 731 | |
730 | fileL = fileL.stripWhiteSpace(); | 732 | if(s.find("total",0,TRUE) == 0) |
733 | continue; | ||
734 | |||
735 | int len, month = monthRe.match(s, 0, &len); | ||
736 | fileDate = s.mid(month + 1, len - 2); // minus spaces | ||
737 | fileL = s.right(s.length() - month - len); | ||
731 | if(s.left(1) == "d") | 738 | if(s.left(1) == "d") |
732 | fileL = fileL+"/"; | 739 | fileL = fileL+"/"; |
733 | // fileL = "/"+fileL+"/"; | 740 | fileS = s.mid(month - 8, 8); // FIXME |
734 | fileS = s.mid( 30, 42-30); | ||
735 | fileS = fileS.stripWhiteSpace(); | 741 | fileS = fileS.stripWhiteSpace(); |
736 | fileDate = s.mid( 42, 55-42); | 742 | |
737 | fileDate = fileDate.stripWhiteSpace(); | 743 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { |
738 | if(fileL.find("total",0,TRUE) == -1) { | 744 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); |
739 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { | 745 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
740 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); | ||
741 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | ||
742 | // if(itemDir) | 746 | // if(itemDir) |
743 | item->moveItem(itemDir); | 747 | item->moveItem(itemDir); |
744 | itemDir=item; | 748 | itemDir=item; |
745 | } else { | 749 | } else { |
746 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); | 750 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); |
747 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 751 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
748 | // if(itemFile) | 752 | // if(itemFile) |
749 | item->moveItem(itemDir); | 753 | item->moveItem(itemDir); |
750 | item->moveItem(itemFile); | 754 | item->moveItem(itemFile); |
751 | itemFile=item; | 755 | itemFile=item; |
752 | } | 756 | } |
753 | } | ||
754 | } | 757 | } |
755 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 758 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
756 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 759 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
757 | file.close(); | 760 | file.close(); |
758 | if( file.exists()) | 761 | if( file.exists()) |
759 | file. remove(); | 762 | file. remove(); |
760 | } else | 763 | } else |
761 | qDebug("temp file not opened successfullly "+sfile); | 764 | qDebug("temp file not opened successfullly "+sfile); |
762 | Remote_View->setSorting( 4,TRUE); | 765 | Remote_View->setSorting( 4,TRUE); |
763 | return true; | 766 | return true; |
764 | } | 767 | } |
765 | 768 | ||
766 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 769 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
767 | { | 770 | { |
768 | if( selectedItem) { | 771 | if( selectedItem) { |
769 | // QCopEnvelope ( "QPE/System", "busy()" ); | 772 | // QCopEnvelope ( "QPE/System", "busy()" ); |
770 | QString oldRemoteCurrentDir = currentRemoteDir; | 773 | QString oldRemoteCurrentDir = currentRemoteDir; |
771 | QString strItem=selectedItem->text(0); | 774 | QString strItem=selectedItem->text(0); |
772 | strItem=strItem.simplifyWhiteSpace(); | 775 | strItem=strItem.simplifyWhiteSpace(); |
773 | if(strItem == "../") { // the user wants to go ^ | 776 | if(strItem == "../") { // the user wants to go ^ |
774 | if( FtpCDUp( conn) == 0) { | 777 | if( FtpCDUp( conn) == 0) { |
775 | QString msg; | 778 | QString msg; |
776 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 779 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
777 | msg.replace(QRegExp(":"),"\n"); | 780 | msg.replace(QRegExp(":"),"\n"); |
778 | QMessageBox::message(tr("Note"),msg); | 781 | QMessageBox::message(tr("Note"),msg); |
779 | // qDebug(msg); | 782 | // qDebug(msg); |
780 | } | 783 | } |
781 | char path[256]; | 784 | char path[256]; |
782 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 785 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
783 | QString msg; | 786 | QString msg; |
784 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 787 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
785 | msg.replace(QRegExp(":"),"\n"); | 788 | msg.replace(QRegExp(":"),"\n"); |
786 | QMessageBox::message(tr("Note"),msg); | 789 | QMessageBox::message(tr("Note"),msg); |
787 | // qDebug(msg); | 790 | // qDebug(msg); |
788 | } | 791 | } |
789 | currentRemoteDir=path; | 792 | currentRemoteDir=path; |
790 | } else { | 793 | } else { |
791 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 794 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
792 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 795 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
793 | strItem = strItem.stripWhiteSpace(); | 796 | strItem = strItem.stripWhiteSpace(); |
794 | currentRemoteDir = strItem; | 797 | currentRemoteDir = strItem; |
795 | if( !remoteChDir( (const QString &)strItem)) { | 798 | if( !remoteChDir( (const QString &)strItem)) { |
796 | currentRemoteDir = oldRemoteCurrentDir; | 799 | currentRemoteDir = oldRemoteCurrentDir; |
797 | strItem=""; | 800 | strItem=""; |
798 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 801 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
799 | } | 802 | } |
800 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 803 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
801 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 804 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
802 | currentRemoteDir = oldRemoteCurrentDir; | 805 | currentRemoteDir = oldRemoteCurrentDir; |
803 | strItem=""; | 806 | strItem=""; |
804 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 807 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
805 | 808 | ||
806 | } else { | 809 | } else { |
807 | currentRemoteDir = currentRemoteDir+strItem; | 810 | currentRemoteDir = currentRemoteDir+strItem; |
808 | } | 811 | } |
809 | } else { | 812 | } else { |
810 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 813 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
811 | return; | 814 | return; |
812 | } | 815 | } |
813 | } | 816 | } |
814 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 817 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
815 | if(currentRemoteDir.right(1) !="/") | 818 | if(currentRemoteDir.right(1) !="/") |
816 | currentRemoteDir +="/"; | 819 | currentRemoteDir +="/"; |
817 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 820 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
818 | fillRemoteCombo( (const QString &)currentRemoteDir); | 821 | fillRemoteCombo( (const QString &)currentRemoteDir); |
819 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 822 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
820 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | 823 | Remote_View->ensureItemVisible(Remote_View->firstChild()); |
821 | 824 | ||
822 | } | 825 | } |
823 | } | 826 | } |
824 | 827 | ||
825 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 828 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
826 | { | 829 | { |
827 | if(selectedItem!= NULL) { | 830 | if(selectedItem!= NULL) { |
828 | 831 | ||
829 | QString strItem=selectedItem->text(0); | 832 | QString strItem=selectedItem->text(0); |
830 | QString strSize=selectedItem->text(1); | 833 | QString strSize=selectedItem->text(1); |
831 | strSize=strSize.stripWhiteSpace(); | 834 | strSize=strSize.stripWhiteSpace(); |
832 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 835 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
833 | // is symlink | 836 | // is symlink |
834 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 837 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
835 | if(QDir(strItem2).exists() ) { | 838 | if(QDir(strItem2).exists() ) { |
836 | currentDir.cd(strItem2, TRUE); | 839 | currentDir.cd(strItem2, TRUE); |
837 | populateLocalView(); | 840 | populateLocalView(); |
838 | } | 841 | } |
839 | } else { // not a symlink | 842 | } else { // not a symlink |
840 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 843 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
841 | 844 | ||
842 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 845 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
843 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 846 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
844 | currentDir.cd(strItem,FALSE); | 847 | currentDir.cd(strItem,FALSE); |
845 | populateLocalView(); | 848 | populateLocalView(); |
846 | } else { | 849 | } else { |
847 | currentDir.cdUp(); | 850 | currentDir.cdUp(); |
848 | populateLocalView(); | 851 | populateLocalView(); |
849 | } | 852 | } |
850 | if(QDir(strItem).exists()){ | 853 | if(QDir(strItem).exists()){ |
851 | currentDir.cd(strItem, TRUE); | 854 | currentDir.cd(strItem, TRUE); |
852 | populateLocalView(); | 855 | populateLocalView(); |
853 | } | 856 | } |
854 | } else { | 857 | } else { |
855 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 858 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
856 | if( QFile::exists(strItem ) ) { | 859 | if( QFile::exists(strItem ) ) { |
857 | // qDebug("upload "+strItem); | 860 | // qDebug("upload "+strItem); |
858 | return; | 861 | return; |
859 | } | 862 | } |
860 | } //end not symlink | 863 | } //end not symlink |
861 | chdir(strItem.latin1()); | 864 | chdir(strItem.latin1()); |
862 | } | 865 | } |
863 | Local_View->ensureItemVisible(Local_View->firstChild()); | 866 | Local_View->ensureItemVisible(Local_View->firstChild()); |
864 | } | 867 | } |
865 | } | 868 | } |
866 | 869 | ||
867 | void OpieFtp::doLocalCd() | 870 | void OpieFtp::doLocalCd() |
868 | { | 871 | { |
869 | localListClicked( Local_View->currentItem()); | 872 | localListClicked( Local_View->currentItem()); |
870 | } | 873 | } |
871 | 874 | ||
872 | void OpieFtp:: doRemoteCd() | 875 | void OpieFtp:: doRemoteCd() |
873 | { | 876 | { |
874 | remoteListClicked( Remote_View->currentItem()); | 877 | remoteListClicked( Remote_View->currentItem()); |
875 | 878 | ||
876 | } | 879 | } |
877 | 880 | ||
878 | void OpieFtp::showHidden() | 881 | void OpieFtp::showHidden() |
879 | { | 882 | { |
880 | if (!b) { | 883 | if (!b) { |
881 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 884 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
882 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 885 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
883 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 886 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
884 | b=TRUE; | 887 | b=TRUE; |
885 | 888 | ||
886 | } else { | 889 | } else { |
887 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 890 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
888 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 891 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
889 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 892 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
890 | b=FALSE; | 893 | b=FALSE; |
891 | } | 894 | } |
892 | populateLocalView(); | 895 | populateLocalView(); |
893 | } | 896 | } |
894 | 897 | ||
895 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &, int) | 898 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &, int) |
896 | { | 899 | { |
897 | // if(item) | 900 | // if(item) |
898 | if (mouse == 2) { | 901 | if (mouse == 2) { |
899 | showLocalMenu(item); | 902 | showLocalMenu(item); |
900 | } | 903 | } |
901 | } | 904 | } |
902 | 905 | ||
903 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &, int ) | 906 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &, int ) |
904 | { | 907 | { |
905 | if(mouse == 2) { | 908 | if(mouse == 2) { |
906 | showRemoteMenu(item); | 909 | showRemoteMenu(item); |
907 | } | 910 | } |
908 | } | 911 | } |
909 | 912 | ||
910 | void OpieFtp::showRemoteMenu(QListViewItem * item) | 913 | void OpieFtp::showRemoteMenu(QListViewItem * item) |
911 | { | 914 | { |
912 | QPopupMenu * m;// = new QPopupMenu( Local_View ); | 915 | QPopupMenu * m;// = new QPopupMenu( Local_View ); |
913 | m = new QPopupMenu(this); | 916 | m = new QPopupMenu(this); |
914 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) | 917 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) |
915 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 918 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
916 | else | 919 | else |
917 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 920 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
918 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 921 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
919 | m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() )); | 922 | m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() )); |
920 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 923 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
921 | m->insertSeparator(); | 924 | m->insertSeparator(); |
922 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 925 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
923 | m->exec( QCursor::pos() ); | 926 | m->exec( QCursor::pos() ); |
924 | delete m; | 927 | delete m; |
925 | } | 928 | } |
926 | 929 | ||
927 | void OpieFtp::showLocalMenu(QListViewItem * item) | 930 | void OpieFtp::showLocalMenu(QListViewItem * item) |
928 | { | 931 | { |
929 | 932 | ||
930 | QPopupMenu *m; | 933 | QPopupMenu *m; |
931 | m = new QPopupMenu( this); | 934 | m = new QPopupMenu( this); |
932 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 935 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
933 | m->insertSeparator(); | 936 | m->insertSeparator(); |
934 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 937 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
935 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 938 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
936 | else | 939 | else |
937 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 940 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
938 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 941 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
939 | m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() )); | 942 | m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() )); |
940 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 943 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
941 | m->insertSeparator(); | 944 | m->insertSeparator(); |
942 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 945 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
943 | m->setCheckable(TRUE); | 946 | m->setCheckable(TRUE); |
944 | if (b) | 947 | if (b) |
945 | m->setItemChecked(m->idAt(0),TRUE); | 948 | m->setItemChecked(m->idAt(0),TRUE); |
946 | else | 949 | else |
947 | m->setItemChecked(m->idAt(0),FALSE); | 950 | m->setItemChecked(m->idAt(0),FALSE); |
948 | 951 | ||
949 | m->exec( QCursor::pos() ); | 952 | m->exec( QCursor::pos() ); |
950 | delete m; | 953 | delete m; |
951 | } | 954 | } |
952 | 955 | ||
953 | void OpieFtp::localMakDir() | 956 | void OpieFtp::localMakDir() |
954 | { | 957 | { |
955 | InputDialog *fileDlg; | 958 | InputDialog *fileDlg; |
956 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 959 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
957 | fileDlg->exec(); | 960 | fileDlg->exec(); |
958 | if( fileDlg->result() == 1 ) { | 961 | if( fileDlg->result() == 1 ) { |
959 | QString filename = fileDlg->LineEdit1->text(); | 962 | QString filename = fileDlg->LineEdit1->text(); |
960 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 963 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
961 | } | 964 | } |
962 | populateLocalView(); | 965 | populateLocalView(); |
963 | } | 966 | } |
964 | 967 | ||
965 | void OpieFtp::localDelete() | 968 | void OpieFtp::localDelete() |
966 | { | 969 | { |
967 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 970 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
968 | QListViewItemIterator it( Local_View ); | 971 | QListViewItemIterator it( Local_View ); |
969 | for ( ; it.current(); ++it ) { | 972 | for ( ; it.current(); ++it ) { |
970 | if ( it.current()->isSelected() ) { | 973 | if ( it.current()->isSelected() ) { |
971 | QString f = it.current()->text(0); | 974 | QString f = it.current()->text(0); |
972 | it.current()->setSelected(FALSE); | 975 | it.current()->setSelected(FALSE); |
973 | 976 | ||
974 | // QString f = Local_View->currentItem()->text(0); | 977 | // QString f = Local_View->currentItem()->text(0); |
975 | if(QDir(f).exists() ) { | 978 | if(QDir(f).exists() ) { |
976 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 979 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
977 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { | 980 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { |
978 | case 0: { | 981 | case 0: { |
979 | f=currentDir.canonicalPath()+"/"+f; | 982 | f=currentDir.canonicalPath()+"/"+f; |
980 | QString cmd="rmdir "+f; | 983 | QString cmd="rmdir "+f; |
981 | system( cmd.latin1()); | 984 | system( cmd.latin1()); |
982 | } | 985 | } |
983 | break; | 986 | break; |
984 | case 1: | 987 | case 1: |
985 | // exit | 988 | // exit |
986 | break; | 989 | break; |
987 | }; | 990 | }; |
988 | 991 | ||
989 | } else { | 992 | } else { |
990 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 993 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
991 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 994 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
992 | case 0: { | 995 | case 0: { |
993 | f=currentDir.canonicalPath()+"/"+f; | 996 | f=currentDir.canonicalPath()+"/"+f; |
994 | QString cmd="rm "+f; | 997 | QString cmd="rm "+f; |
995 | system( cmd.latin1()); | 998 | system( cmd.latin1()); |
996 | } | 999 | } |
997 | break; | 1000 | break; |
998 | case 1: | 1001 | case 1: |
999 | // exit | 1002 | // exit |
1000 | break; | 1003 | break; |
1001 | }; | 1004 | }; |
1002 | } | 1005 | } |
1003 | } | 1006 | } |
1004 | } | 1007 | } |
1005 | populateLocalView(); | 1008 | populateLocalView(); |
1006 | 1009 | ||
1007 | } | 1010 | } |
1008 | 1011 | ||
1009 | void OpieFtp::remoteMakDir() | 1012 | void OpieFtp::remoteMakDir() |
1010 | { | 1013 | { |
1011 | InputDialog *fileDlg; | 1014 | InputDialog *fileDlg; |
1012 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 1015 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
1013 | fileDlg->exec(); | 1016 | fileDlg->exec(); |
1014 | if( fileDlg->result() == 1 ) { | 1017 | if( fileDlg->result() == 1 ) { |
1015 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; | 1018 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; |
1016 | QString tmp=currentRemoteDir+filename; | 1019 | QString tmp=currentRemoteDir+filename; |
1017 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1020 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1018 | if(FtpMkdir( tmp.latin1(), conn) == 0) { | 1021 | if(FtpMkdir( tmp.latin1(), conn) == 0) { |
1019 | QString msg; | 1022 | QString msg; |
1020 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); | 1023 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); |
1021 | msg.replace(QRegExp(":"),"\n"); | 1024 | msg.replace(QRegExp(":"),"\n"); |
1022 | QMessageBox::message(tr("Note"),msg); | 1025 | QMessageBox::message(tr("Note"),msg); |
1023 | } | 1026 | } |
1024 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1027 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1025 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1028 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1026 | } | 1029 | } |
1027 | } | 1030 | } |
1028 | 1031 | ||
1029 | void OpieFtp::remoteDelete() | 1032 | void OpieFtp::remoteDelete() |
1030 | { | 1033 | { |
1031 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 1034 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
1032 | QListViewItemIterator it( Remote_View ); | 1035 | QListViewItemIterator it( Remote_View ); |
1033 | for ( ; it.current(); ++it ) { | 1036 | for ( ; it.current(); ++it ) { |
1034 | if ( it.current()->isSelected() ) { | 1037 | if ( it.current()->isSelected() ) { |
1035 | QString f = it.current()->text(0); | 1038 | QString f = it.current()->text(0); |
1036 | // QString f = Remote_View->currentItem()->text(0); | 1039 | // QString f = Remote_View->currentItem()->text(0); |
1037 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1040 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1038 | if( f.right(1) =="/") { | 1041 | if( f.right(1) =="/") { |
1039 | QString path= currentRemoteDir+f; | 1042 | QString path= currentRemoteDir+f; |
1040 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 1043 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
1041 | ,tr("Yes"),tr("No"),0,0,1) ) { | 1044 | ,tr("Yes"),tr("No"),0,0,1) ) { |
1042 | case 0: { | 1045 | case 0: { |
1043 | f=currentDir.canonicalPath()+"/"+f; | 1046 | f=currentDir.canonicalPath()+"/"+f; |
1044 | if(FtpRmdir( path.latin1(), conn) ==0) { | 1047 | if(FtpRmdir( path.latin1(), conn) ==0) { |
1045 | QString msg; | 1048 | QString msg; |
1046 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); | 1049 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); |
1047 | msg.replace(QRegExp(":"),"\n"); | 1050 | msg.replace(QRegExp(":"),"\n"); |
1048 | QMessageBox::message(tr("Note"),msg); | 1051 | QMessageBox::message(tr("Note"),msg); |
1049 | } | 1052 | } |
1050 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1053 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1051 | } | 1054 | } |
1052 | break; | 1055 | break; |
1053 | }; | 1056 | }; |
1054 | } else { | 1057 | } else { |
1055 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 1058 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
1056 | ,tr("Yes"),tr("No"),0,0,1) ) { | 1059 | ,tr("Yes"),tr("No"),0,0,1) ) { |
1057 | case 0: { | 1060 | case 0: { |
1058 | QString path= currentRemoteDir+f; | 1061 | QString path= currentRemoteDir+f; |
1059 | if(FtpDelete( path.latin1(), conn)==0) { | 1062 | if(FtpDelete( path.latin1(), conn)==0) { |
1060 | QString msg; | 1063 | QString msg; |
1061 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); | 1064 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); |
1062 | msg.replace(QRegExp(":"),"\n"); | 1065 | msg.replace(QRegExp(":"),"\n"); |
1063 | QMessageBox::message(tr("Note"),msg); | 1066 | QMessageBox::message(tr("Note"),msg); |
1064 | } | 1067 | } |
1065 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1068 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1066 | } | 1069 | } |
1067 | break; | 1070 | break; |
1068 | }; | 1071 | }; |
1069 | } | 1072 | } |
1070 | } | 1073 | } |
1071 | } | 1074 | } |
1072 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1075 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1073 | } | 1076 | } |
1074 | 1077 | ||
1075 | void OpieFtp::remoteRename() | 1078 | void OpieFtp::remoteRename() |
1076 | { | 1079 | { |
1077 | QString curFile = Remote_View->currentItem()->text(0); | 1080 | QString curFile = Remote_View->currentItem()->text(0); |
1078 | InputDialog *fileDlg; | 1081 | InputDialog *fileDlg; |
1079 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1082 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1080 | fileDlg->setTextEdit((const QString &)curFile); | 1083 | fileDlg->setTextEdit((const QString &)curFile); |
1081 | fileDlg->exec(); | 1084 | fileDlg->exec(); |
1082 | if( fileDlg->result() == 1 ) { | 1085 | if( fileDlg->result() == 1 ) { |
1083 | QString oldName = currentRemoteDir +"/"+ curFile; | 1086 | QString oldName = currentRemoteDir +"/"+ curFile; |
1084 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; | 1087 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; |
1085 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1088 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1086 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { | 1089 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { |
1087 | QString msg; | 1090 | QString msg; |
1088 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); | 1091 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); |
1089 | msg.replace(QRegExp(":"),"\n"); | 1092 | msg.replace(QRegExp(":"),"\n"); |
1090 | QMessageBox::message(tr("Note"),msg); | 1093 | QMessageBox::message(tr("Note"),msg); |
1091 | } | 1094 | } |
1092 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1095 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1093 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1096 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1094 | } | 1097 | } |
1095 | } | 1098 | } |
1096 | 1099 | ||
1097 | void OpieFtp::localRename() | 1100 | void OpieFtp::localRename() |
1098 | { | 1101 | { |
1099 | QString curFile = Local_View->currentItem()->text(0); | 1102 | QString curFile = Local_View->currentItem()->text(0); |
1100 | InputDialog *fileDlg; | 1103 | InputDialog *fileDlg; |
1101 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1104 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1102 | fileDlg->setTextEdit((const QString &)curFile); | 1105 | fileDlg->setTextEdit((const QString &)curFile); |
1103 | fileDlg->exec(); | 1106 | fileDlg->exec(); |
1104 | if( fileDlg->result() == 1 ) { | 1107 | if( fileDlg->result() == 1 ) { |
1105 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 1108 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
1106 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 1109 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
1107 | if( rename(oldname.latin1(), newName.latin1())== -1) | 1110 | if( rename(oldname.latin1(), newName.latin1())== -1) |
1108 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 1111 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1109 | } | 1112 | } |
1110 | populateLocalView(); | 1113 | populateLocalView(); |
1111 | } | 1114 | } |
1112 | 1115 | ||
1113 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { | 1116 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { |
1114 | if (TabWidget->currentPageIndex() == 0) { | 1117 | if (TabWidget->currentPageIndex() == 0) { |
1115 | chdir( currentPath.latin1() ); | 1118 | chdir( currentPath.latin1() ); |
1116 | currentDir.cd( currentPath, TRUE); | 1119 | currentDir.cd( currentPath, TRUE); |
1117 | populateLocalView(); | 1120 | populateLocalView(); |
1118 | update(); | 1121 | update(); |
1119 | } else { | 1122 | } else { |
1120 | // chdir( currentPath.latin1() ); | 1123 | // chdir( currentPath.latin1() ); |
1121 | // currentDir.cd( currentPath, TRUE); | 1124 | // currentDir.cd( currentPath, TRUE); |
1122 | // populateList(); | 1125 | // populateList(); |
1123 | // update(); | 1126 | // update(); |
1124 | 1127 | ||
1125 | } | 1128 | } |
1126 | } | 1129 | } |
1127 | 1130 | ||
1128 | void OpieFtp::fillCombo(const QString ¤tPath) { | 1131 | void OpieFtp::fillCombo(const QString ¤tPath) { |
1129 | 1132 | ||
1130 | currentPathCombo->lineEdit()->setText(currentPath); | 1133 | currentPathCombo->lineEdit()->setText(currentPath); |
1131 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1134 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1132 | currentPathCombo->clear(); | 1135 | currentPathCombo->clear(); |
1133 | localDirPathStringList.prepend(currentPath ); | 1136 | localDirPathStringList.prepend(currentPath ); |
1134 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 1137 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
1135 | } | 1138 | } |
1136 | currentPathCombo->lineEdit()->setText(currentPath); | 1139 | currentPathCombo->lineEdit()->setText(currentPath); |
1137 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1140 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1138 | currentPathCombo->clear(); | 1141 | currentPathCombo->clear(); |
1139 | remoteDirPathStringList.prepend(currentPath ); | 1142 | remoteDirPathStringList.prepend(currentPath ); |
1140 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1143 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1141 | } | 1144 | } |
1142 | } | 1145 | } |
1143 | 1146 | ||
1144 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { | 1147 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { |
1145 | 1148 | ||
1146 | currentPathCombo->lineEdit()->setText(currentPath); | 1149 | currentPathCombo->lineEdit()->setText(currentPath); |
1147 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1150 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1148 | currentPathCombo->clear(); | 1151 | currentPathCombo->clear(); |
1149 | remoteDirPathStringList.prepend(currentPath ); | 1152 | remoteDirPathStringList.prepend(currentPath ); |
1150 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1153 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1151 | } | 1154 | } |
1152 | } | 1155 | } |
1153 | 1156 | ||
1154 | void OpieFtp::currentPathComboChanged() | 1157 | void OpieFtp::currentPathComboChanged() |
1155 | { | 1158 | { |
1156 | QString oldRemoteCurrentDir = currentRemoteDir; | 1159 | QString oldRemoteCurrentDir = currentRemoteDir; |
1157 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 1160 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); |
1158 | if (TabWidget->currentPageIndex() == 0) { | 1161 | if (TabWidget->currentPageIndex() == 0) { |
1159 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 1162 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
1160 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 1163 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
1161 | populateLocalView(); | 1164 | populateLocalView(); |
1162 | } else { | 1165 | } else { |
1163 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 1166 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
1164 | } | 1167 | } |
1165 | } | 1168 | } |
1166 | if (TabWidget->currentPageIndex() == 1) { | 1169 | if (TabWidget->currentPageIndex() == 1) { |
1167 | currentRemoteDir = currentPathCombo->lineEdit()->text(); | 1170 | currentRemoteDir = currentPathCombo->lineEdit()->text(); |
1168 | if(currentRemoteDir.right(1) !="/") { | 1171 | if(currentRemoteDir.right(1) !="/") { |
1169 | currentRemoteDir = currentRemoteDir +"/"; | 1172 | currentRemoteDir = currentRemoteDir +"/"; |
1170 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1173 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1171 | } | 1174 | } |
1172 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 1175 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
1173 | currentRemoteDir = oldRemoteCurrentDir; | 1176 | currentRemoteDir = oldRemoteCurrentDir; |
1174 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1177 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1175 | } | 1178 | } |
1176 | 1179 | ||
1177 | remoteDirList( (const QString &)currentRemoteDir); | 1180 | remoteDirList( (const QString &)currentRemoteDir); |
1178 | } | 1181 | } |
1179 | } | 1182 | } |
1180 | 1183 | ||
1181 | void OpieFtp::switchToLocalTab() | 1184 | void OpieFtp::switchToLocalTab() |
1182 | { | 1185 | { |
1183 | TabWidget->setCurrentPage(0); | 1186 | TabWidget->setCurrentPage(0); |
1184 | } | 1187 | } |
1185 | 1188 | ||
1186 | void OpieFtp::switchToRemoteTab() | 1189 | void OpieFtp::switchToRemoteTab() |
1187 | { | 1190 | { |
1188 | TabWidget->setCurrentPage(1); | 1191 | TabWidget->setCurrentPage(1); |
1189 | } | 1192 | } |
1190 | 1193 | ||
1191 | void OpieFtp::switchToConfigTab() | 1194 | void OpieFtp::switchToConfigTab() |
1192 | { | 1195 | { |
1193 | TabWidget->setCurrentPage(2); | 1196 | TabWidget->setCurrentPage(2); |
1194 | } | 1197 | } |
1195 | 1198 | ||
1196 | void OpieFtp::readConfig() | 1199 | void OpieFtp::readConfig() |
1197 | { | 1200 | { |
1198 | fillCombos(); | 1201 | fillCombos(); |
1199 | Config cfg("opieftp"); | 1202 | Config cfg("opieftp"); |
1200 | cfg.setGroup("Server"); | 1203 | cfg.setGroup("Server"); |
1201 | currentServerConfig = cfg.readNumEntry("currentServer", -1); | 1204 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
1202 | 1205 | ||
1203 | // qDebug("Reading %d", currentServerConfig); | 1206 | // qDebug("Reading %d", currentServerConfig); |
1204 | serverComboSelected( currentServerConfig-1); | 1207 | serverComboSelected( currentServerConfig-1); |
1205 | 1208 | ||
1206 | } | 1209 | } |
1207 | 1210 | ||
1208 | void OpieFtp::writeConfig() | 1211 | void OpieFtp::writeConfig() |
1209 | { | 1212 | { |
1210 | qDebug("write config"); | 1213 | qDebug("write config"); |
1211 | Config cfg("opieftp"); | 1214 | Config cfg("opieftp"); |
1212 | cfg.setGroup("Server"); | 1215 | cfg.setGroup("Server"); |
1213 | 1216 | ||
1214 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1217 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1215 | 1218 | ||
1216 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1219 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1217 | 1220 | ||
1218 | if( currentServerConfig == -1) { | 1221 | if( currentServerConfig == -1) { |
1219 | 1222 | ||
1220 | for (int i = 1; i <= numberOfEntries; i++) { | 1223 | for (int i = 1; i <= numberOfEntries; i++) { |
1221 | temp.setNum(i); | 1224 | temp.setNum(i); |
1222 | cfg.setGroup("Server"); | 1225 | cfg.setGroup("Server"); |
1223 | QString tempStr = cfg.readEntry( temp,""); | 1226 | QString tempStr = cfg.readEntry( temp,""); |
1224 | } | 1227 | } |
1225 | 1228 | ||
1226 | temp.setNum( numberOfEntries + 1); | 1229 | temp.setNum( numberOfEntries + 1); |
1227 | cfg.setGroup("Server"); | 1230 | cfg.setGroup("Server"); |
1228 | 1231 | ||
1229 | remoteServerStr = cfg.readEntry( temp,""); | 1232 | remoteServerStr = cfg.readEntry( temp,""); |
1230 | 1233 | ||
1231 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1234 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1232 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1235 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1233 | 1236 | ||
1234 | temp.setNum(numberOfEntries+1); | 1237 | temp.setNum(numberOfEntries+1); |
1235 | cfg.setGroup("Server"); | 1238 | cfg.setGroup("Server"); |
1236 | 1239 | ||
1237 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1240 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1238 | cfg.writeEntry("currentServer", numberOfEntries+1); | 1241 | cfg.writeEntry("currentServer", numberOfEntries+1); |
1239 | 1242 | ||
1240 | currentServerConfig = numberOfEntries+1; | 1243 | currentServerConfig = numberOfEntries+1; |
1241 | qDebug("setting currentserverconfig to %d", currentServerConfig); | 1244 | qDebug("setting currentserverconfig to %d", currentServerConfig); |
1242 | 1245 | ||
1243 | cfg.setGroup(temp); | 1246 | cfg.setGroup(temp); |
1244 | if(!newServerName.isEmpty()) | 1247 | if(!newServerName.isEmpty()) |
1245 | cfg.writeEntry("ServerName", newServerName); | 1248 | cfg.writeEntry("ServerName", newServerName); |
1246 | 1249 | ||
1247 | cfg.writeEntry("RemotePath", remotePath->text()); | 1250 | cfg.writeEntry("RemotePath", remotePath->text()); |
1248 | 1251 | ||
1249 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1252 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1250 | 1253 | ||
1251 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1254 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1252 | cfg.setGroup("Server"); | 1255 | cfg.setGroup("Server"); |
1253 | 1256 | ||
1254 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1257 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1255 | 1258 | ||
1256 | } | 1259 | } |
1257 | } | 1260 | } |
1258 | 1261 | ||
1259 | void OpieFtp::clearCombos() { | 1262 | void OpieFtp::clearCombos() { |
1260 | qDebug("clearing"); | 1263 | qDebug("clearing"); |
1261 | ServerComboBox->clear(); | 1264 | ServerComboBox->clear(); |
1262 | UsernameComboBox->clear(); | 1265 | UsernameComboBox->clear(); |
1263 | PasswordEdit->clear(); | 1266 | PasswordEdit->clear(); |
1264 | serverListView->clear(); | 1267 | serverListView->clear(); |
1265 | } | 1268 | } |
1266 | 1269 | ||
1267 | 1270 | ||
1268 | void OpieFtp::fillCombos() | 1271 | void OpieFtp::fillCombos() |
1269 | { | 1272 | { |
1270 | clearCombos(); | 1273 | clearCombos(); |
1271 | 1274 | ||
1272 | Config cfg("opieftp"); | 1275 | Config cfg("opieftp"); |
1273 | cfg.setGroup("Server"); | 1276 | cfg.setGroup("Server"); |
1274 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1277 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1275 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1278 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1276 | 1279 | ||
1277 | for (int i = 1; i <= numberOfEntries; i++) { | 1280 | for (int i = 1; i <= numberOfEntries; i++) { |
1278 | temp.setNum(i); | 1281 | temp.setNum(i); |
1279 | qDebug(temp); | 1282 | qDebug(temp); |
1280 | cfg.setGroup("Server"); | 1283 | cfg.setGroup("Server"); |
1281 | remoteServerStr = cfg.readEntry( temp,""); | 1284 | remoteServerStr = cfg.readEntry( temp,""); |
1282 | qDebug( remoteServerStr); | 1285 | qDebug( remoteServerStr); |
1283 | 1286 | ||
1284 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1287 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1285 | port = remoteServerStr.right( divider - 1); | 1288 | port = remoteServerStr.right( divider - 1); |
1286 | bool ok; | 1289 | bool ok; |
1287 | PortSpinBox->setValue( port.toInt(&ok,10)); | 1290 | PortSpinBox->setValue( port.toInt(&ok,10)); |
1288 | 1291 | ||
1289 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1292 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1290 | qDebug( "remote server string "+remoteServerStr); | 1293 | qDebug( "remote server string "+remoteServerStr); |
1291 | ServerComboBox->insertItem( remoteServerStr ); | 1294 | ServerComboBox->insertItem( remoteServerStr ); |
1292 | 1295 | ||
1293 | cfg.setGroup(temp); | 1296 | cfg.setGroup(temp); |
1294 | 1297 | ||
1295 | username = cfg.readEntry(temp); | 1298 | username = cfg.readEntry(temp); |
1296 | UsernameComboBox->insertItem(username); | 1299 | UsernameComboBox->insertItem(username); |
1297 | password = cfg.readEntryCrypt(username,""); | 1300 | password = cfg.readEntryCrypt(username,""); |
1298 | PasswordEdit->setText(password); | 1301 | PasswordEdit->setText(password); |
1299 | 1302 | ||
1300 | serverListView->insertItem( cfg.readEntry("ServerName")); | 1303 | serverListView->insertItem( cfg.readEntry("ServerName")); |
1301 | } | 1304 | } |
1302 | } | 1305 | } |
1303 | 1306 | ||
1304 | 1307 | ||
1305 | void OpieFtp::serverComboSelected(int index) | 1308 | void OpieFtp::serverComboSelected(int index) |
1306 | { | 1309 | { |
1307 | currentServerConfig = index+1; | 1310 | currentServerConfig = index+1; |
1308 | qDebug("server combo selected %d", index+1); | 1311 | qDebug("server combo selected %d", index+1); |
1309 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1312 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1310 | // remoteServerStr = ServerComboBox->text(index); | 1313 | // remoteServerStr = ServerComboBox->text(index); |
1311 | 1314 | ||
1312 | Config cfg("opieftp"); | 1315 | Config cfg("opieftp"); |
1313 | cfg.setGroup("Server"); | 1316 | cfg.setGroup("Server"); |
1314 | // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1317 | // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1315 | 1318 | ||
1316 | temp.setNum(index+1); | 1319 | temp.setNum(index+1); |
1317 | remoteServerStr = cfg.readEntry( temp,""); | 1320 | remoteServerStr = cfg.readEntry( temp,""); |
1318 | 1321 | ||
1319 | qDebug("Group" +temp); | 1322 | qDebug("Group" +temp); |
1320 | cfg.setGroup(temp); | 1323 | cfg.setGroup(temp); |
1321 | // qDebug(temp); | 1324 | // qDebug(temp); |
1322 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1325 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1323 | port = remoteServerStr.right( divider - 1); | 1326 | port = remoteServerStr.right( divider - 1); |
1324 | bool ok; | 1327 | bool ok; |
1325 | int portInt = port.toInt(&ok,10); | 1328 | int portInt = port.toInt(&ok,10); |
1326 | if( portInt == 0) portInt = 21; | 1329 | if( portInt == 0) portInt = 21; |
1327 | 1330 | ||
1328 | ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); | 1331 | ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); |
1329 | 1332 | ||
1330 | PortSpinBox->setValue( portInt); | 1333 | PortSpinBox->setValue( portInt); |
1331 | 1334 | ||
1332 | remotePath->setText(cfg.readEntry("RemotePath", "/")); | 1335 | remotePath->setText(cfg.readEntry("RemotePath", "/")); |
1333 | 1336 | ||
1334 | username = cfg.readEntry("Username", "anonymous"); | 1337 | username = cfg.readEntry("Username", "anonymous"); |
1335 | UsernameComboBox->lineEdit()->setText(username); | 1338 | UsernameComboBox->lineEdit()->setText(username); |
1336 | qDebug(username); | 1339 | qDebug(username); |
1337 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); | 1340 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); |
1338 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); | 1341 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); |
1339 | // UsernameComboBox | 1342 | // UsernameComboBox |
1340 | // PasswordEdit | 1343 | // PasswordEdit |
1341 | 1344 | ||
1342 | cfg.setGroup("Server"); | 1345 | cfg.setGroup("Server"); |
1343 | temp.sprintf("%d",currentServerConfig); | 1346 | temp.sprintf("%d",currentServerConfig); |
1344 | cfg.writeEntry("currentServer", temp); | 1347 | cfg.writeEntry("currentServer", temp); |
1345 | 1348 | ||
1346 | fuckeduphack = TRUE; | 1349 | fuckeduphack = TRUE; |
1347 | serverListView->setCurrentItem( index); | 1350 | serverListView->setCurrentItem( index); |
1348 | fuckeduphack=FALSE; | 1351 | fuckeduphack=FALSE; |
1349 | qDebug("server list set selected %d",index); | 1352 | qDebug("server list set selected %d",index); |
1350 | update(); | 1353 | update(); |
1351 | } | 1354 | } |
1352 | 1355 | ||
1353 | void OpieFtp::deleteServer() | 1356 | void OpieFtp::deleteServer() |
1354 | { | 1357 | { |
1355 | QString username, remoteServerStr, remotePathStr, password, port, temp, servername; | 1358 | QString username, remoteServerStr, remotePathStr, password, port, temp, servername; |
1356 | remoteServerStr = ServerComboBox->currentText( ); | 1359 | remoteServerStr = ServerComboBox->currentText( ); |
1357 | username = UsernameComboBox->currentText(); | 1360 | username = UsernameComboBox->currentText(); |
1358 | servername=serverListView->currentText(); | 1361 | servername=serverListView->currentText(); |
1359 | 1362 | ||
1360 | Config cfg("opieftp"); | 1363 | Config cfg("opieftp"); |
1361 | cfg.setGroup("Server"); | 1364 | cfg.setGroup("Server"); |
1362 | QString tempname; | 1365 | QString tempname; |
1363 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1366 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1364 | 1367 | ||
1365 | for (int i = 1; i <= numberOfEntries; i++) { | 1368 | for (int i = 1; i <= numberOfEntries; i++) { |
1366 | temp.setNum(i); | 1369 | temp.setNum(i); |
1367 | // cfg.setGroup("Server"); | 1370 | // cfg.setGroup("Server"); |
1368 | cfg.setGroup(QString::number(i)); | 1371 | cfg.setGroup(QString::number(i)); |
1369 | tempname=cfg.readEntry( "ServerName",""); | 1372 | tempname=cfg.readEntry( "ServerName",""); |
1370 | 1373 | ||
1371 | if( tempname.find( servername,0,TRUE) != -1 ) { | 1374 | if( tempname.find( servername,0,TRUE) != -1 ) { |
1372 | // servername.find( cfg.readEntry("ServerName")) != -1 && | 1375 | // servername.find( cfg.readEntry("ServerName")) != -1 && |
1373 | // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && | 1376 | // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && |
1374 | // username.find( cfg.readEntry("Username")) != -1) { | 1377 | // username.find( cfg.readEntry("Username")) != -1) { |
1375 | 1378 | ||
1376 | serverListView->removeItem(i); | 1379 | serverListView->removeItem(i); |
1377 | 1380 | ||
1378 | qDebug("OK DELETE "+tempname); | 1381 | qDebug("OK DELETE "+tempname); |
1379 | cfg.removeEntry(QString::number(i)); | 1382 | cfg.removeEntry(QString::number(i)); |
1380 | for ( i; i <= numberOfEntries; i++) { | 1383 | for ( i; i <= numberOfEntries; i++) { |
1381 | cfg.setGroup("Server"); | 1384 | cfg.setGroup("Server"); |
1382 | cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); | 1385 | cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); |
1383 | 1386 | ||
1384 | cfg.setGroup(QString::number(i+1)); //get next server config | 1387 | cfg.setGroup(QString::number(i+1)); //get next server config |
1385 | servername=cfg.readEntry("ServerName"); | 1388 | servername=cfg.readEntry("ServerName"); |
1386 | remoteServerStr=cfg.readEntry("RemotePath"); | 1389 | remoteServerStr=cfg.readEntry("RemotePath"); |
1387 | username=cfg.readEntry("Username"); | 1390 | username=cfg.readEntry("Username"); |
1388 | password=cfg.readEntryCrypt( username); | 1391 | password=cfg.readEntryCrypt( username); |
1389 | 1392 | ||
1390 | cfg.setGroup(QString::number(i)); | 1393 | cfg.setGroup(QString::number(i)); |
1391 | 1394 | ||
1392 | cfg.writeEntry("RemotePath", remoteServerStr); | 1395 | cfg.writeEntry("RemotePath", remoteServerStr); |
1393 | cfg.writeEntry("ServerName", servername); | 1396 | cfg.writeEntry("ServerName", servername); |
1394 | cfg.writeEntry("Username", username); | 1397 | cfg.writeEntry("Username", username); |
1395 | cfg.writeEntryCrypt( username, password); | 1398 | cfg.writeEntryCrypt( username, password); |
1396 | 1399 | ||
1397 | } | 1400 | } |
1398 | cfg.setGroup("Server"); | 1401 | cfg.setGroup("Server"); |
1399 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries - 1 )); | 1402 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries - 1 )); |
1400 | } | 1403 | } |
1401 | } | 1404 | } |
1402 | cfg.setGroup(QString::number(numberOfEntries)); | 1405 | cfg.setGroup(QString::number(numberOfEntries)); |
1403 | cfg.removeEntry("Server"); | 1406 | cfg.removeEntry("Server"); |
1404 | cfg.removeEntry("RemotePath"); | 1407 | cfg.removeEntry("RemotePath"); |
1405 | cfg.removeEntry("ServerName"); | 1408 | cfg.removeEntry("ServerName"); |
1406 | username=cfg.readEntry("Username"); | 1409 | username=cfg.readEntry("Username"); |
1407 | cfg.removeEntry("Username"); | 1410 | cfg.removeEntry("Username"); |
1408 | cfg.removeEntry(username); | 1411 | cfg.removeEntry(username); |
1409 | 1412 | ||
1410 | currentServerConfig=currentServerConfig-1; | 1413 | currentServerConfig=currentServerConfig-1; |
1411 | 1414 | ||
1412 | fillCombos(); | 1415 | fillCombos(); |
1413 | update(); | 1416 | update(); |
1414 | } | 1417 | } |
1415 | 1418 | ||
1416 | void OpieFtp::upDir() | 1419 | void OpieFtp::upDir() |
1417 | { | 1420 | { |
1418 | if (TabWidget->currentPageIndex() == 0) { | 1421 | if (TabWidget->currentPageIndex() == 0) { |
1419 | QString current = currentDir.canonicalPath(); | 1422 | QString current = currentDir.canonicalPath(); |
1420 | QDir dir(current); | 1423 | QDir dir(current); |
1421 | dir.cdUp(); | 1424 | dir.cdUp(); |
1422 | current = dir.canonicalPath(); | 1425 | current = dir.canonicalPath(); |
1423 | chdir( current.latin1() ); | 1426 | chdir( current.latin1() ); |
1424 | currentDir.cd( current, TRUE); | 1427 | currentDir.cd( current, TRUE); |
1425 | populateLocalView(); | 1428 | populateLocalView(); |
1426 | update(); | 1429 | update(); |
1427 | } else { | 1430 | } else { |
1428 | if( FtpCDUp( conn) == 0) { | 1431 | if( FtpCDUp( conn) == 0) { |
1429 | QString msg; | 1432 | QString msg; |
1430 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 1433 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
1431 | msg.replace(QRegExp(":"),"\n"); | 1434 | msg.replace(QRegExp(":"),"\n"); |
1432 | QMessageBox::message(tr("Note"),msg); | 1435 | QMessageBox::message(tr("Note"),msg); |
1433 | // qDebug(msg); | 1436 | // qDebug(msg); |
1434 | } | 1437 | } |
1435 | char path[256]; | 1438 | char path[256]; |
1436 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 1439 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
1437 | QString msg; | 1440 | QString msg; |
1438 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 1441 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
1439 | msg.replace(QRegExp(":"),"\n"); | 1442 | msg.replace(QRegExp(":"),"\n"); |
1440 | QMessageBox::message(tr("Note"),msg); | 1443 | QMessageBox::message(tr("Note"),msg); |
1441 | // qDebug(msg); | 1444 | // qDebug(msg); |
1442 | } | 1445 | } |
1443 | currentRemoteDir=path; | 1446 | currentRemoteDir=path; |
1444 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1447 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1445 | if(currentRemoteDir.right(1) !="/") | 1448 | if(currentRemoteDir.right(1) !="/") |
1446 | currentRemoteDir +="/"; | 1449 | currentRemoteDir +="/"; |
1447 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 1450 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
1448 | fillRemoteCombo( (const QString &)currentRemoteDir); | 1451 | fillRemoteCombo( (const QString &)currentRemoteDir); |
1449 | 1452 | ||
1450 | } | 1453 | } |
1451 | } | 1454 | } |
1452 | 1455 | ||
1453 | void OpieFtp::docButtonPushed() { | 1456 | void OpieFtp::docButtonPushed() { |
1454 | QString current = QPEApplication::documentDir(); | 1457 | QString current = QPEApplication::documentDir(); |
1455 | chdir( current.latin1() ); | 1458 | chdir( current.latin1() ); |
1456 | currentDir.cd( current, TRUE); | 1459 | currentDir.cd( current, TRUE); |
1457 | populateLocalView(); | 1460 | populateLocalView(); |
1458 | update(); | 1461 | update(); |
1459 | 1462 | ||
1460 | } | 1463 | } |
1461 | 1464 | ||
1462 | void OpieFtp::homeButtonPushed() { | 1465 | void OpieFtp::homeButtonPushed() { |
1463 | QString current = QDir::homeDirPath(); | 1466 | QString current = QDir::homeDirPath(); |
1464 | chdir( current.latin1() ); | 1467 | chdir( current.latin1() ); |
1465 | currentDir.cd( current, TRUE); | 1468 | currentDir.cd( current, TRUE); |
1466 | populateLocalView(); | 1469 | populateLocalView(); |
1467 | update(); | 1470 | update(); |
1468 | } | 1471 | } |
1469 | 1472 | ||
1470 | void OpieFtp::doAbout() { | 1473 | void OpieFtp::doAbout() { |
1471 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" | 1474 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" |
1472 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1475 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1473 | "and uses ftplib copyright 1996-2000\n" | 1476 | "and uses ftplib copyright 1996-2000\n" |
1474 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" | 1477 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" |
1475 | "and is licensed by the GPL"); | 1478 | "and is licensed by the GPL"); |
1476 | } | 1479 | } |
1477 | 1480 | ||
1478 | void OpieFtp::NewServer() { | 1481 | void OpieFtp::NewServer() { |
1479 | InputDialog *fileDlg; | 1482 | InputDialog *fileDlg; |
1480 | fileDlg = new InputDialog(this,tr("New Server name"),TRUE, 0); | 1483 | fileDlg = new InputDialog(this,tr("New Server name"),TRUE, 0); |
1481 | fileDlg->exec(); | 1484 | fileDlg->exec(); |
1482 | Config cfg("opieftp"); | 1485 | Config cfg("opieftp"); |
1483 | if( fileDlg->result() == 1 ) { | 1486 | if( fileDlg->result() == 1 ) { |
1484 | newServerName = fileDlg->LineEdit1->text(); | 1487 | newServerName = fileDlg->LineEdit1->text(); |
1485 | for(int i=1;i<serverListView->count();i++) { | 1488 | for(int i=1;i<serverListView->count();i++) { |
1486 | cfg.setGroup( QString::number(i)); | 1489 | cfg.setGroup( QString::number(i)); |
1487 | if(cfg.readEntry("ServerName").find(newServerName,0,TRUE) != -1) { | 1490 | if(cfg.readEntry("ServerName").find(newServerName,0,TRUE) != -1) { |
1488 | QMessageBox::message(tr("OpieFtp"),tr("Sorry name already taken")); | 1491 | QMessageBox::message(tr("OpieFtp"),tr("Sorry name already taken")); |
1489 | return; | 1492 | return; |
1490 | } | 1493 | } |
1491 | } | 1494 | } |
1492 | currentServerConfig =-1; | 1495 | currentServerConfig =-1; |
1493 | writeConfig(); | 1496 | writeConfig(); |
1494 | serverListView->insertItem( newServerName ); | 1497 | serverListView->insertItem( newServerName ); |
1495 | serverListView->setCurrentItem( serverListView->count()); | 1498 | serverListView->setCurrentItem( serverListView->count()); |
1496 | } | 1499 | } |
1497 | } | 1500 | } |
1498 | 1501 | ||
1499 | void OpieFtp::serverListClicked( const QString &item) { | 1502 | void OpieFtp::serverListClicked( const QString &item) { |
1500 | if(item.isEmpty()) return; | 1503 | if(item.isEmpty()) return; |
1501 | Config cfg("opieftp"); | 1504 | Config cfg("opieftp"); |
1502 | qDebug("highltined "+item); | 1505 | qDebug("highltined "+item); |
1503 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1506 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1504 | for (int i = 1; i <= numberOfEntries; i++) { | 1507 | for (int i = 1; i <= numberOfEntries; i++) { |
1505 | cfg.setGroup(QString::number(i)); | 1508 | cfg.setGroup(QString::number(i)); |
1506 | if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) | 1509 | if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) |
1507 | serverComboSelected(i-1); | 1510 | serverComboSelected(i-1); |
1508 | } | 1511 | } |
1509 | } | 1512 | } |