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