summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 0cdac79..523a36c 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -53,215 +53,219 @@ static int log_progress(netbuf *ctl, int xfered, void *arg)
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
62OpieFtp::OpieFtp( ) 62OpieFtp::OpieFtp( )
63 : QMainWindow( ) 63 : QMainWindow( )
64{ 64{
65 resize( 236, 290 ); 65 resize( 236, 290 );
66 setMaximumSize( QSize( 240, 320 ) ); 66 setMaximumSize( QSize( 240, 320 ) );
67 setCaption( tr( "OpieFtp" ) ); 67 setCaption( tr( "OpieFtp" ) );
68 68
69 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 69 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
70 70
71 QPEMenuBar *menuBar = new QPEMenuBar( this ); 71 QPEMenuBar *menuBar = new QPEMenuBar( this );
72 connectionMenu = new QPopupMenu( this ); 72 connectionMenu = new QPopupMenu( this );
73 localMenu = new QPopupMenu( this ); 73 localMenu = new QPopupMenu( this );
74 remoteMenu = new QPopupMenu( this ); 74 remoteMenu = new QPopupMenu( this );
75 menuBar->insertItem( tr( "Connection" ), connectionMenu); 75 menuBar->insertItem( tr( "Connection" ), connectionMenu);
76 menuBar->insertItem( tr( "Local" ), localMenu); 76 menuBar->insertItem( tr( "Local" ), localMenu);
77 menuBar->insertItem( tr( "Remote" ), remoteMenu); 77 menuBar->insertItem( tr( "Remote" ), remoteMenu);
78 78
79 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 79 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
80 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 80 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
81 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 81 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
82 82
83 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 83 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
84 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 84 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
85 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 85 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
86 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 86 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
87 localMenu->insertSeparator(); 87 localMenu->insertSeparator();
88 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 88 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
89 89
90 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 90 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
91 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 91 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
92 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 92 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
93 remoteMenu->insertSeparator(); 93 remoteMenu->insertSeparator();
94 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 94 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
95 95
96 ProgressBar = new QProgressBar( this, "ProgressBar" ); 96 ProgressBar = new QProgressBar( this, "ProgressBar" );
97 ProgressBar->setGeometry( QRect( 5, 268, 231, 15 ) ); 97 ProgressBar->setGeometry( QRect( 5, 268, 231, 15 ) );
98 98
99 TabWidget = new QTabWidget( this, "TabWidget2" ); 99 TabWidget = new QTabWidget( this, "TabWidget2" );
100 TabWidget->setGeometry( QRect( 3, 25, 240, 220 ) ); 100 TabWidget->setGeometry( QRect( 3, 25, 240, 220 ) );
101 TabWidget->setTabShape(QTabWidget::Triangular); 101 TabWidget->setTabShape(QTabWidget::Triangular);
102 102
103 tab = new QWidget( TabWidget, "tab" ); 103 tab = new QWidget( TabWidget, "tab" );
104 104
105 Local_View = new QListView( tab, "Local_View" ); 105 Local_View = new QListView( tab, "Local_View" );
106 Local_View->setGeometry( QRect( 3, 2, 225, 195 ) ); 106 Local_View->setGeometry( QRect( 3, 2, 225, 195 ) );
107 Local_View->addColumn( "File",120); 107 Local_View->addColumn( "File",120);
108 Local_View->addColumn( "Size",-1); 108 Local_View->addColumn( "Size",-1);
109 Local_View->setColumnAlignment(1,QListView::AlignRight); 109 Local_View->setColumnAlignment(1,QListView::AlignRight);
110 Local_View->addColumn( "Date",-1); 110 Local_View->addColumn( "Date",-1);
111 Local_View->setColumnAlignment(2,QListView::AlignRight); 111 Local_View->setColumnAlignment(2,QListView::AlignRight);
112 Local_View->setAllColumnsShowFocus(TRUE); 112 Local_View->setAllColumnsShowFocus(TRUE);
113 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 113 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
114 114
115 connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), 115 connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
116 this,SLOT( localListClicked(QListViewItem *)) ); 116 this,SLOT( localListClicked(QListViewItem *)) );
117 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 117 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
118 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 118 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
119 119
120 TabWidget->insertTab( tab, tr( "Local" ) ); 120 TabWidget->insertTab( tab, tr( "Local" ) );
121 121
122 tab_2 = new QWidget( TabWidget, "tab_2" ); 122 tab_2 = new QWidget( TabWidget, "tab_2" );
123 123
124 Remote_View = new QListView( tab_2, "Remote_View" ); 124 Remote_View = new QListView( tab_2, "Remote_View" );
125 Remote_View->setGeometry( QRect( 3, 2, 225, 195 ) ); 125 Remote_View->setGeometry( QRect( 3, 2, 225, 195 ) );
126 Remote_View->addColumn( "File",120); 126 Remote_View->addColumn( "File",120);
127 Remote_View->addColumn( "Size",-1); 127 Remote_View->addColumn( "Size",-1);
128 Remote_View->setColumnAlignment(1,QListView::AlignRight); 128 Remote_View->setColumnAlignment(1,QListView::AlignRight);
129 Remote_View->addColumn( "Date",-1); 129 Remote_View->addColumn( "Date",-1);
130 Remote_View->setColumnAlignment(2,QListView::AlignRight); 130 Remote_View->setColumnAlignment(2,QListView::AlignRight);
131 Remote_View->setAllColumnsShowFocus(TRUE); 131 Remote_View->setAllColumnsShowFocus(TRUE);
132 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 132 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
133 133
134 connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)), 134 connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)),
135 this,SLOT( remoteListClicked(QListViewItem *)) ); 135 this,SLOT( remoteListClicked(QListViewItem *)) );
136 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 136 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
137 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 137 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
138 138
139 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 139 TabWidget->insertTab( tab_2, tr( "Remote" ) );
140 140
141 tab_3 = new QWidget( TabWidget, "tab_3" ); 141 tab_3 = new QWidget( TabWidget, "tab_3" );
142 142
143 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 143 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
144 TextLabel1->setGeometry( QRect( 10, 10, 60, 16 ) ); 144 TextLabel1->setGeometry( QRect( 10, 10, 60, 16 ) );
145 TextLabel1->setText( tr( "Username" ) ); 145 TextLabel1->setText( tr( "Username" ) );
146 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 146 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
147 UsernameComboBox->setGeometry( QRect( 10, 25, 196, 21 ) ); 147 UsernameComboBox->setGeometry( QRect( 10, 25, 196, 21 ) );
148 UsernameComboBox->setEditable(TRUE); 148 UsernameComboBox->setEditable(TRUE);
149 UsernameComboBox->lineEdit()->setText("llornkcor"); 149 UsernameComboBox->lineEdit()->setText("anonymous");
150// UsernameComboBox->lineEdit()->setText("llornkcor");
150 151
151 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 152 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
152 TextLabel2->setGeometry( QRect( 10, 50, 65, 16 ) ); 153 TextLabel2->setGeometry( QRect( 10, 50, 65, 16 ) );
153 TextLabel2->setText( tr( "Password" ) ); 154 TextLabel2->setText( tr( "Password" ) );
154 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 155 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
155 PasswordEdit->setGeometry( QRect( 10, 65, 195, 16 ) ); 156 PasswordEdit->setGeometry( QRect( 10, 65, 195, 16 ) );
156 PasswordEdit->setEchoMode(QLineEdit::Password); 157 PasswordEdit->setEchoMode(QLineEdit::Password);
158 PasswordEdit->setText( tr( "me@opieftp.org" ) );
157 159
158 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 160 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
159 TextLabel3->setGeometry( QRect( 10, 90, 95, 16 ) ); 161 TextLabel3->setGeometry( QRect( 10, 90, 95, 16 ) );
160 TextLabel3->setText( tr( "Remote server" ) ); 162 TextLabel3->setText( tr( "Remote server" ) );
161 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 163 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
162 ServerComboBox->setGeometry( QRect( 10, 105, 195, 21 ) ); 164 ServerComboBox->setGeometry( QRect( 10, 105, 195, 21 ) );
163 ServerComboBox->setEditable(TRUE); 165 ServerComboBox->setEditable(TRUE);
164 ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); 166 ServerComboBox->lineEdit()->setText( tr( "" ) );
167// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
165 168
166 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 169 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
167 TextLabel5->setGeometry( QRect( 10, 130, 95, 16 ) ); 170 TextLabel5->setGeometry( QRect( 10, 130, 95, 16 ) );
168 TextLabel5->setText( tr( "Remote path" ) ); 171 TextLabel5->setText( tr( "Remote path" ) );
169 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 172 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
170 remotePath->setGeometry( QRect( 10, 145, 195, 16 ) ); 173 remotePath->setGeometry( QRect( 10, 145, 195, 16 ) );
171 remotePath->setText( currentRemoteDir = "/home/llornkcor/"); 174 remotePath->setText( currentRemoteDir = "/");
175// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
172 176
173 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 177 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
174 TextLabel4->setGeometry( QRect( 10, 170, 30, 21 ) ); 178 TextLabel4->setGeometry( QRect( 10, 170, 30, 21 ) );
175 TextLabel4->setText( tr( "Port" ) ); 179 TextLabel4->setText( tr( "Port" ) );
176 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 180 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
177 PortSpinBox->setGeometry( QRect( 40, 175, 75, 20 ) ); 181 PortSpinBox->setGeometry( QRect( 40, 175, 75, 20 ) );
178 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 182 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
179 PortSpinBox->setMaxValue(32786); 183 PortSpinBox->setMaxValue(32786);
180 PortSpinBox->setValue( 21); 184 PortSpinBox->setValue( 21);
181 185
182 TabWidget->insertTab( tab_3, tr( "Config" ) ); 186 TabWidget->insertTab( tab_3, tr( "Config" ) );
183 187
184 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 188 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
185 this,SLOT(tabChanged(QWidget*))); 189 this,SLOT(tabChanged(QWidget*)));
186 190
187 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 191 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
188 currentDir.setPath( QDir::currentDirPath()); 192 currentDir.setPath( QDir::currentDirPath());
189// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 193// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
190 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); 194 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" );
191 currentPathEdit->setGeometry( QRect( 5, 248, 220, 18 ) ); 195 currentPathEdit->setGeometry( QRect( 5, 248, 220, 18 ) );
192 currentPathEdit->setText( currentDir.canonicalPath()); 196 currentPathEdit->setText( currentDir.canonicalPath());
193 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); 197 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged()));
194 198
195 filterStr="*"; 199 filterStr="*";
196 populateLocalView(); 200 populateLocalView();
197} 201}
198 202
199OpieFtp::~OpieFtp() 203OpieFtp::~OpieFtp()
200{ 204{
201} 205}
202 206
203void OpieFtp::cleanUp() 207void OpieFtp::cleanUp()
204{ 208{
205 if(conn) 209 if(conn)
206 FtpQuit(conn); 210 FtpQuit(conn);
207 QFile f("./._temp"); 211 QFile f("./._temp");
208 if(f.exists()) 212 if(f.exists())
209 f. remove(); 213 f. remove();
210} 214}
211 215
212void OpieFtp::tabChanged(QWidget *w) 216void OpieFtp::tabChanged(QWidget *w)
213{ 217{
214 if (TabWidget->currentPageIndex() == 0) { 218 if (TabWidget->currentPageIndex() == 0) {
215 currentPathEdit->setText( currentDir.canonicalPath()); 219 currentPathEdit->setText( currentDir.canonicalPath());
216 } else if (TabWidget->currentPageIndex() == 1) { 220 } else if (TabWidget->currentPageIndex() == 1) {
217 currentPathEdit->setText( currentRemoteDir ); 221 currentPathEdit->setText( currentRemoteDir );
218 } 222 }
219} 223}
220 224
221void OpieFtp::localUpload() 225void OpieFtp::localUpload()
222{ 226{
223 int fsz; 227 int fsz;
224 QCopEnvelope ( "QPE/System", "busy()" ); 228 QCopEnvelope ( "QPE/System", "busy()" );
225 qApp->processEvents(); 229 qApp->processEvents();
226 QString strItem = Local_View->currentItem()->text(0); 230 QString strItem = Local_View->currentItem()->text(0);
227 QString localFile = currentDir.canonicalPath()+"/"+strItem; 231 QString localFile = currentDir.canonicalPath()+"/"+strItem;
228 QString remoteFile= currentRemoteDir+strItem; 232 QString remoteFile= currentRemoteDir+strItem;
229 QFileInfo fi(localFile); 233 QFileInfo fi(localFile);
230 if( !fi.isDir()) { 234 if( !fi.isDir()) {
231 fsz=fi.size(); 235 fsz=fi.size();
232 ProgressBar->setTotalSteps(fsz); 236 ProgressBar->setTotalSteps(fsz);
233 237
234 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 238 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
235 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 239 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
236 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 240 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
237 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 241 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
238 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 242 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
239 243
240 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 244 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
241 QString msg; 245 QString msg;
242 msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn)); 246 msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn));
243 msg.replace(QRegExp(":"),"\n"); 247 msg.replace(QRegExp(":"),"\n");
244 QMessageBox::message("Note",msg); 248 QMessageBox::message("Note",msg);
245// FtpQuit(conn); 249// FtpQuit(conn);
246 } 250 }
247 ProgressBar->reset(); 251 ProgressBar->reset();
248 nullifyCallBack(); 252 nullifyCallBack();
249 } else { 253 } else {
250 QMessageBox::message("Note","Cannot upload directories"); 254 QMessageBox::message("Note","Cannot upload directories");
251 } 255 }
252 TabWidget->setCurrentPage(1); 256 TabWidget->setCurrentPage(1);
253 populateRemoteView(); 257 populateRemoteView();
254 QCopEnvelope ( "QPE/System", "notBusy()" ); 258 QCopEnvelope ( "QPE/System", "notBusy()" );
255} 259}
256 260
257void OpieFtp::nullifyCallBack() { 261void OpieFtp::nullifyCallBack() {
258 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 262 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
259 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 263 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
260 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 264 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
261 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 265 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
262 266
263} 267}
264 268
265void OpieFtp::remoteDownload() 269void OpieFtp::remoteDownload()
266{ 270{
267 int fsz; 271 int fsz;