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