-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 10 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.h | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 7c83223..db365ca 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -1,1516 +1,1520 @@ | |||
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 <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/mimetype.h> | 28 | #include <qpe/mimetype.h> |
29 | #include <qpe/qpemessagebox.h> | 29 | #include <qpe/qpemessagebox.h> |
30 | 30 | ||
31 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qtoolbutton.h> | 34 | #include <qtoolbutton.h> |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include <qdir.h> | 36 | #include <qdir.h> |
37 | #include <qfile.h> | 37 | #include <qfile.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qpopupmenu.h> | 40 | #include <qpopupmenu.h> |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | #include <qmainwindow.h> | 42 | #include <qmainwindow.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qprogressbar.h> | 44 | #include <qprogressbar.h> |
45 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
46 | #include <qtabwidget.h> | 46 | #include <qtabwidget.h> |
47 | #include <qwidget.h> | 47 | #include <qwidget.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qimage.h> | 49 | #include <qimage.h> |
50 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qlineedit.h> | 52 | #include <qlineedit.h> |
53 | #include <qregexp.h> | 53 | #include <qregexp.h> |
54 | #include <qlistbox.h> | 54 | #include <qlistbox.h> |
55 | 55 | ||
56 | #include <unistd.h> | 56 | #include <unistd.h> |
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | 58 | ||
59 | 59 | ||
60 | QProgressBar *ProgressBar; | 60 | QProgressBar *ProgressBar; |
61 | static netbuf *conn=NULL; | 61 | static netbuf *conn=NULL; |
62 | 62 | ||
63 | static int log_progress(netbuf *, int xfered, void *) | 63 | static int log_progress(netbuf *, int xfered, void *) |
64 | { | 64 | { |
65 | // int fsz = *(int *)arg; | 65 | // int fsz = *(int *)arg; |
66 | // int pct = (xfered * 100) / fsz; | 66 | // int pct = (xfered * 100) / fsz; |
67 | // printf("%3d%%\r", pct); | 67 | // printf("%3d%%\r", pct); |
68 | // fflush(stdout); | 68 | // fflush(stdout); |
69 | ProgressBar->setProgress(xfered); | 69 | ProgressBar->setProgress(xfered); |
70 | qApp->processEvents(); | 70 | qApp->processEvents(); |
71 | return 1; | 71 | return 1; |
72 | } | 72 | } |
73 | 73 | ||
74 | OpieFtp::OpieFtp( ) | 74 | OpieFtp::OpieFtp( ) |
75 | : QMainWindow( ) | 75 | : QMainWindow( ) |
76 | { | 76 | { |
77 | setCaption( tr( "OpieFtp" ) ); | 77 | setCaption( tr( "OpieFtp" ) ); |
78 | fuckeduphack=FALSE; | 78 | fuckeduphack=FALSE; |
79 | QGridLayout *layout = new QGridLayout( this ); | 79 | QGridLayout *layout = new QGridLayout( this ); |
80 | layout->setSpacing( 2); | 80 | layout->setSpacing( 2); |
81 | layout->setMargin( 2); | 81 | layout->setMargin( 2); |
82 | 82 | ||
83 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 83 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
84 | 84 | ||
85 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 85 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
86 | // QPEToolBar *menuBar = new QPEToolBar(this); | 86 | // QPEToolBar *menuBar = new QPEToolBar(this); |
87 | // menuBar->setHorizontalStretchable( TRUE ); | 87 | // menuBar->setHorizontalStretchable( TRUE ); |
88 | 88 | ||
89 | QWMatrix matrix; | ||
90 | QPixmap pix(Resource::loadPixmap( "UnknownDocument" )); | ||
91 | matrix.scale( .4, .4); | ||
92 | unknownXpm = pix.xForm(matrix); | ||
93 | |||
89 | connectionMenu = new QPopupMenu( this ); | 94 | connectionMenu = new QPopupMenu( this ); |
90 | localMenu = new QPopupMenu( this ); | 95 | localMenu = new QPopupMenu( this ); |
91 | remoteMenu = new QPopupMenu( this ); | 96 | remoteMenu = new QPopupMenu( this ); |
92 | tabMenu = new QPopupMenu( this ); | 97 | tabMenu = new QPopupMenu( this ); |
93 | 98 | ||
94 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); | 99 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); |
95 | 100 | ||
96 | menuBar->insertItem( tr( "Connection" ), connectionMenu); | 101 | menuBar->insertItem( tr( "Connection" ), connectionMenu); |
97 | menuBar->insertItem( tr( "Local" ), localMenu); | 102 | menuBar->insertItem( tr( "Local" ), localMenu); |
98 | menuBar->insertItem( tr( "Remote" ), remoteMenu); | 103 | menuBar->insertItem( tr( "Remote" ), remoteMenu); |
99 | menuBar->insertItem( tr( "View" ), tabMenu); | 104 | menuBar->insertItem( tr( "View" ), tabMenu); |
100 | 105 | ||
101 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 106 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
102 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 107 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
103 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 108 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
104 | 109 | ||
105 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 110 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
106 | localMenu->insertSeparator(); | 111 | localMenu->insertSeparator(); |
107 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 112 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
108 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 113 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
109 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 114 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
110 | localMenu->insertSeparator(); | 115 | localMenu->insertSeparator(); |
111 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 116 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
112 | localMenu->setCheckable(TRUE); | 117 | localMenu->setCheckable(TRUE); |
113 | 118 | ||
114 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 119 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
115 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 120 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
116 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 121 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
117 | remoteMenu->insertSeparator(); | 122 | remoteMenu->insertSeparator(); |
118 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 123 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
119 | 124 | ||
120 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 125 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
121 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 126 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
122 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); | 127 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); |
123 | tabMenu->insertSeparator(); | 128 | tabMenu->insertSeparator(); |
124 | tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 129 | tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
125 | tabMenu->setCheckable(TRUE); | 130 | tabMenu->setCheckable(TRUE); |
126 | 131 | ||
127 | 132 | ||
128 | 133 | ||
129 | cdUpButton = new QToolButton( this,"cdUpButton"); | 134 | cdUpButton = new QToolButton( this,"cdUpButton"); |
130 | cdUpButton->setPixmap(Resource::loadPixmap("up")); | 135 | cdUpButton->setPixmap(Resource::loadPixmap("up")); |
131 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); | 136 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); |
132 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 137 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
133 | layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); | 138 | layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); |
134 | cdUpButton->hide(); | 139 | cdUpButton->hide(); |
135 | 140 | ||
136 | // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 141 | // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
137 | // docButton->setFixedSize( QSize( 20, 20 ) ); | 142 | // docButton->setFixedSize( QSize( 20, 20 ) ); |
138 | // connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 143 | // connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
139 | // docButton->setFlat(TRUE); | 144 | // docButton->setFlat(TRUE); |
140 | // layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); | 145 | // layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
141 | 146 | ||
142 | homeButton = new QToolButton(this,"homeButton"); | 147 | homeButton = new QToolButton(this,"homeButton"); |
143 | homeButton->setPixmap( Resource::loadPixmap("home")); | 148 | homeButton->setPixmap( Resource::loadPixmap("home")); |
144 | homeButton->setFixedSize( QSize( 20, 20 ) ); | 149 | homeButton->setFixedSize( QSize( 20, 20 ) ); |
145 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 150 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
146 | layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); | 151 | layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); |
147 | homeButton->hide(); | 152 | homeButton->hide(); |
148 | 153 | ||
149 | TabWidget = new QTabWidget( this, "TabWidget" ); | 154 | TabWidget = new QTabWidget( this, "TabWidget" ); |
150 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); | 155 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); |
151 | 156 | ||
152 | // TabWidget->setTabShape(QTabWidget::Triangular); | 157 | // TabWidget->setTabShape(QTabWidget::Triangular); |
153 | 158 | ||
154 | tab = new QWidget( TabWidget, "tab" ); | 159 | tab = new QWidget( TabWidget, "tab" ); |
155 | tabLayout = new QGridLayout( tab ); | 160 | tabLayout = new QGridLayout( tab ); |
156 | tabLayout->setSpacing( 2); | 161 | tabLayout->setSpacing( 2); |
157 | tabLayout->setMargin( 2); | 162 | tabLayout->setMargin( 2); |
158 | 163 | ||
159 | Local_View = new QListView( tab, "Local_View" ); | 164 | Local_View = new QListView( tab, "Local_View" ); |
160 | // Local_View->setResizePolicy( QListView::AutoOneFit ); | 165 | // Local_View->setResizePolicy( QListView::AutoOneFit ); |
161 | Local_View->addColumn( tr("File"),150); | 166 | Local_View->addColumn( tr("File"),150); |
162 | Local_View->addColumn( tr("Date"),-1); | 167 | Local_View->addColumn( tr("Date"),-1); |
163 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 168 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
164 | Local_View->addColumn( tr("Size"),-1); | 169 | Local_View->addColumn( tr("Size"),-1); |
165 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 170 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
166 | Local_View->setAllColumnsShowFocus(TRUE); | 171 | Local_View->setAllColumnsShowFocus(TRUE); |
167 | 172 | ||
168 | Local_View->setMultiSelection( TRUE); | 173 | Local_View->setMultiSelection( TRUE); |
169 | Local_View->setSelectionMode(QListView::Extended); | 174 | Local_View->setSelectionMode(QListView::Extended); |
170 | Local_View->setFocusPolicy(QWidget::ClickFocus); | 175 | Local_View->setFocusPolicy(QWidget::ClickFocus); |
171 | 176 | ||
172 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 177 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
173 | 178 | ||
174 | tabLayout->addWidget( Local_View, 0, 0 ); | 179 | tabLayout->addWidget( Local_View, 0, 0 ); |
175 | 180 | ||
176 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 181 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
177 | this,SLOT( localListClicked(QListViewItem *)) ); | 182 | this,SLOT( localListClicked(QListViewItem *)) ); |
178 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), | 183 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), |
179 | // this,SLOT( localListClicked(QListViewItem *)) ); | 184 | // this,SLOT( localListClicked(QListViewItem *)) ); |
180 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 185 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
181 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 186 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
182 | 187 | ||
183 | TabWidget->insertTab( tab, tr( "Local" ) ); | 188 | TabWidget->insertTab( tab, tr( "Local" ) ); |
184 | 189 | ||
185 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 190 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
186 | tabLayout_2 = new QGridLayout( tab_2 ); | 191 | tabLayout_2 = new QGridLayout( tab_2 ); |
187 | tabLayout_2->setSpacing( 2); | 192 | tabLayout_2->setSpacing( 2); |
188 | tabLayout_2->setMargin( 2); | 193 | tabLayout_2->setMargin( 2); |
189 | 194 | ||
190 | Remote_View = new QListView( tab_2, "Remote_View" ); | 195 | Remote_View = new QListView( tab_2, "Remote_View" ); |
191 | Remote_View->addColumn( tr("File"),150); | 196 | Remote_View->addColumn( tr("File"),150); |
192 | Remote_View->addColumn( tr("Date"),-1); | 197 | Remote_View->addColumn( tr("Date"),-1); |
193 | // Remote_View->setColumnAlignment(1,QListView::AlignRight); | 198 | // Remote_View->setColumnAlignment(1,QListView::AlignRight); |
194 | Remote_View->addColumn( tr("Size"),-1); | 199 | Remote_View->addColumn( tr("Size"),-1); |
195 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 200 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
196 | Remote_View->setColumnAlignment(3,QListView::AlignCenter); | 201 | Remote_View->setColumnAlignment(3,QListView::AlignCenter); |
197 | Remote_View->addColumn( tr("Dir"),-1); | 202 | Remote_View->addColumn( tr("Dir"),-1); |
198 | Remote_View->setColumnAlignment(4,QListView::AlignRight); | 203 | Remote_View->setColumnAlignment(4,QListView::AlignRight); |
199 | Remote_View->setAllColumnsShowFocus(TRUE); | 204 | Remote_View->setAllColumnsShowFocus(TRUE); |
200 | 205 | ||
201 | Remote_View->setMultiSelection( FALSE); | 206 | Remote_View->setMultiSelection( FALSE); |
202 | Remote_View->setSelectionMode(QListView::Extended); | 207 | Remote_View->setSelectionMode(QListView::Extended); |
203 | Remote_View->setFocusPolicy(QWidget::ClickFocus); | 208 | Remote_View->setFocusPolicy(QWidget::ClickFocus); |
204 | 209 | ||
205 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 210 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
206 | 211 | ||
207 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 212 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
208 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 213 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
209 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 214 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
210 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 215 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
211 | 216 | ||
212 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 217 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
213 | 218 | ||
214 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); | 219 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); |
215 | 220 | ||
216 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 221 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
217 | tabLayout_3 = new QGridLayout( tab_3 ); | 222 | tabLayout_3 = new QGridLayout( tab_3 ); |
218 | tabLayout_3->setSpacing( 2); | 223 | tabLayout_3->setSpacing( 2); |
219 | tabLayout_3->setMargin( 2); | 224 | tabLayout_3->setMargin( 2); |
220 | 225 | ||
221 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); | 226 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); |
222 | TextLabel1->setText( tr( "Username" ) ); | 227 | TextLabel1->setText( tr( "Username" ) ); |
223 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); | 228 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); |
224 | 229 | ||
225 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); | 230 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); |
226 | UsernameComboBox->setEditable(TRUE); | 231 | UsernameComboBox->setEditable(TRUE); |
227 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); | 232 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); |
228 | 233 | ||
229 | connect( UsernameComboBox,SIGNAL(textChanged(const QString &)),this, | 234 | connect( UsernameComboBox,SIGNAL(textChanged(const QString &)),this, |
230 | SLOT( UsernameComboBoxEdited(const QString & ) )); | 235 | SLOT( UsernameComboBoxEdited(const QString & ) )); |
231 | 236 | ||
232 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 237 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
233 | TextLabel2->setText( tr( "Password" ) ); | 238 | TextLabel2->setText( tr( "Password" ) ); |
234 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); | 239 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); |
235 | 240 | ||
236 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); | 241 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); |
237 | PasswordEdit->setEchoMode(QLineEdit::Password); | 242 | PasswordEdit->setEchoMode(QLineEdit::Password); |
238 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); | 243 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); |
239 | 244 | ||
240 | connect( PasswordEdit,SIGNAL(textChanged(const QString &)),this, | 245 | connect( PasswordEdit,SIGNAL(textChanged(const QString &)),this, |
241 | SLOT( PasswordEditEdited(const QString & ) )); | 246 | SLOT( PasswordEditEdited(const QString & ) )); |
242 | 247 | ||
243 | //PasswordEdit->setFixedWidth(85); | 248 | //PasswordEdit->setFixedWidth(85); |
244 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); | 249 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); |
245 | TextLabel3->setText( tr( "Remote server" ) ); | 250 | TextLabel3->setText( tr( "Remote server" ) ); |
246 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); | 251 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); |
247 | 252 | ||
248 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); | 253 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); |
249 | ServerComboBox->setEditable(TRUE); | 254 | ServerComboBox->setEditable(TRUE); |
250 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); | 255 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); |
251 | 256 | ||
252 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); | 257 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); |
253 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this, | 258 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this, |
254 | SLOT(serverComboEdited(const QString & ) )); | 259 | SLOT(serverComboEdited(const QString & ) )); |
255 | 260 | ||
256 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); | 261 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); |
257 | TextLabel5->setText( tr( "Remote path" ) ); | 262 | TextLabel5->setText( tr( "Remote path" ) ); |
258 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); | 263 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); |
259 | 264 | ||
260 | 265 | ||
261 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 266 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
262 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | 267 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); |
263 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 268 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
264 | TextLabel4->setText( tr( "Port" ) ); | 269 | TextLabel4->setText( tr( "Port" ) ); |
265 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); | 270 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); |
266 | 271 | ||
267 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); | 272 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); |
268 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 273 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
269 | PortSpinBox->setMaxValue(32786); | 274 | PortSpinBox->setMaxValue(32786); |
270 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); | 275 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); |
271 | 276 | ||
272 | serverListView = new QListBox( tab_3, "ServerListView" ); | 277 | serverListView = new QListBox( tab_3, "ServerListView" ); |
273 | tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5); | 278 | tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5); |
274 | 279 | ||
275 | connect( serverListView, SIGNAL( highlighted( const QString &)), | 280 | connect( serverListView, SIGNAL( highlighted( const QString &)), |
276 | this,SLOT( serverListClicked( const QString &) ) ); | 281 | this,SLOT( serverListClicked( const QString &) ) ); |
277 | 282 | ||
278 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); | 283 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); |
279 | tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1); | 284 | tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1); |
280 | connectServerBtn->setToggleButton(TRUE); | 285 | connectServerBtn->setToggleButton(TRUE); |
281 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); | 286 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); |
282 | 287 | ||
283 | newServerButton= new QPushButton( "Add", tab_3 , "NewServerButton" ); | 288 | newServerButton= new QPushButton( "Add", tab_3 , "NewServerButton" ); |
284 | tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2); | 289 | tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2); |
285 | connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() )); | 290 | connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() )); |
286 | 291 | ||
287 | QPushButton *deleteServerBtn; | 292 | QPushButton *deleteServerBtn; |
288 | deleteServerBtn = new QPushButton( "Delete", tab_3 , "OpenButton" ); | 293 | deleteServerBtn = new QPushButton( "Delete", tab_3 , "OpenButton" ); |
289 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3); | 294 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3); |
290 | 295 | ||
291 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); | 296 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); |
292 | 297 | ||
293 | 298 | ||
294 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 299 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
295 | tabLayout_3->addItem( spacer, 5, 0 ); | 300 | tabLayout_3->addItem( spacer, 5, 0 ); |
296 | 301 | ||
297 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 302 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
298 | 303 | ||
299 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 304 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
300 | this,SLOT(tabChanged(QWidget*))); | 305 | this,SLOT(tabChanged(QWidget*))); |
301 | 306 | ||
302 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 307 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
303 | currentDir.setPath( QDir::currentDirPath()); | 308 | currentDir.setPath( QDir::currentDirPath()); |
304 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 309 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
305 | 310 | ||
306 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 311 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
307 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); | 312 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); |
308 | currentPathCombo ->setFixedWidth(220); | 313 | currentPathCombo ->setFixedWidth(220); |
309 | currentPathCombo->setEditable(TRUE); | 314 | currentPathCombo->setEditable(TRUE); |
310 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 315 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
311 | 316 | ||
312 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 317 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
313 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 318 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
314 | 319 | ||
315 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 320 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
316 | this,SLOT(currentPathComboChanged())); | 321 | this,SLOT(currentPathComboChanged())); |
317 | 322 | ||
318 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 323 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
319 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); | 324 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); |
320 | ProgressBar->setMaximumHeight(10); | 325 | ProgressBar->setMaximumHeight(10); |
321 | filterStr="*"; | 326 | filterStr="*"; |
322 | b=FALSE; | 327 | b=FALSE; |
323 | populateLocalView(); | 328 | populateLocalView(); |
324 | readConfig(); | 329 | readConfig(); |
325 | 330 | ||
326 | // ServerComboBox->setCurrentItem(currentServerConfig); | 331 | // ServerComboBox->setCurrentItem(currentServerConfig); |
327 | 332 | ||
328 | TabWidget->setCurrentPage(2); | 333 | TabWidget->setCurrentPage(2); |
329 | } | 334 | } |
330 | 335 | ||
331 | OpieFtp::~OpieFtp() | 336 | OpieFtp::~OpieFtp() |
332 | { | 337 | { |
333 | } | 338 | } |
334 | 339 | ||
335 | void OpieFtp::cleanUp() | 340 | void OpieFtp::cleanUp() |
336 | { | 341 | { |
337 | if(conn) | 342 | if(conn) |
338 | FtpQuit(conn); | 343 | FtpQuit(conn); |
339 | QString sfile=QDir::homeDirPath(); | 344 | QString sfile=QDir::homeDirPath(); |
340 | if(sfile.right(1) != "/") | 345 | if(sfile.right(1) != "/") |
341 | sfile+="/._temp"; | 346 | sfile+="/._temp"; |
342 | else | 347 | else |
343 | sfile+="._temp"; | 348 | sfile+="._temp"; |
344 | QFile file( sfile); | 349 | QFile file( sfile); |
345 | if(file.exists()) | 350 | if(file.exists()) |
346 | file.remove(); | 351 | file.remove(); |
347 | Config cfg("opieftp"); | 352 | Config cfg("opieftp"); |
348 | cfg.setGroup("Server"); | 353 | cfg.setGroup("Server"); |
349 | cfg.writeEntry("currentServer", currentServerConfig); | 354 | cfg.writeEntry("currentServer", currentServerConfig); |
350 | 355 | ||
351 | exit(0); | 356 | exit(0); |
352 | } | 357 | } |
353 | 358 | ||
354 | void OpieFtp::tabChanged(QWidget *) | 359 | void OpieFtp::tabChanged(QWidget *) |
355 | { | 360 | { |
356 | if (TabWidget->currentPageIndex() == 0) { | 361 | if (TabWidget->currentPageIndex() == 0) { |
357 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 362 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
358 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); | 363 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); |
359 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 364 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
360 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 365 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
361 | if(cdUpButton->isHidden()) | 366 | if(cdUpButton->isHidden()) |
362 | cdUpButton->show(); | 367 | cdUpButton->show(); |
363 | if(homeButton->isHidden()) | 368 | if(homeButton->isHidden()) |
364 | homeButton->show(); | 369 | homeButton->show(); |
365 | 370 | ||
366 | } | 371 | } |
367 | if (TabWidget->currentPageIndex() == 1) { | 372 | if (TabWidget->currentPageIndex() == 1) { |
368 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 373 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
369 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); | 374 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); |
370 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 375 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
371 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 376 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
372 | if(cdUpButton->isHidden()) | 377 | if(cdUpButton->isHidden()) |
373 | cdUpButton->show(); | 378 | cdUpButton->show(); |
374 | homeButton->hide(); | 379 | homeButton->hide(); |
375 | 380 | ||
376 | } | 381 | } |
377 | if (TabWidget->currentPageIndex() == 2) { | 382 | if (TabWidget->currentPageIndex() == 2) { |
378 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); | 383 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); |
379 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 384 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
380 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 385 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
381 | cdUpButton->hide(); | 386 | cdUpButton->hide(); |
382 | homeButton->hide(); | 387 | homeButton->hide(); |
383 | } | 388 | } |
384 | } | 389 | } |
385 | 390 | ||
386 | void OpieFtp::newConnection() | 391 | void OpieFtp::newConnection() |
387 | { | 392 | { |
388 | UsernameComboBox->lineEdit()->setText(""); | 393 | UsernameComboBox->lineEdit()->setText(""); |
389 | PasswordEdit->setText( "" ); | 394 | PasswordEdit->setText( "" ); |
390 | ServerComboBox->lineEdit()->setText( ""); | 395 | ServerComboBox->lineEdit()->setText( ""); |
391 | remotePath->setText( currentRemoteDir = "/"); | 396 | remotePath->setText( currentRemoteDir = "/"); |
392 | PortSpinBox->setValue( 21); | 397 | PortSpinBox->setValue( 21); |
393 | TabWidget->setCurrentPage(2); | 398 | TabWidget->setCurrentPage(2); |
394 | } | 399 | } |
395 | 400 | ||
396 | void OpieFtp::serverComboEdited(const QString & ) | 401 | void OpieFtp::serverComboEdited(const QString & ) |
397 | { | 402 | { |
398 | // if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { | 403 | // if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { |
399 | // qDebug("ServerComboEdited"); | 404 | // qDebug("ServerComboEdited"); |
400 | // // currentServerConfig = -1; | 405 | // // currentServerConfig = -1; |
401 | // } | 406 | // } |
402 | } | 407 | } |
403 | 408 | ||
404 | void OpieFtp::UsernameComboBoxEdited(const QString &) { | 409 | void OpieFtp::UsernameComboBoxEdited(const QString &) { |
405 | // currentServerConfig = -1; | 410 | // currentServerConfig = -1; |
406 | } | 411 | } |
407 | 412 | ||
408 | void OpieFtp::PasswordEditEdited(const QString & ) { | 413 | void OpieFtp::PasswordEditEdited(const QString & ) { |
409 | // currentServerConfig = -1; | 414 | // currentServerConfig = -1; |
410 | } | 415 | } |
411 | 416 | ||
412 | void OpieFtp::connectorBtnToggled(bool On) | 417 | void OpieFtp::connectorBtnToggled(bool On) |
413 | { | 418 | { |
414 | if(On) { | 419 | if(On) { |
415 | connector(); | 420 | connector(); |
416 | } else { | 421 | } else { |
417 | disConnector(); | 422 | disConnector(); |
418 | } | 423 | } |
419 | 424 | ||
420 | } | 425 | } |
421 | 426 | ||
422 | void OpieFtp::connector() | 427 | void OpieFtp::connector() |
423 | { | 428 | { |
424 | // QCopEnvelope ( "QPE/System", "busy()" ); | 429 | // QCopEnvelope ( "QPE/System", "busy()" ); |
425 | // qApp->processEvents(); | 430 | // qApp->processEvents(); |
426 | currentRemoteDir=remotePath->text(); | 431 | currentRemoteDir=remotePath->text(); |
427 | 432 | ||
428 | if( ServerComboBox->currentText().isEmpty()) { | 433 | if( ServerComboBox->currentText().isEmpty()) { |
429 | 434 | ||
430 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); | 435 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); |
431 | TabWidget->setCurrentPage(2); | 436 | TabWidget->setCurrentPage(2); |
432 | ServerComboBox->setFocus(); | 437 | ServerComboBox->setFocus(); |
433 | connectServerBtn->setOn(FALSE); | 438 | connectServerBtn->setOn(FALSE); |
434 | connectServerBtn->setText( tr("Connect")); | 439 | connectServerBtn->setText( tr("Connect")); |
435 | return; | 440 | return; |
436 | } | 441 | } |
437 | 442 | ||
438 | FtpInit(); | 443 | FtpInit(); |
439 | 444 | ||
440 | TabWidget->setCurrentPage(1); | 445 | TabWidget->setCurrentPage(1); |
441 | QString ftp_host = ServerComboBox->currentText(); | 446 | QString ftp_host = ServerComboBox->currentText(); |
442 | QString ftp_user = UsernameComboBox->currentText(); | 447 | QString ftp_user = UsernameComboBox->currentText(); |
443 | QString ftp_pass = PasswordEdit->text(); | 448 | QString ftp_pass = PasswordEdit->text(); |
444 | QString port=PortSpinBox->cleanText(); | 449 | QString port=PortSpinBox->cleanText(); |
445 | port.stripWhiteSpace(); | 450 | port.stripWhiteSpace(); |
446 | 451 | ||
447 | Config cfg("opieftp"); | 452 | Config cfg("opieftp"); |
448 | cfg.setGroup("Server"); | 453 | cfg.setGroup("Server"); |
449 | // int current=cfg.readNumEntry("currentServer", 1); | 454 | // int current=cfg.readNumEntry("currentServer", 1); |
450 | 455 | ||
451 | // if(ftp_host!= cfg.readEntry(QString::number( current))) | 456 | // if(ftp_host!= cfg.readEntry(QString::number( current))) |
452 | // currentServerConfig=-1; | 457 | // currentServerConfig=-1; |
453 | // cfg.setGroup(QString::number(current)); | 458 | // cfg.setGroup(QString::number(current)); |
454 | // if( ftp_user != cfg.readEntry("Username")) | 459 | // if( ftp_user != cfg.readEntry("Username")) |
455 | // currentServerConfig=-1; | 460 | // currentServerConfig=-1; |
456 | // if(ftp_pass != cfg.readEntry(cfg.readEntry("Username"))) | 461 | // if(ftp_pass != cfg.readEntry(cfg.readEntry("Username"))) |
457 | // currentServerConfig=-1; | 462 | // currentServerConfig=-1; |
458 | 463 | ||
459 | 464 | ||
460 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) | 465 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) |
461 | ftp_host=ftp_host.right(ftp_host.length()-6); | 466 | ftp_host=ftp_host.right(ftp_host.length()-6); |
462 | ftp_host+=":"+port; | 467 | ftp_host+=":"+port; |
463 | 468 | ||
464 | if (!FtpConnect( ftp_host.latin1(), &conn)) { | 469 | if (!FtpConnect( ftp_host.latin1(), &conn)) { |
465 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); | 470 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); |
466 | connectServerBtn->setOn(FALSE); | 471 | connectServerBtn->setOn(FALSE); |
467 | connectServerBtn->setText( tr("Connect")); | 472 | connectServerBtn->setText( tr("Connect")); |
468 | return ; | 473 | return ; |
469 | } | 474 | } |
470 | 475 | ||
471 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { | 476 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { |
472 | QString msg; | 477 | QString msg; |
473 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); | 478 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); |
474 | msg.replace(QRegExp(":"),"\n"); | 479 | msg.replace(QRegExp(":"),"\n"); |
475 | QMessageBox::message(tr("Note"),msg); | 480 | QMessageBox::message(tr("Note"),msg); |
476 | if(conn) | 481 | if(conn) |
477 | FtpQuit(conn); | 482 | FtpQuit(conn); |
478 | connectServerBtn->setOn(FALSE); | 483 | connectServerBtn->setOn(FALSE); |
479 | connectServerBtn->setText( tr("Connect")); | 484 | connectServerBtn->setText( tr("Connect")); |
480 | return ; | 485 | return ; |
481 | } | 486 | } |
482 | 487 | ||
483 | remoteDirList("/") ; | 488 | remoteDirList("/") ; |
484 | setCaption(ftp_host); | 489 | setCaption(ftp_host); |
485 | if( currentServerConfig == -1) | 490 | if( currentServerConfig == -1) |
486 | writeConfig(); | 491 | writeConfig(); |
487 | connectServerBtn->setText( tr("Disconnect")); | 492 | connectServerBtn->setText( tr("Disconnect")); |
488 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 493 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
489 | } | 494 | } |
490 | 495 | ||
491 | void OpieFtp::disConnector() | 496 | void OpieFtp::disConnector() |
492 | { | 497 | { |
493 | if(conn) | 498 | if(conn) |
494 | FtpQuit(conn); | 499 | FtpQuit(conn); |
495 | setCaption("OpieFtp"); | 500 | setCaption("OpieFtp"); |
496 | currentRemoteDir="/"; | 501 | currentRemoteDir="/"; |
497 | Remote_View->clear(); | 502 | Remote_View->clear(); |
498 | connectServerBtn->setText( tr("Connect")); | 503 | connectServerBtn->setText( tr("Connect")); |
499 | connectServerBtn->setOn(FALSE); | 504 | connectServerBtn->setOn(FALSE); |
500 | setCaption("OpieFtp"); | 505 | setCaption("OpieFtp"); |
501 | } | 506 | } |
502 | 507 | ||
503 | void OpieFtp::localUpload() | 508 | void OpieFtp::localUpload() |
504 | { | 509 | { |
505 | int fsz; | 510 | int fsz; |
506 | // QCopEnvelope ( "QPE/System", "busy()" ); | 511 | // QCopEnvelope ( "QPE/System", "busy()" ); |
507 | // qApp->processEvents(); | 512 | // qApp->processEvents(); |
508 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 513 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
509 | QListViewItemIterator it( Local_View ); | 514 | QListViewItemIterator it( Local_View ); |
510 | for ( ; it.current(); ++it ) { | 515 | for ( ; it.current(); ++it ) { |
511 | if ( it.current()->isSelected() ) { | 516 | if ( it.current()->isSelected() ) { |
512 | QString strItem = it.current()->text(0); | 517 | QString strItem = it.current()->text(0); |
513 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 518 | QString localFile = currentDir.canonicalPath()+"/"+strItem; |
514 | QString remoteFile= currentRemoteDir+strItem; | 519 | QString remoteFile= currentRemoteDir+strItem; |
515 | QFileInfo fi(localFile); | 520 | QFileInfo fi(localFile); |
516 | if( !fi.isDir()) { | 521 | if( !fi.isDir()) { |
517 | fsz=fi.size(); | 522 | fsz=fi.size(); |
518 | ProgressBar->setTotalSteps(fsz); | 523 | ProgressBar->setTotalSteps(fsz); |
519 | 524 | ||
520 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 525 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
521 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 526 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
522 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 527 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
523 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 528 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
524 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); | 529 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); |
525 | 530 | ||
526 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 531 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
527 | QString msg; | 532 | QString msg; |
528 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); | 533 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); |
529 | msg.replace(QRegExp(":"),"\n"); | 534 | msg.replace(QRegExp(":"),"\n"); |
530 | QMessageBox::message(tr("Note"),msg); | 535 | QMessageBox::message(tr("Note"),msg); |
531 | } | 536 | } |
532 | } else { | 537 | } else { |
533 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); | 538 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); |
534 | } | 539 | } |
535 | ProgressBar->reset(); | 540 | ProgressBar->reset(); |
536 | nullifyCallBack(); | 541 | nullifyCallBack(); |
537 | it.current()->setSelected(FALSE); | 542 | it.current()->setSelected(FALSE); |
538 | } //end currentSelected | 543 | } //end currentSelected |
539 | } | 544 | } |
540 | for ( ; it.current(); ++it ) { | 545 | for ( ; it.current(); ++it ) { |
541 | Local_View->clearSelection(); | 546 | Local_View->clearSelection(); |
542 | } | 547 | } |
543 | Local_View->clearFocus(); | 548 | Local_View->clearFocus(); |
544 | TabWidget->setCurrentPage(1); | 549 | TabWidget->setCurrentPage(1); |
545 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 550 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
546 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 551 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
547 | } | 552 | } |
548 | 553 | ||
549 | void OpieFtp::nullifyCallBack() | 554 | void OpieFtp::nullifyCallBack() |
550 | { | 555 | { |
551 | FtpOptions(FTPLIB_CALLBACK, 0, conn); | 556 | FtpOptions(FTPLIB_CALLBACK, 0, conn); |
552 | FtpOptions(FTPLIB_IDLETIME, 0, conn); | 557 | FtpOptions(FTPLIB_IDLETIME, 0, conn); |
553 | FtpOptions(FTPLIB_CALLBACKARG, 0, conn); | 558 | FtpOptions(FTPLIB_CALLBACKARG, 0, conn); |
554 | FtpOptions(FTPLIB_CALLBACKBYTES, 0, conn); | 559 | FtpOptions(FTPLIB_CALLBACKBYTES, 0, conn); |
555 | } | 560 | } |
556 | 561 | ||
557 | void OpieFtp::remoteDownload() | 562 | void OpieFtp::remoteDownload() |
558 | { | 563 | { |
559 | // qApp->processEvents(); | 564 | // qApp->processEvents(); |
560 | int fsz; | 565 | int fsz; |
561 | // QCopEnvelope ( "QPE/System", "busy()" ); | 566 | // QCopEnvelope ( "QPE/System", "busy()" ); |
562 | 567 | ||
563 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 568 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
564 | QListViewItemIterator it( Remote_View ); | 569 | QListViewItemIterator it( Remote_View ); |
565 | for ( ; it.current(); ++it ) { | 570 | for ( ; it.current(); ++it ) { |
566 | if ( it.current()->isSelected() ) { | 571 | if ( it.current()->isSelected() ) { |
567 | QString strItem = it.current()->text(0); | 572 | QString strItem = it.current()->text(0); |
568 | // strItem=strItem.right(strItem.length()-1); | 573 | // strItem=strItem.right(strItem.length()-1); |
569 | QString localFile = currentDir.canonicalPath(); | 574 | QString localFile = currentDir.canonicalPath(); |
570 | if(localFile.right(1).find("/",0,TRUE) == -1) | 575 | if(localFile.right(1).find("/",0,TRUE) == -1) |
571 | localFile += "/"; | 576 | localFile += "/"; |
572 | localFile += strItem; | 577 | localFile += strItem; |
573 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | 578 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; |
574 | QString remoteFile= currentRemoteDir+strItem; | 579 | QString remoteFile= currentRemoteDir+strItem; |
575 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 580 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
576 | fsz = 0; | 581 | fsz = 0; |
577 | QString temp; | 582 | QString temp; |
578 | temp.sprintf( remoteFile+" "+" %dkb", fsz); | 583 | temp.sprintf( remoteFile+" "+" %dkb", fsz); |
579 | 584 | ||
580 | ProgressBar->setTotalSteps(fsz); | 585 | ProgressBar->setTotalSteps(fsz); |
581 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 586 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
582 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 587 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
583 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 588 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
584 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 589 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
585 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); | 590 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); |
586 | 591 | ||
587 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 592 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
588 | QString msg; | 593 | QString msg; |
589 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); | 594 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); |
590 | msg.replace(QRegExp(":"),"\n"); | 595 | msg.replace(QRegExp(":"),"\n"); |
591 | QMessageBox::message(tr("Note"),msg); | 596 | QMessageBox::message(tr("Note"),msg); |
592 | } | 597 | } |
593 | ProgressBar->reset(); | 598 | ProgressBar->reset(); |
594 | nullifyCallBack(); | 599 | nullifyCallBack(); |
595 | it.current()->setSelected(FALSE); | 600 | it.current()->setSelected(FALSE); |
596 | } | 601 | } |
597 | } | 602 | } |
598 | for ( ; it.current(); ++it ) { | 603 | for ( ; it.current(); ++it ) { |
599 | Remote_View->clearSelection(); | 604 | Remote_View->clearSelection(); |
600 | } | 605 | } |
601 | Remote_View->setFocus(); | 606 | Remote_View->setFocus(); |
602 | TabWidget->setCurrentPage(0); | 607 | TabWidget->setCurrentPage(0); |
603 | populateLocalView(); | 608 | populateLocalView(); |
604 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 609 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
605 | } | 610 | } |
606 | 611 | ||
607 | bool OpieFtp::remoteDirList(const QString &dir) | 612 | bool OpieFtp::remoteDirList(const QString &dir) |
608 | { | 613 | { |
609 | QString tmp = QDir::homeDirPath(); | 614 | QString tmp = QDir::homeDirPath(); |
610 | if(tmp.right(1) != "/") | 615 | if(tmp.right(1) != "/") |
611 | tmp+="/._temp"; | 616 | tmp+="/._temp"; |
612 | else | 617 | else |
613 | tmp+="._temp"; | 618 | tmp+="._temp"; |
614 | // qDebug("Listing remote dir "+tmp); | 619 | // qDebug("Listing remote dir "+tmp); |
615 | // QCopEnvelope ( "QPE/System", "busy()" ); | 620 | // QCopEnvelope ( "QPE/System", "busy()" ); |
616 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { | 621 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { |
617 | QString msg; | 622 | QString msg; |
618 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); | 623 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); |
619 | msg.replace(QRegExp(":"),"\n"); | 624 | msg.replace(QRegExp(":"),"\n"); |
620 | QMessageBox::message(tr("Note"),msg); | 625 | QMessageBox::message(tr("Note"),msg); |
621 | return false; | 626 | return false; |
622 | } | 627 | } |
623 | populateRemoteView() ; | 628 | populateRemoteView() ; |
624 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 629 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
625 | return true; | 630 | return true; |
626 | } | 631 | } |
627 | 632 | ||
628 | bool OpieFtp::remoteChDir(const QString &dir) | 633 | bool OpieFtp::remoteChDir(const QString &dir) |
629 | { | 634 | { |
630 | // QCopEnvelope ( "QPE/System", "busy()" ); | 635 | // QCopEnvelope ( "QPE/System", "busy()" ); |
631 | if (!FtpChdir( dir.latin1(), conn )) { | 636 | if (!FtpChdir( dir.latin1(), conn )) { |
632 | QString msg; | 637 | QString msg; |
633 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); | 638 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); |
634 | msg.replace(QRegExp(":"),"\n"); | 639 | msg.replace(QRegExp(":"),"\n"); |
635 | QMessageBox::message(tr("Note"),msg); | 640 | QMessageBox::message(tr("Note"),msg); |
636 | // qDebug(msg); | 641 | // qDebug(msg); |
637 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 642 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
638 | return FALSE; | 643 | return FALSE; |
639 | } | 644 | } |
640 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 645 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
641 | return TRUE; | 646 | return TRUE; |
642 | } | 647 | } |
643 | 648 | ||
644 | void OpieFtp::populateLocalView() | 649 | void OpieFtp::populateLocalView() |
645 | { | 650 | { |
646 | Local_View->clear(); | 651 | Local_View->clear(); |
647 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 652 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
648 | currentDir.setMatchAllDirs(TRUE); | 653 | currentDir.setMatchAllDirs(TRUE); |
649 | currentDir.setNameFilter(filterStr); | 654 | currentDir.setNameFilter(filterStr); |
650 | QString fileL, fileS, fileDate; | 655 | QString fileL, fileS, fileDate; |
651 | bool isDir=FALSE; | 656 | bool isDir=FALSE; |
652 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 657 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
653 | QFileInfoListIterator it(*list); | 658 | QFileInfoListIterator it(*list); |
654 | QFileInfo *fi; | 659 | QFileInfo *fi; |
655 | while ( (fi=it.current()) ) { | 660 | while ( (fi=it.current()) ) { |
656 | if (fi->isSymLink() ){ | 661 | if (fi->isSymLink() ){ |
657 | QString symLink=fi->readLink(); | 662 | QString symLink=fi->readLink(); |
658 | // qDebug("Symlink detected "+symLink); | 663 | // qDebug("Symlink detected "+symLink); |
659 | QFileInfo sym( symLink); | 664 | QFileInfo sym( symLink); |
660 | fileS.sprintf( "%10i", sym.size() ); | 665 | fileS.sprintf( "%10i", sym.size() ); |
661 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 666 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
662 | fileDate = sym.lastModified().toString(); | 667 | fileDate = sym.lastModified().toString(); |
663 | } else { | 668 | } else { |
664 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 669 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
665 | fileS.sprintf( "%10i", fi->size() ); | 670 | fileS.sprintf( "%10i", fi->size() ); |
666 | fileL.sprintf( "%s",fi->fileName().data() ); | 671 | fileL.sprintf( "%s",fi->fileName().data() ); |
667 | fileDate= fi->lastModified().toString(); | 672 | fileDate= fi->lastModified().toString(); |
668 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 673 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
669 | fileL+="/"; | 674 | fileL+="/"; |
670 | isDir=TRUE; | 675 | isDir=TRUE; |
671 | // qDebug( fileL); | 676 | // qDebug( fileL); |
672 | } | 677 | } |
673 | } | 678 | } |
674 | if(fileL !="./" && fi->exists()) { | 679 | if(fileL !="./" && fi->exists()) { |
675 | item = new QListViewItem( Local_View,fileL, fileDate, fileS ); | 680 | item = new QListViewItem( Local_View,fileL, fileDate, fileS ); |
676 | QPixmap pm; | 681 | QPixmap pm; |
677 | 682 | ||
678 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 683 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
679 | if( !QDir( fi->filePath() ).isReadable()) | 684 | if( !QDir( fi->filePath() ).isReadable()) |
680 | pm = Resource::loadPixmap( "lockedfolder" ); | 685 | pm = Resource::loadPixmap( "lockedfolder" ); |
681 | else | 686 | else |
682 | pm= Resource::loadPixmap( "folder" ); | 687 | pm= Resource::loadPixmap( "folder" ); |
683 | item->setPixmap( 0,pm ); | 688 | item->setPixmap( 0,pm ); |
684 | } else { | 689 | } else { |
685 | if( !fi->isReadable() ) | 690 | if( !fi->isReadable() ) |
686 | pm = Resource::loadPixmap( "locked" ); | 691 | pm = Resource::loadPixmap( "locked" ); |
687 | else { | 692 | else { |
688 | MimeType mt(fi->filePath()); | 693 | MimeType mt(fi->filePath()); |
689 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 694 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
690 | if(pm.isNull()) | 695 | if(pm.isNull()) |
691 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 696 | pm = unknownXpm; |
692 | item->setPixmap( 0,pm); | ||
693 | } | 697 | } |
694 | } | 698 | } |
695 | if( fileL.find("->",0,TRUE) != -1) { | 699 | if( fileL.find("->",0,TRUE) != -1) { |
696 | // overlay link image | 700 | // overlay link image |
697 | pm= Resource::loadPixmap( "folder" ); | 701 | pm= Resource::loadPixmap( "folder" ); |
698 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 702 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
699 | QPainter painter( &pm ); | 703 | QPainter painter( &pm ); |
700 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 704 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
701 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 705 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
702 | item->setPixmap( 0, pm); | ||
703 | } | 706 | } |
707 | item->setPixmap( 0,pm); | ||
704 | } | 708 | } |
705 | isDir=FALSE; | 709 | isDir=FALSE; |
706 | ++it; | 710 | ++it; |
707 | } | 711 | } |
708 | Local_View->setSorting( 3,FALSE); | 712 | Local_View->setSorting( 3,FALSE); |
709 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); | 713 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); |
710 | fillCombo( (const QString &)currentDir); | 714 | fillCombo( (const QString &)currentDir); |
711 | } | 715 | } |
712 | 716 | ||
713 | bool OpieFtp::populateRemoteView( ) | 717 | bool OpieFtp::populateRemoteView( ) |
714 | { | 718 | { |
715 | // qDebug("populate remoteview"); | 719 | // qDebug("populate remoteview"); |
716 | QString sfile=QDir::homeDirPath(); | 720 | QString sfile=QDir::homeDirPath(); |
717 | if(sfile.right(1) != "/") | 721 | if(sfile.right(1) != "/") |
718 | sfile+="/._temp"; | 722 | sfile+="/._temp"; |
719 | else | 723 | else |
720 | sfile+="._temp"; | 724 | sfile+="._temp"; |
721 | QFile file( sfile); | 725 | QFile file( sfile); |
722 | Remote_View->clear(); | 726 | Remote_View->clear(); |
723 | QString s, File_Name; | 727 | QString s, File_Name; |
724 | QListViewItem *itemDir=NULL, *itemFile=NULL; | 728 | QListViewItem *itemDir=NULL, *itemFile=NULL; |
725 | QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); | 729 | QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); |
726 | QString fileL, fileS, fileDate; | 730 | QString fileL, fileS, fileDate; |
727 | if ( file.open(IO_ReadOnly)) { | 731 | if ( file.open(IO_ReadOnly)) { |
728 | QTextStream t( &file ); // use a text stream | 732 | QTextStream t( &file ); // use a text stream |
729 | while ( !t.eof()) { | 733 | while ( !t.eof()) { |
730 | s = t.readLine(); | 734 | s = t.readLine(); |
731 | 735 | ||
732 | if(s.find("total",0,TRUE) == 0) | 736 | if(s.find("total",0,TRUE) == 0) |
733 | continue; | 737 | continue; |
734 | 738 | ||
735 | int len, month = monthRe.match(s, 0, &len); | 739 | int len, month = monthRe.match(s, 0, &len); |
736 | fileDate = s.mid(month + 1, len - 2); // minus spaces | 740 | fileDate = s.mid(month + 1, len - 2); // minus spaces |
737 | fileL = s.right(s.length() - month - len); | 741 | fileL = s.right(s.length() - month - len); |
738 | if(s.left(1) == "d") | 742 | if(s.left(1) == "d") |
739 | fileL = fileL+"/"; | 743 | fileL = fileL+"/"; |
740 | fileS = s.mid(month - 8, 8); // FIXME | 744 | fileS = s.mid(month - 8, 8); // FIXME |
741 | fileS = fileS.stripWhiteSpace(); | 745 | fileS = fileS.stripWhiteSpace(); |
742 | 746 | ||
743 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { | 747 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { |
744 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); | 748 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); |
745 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 749 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
746 | // if(itemDir) | 750 | // if(itemDir) |
747 | item->moveItem(itemDir); | 751 | item->moveItem(itemDir); |
748 | itemDir=item; | 752 | itemDir=item; |
749 | } else { | 753 | } else { |
750 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); | 754 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); |
751 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 755 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
752 | // if(itemFile) | 756 | // if(itemFile) |
753 | item->moveItem(itemDir); | 757 | item->moveItem(itemDir); |
754 | item->moveItem(itemFile); | 758 | item->moveItem(itemFile); |
755 | itemFile=item; | 759 | itemFile=item; |
756 | } | 760 | } |
757 | } | 761 | } |
758 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 762 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
759 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 763 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
760 | file.close(); | 764 | file.close(); |
761 | if( file.exists()) | 765 | if( file.exists()) |
762 | file. remove(); | 766 | file. remove(); |
763 | } else | 767 | } else |
764 | qDebug("temp file not opened successfullly "+sfile); | 768 | qDebug("temp file not opened successfullly "+sfile); |
765 | Remote_View->setSorting( 4,TRUE); | 769 | Remote_View->setSorting( 4,TRUE); |
766 | return true; | 770 | return true; |
767 | } | 771 | } |
768 | 772 | ||
769 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 773 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
770 | { | 774 | { |
771 | if( selectedItem) { | 775 | if( selectedItem) { |
772 | // QCopEnvelope ( "QPE/System", "busy()" ); | 776 | // QCopEnvelope ( "QPE/System", "busy()" ); |
773 | QString oldRemoteCurrentDir = currentRemoteDir; | 777 | QString oldRemoteCurrentDir = currentRemoteDir; |
774 | QString strItem=selectedItem->text(0); | 778 | QString strItem=selectedItem->text(0); |
775 | strItem=strItem.simplifyWhiteSpace(); | 779 | strItem=strItem.simplifyWhiteSpace(); |
776 | if(strItem == "../") { // the user wants to go ^ | 780 | if(strItem == "../") { // the user wants to go ^ |
777 | if( FtpCDUp( conn) == 0) { | 781 | if( FtpCDUp( conn) == 0) { |
778 | QString msg; | 782 | QString msg; |
779 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 783 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
780 | msg.replace(QRegExp(":"),"\n"); | 784 | msg.replace(QRegExp(":"),"\n"); |
781 | QMessageBox::message(tr("Note"),msg); | 785 | QMessageBox::message(tr("Note"),msg); |
782 | // qDebug(msg); | 786 | // qDebug(msg); |
783 | } | 787 | } |
784 | char path[256]; | 788 | char path[256]; |
785 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 789 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
786 | QString msg; | 790 | QString msg; |
787 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 791 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
788 | msg.replace(QRegExp(":"),"\n"); | 792 | msg.replace(QRegExp(":"),"\n"); |
789 | QMessageBox::message(tr("Note"),msg); | 793 | QMessageBox::message(tr("Note"),msg); |
790 | // qDebug(msg); | 794 | // qDebug(msg); |
791 | } | 795 | } |
792 | currentRemoteDir=path; | 796 | currentRemoteDir=path; |
793 | } else { | 797 | } else { |
794 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 798 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
795 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 799 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
796 | strItem = strItem.stripWhiteSpace(); | 800 | strItem = strItem.stripWhiteSpace(); |
797 | currentRemoteDir = strItem; | 801 | currentRemoteDir = strItem; |
798 | if( !remoteChDir( (const QString &)strItem)) { | 802 | if( !remoteChDir( (const QString &)strItem)) { |
799 | currentRemoteDir = oldRemoteCurrentDir; | 803 | currentRemoteDir = oldRemoteCurrentDir; |
800 | strItem=""; | 804 | strItem=""; |
801 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 805 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
802 | } | 806 | } |
803 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 807 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
804 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 808 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
805 | currentRemoteDir = oldRemoteCurrentDir; | 809 | currentRemoteDir = oldRemoteCurrentDir; |
806 | strItem=""; | 810 | strItem=""; |
807 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 811 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
808 | 812 | ||
809 | } else { | 813 | } else { |
810 | currentRemoteDir = currentRemoteDir+strItem; | 814 | currentRemoteDir = currentRemoteDir+strItem; |
811 | } | 815 | } |
812 | } else { | 816 | } else { |
813 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 817 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
814 | return; | 818 | return; |
815 | } | 819 | } |
816 | } | 820 | } |
817 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 821 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
818 | if(currentRemoteDir.right(1) !="/") | 822 | if(currentRemoteDir.right(1) !="/") |
819 | currentRemoteDir +="/"; | 823 | currentRemoteDir +="/"; |
820 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 824 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
821 | fillRemoteCombo( (const QString &)currentRemoteDir); | 825 | fillRemoteCombo( (const QString &)currentRemoteDir); |
822 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 826 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
823 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | 827 | Remote_View->ensureItemVisible(Remote_View->firstChild()); |
824 | 828 | ||
825 | } | 829 | } |
826 | } | 830 | } |
827 | 831 | ||
828 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 832 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
829 | { | 833 | { |
830 | if(selectedItem!= NULL) { | 834 | if(selectedItem!= NULL) { |
831 | 835 | ||
832 | QString strItem=selectedItem->text(0); | 836 | QString strItem=selectedItem->text(0); |
833 | QString strSize=selectedItem->text(1); | 837 | QString strSize=selectedItem->text(1); |
834 | strSize=strSize.stripWhiteSpace(); | 838 | strSize=strSize.stripWhiteSpace(); |
835 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 839 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
836 | // is symlink | 840 | // is symlink |
837 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 841 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
838 | if(QDir(strItem2).exists() ) { | 842 | if(QDir(strItem2).exists() ) { |
839 | currentDir.cd(strItem2, TRUE); | 843 | currentDir.cd(strItem2, TRUE); |
840 | populateLocalView(); | 844 | populateLocalView(); |
841 | } | 845 | } |
842 | } else { // not a symlink | 846 | } else { // not a symlink |
843 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 847 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
844 | 848 | ||
845 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 849 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
846 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 850 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
847 | currentDir.cd(strItem,FALSE); | 851 | currentDir.cd(strItem,FALSE); |
848 | populateLocalView(); | 852 | populateLocalView(); |
849 | } else { | 853 | } else { |
850 | currentDir.cdUp(); | 854 | currentDir.cdUp(); |
851 | populateLocalView(); | 855 | populateLocalView(); |
852 | } | 856 | } |
853 | if(QDir(strItem).exists()){ | 857 | if(QDir(strItem).exists()){ |
854 | currentDir.cd(strItem, TRUE); | 858 | currentDir.cd(strItem, TRUE); |
855 | populateLocalView(); | 859 | populateLocalView(); |
856 | } | 860 | } |
857 | } else { | 861 | } else { |
858 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 862 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
859 | if( QFile::exists(strItem ) ) { | 863 | if( QFile::exists(strItem ) ) { |
860 | // qDebug("upload "+strItem); | 864 | // qDebug("upload "+strItem); |
861 | return; | 865 | return; |
862 | } | 866 | } |
863 | } //end not symlink | 867 | } //end not symlink |
864 | chdir(strItem.latin1()); | 868 | chdir(strItem.latin1()); |
865 | } | 869 | } |
866 | Local_View->ensureItemVisible(Local_View->firstChild()); | 870 | Local_View->ensureItemVisible(Local_View->firstChild()); |
867 | } | 871 | } |
868 | } | 872 | } |
869 | 873 | ||
870 | void OpieFtp::doLocalCd() | 874 | void OpieFtp::doLocalCd() |
871 | { | 875 | { |
872 | localListClicked( Local_View->currentItem()); | 876 | localListClicked( Local_View->currentItem()); |
873 | } | 877 | } |
874 | 878 | ||
875 | void OpieFtp:: doRemoteCd() | 879 | void OpieFtp:: doRemoteCd() |
876 | { | 880 | { |
877 | remoteListClicked( Remote_View->currentItem()); | 881 | remoteListClicked( Remote_View->currentItem()); |
878 | 882 | ||
879 | } | 883 | } |
880 | 884 | ||
881 | void OpieFtp::showHidden() | 885 | void OpieFtp::showHidden() |
882 | { | 886 | { |
883 | if (!b) { | 887 | if (!b) { |
884 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 888 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
885 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 889 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
886 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 890 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
887 | b=TRUE; | 891 | b=TRUE; |
888 | 892 | ||
889 | } else { | 893 | } else { |
890 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 894 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
891 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 895 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
892 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 896 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
893 | b=FALSE; | 897 | b=FALSE; |
894 | } | 898 | } |
895 | populateLocalView(); | 899 | populateLocalView(); |
896 | } | 900 | } |
897 | 901 | ||
898 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &, int) | 902 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &, int) |
899 | { | 903 | { |
900 | // if(item) | 904 | // if(item) |
901 | if (mouse == 2) { | 905 | if (mouse == 2) { |
902 | showLocalMenu(item); | 906 | showLocalMenu(item); |
903 | } | 907 | } |
904 | } | 908 | } |
905 | 909 | ||
906 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &, int ) | 910 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &, int ) |
907 | { | 911 | { |
908 | if(mouse == 2) { | 912 | if(mouse == 2) { |
909 | showRemoteMenu(item); | 913 | showRemoteMenu(item); |
910 | } | 914 | } |
911 | } | 915 | } |
912 | 916 | ||
913 | void OpieFtp::showRemoteMenu(QListViewItem * item) | 917 | void OpieFtp::showRemoteMenu(QListViewItem * item) |
914 | { | 918 | { |
915 | QPopupMenu * m;// = new QPopupMenu( Local_View ); | 919 | QPopupMenu * m;// = new QPopupMenu( Local_View ); |
916 | m = new QPopupMenu(this); | 920 | m = new QPopupMenu(this); |
917 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) | 921 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) |
918 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 922 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
919 | else | 923 | else |
920 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 924 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
921 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 925 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
922 | m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() )); | 926 | m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() )); |
923 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 927 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
924 | m->insertSeparator(); | 928 | m->insertSeparator(); |
925 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 929 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
926 | m->exec( QCursor::pos() ); | 930 | m->exec( QCursor::pos() ); |
927 | delete m; | 931 | delete m; |
928 | } | 932 | } |
929 | 933 | ||
930 | void OpieFtp::showLocalMenu(QListViewItem * item) | 934 | void OpieFtp::showLocalMenu(QListViewItem * item) |
931 | { | 935 | { |
932 | 936 | ||
933 | QPopupMenu *m; | 937 | QPopupMenu *m; |
934 | m = new QPopupMenu( this); | 938 | m = new QPopupMenu( this); |
935 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 939 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
936 | m->insertSeparator(); | 940 | m->insertSeparator(); |
937 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 941 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
938 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 942 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
939 | else | 943 | else |
940 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 944 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
941 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 945 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
942 | m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() )); | 946 | m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() )); |
943 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 947 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
944 | m->insertSeparator(); | 948 | m->insertSeparator(); |
945 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 949 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
946 | m->setCheckable(TRUE); | 950 | m->setCheckable(TRUE); |
947 | if (b) | 951 | if (b) |
948 | m->setItemChecked(m->idAt(0),TRUE); | 952 | m->setItemChecked(m->idAt(0),TRUE); |
949 | else | 953 | else |
950 | m->setItemChecked(m->idAt(0),FALSE); | 954 | m->setItemChecked(m->idAt(0),FALSE); |
951 | 955 | ||
952 | m->exec( QCursor::pos() ); | 956 | m->exec( QCursor::pos() ); |
953 | delete m; | 957 | delete m; |
954 | } | 958 | } |
955 | 959 | ||
956 | void OpieFtp::localMakDir() | 960 | void OpieFtp::localMakDir() |
957 | { | 961 | { |
958 | InputDialog *fileDlg; | 962 | InputDialog *fileDlg; |
959 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 963 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
960 | fileDlg->exec(); | 964 | fileDlg->exec(); |
961 | if( fileDlg->result() == 1 ) { | 965 | if( fileDlg->result() == 1 ) { |
962 | QString filename = fileDlg->LineEdit1->text(); | 966 | QString filename = fileDlg->LineEdit1->text(); |
963 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 967 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
964 | } | 968 | } |
965 | populateLocalView(); | 969 | populateLocalView(); |
966 | } | 970 | } |
967 | 971 | ||
968 | void OpieFtp::localDelete() | 972 | void OpieFtp::localDelete() |
969 | { | 973 | { |
970 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 974 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
971 | QListViewItemIterator it( Local_View ); | 975 | QListViewItemIterator it( Local_View ); |
972 | for ( ; it.current(); ++it ) { | 976 | for ( ; it.current(); ++it ) { |
973 | if ( it.current()->isSelected() ) { | 977 | if ( it.current()->isSelected() ) { |
974 | QString f = it.current()->text(0); | 978 | QString f = it.current()->text(0); |
975 | it.current()->setSelected(FALSE); | 979 | it.current()->setSelected(FALSE); |
976 | 980 | ||
977 | // QString f = Local_View->currentItem()->text(0); | 981 | // QString f = Local_View->currentItem()->text(0); |
978 | if(QDir(f).exists() ) { | 982 | if(QDir(f).exists() ) { |
979 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 983 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
980 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { | 984 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { |
981 | case 0: { | 985 | case 0: { |
982 | f=currentDir.canonicalPath()+"/"+f; | 986 | f=currentDir.canonicalPath()+"/"+f; |
983 | QString cmd="rmdir "+f; | 987 | QString cmd="rmdir "+f; |
984 | system( cmd.latin1()); | 988 | system( cmd.latin1()); |
985 | } | 989 | } |
986 | break; | 990 | break; |
987 | case 1: | 991 | case 1: |
988 | // exit | 992 | // exit |
989 | break; | 993 | break; |
990 | }; | 994 | }; |
991 | 995 | ||
992 | } else { | 996 | } else { |
993 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 997 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
994 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 998 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
995 | case 0: { | 999 | case 0: { |
996 | f=currentDir.canonicalPath()+"/"+f; | 1000 | f=currentDir.canonicalPath()+"/"+f; |
997 | QString cmd="rm "+f; | 1001 | QString cmd="rm "+f; |
998 | system( cmd.latin1()); | 1002 | system( cmd.latin1()); |
999 | } | 1003 | } |
1000 | break; | 1004 | break; |
1001 | case 1: | 1005 | case 1: |
1002 | // exit | 1006 | // exit |
1003 | break; | 1007 | break; |
1004 | }; | 1008 | }; |
1005 | } | 1009 | } |
1006 | } | 1010 | } |
1007 | } | 1011 | } |
1008 | populateLocalView(); | 1012 | populateLocalView(); |
1009 | 1013 | ||
1010 | } | 1014 | } |
1011 | 1015 | ||
1012 | void OpieFtp::remoteMakDir() | 1016 | void OpieFtp::remoteMakDir() |
1013 | { | 1017 | { |
1014 | InputDialog *fileDlg; | 1018 | InputDialog *fileDlg; |
1015 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 1019 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
1016 | fileDlg->exec(); | 1020 | fileDlg->exec(); |
1017 | if( fileDlg->result() == 1 ) { | 1021 | if( fileDlg->result() == 1 ) { |
1018 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; | 1022 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; |
1019 | QString tmp=currentRemoteDir+filename; | 1023 | QString tmp=currentRemoteDir+filename; |
1020 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1024 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1021 | if(FtpMkdir( tmp.latin1(), conn) == 0) { | 1025 | if(FtpMkdir( tmp.latin1(), conn) == 0) { |
1022 | QString msg; | 1026 | QString msg; |
1023 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); | 1027 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); |
1024 | msg.replace(QRegExp(":"),"\n"); | 1028 | msg.replace(QRegExp(":"),"\n"); |
1025 | QMessageBox::message(tr("Note"),msg); | 1029 | QMessageBox::message(tr("Note"),msg); |
1026 | } | 1030 | } |
1027 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1031 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1028 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1032 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1029 | } | 1033 | } |
1030 | } | 1034 | } |
1031 | 1035 | ||
1032 | void OpieFtp::remoteDelete() | 1036 | void OpieFtp::remoteDelete() |
1033 | { | 1037 | { |
1034 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 1038 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
1035 | QListViewItemIterator it( Remote_View ); | 1039 | QListViewItemIterator it( Remote_View ); |
1036 | for ( ; it.current(); ++it ) { | 1040 | for ( ; it.current(); ++it ) { |
1037 | if ( it.current()->isSelected() ) { | 1041 | if ( it.current()->isSelected() ) { |
1038 | QString f = it.current()->text(0); | 1042 | QString f = it.current()->text(0); |
1039 | // QString f = Remote_View->currentItem()->text(0); | 1043 | // QString f = Remote_View->currentItem()->text(0); |
1040 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1044 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1041 | if( f.right(1) =="/") { | 1045 | if( f.right(1) =="/") { |
1042 | QString path= currentRemoteDir+f; | 1046 | QString path= currentRemoteDir+f; |
1043 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 1047 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
1044 | ,tr("Yes"),tr("No"),0,0,1) ) { | 1048 | ,tr("Yes"),tr("No"),0,0,1) ) { |
1045 | case 0: { | 1049 | case 0: { |
1046 | f=currentDir.canonicalPath()+"/"+f; | 1050 | f=currentDir.canonicalPath()+"/"+f; |
1047 | if(FtpRmdir( path.latin1(), conn) ==0) { | 1051 | if(FtpRmdir( path.latin1(), conn) ==0) { |
1048 | QString msg; | 1052 | QString msg; |
1049 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); | 1053 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); |
1050 | msg.replace(QRegExp(":"),"\n"); | 1054 | msg.replace(QRegExp(":"),"\n"); |
1051 | QMessageBox::message(tr("Note"),msg); | 1055 | QMessageBox::message(tr("Note"),msg); |
1052 | } | 1056 | } |
1053 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1057 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1054 | } | 1058 | } |
1055 | break; | 1059 | break; |
1056 | }; | 1060 | }; |
1057 | } else { | 1061 | } else { |
1058 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 1062 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
1059 | ,tr("Yes"),tr("No"),0,0,1) ) { | 1063 | ,tr("Yes"),tr("No"),0,0,1) ) { |
1060 | case 0: { | 1064 | case 0: { |
1061 | QString path= currentRemoteDir+f; | 1065 | QString path= currentRemoteDir+f; |
1062 | if(FtpDelete( path.latin1(), conn)==0) { | 1066 | if(FtpDelete( path.latin1(), conn)==0) { |
1063 | QString msg; | 1067 | QString msg; |
1064 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); | 1068 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); |
1065 | msg.replace(QRegExp(":"),"\n"); | 1069 | msg.replace(QRegExp(":"),"\n"); |
1066 | QMessageBox::message(tr("Note"),msg); | 1070 | QMessageBox::message(tr("Note"),msg); |
1067 | } | 1071 | } |
1068 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1072 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1069 | } | 1073 | } |
1070 | break; | 1074 | break; |
1071 | }; | 1075 | }; |
1072 | } | 1076 | } |
1073 | } | 1077 | } |
1074 | } | 1078 | } |
1075 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1079 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1076 | } | 1080 | } |
1077 | 1081 | ||
1078 | void OpieFtp::remoteRename() | 1082 | void OpieFtp::remoteRename() |
1079 | { | 1083 | { |
1080 | QString curFile = Remote_View->currentItem()->text(0); | 1084 | QString curFile = Remote_View->currentItem()->text(0); |
1081 | InputDialog *fileDlg; | 1085 | InputDialog *fileDlg; |
1082 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1086 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1083 | fileDlg->setTextEdit((const QString &)curFile); | 1087 | fileDlg->setTextEdit((const QString &)curFile); |
1084 | fileDlg->exec(); | 1088 | fileDlg->exec(); |
1085 | if( fileDlg->result() == 1 ) { | 1089 | if( fileDlg->result() == 1 ) { |
1086 | QString oldName = currentRemoteDir +"/"+ curFile; | 1090 | QString oldName = currentRemoteDir +"/"+ curFile; |
1087 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; | 1091 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; |
1088 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1092 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1089 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { | 1093 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { |
1090 | QString msg; | 1094 | QString msg; |
1091 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); | 1095 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); |
1092 | msg.replace(QRegExp(":"),"\n"); | 1096 | msg.replace(QRegExp(":"),"\n"); |
1093 | QMessageBox::message(tr("Note"),msg); | 1097 | QMessageBox::message(tr("Note"),msg); |
1094 | } | 1098 | } |
1095 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1099 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1096 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1100 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1097 | } | 1101 | } |
1098 | } | 1102 | } |
1099 | 1103 | ||
1100 | void OpieFtp::localRename() | 1104 | void OpieFtp::localRename() |
1101 | { | 1105 | { |
1102 | QString curFile = Local_View->currentItem()->text(0); | 1106 | QString curFile = Local_View->currentItem()->text(0); |
1103 | InputDialog *fileDlg; | 1107 | InputDialog *fileDlg; |
1104 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1108 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1105 | fileDlg->setTextEdit((const QString &)curFile); | 1109 | fileDlg->setTextEdit((const QString &)curFile); |
1106 | fileDlg->exec(); | 1110 | fileDlg->exec(); |
1107 | if( fileDlg->result() == 1 ) { | 1111 | if( fileDlg->result() == 1 ) { |
1108 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 1112 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
1109 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 1113 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
1110 | if( rename(oldname.latin1(), newName.latin1())== -1) | 1114 | if( rename(oldname.latin1(), newName.latin1())== -1) |
1111 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 1115 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1112 | } | 1116 | } |
1113 | populateLocalView(); | 1117 | populateLocalView(); |
1114 | } | 1118 | } |
1115 | 1119 | ||
1116 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { | 1120 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { |
1117 | if (TabWidget->currentPageIndex() == 0) { | 1121 | if (TabWidget->currentPageIndex() == 0) { |
1118 | chdir( currentPath.latin1() ); | 1122 | chdir( currentPath.latin1() ); |
1119 | currentDir.cd( currentPath, TRUE); | 1123 | currentDir.cd( currentPath, TRUE); |
1120 | populateLocalView(); | 1124 | populateLocalView(); |
1121 | update(); | 1125 | update(); |
1122 | } else { | 1126 | } else { |
1123 | // chdir( currentPath.latin1() ); | 1127 | // chdir( currentPath.latin1() ); |
1124 | // currentDir.cd( currentPath, TRUE); | 1128 | // currentDir.cd( currentPath, TRUE); |
1125 | // populateList(); | 1129 | // populateList(); |
1126 | // update(); | 1130 | // update(); |
1127 | 1131 | ||
1128 | } | 1132 | } |
1129 | } | 1133 | } |
1130 | 1134 | ||
1131 | void OpieFtp::fillCombo(const QString ¤tPath) { | 1135 | void OpieFtp::fillCombo(const QString ¤tPath) { |
1132 | 1136 | ||
1133 | currentPathCombo->lineEdit()->setText(currentPath); | 1137 | currentPathCombo->lineEdit()->setText(currentPath); |
1134 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1138 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1135 | currentPathCombo->clear(); | 1139 | currentPathCombo->clear(); |
1136 | localDirPathStringList.prepend(currentPath ); | 1140 | localDirPathStringList.prepend(currentPath ); |
1137 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 1141 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
1138 | } | 1142 | } |
1139 | currentPathCombo->lineEdit()->setText(currentPath); | 1143 | currentPathCombo->lineEdit()->setText(currentPath); |
1140 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1144 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1141 | currentPathCombo->clear(); | 1145 | currentPathCombo->clear(); |
1142 | remoteDirPathStringList.prepend(currentPath ); | 1146 | remoteDirPathStringList.prepend(currentPath ); |
1143 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1147 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1144 | } | 1148 | } |
1145 | } | 1149 | } |
1146 | 1150 | ||
1147 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { | 1151 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { |
1148 | 1152 | ||
1149 | currentPathCombo->lineEdit()->setText(currentPath); | 1153 | currentPathCombo->lineEdit()->setText(currentPath); |
1150 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1154 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1151 | currentPathCombo->clear(); | 1155 | currentPathCombo->clear(); |
1152 | remoteDirPathStringList.prepend(currentPath ); | 1156 | remoteDirPathStringList.prepend(currentPath ); |
1153 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1157 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1154 | } | 1158 | } |
1155 | } | 1159 | } |
1156 | 1160 | ||
1157 | void OpieFtp::currentPathComboChanged() | 1161 | void OpieFtp::currentPathComboChanged() |
1158 | { | 1162 | { |
1159 | QString oldRemoteCurrentDir = currentRemoteDir; | 1163 | QString oldRemoteCurrentDir = currentRemoteDir; |
1160 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 1164 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); |
1161 | if (TabWidget->currentPageIndex() == 0) { | 1165 | if (TabWidget->currentPageIndex() == 0) { |
1162 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 1166 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
1163 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 1167 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
1164 | populateLocalView(); | 1168 | populateLocalView(); |
1165 | } else { | 1169 | } else { |
1166 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 1170 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
1167 | } | 1171 | } |
1168 | } | 1172 | } |
1169 | if (TabWidget->currentPageIndex() == 1) { | 1173 | if (TabWidget->currentPageIndex() == 1) { |
1170 | currentRemoteDir = currentPathCombo->lineEdit()->text(); | 1174 | currentRemoteDir = currentPathCombo->lineEdit()->text(); |
1171 | if(currentRemoteDir.right(1) !="/") { | 1175 | if(currentRemoteDir.right(1) !="/") { |
1172 | currentRemoteDir = currentRemoteDir +"/"; | 1176 | currentRemoteDir = currentRemoteDir +"/"; |
1173 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1177 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1174 | } | 1178 | } |
1175 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 1179 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
1176 | currentRemoteDir = oldRemoteCurrentDir; | 1180 | currentRemoteDir = oldRemoteCurrentDir; |
1177 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1181 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1178 | } | 1182 | } |
1179 | 1183 | ||
1180 | remoteDirList( (const QString &)currentRemoteDir); | 1184 | remoteDirList( (const QString &)currentRemoteDir); |
1181 | } | 1185 | } |
1182 | } | 1186 | } |
1183 | 1187 | ||
1184 | void OpieFtp::switchToLocalTab() | 1188 | void OpieFtp::switchToLocalTab() |
1185 | { | 1189 | { |
1186 | TabWidget->setCurrentPage(0); | 1190 | TabWidget->setCurrentPage(0); |
1187 | } | 1191 | } |
1188 | 1192 | ||
1189 | void OpieFtp::switchToRemoteTab() | 1193 | void OpieFtp::switchToRemoteTab() |
1190 | { | 1194 | { |
1191 | TabWidget->setCurrentPage(1); | 1195 | TabWidget->setCurrentPage(1); |
1192 | } | 1196 | } |
1193 | 1197 | ||
1194 | void OpieFtp::switchToConfigTab() | 1198 | void OpieFtp::switchToConfigTab() |
1195 | { | 1199 | { |
1196 | TabWidget->setCurrentPage(2); | 1200 | TabWidget->setCurrentPage(2); |
1197 | } | 1201 | } |
1198 | 1202 | ||
1199 | void OpieFtp::readConfig() | 1203 | void OpieFtp::readConfig() |
1200 | { | 1204 | { |
1201 | fillCombos(); | 1205 | fillCombos(); |
1202 | Config cfg("opieftp"); | 1206 | Config cfg("opieftp"); |
1203 | cfg.setGroup("Server"); | 1207 | cfg.setGroup("Server"); |
1204 | currentServerConfig = cfg.readNumEntry("currentServer", -1); | 1208 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
1205 | 1209 | ||
1206 | // qDebug("Reading %d", currentServerConfig); | 1210 | // qDebug("Reading %d", currentServerConfig); |
1207 | serverComboSelected( currentServerConfig-1); | 1211 | serverComboSelected( currentServerConfig-1); |
1208 | 1212 | ||
1209 | } | 1213 | } |
1210 | 1214 | ||
1211 | void OpieFtp::writeConfig() | 1215 | void OpieFtp::writeConfig() |
1212 | { | 1216 | { |
1213 | qDebug("write config"); | 1217 | qDebug("write config"); |
1214 | Config cfg("opieftp"); | 1218 | Config cfg("opieftp"); |
1215 | cfg.setGroup("Server"); | 1219 | cfg.setGroup("Server"); |
1216 | 1220 | ||
1217 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1221 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1218 | 1222 | ||
1219 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1223 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1220 | 1224 | ||
1221 | if( currentServerConfig == -1) { | 1225 | if( currentServerConfig == -1) { |
1222 | 1226 | ||
1223 | for (int i = 1; i <= numberOfEntries; i++) { | 1227 | for (int i = 1; i <= numberOfEntries; i++) { |
1224 | temp.setNum(i); | 1228 | temp.setNum(i); |
1225 | cfg.setGroup("Server"); | 1229 | cfg.setGroup("Server"); |
1226 | QString tempStr = cfg.readEntry( temp,""); | 1230 | QString tempStr = cfg.readEntry( temp,""); |
1227 | } | 1231 | } |
1228 | 1232 | ||
1229 | temp.setNum( numberOfEntries + 1); | 1233 | temp.setNum( numberOfEntries + 1); |
1230 | cfg.setGroup("Server"); | 1234 | cfg.setGroup("Server"); |
1231 | 1235 | ||
1232 | remoteServerStr = cfg.readEntry( temp,""); | 1236 | remoteServerStr = cfg.readEntry( temp,""); |
1233 | 1237 | ||
1234 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1238 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1235 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1239 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1236 | 1240 | ||
1237 | temp.setNum(numberOfEntries+1); | 1241 | temp.setNum(numberOfEntries+1); |
1238 | cfg.setGroup("Server"); | 1242 | cfg.setGroup("Server"); |
1239 | 1243 | ||
1240 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1244 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1241 | cfg.writeEntry("currentServer", numberOfEntries+1); | 1245 | cfg.writeEntry("currentServer", numberOfEntries+1); |
1242 | 1246 | ||
1243 | currentServerConfig = numberOfEntries+1; | 1247 | currentServerConfig = numberOfEntries+1; |
1244 | qDebug("setting currentserverconfig to %d", currentServerConfig); | 1248 | qDebug("setting currentserverconfig to %d", currentServerConfig); |
1245 | 1249 | ||
1246 | cfg.setGroup(temp); | 1250 | cfg.setGroup(temp); |
1247 | if(!newServerName.isEmpty()) | 1251 | if(!newServerName.isEmpty()) |
1248 | cfg.writeEntry("ServerName", newServerName); | 1252 | cfg.writeEntry("ServerName", newServerName); |
1249 | 1253 | ||
1250 | cfg.writeEntry("RemotePath", remotePath->text()); | 1254 | cfg.writeEntry("RemotePath", remotePath->text()); |
1251 | 1255 | ||
1252 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1256 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1253 | 1257 | ||
1254 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1258 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1255 | cfg.setGroup("Server"); | 1259 | cfg.setGroup("Server"); |
1256 | 1260 | ||
1257 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1261 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1258 | 1262 | ||
1259 | } | 1263 | } |
1260 | } | 1264 | } |
1261 | 1265 | ||
1262 | void OpieFtp::clearCombos() { | 1266 | void OpieFtp::clearCombos() { |
1263 | qDebug("clearing"); | 1267 | qDebug("clearing"); |
1264 | ServerComboBox->clear(); | 1268 | ServerComboBox->clear(); |
1265 | UsernameComboBox->clear(); | 1269 | UsernameComboBox->clear(); |
1266 | PasswordEdit->clear(); | 1270 | PasswordEdit->clear(); |
1267 | serverListView->clear(); | 1271 | serverListView->clear(); |
1268 | } | 1272 | } |
1269 | 1273 | ||
1270 | 1274 | ||
1271 | void OpieFtp::fillCombos() | 1275 | void OpieFtp::fillCombos() |
1272 | { | 1276 | { |
1273 | clearCombos(); | 1277 | clearCombos(); |
1274 | 1278 | ||
1275 | Config cfg("opieftp"); | 1279 | Config cfg("opieftp"); |
1276 | cfg.setGroup("Server"); | 1280 | cfg.setGroup("Server"); |
1277 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1281 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1278 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1282 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1279 | 1283 | ||
1280 | for (int i = 1; i <= numberOfEntries; i++) { | 1284 | for (int i = 1; i <= numberOfEntries; i++) { |
1281 | temp.setNum(i); | 1285 | temp.setNum(i); |
1282 | qDebug(temp); | 1286 | qDebug(temp); |
1283 | cfg.setGroup("Server"); | 1287 | cfg.setGroup("Server"); |
1284 | remoteServerStr = cfg.readEntry( temp,""); | 1288 | remoteServerStr = cfg.readEntry( temp,""); |
1285 | qDebug( remoteServerStr); | 1289 | qDebug( remoteServerStr); |
1286 | 1290 | ||
1287 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1291 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1288 | port = remoteServerStr.right( divider - 1); | 1292 | port = remoteServerStr.right( divider - 1); |
1289 | bool ok; | 1293 | bool ok; |
1290 | PortSpinBox->setValue( port.toInt(&ok,10)); | 1294 | PortSpinBox->setValue( port.toInt(&ok,10)); |
1291 | 1295 | ||
1292 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1296 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1293 | qDebug( "remote server string "+remoteServerStr); | 1297 | qDebug( "remote server string "+remoteServerStr); |
1294 | ServerComboBox->insertItem( remoteServerStr ); | 1298 | ServerComboBox->insertItem( remoteServerStr ); |
1295 | 1299 | ||
1296 | cfg.setGroup(temp); | 1300 | cfg.setGroup(temp); |
1297 | 1301 | ||
1298 | username = cfg.readEntry(temp); | 1302 | username = cfg.readEntry(temp); |
1299 | UsernameComboBox->insertItem(username); | 1303 | UsernameComboBox->insertItem(username); |
1300 | password = cfg.readEntryCrypt(username,""); | 1304 | password = cfg.readEntryCrypt(username,""); |
1301 | PasswordEdit->setText(password); | 1305 | PasswordEdit->setText(password); |
1302 | 1306 | ||
1303 | serverListView->insertItem( cfg.readEntry("ServerName")); | 1307 | serverListView->insertItem( cfg.readEntry("ServerName")); |
1304 | } | 1308 | } |
1305 | } | 1309 | } |
1306 | 1310 | ||
1307 | 1311 | ||
1308 | void OpieFtp::serverComboSelected(int index) | 1312 | void OpieFtp::serverComboSelected(int index) |
1309 | { | 1313 | { |
1310 | currentServerConfig = index+1; | 1314 | currentServerConfig = index+1; |
1311 | qDebug("server combo selected %d", index+1); | 1315 | qDebug("server combo selected %d", index+1); |
1312 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1316 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1313 | // remoteServerStr = ServerComboBox->text(index); | 1317 | // remoteServerStr = ServerComboBox->text(index); |
1314 | 1318 | ||
1315 | Config cfg("opieftp"); | 1319 | Config cfg("opieftp"); |
1316 | cfg.setGroup("Server"); | 1320 | cfg.setGroup("Server"); |
1317 | // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1321 | // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1318 | 1322 | ||
1319 | temp.setNum(index+1); | 1323 | temp.setNum(index+1); |
1320 | remoteServerStr = cfg.readEntry( temp,""); | 1324 | remoteServerStr = cfg.readEntry( temp,""); |
1321 | 1325 | ||
1322 | qDebug("Group" +temp); | 1326 | qDebug("Group" +temp); |
1323 | cfg.setGroup(temp); | 1327 | cfg.setGroup(temp); |
1324 | // qDebug(temp); | 1328 | // qDebug(temp); |
1325 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1329 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1326 | port = remoteServerStr.right( divider - 1); | 1330 | port = remoteServerStr.right( divider - 1); |
1327 | bool ok; | 1331 | bool ok; |
1328 | int portInt = port.toInt(&ok,10); | 1332 | int portInt = port.toInt(&ok,10); |
1329 | if( portInt == 0) portInt = 21; | 1333 | if( portInt == 0) portInt = 21; |
1330 | 1334 | ||
1331 | ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); | 1335 | ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); |
1332 | 1336 | ||
1333 | PortSpinBox->setValue( portInt); | 1337 | PortSpinBox->setValue( portInt); |
1334 | 1338 | ||
1335 | remotePath->setText(cfg.readEntry("RemotePath", "/")); | 1339 | remotePath->setText(cfg.readEntry("RemotePath", "/")); |
1336 | 1340 | ||
1337 | username = cfg.readEntry("Username", "anonymous"); | 1341 | username = cfg.readEntry("Username", "anonymous"); |
1338 | UsernameComboBox->lineEdit()->setText(username); | 1342 | UsernameComboBox->lineEdit()->setText(username); |
1339 | qDebug(username); | 1343 | qDebug(username); |
1340 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); | 1344 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); |
1341 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); | 1345 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); |
1342 | // UsernameComboBox | 1346 | // UsernameComboBox |
1343 | // PasswordEdit | 1347 | // PasswordEdit |
1344 | 1348 | ||
1345 | cfg.setGroup("Server"); | 1349 | cfg.setGroup("Server"); |
1346 | temp.sprintf("%d",currentServerConfig); | 1350 | temp.sprintf("%d",currentServerConfig); |
1347 | cfg.writeEntry("currentServer", temp); | 1351 | cfg.writeEntry("currentServer", temp); |
1348 | 1352 | ||
1349 | fuckeduphack = TRUE; | 1353 | fuckeduphack = TRUE; |
1350 | serverListView->setCurrentItem( index); | 1354 | serverListView->setCurrentItem( index); |
1351 | fuckeduphack=FALSE; | 1355 | fuckeduphack=FALSE; |
1352 | qDebug("server list set selected %d",index); | 1356 | qDebug("server list set selected %d",index); |
1353 | update(); | 1357 | update(); |
1354 | } | 1358 | } |
1355 | 1359 | ||
1356 | void OpieFtp::deleteServer() | 1360 | void OpieFtp::deleteServer() |
1357 | { | 1361 | { |
1358 | QString username, remoteServerStr, remotePathStr, password, port, temp, servername; | 1362 | QString username, remoteServerStr, remotePathStr, password, port, temp, servername; |
1359 | remoteServerStr = ServerComboBox->currentText( ); | 1363 | remoteServerStr = ServerComboBox->currentText( ); |
1360 | username = UsernameComboBox->currentText(); | 1364 | username = UsernameComboBox->currentText(); |
1361 | servername=serverListView->currentText(); | 1365 | servername=serverListView->currentText(); |
1362 | 1366 | ||
1363 | Config cfg("opieftp"); | 1367 | Config cfg("opieftp"); |
1364 | cfg.setGroup("Server"); | 1368 | cfg.setGroup("Server"); |
1365 | QString tempname; | 1369 | QString tempname; |
1366 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1370 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1367 | 1371 | ||
1368 | for (int i = 1; i <= numberOfEntries; i++) { | 1372 | for (int i = 1; i <= numberOfEntries; i++) { |
1369 | temp.setNum(i); | 1373 | temp.setNum(i); |
1370 | // cfg.setGroup("Server"); | 1374 | // cfg.setGroup("Server"); |
1371 | cfg.setGroup(QString::number(i)); | 1375 | cfg.setGroup(QString::number(i)); |
1372 | tempname=cfg.readEntry( "ServerName",""); | 1376 | tempname=cfg.readEntry( "ServerName",""); |
1373 | 1377 | ||
1374 | if( tempname.find( servername,0,TRUE) != -1 ) { | 1378 | if( tempname.find( servername,0,TRUE) != -1 ) { |
1375 | // servername.find( cfg.readEntry("ServerName")) != -1 && | 1379 | // servername.find( cfg.readEntry("ServerName")) != -1 && |
1376 | // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && | 1380 | // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && |
1377 | // username.find( cfg.readEntry("Username")) != -1) { | 1381 | // username.find( cfg.readEntry("Username")) != -1) { |
1378 | 1382 | ||
1379 | serverListView->removeItem(i); | 1383 | serverListView->removeItem(i); |
1380 | 1384 | ||
1381 | qDebug("OK DELETE "+tempname); | 1385 | qDebug("OK DELETE "+tempname); |
1382 | cfg.removeEntry(QString::number(i)); | 1386 | cfg.removeEntry(QString::number(i)); |
1383 | for ( ; i <= numberOfEntries; i++) { | 1387 | for ( ; i <= numberOfEntries; i++) { |
1384 | cfg.setGroup("Server"); | 1388 | cfg.setGroup("Server"); |
1385 | cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); | 1389 | cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); |
1386 | 1390 | ||
1387 | cfg.setGroup(QString::number(i+1)); //get next server config | 1391 | cfg.setGroup(QString::number(i+1)); //get next server config |
1388 | servername=cfg.readEntry("ServerName"); | 1392 | servername=cfg.readEntry("ServerName"); |
1389 | remoteServerStr=cfg.readEntry("RemotePath"); | 1393 | remoteServerStr=cfg.readEntry("RemotePath"); |
1390 | username=cfg.readEntry("Username"); | 1394 | username=cfg.readEntry("Username"); |
1391 | password=cfg.readEntryCrypt( username); | 1395 | password=cfg.readEntryCrypt( username); |
1392 | 1396 | ||
1393 | cfg.setGroup(QString::number(i)); | 1397 | cfg.setGroup(QString::number(i)); |
1394 | 1398 | ||
1395 | cfg.writeEntry("RemotePath", remoteServerStr); | 1399 | cfg.writeEntry("RemotePath", remoteServerStr); |
1396 | cfg.writeEntry("ServerName", servername); | 1400 | cfg.writeEntry("ServerName", servername); |
1397 | cfg.writeEntry("Username", username); | 1401 | cfg.writeEntry("Username", username); |
1398 | cfg.writeEntryCrypt( username, password); | 1402 | cfg.writeEntryCrypt( username, password); |
1399 | 1403 | ||
1400 | } | 1404 | } |
1401 | cfg.setGroup("Server"); | 1405 | cfg.setGroup("Server"); |
1402 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries - 1 )); | 1406 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries - 1 )); |
1403 | } | 1407 | } |
1404 | } | 1408 | } |
1405 | cfg.setGroup(QString::number(numberOfEntries)); | 1409 | cfg.setGroup(QString::number(numberOfEntries)); |
1406 | cfg.removeEntry("Server"); | 1410 | cfg.removeEntry("Server"); |
1407 | cfg.removeEntry("RemotePath"); | 1411 | cfg.removeEntry("RemotePath"); |
1408 | cfg.removeEntry("ServerName"); | 1412 | cfg.removeEntry("ServerName"); |
1409 | username=cfg.readEntry("Username"); | 1413 | username=cfg.readEntry("Username"); |
1410 | cfg.removeEntry("Username"); | 1414 | cfg.removeEntry("Username"); |
1411 | cfg.removeEntry(username); | 1415 | cfg.removeEntry(username); |
1412 | 1416 | ||
1413 | currentServerConfig=currentServerConfig-1; | 1417 | currentServerConfig=currentServerConfig-1; |
1414 | 1418 | ||
1415 | fillCombos(); | 1419 | fillCombos(); |
1416 | update(); | 1420 | update(); |
1417 | } | 1421 | } |
1418 | 1422 | ||
1419 | void OpieFtp::upDir() | 1423 | void OpieFtp::upDir() |
1420 | { | 1424 | { |
1421 | if (TabWidget->currentPageIndex() == 0) { | 1425 | if (TabWidget->currentPageIndex() == 0) { |
1422 | QString current = currentDir.canonicalPath(); | 1426 | QString current = currentDir.canonicalPath(); |
1423 | QDir dir(current); | 1427 | QDir dir(current); |
1424 | dir.cdUp(); | 1428 | dir.cdUp(); |
1425 | current = dir.canonicalPath(); | 1429 | current = dir.canonicalPath(); |
1426 | chdir( current.latin1() ); | 1430 | chdir( current.latin1() ); |
1427 | currentDir.cd( current, TRUE); | 1431 | currentDir.cd( current, TRUE); |
1428 | populateLocalView(); | 1432 | populateLocalView(); |
1429 | update(); | 1433 | update(); |
1430 | } else { | 1434 | } else { |
1431 | if( FtpCDUp( conn) == 0) { | 1435 | if( FtpCDUp( conn) == 0) { |
1432 | QString msg; | 1436 | QString msg; |
1433 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 1437 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
1434 | msg.replace(QRegExp(":"),"\n"); | 1438 | msg.replace(QRegExp(":"),"\n"); |
1435 | QMessageBox::message(tr("Note"),msg); | 1439 | QMessageBox::message(tr("Note"),msg); |
1436 | // qDebug(msg); | 1440 | // qDebug(msg); |
1437 | } | 1441 | } |
1438 | char path[256]; | 1442 | char path[256]; |
1439 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 1443 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
1440 | QString msg; | 1444 | QString msg; |
1441 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 1445 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
1442 | msg.replace(QRegExp(":"),"\n"); | 1446 | msg.replace(QRegExp(":"),"\n"); |
1443 | QMessageBox::message(tr("Note"),msg); | 1447 | QMessageBox::message(tr("Note"),msg); |
1444 | // qDebug(msg); | 1448 | // qDebug(msg); |
1445 | } | 1449 | } |
1446 | currentRemoteDir=path; | 1450 | currentRemoteDir=path; |
1447 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1451 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1448 | if(currentRemoteDir.right(1) !="/") | 1452 | if(currentRemoteDir.right(1) !="/") |
1449 | currentRemoteDir +="/"; | 1453 | currentRemoteDir +="/"; |
1450 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 1454 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
1451 | fillRemoteCombo( (const QString &)currentRemoteDir); | 1455 | fillRemoteCombo( (const QString &)currentRemoteDir); |
1452 | 1456 | ||
1453 | } | 1457 | } |
1454 | } | 1458 | } |
1455 | 1459 | ||
1456 | void OpieFtp::docButtonPushed() { | 1460 | void OpieFtp::docButtonPushed() { |
1457 | QString current = QPEApplication::documentDir(); | 1461 | QString current = QPEApplication::documentDir(); |
1458 | chdir( current.latin1() ); | 1462 | chdir( current.latin1() ); |
1459 | currentDir.cd( current, TRUE); | 1463 | currentDir.cd( current, TRUE); |
1460 | populateLocalView(); | 1464 | populateLocalView(); |
1461 | update(); | 1465 | update(); |
1462 | 1466 | ||
1463 | } | 1467 | } |
1464 | 1468 | ||
1465 | void OpieFtp::homeButtonPushed() { | 1469 | void OpieFtp::homeButtonPushed() { |
1466 | QString current = QDir::homeDirPath(); | 1470 | QString current = QDir::homeDirPath(); |
1467 | chdir( current.latin1() ); | 1471 | chdir( current.latin1() ); |
1468 | currentDir.cd( current, TRUE); | 1472 | currentDir.cd( current, TRUE); |
1469 | populateLocalView(); | 1473 | populateLocalView(); |
1470 | update(); | 1474 | update(); |
1471 | } | 1475 | } |
1472 | 1476 | ||
1473 | void OpieFtp::doAbout() { | 1477 | void OpieFtp::doAbout() { |
1474 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" | 1478 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" |
1475 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1479 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1476 | "and uses ftplib copyright 1996-2000\n" | 1480 | "and uses ftplib copyright 1996-2000\n" |
1477 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" | 1481 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" |
1478 | "and is licensed by the GPL"); | 1482 | "and is licensed by the GPL"); |
1479 | } | 1483 | } |
1480 | 1484 | ||
1481 | void OpieFtp::NewServer() { | 1485 | void OpieFtp::NewServer() { |
1482 | InputDialog *fileDlg; | 1486 | InputDialog *fileDlg; |
1483 | fileDlg = new InputDialog(this,tr("New Server name"),TRUE, 0); | 1487 | fileDlg = new InputDialog(this,tr("New Server name"),TRUE, 0); |
1484 | fileDlg->exec(); | 1488 | fileDlg->exec(); |
1485 | Config cfg("opieftp"); | 1489 | Config cfg("opieftp"); |
1486 | if( fileDlg->result() == 1 ) { | 1490 | if( fileDlg->result() == 1 ) { |
1487 | newServerName = fileDlg->LineEdit1->text(); | 1491 | newServerName = fileDlg->LineEdit1->text(); |
1488 | for(int i=1;i<serverListView->count();i++) { | 1492 | for(int i=1;i<serverListView->count();i++) { |
1489 | cfg.setGroup( QString::number(i)); | 1493 | cfg.setGroup( QString::number(i)); |
1490 | if(cfg.readEntry("ServerName").find(newServerName,0,TRUE) != -1) { | 1494 | if(cfg.readEntry("ServerName").find(newServerName,0,TRUE) != -1) { |
1491 | QMessageBox::message(tr("OpieFtp"),tr("Sorry name already taken")); | 1495 | QMessageBox::message(tr("OpieFtp"),tr("Sorry name already taken")); |
1492 | return; | 1496 | return; |
1493 | } | 1497 | } |
1494 | } | 1498 | } |
1495 | currentServerConfig =-1; | 1499 | currentServerConfig =-1; |
1496 | writeConfig(); | 1500 | writeConfig(); |
1497 | serverListView->insertItem( newServerName ); | 1501 | serverListView->insertItem( newServerName ); |
1498 | serverListView->setCurrentItem( serverListView->count()); | 1502 | serverListView->setCurrentItem( serverListView->count()); |
1499 | } | 1503 | } |
1500 | } | 1504 | } |
1501 | 1505 | ||
1502 | void OpieFtp::serverListClicked( const QString &item) { | 1506 | void OpieFtp::serverListClicked( const QString &item) { |
1503 | if(item.isEmpty()) return; | 1507 | if(item.isEmpty()) return; |
1504 | Config cfg("opieftp"); | 1508 | Config cfg("opieftp"); |
1505 | qDebug("highltined "+item); | 1509 | qDebug("highltined "+item); |
1506 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1510 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1507 | for (int i = 1; i <= numberOfEntries; i++) { | 1511 | for (int i = 1; i <= numberOfEntries; i++) { |
1508 | cfg.setGroup(QString::number(i)); | 1512 | cfg.setGroup(QString::number(i)); |
1509 | if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) | 1513 | if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) |
1510 | serverComboSelected(i-1); | 1514 | serverComboSelected(i-1); |
1511 | } | 1515 | } |
1512 | } | 1516 | } |
1513 | 1517 | ||
1514 | void OpieFtp::timerOut() { | 1518 | void OpieFtp::timerOut() { |
1515 | 1519 | ||
1516 | } | 1520 | } |
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h index 109b5f8..9d5d211 100644 --- a/noncore/net/opieftp/opieftp.h +++ b/noncore/net/opieftp/opieftp.h | |||
@@ -1,140 +1,142 @@ | |||
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 | #include <qpixmap.h> | ||
21 | 22 | ||
22 | class QVBoxLayout; | 23 | class QVBoxLayout; |
23 | class QHBoxLayout; | 24 | class QHBoxLayout; |
24 | class QGridLayout; | 25 | class QGridLayout; |
25 | class QComboBox; | 26 | class QComboBox; |
26 | class QListView; | 27 | class QListView; |
27 | class QListViewItem; | 28 | class QListViewItem; |
28 | class QLabel; | 29 | class QLabel; |
29 | class QProgressBar; | 30 | class QProgressBar; |
30 | class QSpinBox; | 31 | class QSpinBox; |
31 | class QTabWidget; | 32 | class QTabWidget; |
32 | class QWidget; | 33 | class QWidget; |
33 | class QPEToolBar; | 34 | class QPEToolBar; |
34 | class QPEMenuBar; | 35 | class QPEMenuBar; |
35 | class QPopupMenu; | 36 | class QPopupMenu; |
36 | class QFile; | 37 | class QFile; |
37 | class QLineEdit; | 38 | class QLineEdit; |
38 | class QPushButton; | 39 | class QPushButton; |
39 | class QToolButton; | 40 | class QToolButton; |
40 | class QStringList; | 41 | class QStringList; |
41 | class QListBox; | 42 | class QListBox; |
42 | class QTimer; | 43 | class QTimer; |
43 | 44 | ||
44 | class OpieFtp : public QMainWindow | 45 | class OpieFtp : public QMainWindow |
45 | { | 46 | { |
46 | Q_OBJECT | 47 | Q_OBJECT |
47 | 48 | ||
48 | public: | 49 | public: |
49 | OpieFtp( ); | 50 | OpieFtp( ); |
50 | ~OpieFtp(); | 51 | ~OpieFtp(); |
51 | 52 | ||
52 | QTabWidget *TabWidget; | 53 | QTabWidget *TabWidget; |
53 | QWidget *tab, *tab_2, *tab_3; | 54 | QWidget *tab, *tab_2, *tab_3; |
54 | QListView *Local_View, *Remote_View; | 55 | QListView *Local_View, *Remote_View; |
55 | QListBox *serverListView; | 56 | QListBox *serverListView; |
56 | 57 | ||
57 | QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo; | 58 | QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo; |
58 | QLineEdit *PasswordEdit, *remotePath; | 59 | QLineEdit *PasswordEdit, *remotePath; |
59 | QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;; | 60 | QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;; |
60 | QSpinBox* PortSpinBox; | 61 | QSpinBox* PortSpinBox; |
61 | QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu, *aboutMenu; | 62 | QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu, *aboutMenu; |
62 | QDir currentDir; | 63 | QDir currentDir; |
63 | QString currentRemoteDir; | 64 | QString currentRemoteDir; |
64 | QString filterStr; | 65 | QString filterStr; |
65 | QListViewItem * item; | 66 | QListViewItem * item; |
66 | QPushButton *connectServerBtn, *newServerButton;// | 67 | QPushButton *connectServerBtn, *newServerButton;// |
67 | QToolButton *cdUpButton, *homeButton, *docButton; | 68 | QToolButton *cdUpButton, *homeButton, *docButton; |
68 | bool b; | 69 | bool b; |
69 | int currentServerConfig; | 70 | int currentServerConfig; |
70 | protected slots: | 71 | protected slots: |
71 | void timerOut(); | 72 | void timerOut(); |
72 | void upDir(); | 73 | void upDir(); |
73 | void homeButtonPushed(); | 74 | void homeButtonPushed(); |
74 | void docButtonPushed(); | 75 | void docButtonPushed(); |
75 | void doAbout(); | 76 | void doAbout(); |
76 | 77 | ||
77 | void serverComboEdited(const QString & ); | 78 | void serverComboEdited(const QString & ); |
78 | void UsernameComboBoxEdited(const QString & ); | 79 | void UsernameComboBoxEdited(const QString & ); |
79 | void PasswordEditEdited(const QString & ); | 80 | void PasswordEditEdited(const QString & ); |
80 | 81 | ||
81 | void showLocalMenu( QListViewItem *); | 82 | void showLocalMenu( QListViewItem *); |
82 | void showRemoteMenu( QListViewItem *); | 83 | void showRemoteMenu( QListViewItem *); |
83 | void doLocalCd(); | 84 | void doLocalCd(); |
84 | void doRemoteCd(); | 85 | void doRemoteCd(); |
85 | void localUpload(); | 86 | void localUpload(); |
86 | void remoteDownload(); | 87 | void remoteDownload(); |
87 | void newConnection(); | 88 | void newConnection(); |
88 | void connector(); | 89 | void connector(); |
89 | void disConnector(); | 90 | void disConnector(); |
90 | void populateLocalView(); | 91 | void populateLocalView(); |
91 | bool populateRemoteView(); | 92 | bool populateRemoteView(); |
92 | void showHidden(); | 93 | void showHidden(); |
93 | void writeConfig(); | 94 | void writeConfig(); |
94 | void readConfig(); | 95 | void readConfig(); |
95 | void localListClicked(QListViewItem *); | 96 | void localListClicked(QListViewItem *); |
96 | void remoteListClicked(QListViewItem *); | 97 | void remoteListClicked(QListViewItem *); |
97 | void ListPressed( int, QListViewItem *, const QPoint&, int); | 98 | void ListPressed( int, QListViewItem *, const QPoint&, int); |
98 | void RemoteListPressed( int, QListViewItem *, const QPoint&, int); | 99 | void RemoteListPressed( int, QListViewItem *, const QPoint&, int); |
99 | void localMakDir(); | 100 | void localMakDir(); |
100 | void localDelete(); | 101 | void localDelete(); |
101 | void remoteMakDir(); | 102 | void remoteMakDir(); |
102 | void remoteDelete(); | 103 | void remoteDelete(); |
103 | 104 | ||
104 | bool remoteDirList(const QString &); | 105 | bool remoteDirList(const QString &); |
105 | bool remoteChDir(const QString &); | 106 | bool remoteChDir(const QString &); |
106 | 107 | ||
107 | void tabChanged(QWidget*); | 108 | void tabChanged(QWidget*); |
108 | void cleanUp(); | 109 | void cleanUp(); |
109 | 110 | ||
110 | void remoteRename(); | 111 | void remoteRename(); |
111 | void localRename(); | 112 | void localRename(); |
112 | 113 | ||
113 | void currentPathComboChanged(); | 114 | void currentPathComboChanged(); |
114 | void currentPathComboActivated(const QString &); | 115 | void currentPathComboActivated(const QString &); |
115 | void switchToLocalTab(); | 116 | void switchToLocalTab(); |
116 | void switchToRemoteTab(); | 117 | void switchToRemoteTab(); |
117 | void switchToConfigTab(); | 118 | void switchToConfigTab(); |
118 | 119 | ||
119 | void fillCombos(); | 120 | void fillCombos(); |
120 | void clearCombos(); | 121 | void clearCombos(); |
121 | void fillRemoteCombo(const QString&); | 122 | void fillRemoteCombo(const QString&); |
122 | void fillCombo(const QString &); | 123 | void fillCombo(const QString &); |
123 | void serverComboSelected(int); | 124 | void serverComboSelected(int); |
124 | void deleteServer(); | 125 | void deleteServer(); |
125 | void connectorBtnToggled(bool); | 126 | void connectorBtnToggled(bool); |
126 | void NewServer(); | 127 | void NewServer(); |
127 | void serverListClicked( const QString &); | 128 | void serverListClicked( const QString &); |
128 | 129 | ||
129 | protected: | 130 | protected: |
131 | QPixmap unknownXpm; | ||
130 | bool fuckeduphack; | 132 | bool fuckeduphack; |
131 | QStringList remoteDirPathStringList, localDirPathStringList; | 133 | QStringList remoteDirPathStringList, localDirPathStringList; |
132 | QString newServerName; | 134 | QString newServerName; |
133 | void nullifyCallBack(); | 135 | void nullifyCallBack(); |
134 | QGridLayout* tabLayout; | 136 | QGridLayout* tabLayout; |
135 | QGridLayout* tabLayout_2; | 137 | QGridLayout* tabLayout_2; |
136 | QGridLayout* tabLayout_3; | 138 | QGridLayout* tabLayout_3; |
137 | 139 | ||
138 | }; | 140 | }; |
139 | 141 | ||
140 | #endif // OPIEFTP_H | 142 | #endif // OPIEFTP_H |