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