author | llornkcor <llornkcor> | 2002-03-24 17:03:37 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-24 17:03:37 (UTC) |
commit | 6ce8bbff9eb16e0d731755010bda63e7fb43f70b (patch) (unidiff) | |
tree | 0f3cf5476398743f86fa6d884d86751a7251df3e | |
parent | 368d5032f4ff4566dea1e99aa2bb782300e0bfd5 (diff) | |
download | opie-6ce8bbff9eb16e0d731755010bda63e7fb43f70b.zip opie-6ce8bbff9eb16e0d731755010bda63e7fb43f70b.tar.gz opie-6ce8bbff9eb16e0d731755010bda63e7fb43f70b.tar.bz2 |
config last server on startup
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index e2a6cad..e97a9bf 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -58,301 +58,304 @@ static int log_progress(netbuf *ctl, int xfered, void *arg) | |||
58 | int pct = (xfered * 100) / fsz; | 58 | int pct = (xfered * 100) / fsz; |
59 | // printf("%3d%%\r", pct); | 59 | // printf("%3d%%\r", pct); |
60 | // fflush(stdout); | 60 | // fflush(stdout); |
61 | ProgressBar->setProgress(xfered); | 61 | ProgressBar->setProgress(xfered); |
62 | qApp->processEvents(); | 62 | qApp->processEvents(); |
63 | return 1; | 63 | return 1; |
64 | } | 64 | } |
65 | 65 | ||
66 | OpieFtp::OpieFtp( ) | 66 | OpieFtp::OpieFtp( ) |
67 | : QMainWindow( ) | 67 | : QMainWindow( ) |
68 | { | 68 | { |
69 | setCaption( tr( "OpieFtp" ) ); | 69 | setCaption( tr( "OpieFtp" ) ); |
70 | 70 | ||
71 | QGridLayout *layout = new QGridLayout( this ); | 71 | QGridLayout *layout = new QGridLayout( this ); |
72 | layout->setSpacing( 2); | 72 | layout->setSpacing( 2); |
73 | layout->setMargin( 2); | 73 | layout->setMargin( 2); |
74 | 74 | ||
75 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 75 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
76 | 76 | ||
77 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 77 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
78 | connectionMenu = new QPopupMenu( this ); | 78 | connectionMenu = new QPopupMenu( this ); |
79 | localMenu = new QPopupMenu( this ); | 79 | localMenu = new QPopupMenu( this ); |
80 | remoteMenu = new QPopupMenu( this ); | 80 | remoteMenu = new QPopupMenu( this ); |
81 | tabMenu = new QPopupMenu( this ); | 81 | tabMenu = new QPopupMenu( this ); |
82 | 82 | ||
83 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); | 83 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); |
84 | 84 | ||
85 | menuBar->insertItem( tr( "Connection" ), connectionMenu); | 85 | menuBar->insertItem( tr( "Connection" ), connectionMenu); |
86 | menuBar->insertItem( tr( "Local" ), localMenu); | 86 | menuBar->insertItem( tr( "Local" ), localMenu); |
87 | menuBar->insertItem( tr( "Remote" ), remoteMenu); | 87 | menuBar->insertItem( tr( "Remote" ), remoteMenu); |
88 | menuBar->insertItem( tr( "View" ), tabMenu); | 88 | menuBar->insertItem( tr( "View" ), tabMenu); |
89 | 89 | ||
90 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 90 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
91 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 91 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
92 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 92 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
93 | 93 | ||
94 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 94 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
95 | localMenu->insertSeparator(); | 95 | localMenu->insertSeparator(); |
96 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 96 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
97 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 97 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
98 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 98 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
99 | localMenu->insertSeparator(); | 99 | localMenu->insertSeparator(); |
100 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 100 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
101 | localMenu->setCheckable(TRUE); | 101 | localMenu->setCheckable(TRUE); |
102 | 102 | ||
103 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 103 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
104 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 104 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
105 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 105 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
106 | remoteMenu->insertSeparator(); | 106 | remoteMenu->insertSeparator(); |
107 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 107 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
108 | 108 | ||
109 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 109 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
110 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 110 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
111 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); | 111 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); |
112 | tabMenu->setCheckable(TRUE); | 112 | tabMenu->setCheckable(TRUE); |
113 | 113 | ||
114 | TabWidget = new QTabWidget( this, "TabWidget" ); | 114 | TabWidget = new QTabWidget( this, "TabWidget" ); |
115 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); | 115 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); |
116 | 116 | ||
117 | TabWidget->setTabShape(QTabWidget::Triangular); | 117 | TabWidget->setTabShape(QTabWidget::Triangular); |
118 | 118 | ||
119 | tab = new QWidget( TabWidget, "tab" ); | 119 | tab = new QWidget( TabWidget, "tab" ); |
120 | tabLayout = new QGridLayout( tab ); | 120 | tabLayout = new QGridLayout( tab ); |
121 | tabLayout->setSpacing( 2); | 121 | tabLayout->setSpacing( 2); |
122 | tabLayout->setMargin( 2); | 122 | tabLayout->setMargin( 2); |
123 | 123 | ||
124 | Local_View = new QListView( tab, "Local_View" ); | 124 | Local_View = new QListView( tab, "Local_View" ); |
125 | // Local_View->setResizePolicy( QListView::AutoOneFit ); | 125 | // Local_View->setResizePolicy( QListView::AutoOneFit ); |
126 | Local_View->addColumn( tr("File"),120); | 126 | Local_View->addColumn( tr("File"),120); |
127 | Local_View->addColumn( tr("Size"),-1); | 127 | Local_View->addColumn( tr("Size"),-1); |
128 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 128 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
129 | Local_View->addColumn( tr("Date"),-1); | 129 | Local_View->addColumn( tr("Date"),-1); |
130 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 130 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
131 | Local_View->setAllColumnsShowFocus(TRUE); | 131 | Local_View->setAllColumnsShowFocus(TRUE); |
132 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 132 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
133 | 133 | ||
134 | tabLayout->addWidget( Local_View, 0, 0 ); | 134 | tabLayout->addWidget( Local_View, 0, 0 ); |
135 | 135 | ||
136 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 136 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
137 | this,SLOT( localListClicked(QListViewItem *)) ); | 137 | this,SLOT( localListClicked(QListViewItem *)) ); |
138 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 138 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
139 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 139 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
140 | 140 | ||
141 | TabWidget->insertTab( tab, tr( "Local" ) ); | 141 | TabWidget->insertTab( tab, tr( "Local" ) ); |
142 | 142 | ||
143 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 143 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
144 | tabLayout_2 = new QGridLayout( tab_2 ); | 144 | tabLayout_2 = new QGridLayout( tab_2 ); |
145 | tabLayout_2->setSpacing( 2); | 145 | tabLayout_2->setSpacing( 2); |
146 | tabLayout_2->setMargin( 2); | 146 | tabLayout_2->setMargin( 2); |
147 | 147 | ||
148 | Remote_View = new QListView( tab_2, "Remote_View" ); | 148 | Remote_View = new QListView( tab_2, "Remote_View" ); |
149 | Remote_View->addColumn( tr("File"),120); | 149 | Remote_View->addColumn( tr("File"),120); |
150 | Remote_View->addColumn( tr("Size"),-1); | 150 | Remote_View->addColumn( tr("Size"),-1); |
151 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 151 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
152 | Remote_View->addColumn( tr("Date"),-1); | 152 | Remote_View->addColumn( tr("Date"),-1); |
153 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 153 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
154 | Remote_View->addColumn( tr("Dir"),-1); | ||
155 | Remote_View->setColumnAlignment(4,QListView::AlignRight); | ||
154 | Remote_View->setAllColumnsShowFocus(TRUE); | 156 | Remote_View->setAllColumnsShowFocus(TRUE); |
155 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 157 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
156 | 158 | ||
157 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 159 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
158 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 160 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
159 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 161 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
160 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 162 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
161 | 163 | ||
162 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 164 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
163 | 165 | ||
164 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); | 166 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); |
165 | 167 | ||
166 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 168 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
167 | tabLayout_3 = new QGridLayout( tab_3 ); | 169 | tabLayout_3 = new QGridLayout( tab_3 ); |
168 | tabLayout_3->setSpacing( 2); | 170 | tabLayout_3->setSpacing( 2); |
169 | tabLayout_3->setMargin( 2); | 171 | tabLayout_3->setMargin( 2); |
170 | 172 | ||
171 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); | 173 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); |
172 | TextLabel1->setText( tr( "Username" ) ); | 174 | TextLabel1->setText( tr( "Username" ) ); |
173 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); | 175 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); |
174 | 176 | ||
175 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); | 177 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); |
176 | UsernameComboBox->setEditable(TRUE); | 178 | UsernameComboBox->setEditable(TRUE); |
177 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); | 179 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); |
178 | 180 | ||
179 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 181 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
180 | TextLabel2->setText( tr( "Password" ) ); | 182 | TextLabel2->setText( tr( "Password" ) ); |
181 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); | 183 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); |
182 | 184 | ||
183 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); | 185 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); |
184 | PasswordEdit->setEchoMode(QLineEdit::Password); | 186 | PasswordEdit->setEchoMode(QLineEdit::Password); |
185 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); | 187 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); |
186 | 188 | ||
187 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); | 189 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); |
188 | TextLabel3->setText( tr( "Remote server" ) ); | 190 | TextLabel3->setText( tr( "Remote server" ) ); |
189 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); | 191 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); |
190 | 192 | ||
191 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); | 193 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); |
192 | ServerComboBox->setEditable(TRUE); | 194 | ServerComboBox->setEditable(TRUE); |
193 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); | 195 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); |
194 | 196 | ||
195 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); | 197 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); |
196 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); | 198 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); |
197 | 199 | ||
198 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); | 200 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); |
199 | TextLabel5->setText( tr( "Remote path" ) ); | 201 | TextLabel5->setText( tr( "Remote path" ) ); |
200 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); | 202 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); |
201 | 203 | ||
202 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 204 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
203 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | 205 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); |
204 | 206 | ||
205 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 207 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
206 | TextLabel4->setText( tr( "Port" ) ); | 208 | TextLabel4->setText( tr( "Port" ) ); |
207 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); | 209 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); |
208 | 210 | ||
209 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); | 211 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); |
210 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 212 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
211 | PortSpinBox->setMaxValue(32786); | 213 | PortSpinBox->setMaxValue(32786); |
212 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); | 214 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); |
213 | 215 | ||
214 | QPushButton *deleteServerBtn; | 216 | QPushButton *deleteServerBtn; |
215 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); | 217 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); |
216 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); | 218 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); |
217 | 219 | ||
218 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); | 220 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); |
219 | 221 | ||
220 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); | 222 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); |
221 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); | 223 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); |
222 | connectServerBtn->setToggleButton(TRUE); | 224 | connectServerBtn->setToggleButton(TRUE); |
223 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); | 225 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); |
224 | 226 | ||
225 | 227 | ||
226 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 228 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
227 | tabLayout_3->addItem( spacer, 5, 0 ); | 229 | tabLayout_3->addItem( spacer, 5, 0 ); |
228 | 230 | ||
229 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 231 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
230 | 232 | ||
231 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 233 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
232 | this,SLOT(tabChanged(QWidget*))); | 234 | this,SLOT(tabChanged(QWidget*))); |
233 | 235 | ||
234 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 236 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
235 | currentDir.setPath( QDir::currentDirPath()); | 237 | currentDir.setPath( QDir::currentDirPath()); |
236 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 238 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
237 | currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); | 239 | currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); |
238 | layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); | 240 | layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); |
239 | 241 | ||
240 | currentPathEdit->setText( currentDir.canonicalPath()); | 242 | currentPathEdit->setText( currentDir.canonicalPath()); |
241 | connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); | 243 | connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); |
242 | 244 | ||
243 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 245 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
244 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); | 246 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); |
245 | 247 | ||
246 | serverComboSelected(0); | 248 | // fillCombos(); |
247 | fillCombos(); | ||
248 | 249 | ||
249 | #ifdef DEVELOPERS_VERSION | 250 | #ifdef DEVELOPERS_VERSION |
250 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 251 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); |
251 | UsernameComboBox->lineEdit()->setText("root"); | 252 | UsernameComboBox->lineEdit()->setText("root"); |
252 | PortSpinBox->setValue( 4242); | 253 | PortSpinBox->setValue( 4242); |
253 | remotePath->setText( currentRemoteDir = "/"); | 254 | remotePath->setText( currentRemoteDir = "/"); |
254 | // ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); | 255 | // ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); |
255 | // UsernameComboBox->lineEdit()->setText("llornkcor"); | 256 | // UsernameComboBox->lineEdit()->setText("llornkcor"); |
256 | // PortSpinBox->setValue( 21); | 257 | // PortSpinBox->setValue( 21); |
257 | // remotePath->setText( currentRemoteDir = "/home/llornkcor"); | 258 | // remotePath->setText( currentRemoteDir = "/home/llornkcor"); |
258 | PasswordEdit->setText( tr( "" ) ); | 259 | PasswordEdit->setText( tr( "" ) ); |
259 | #endif | 260 | #endif |
260 | filterStr="*"; | 261 | filterStr="*"; |
261 | b=FALSE; | 262 | b=FALSE; |
262 | populateLocalView(); | 263 | populateLocalView(); |
264 | readConfig(); | ||
265 | ServerComboBox->setCurrentItem(currentServerConfig); | ||
263 | TabWidget->setCurrentPage(2); | 266 | TabWidget->setCurrentPage(2); |
264 | } | 267 | } |
265 | 268 | ||
266 | OpieFtp::~OpieFtp() | 269 | OpieFtp::~OpieFtp() |
267 | { | 270 | { |
268 | } | 271 | } |
269 | 272 | ||
270 | void OpieFtp::cleanUp() | 273 | void OpieFtp::cleanUp() |
271 | { | 274 | { |
272 | if(conn) | 275 | if(conn) |
273 | FtpQuit(conn); | 276 | FtpQuit(conn); |
274 | QString sfile=QDir::homeDirPath(); | 277 | QString sfile=QDir::homeDirPath(); |
275 | if(sfile.right(1) != "/") | 278 | if(sfile.right(1) != "/") |
276 | sfile+="/._temp"; | 279 | sfile+="/._temp"; |
277 | else | 280 | else |
278 | sfile+="._temp"; | 281 | sfile+="._temp"; |
279 | QFile file( sfile); | 282 | QFile file( sfile); |
280 | if(file.exists()) | 283 | if(file.exists()) |
281 | file.remove(); | 284 | file.remove(); |
282 | } | 285 | } |
283 | 286 | ||
284 | void OpieFtp::tabChanged(QWidget *w) | 287 | void OpieFtp::tabChanged(QWidget *w) |
285 | { | 288 | { |
286 | if (TabWidget->currentPageIndex() == 0) { | 289 | if (TabWidget->currentPageIndex() == 0) { |
287 | currentPathEdit->setText( currentDir.canonicalPath()); | 290 | currentPathEdit->setText( currentDir.canonicalPath()); |
288 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); | 291 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); |
289 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 292 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
290 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 293 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
291 | } | 294 | } |
292 | if (TabWidget->currentPageIndex() == 1) { | 295 | if (TabWidget->currentPageIndex() == 1) { |
293 | currentPathEdit->setText( currentRemoteDir ); | 296 | currentPathEdit->setText( currentRemoteDir ); |
294 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); | 297 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); |
295 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 298 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
296 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 299 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
297 | } | 300 | } |
298 | if (TabWidget->currentPageIndex() == 2) { | 301 | if (TabWidget->currentPageIndex() == 2) { |
299 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); | 302 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); |
300 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 303 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
301 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 304 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
302 | } | 305 | } |
303 | } | 306 | } |
304 | 307 | ||
305 | void OpieFtp::newConnection() | 308 | void OpieFtp::newConnection() |
306 | { | 309 | { |
307 | UsernameComboBox->lineEdit()->setText(""); | 310 | UsernameComboBox->lineEdit()->setText(""); |
308 | PasswordEdit->setText( "" ); | 311 | PasswordEdit->setText( "" ); |
309 | ServerComboBox->lineEdit()->setText( ""); | 312 | ServerComboBox->lineEdit()->setText( ""); |
310 | remotePath->setText( currentRemoteDir = "/"); | 313 | remotePath->setText( currentRemoteDir = "/"); |
311 | PortSpinBox->setValue( 21); | 314 | PortSpinBox->setValue( 21); |
312 | TabWidget->setCurrentPage(2); | 315 | TabWidget->setCurrentPage(2); |
313 | currentServerConfig = -1; | 316 | currentServerConfig = -1; |
314 | } | 317 | } |
315 | 318 | ||
316 | void OpieFtp::serverComboEdited(const QString & edit) { | 319 | void OpieFtp::serverComboEdited(const QString & edit) { |
317 | if( !edit.isEmpty() ) { | 320 | if( !edit.isEmpty() ) { |
318 | currentServerConfig = -1; | 321 | currentServerConfig = -1; |
319 | qDebug("comboedited"); | 322 | qDebug("comboedited"); |
320 | } | 323 | } |
321 | } | 324 | } |
322 | 325 | ||
323 | void OpieFtp::connectorBtnToggled(bool On) | 326 | void OpieFtp::connectorBtnToggled(bool On) |
324 | { | 327 | { |
325 | if(On) { | 328 | if(On) { |
326 | connector(); | 329 | connector(); |
327 | } else { | 330 | } else { |
328 | disConnector(); | 331 | disConnector(); |
329 | } | 332 | } |
330 | 333 | ||
331 | } | 334 | } |
332 | 335 | ||
333 | void OpieFtp::connector() | 336 | void OpieFtp::connector() |
334 | { | 337 | { |
335 | QCopEnvelope ( "QPE/System", "busy()" ); | 338 | QCopEnvelope ( "QPE/System", "busy()" ); |
336 | // qApp->processEvents(); | 339 | // qApp->processEvents(); |
337 | currentRemoteDir=remotePath->text(); | 340 | currentRemoteDir=remotePath->text(); |
338 | if(ServerComboBox->currentText().isEmpty()) { | 341 | if(ServerComboBox->currentText().isEmpty()) { |
339 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); | 342 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); |
340 | TabWidget->setCurrentPage(2); | 343 | TabWidget->setCurrentPage(2); |
341 | ServerComboBox->setFocus(); | 344 | ServerComboBox->setFocus(); |
342 | connectServerBtn->setOn(FALSE); | 345 | connectServerBtn->setOn(FALSE); |
343 | connectServerBtn->setText( tr("Connect")); | 346 | connectServerBtn->setText( tr("Connect")); |
344 | return; | 347 | return; |
345 | } | 348 | } |
346 | FtpInit(); | 349 | FtpInit(); |
347 | TabWidget->setCurrentPage(1); | 350 | TabWidget->setCurrentPage(1); |
348 | QString ftp_host = ServerComboBox->currentText(); | 351 | QString ftp_host = ServerComboBox->currentText(); |
349 | QString ftp_user = UsernameComboBox->currentText(); | 352 | QString ftp_user = UsernameComboBox->currentText(); |
350 | QString ftp_pass = PasswordEdit->text(); | 353 | QString ftp_pass = PasswordEdit->text(); |
351 | QString port=PortSpinBox->cleanText(); | 354 | QString port=PortSpinBox->cleanText(); |
352 | port.stripWhiteSpace(); | 355 | port.stripWhiteSpace(); |
353 | 356 | ||
354 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) | 357 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) |
355 | ftp_host=ftp_host.right(ftp_host.length()-6); | 358 | ftp_host=ftp_host.right(ftp_host.length()-6); |
356 | ftp_host+=":"+port; | 359 | ftp_host+=":"+port; |
357 | if (!FtpConnect( ftp_host.latin1(), &conn)) { | 360 | if (!FtpConnect( ftp_host.latin1(), &conn)) { |
358 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); | 361 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); |
@@ -488,215 +491,216 @@ bool OpieFtp::remoteDirList(const QString &dir) | |||
488 | msg.replace(QRegExp(":"),"\n"); | 491 | msg.replace(QRegExp(":"),"\n"); |
489 | QMessageBox::message(tr("Note"),msg); | 492 | QMessageBox::message(tr("Note"),msg); |
490 | return false; | 493 | return false; |
491 | } | 494 | } |
492 | populateRemoteView() ; | 495 | populateRemoteView() ; |
493 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 496 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
494 | return true; | 497 | return true; |
495 | } | 498 | } |
496 | 499 | ||
497 | bool OpieFtp::remoteChDir(const QString &dir) | 500 | bool OpieFtp::remoteChDir(const QString &dir) |
498 | { | 501 | { |
499 | QCopEnvelope ( "QPE/System", "busy()" ); | 502 | QCopEnvelope ( "QPE/System", "busy()" ); |
500 | if (!FtpChdir( dir.latin1(), conn )) { | 503 | if (!FtpChdir( dir.latin1(), conn )) { |
501 | QString msg; | 504 | QString msg; |
502 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); | 505 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); |
503 | msg.replace(QRegExp(":"),"\n"); | 506 | msg.replace(QRegExp(":"),"\n"); |
504 | QMessageBox::message(tr("Note"),msg); | 507 | QMessageBox::message(tr("Note"),msg); |
505 | qDebug(msg); | 508 | qDebug(msg); |
506 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 509 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
507 | return FALSE; | 510 | return FALSE; |
508 | } | 511 | } |
509 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 512 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
510 | return TRUE; | 513 | return TRUE; |
511 | } | 514 | } |
512 | 515 | ||
513 | void OpieFtp::populateLocalView() | 516 | void OpieFtp::populateLocalView() |
514 | { | 517 | { |
515 | Local_View->clear(); | 518 | Local_View->clear(); |
516 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 519 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
517 | currentDir.setMatchAllDirs(TRUE); | 520 | currentDir.setMatchAllDirs(TRUE); |
518 | currentDir.setNameFilter(filterStr); | 521 | currentDir.setNameFilter(filterStr); |
519 | QString fileL, fileS, fileDate; | 522 | QString fileL, fileS, fileDate; |
520 | bool isDir=FALSE; | 523 | bool isDir=FALSE; |
521 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 524 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
522 | QFileInfoListIterator it(*list); | 525 | QFileInfoListIterator it(*list); |
523 | QFileInfo *fi; | 526 | QFileInfo *fi; |
524 | while ( (fi=it.current()) ) { | 527 | while ( (fi=it.current()) ) { |
525 | if (fi->isSymLink() ){ | 528 | if (fi->isSymLink() ){ |
526 | QString symLink=fi->readLink(); | 529 | QString symLink=fi->readLink(); |
527 | // qDebug("Symlink detected "+symLink); | 530 | // qDebug("Symlink detected "+symLink); |
528 | QFileInfo sym( symLink); | 531 | QFileInfo sym( symLink); |
529 | fileS.sprintf( "%10li", sym.size() ); | 532 | fileS.sprintf( "%10li", sym.size() ); |
530 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 533 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
531 | fileDate = sym.lastModified().toString(); | 534 | fileDate = sym.lastModified().toString(); |
532 | } else { | 535 | } else { |
533 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 536 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
534 | fileS.sprintf( "%10li", fi->size() ); | 537 | fileS.sprintf( "%10li", fi->size() ); |
535 | fileL.sprintf( "%s",fi->fileName().data() ); | 538 | fileL.sprintf( "%s",fi->fileName().data() ); |
536 | fileDate= fi->lastModified().toString(); | 539 | fileDate= fi->lastModified().toString(); |
537 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 540 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
538 | fileL+="/"; | 541 | fileL+="/"; |
539 | isDir=TRUE; | 542 | isDir=TRUE; |
540 | // qDebug( fileL); | 543 | // qDebug( fileL); |
541 | } | 544 | } |
542 | } | 545 | } |
543 | if(fileL !="./") { | 546 | if(fileL !="./") { |
544 | item = new QListViewItem( Local_View,fileL,fileS, fileDate); | 547 | item = new QListViewItem( Local_View,fileL,fileS, fileDate); |
545 | if(isDir || fileL.find("/",0,TRUE) != -1) | 548 | if(isDir || fileL.find("/",0,TRUE) != -1) |
546 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 549 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
547 | else | 550 | else |
548 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 551 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
549 | } | 552 | } |
550 | isDir=FALSE; | 553 | isDir=FALSE; |
551 | ++it; | 554 | ++it; |
552 | } | 555 | } |
553 | Local_View->setSorting( 3,FALSE); | 556 | Local_View->setSorting( 3,FALSE); |
554 | currentPathEdit->setText( currentDir.canonicalPath() ); | 557 | currentPathEdit->setText( currentDir.canonicalPath() ); |
555 | } | 558 | } |
556 | 559 | ||
557 | bool OpieFtp::populateRemoteView( ) | 560 | bool OpieFtp::populateRemoteView( ) |
558 | { | 561 | { |
559 | // qDebug("populate remoteview"); | 562 | // qDebug("populate remoteview"); |
560 | QString sfile=QDir::homeDirPath(); | 563 | QString sfile=QDir::homeDirPath(); |
561 | if(sfile.right(1) != "/") | 564 | if(sfile.right(1) != "/") |
562 | sfile+="/._temp"; | 565 | sfile+="/._temp"; |
563 | else | 566 | else |
564 | sfile+="._temp"; | 567 | sfile+="._temp"; |
565 | QFile file( sfile); | 568 | QFile file( sfile); |
566 | Remote_View->clear(); | 569 | Remote_View->clear(); |
567 | QString s, File_Name; | 570 | QString s, File_Name; |
568 | QListViewItem *itemDir=NULL, *itemFile=NULL; | 571 | QListViewItem *itemDir=NULL, *itemFile=NULL; |
569 | QString fileL, fileS, fileDate; | 572 | QString fileL, fileS, fileDate; |
570 | if ( file.open(IO_ReadOnly)) { | 573 | if ( file.open(IO_ReadOnly)) { |
571 | QTextStream t( &file ); // use a text stream | 574 | QTextStream t( &file ); // use a text stream |
572 | while ( !t.eof()) { | 575 | while ( !t.eof()) { |
573 | s = t.readLine(); | 576 | s = t.readLine(); |
574 | fileL = s.right(s.length()-55); | 577 | fileL = s.right(s.length()-55); |
575 | fileL = fileL.stripWhiteSpace(); | 578 | fileL = fileL.stripWhiteSpace(); |
576 | if(s.left(1) == "d") | 579 | if(s.left(1) == "d") |
577 | fileL = fileL+"/"; | 580 | fileL = fileL+"/"; |
578 | // fileL = "/"+fileL+"/"; | 581 | // fileL = "/"+fileL+"/"; |
579 | fileS = s.mid( 30, 42-30); | 582 | fileS = s.mid( 30, 42-30); |
580 | fileS = fileS.stripWhiteSpace(); | 583 | fileS = fileS.stripWhiteSpace(); |
581 | fileDate = s.mid( 42, 55-42); | 584 | fileDate = s.mid( 42, 55-42); |
582 | fileDate = fileDate.stripWhiteSpace(); | 585 | fileDate = fileDate.stripWhiteSpace(); |
583 | if(fileL.find("total",0,TRUE) == -1) { | 586 | if(fileL.find("total",0,TRUE) == -1) { |
584 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate); | ||
585 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { | 587 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { |
588 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); | ||
586 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 589 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
587 | if(itemDir) | 590 | // if(itemDir) |
588 | item->moveItem(itemDir); | 591 | item->moveItem(itemDir); |
589 | itemDir=item; | 592 | itemDir=item; |
590 | } else { | 593 | } else { |
594 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); | ||
591 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 595 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
592 | if(itemFile) | 596 | // if(itemFile) |
597 | item->moveItem(itemDir); | ||
593 | item->moveItem(itemFile); | 598 | item->moveItem(itemFile); |
594 | itemFile=item; | 599 | itemFile=item; |
595 | } | 600 | } |
596 | } | 601 | } |
597 | } | 602 | } |
598 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 603 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
599 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 604 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
600 | file.close(); | 605 | file.close(); |
601 | if( file.exists()) | 606 | if( file.exists()) |
602 | file. remove(); | 607 | file. remove(); |
603 | } else | 608 | } else |
604 | qDebug("temp file not opened successfullly "+sfile); | 609 | qDebug("temp file not opened successfullly "+sfile); |
605 | Remote_View->setSorting( 4,TRUE); | 610 | Remote_View->setSorting( 4,TRUE); |
606 | |||
607 | return true; | 611 | return true; |
608 | } | 612 | } |
609 | 613 | ||
610 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 614 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
611 | { | 615 | { |
612 | QCopEnvelope ( "QPE/System", "busy()" ); | 616 | QCopEnvelope ( "QPE/System", "busy()" ); |
613 | QString oldRemoteCurrentDir = currentRemoteDir; | 617 | QString oldRemoteCurrentDir = currentRemoteDir; |
614 | QString strItem=selectedItem->text(0); | 618 | QString strItem=selectedItem->text(0); |
615 | strItem=strItem.simplifyWhiteSpace(); | 619 | strItem=strItem.simplifyWhiteSpace(); |
616 | if(strItem == "../") { // the user wants to go ^ | 620 | if(strItem == "../") { // the user wants to go ^ |
617 | if( FtpCDUp( conn) == 0) { | 621 | if( FtpCDUp( conn) == 0) { |
618 | QString msg; | 622 | QString msg; |
619 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 623 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
620 | msg.replace(QRegExp(":"),"\n"); | 624 | msg.replace(QRegExp(":"),"\n"); |
621 | QMessageBox::message(tr("Note"),msg); | 625 | QMessageBox::message(tr("Note"),msg); |
622 | qDebug(msg); | 626 | qDebug(msg); |
623 | } | 627 | } |
624 | char path[256]; | 628 | char path[256]; |
625 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 629 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
626 | QString msg; | 630 | QString msg; |
627 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 631 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
628 | msg.replace(QRegExp(":"),"\n"); | 632 | msg.replace(QRegExp(":"),"\n"); |
629 | QMessageBox::message(tr("Note"),msg); | 633 | QMessageBox::message(tr("Note"),msg); |
630 | qDebug(msg); | 634 | qDebug(msg); |
631 | } | 635 | } |
632 | currentRemoteDir=path; | 636 | currentRemoteDir=path; |
633 | } else { | 637 | } else { |
634 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 638 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
635 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 639 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
636 | strItem = strItem.stripWhiteSpace(); | 640 | strItem = strItem.stripWhiteSpace(); |
637 | currentRemoteDir = strItem; | 641 | currentRemoteDir = strItem; |
638 | if( !remoteChDir( (const QString &)strItem)) { | 642 | if( !remoteChDir( (const QString &)strItem)) { |
639 | currentRemoteDir = oldRemoteCurrentDir; | 643 | currentRemoteDir = oldRemoteCurrentDir; |
640 | strItem=""; | 644 | strItem=""; |
641 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 645 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
642 | } | 646 | } |
643 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 647 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
644 | qDebug("trying directory"); | 648 | qDebug("trying directory"); |
645 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 649 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
646 | currentRemoteDir = oldRemoteCurrentDir; | 650 | currentRemoteDir = oldRemoteCurrentDir; |
647 | strItem=""; | 651 | strItem=""; |
648 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 652 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
649 | 653 | ||
650 | } else { | 654 | } else { |
651 | currentRemoteDir = currentRemoteDir+strItem; | 655 | currentRemoteDir = currentRemoteDir+strItem; |
652 | } | 656 | } |
653 | } else { | 657 | } else { |
654 | qDebug("download "+strItem); | 658 | qDebug("download "+strItem); |
655 | } | 659 | } |
656 | } | 660 | } |
657 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 661 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
658 | if(currentRemoteDir.right(1) !="/") | 662 | if(currentRemoteDir.right(1) !="/") |
659 | currentRemoteDir +="/"; | 663 | currentRemoteDir +="/"; |
660 | currentPathEdit->setText( currentRemoteDir ); | 664 | currentPathEdit->setText( currentRemoteDir ); |
661 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 665 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
662 | } | 666 | } |
663 | 667 | ||
664 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 668 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
665 | { | 669 | { |
666 | QString strItem=selectedItem->text(0); | 670 | QString strItem=selectedItem->text(0); |
667 | QString strSize=selectedItem->text(1); | 671 | QString strSize=selectedItem->text(1); |
668 | strSize=strSize.stripWhiteSpace(); | 672 | strSize=strSize.stripWhiteSpace(); |
669 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 673 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
670 | // is symlink | 674 | // is symlink |
671 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 675 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
672 | if(QDir(strItem2).exists() ) { | 676 | if(QDir(strItem2).exists() ) { |
673 | currentDir.cd(strItem2, TRUE); | 677 | currentDir.cd(strItem2, TRUE); |
674 | populateLocalView(); | 678 | populateLocalView(); |
675 | } | 679 | } |
676 | } else { // not a symlink | 680 | } else { // not a symlink |
677 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 681 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
678 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 682 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
679 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 683 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
680 | currentDir.cd(strItem,FALSE); | 684 | currentDir.cd(strItem,FALSE); |
681 | populateLocalView(); | 685 | populateLocalView(); |
682 | } else { | 686 | } else { |
683 | currentDir.cdUp(); | 687 | currentDir.cdUp(); |
684 | populateLocalView(); | 688 | populateLocalView(); |
685 | } | 689 | } |
686 | if(QDir(strItem).exists()){ | 690 | if(QDir(strItem).exists()){ |
687 | currentDir.cd(strItem, TRUE); | 691 | currentDir.cd(strItem, TRUE); |
688 | populateLocalView(); | 692 | populateLocalView(); |
689 | } | 693 | } |
690 | } else { | 694 | } else { |
691 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 695 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
692 | if( QFile::exists(strItem ) ) { | 696 | if( QFile::exists(strItem ) ) { |
693 | qDebug("upload "+strItem); | 697 | qDebug("upload "+strItem); |
694 | } | 698 | } |
695 | } //end not symlink | 699 | } //end not symlink |
696 | chdir(strItem.latin1()); | 700 | chdir(strItem.latin1()); |
697 | } | 701 | } |
698 | } | 702 | } |
699 | 703 | ||
700 | void OpieFtp::doLocalCd() | 704 | void OpieFtp::doLocalCd() |
701 | { | 705 | { |
702 | localListClicked( Local_View->currentItem()); | 706 | localListClicked( Local_View->currentItem()); |
@@ -879,238 +883,222 @@ void OpieFtp::remoteDelete() | |||
879 | if(FtpDelete( path.latin1(), conn)==0) { | 883 | if(FtpDelete( path.latin1(), conn)==0) { |
880 | QString msg; | 884 | QString msg; |
881 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); | 885 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); |
882 | msg.replace(QRegExp(":"),"\n"); | 886 | msg.replace(QRegExp(":"),"\n"); |
883 | QMessageBox::message(tr("Note"),msg); | 887 | QMessageBox::message(tr("Note"),msg); |
884 | } | 888 | } |
885 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 889 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
886 | } | 890 | } |
887 | break; | 891 | break; |
888 | }; | 892 | }; |
889 | } | 893 | } |
890 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 894 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
891 | } | 895 | } |
892 | 896 | ||
893 | void OpieFtp::remoteRename() | 897 | void OpieFtp::remoteRename() |
894 | { | 898 | { |
895 | QString curFile = Remote_View->currentItem()->text(0); | 899 | QString curFile = Remote_View->currentItem()->text(0); |
896 | InputDialog *fileDlg; | 900 | InputDialog *fileDlg; |
897 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 901 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
898 | fileDlg->inputText = curFile; | 902 | fileDlg->inputText = curFile; |
899 | fileDlg->exec(); | 903 | fileDlg->exec(); |
900 | if( fileDlg->result() == 1 ) { | 904 | if( fileDlg->result() == 1 ) { |
901 | QString oldName = currentRemoteDir +"/"+ curFile; | 905 | QString oldName = currentRemoteDir +"/"+ curFile; |
902 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; | 906 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; |
903 | QCopEnvelope ( "QPE/System", "busy()" ); | 907 | QCopEnvelope ( "QPE/System", "busy()" ); |
904 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { | 908 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { |
905 | QString msg; | 909 | QString msg; |
906 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); | 910 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); |
907 | msg.replace(QRegExp(":"),"\n"); | 911 | msg.replace(QRegExp(":"),"\n"); |
908 | QMessageBox::message(tr("Note"),msg); | 912 | QMessageBox::message(tr("Note"),msg); |
909 | } | 913 | } |
910 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 914 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
911 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 915 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
912 | } | 916 | } |
913 | } | 917 | } |
914 | 918 | ||
915 | void OpieFtp::localRename() | 919 | void OpieFtp::localRename() |
916 | { | 920 | { |
917 | QString curFile = Local_View->currentItem()->text(0); | 921 | QString curFile = Local_View->currentItem()->text(0); |
918 | InputDialog *fileDlg; | 922 | InputDialog *fileDlg; |
919 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 923 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
920 | fileDlg->inputText = curFile; | 924 | fileDlg->inputText = curFile; |
921 | fileDlg->exec(); | 925 | fileDlg->exec(); |
922 | if( fileDlg->result() == 1 ) { | 926 | if( fileDlg->result() == 1 ) { |
923 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 927 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
924 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 928 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
925 | if( rename(oldname.latin1(), newName.latin1())== -1) | 929 | if( rename(oldname.latin1(), newName.latin1())== -1) |
926 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 930 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
927 | } | 931 | } |
928 | populateLocalView(); | 932 | populateLocalView(); |
929 | } | 933 | } |
930 | 934 | ||
931 | void OpieFtp::currentPathEditChanged() | 935 | void OpieFtp::currentPathEditChanged() |
932 | { | 936 | { |
933 | QString oldRemoteCurrentDir = currentRemoteDir; | 937 | QString oldRemoteCurrentDir = currentRemoteDir; |
934 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 938 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); |
935 | if (TabWidget->currentPageIndex() == 0) { | 939 | if (TabWidget->currentPageIndex() == 0) { |
936 | if(QDir( currentPathEdit->text()).exists()) { | 940 | if(QDir( currentPathEdit->text()).exists()) { |
937 | currentDir.setPath( currentPathEdit->text() ); | 941 | currentDir.setPath( currentPathEdit->text() ); |
938 | populateLocalView(); | 942 | populateLocalView(); |
939 | } else { | 943 | } else { |
940 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 944 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
941 | } | 945 | } |
942 | } | 946 | } |
943 | if (TabWidget->currentPageIndex() == 1) { | 947 | if (TabWidget->currentPageIndex() == 1) { |
944 | currentRemoteDir = currentPathEdit->text(); | 948 | currentRemoteDir = currentPathEdit->text(); |
945 | if(currentRemoteDir.right(1) !="/") { | 949 | if(currentRemoteDir.right(1) !="/") { |
946 | currentRemoteDir = currentRemoteDir +"/"; | 950 | currentRemoteDir = currentRemoteDir +"/"; |
947 | currentPathEdit->setText( currentRemoteDir ); | 951 | currentPathEdit->setText( currentRemoteDir ); |
948 | } | 952 | } |
949 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 953 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
950 | currentRemoteDir = oldRemoteCurrentDir; | 954 | currentRemoteDir = oldRemoteCurrentDir; |
951 | currentPathEdit->setText( currentRemoteDir ); | 955 | currentPathEdit->setText( currentRemoteDir ); |
952 | } | 956 | } |
953 | 957 | ||
954 | remoteDirList( (const QString &)currentRemoteDir); | 958 | remoteDirList( (const QString &)currentRemoteDir); |
955 | } | 959 | } |
956 | } | 960 | } |
957 | 961 | ||
958 | void OpieFtp::switchToLocalTab() | 962 | void OpieFtp::switchToLocalTab() |
959 | { | 963 | { |
960 | TabWidget->setCurrentPage(0); | 964 | TabWidget->setCurrentPage(0); |
961 | } | 965 | } |
962 | 966 | ||
963 | void OpieFtp::switchToRemoteTab() | 967 | void OpieFtp::switchToRemoteTab() |
964 | { | 968 | { |
965 | TabWidget->setCurrentPage(1); | 969 | TabWidget->setCurrentPage(1); |
966 | } | 970 | } |
967 | 971 | ||
968 | void OpieFtp::switchToConfigTab() | 972 | void OpieFtp::switchToConfigTab() |
969 | { | 973 | { |
970 | TabWidget->setCurrentPage(2); | 974 | TabWidget->setCurrentPage(2); |
971 | } | 975 | } |
972 | 976 | ||
973 | void OpieFtp::readConfig() | 977 | void OpieFtp::readConfig() |
974 | { | 978 | { |
975 | 979 | fillCombos(); | |
976 | Config cfg("opieftp"); | 980 | Config cfg("opieftp"); |
977 | cfg.setGroup("Server"); | 981 | cfg.setGroup("Server"); |
978 | QString username, remoteServer, remotePathStr, password, port, temp; | 982 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
979 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 983 | serverComboSelected( currentServerConfig); |
980 | for (int i = 0; i <= numberOfEntries; i++) { | ||
981 | temp.setNum(i+1); | ||
982 | cfg.setGroup("Server"); | ||
983 | remoteServer = cfg.readEntry( temp,""); | ||
984 | ServerComboBox->insertItem( remoteServer ); | ||
985 | cfg.setGroup(temp); | ||
986 | |||
987 | remotePathStr = cfg.readEntry(remoteServer,""); | ||
988 | int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); | ||
989 | port = remoteServer.right( divider+1); | ||
990 | bool ok; | ||
991 | PortSpinBox->setValue( port.toInt(&ok,10)); | ||
992 | |||
993 | remoteServer = remoteServer.left(divider - 1); | ||
994 | remotePath->setText( remotePathStr); | ||
995 | username = cfg.readEntry(temp); | ||
996 | UsernameComboBox->insertItem(username); | ||
997 | password = cfg.readEntryCrypt(username,""); | ||
998 | PasswordEdit->setText(password); | ||
999 | } | ||
1000 | } | 984 | } |
1001 | 985 | ||
1002 | void OpieFtp::writeConfig() | 986 | void OpieFtp::writeConfig() |
1003 | { | 987 | { |
1004 | 988 | ||
1005 | Config cfg("opieftp"); | 989 | Config cfg("opieftp"); |
1006 | cfg.setGroup("Server"); | 990 | cfg.setGroup("Server"); |
1007 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 991 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1008 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 992 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1009 | if( currentServerConfig == -1) { | 993 | if( currentServerConfig == -1) { |
1010 | 994 | ||
1011 | temp.setNum( numberOfEntries + 1); | 995 | temp.setNum( numberOfEntries + 1); |
1012 | cfg.setGroup("Server"); | 996 | cfg.setGroup("Server"); |
1013 | remoteServerStr = cfg.readEntry( temp,""); | 997 | remoteServerStr = cfg.readEntry( temp,""); |
1014 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 998 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1015 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 999 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1016 | 1000 | ||
1017 | temp.setNum(numberOfEntries+1); | 1001 | temp.setNum(numberOfEntries+1); |
1018 | cfg.setGroup("Server"); | 1002 | cfg.setGroup("Server"); |
1019 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1003 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1020 | cfg.setGroup(temp); | 1004 | cfg.setGroup(temp); |
1021 | cfg.writeEntry("RemotePath", remotePath->text()); | 1005 | cfg.writeEntry("RemotePath", remotePath->text()); |
1022 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1006 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1023 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1007 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1024 | cfg.setGroup("Server"); | 1008 | cfg.setGroup("Server"); |
1025 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1009 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1026 | 1010 | ||
1027 | } | 1011 | } |
1028 | } | 1012 | } |
1029 | 1013 | ||
1030 | void OpieFtp::fillCombos() | 1014 | void OpieFtp::fillCombos() |
1031 | { | 1015 | { |
1032 | Config cfg("opieftp"); | 1016 | Config cfg("opieftp"); |
1033 | cfg.setGroup("Server"); | 1017 | cfg.setGroup("Server"); |
1034 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1018 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1035 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1019 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1036 | for (int i = 1; i <= numberOfEntries; i++) { | 1020 | for (int i = 1; i <= numberOfEntries; i++) { |
1037 | temp.setNum(i); | 1021 | temp.setNum(i); |
1038 | cfg.setGroup("Server"); | 1022 | cfg.setGroup("Server"); |
1039 | remoteServerStr = cfg.readEntry( temp,""); | 1023 | remoteServerStr = cfg.readEntry( temp,""); |
1040 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1024 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1041 | port = remoteServerStr.right( divider - 1); | 1025 | port = remoteServerStr.right( divider - 1); |
1042 | bool ok; | 1026 | bool ok; |
1043 | PortSpinBox->setValue( port.toInt(&ok,10)); | 1027 | PortSpinBox->setValue( port.toInt(&ok,10)); |
1044 | 1028 | ||
1045 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1029 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1046 | ServerComboBox->insertItem( remoteServerStr ); | 1030 | ServerComboBox->insertItem( remoteServerStr ); |
1047 | // cfg.setGroup(temp); | 1031 | // cfg.setGroup(temp); |
1048 | 1032 | ||
1049 | // remotePathStr = cfg.readEntry(remoteServer,""); | 1033 | // remotePathStr = cfg.readEntry(remoteServer,""); |
1050 | // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); | 1034 | // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); |
1051 | // port = remoteServer.right( divider+1); | 1035 | // port = remoteServer.right( divider+1); |
1052 | // PortSpinBox->setValue( port); | 1036 | // PortSpinBox->setValue( port); |
1053 | 1037 | ||
1054 | // remoteServer = remoteServer.left(divider - 1); | 1038 | // remoteServer = remoteServer.left(divider - 1); |
1055 | // remotePath->setText( remotePathStr); | 1039 | // remotePath->setText( remotePathStr); |
1056 | 1040 | ||
1057 | // username = cfg.readEntry(temp); | 1041 | // username = cfg.readEntry(temp); |
1058 | // UsernameComboBox->insertItem(username); | 1042 | // UsernameComboBox->insertItem(username); |
1059 | // password = cfg.readEntryCrypt(username,""); | 1043 | // password = cfg.readEntryCrypt(username,""); |
1060 | // PasswordEdit->setText(password); | 1044 | // PasswordEdit->setText(password); |
1061 | } | 1045 | } |
1062 | } | 1046 | } |
1063 | 1047 | ||
1064 | 1048 | ||
1065 | void OpieFtp::serverComboSelected(int index) | 1049 | void OpieFtp::serverComboSelected(int index) |
1066 | { | 1050 | { |
1067 | currentServerConfig = index; | 1051 | currentServerConfig = index; |
1068 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1052 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1069 | // remoteServerStr = ServerComboBox->text(index); | 1053 | // remoteServerStr = ServerComboBox->text(index); |
1070 | Config cfg("opieftp"); | 1054 | Config cfg("opieftp"); |
1071 | cfg.setGroup("Server"); | 1055 | cfg.setGroup("Server"); |
1072 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1056 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1073 | 1057 | ||
1074 | temp.setNum(index+1); | 1058 | temp.setNum(index+1); |
1075 | remoteServerStr = cfg.readEntry( temp,""); | 1059 | remoteServerStr = cfg.readEntry( temp,""); |
1076 | cfg.setGroup(temp); | 1060 | cfg.setGroup(temp); |
1077 | qDebug(temp); | 1061 | qDebug(temp); |
1078 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1062 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1079 | port = remoteServerStr.right( divider - 1); | 1063 | port = remoteServerStr.right( divider - 1); |
1080 | bool ok; | 1064 | bool ok; |
1081 | int portInt = port.toInt(&ok,10); | 1065 | int portInt = port.toInt(&ok,10); |
1082 | if( portInt == 0) portInt = 21; | 1066 | if( portInt == 0) portInt = 21; |
1083 | 1067 | ||
1084 | PortSpinBox->setValue( portInt); | 1068 | PortSpinBox->setValue( portInt); |
1085 | 1069 | ||
1086 | remotePath->setText(cfg.readEntry("RemotePath", "/")); | 1070 | remotePath->setText(cfg.readEntry("RemotePath", "/")); |
1087 | 1071 | ||
1088 | username = cfg.readEntry("Username", "anonymous"); | 1072 | username = cfg.readEntry("Username", "anonymous"); |
1089 | UsernameComboBox->lineEdit()->setText(username); | 1073 | UsernameComboBox->lineEdit()->setText(username); |
1090 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); | 1074 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); |
1075 | |||
1076 | cfg.setGroup("Server"); | ||
1077 | temp.sprintf("%d",currentServerConfig); | ||
1078 | cfg.writeEntry("currentServer", temp); | ||
1091 | update(); | 1079 | update(); |
1092 | } | 1080 | } |
1093 | // UsernameComboBox->lineEdit()->setText("root"); | 1081 | // UsernameComboBox->lineEdit()->setText("root"); |
1094 | // PasswordEdit->setText( tr( "" ) ); | 1082 | // PasswordEdit->setText( tr( "" ) ); |
1095 | // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 1083 | // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); |
1096 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); | 1084 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); |
1097 | // PortSpinBox->setValue( 4242); | 1085 | // PortSpinBox->setValue( 4242); |
1098 | 1086 | ||
1099 | void OpieFtp::deleteServer() | 1087 | void OpieFtp::deleteServer() |
1100 | { | 1088 | { |
1101 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1089 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1102 | remoteServerStr = ServerComboBox->currentText( ); | 1090 | remoteServerStr = ServerComboBox->currentText( ); |
1103 | username = UsernameComboBox->currentText(); | 1091 | username = UsernameComboBox->currentText(); |
1104 | Config cfg("opieftp"); | 1092 | Config cfg("opieftp"); |
1105 | cfg.setGroup("Server"); | 1093 | cfg.setGroup("Server"); |
1106 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1094 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1107 | for (int i = 0; i <= numberOfEntries; i++) { | 1095 | for (int i = 0; i <= numberOfEntries; i++) { |
1108 | temp.setNum(i+1); | 1096 | temp.setNum(i+1); |
1109 | cfg.setGroup("Server"); | 1097 | cfg.setGroup("Server"); |
1110 | if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 | 1098 | if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 |
1111 | && cfg.readEntry(temp).find(username,0,TRUE) != -1 | 1099 | && cfg.readEntry(temp).find(username,0,TRUE) != -1 |
1112 | && !remoteServerStr.isEmpty()) { | 1100 | && !remoteServerStr.isEmpty()) { |
1113 | qDebug(temp); | 1101 | qDebug(temp); |
1114 | } | 1102 | } |
1115 | } | 1103 | } |
1116 | } | 1104 | } |