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