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