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