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