author | korovkin <korovkin> | 2006-04-30 08:54:54 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-04-30 08:54:54 (UTC) |
commit | 2f32b6d589d389848c5c73ba2e5ad13117c1da9e (patch) (side-by-side diff) | |
tree | ec8a086ad17e3fa9014baa9476ab9cc77c5c29dc | |
parent | b91d3399fbd3178085e9d0fc5faeefbe31c674b7 (diff) | |
download | opie-2f32b6d589d389848c5c73ba2e5ad13117c1da9e.zip opie-2f32b6d589d389848c5c73ba2e5ad13117c1da9e.tar.gz opie-2f32b6d589d389848c5c73ba2e5ad13117c1da9e.tar.bz2 |
Fixed bug with suspend reenabling.
Made some minor formatting.
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 39 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/obexftpdialog.cpp | 2 |
2 files changed, 29 insertions, 12 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 58f97fa..85385d8 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp @@ -505,297 +505,314 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); } } else { Services s1; s1.setServiceName( tr("no services found") ); serviceItem = new BTServiceItem( deviceItem, s1 ); } // now remove them from the list m_deviceList.remove( it ); } void BlueBase::addSignalStrength() { QListViewItemIterator it( connectionsView ); for ( ; it.current(); ++it ) { m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); } QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); } void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) { QListViewItemIterator it( connectionsView ); for ( ; it.current(); ++it ) { if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) { ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); } } } /** * Add the existing connections (pairs) to the connections tab. * This one triggers the search */ void BlueBase::addConnectedDevices() { m_localDevice->searchConnections(); QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); } /** * This adds the found connections to the connection tab. * @param connectionList the ValueList with all current connections */ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { QValueList<OpieTooth::ConnectionState>::Iterator it; BTConnectionItem * connectionItem; if ( !connectionList.isEmpty() ) { for (it = connectionList.begin(); it != connectionList.end(); ++it) { QListViewItemIterator it2( connectionsView ); bool found = false; for ( ; it2.current(); ++it2 ) { if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) { found = true; } } if ( found == false ) { connectionItem = new BTConnectionItem( connectionsView, (*it) ); if( m_deviceList.find((*it).mac()).data() ) { connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); } } } QListViewItemIterator it2( connectionsView ); for ( ; it2.current(); ++it2 ) { bool found = false; for (it = connectionList.begin(); it != connectionList.end(); ++it) { if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) { found = true; } } if ( !found ) { delete it2.current(); } } } else { connectionsView->clear(); ConnectionState con; con.setMac( tr("No connections found") ); connectionItem = new BTConnectionItem( connectionsView , con ); } // recall connection search after some time QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); } /** * Find out if a device can currently be reached * @param device */ void BlueBase::deviceActive( const RemoteDevice &device ) { // search by mac, async, gets a signal back // We should have a BTDeviceItem there or where does it get added to the map -zecke m_localDevice->isAvailable( device.mac() ); } /** * The signal catcher. Set the avail. status on device. * @param device - the mac address * @param connected - if it is avail. or not */ void BlueBase::deviceActive( const QString& device, bool connected ) { odebug << "deviceActive slot" << oendl; QMap<QString,BTDeviceItem*>::Iterator it; it = m_deviceList.find( device ); if( it == m_deviceList.end() ) return; BTDeviceItem* deviceItem = it.data(); if ( connected ) { deviceItem->setPixmap( 1, m_onPix ); } else { deviceItem->setPixmap( 1, m_offPix ); } m_deviceList.remove( it ); } /** * Open the "scan for devices" dialog */ void BlueBase::startScan() { ScanDialog *scan = new ScanDialog( this, "ScanDialog", true, WDestructiveClose ); QObject::connect( scan, SIGNAL( selectedDevices(const QValueList<RemoteDevice>&) ), this, SLOT( addSearchedDevices(const QValueList<RemoteDevice>&) ) ); QPEApplication::showDialog( scan ); } /** * Set the informations about the local device in information Tab */ void BlueBase::setInfo() { StatusLabel->setText( status() ); } /** * Decontructor */ BlueBase::~BlueBase() { writeSavedDevices(); if (forwarder) { #if defined(Q_WS_QWS) && !defined(QT_NO_COP) - QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) - << QPEApplication::Enable; + { + odebug << "SUSP: Enable suspend mode" << oendl; + QCopEnvelope e("QPE/System", "setScreenSaverMode(int)" ); + e << QPEApplication::Enable; + } #endif delete forwarder; forwarder = NULL; } delete m_iconLoader; } /** * find searches the ListView for a BTDeviceItem containig * the same Device if found return true else false * @param dev RemoteDevice to find * @return returns true if found */ bool BlueBase::find( const RemoteDevice& rem ) { QListViewItemIterator it( devicesView ); BTListItem* item; BTDeviceItem* device; for (; it.current(); ++it ) { item = (BTListItem*) it.current(); if ( item->typeId() != BTListItem::Device ) continue; device = (BTDeviceItem*)item; if ( rem.equals( device->remoteDevice() ) ) return true; } return false; // not found } /** * Start process of the cell phone forwarding */ void BlueBase::doForward() { if (forwarder && forwarder->isRunning()) { runButton->setText("start gateway"); forwarder->stop(); delete forwarder; forwarder = NULL; +#if defined(Q_WS_QWS) && !defined(QT_NO_COP) + { + odebug << "SUSP: Enable suspend mode" << oendl; + QCopEnvelope e("QPE/System", "setScreenSaverMode(int)" ); + e << QPEApplication::Enable; + } +#endif return; } QString str = serDevName->text(); forwarder = new SerialForwarder(str, speeds[serSpeed->currentItem()].val); - connect(forwarder, SIGNAL(processExited(Opie::Core::OProcess*)), - this, SLOT(forwardExited(Opie::Core::OProcess*))); if (forwarder->start(OProcess::NotifyOnExit) < 0) { QMessageBox::critical(this, tr("Forwarder Error"), tr("Forwarder start error:") + tr(strerror(errno))); return; } + connect(forwarder, SIGNAL(processExited(Opie::Core::OProcess*)), + this, SLOT(forwardExited(Opie::Core::OProcess*))); runButton->setText("stop gateway"); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) - QCopEnvelope("QPE/System", "setScreenSaverMode(int)") - << QPEApplication::DisableSuspend; + { + odebug << "SUSP: Disable suspend mode" << oendl; + QCopEnvelope e("QPE/System", "setScreenSaverMode(int)"); + e << QPEApplication::DisableSuspend; + } #endif } /** * React on the process end */ void BlueBase::forwardExit(Opie::Core::OProcess* proc) { + odebug << "Process exited" << oendl; #if defined(Q_WS_QWS) && !defined(QT_NO_COP) - QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) - << QPEApplication::Enable; + if (forwarder) { + delete forwarder; + forwarder = NULL; + runButton->setText("start gateway"); + odebug << "SUSP: Enable suspend mode" << oendl; + QCopEnvelope e("QPE/System", "setScreenSaverMode(int)" ); + e << QPEApplication::Enable; + } #endif if (proc->exitStatus() != 0) QMessageBox::critical(this, tr("Forwarder Error"), tr("Forwarder start error")); - delete proc; - forwarder = NULL; - runButton->setText("start gateway"); } /** * Encrypt entered passkey * doit - do encryption of the key */ void BlueBase::doEncrypt(bool doit) { passkeyLine->setEchoMode((doit)? QLineEdit::Password: QLineEdit::Normal); } /** * Start services edit dialog */ void BlueBase::editServices() { QString conf = "/etc/default/bluetooth"; //// Use for debugging purposes //// QString conf = "/mnt/net/opie/bin/bluetooth"; ServicesDialog svcEdit(conf, this, "ServicesDialog", true, WStyle_ContextHelp); if (QPEApplication::execDialog(&svcEdit) == QDialog::Accepted) { } } //eof diff --git a/noncore/net/opietooth/manager/obexftpdialog.cpp b/noncore/net/opietooth/manager/obexftpdialog.cpp index fd2015e..2f04ecf 100644 --- a/noncore/net/opietooth/manager/obexftpdialog.cpp +++ b/noncore/net/opietooth/manager/obexftpdialog.cpp @@ -89,385 +89,385 @@ ObexFtpDialog::ObexFtpDialog(const QString& device, int port, SLOT(getFile())); connect(putButton, SIGNAL(clicked()), SLOT(putFile())); connect(delButton, SIGNAL(clicked()), SLOT(delFile())); connect(destFile, SIGNAL(dirSelected (const QString&)), SLOT(updateDir(const QString&))); connect(saveButton, SIGNAL(clicked()), SLOT(slotSaveLog())); connect(browseButton, SIGNAL(clicked()), SLOT(slotBrowseLog())); } ObexFtpDialog::~ObexFtpDialog() { if (client != NULL) { obexftp_disconnect(client); obexftp_close(client); } } /* * Do device browsing */ void ObexFtpDialog::slotBrowse() { stat_entry_t* ent; //Directory entry void *dir; //Directory to read const uint8_t* use_uuid; //uuid int len; //uuid length FileListItem* root; //root node int fsize; //file size bool numOk; //true if the string is a number int tmp; //just a temp var status(tr("Connecting to ") + m_device); odebug << "Browse device " << m_device << oendl; browseLog->clear(); fileList->clear(); progressStatus = 0; fileProgress->setTotalSteps(MAX_PROGRESS); fileProgress->reset(); //Get parameters tmp = nReries->text().toInt(&numOk); if (numOk) nRetries = tmp; if (uuidType->currentText() == "FBS") { use_uuid = UUID_FBS; len = sizeof(UUID_FBS); } else if (uuidType->currentText() == "S45") { use_uuid = UUID_S45; len = sizeof(UUID_S45); } else { use_uuid = UUID_FBS; len = sizeof(UUID_FBS); } if (!cli_connect_uuid(use_uuid, len)) { log(tr("Connection failed: ") + tr(strerror(errno))); errBox("Connection failed"); status("Connection failed"); return; } else { log(QString("Connected to ") + m_device); status(QString("Connected to ") + m_device); } /* List folder */ root = new FileListItem(fileList, NULL); dir = obexftp_opendir(client, curdir); while ((ent = obexftp_readdir(dir)) != NULL) { FileListItem* a; //List view item if (ent->mode != 16877) { fsize = ent->size; } else fsize = 0; log(QString(ent->name) + QString(" ") + QString::number(ent->mode)); a = new FileListItem(fileList, ent, fsize); } obexftp_closedir(dir); } //Error message box int ObexFtpDialog::errBox(QCString msg) { return QMessageBox::critical(this, tr("ObexFTP error"), msg); } int ObexFtpDialog::errBox(QString msg) { return QMessageBox::critical(this, tr("ObexFTP error"), msg); } int ObexFtpDialog::errBox(const char* msg) { return QMessageBox::critical(this, tr("ObexFTP error"), tr(msg)); } //Text in the status bar void ObexFtpDialog::status(QCString msg) { statusBar->setText(msg); statusBar->repaint(); } void ObexFtpDialog::status(QString msg) { statusBar->setText(msg); statusBar->repaint(); } void ObexFtpDialog::status(const char* msg) { statusBar->setText(msg); statusBar->repaint(); } /* * Change directory with item under the cursor */ void ObexFtpDialog::slotCd(QListViewItem* item) { FileListItem* file = (FileListItem*)item; int idx; if (file == NULL) return; odebug << "Item " << file->text(0) << " clicked" << oendl; if (file->gettype() == IS_DIR) { if (file->text(0) == "../") { if (curdir.right(1) == "/") curdir.remove(curdir.length() - 1, 1); idx = curdir.findRev('/'); if (idx >= 0) curdir.remove(idx, curdir.length() - idx); else curdir = ""; } else { if (curdir != "" && curdir.right(1) != "/") curdir += "/"; curdir += file->text(0); } odebug << "Browse " << curdir << oendl; if (obexftp_setpath(client, curdir, 0) < 0) log(tr("CD failed: ") + tr(strerror(errno))); slotBrowse(); } } /* * Copy file from a remote device to the local device */ void ObexFtpDialog::getFile() { FileListItem* file = (FileListItem*)fileList->selectedItem(); int result; if (file == NULL) return; file2get = "/"; local = localCurdir; if (local == "") { errBox("Select a destination first"); return; } if (local.right(1) != "/") local += "/"; if (file->gettype() == IS_FILE) { if (client == NULL) { errBox("No connection established"); return; } file2get += curdir; if (curdir != "" && curdir.right(1) != "/") file2get += "/"; file2get += file->text(0); local += file->text(0); odebug << "Copy " << file2get << " to " << local << oendl; progressStatus = 0; fileProgress->setTotalSteps(file->getsize() / 1024); fileProgress->reset(); status(tr("Receiving file ") + file2get); result = obexftp_get(client, local, file2get); if (result < 0) { - log(file2get + QString(" receive ERROR:\n") + tr(strerror(errno))); + log(file2get + QString(" receive ERROR:\n") + tr(strerror(errno))); errBox(file2get + QString(" receive ERROR")); status(file2get + QString(" receive ERROR")); } else { log(file2get + QString(" received")); status(file2get + QString(" received")); destFile->reread(); } } } /* * Copy file from the local device to a remote device */ void ObexFtpDialog::putFile() { int result; //OPeration result int idx; //Index of a symbol in the string struct stat localFStat; //Local file information if (client == NULL) { errBox("No connection established"); return; } local = destFile->selectedName(); if (local == "") { errBox("No file slected"); return; } result = stat(local, &localFStat); if (result < 0) { errBox(tr("Wrong file selected ") + local + tr(" ") + tr(strerror(errno))); return; } idx = local.findRev('/'); if (idx > 0) { file2get = local.right(local.length() - idx - 1); } else file2get = local; odebug << "Copy " << local << " to " << file2get << oendl; progressStatus = 0; fileProgress->setTotalSteps(localFStat.st_size / 1024); fileProgress->reset(); status(tr("Sending file ") + local); result = obexftp_put_file(client, local, file2get); if (result < 0) { log(local + QString(" send ERROR:\n") + tr(strerror(errno))); errBox(local + QString(" send ERROR")); status(local + QString(" send ERROR")); } else { slotBrowse(); log(local + QString(" sent")); status(local + QString(" sent")); } } /* * Delete file on a remote device */ void ObexFtpDialog::delFile() { FileListItem* file = (FileListItem*)fileList->selectedItem(); int result; if (file == NULL) return; file2get = "/"; if (file->gettype() == IS_FILE) { if (client == NULL) { errBox("No connection established"); return; } file2get += curdir; if (curdir != "" && curdir.right(1) != "/") file2get += "/"; file2get += file->text(0); } result = QMessageBox::warning(this, tr("Remove File"), tr("Do you want to remove\n") + file2get, "Yes", "No"); if (result != 0) return; odebug << "Remove " << file2get << oendl; result = obexftp_del(client, file2get); if (result < 0) { log(file2get + QString(" remove ERROR\n") + tr(strerror(errno))); errBox(file2get + QString(" remove ERROR")); status(file2get + QString(" remove ERROR")); } else { slotBrowse(); log(file2get + QString(" removed")); status(file2get + QString(" removed")); } } /* connect with given uuid. re-connect every time */ int ObexFtpDialog::cli_connect_uuid(const uint8_t *uuid, int uuid_len) { int retry; if (client != NULL) return TRUE; /* Open */ client = obexftp_open (transport, NULL, info_cb, this); if(client == NULL) { errBox("Error opening obexftp-client"); return FALSE; } if (!use_conn) client->quirks &= ~OBEXFTP_CONN_HEADER; if (!use_path) client->quirks &= ~OBEXFTP_SPLIT_SETPATH; for (retry = 0; retry < nRetries; retry++) { /* Connect */ switch (transport) { case OBEX_TRANS_IRDA: if (obexftp_connect_uuid(client, NULL, 0, uuid, uuid_len) >= 0) return TRUE; break; case OBEX_TRANS_BLUETOOTH: if (obexftp_connect_uuid(client, m_device, m_port, uuid, uuid_len) >= 0) return TRUE; break; default: errBox("Transport type unknown"); return FALSE; } log(tr("Still trying to connect")); } client = NULL; return FALSE; } /* * Put a message to the log window */ void ObexFtpDialog::log(QString str) { browseLog->append(str); } void ObexFtpDialog::log(QCString str) { browseLog->append(str); } void ObexFtpDialog::log(QString& str) { browseLog->append(str); } void ObexFtpDialog::log(const char* str) { browseLog->append(str); } void ObexFtpDialog::incProgress() { if (progressStatus < fileProgress->totalSteps()) fileProgress->setProgress(progressStatus++); } void ObexFtpDialog::doneProgress() { progressStatus = 0; fileProgress->reset(); } void ObexFtpDialog::updateDir(const QString& newdir) { localCurdir = newdir; } /** * Save Log to the specified file */ void ObexFtpDialog::slotSaveLog() { QFile logFile(saveLogEdit->text()); if (!logFile.open(IO_WriteOnly)) { errBox(tr("Unable to open file ") + saveLogEdit->text() + tr(" ") + tr(strerror(errno))); return; } QTextStream stream(&logFile); stream << browseLog->text() << endl; QMessageBox::information(this, tr("Saving"), tr("Log file saved to ") + saveLogEdit->text()); |