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