-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index e15bbef..d78b7d1 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -1,527 +1,531 @@ | |||
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 | |||
16 | extern "C" { | ||
15 | #include "ftplib.h" | 17 | #include "ftplib.h" |
18 | } | ||
19 | |||
16 | #include "inputDialog.h" | 20 | #include "inputDialog.h" |
17 | 21 | ||
18 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
19 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
20 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
24 | #include <qpe/mimetype.h> | 28 | #include <qpe/mimetype.h> |
25 | #include <qpe/qpemessagebox.h> | 29 | #include <qpe/qpemessagebox.h> |
26 | 30 | ||
27 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
28 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
29 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
30 | #include <qtoolbutton.h> | 34 | #include <qtoolbutton.h> |
31 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
32 | #include <qdir.h> | 36 | #include <qdir.h> |
33 | #include <qfile.h> | 37 | #include <qfile.h> |
34 | #include <qstring.h> | 38 | #include <qstring.h> |
35 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
36 | #include <qpopupmenu.h> | 40 | #include <qpopupmenu.h> |
37 | #include <qlistview.h> | 41 | #include <qlistview.h> |
38 | #include <qmainwindow.h> | 42 | #include <qmainwindow.h> |
39 | #include <qlabel.h> | 43 | #include <qlabel.h> |
40 | #include <qprogressbar.h> | 44 | #include <qprogressbar.h> |
41 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
42 | #include <qtabwidget.h> | 46 | #include <qtabwidget.h> |
43 | #include <qwidget.h> | 47 | #include <qwidget.h> |
44 | #include <qlayout.h> | 48 | #include <qlayout.h> |
45 | #include <qimage.h> | 49 | #include <qimage.h> |
46 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
47 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
48 | #include <qlineedit.h> | 52 | #include <qlineedit.h> |
49 | #include <qregexp.h> | 53 | #include <qregexp.h> |
50 | 54 | ||
51 | #include <unistd.h> | 55 | #include <unistd.h> |
52 | #include <stdlib.h> | 56 | #include <stdlib.h> |
53 | 57 | ||
54 | 58 | ||
55 | QProgressBar *ProgressBar; | 59 | QProgressBar *ProgressBar; |
56 | static netbuf *conn=NULL; | 60 | static netbuf *conn=NULL; |
57 | 61 | ||
58 | static int log_progress(netbuf *ctl, int xfered, void *arg) | 62 | static int log_progress(netbuf *ctl, int xfered, void *arg) |
59 | { | 63 | { |
60 | int fsz = *(int *)arg; | 64 | int fsz = *(int *)arg; |
61 | int pct = (xfered * 100) / fsz; | 65 | int pct = (xfered * 100) / fsz; |
62 | // printf("%3d%%\r", pct); | 66 | // printf("%3d%%\r", pct); |
63 | // fflush(stdout); | 67 | // fflush(stdout); |
64 | ProgressBar->setProgress(xfered); | 68 | ProgressBar->setProgress(xfered); |
65 | qApp->processEvents(); | 69 | qApp->processEvents(); |
66 | return 1; | 70 | return 1; |
67 | } | 71 | } |
68 | 72 | ||
69 | OpieFtp::OpieFtp( ) | 73 | OpieFtp::OpieFtp( ) |
70 | : QMainWindow( ) | 74 | : QMainWindow( ) |
71 | { | 75 | { |
72 | setCaption( tr( "OpieFtp" ) ); | 76 | setCaption( tr( "OpieFtp" ) ); |
73 | 77 | ||
74 | QGridLayout *layout = new QGridLayout( this ); | 78 | QGridLayout *layout = new QGridLayout( this ); |
75 | layout->setSpacing( 2); | 79 | layout->setSpacing( 2); |
76 | layout->setMargin( 2); | 80 | layout->setMargin( 2); |
77 | 81 | ||
78 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 82 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
79 | 83 | ||
80 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 84 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
81 | // QPEToolBar *menuBar = new QPEToolBar(this); | 85 | // QPEToolBar *menuBar = new QPEToolBar(this); |
82 | // menuBar->setHorizontalStretchable( TRUE ); | 86 | // menuBar->setHorizontalStretchable( TRUE ); |
83 | 87 | ||
84 | connectionMenu = new QPopupMenu( this ); | 88 | connectionMenu = new QPopupMenu( this ); |
85 | localMenu = new QPopupMenu( this ); | 89 | localMenu = new QPopupMenu( this ); |
86 | remoteMenu = new QPopupMenu( this ); | 90 | remoteMenu = new QPopupMenu( this ); |
87 | tabMenu = new QPopupMenu( this ); | 91 | tabMenu = new QPopupMenu( this ); |
88 | 92 | ||
89 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); | 93 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); |
90 | 94 | ||
91 | menuBar->insertItem( tr( "Connection" ), connectionMenu); | 95 | menuBar->insertItem( tr( "Connection" ), connectionMenu); |
92 | menuBar->insertItem( tr( "Local" ), localMenu); | 96 | menuBar->insertItem( tr( "Local" ), localMenu); |
93 | menuBar->insertItem( tr( "Remote" ), remoteMenu); | 97 | menuBar->insertItem( tr( "Remote" ), remoteMenu); |
94 | menuBar->insertItem( tr( "View" ), tabMenu); | 98 | menuBar->insertItem( tr( "View" ), tabMenu); |
95 | 99 | ||
96 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 100 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
97 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 101 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
98 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 102 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
99 | 103 | ||
100 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 104 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
101 | localMenu->insertSeparator(); | 105 | localMenu->insertSeparator(); |
102 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 106 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
103 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 107 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
104 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 108 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
105 | localMenu->insertSeparator(); | 109 | localMenu->insertSeparator(); |
106 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 110 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
107 | localMenu->setCheckable(TRUE); | 111 | localMenu->setCheckable(TRUE); |
108 | 112 | ||
109 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 113 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
110 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 114 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
111 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 115 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
112 | remoteMenu->insertSeparator(); | 116 | remoteMenu->insertSeparator(); |
113 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 117 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
114 | 118 | ||
115 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 119 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
116 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 120 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
117 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); | 121 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); |
118 | tabMenu->insertSeparator(); | 122 | tabMenu->insertSeparator(); |
119 | tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 123 | tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
120 | tabMenu->setCheckable(TRUE); | 124 | tabMenu->setCheckable(TRUE); |
121 | 125 | ||
122 | 126 | ||
123 | 127 | ||
124 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); | 128 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); |
125 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); | 129 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); |
126 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 130 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
127 | cdUpButton ->setFlat(TRUE); | 131 | cdUpButton ->setFlat(TRUE); |
128 | layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); | 132 | layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); |
129 | cdUpButton->hide(); | 133 | cdUpButton->hide(); |
130 | 134 | ||
131 | // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 135 | // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
132 | // docButton->setFixedSize( QSize( 20, 20 ) ); | 136 | // docButton->setFixedSize( QSize( 20, 20 ) ); |
133 | // connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 137 | // connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
134 | // docButton->setFlat(TRUE); | 138 | // docButton->setFlat(TRUE); |
135 | // layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); | 139 | // layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
136 | 140 | ||
137 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); | 141 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); |
138 | homeButton->setFixedSize( QSize( 20, 20 ) ); | 142 | homeButton->setFixedSize( QSize( 20, 20 ) ); |
139 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 143 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
140 | homeButton->setFlat(TRUE); | 144 | homeButton->setFlat(TRUE); |
141 | layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); | 145 | layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); |
142 | homeButton->hide(); | 146 | homeButton->hide(); |
143 | 147 | ||
144 | TabWidget = new QTabWidget( this, "TabWidget" ); | 148 | TabWidget = new QTabWidget( this, "TabWidget" ); |
145 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); | 149 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); |
146 | 150 | ||
147 | // TabWidget->setTabShape(QTabWidget::Triangular); | 151 | // TabWidget->setTabShape(QTabWidget::Triangular); |
148 | 152 | ||
149 | tab = new QWidget( TabWidget, "tab" ); | 153 | tab = new QWidget( TabWidget, "tab" ); |
150 | tabLayout = new QGridLayout( tab ); | 154 | tabLayout = new QGridLayout( tab ); |
151 | tabLayout->setSpacing( 2); | 155 | tabLayout->setSpacing( 2); |
152 | tabLayout->setMargin( 2); | 156 | tabLayout->setMargin( 2); |
153 | 157 | ||
154 | Local_View = new QListView( tab, "Local_View" ); | 158 | Local_View = new QListView( tab, "Local_View" ); |
155 | // Local_View->setResizePolicy( QListView::AutoOneFit ); | 159 | // Local_View->setResizePolicy( QListView::AutoOneFit ); |
156 | Local_View->addColumn( tr("File"),150); | 160 | Local_View->addColumn( tr("File"),150); |
157 | Local_View->addColumn( tr("Date"),-1); | 161 | Local_View->addColumn( tr("Date"),-1); |
158 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 162 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
159 | Local_View->addColumn( tr("Size"),-1); | 163 | Local_View->addColumn( tr("Size"),-1); |
160 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 164 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
161 | Local_View->setAllColumnsShowFocus(TRUE); | 165 | Local_View->setAllColumnsShowFocus(TRUE); |
162 | 166 | ||
163 | Local_View->setMultiSelection( TRUE); | 167 | Local_View->setMultiSelection( TRUE); |
164 | Local_View->setSelectionMode(QListView::Extended); | 168 | Local_View->setSelectionMode(QListView::Extended); |
165 | Local_View->setFocusPolicy(QWidget::ClickFocus); | 169 | Local_View->setFocusPolicy(QWidget::ClickFocus); |
166 | 170 | ||
167 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 171 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
168 | 172 | ||
169 | tabLayout->addWidget( Local_View, 0, 0 ); | 173 | tabLayout->addWidget( Local_View, 0, 0 ); |
170 | 174 | ||
171 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 175 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
172 | this,SLOT( localListClicked(QListViewItem *)) ); | 176 | this,SLOT( localListClicked(QListViewItem *)) ); |
173 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), | 177 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), |
174 | // this,SLOT( localListClicked(QListViewItem *)) ); | 178 | // this,SLOT( localListClicked(QListViewItem *)) ); |
175 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 179 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
176 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 180 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
177 | 181 | ||
178 | TabWidget->insertTab( tab, tr( "Local" ) ); | 182 | TabWidget->insertTab( tab, tr( "Local" ) ); |
179 | 183 | ||
180 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 184 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
181 | tabLayout_2 = new QGridLayout( tab_2 ); | 185 | tabLayout_2 = new QGridLayout( tab_2 ); |
182 | tabLayout_2->setSpacing( 2); | 186 | tabLayout_2->setSpacing( 2); |
183 | tabLayout_2->setMargin( 2); | 187 | tabLayout_2->setMargin( 2); |
184 | 188 | ||
185 | Remote_View = new QListView( tab_2, "Remote_View" ); | 189 | Remote_View = new QListView( tab_2, "Remote_View" ); |
186 | Remote_View->addColumn( tr("File"),150); | 190 | Remote_View->addColumn( tr("File"),150); |
187 | Remote_View->addColumn( tr("Date"),-1); | 191 | Remote_View->addColumn( tr("Date"),-1); |
188 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 192 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
189 | Remote_View->addColumn( tr("Size"),-1); | 193 | Remote_View->addColumn( tr("Size"),-1); |
190 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 194 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
191 | Remote_View->addColumn( tr("Dir"),-1); | 195 | Remote_View->addColumn( tr("Dir"),-1); |
192 | Remote_View->setColumnAlignment(4,QListView::AlignRight); | 196 | Remote_View->setColumnAlignment(4,QListView::AlignRight); |
193 | Remote_View->setAllColumnsShowFocus(TRUE); | 197 | Remote_View->setAllColumnsShowFocus(TRUE); |
194 | 198 | ||
195 | Remote_View->setMultiSelection( FALSE); | 199 | Remote_View->setMultiSelection( FALSE); |
196 | Remote_View->setSelectionMode(QListView::Extended); | 200 | Remote_View->setSelectionMode(QListView::Extended); |
197 | Remote_View->setFocusPolicy(QWidget::ClickFocus); | 201 | Remote_View->setFocusPolicy(QWidget::ClickFocus); |
198 | 202 | ||
199 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 203 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
200 | 204 | ||
201 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 205 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
202 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 206 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
203 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 207 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
204 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 208 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
205 | 209 | ||
206 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 210 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
207 | 211 | ||
208 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); | 212 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); |
209 | 213 | ||
210 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 214 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
211 | tabLayout_3 = new QGridLayout( tab_3 ); | 215 | tabLayout_3 = new QGridLayout( tab_3 ); |
212 | tabLayout_3->setSpacing( 2); | 216 | tabLayout_3->setSpacing( 2); |
213 | tabLayout_3->setMargin( 2); | 217 | tabLayout_3->setMargin( 2); |
214 | 218 | ||
215 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); | 219 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); |
216 | TextLabel1->setText( tr( "Username" ) ); | 220 | TextLabel1->setText( tr( "Username" ) ); |
217 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); | 221 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); |
218 | 222 | ||
219 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); | 223 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); |
220 | UsernameComboBox->setEditable(TRUE); | 224 | UsernameComboBox->setEditable(TRUE); |
221 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); | 225 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); |
222 | 226 | ||
223 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 227 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
224 | TextLabel2->setText( tr( "Password" ) ); | 228 | TextLabel2->setText( tr( "Password" ) ); |
225 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); | 229 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); |
226 | 230 | ||
227 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); | 231 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); |
228 | PasswordEdit->setEchoMode(QLineEdit::Password); | 232 | PasswordEdit->setEchoMode(QLineEdit::Password); |
229 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); | 233 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); |
230 | 234 | ||
231 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); | 235 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); |
232 | TextLabel3->setText( tr( "Remote server" ) ); | 236 | TextLabel3->setText( tr( "Remote server" ) ); |
233 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); | 237 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); |
234 | 238 | ||
235 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); | 239 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); |
236 | ServerComboBox->setEditable(TRUE); | 240 | ServerComboBox->setEditable(TRUE); |
237 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); | 241 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); |
238 | 242 | ||
239 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); | 243 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); |
240 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); | 244 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); |
241 | 245 | ||
242 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); | 246 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); |
243 | TextLabel5->setText( tr( "Remote path" ) ); | 247 | TextLabel5->setText( tr( "Remote path" ) ); |
244 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); | 248 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); |
245 | 249 | ||
246 | 250 | ||
247 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 251 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
248 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | 252 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); |
249 | 253 | ||
250 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 254 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
251 | TextLabel4->setText( tr( "Port" ) ); | 255 | TextLabel4->setText( tr( "Port" ) ); |
252 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); | 256 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); |
253 | 257 | ||
254 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); | 258 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); |
255 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 259 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
256 | PortSpinBox->setMaxValue(32786); | 260 | PortSpinBox->setMaxValue(32786); |
257 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); | 261 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); |
258 | 262 | ||
259 | QPushButton *deleteServerBtn; | 263 | QPushButton *deleteServerBtn; |
260 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); | 264 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); |
261 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); | 265 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); |
262 | 266 | ||
263 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); | 267 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); |
264 | 268 | ||
265 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); | 269 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); |
266 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); | 270 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); |
267 | connectServerBtn->setToggleButton(TRUE); | 271 | connectServerBtn->setToggleButton(TRUE); |
268 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); | 272 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); |
269 | 273 | ||
270 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 274 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
271 | tabLayout_3->addItem( spacer, 5, 0 ); | 275 | tabLayout_3->addItem( spacer, 5, 0 ); |
272 | 276 | ||
273 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 277 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
274 | 278 | ||
275 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 279 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
276 | this,SLOT(tabChanged(QWidget*))); | 280 | this,SLOT(tabChanged(QWidget*))); |
277 | 281 | ||
278 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 282 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
279 | currentDir.setPath( QDir::currentDirPath()); | 283 | currentDir.setPath( QDir::currentDirPath()); |
280 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 284 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
281 | 285 | ||
282 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 286 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
283 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); | 287 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); |
284 | 288 | ||
285 | currentPathCombo->setEditable(TRUE); | 289 | currentPathCombo->setEditable(TRUE); |
286 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 290 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
287 | 291 | ||
288 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 292 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
289 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 293 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
290 | 294 | ||
291 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 295 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
292 | this,SLOT(currentPathComboChanged())); | 296 | this,SLOT(currentPathComboChanged())); |
293 | 297 | ||
294 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 298 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
295 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); | 299 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); |
296 | 300 | ||
297 | // fillCombos(); | 301 | // fillCombos(); |
298 | 302 | ||
299 | filterStr="*"; | 303 | filterStr="*"; |
300 | b=FALSE; | 304 | b=FALSE; |
301 | populateLocalView(); | 305 | populateLocalView(); |
302 | readConfig(); | 306 | readConfig(); |
303 | ServerComboBox->setCurrentItem(currentServerConfig); | 307 | ServerComboBox->setCurrentItem(currentServerConfig); |
304 | 308 | ||
305 | TabWidget->setCurrentPage(2); | 309 | TabWidget->setCurrentPage(2); |
306 | } | 310 | } |
307 | 311 | ||
308 | OpieFtp::~OpieFtp() | 312 | OpieFtp::~OpieFtp() |
309 | { | 313 | { |
310 | } | 314 | } |
311 | 315 | ||
312 | void OpieFtp::cleanUp() | 316 | void OpieFtp::cleanUp() |
313 | { | 317 | { |
314 | if(conn) | 318 | if(conn) |
315 | FtpQuit(conn); | 319 | FtpQuit(conn); |
316 | QString sfile=QDir::homeDirPath(); | 320 | QString sfile=QDir::homeDirPath(); |
317 | if(sfile.right(1) != "/") | 321 | if(sfile.right(1) != "/") |
318 | sfile+="/._temp"; | 322 | sfile+="/._temp"; |
319 | else | 323 | else |
320 | sfile+="._temp"; | 324 | sfile+="._temp"; |
321 | QFile file( sfile); | 325 | QFile file( sfile); |
322 | if(file.exists()) | 326 | if(file.exists()) |
323 | file.remove(); | 327 | file.remove(); |
324 | exit(0); | 328 | exit(0); |
325 | } | 329 | } |
326 | 330 | ||
327 | void OpieFtp::tabChanged(QWidget *w) | 331 | void OpieFtp::tabChanged(QWidget *w) |
328 | { | 332 | { |
329 | if (TabWidget->currentPageIndex() == 0) { | 333 | if (TabWidget->currentPageIndex() == 0) { |
330 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 334 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
331 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); | 335 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); |
332 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 336 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
333 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 337 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
334 | if(cdUpButton->isHidden()) | 338 | if(cdUpButton->isHidden()) |
335 | cdUpButton->show(); | 339 | cdUpButton->show(); |
336 | if(homeButton->isHidden()) | 340 | if(homeButton->isHidden()) |
337 | homeButton->show(); | 341 | homeButton->show(); |
338 | 342 | ||
339 | } | 343 | } |
340 | if (TabWidget->currentPageIndex() == 1) { | 344 | if (TabWidget->currentPageIndex() == 1) { |
341 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 345 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
342 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); | 346 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); |
343 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 347 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
344 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 348 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
345 | if(cdUpButton->isHidden()) | 349 | if(cdUpButton->isHidden()) |
346 | cdUpButton->show(); | 350 | cdUpButton->show(); |
347 | homeButton->hide(); | 351 | homeButton->hide(); |
348 | 352 | ||
349 | } | 353 | } |
350 | if (TabWidget->currentPageIndex() == 2) { | 354 | if (TabWidget->currentPageIndex() == 2) { |
351 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); | 355 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); |
352 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 356 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
353 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 357 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
354 | cdUpButton->hide(); | 358 | cdUpButton->hide(); |
355 | homeButton->hide(); | 359 | homeButton->hide(); |
356 | } | 360 | } |
357 | } | 361 | } |
358 | 362 | ||
359 | void OpieFtp::newConnection() | 363 | void OpieFtp::newConnection() |
360 | { | 364 | { |
361 | UsernameComboBox->lineEdit()->setText(""); | 365 | UsernameComboBox->lineEdit()->setText(""); |
362 | PasswordEdit->setText( "" ); | 366 | PasswordEdit->setText( "" ); |
363 | ServerComboBox->lineEdit()->setText( ""); | 367 | ServerComboBox->lineEdit()->setText( ""); |
364 | remotePath->setText( currentRemoteDir = "/"); | 368 | remotePath->setText( currentRemoteDir = "/"); |
365 | PortSpinBox->setValue( 21); | 369 | PortSpinBox->setValue( 21); |
366 | TabWidget->setCurrentPage(2); | 370 | TabWidget->setCurrentPage(2); |
367 | } | 371 | } |
368 | 372 | ||
369 | void OpieFtp::serverComboEdited(const QString & edit) | 373 | void OpieFtp::serverComboEdited(const QString & edit) |
370 | { | 374 | { |
371 | if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { | 375 | if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { |
372 | qDebug("ServerComboEdited"); | 376 | qDebug("ServerComboEdited"); |
373 | currentServerConfig = -1; | 377 | currentServerConfig = -1; |
374 | } | 378 | } |
375 | } | 379 | } |
376 | 380 | ||
377 | void OpieFtp::connectorBtnToggled(bool On) | 381 | void OpieFtp::connectorBtnToggled(bool On) |
378 | { | 382 | { |
379 | if(On) { | 383 | if(On) { |
380 | connector(); | 384 | connector(); |
381 | } else { | 385 | } else { |
382 | disConnector(); | 386 | disConnector(); |
383 | } | 387 | } |
384 | 388 | ||
385 | } | 389 | } |
386 | 390 | ||
387 | void OpieFtp::connector() | 391 | void OpieFtp::connector() |
388 | { | 392 | { |
389 | QCopEnvelope ( "QPE/System", "busy()" ); | 393 | QCopEnvelope ( "QPE/System", "busy()" ); |
390 | // qApp->processEvents(); | 394 | // qApp->processEvents(); |
391 | currentRemoteDir=remotePath->text(); | 395 | currentRemoteDir=remotePath->text(); |
392 | if(ServerComboBox->currentText().isEmpty()) { | 396 | if(ServerComboBox->currentText().isEmpty()) { |
393 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); | 397 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); |
394 | TabWidget->setCurrentPage(2); | 398 | TabWidget->setCurrentPage(2); |
395 | ServerComboBox->setFocus(); | 399 | ServerComboBox->setFocus(); |
396 | connectServerBtn->setOn(FALSE); | 400 | connectServerBtn->setOn(FALSE); |
397 | connectServerBtn->setText( tr("Connect")); | 401 | connectServerBtn->setText( tr("Connect")); |
398 | return; | 402 | return; |
399 | } | 403 | } |
400 | FtpInit(); | 404 | FtpInit(); |
401 | TabWidget->setCurrentPage(1); | 405 | TabWidget->setCurrentPage(1); |
402 | QString ftp_host = ServerComboBox->currentText(); | 406 | QString ftp_host = ServerComboBox->currentText(); |
403 | QString ftp_user = UsernameComboBox->currentText(); | 407 | QString ftp_user = UsernameComboBox->currentText(); |
404 | QString ftp_pass = PasswordEdit->text(); | 408 | QString ftp_pass = PasswordEdit->text(); |
405 | QString port=PortSpinBox->cleanText(); | 409 | QString port=PortSpinBox->cleanText(); |
406 | port.stripWhiteSpace(); | 410 | port.stripWhiteSpace(); |
407 | 411 | ||
408 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) | 412 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) |
409 | ftp_host=ftp_host.right(ftp_host.length()-6); | 413 | ftp_host=ftp_host.right(ftp_host.length()-6); |
410 | ftp_host+=":"+port; | 414 | ftp_host+=":"+port; |
411 | if (!FtpConnect( ftp_host.latin1(), &conn)) { | 415 | if (!FtpConnect( ftp_host.latin1(), &conn)) { |
412 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); | 416 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); |
413 | connectServerBtn->setOn(FALSE); | 417 | connectServerBtn->setOn(FALSE); |
414 | connectServerBtn->setText( tr("Connect")); | 418 | connectServerBtn->setText( tr("Connect")); |
415 | return ; | 419 | return ; |
416 | } | 420 | } |
417 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { | 421 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { |
418 | QString msg; | 422 | QString msg; |
419 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); | 423 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); |
420 | msg.replace(QRegExp(":"),"\n"); | 424 | msg.replace(QRegExp(":"),"\n"); |
421 | QMessageBox::message(tr("Note"),msg); | 425 | QMessageBox::message(tr("Note"),msg); |
422 | if(conn) | 426 | if(conn) |
423 | FtpQuit(conn); | 427 | FtpQuit(conn); |
424 | connectServerBtn->setOn(FALSE); | 428 | connectServerBtn->setOn(FALSE); |
425 | connectServerBtn->setText( tr("Connect")); | 429 | connectServerBtn->setText( tr("Connect")); |
426 | return ; | 430 | return ; |
427 | } | 431 | } |
428 | remoteDirList("/") ; | 432 | remoteDirList("/") ; |
429 | setCaption(ftp_host); | 433 | setCaption(ftp_host); |
430 | writeConfig(); | 434 | writeConfig(); |
431 | connectServerBtn->setText( tr("Disconnect")); | 435 | connectServerBtn->setText( tr("Disconnect")); |
432 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 436 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
433 | } | 437 | } |
434 | 438 | ||
435 | void OpieFtp::disConnector() | 439 | void OpieFtp::disConnector() |
436 | { | 440 | { |
437 | if(conn) | 441 | if(conn) |
438 | FtpQuit(conn); | 442 | FtpQuit(conn); |
439 | setCaption("OpieFtp"); | 443 | setCaption("OpieFtp"); |
440 | currentRemoteDir="/"; | 444 | currentRemoteDir="/"; |
441 | Remote_View->clear(); | 445 | Remote_View->clear(); |
442 | connectServerBtn->setText( tr("Connect")); | 446 | connectServerBtn->setText( tr("Connect")); |
443 | connectServerBtn->setOn(FALSE); | 447 | connectServerBtn->setOn(FALSE); |
444 | } | 448 | } |
445 | 449 | ||
446 | void OpieFtp::localUpload() | 450 | void OpieFtp::localUpload() |
447 | { | 451 | { |
448 | int fsz; | 452 | int fsz; |
449 | // QCopEnvelope ( "QPE/System", "busy()" ); | 453 | // QCopEnvelope ( "QPE/System", "busy()" ); |
450 | // qApp->processEvents(); | 454 | // qApp->processEvents(); |
451 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 455 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
452 | QListViewItemIterator it( Local_View ); | 456 | QListViewItemIterator it( Local_View ); |
453 | for ( ; it.current(); ++it ) { | 457 | for ( ; it.current(); ++it ) { |
454 | if ( it.current()->isSelected() ) { | 458 | if ( it.current()->isSelected() ) { |
455 | QString strItem = it.current()->text(0); | 459 | QString strItem = it.current()->text(0); |
456 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 460 | QString localFile = currentDir.canonicalPath()+"/"+strItem; |
457 | QString remoteFile= currentRemoteDir+strItem; | 461 | QString remoteFile= currentRemoteDir+strItem; |
458 | QFileInfo fi(localFile); | 462 | QFileInfo fi(localFile); |
459 | if( !fi.isDir()) { | 463 | if( !fi.isDir()) { |
460 | fsz=fi.size(); | 464 | fsz=fi.size(); |
461 | ProgressBar->setTotalSteps(fsz); | 465 | ProgressBar->setTotalSteps(fsz); |
462 | 466 | ||
463 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 467 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
464 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 468 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
465 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 469 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
466 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 470 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
467 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); | 471 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); |
468 | 472 | ||
469 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 473 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
470 | QString msg; | 474 | QString msg; |
471 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); | 475 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); |
472 | msg.replace(QRegExp(":"),"\n"); | 476 | msg.replace(QRegExp(":"),"\n"); |
473 | QMessageBox::message(tr("Note"),msg); | 477 | QMessageBox::message(tr("Note"),msg); |
474 | } | 478 | } |
475 | } else { | 479 | } else { |
476 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); | 480 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); |
477 | } | 481 | } |
478 | ProgressBar->reset(); | 482 | ProgressBar->reset(); |
479 | nullifyCallBack(); | 483 | nullifyCallBack(); |
480 | it.current()->setSelected(FALSE); | 484 | it.current()->setSelected(FALSE); |
481 | } //end currentSelected | 485 | } //end currentSelected |
482 | } | 486 | } |
483 | for ( ; it.current(); ++it ) { | 487 | for ( ; it.current(); ++it ) { |
484 | Local_View->clearSelection(); | 488 | Local_View->clearSelection(); |
485 | } | 489 | } |
486 | Local_View->clearFocus(); | 490 | Local_View->clearFocus(); |
487 | TabWidget->setCurrentPage(1); | 491 | TabWidget->setCurrentPage(1); |
488 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 492 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
489 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 493 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
490 | } | 494 | } |
491 | 495 | ||
492 | void OpieFtp::nullifyCallBack() | 496 | void OpieFtp::nullifyCallBack() |
493 | { | 497 | { |
494 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); | 498 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); |
495 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); | 499 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); |
496 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); | 500 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); |
497 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); | 501 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); |
498 | } | 502 | } |
499 | 503 | ||
500 | void OpieFtp::remoteDownload() | 504 | void OpieFtp::remoteDownload() |
501 | { | 505 | { |
502 | // qApp->processEvents(); | 506 | // qApp->processEvents(); |
503 | int fsz; | 507 | int fsz; |
504 | QCopEnvelope ( "QPE/System", "busy()" ); | 508 | QCopEnvelope ( "QPE/System", "busy()" ); |
505 | 509 | ||
506 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 510 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
507 | QListViewItemIterator it( Remote_View ); | 511 | QListViewItemIterator it( Remote_View ); |
508 | for ( ; it.current(); ++it ) { | 512 | for ( ; it.current(); ++it ) { |
509 | if ( it.current()->isSelected() ) { | 513 | if ( it.current()->isSelected() ) { |
510 | QString strItem = it.current()->text(0); | 514 | QString strItem = it.current()->text(0); |
511 | // strItem=strItem.right(strItem.length()-1); | 515 | // strItem=strItem.right(strItem.length()-1); |
512 | QString localFile = currentDir.canonicalPath(); | 516 | QString localFile = currentDir.canonicalPath(); |
513 | if(localFile.right(1).find("/",0,TRUE) == -1) | 517 | if(localFile.right(1).find("/",0,TRUE) == -1) |
514 | localFile += "/"; | 518 | localFile += "/"; |
515 | localFile += strItem; | 519 | localFile += strItem; |
516 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | 520 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; |
517 | QString remoteFile= currentRemoteDir+strItem; | 521 | QString remoteFile= currentRemoteDir+strItem; |
518 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 522 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
519 | fsz = 0; | 523 | fsz = 0; |
520 | QString temp; | 524 | QString temp; |
521 | temp.sprintf( remoteFile+" "+" %dkb", fsz); | 525 | temp.sprintf( remoteFile+" "+" %dkb", fsz); |
522 | 526 | ||
523 | ProgressBar->setTotalSteps(fsz); | 527 | ProgressBar->setTotalSteps(fsz); |
524 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 528 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
525 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 529 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
526 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 530 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
527 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 531 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
@@ -723,605 +727,607 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | |||
723 | // qDebug(msg); | 727 | // qDebug(msg); |
724 | } | 728 | } |
725 | char path[256]; | 729 | char path[256]; |
726 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 730 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
727 | QString msg; | 731 | QString msg; |
728 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 732 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
729 | msg.replace(QRegExp(":"),"\n"); | 733 | msg.replace(QRegExp(":"),"\n"); |
730 | QMessageBox::message(tr("Note"),msg); | 734 | QMessageBox::message(tr("Note"),msg); |
731 | // qDebug(msg); | 735 | // qDebug(msg); |
732 | } | 736 | } |
733 | currentRemoteDir=path; | 737 | currentRemoteDir=path; |
734 | } else { | 738 | } else { |
735 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 739 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
736 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 740 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
737 | strItem = strItem.stripWhiteSpace(); | 741 | strItem = strItem.stripWhiteSpace(); |
738 | currentRemoteDir = strItem; | 742 | currentRemoteDir = strItem; |
739 | if( !remoteChDir( (const QString &)strItem)) { | 743 | if( !remoteChDir( (const QString &)strItem)) { |
740 | currentRemoteDir = oldRemoteCurrentDir; | 744 | currentRemoteDir = oldRemoteCurrentDir; |
741 | strItem=""; | 745 | strItem=""; |
742 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 746 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
743 | } | 747 | } |
744 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 748 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
745 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 749 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
746 | currentRemoteDir = oldRemoteCurrentDir; | 750 | currentRemoteDir = oldRemoteCurrentDir; |
747 | strItem=""; | 751 | strItem=""; |
748 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 752 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
749 | 753 | ||
750 | } else { | 754 | } else { |
751 | currentRemoteDir = currentRemoteDir+strItem; | 755 | currentRemoteDir = currentRemoteDir+strItem; |
752 | } | 756 | } |
753 | } else { | 757 | } else { |
754 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 758 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
755 | return; | 759 | return; |
756 | } | 760 | } |
757 | } | 761 | } |
758 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 762 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
759 | if(currentRemoteDir.right(1) !="/") | 763 | if(currentRemoteDir.right(1) !="/") |
760 | currentRemoteDir +="/"; | 764 | currentRemoteDir +="/"; |
761 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 765 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
762 | fillRemoteCombo( (const QString &)currentRemoteDir); | 766 | fillRemoteCombo( (const QString &)currentRemoteDir); |
763 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 767 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
764 | } | 768 | } |
765 | } | 769 | } |
766 | 770 | ||
767 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 771 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
768 | { | 772 | { |
769 | if(selectedItem!= NULL) { | 773 | if(selectedItem!= NULL) { |
770 | 774 | ||
771 | QString strItem=selectedItem->text(0); | 775 | QString strItem=selectedItem->text(0); |
772 | QString strSize=selectedItem->text(1); | 776 | QString strSize=selectedItem->text(1); |
773 | strSize=strSize.stripWhiteSpace(); | 777 | strSize=strSize.stripWhiteSpace(); |
774 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 778 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
775 | // is symlink | 779 | // is symlink |
776 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 780 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
777 | if(QDir(strItem2).exists() ) { | 781 | if(QDir(strItem2).exists() ) { |
778 | currentDir.cd(strItem2, TRUE); | 782 | currentDir.cd(strItem2, TRUE); |
779 | populateLocalView(); | 783 | populateLocalView(); |
780 | } | 784 | } |
781 | } else { // not a symlink | 785 | } else { // not a symlink |
782 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 786 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
783 | 787 | ||
784 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 788 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
785 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 789 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
786 | currentDir.cd(strItem,FALSE); | 790 | currentDir.cd(strItem,FALSE); |
787 | populateLocalView(); | 791 | populateLocalView(); |
788 | } else { | 792 | } else { |
789 | currentDir.cdUp(); | 793 | currentDir.cdUp(); |
790 | populateLocalView(); | 794 | populateLocalView(); |
791 | } | 795 | } |
792 | if(QDir(strItem).exists()){ | 796 | if(QDir(strItem).exists()){ |
793 | currentDir.cd(strItem, TRUE); | 797 | currentDir.cd(strItem, TRUE); |
794 | populateLocalView(); | 798 | populateLocalView(); |
795 | } | 799 | } |
796 | } else { | 800 | } else { |
797 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 801 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
798 | if( QFile::exists(strItem ) ) { | 802 | if( QFile::exists(strItem ) ) { |
799 | // qDebug("upload "+strItem); | 803 | // qDebug("upload "+strItem); |
800 | return; | 804 | return; |
801 | } | 805 | } |
802 | } //end not symlink | 806 | } //end not symlink |
803 | chdir(strItem.latin1()); | 807 | chdir(strItem.latin1()); |
804 | } | 808 | } |
805 | } | 809 | } |
806 | } | 810 | } |
807 | 811 | ||
808 | void OpieFtp::doLocalCd() | 812 | void OpieFtp::doLocalCd() |
809 | { | 813 | { |
810 | localListClicked( Local_View->currentItem()); | 814 | localListClicked( Local_View->currentItem()); |
811 | } | 815 | } |
812 | 816 | ||
813 | void OpieFtp:: doRemoteCd() | 817 | void OpieFtp:: doRemoteCd() |
814 | { | 818 | { |
815 | remoteListClicked( Remote_View->currentItem()); | 819 | remoteListClicked( Remote_View->currentItem()); |
816 | 820 | ||
817 | } | 821 | } |
818 | 822 | ||
819 | void OpieFtp::showHidden() | 823 | void OpieFtp::showHidden() |
820 | { | 824 | { |
821 | if (!b) { | 825 | if (!b) { |
822 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 826 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
823 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 827 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
824 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 828 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
825 | b=TRUE; | 829 | b=TRUE; |
826 | 830 | ||
827 | } else { | 831 | } else { |
828 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 832 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
829 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 833 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
830 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 834 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
831 | b=FALSE; | 835 | b=FALSE; |
832 | } | 836 | } |
833 | populateLocalView(); | 837 | populateLocalView(); |
834 | } | 838 | } |
835 | 839 | ||
836 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 840 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
837 | { | 841 | { |
838 | // if(item) | 842 | // if(item) |
839 | if (mouse == 2) { | 843 | if (mouse == 2) { |
840 | showLocalMenu(item); | 844 | showLocalMenu(item); |
841 | } | 845 | } |
842 | } | 846 | } |
843 | 847 | ||
844 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 848 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
845 | { | 849 | { |
846 | if(mouse == 2) { | 850 | if(mouse == 2) { |
847 | showRemoteMenu(item); | 851 | showRemoteMenu(item); |
848 | } | 852 | } |
849 | } | 853 | } |
850 | 854 | ||
851 | void OpieFtp::showRemoteMenu(QListViewItem * item) | 855 | void OpieFtp::showRemoteMenu(QListViewItem * item) |
852 | { | 856 | { |
853 | QPopupMenu * m;// = new QPopupMenu( Local_View ); | 857 | QPopupMenu * m;// = new QPopupMenu( Local_View ); |
854 | m = new QPopupMenu(this); | 858 | m = new QPopupMenu(this); |
855 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) | 859 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) |
856 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 860 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
857 | else | 861 | else |
858 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 862 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
859 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 863 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
860 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 864 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
861 | m->insertSeparator(); | 865 | m->insertSeparator(); |
862 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 866 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
863 | m->exec( QCursor::pos() ); | 867 | m->exec( QCursor::pos() ); |
864 | delete m; | 868 | delete m; |
865 | } | 869 | } |
866 | 870 | ||
867 | void OpieFtp::showLocalMenu(QListViewItem * item) | 871 | void OpieFtp::showLocalMenu(QListViewItem * item) |
868 | { | 872 | { |
869 | 873 | ||
870 | QPopupMenu *m; | 874 | QPopupMenu *m; |
871 | m = new QPopupMenu( this); | 875 | m = new QPopupMenu( this); |
872 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 876 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
873 | m->insertSeparator(); | 877 | m->insertSeparator(); |
874 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 878 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
875 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 879 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
876 | else | 880 | else |
877 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 881 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
878 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 882 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
879 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 883 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
880 | m->insertSeparator(); | 884 | m->insertSeparator(); |
881 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 885 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
882 | m->setCheckable(TRUE); | 886 | m->setCheckable(TRUE); |
883 | if (b) | 887 | if (b) |
884 | m->setItemChecked(m->idAt(0),TRUE); | 888 | m->setItemChecked(m->idAt(0),TRUE); |
885 | else | 889 | else |
886 | m->setItemChecked(m->idAt(0),FALSE); | 890 | m->setItemChecked(m->idAt(0),FALSE); |
887 | 891 | ||
888 | m->exec( QCursor::pos() ); | 892 | m->exec( QCursor::pos() ); |
889 | delete m; | 893 | delete m; |
890 | } | 894 | } |
891 | 895 | ||
892 | void OpieFtp::localMakDir() | 896 | void OpieFtp::localMakDir() |
893 | { | 897 | { |
894 | InputDialog *fileDlg; | 898 | InputDialog *fileDlg; |
895 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 899 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
896 | fileDlg->exec(); | 900 | fileDlg->exec(); |
897 | if( fileDlg->result() == 1 ) { | 901 | if( fileDlg->result() == 1 ) { |
898 | QString filename = fileDlg->LineEdit1->text(); | 902 | QString filename = fileDlg->LineEdit1->text(); |
899 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 903 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
900 | } | 904 | } |
901 | populateLocalView(); | 905 | populateLocalView(); |
902 | } | 906 | } |
903 | 907 | ||
904 | void OpieFtp::localDelete() | 908 | void OpieFtp::localDelete() |
905 | { | 909 | { |
906 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 910 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
907 | QListViewItemIterator it( Local_View ); | 911 | QListViewItemIterator it( Local_View ); |
908 | for ( ; it.current(); ++it ) { | 912 | for ( ; it.current(); ++it ) { |
909 | if ( it.current()->isSelected() ) { | 913 | if ( it.current()->isSelected() ) { |
910 | QString f = it.current()->text(0); | 914 | QString f = it.current()->text(0); |
911 | it.current()->setSelected(FALSE); | 915 | it.current()->setSelected(FALSE); |
912 | 916 | ||
913 | // QString f = Local_View->currentItem()->text(0); | 917 | // QString f = Local_View->currentItem()->text(0); |
914 | if(QDir(f).exists() ) { | 918 | if(QDir(f).exists() ) { |
915 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 919 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
916 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { | 920 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { |
917 | case 0: { | 921 | case 0: { |
918 | f=currentDir.canonicalPath()+"/"+f; | 922 | f=currentDir.canonicalPath()+"/"+f; |
919 | QString cmd="rmdir "+f; | 923 | QString cmd="rmdir "+f; |
920 | system( cmd.latin1()); | 924 | system( cmd.latin1()); |
921 | } | 925 | } |
922 | break; | 926 | break; |
923 | case 1: | 927 | case 1: |
924 | // exit | 928 | // exit |
925 | break; | 929 | break; |
926 | }; | 930 | }; |
927 | 931 | ||
928 | } else { | 932 | } else { |
929 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 933 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
930 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 934 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
931 | case 0: { | 935 | case 0: { |
932 | f=currentDir.canonicalPath()+"/"+f; | 936 | f=currentDir.canonicalPath()+"/"+f; |
933 | QString cmd="rm "+f; | 937 | QString cmd="rm "+f; |
934 | system( cmd.latin1()); | 938 | system( cmd.latin1()); |
935 | } | 939 | } |
936 | break; | 940 | break; |
937 | case 1: | 941 | case 1: |
938 | // exit | 942 | // exit |
939 | break; | 943 | break; |
940 | }; | 944 | }; |
941 | } | 945 | } |
942 | } | 946 | } |
943 | } | 947 | } |
944 | populateLocalView(); | 948 | populateLocalView(); |
945 | 949 | ||
946 | } | 950 | } |
947 | 951 | ||
948 | void OpieFtp::remoteMakDir() | 952 | void OpieFtp::remoteMakDir() |
949 | { | 953 | { |
950 | InputDialog *fileDlg; | 954 | InputDialog *fileDlg; |
951 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 955 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
952 | fileDlg->exec(); | 956 | fileDlg->exec(); |
953 | if( fileDlg->result() == 1 ) { | 957 | if( fileDlg->result() == 1 ) { |
954 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; | 958 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; |
955 | QString tmp=currentRemoteDir+filename; | 959 | QString tmp=currentRemoteDir+filename; |
956 | QCopEnvelope ( "QPE/System", "busy()" ); | 960 | QCopEnvelope ( "QPE/System", "busy()" ); |
957 | if(FtpMkdir( tmp.latin1(), conn) == 0) { | 961 | if(FtpMkdir( tmp.latin1(), conn) == 0) { |
958 | QString msg; | 962 | QString msg; |
959 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); | 963 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); |
960 | msg.replace(QRegExp(":"),"\n"); | 964 | msg.replace(QRegExp(":"),"\n"); |
961 | QMessageBox::message(tr("Note"),msg); | 965 | QMessageBox::message(tr("Note"),msg); |
962 | } | 966 | } |
963 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 967 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
964 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 968 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
965 | } | 969 | } |
966 | } | 970 | } |
967 | 971 | ||
968 | void OpieFtp::remoteDelete() | 972 | void OpieFtp::remoteDelete() |
969 | { | 973 | { |
970 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 974 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
971 | QListViewItemIterator it( Remote_View ); | 975 | QListViewItemIterator it( Remote_View ); |
972 | for ( ; it.current(); ++it ) { | 976 | for ( ; it.current(); ++it ) { |
973 | if ( it.current()->isSelected() ) { | 977 | if ( it.current()->isSelected() ) { |
974 | QString f = it.current()->text(0); | 978 | QString f = it.current()->text(0); |
975 | // QString f = Remote_View->currentItem()->text(0); | 979 | // QString f = Remote_View->currentItem()->text(0); |
976 | QCopEnvelope ( "QPE/System", "busy()" ); | 980 | QCopEnvelope ( "QPE/System", "busy()" ); |
977 | if( f.right(1) =="/") { | 981 | if( f.right(1) =="/") { |
978 | QString path= currentRemoteDir+f; | 982 | QString path= currentRemoteDir+f; |
979 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 983 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
980 | ,tr("Yes"),tr("No"),0,0,1) ) { | 984 | ,tr("Yes"),tr("No"),0,0,1) ) { |
981 | case 0: { | 985 | case 0: { |
982 | f=currentDir.canonicalPath()+"/"+f; | 986 | f=currentDir.canonicalPath()+"/"+f; |
983 | if(FtpRmdir( path.latin1(), conn) ==0) { | 987 | if(FtpRmdir( path.latin1(), conn) ==0) { |
984 | QString msg; | 988 | QString msg; |
985 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); | 989 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); |
986 | msg.replace(QRegExp(":"),"\n"); | 990 | msg.replace(QRegExp(":"),"\n"); |
987 | QMessageBox::message(tr("Note"),msg); | 991 | QMessageBox::message(tr("Note"),msg); |
988 | } | 992 | } |
989 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 993 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
990 | } | 994 | } |
991 | break; | 995 | break; |
992 | }; | 996 | }; |
993 | } else { | 997 | } else { |
994 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 998 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
995 | ,tr("Yes"),tr("No"),0,0,1) ) { | 999 | ,tr("Yes"),tr("No"),0,0,1) ) { |
996 | case 0: { | 1000 | case 0: { |
997 | QString path= currentRemoteDir+f; | 1001 | QString path= currentRemoteDir+f; |
998 | if(FtpDelete( path.latin1(), conn)==0) { | 1002 | if(FtpDelete( path.latin1(), conn)==0) { |
999 | QString msg; | 1003 | QString msg; |
1000 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); | 1004 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); |
1001 | msg.replace(QRegExp(":"),"\n"); | 1005 | msg.replace(QRegExp(":"),"\n"); |
1002 | QMessageBox::message(tr("Note"),msg); | 1006 | QMessageBox::message(tr("Note"),msg); |
1003 | } | 1007 | } |
1004 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1008 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1005 | } | 1009 | } |
1006 | break; | 1010 | break; |
1007 | }; | 1011 | }; |
1008 | } | 1012 | } |
1009 | } | 1013 | } |
1010 | } | 1014 | } |
1011 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 1015 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
1012 | } | 1016 | } |
1013 | 1017 | ||
1014 | void OpieFtp::remoteRename() | 1018 | void OpieFtp::remoteRename() |
1015 | { | 1019 | { |
1016 | QString curFile = Remote_View->currentItem()->text(0); | 1020 | QString curFile = Remote_View->currentItem()->text(0); |
1017 | InputDialog *fileDlg; | 1021 | InputDialog *fileDlg; |
1018 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1022 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1019 | fileDlg->setTextEdit((const QString &)curFile); | 1023 | fileDlg->setTextEdit((const QString &)curFile); |
1020 | fileDlg->exec(); | 1024 | fileDlg->exec(); |
1021 | if( fileDlg->result() == 1 ) { | 1025 | if( fileDlg->result() == 1 ) { |
1022 | QString oldName = currentRemoteDir +"/"+ curFile; | 1026 | QString oldName = currentRemoteDir +"/"+ curFile; |
1023 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; | 1027 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; |
1024 | QCopEnvelope ( "QPE/System", "busy()" ); | 1028 | QCopEnvelope ( "QPE/System", "busy()" ); |
1025 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { | 1029 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { |
1026 | QString msg; | 1030 | QString msg; |
1027 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); | 1031 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); |
1028 | msg.replace(QRegExp(":"),"\n"); | 1032 | msg.replace(QRegExp(":"),"\n"); |
1029 | QMessageBox::message(tr("Note"),msg); | 1033 | QMessageBox::message(tr("Note"),msg); |
1030 | } | 1034 | } |
1031 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 1035 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
1032 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1036 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1033 | } | 1037 | } |
1034 | } | 1038 | } |
1035 | 1039 | ||
1036 | void OpieFtp::localRename() | 1040 | void OpieFtp::localRename() |
1037 | { | 1041 | { |
1038 | QString curFile = Local_View->currentItem()->text(0); | 1042 | QString curFile = Local_View->currentItem()->text(0); |
1039 | InputDialog *fileDlg; | 1043 | InputDialog *fileDlg; |
1040 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1044 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1041 | fileDlg->setTextEdit((const QString &)curFile); | 1045 | fileDlg->setTextEdit((const QString &)curFile); |
1042 | fileDlg->exec(); | 1046 | fileDlg->exec(); |
1043 | if( fileDlg->result() == 1 ) { | 1047 | if( fileDlg->result() == 1 ) { |
1044 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 1048 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
1045 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 1049 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
1046 | if( rename(oldname.latin1(), newName.latin1())== -1) | 1050 | if( rename(oldname.latin1(), newName.latin1())== -1) |
1047 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 1051 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1048 | } | 1052 | } |
1049 | populateLocalView(); | 1053 | populateLocalView(); |
1050 | } | 1054 | } |
1051 | 1055 | ||
1052 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { | 1056 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { |
1053 | if (TabWidget->currentPageIndex() == 0) { | 1057 | if (TabWidget->currentPageIndex() == 0) { |
1054 | chdir( currentPath.latin1() ); | 1058 | chdir( currentPath.latin1() ); |
1055 | currentDir.cd( currentPath, TRUE); | 1059 | currentDir.cd( currentPath, TRUE); |
1056 | populateLocalView(); | 1060 | populateLocalView(); |
1057 | update(); | 1061 | update(); |
1058 | } else { | 1062 | } else { |
1059 | // chdir( currentPath.latin1() ); | 1063 | // chdir( currentPath.latin1() ); |
1060 | // currentDir.cd( currentPath, TRUE); | 1064 | // currentDir.cd( currentPath, TRUE); |
1061 | // populateList(); | 1065 | // populateList(); |
1062 | // update(); | 1066 | // update(); |
1063 | 1067 | ||
1064 | } | 1068 | } |
1065 | } | 1069 | } |
1066 | 1070 | ||
1067 | void OpieFtp::fillCombo(const QString ¤tPath) { | 1071 | void OpieFtp::fillCombo(const QString ¤tPath) { |
1068 | 1072 | ||
1069 | currentPathCombo->lineEdit()->setText(currentPath); | 1073 | currentPathCombo->lineEdit()->setText(currentPath); |
1070 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1074 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1071 | currentPathCombo->clear(); | 1075 | currentPathCombo->clear(); |
1072 | localDirPathStringList.prepend(currentPath ); | 1076 | localDirPathStringList.prepend(currentPath ); |
1073 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 1077 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
1074 | } | 1078 | } |
1075 | currentPathCombo->lineEdit()->setText(currentPath); | 1079 | currentPathCombo->lineEdit()->setText(currentPath); |
1076 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1080 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1077 | currentPathCombo->clear(); | 1081 | currentPathCombo->clear(); |
1078 | remoteDirPathStringList.prepend(currentPath ); | 1082 | remoteDirPathStringList.prepend(currentPath ); |
1079 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1083 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1080 | } | 1084 | } |
1081 | } | 1085 | } |
1082 | 1086 | ||
1083 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { | 1087 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { |
1084 | 1088 | ||
1085 | currentPathCombo->lineEdit()->setText(currentPath); | 1089 | currentPathCombo->lineEdit()->setText(currentPath); |
1086 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1090 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1087 | currentPathCombo->clear(); | 1091 | currentPathCombo->clear(); |
1088 | remoteDirPathStringList.prepend(currentPath ); | 1092 | remoteDirPathStringList.prepend(currentPath ); |
1089 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1093 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1090 | } | 1094 | } |
1091 | } | 1095 | } |
1092 | 1096 | ||
1093 | void OpieFtp::currentPathComboChanged() | 1097 | void OpieFtp::currentPathComboChanged() |
1094 | { | 1098 | { |
1095 | QString oldRemoteCurrentDir = currentRemoteDir; | 1099 | QString oldRemoteCurrentDir = currentRemoteDir; |
1096 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 1100 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); |
1097 | if (TabWidget->currentPageIndex() == 0) { | 1101 | if (TabWidget->currentPageIndex() == 0) { |
1098 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 1102 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
1099 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 1103 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
1100 | populateLocalView(); | 1104 | populateLocalView(); |
1101 | } else { | 1105 | } else { |
1102 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 1106 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
1103 | } | 1107 | } |
1104 | } | 1108 | } |
1105 | if (TabWidget->currentPageIndex() == 1) { | 1109 | if (TabWidget->currentPageIndex() == 1) { |
1106 | currentRemoteDir = currentPathCombo->lineEdit()->text(); | 1110 | currentRemoteDir = currentPathCombo->lineEdit()->text(); |
1107 | if(currentRemoteDir.right(1) !="/") { | 1111 | if(currentRemoteDir.right(1) !="/") { |
1108 | currentRemoteDir = currentRemoteDir +"/"; | 1112 | currentRemoteDir = currentRemoteDir +"/"; |
1109 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1113 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1110 | } | 1114 | } |
1111 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 1115 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
1112 | currentRemoteDir = oldRemoteCurrentDir; | 1116 | currentRemoteDir = oldRemoteCurrentDir; |
1113 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1117 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1114 | } | 1118 | } |
1115 | 1119 | ||
1116 | remoteDirList( (const QString &)currentRemoteDir); | 1120 | remoteDirList( (const QString &)currentRemoteDir); |
1117 | } | 1121 | } |
1118 | } | 1122 | } |
1119 | 1123 | ||
1120 | void OpieFtp::switchToLocalTab() | 1124 | void OpieFtp::switchToLocalTab() |
1121 | { | 1125 | { |
1122 | TabWidget->setCurrentPage(0); | 1126 | TabWidget->setCurrentPage(0); |
1123 | } | 1127 | } |
1124 | 1128 | ||
1125 | void OpieFtp::switchToRemoteTab() | 1129 | void OpieFtp::switchToRemoteTab() |
1126 | { | 1130 | { |
1127 | TabWidget->setCurrentPage(1); | 1131 | TabWidget->setCurrentPage(1); |
1128 | } | 1132 | } |
1129 | 1133 | ||
1130 | void OpieFtp::switchToConfigTab() | 1134 | void OpieFtp::switchToConfigTab() |
1131 | { | 1135 | { |
1132 | TabWidget->setCurrentPage(2); | 1136 | TabWidget->setCurrentPage(2); |
1133 | } | 1137 | } |
1134 | 1138 | ||
1135 | void OpieFtp::readConfig() | 1139 | void OpieFtp::readConfig() |
1136 | { | 1140 | { |
1137 | fillCombos(); | 1141 | fillCombos(); |
1138 | Config cfg("opieftp"); | 1142 | Config cfg("opieftp"); |
1139 | cfg.setGroup("Server"); | 1143 | cfg.setGroup("Server"); |
1140 | currentServerConfig = cfg.readNumEntry("currentServer", -1); | 1144 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
1141 | // qDebug("Reading %d", currentServerConfig); | 1145 | // qDebug("Reading %d", currentServerConfig); |
1142 | serverComboSelected( currentServerConfig); | 1146 | serverComboSelected( currentServerConfig); |
1143 | } | 1147 | } |
1144 | 1148 | ||
1145 | void OpieFtp::writeConfig() | 1149 | void OpieFtp::writeConfig() |
1146 | { | 1150 | { |
1147 | Config cfg("opieftp"); | 1151 | Config cfg("opieftp"); |
1148 | cfg.setGroup("Server"); | 1152 | cfg.setGroup("Server"); |
1149 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1153 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1150 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1154 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1151 | if( currentServerConfig == -1) { | 1155 | if( currentServerConfig == -1) { |
1152 | for (int i = 1; i <= numberOfEntries; i++) { | 1156 | for (int i = 1; i <= numberOfEntries; i++) { |
1153 | temp.setNum(i); | 1157 | temp.setNum(i); |
1154 | cfg.setGroup("Server"); | 1158 | cfg.setGroup("Server"); |
1155 | QString tempStr = cfg.readEntry( temp,""); | 1159 | QString tempStr = cfg.readEntry( temp,""); |
1156 | } | 1160 | } |
1157 | temp.setNum( numberOfEntries + 1); | 1161 | temp.setNum( numberOfEntries + 1); |
1158 | cfg.setGroup("Server"); | 1162 | cfg.setGroup("Server"); |
1159 | remoteServerStr = cfg.readEntry( temp,""); | 1163 | remoteServerStr = cfg.readEntry( temp,""); |
1160 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1164 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1161 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1165 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1162 | 1166 | ||
1163 | temp.setNum(numberOfEntries+1); | 1167 | temp.setNum(numberOfEntries+1); |
1164 | cfg.setGroup("Server"); | 1168 | cfg.setGroup("Server"); |
1165 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1169 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1166 | cfg.setGroup(temp); | 1170 | cfg.setGroup(temp); |
1167 | cfg.writeEntry("RemotePath", remotePath->text()); | 1171 | cfg.writeEntry("RemotePath", remotePath->text()); |
1168 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1172 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1169 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1173 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1170 | cfg.setGroup("Server"); | 1174 | cfg.setGroup("Server"); |
1171 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1175 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1172 | } | 1176 | } |
1173 | } | 1177 | } |
1174 | 1178 | ||
1175 | void OpieFtp::fillCombos() | 1179 | void OpieFtp::fillCombos() |
1176 | { | 1180 | { |
1177 | Config cfg("opieftp"); | 1181 | Config cfg("opieftp"); |
1178 | cfg.setGroup("Server"); | 1182 | cfg.setGroup("Server"); |
1179 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1183 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1180 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1184 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1181 | for (int i = 1; i <= numberOfEntries; i++) { | 1185 | for (int i = 1; i <= numberOfEntries; i++) { |
1182 | temp.setNum(i); | 1186 | temp.setNum(i); |
1183 | cfg.setGroup("Server"); | 1187 | cfg.setGroup("Server"); |
1184 | remoteServerStr = cfg.readEntry( temp,""); | 1188 | remoteServerStr = cfg.readEntry( temp,""); |
1185 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1189 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1186 | port = remoteServerStr.right( divider - 1); | 1190 | port = remoteServerStr.right( divider - 1); |
1187 | bool ok; | 1191 | bool ok; |
1188 | PortSpinBox->setValue( port.toInt(&ok,10)); | 1192 | PortSpinBox->setValue( port.toInt(&ok,10)); |
1189 | 1193 | ||
1190 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1194 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1191 | ServerComboBox->insertItem( remoteServerStr ); | 1195 | ServerComboBox->insertItem( remoteServerStr ); |
1192 | // cfg.setGroup(temp); | 1196 | // cfg.setGroup(temp); |
1193 | 1197 | ||
1194 | // remotePathStr = cfg.readEntry(remoteServer,""); | 1198 | // remotePathStr = cfg.readEntry(remoteServer,""); |
1195 | // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); | 1199 | // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); |
1196 | // port = remoteServer.right( divider+1); | 1200 | // port = remoteServer.right( divider+1); |
1197 | // PortSpinBox->setValue( port); | 1201 | // PortSpinBox->setValue( port); |
1198 | 1202 | ||
1199 | // remoteServer = remoteServer.left(divider - 1); | 1203 | // remoteServer = remoteServer.left(divider - 1); |
1200 | // remotePath->setText( remotePathStr); | 1204 | // remotePath->setText( remotePathStr); |
1201 | 1205 | ||
1202 | // username = cfg.readEntry(temp); | 1206 | // username = cfg.readEntry(temp); |
1203 | // UsernameComboBox->insertItem(username); | 1207 | // UsernameComboBox->insertItem(username); |
1204 | // password = cfg.readEntryCrypt(username,""); | 1208 | // password = cfg.readEntryCrypt(username,""); |
1205 | // PasswordEdit->setText(password); | 1209 | // PasswordEdit->setText(password); |
1206 | } | 1210 | } |
1207 | } | 1211 | } |
1208 | 1212 | ||
1209 | 1213 | ||
1210 | void OpieFtp::serverComboSelected(int index) | 1214 | void OpieFtp::serverComboSelected(int index) |
1211 | { | 1215 | { |
1212 | currentServerConfig = index; | 1216 | currentServerConfig = index; |
1213 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1217 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1214 | // remoteServerStr = ServerComboBox->text(index); | 1218 | // remoteServerStr = ServerComboBox->text(index); |
1215 | Config cfg("opieftp"); | 1219 | Config cfg("opieftp"); |
1216 | cfg.setGroup("Server"); | 1220 | cfg.setGroup("Server"); |
1217 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1221 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1218 | 1222 | ||
1219 | temp.setNum(index+1); | 1223 | temp.setNum(index+1); |
1220 | remoteServerStr = cfg.readEntry( temp,""); | 1224 | remoteServerStr = cfg.readEntry( temp,""); |
1221 | cfg.setGroup(temp); | 1225 | cfg.setGroup(temp); |
1222 | // qDebug(temp); | 1226 | // qDebug(temp); |
1223 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1227 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1224 | port = remoteServerStr.right( divider - 1); | 1228 | port = remoteServerStr.right( divider - 1); |
1225 | bool ok; | 1229 | bool ok; |
1226 | int portInt = port.toInt(&ok,10); | 1230 | int portInt = port.toInt(&ok,10); |
1227 | if( portInt == 0) portInt = 21; | 1231 | if( portInt == 0) portInt = 21; |
1228 | 1232 | ||
1229 | PortSpinBox->setValue( portInt); | 1233 | PortSpinBox->setValue( portInt); |
1230 | 1234 | ||
1231 | remotePath->setText(cfg.readEntry("RemotePath", "/")); | 1235 | remotePath->setText(cfg.readEntry("RemotePath", "/")); |
1232 | 1236 | ||
1233 | username = cfg.readEntry("Username", "anonymous"); | 1237 | username = cfg.readEntry("Username", "anonymous"); |
1234 | UsernameComboBox->lineEdit()->setText(username); | 1238 | UsernameComboBox->lineEdit()->setText(username); |
1239 | |||
1240 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); | ||
1235 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); | 1241 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); |
1236 | 1242 | ||
1237 | cfg.setGroup("Server"); | 1243 | cfg.setGroup("Server"); |
1238 | temp.sprintf("%d",currentServerConfig); | 1244 | temp.sprintf("%d",currentServerConfig); |
1239 | cfg.writeEntry("currentServer", temp); | 1245 | cfg.writeEntry("currentServer", temp); |
1240 | update(); | 1246 | update(); |
1241 | } | 1247 | } |
1242 | // UsernameComboBox->lineEdit()->setText("root"); | 1248 | // UsernameComboBox->lineEdit()->setText("root"); |
1243 | // PasswordEdit->setText( tr( "" ) ); | 1249 | // PasswordEdit->setText( tr( "" ) ); |
1244 | // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 1250 | // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); |
1245 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); | 1251 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); |
1246 | // PortSpinBox->setValue( 4242); | 1252 | // PortSpinBox->setValue( 4242); |
1247 | 1253 | ||
1248 | void OpieFtp::deleteServer() | 1254 | void OpieFtp::deleteServer() |
1249 | { | 1255 | { |
1250 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1256 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1251 | remoteServerStr = ServerComboBox->currentText( ); | 1257 | remoteServerStr = ServerComboBox->currentText( ); |
1252 | username = UsernameComboBox->currentText(); | 1258 | username = UsernameComboBox->currentText(); |
1253 | Config cfg("opieftp"); | 1259 | Config cfg("opieftp"); |
1254 | cfg.setGroup("Server"); | 1260 | cfg.setGroup("Server"); |
1255 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1261 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1256 | for (int i = 0; i <= numberOfEntries; i++) { | 1262 | for (int i = 0; i <= numberOfEntries; i++) { |
1257 | temp.setNum(i+1); | 1263 | temp.setNum(i+1); |
1258 | cfg.setGroup("Server"); | 1264 | cfg.setGroup("Server"); |
1259 | if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 | 1265 | if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 |
1260 | && cfg.readEntry(temp).find(username,0,TRUE) != -1 | 1266 | && cfg.readEntry(temp).find(username,0,TRUE) != -1 |
1261 | && !remoteServerStr.isEmpty()) { | 1267 | && !remoteServerStr.isEmpty()) { |
1262 | qDebug(temp); | 1268 | qDebug(temp); |
1263 | } | 1269 | } |
1264 | } | 1270 | } |
1265 | } | 1271 | } |
1266 | 1272 | ||
1267 | void OpieFtp::upDir() | 1273 | void OpieFtp::upDir() |
1268 | { | 1274 | { |
1269 | if (TabWidget->currentPageIndex() == 0) { | 1275 | if (TabWidget->currentPageIndex() == 0) { |
1270 | QString current = currentDir.canonicalPath(); | 1276 | QString current = currentDir.canonicalPath(); |
1271 | QDir dir(current); | 1277 | QDir dir(current); |
1272 | dir.cdUp(); | 1278 | dir.cdUp(); |
1273 | current = dir.canonicalPath(); | 1279 | current = dir.canonicalPath(); |
1274 | chdir( current.latin1() ); | 1280 | chdir( current.latin1() ); |
1275 | currentDir.cd( current, TRUE); | 1281 | currentDir.cd( current, TRUE); |
1276 | populateLocalView(); | 1282 | populateLocalView(); |
1277 | update(); | 1283 | update(); |
1278 | } else { | 1284 | } else { |
1279 | if( FtpCDUp( conn) == 0) { | 1285 | if( FtpCDUp( conn) == 0) { |
1280 | QString msg; | 1286 | QString msg; |
1281 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 1287 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
1282 | msg.replace(QRegExp(":"),"\n"); | 1288 | msg.replace(QRegExp(":"),"\n"); |
1283 | QMessageBox::message(tr("Note"),msg); | 1289 | QMessageBox::message(tr("Note"),msg); |
1284 | // qDebug(msg); | 1290 | // qDebug(msg); |
1285 | } | 1291 | } |
1286 | char path[256]; | 1292 | char path[256]; |
1287 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 1293 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
1288 | QString msg; | 1294 | QString msg; |
1289 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 1295 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
1290 | msg.replace(QRegExp(":"),"\n"); | 1296 | msg.replace(QRegExp(":"),"\n"); |
1291 | QMessageBox::message(tr("Note"),msg); | 1297 | QMessageBox::message(tr("Note"),msg); |
1292 | // qDebug(msg); | 1298 | // qDebug(msg); |
1293 | } | 1299 | } |
1294 | currentRemoteDir=path; | 1300 | currentRemoteDir=path; |
1295 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1301 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1296 | if(currentRemoteDir.right(1) !="/") | 1302 | if(currentRemoteDir.right(1) !="/") |
1297 | currentRemoteDir +="/"; | 1303 | currentRemoteDir +="/"; |
1298 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 1304 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
1299 | fillRemoteCombo( (const QString &)currentRemoteDir); | 1305 | fillRemoteCombo( (const QString &)currentRemoteDir); |
1300 | 1306 | ||
1301 | } | 1307 | } |
1302 | } | 1308 | } |
1303 | 1309 | ||
1304 | void OpieFtp::docButtonPushed() { | 1310 | void OpieFtp::docButtonPushed() { |
1305 | QString current = QPEApplication::documentDir(); | 1311 | QString current = QPEApplication::documentDir(); |
1306 | chdir( current.latin1() ); | 1312 | chdir( current.latin1() ); |
1307 | currentDir.cd( current, TRUE); | 1313 | currentDir.cd( current, TRUE); |
1308 | populateLocalView(); | 1314 | populateLocalView(); |
1309 | update(); | 1315 | update(); |
1310 | 1316 | ||
1311 | } | 1317 | } |
1312 | 1318 | ||
1313 | void OpieFtp::homeButtonPushed() { | 1319 | void OpieFtp::homeButtonPushed() { |
1314 | QString current = QDir::homeDirPath(); | 1320 | QString current = QDir::homeDirPath(); |
1315 | chdir( current.latin1() ); | 1321 | chdir( current.latin1() ); |
1316 | currentDir.cd( current, TRUE); | 1322 | currentDir.cd( current, TRUE); |
1317 | populateLocalView(); | 1323 | populateLocalView(); |
1318 | update(); | 1324 | update(); |
1319 | } | 1325 | } |
1320 | 1326 | ||
1321 | void OpieFtp::doAbout() { | 1327 | void OpieFtp::doAbout() { |
1322 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" | 1328 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" |
1323 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1329 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1324 | "and uses ftplib copyright 1996-2000\n" | 1330 | "and uses ftplib copyright 1996-2000\n" |
1325 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" | 1331 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" |
1326 | "and is licensed by the GPL"); | 1332 | "and is licensed by the GPL"); |
1327 | } | 1333 | } |