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