author | llornkcor <llornkcor> | 2002-04-05 01:34:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-05 01:34:24 (UTC) |
commit | dd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670 (patch) (unidiff) | |
tree | e8ebf3f926e3ac7e4d612964a05bce834fe6fc2e /noncore/net | |
parent | 8674b15e0768d5108d9a225ff2631538283e1019 (diff) | |
download | opie-dd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670.zip opie-dd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670.tar.gz opie-dd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670.tar.bz2 |
fixed bug where same server was being saved multiple times
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index b451925..919649e 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -71,97 +71,97 @@ OpieFtp::OpieFtp( ) | |||
71 | setCaption( tr( "OpieFtp" ) ); | 71 | setCaption( tr( "OpieFtp" ) ); |
72 | 72 | ||
73 | QGridLayout *layout = new QGridLayout( this ); | 73 | QGridLayout *layout = new QGridLayout( this ); |
74 | layout->setSpacing( 2); | 74 | layout->setSpacing( 2); |
75 | layout->setMargin( 2); | 75 | layout->setMargin( 2); |
76 | 76 | ||
77 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 77 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
78 | 78 | ||
79 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 79 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
80 | connectionMenu = new QPopupMenu( this ); | 80 | connectionMenu = new QPopupMenu( this ); |
81 | localMenu = new QPopupMenu( this ); | 81 | localMenu = new QPopupMenu( this ); |
82 | remoteMenu = new QPopupMenu( this ); | 82 | remoteMenu = new QPopupMenu( this ); |
83 | tabMenu = new QPopupMenu( this ); | 83 | tabMenu = new QPopupMenu( this ); |
84 | 84 | ||
85 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); | 85 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); |
86 | 86 | ||
87 | menuBar->insertItem( tr( "Connection" ), connectionMenu); | 87 | menuBar->insertItem( tr( "Connection" ), connectionMenu); |
88 | menuBar->insertItem( tr( "Local" ), localMenu); | 88 | menuBar->insertItem( tr( "Local" ), localMenu); |
89 | menuBar->insertItem( tr( "Remote" ), remoteMenu); | 89 | menuBar->insertItem( tr( "Remote" ), remoteMenu); |
90 | menuBar->insertItem( tr( "View" ), tabMenu); | 90 | menuBar->insertItem( tr( "View" ), tabMenu); |
91 | 91 | ||
92 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 92 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
93 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 93 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
94 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 94 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
95 | 95 | ||
96 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 96 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
97 | localMenu->insertSeparator(); | 97 | localMenu->insertSeparator(); |
98 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 98 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
99 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 99 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
100 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 100 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
101 | localMenu->insertSeparator(); | 101 | localMenu->insertSeparator(); |
102 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 102 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
103 | localMenu->setCheckable(TRUE); | 103 | localMenu->setCheckable(TRUE); |
104 | 104 | ||
105 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 105 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
106 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 106 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
107 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 107 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
108 | remoteMenu->insertSeparator(); | 108 | remoteMenu->insertSeparator(); |
109 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 109 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
110 | 110 | ||
111 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 111 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
112 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 112 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
113 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); | 113 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); |
114 | tabMenu->setCheckable(TRUE); | 114 | tabMenu->setCheckable(TRUE); |
115 | 115 | ||
116 | TabWidget = new QTabWidget( this, "TabWidget" ); | 116 | TabWidget = new QTabWidget( this, "TabWidget" ); |
117 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); | 117 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); |
118 | 118 | ||
119 | TabWidget->setTabShape(QTabWidget::Triangular); | 119 | // TabWidget->setTabShape(QTabWidget::Triangular); |
120 | 120 | ||
121 | tab = new QWidget( TabWidget, "tab" ); | 121 | tab = new QWidget( TabWidget, "tab" ); |
122 | tabLayout = new QGridLayout( tab ); | 122 | tabLayout = new QGridLayout( tab ); |
123 | tabLayout->setSpacing( 2); | 123 | tabLayout->setSpacing( 2); |
124 | tabLayout->setMargin( 2); | 124 | tabLayout->setMargin( 2); |
125 | 125 | ||
126 | Local_View = new QListView( tab, "Local_View" ); | 126 | Local_View = new QListView( tab, "Local_View" ); |
127 | // Local_View->setResizePolicy( QListView::AutoOneFit ); | 127 | // Local_View->setResizePolicy( QListView::AutoOneFit ); |
128 | Local_View->addColumn( tr("File"),150); | 128 | Local_View->addColumn( tr("File"),150); |
129 | Local_View->addColumn( tr("Size"),-1); | 129 | Local_View->addColumn( tr("Size"),-1); |
130 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 130 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
131 | Local_View->addColumn( tr("Date"),-1); | 131 | Local_View->addColumn( tr("Date"),-1); |
132 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 132 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
133 | Local_View->setAllColumnsShowFocus(TRUE); | 133 | Local_View->setAllColumnsShowFocus(TRUE); |
134 | Local_View->setMultiSelection( TRUE ); | 134 | Local_View->setMultiSelection( TRUE ); |
135 | Local_View->setSelectionMode(QListView::Extended); | 135 | Local_View->setSelectionMode(QListView::Extended); |
136 | 136 | ||
137 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 137 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
138 | 138 | ||
139 | tabLayout->addWidget( Local_View, 0, 0 ); | 139 | tabLayout->addWidget( Local_View, 0, 0 ); |
140 | 140 | ||
141 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 141 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
142 | this,SLOT( localListClicked(QListViewItem *)) ); | 142 | this,SLOT( localListClicked(QListViewItem *)) ); |
143 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), | 143 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), |
144 | // this,SLOT( localListClicked(QListViewItem *)) ); | 144 | // this,SLOT( localListClicked(QListViewItem *)) ); |
145 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 145 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
146 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 146 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
147 | 147 | ||
148 | TabWidget->insertTab( tab, tr( "Local" ) ); | 148 | TabWidget->insertTab( tab, tr( "Local" ) ); |
149 | 149 | ||
150 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 150 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
151 | tabLayout_2 = new QGridLayout( tab_2 ); | 151 | tabLayout_2 = new QGridLayout( tab_2 ); |
152 | tabLayout_2->setSpacing( 2); | 152 | tabLayout_2->setSpacing( 2); |
153 | tabLayout_2->setMargin( 2); | 153 | tabLayout_2->setMargin( 2); |
154 | 154 | ||
155 | Remote_View = new QListView( tab_2, "Remote_View" ); | 155 | Remote_View = new QListView( tab_2, "Remote_View" ); |
156 | Remote_View->addColumn( tr("File"),150); | 156 | Remote_View->addColumn( tr("File"),150); |
157 | Remote_View->addColumn( tr("Size"),-1); | 157 | Remote_View->addColumn( tr("Size"),-1); |
158 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 158 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
159 | Remote_View->addColumn( tr("Date"),-1); | 159 | Remote_View->addColumn( tr("Date"),-1); |
160 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 160 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
161 | Remote_View->addColumn( tr("Dir"),-1); | 161 | Remote_View->addColumn( tr("Dir"),-1); |
162 | Remote_View->setColumnAlignment(4,QListView::AlignRight); | 162 | Remote_View->setColumnAlignment(4,QListView::AlignRight); |
163 | Remote_View->setAllColumnsShowFocus(TRUE); | 163 | Remote_View->setAllColumnsShowFocus(TRUE); |
164 | Remote_View->setMultiSelection( TRUE ); | 164 | Remote_View->setMultiSelection( TRUE ); |
165 | Remote_View->setSelectionMode(QListView::Extended); | 165 | Remote_View->setSelectionMode(QListView::Extended); |
166 | 166 | ||
167 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 167 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
@@ -222,155 +222,156 @@ OpieFtp::OpieFtp( ) | |||
222 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); | 222 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); |
223 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 223 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
224 | PortSpinBox->setMaxValue(32786); | 224 | PortSpinBox->setMaxValue(32786); |
225 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); | 225 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); |
226 | 226 | ||
227 | QPushButton *deleteServerBtn; | 227 | QPushButton *deleteServerBtn; |
228 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); | 228 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); |
229 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); | 229 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); |
230 | 230 | ||
231 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); | 231 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); |
232 | 232 | ||
233 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); | 233 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); |
234 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); | 234 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); |
235 | connectServerBtn->setToggleButton(TRUE); | 235 | connectServerBtn->setToggleButton(TRUE); |
236 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); | 236 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); |
237 | 237 | ||
238 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 238 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
239 | tabLayout_3->addItem( spacer, 5, 0 ); | 239 | tabLayout_3->addItem( spacer, 5, 0 ); |
240 | 240 | ||
241 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 241 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
242 | 242 | ||
243 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 243 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
244 | this,SLOT(tabChanged(QWidget*))); | 244 | this,SLOT(tabChanged(QWidget*))); |
245 | 245 | ||
246 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 246 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
247 | currentDir.setPath( QDir::currentDirPath()); | 247 | currentDir.setPath( QDir::currentDirPath()); |
248 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 248 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
249 | 249 | ||
250 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 250 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
251 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 ); | 251 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 ); |
252 | currentPathCombo->setEditable(TRUE); | 252 | currentPathCombo->setEditable(TRUE); |
253 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 253 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
254 | 254 | ||
255 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 255 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
256 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 256 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
257 | 257 | ||
258 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 258 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
259 | this,SLOT(currentPathComboChanged())); | 259 | this,SLOT(currentPathComboChanged())); |
260 | 260 | ||
261 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 261 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
262 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); | 262 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); |
263 | 263 | ||
264 | // fillCombos(); | 264 | // fillCombos(); |
265 | 265 | ||
266 | filterStr="*"; | 266 | filterStr="*"; |
267 | b=FALSE; | 267 | b=FALSE; |
268 | populateLocalView(); | 268 | populateLocalView(); |
269 | readConfig(); | 269 | readConfig(); |
270 | ServerComboBox->setCurrentItem(currentServerConfig); | 270 | ServerComboBox->setCurrentItem(currentServerConfig); |
271 | |||
271 | TabWidget->setCurrentPage(2); | 272 | TabWidget->setCurrentPage(2); |
272 | } | 273 | } |
273 | 274 | ||
274 | OpieFtp::~OpieFtp() | 275 | OpieFtp::~OpieFtp() |
275 | { | 276 | { |
276 | } | 277 | } |
277 | 278 | ||
278 | void OpieFtp::cleanUp() | 279 | void OpieFtp::cleanUp() |
279 | { | 280 | { |
280 | if(conn) | 281 | if(conn) |
281 | FtpQuit(conn); | 282 | FtpQuit(conn); |
282 | QString sfile=QDir::homeDirPath(); | 283 | QString sfile=QDir::homeDirPath(); |
283 | if(sfile.right(1) != "/") | 284 | if(sfile.right(1) != "/") |
284 | sfile+="/._temp"; | 285 | sfile+="/._temp"; |
285 | else | 286 | else |
286 | sfile+="._temp"; | 287 | sfile+="._temp"; |
287 | QFile file( sfile); | 288 | QFile file( sfile); |
288 | if(file.exists()) | 289 | if(file.exists()) |
289 | file.remove(); | 290 | file.remove(); |
290 | exit(0); | 291 | exit(0); |
291 | } | 292 | } |
292 | 293 | ||
293 | void OpieFtp::tabChanged(QWidget *w) | 294 | void OpieFtp::tabChanged(QWidget *w) |
294 | { | 295 | { |
295 | if (TabWidget->currentPageIndex() == 0) { | 296 | if (TabWidget->currentPageIndex() == 0) { |
296 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 297 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
297 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); | 298 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); |
298 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 299 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
299 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 300 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
300 | } | 301 | } |
301 | if (TabWidget->currentPageIndex() == 1) { | 302 | if (TabWidget->currentPageIndex() == 1) { |
302 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 303 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
303 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); | 304 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); |
304 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 305 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
305 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 306 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
306 | } | 307 | } |
307 | if (TabWidget->currentPageIndex() == 2) { | 308 | if (TabWidget->currentPageIndex() == 2) { |
308 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); | 309 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); |
309 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 310 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
310 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 311 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
311 | } | 312 | } |
312 | } | 313 | } |
313 | 314 | ||
314 | void OpieFtp::newConnection() | 315 | void OpieFtp::newConnection() |
315 | { | 316 | { |
316 | UsernameComboBox->lineEdit()->setText(""); | 317 | UsernameComboBox->lineEdit()->setText(""); |
317 | PasswordEdit->setText( "" ); | 318 | PasswordEdit->setText( "" ); |
318 | ServerComboBox->lineEdit()->setText( ""); | 319 | ServerComboBox->lineEdit()->setText( ""); |
319 | remotePath->setText( currentRemoteDir = "/"); | 320 | remotePath->setText( currentRemoteDir = "/"); |
320 | PortSpinBox->setValue( 21); | 321 | PortSpinBox->setValue( 21); |
321 | TabWidget->setCurrentPage(2); | 322 | TabWidget->setCurrentPage(2); |
322 | } | 323 | } |
323 | 324 | ||
324 | void OpieFtp::serverComboEdited(const QString & edit) | 325 | void OpieFtp::serverComboEdited(const QString & edit) |
325 | { | 326 | { |
326 | if( !edit.isEmpty() ) { | 327 | if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { |
328 | qDebug("ServerComboEdited"); | ||
327 | currentServerConfig = -1; | 329 | currentServerConfig = -1; |
328 | // qDebug("comboedited"); | ||
329 | } | 330 | } |
330 | } | 331 | } |
331 | 332 | ||
332 | void OpieFtp::connectorBtnToggled(bool On) | 333 | void OpieFtp::connectorBtnToggled(bool On) |
333 | { | 334 | { |
334 | if(On) { | 335 | if(On) { |
335 | connector(); | 336 | connector(); |
336 | } else { | 337 | } else { |
337 | disConnector(); | 338 | disConnector(); |
338 | } | 339 | } |
339 | 340 | ||
340 | } | 341 | } |
341 | 342 | ||
342 | void OpieFtp::connector() | 343 | void OpieFtp::connector() |
343 | { | 344 | { |
344 | QCopEnvelope ( "QPE/System", "busy()" ); | 345 | QCopEnvelope ( "QPE/System", "busy()" ); |
345 | // qApp->processEvents(); | 346 | // qApp->processEvents(); |
346 | currentRemoteDir=remotePath->text(); | 347 | currentRemoteDir=remotePath->text(); |
347 | if(ServerComboBox->currentText().isEmpty()) { | 348 | if(ServerComboBox->currentText().isEmpty()) { |
348 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); | 349 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); |
349 | TabWidget->setCurrentPage(2); | 350 | TabWidget->setCurrentPage(2); |
350 | ServerComboBox->setFocus(); | 351 | ServerComboBox->setFocus(); |
351 | connectServerBtn->setOn(FALSE); | 352 | connectServerBtn->setOn(FALSE); |
352 | connectServerBtn->setText( tr("Connect")); | 353 | connectServerBtn->setText( tr("Connect")); |
353 | return; | 354 | return; |
354 | } | 355 | } |
355 | FtpInit(); | 356 | FtpInit(); |
356 | TabWidget->setCurrentPage(1); | 357 | TabWidget->setCurrentPage(1); |
357 | QString ftp_host = ServerComboBox->currentText(); | 358 | QString ftp_host = ServerComboBox->currentText(); |
358 | QString ftp_user = UsernameComboBox->currentText(); | 359 | QString ftp_user = UsernameComboBox->currentText(); |
359 | QString ftp_pass = PasswordEdit->text(); | 360 | QString ftp_pass = PasswordEdit->text(); |
360 | QString port=PortSpinBox->cleanText(); | 361 | QString port=PortSpinBox->cleanText(); |
361 | port.stripWhiteSpace(); | 362 | port.stripWhiteSpace(); |
362 | 363 | ||
363 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) | 364 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) |
364 | ftp_host=ftp_host.right(ftp_host.length()-6); | 365 | ftp_host=ftp_host.right(ftp_host.length()-6); |
365 | ftp_host+=":"+port; | 366 | ftp_host+=":"+port; |
366 | if (!FtpConnect( ftp_host.latin1(), &conn)) { | 367 | if (!FtpConnect( ftp_host.latin1(), &conn)) { |
367 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); | 368 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); |
368 | connectServerBtn->setOn(FALSE); | 369 | connectServerBtn->setOn(FALSE); |
369 | connectServerBtn->setText( tr("Connect")); | 370 | connectServerBtn->setText( tr("Connect")); |
370 | return ; | 371 | return ; |
371 | } | 372 | } |
372 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { | 373 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { |
373 | QString msg; | 374 | QString msg; |
374 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); | 375 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); |
375 | msg.replace(QRegExp(":"),"\n"); | 376 | msg.replace(QRegExp(":"),"\n"); |
376 | QMessageBox::message(tr("Note"),msg); | 377 | QMessageBox::message(tr("Note"),msg); |
@@ -478,97 +479,97 @@ void OpieFtp::remoteDownload() | |||
478 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 479 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
479 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); | 480 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); |
480 | 481 | ||
481 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 482 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
482 | QString msg; | 483 | QString msg; |
483 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); | 484 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); |
484 | msg.replace(QRegExp(":"),"\n"); | 485 | msg.replace(QRegExp(":"),"\n"); |
485 | QMessageBox::message(tr("Note"),msg); | 486 | QMessageBox::message(tr("Note"),msg); |
486 | } | 487 | } |
487 | ProgressBar->reset(); | 488 | ProgressBar->reset(); |
488 | nullifyCallBack(); | 489 | nullifyCallBack(); |
489 | } | 490 | } |
490 | it.current()->setSelected(FALSE); | 491 | it.current()->setSelected(FALSE); |
491 | } | 492 | } |
492 | TabWidget->setCurrentPage(0); | 493 | TabWidget->setCurrentPage(0); |
493 | populateLocalView(); | 494 | populateLocalView(); |
494 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 495 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
495 | } | 496 | } |
496 | 497 | ||
497 | bool OpieFtp::remoteDirList(const QString &dir) | 498 | bool OpieFtp::remoteDirList(const QString &dir) |
498 | { | 499 | { |
499 | QString tmp = QDir::homeDirPath(); | 500 | QString tmp = QDir::homeDirPath(); |
500 | if(tmp.right(1) != "/") | 501 | if(tmp.right(1) != "/") |
501 | tmp+="/._temp"; | 502 | tmp+="/._temp"; |
502 | else | 503 | else |
503 | tmp+="._temp"; | 504 | tmp+="._temp"; |
504 | // qDebug("Listing remote dir "+tmp); | 505 | // qDebug("Listing remote dir "+tmp); |
505 | QCopEnvelope ( "QPE/System", "busy()" ); | 506 | QCopEnvelope ( "QPE/System", "busy()" ); |
506 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { | 507 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { |
507 | QString msg; | 508 | QString msg; |
508 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); | 509 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); |
509 | msg.replace(QRegExp(":"),"\n"); | 510 | msg.replace(QRegExp(":"),"\n"); |
510 | QMessageBox::message(tr("Note"),msg); | 511 | QMessageBox::message(tr("Note"),msg); |
511 | return false; | 512 | return false; |
512 | } | 513 | } |
513 | populateRemoteView() ; | 514 | populateRemoteView() ; |
514 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 515 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
515 | return true; | 516 | return true; |
516 | } | 517 | } |
517 | 518 | ||
518 | bool OpieFtp::remoteChDir(const QString &dir) | 519 | bool OpieFtp::remoteChDir(const QString &dir) |
519 | { | 520 | { |
520 | QCopEnvelope ( "QPE/System", "busy()" ); | 521 | QCopEnvelope ( "QPE/System", "busy()" ); |
521 | if (!FtpChdir( dir.latin1(), conn )) { | 522 | if (!FtpChdir( dir.latin1(), conn )) { |
522 | QString msg; | 523 | QString msg; |
523 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); | 524 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); |
524 | msg.replace(QRegExp(":"),"\n"); | 525 | msg.replace(QRegExp(":"),"\n"); |
525 | QMessageBox::message(tr("Note"),msg); | 526 | QMessageBox::message(tr("Note"),msg); |
526 | qDebug(msg); | 527 | // qDebug(msg); |
527 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 528 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
528 | return FALSE; | 529 | return FALSE; |
529 | } | 530 | } |
530 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 531 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
531 | return TRUE; | 532 | return TRUE; |
532 | } | 533 | } |
533 | 534 | ||
534 | void OpieFtp::populateLocalView() | 535 | void OpieFtp::populateLocalView() |
535 | { | 536 | { |
536 | Local_View->clear(); | 537 | Local_View->clear(); |
537 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 538 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
538 | currentDir.setMatchAllDirs(TRUE); | 539 | currentDir.setMatchAllDirs(TRUE); |
539 | currentDir.setNameFilter(filterStr); | 540 | currentDir.setNameFilter(filterStr); |
540 | QString fileL, fileS, fileDate; | 541 | QString fileL, fileS, fileDate; |
541 | bool isDir=FALSE; | 542 | bool isDir=FALSE; |
542 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 543 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
543 | QFileInfoListIterator it(*list); | 544 | QFileInfoListIterator it(*list); |
544 | QFileInfo *fi; | 545 | QFileInfo *fi; |
545 | while ( (fi=it.current()) ) { | 546 | while ( (fi=it.current()) ) { |
546 | if (fi->isSymLink() ){ | 547 | if (fi->isSymLink() ){ |
547 | QString symLink=fi->readLink(); | 548 | QString symLink=fi->readLink(); |
548 | // qDebug("Symlink detected "+symLink); | 549 | // qDebug("Symlink detected "+symLink); |
549 | QFileInfo sym( symLink); | 550 | QFileInfo sym( symLink); |
550 | fileS.sprintf( "%10li", sym.size() ); | 551 | fileS.sprintf( "%10li", sym.size() ); |
551 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 552 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
552 | fileDate = sym.lastModified().toString(); | 553 | fileDate = sym.lastModified().toString(); |
553 | } else { | 554 | } else { |
554 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 555 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
555 | fileS.sprintf( "%10li", fi->size() ); | 556 | fileS.sprintf( "%10li", fi->size() ); |
556 | fileL.sprintf( "%s",fi->fileName().data() ); | 557 | fileL.sprintf( "%s",fi->fileName().data() ); |
557 | fileDate= fi->lastModified().toString(); | 558 | fileDate= fi->lastModified().toString(); |
558 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 559 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
559 | fileL+="/"; | 560 | fileL+="/"; |
560 | isDir=TRUE; | 561 | isDir=TRUE; |
561 | // qDebug( fileL); | 562 | // qDebug( fileL); |
562 | } | 563 | } |
563 | } | 564 | } |
564 | if(fileL !="./" && fi->exists()) { | 565 | if(fileL !="./" && fi->exists()) { |
565 | item= new QListViewItem( Local_View,fileL,fileS , fileDate); | 566 | item= new QListViewItem( Local_View,fileL,fileS , fileDate); |
566 | QPixmap pm; | 567 | QPixmap pm; |
567 | 568 | ||
568 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 569 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
569 | if( !QDir( fi->filePath() ).isReadable()) | 570 | if( !QDir( fi->filePath() ).isReadable()) |
570 | pm = Resource::loadPixmap( "lockedfolder" ); | 571 | pm = Resource::loadPixmap( "lockedfolder" ); |
571 | else | 572 | else |
572 | pm= Resource::loadPixmap( "folder" ); | 573 | pm= Resource::loadPixmap( "folder" ); |
573 | item->setPixmap( 0,pm ); | 574 | item->setPixmap( 0,pm ); |
574 | } else { | 575 | } else { |
@@ -622,105 +623,105 @@ bool OpieFtp::populateRemoteView( ) | |||
622 | if(s.left(1) == "d") | 623 | if(s.left(1) == "d") |
623 | fileL = fileL+"/"; | 624 | fileL = fileL+"/"; |
624 | // fileL = "/"+fileL+"/"; | 625 | // fileL = "/"+fileL+"/"; |
625 | fileS = s.mid( 30, 42-30); | 626 | fileS = s.mid( 30, 42-30); |
626 | fileS = fileS.stripWhiteSpace(); | 627 | fileS = fileS.stripWhiteSpace(); |
627 | fileDate = s.mid( 42, 55-42); | 628 | fileDate = s.mid( 42, 55-42); |
628 | fileDate = fileDate.stripWhiteSpace(); | 629 | fileDate = fileDate.stripWhiteSpace(); |
629 | if(fileL.find("total",0,TRUE) == -1) { | 630 | if(fileL.find("total",0,TRUE) == -1) { |
630 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { | 631 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { |
631 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); | 632 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); |
632 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 633 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
633 | // if(itemDir) | 634 | // if(itemDir) |
634 | item->moveItem(itemDir); | 635 | item->moveItem(itemDir); |
635 | itemDir=item; | 636 | itemDir=item; |
636 | } else { | 637 | } else { |
637 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); | 638 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); |
638 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 639 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
639 | // if(itemFile) | 640 | // if(itemFile) |
640 | item->moveItem(itemDir); | 641 | item->moveItem(itemDir); |
641 | item->moveItem(itemFile); | 642 | item->moveItem(itemFile); |
642 | itemFile=item; | 643 | itemFile=item; |
643 | } | 644 | } |
644 | } | 645 | } |
645 | } | 646 | } |
646 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 647 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
647 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 648 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
648 | file.close(); | 649 | file.close(); |
649 | if( file.exists()) | 650 | if( file.exists()) |
650 | file. remove(); | 651 | file. remove(); |
651 | } else | 652 | } else |
652 | qDebug("temp file not opened successfullly "+sfile); | 653 | qDebug("temp file not opened successfullly "+sfile); |
653 | Remote_View->setSorting( 4,TRUE); | 654 | Remote_View->setSorting( 4,TRUE); |
654 | return true; | 655 | return true; |
655 | } | 656 | } |
656 | 657 | ||
657 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 658 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
658 | { | 659 | { |
659 | if( selectedItem) { | 660 | if( selectedItem) { |
660 | // QCopEnvelope ( "QPE/System", "busy()" ); | 661 | // QCopEnvelope ( "QPE/System", "busy()" ); |
661 | QString oldRemoteCurrentDir = currentRemoteDir; | 662 | QString oldRemoteCurrentDir = currentRemoteDir; |
662 | QString strItem=selectedItem->text(0); | 663 | QString strItem=selectedItem->text(0); |
663 | strItem=strItem.simplifyWhiteSpace(); | 664 | strItem=strItem.simplifyWhiteSpace(); |
664 | if(strItem == "../") { // the user wants to go ^ | 665 | if(strItem == "../") { // the user wants to go ^ |
665 | if( FtpCDUp( conn) == 0) { | 666 | if( FtpCDUp( conn) == 0) { |
666 | QString msg; | 667 | QString msg; |
667 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 668 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
668 | msg.replace(QRegExp(":"),"\n"); | 669 | msg.replace(QRegExp(":"),"\n"); |
669 | QMessageBox::message(tr("Note"),msg); | 670 | QMessageBox::message(tr("Note"),msg); |
670 | qDebug(msg); | 671 | // qDebug(msg); |
671 | } | 672 | } |
672 | char path[256]; | 673 | char path[256]; |
673 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 674 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
674 | QString msg; | 675 | QString msg; |
675 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 676 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
676 | msg.replace(QRegExp(":"),"\n"); | 677 | msg.replace(QRegExp(":"),"\n"); |
677 | QMessageBox::message(tr("Note"),msg); | 678 | QMessageBox::message(tr("Note"),msg); |
678 | qDebug(msg); | 679 | // qDebug(msg); |
679 | } | 680 | } |
680 | currentRemoteDir=path; | 681 | currentRemoteDir=path; |
681 | } else { | 682 | } else { |
682 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 683 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
683 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 684 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
684 | strItem = strItem.stripWhiteSpace(); | 685 | strItem = strItem.stripWhiteSpace(); |
685 | currentRemoteDir = strItem; | 686 | currentRemoteDir = strItem; |
686 | if( !remoteChDir( (const QString &)strItem)) { | 687 | if( !remoteChDir( (const QString &)strItem)) { |
687 | currentRemoteDir = oldRemoteCurrentDir; | 688 | currentRemoteDir = oldRemoteCurrentDir; |
688 | strItem=""; | 689 | strItem=""; |
689 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 690 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
690 | } | 691 | } |
691 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 692 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
692 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 693 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
693 | currentRemoteDir = oldRemoteCurrentDir; | 694 | currentRemoteDir = oldRemoteCurrentDir; |
694 | strItem=""; | 695 | strItem=""; |
695 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 696 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
696 | 697 | ||
697 | } else { | 698 | } else { |
698 | currentRemoteDir = currentRemoteDir+strItem; | 699 | currentRemoteDir = currentRemoteDir+strItem; |
699 | } | 700 | } |
700 | } else { | 701 | } else { |
701 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 702 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
702 | return; | 703 | return; |
703 | } | 704 | } |
704 | } | 705 | } |
705 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 706 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
706 | if(currentRemoteDir.right(1) !="/") | 707 | if(currentRemoteDir.right(1) !="/") |
707 | currentRemoteDir +="/"; | 708 | currentRemoteDir +="/"; |
708 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 709 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
709 | fillRemoteCombo( (const QString &)currentRemoteDir); | 710 | fillRemoteCombo( (const QString &)currentRemoteDir); |
710 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 711 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
711 | } | 712 | } |
712 | } | 713 | } |
713 | 714 | ||
714 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 715 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
715 | { | 716 | { |
716 | if(selectedItem!= NULL) { | 717 | if(selectedItem!= NULL) { |
717 | 718 | ||
718 | QString strItem=selectedItem->text(0); | 719 | QString strItem=selectedItem->text(0); |
719 | QString strSize=selectedItem->text(1); | 720 | QString strSize=selectedItem->text(1); |
720 | strSize=strSize.stripWhiteSpace(); | 721 | strSize=strSize.stripWhiteSpace(); |
721 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 722 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
722 | // is symlink | 723 | // is symlink |
723 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 724 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
724 | if(QDir(strItem2).exists() ) { | 725 | if(QDir(strItem2).exists() ) { |
725 | currentDir.cd(strItem2, TRUE); | 726 | currentDir.cd(strItem2, TRUE); |
726 | populateLocalView(); | 727 | populateLocalView(); |
@@ -1020,112 +1021,112 @@ void OpieFtp::fillRemoteCombo(const QString ¤tPath) { | |||
1020 | void OpieFtp::currentPathComboChanged() | 1021 | void OpieFtp::currentPathComboChanged() |
1021 | { | 1022 | { |
1022 | QString oldRemoteCurrentDir = currentRemoteDir; | 1023 | QString oldRemoteCurrentDir = currentRemoteDir; |
1023 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 1024 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); |
1024 | if (TabWidget->currentPageIndex() == 0) { | 1025 | if (TabWidget->currentPageIndex() == 0) { |
1025 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 1026 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
1026 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 1027 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
1027 | populateLocalView(); | 1028 | populateLocalView(); |
1028 | } else { | 1029 | } else { |
1029 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 1030 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
1030 | } | 1031 | } |
1031 | } | 1032 | } |
1032 | if (TabWidget->currentPageIndex() == 1) { | 1033 | if (TabWidget->currentPageIndex() == 1) { |
1033 | currentRemoteDir = currentPathCombo->lineEdit()->text(); | 1034 | currentRemoteDir = currentPathCombo->lineEdit()->text(); |
1034 | if(currentRemoteDir.right(1) !="/") { | 1035 | if(currentRemoteDir.right(1) !="/") { |
1035 | currentRemoteDir = currentRemoteDir +"/"; | 1036 | currentRemoteDir = currentRemoteDir +"/"; |
1036 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1037 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1037 | } | 1038 | } |
1038 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 1039 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
1039 | currentRemoteDir = oldRemoteCurrentDir; | 1040 | currentRemoteDir = oldRemoteCurrentDir; |
1040 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1041 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | remoteDirList( (const QString &)currentRemoteDir); | 1044 | remoteDirList( (const QString &)currentRemoteDir); |
1044 | } | 1045 | } |
1045 | } | 1046 | } |
1046 | 1047 | ||
1047 | void OpieFtp::switchToLocalTab() | 1048 | void OpieFtp::switchToLocalTab() |
1048 | { | 1049 | { |
1049 | TabWidget->setCurrentPage(0); | 1050 | TabWidget->setCurrentPage(0); |
1050 | } | 1051 | } |
1051 | 1052 | ||
1052 | void OpieFtp::switchToRemoteTab() | 1053 | void OpieFtp::switchToRemoteTab() |
1053 | { | 1054 | { |
1054 | TabWidget->setCurrentPage(1); | 1055 | TabWidget->setCurrentPage(1); |
1055 | } | 1056 | } |
1056 | 1057 | ||
1057 | void OpieFtp::switchToConfigTab() | 1058 | void OpieFtp::switchToConfigTab() |
1058 | { | 1059 | { |
1059 | TabWidget->setCurrentPage(2); | 1060 | TabWidget->setCurrentPage(2); |
1060 | } | 1061 | } |
1061 | 1062 | ||
1062 | void OpieFtp::readConfig() | 1063 | void OpieFtp::readConfig() |
1063 | { | 1064 | { |
1064 | fillCombos(); | 1065 | fillCombos(); |
1065 | Config cfg("opieftp"); | 1066 | Config cfg("opieftp"); |
1066 | cfg.setGroup("Server"); | 1067 | cfg.setGroup("Server"); |
1067 | currentServerConfig = cfg.readNumEntry("currentServer", -1); | 1068 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
1069 | // qDebug("Reading %d", currentServerConfig); | ||
1068 | serverComboSelected( currentServerConfig); | 1070 | serverComboSelected( currentServerConfig); |
1069 | } | 1071 | } |
1070 | 1072 | ||
1071 | void OpieFtp::writeConfig() | 1073 | void OpieFtp::writeConfig() |
1072 | { | 1074 | { |
1073 | Config cfg("opieftp"); | 1075 | Config cfg("opieftp"); |
1074 | cfg.setGroup("Server"); | 1076 | cfg.setGroup("Server"); |
1075 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1077 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1076 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1078 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1077 | if( currentServerConfig == -1) { | 1079 | if( currentServerConfig == -1) { |
1078 | for (int i = 1; i <= numberOfEntries; i++) { | 1080 | for (int i = 1; i <= numberOfEntries; i++) { |
1079 | temp.setNum(i); | 1081 | temp.setNum(i); |
1080 | cfg.setGroup("Server"); | 1082 | cfg.setGroup("Server"); |
1081 | QString tempStr = cfg.readEntry( temp,""); | 1083 | QString tempStr = cfg.readEntry( temp,""); |
1082 | } | 1084 | } |
1083 | |||
1084 | temp.setNum( numberOfEntries + 1); | 1085 | temp.setNum( numberOfEntries + 1); |
1085 | cfg.setGroup("Server"); | 1086 | cfg.setGroup("Server"); |
1086 | remoteServerStr = cfg.readEntry( temp,""); | 1087 | remoteServerStr = cfg.readEntry( temp,""); |
1087 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1088 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1088 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1089 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1089 | 1090 | ||
1090 | temp.setNum(numberOfEntries+1); | 1091 | temp.setNum(numberOfEntries+1); |
1091 | cfg.setGroup("Server"); | 1092 | cfg.setGroup("Server"); |
1092 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1093 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1093 | cfg.setGroup(temp); | 1094 | cfg.setGroup(temp); |
1094 | cfg.writeEntry("RemotePath", remotePath->text()); | 1095 | cfg.writeEntry("RemotePath", remotePath->text()); |
1095 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1096 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1096 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1097 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1097 | cfg.setGroup("Server"); | 1098 | cfg.setGroup("Server"); |
1098 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1099 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1099 | } | 1100 | } |
1100 | } | 1101 | } |
1101 | 1102 | ||
1102 | void OpieFtp::fillCombos() | 1103 | void OpieFtp::fillCombos() |
1103 | { | 1104 | { |
1104 | Config cfg("opieftp"); | 1105 | Config cfg("opieftp"); |
1105 | cfg.setGroup("Server"); | 1106 | cfg.setGroup("Server"); |
1106 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1107 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1107 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1108 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1108 | for (int i = 1; i <= numberOfEntries; i++) { | 1109 | for (int i = 1; i <= numberOfEntries; i++) { |
1109 | temp.setNum(i); | 1110 | temp.setNum(i); |
1110 | cfg.setGroup("Server"); | 1111 | cfg.setGroup("Server"); |
1111 | remoteServerStr = cfg.readEntry( temp,""); | 1112 | remoteServerStr = cfg.readEntry( temp,""); |
1112 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1113 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1113 | port = remoteServerStr.right( divider - 1); | 1114 | port = remoteServerStr.right( divider - 1); |
1114 | bool ok; | 1115 | bool ok; |
1115 | PortSpinBox->setValue( port.toInt(&ok,10)); | 1116 | PortSpinBox->setValue( port.toInt(&ok,10)); |
1116 | 1117 | ||
1117 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1118 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1118 | ServerComboBox->insertItem( remoteServerStr ); | 1119 | ServerComboBox->insertItem( remoteServerStr ); |
1119 | // cfg.setGroup(temp); | 1120 | // cfg.setGroup(temp); |
1120 | 1121 | ||
1121 | // remotePathStr = cfg.readEntry(remoteServer,""); | 1122 | // remotePathStr = cfg.readEntry(remoteServer,""); |
1122 | // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); | 1123 | // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); |
1123 | // port = remoteServer.right( divider+1); | 1124 | // port = remoteServer.right( divider+1); |
1124 | // PortSpinBox->setValue( port); | 1125 | // PortSpinBox->setValue( port); |
1125 | 1126 | ||
1126 | // remoteServer = remoteServer.left(divider - 1); | 1127 | // remoteServer = remoteServer.left(divider - 1); |
1127 | // remotePath->setText( remotePathStr); | 1128 | // remotePath->setText( remotePathStr); |
1128 | 1129 | ||
1129 | // username = cfg.readEntry(temp); | 1130 | // username = cfg.readEntry(temp); |
1130 | // UsernameComboBox->insertItem(username); | 1131 | // UsernameComboBox->insertItem(username); |
1131 | // password = cfg.readEntryCrypt(username,""); | 1132 | // password = cfg.readEntryCrypt(username,""); |