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