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