00001
00002 #include "obexdialog.h"
00003 #include <qpushbutton.h>
00004 #include <qmultilineedit.h>
00005 #include <qlineedit.h>
00006 #include <qlayout.h>
00007 #include <qlabel.h>
00008 #include <qfileinfo.h>
00009
00010 #include <qpe/resource.h>
00011
00012 #include <opie2/oprocess.h>
00013 #include <opie2/ofiledialog.h>
00014 #include <opie2/odebug.h>
00015 using namespace Opie::Core;
00016
00017 using namespace OpieTooth;
00018
00019 using namespace Opie::Core;
00020 using namespace Opie::Ui;
00021 using namespace Opie::Core;
00022 ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QString& device )
00023 : QDialog( parent, name, modal, fl ) {
00024
00025 if ( !name )
00026 setName( "ObexDialog" );
00027 setCaption( tr( "beam files " ) ) ;
00028
00029 m_device = device;
00030
00031 layout = new QVBoxLayout( this );
00032
00033 QLabel* info = new QLabel( this );
00034 info->setText( tr("Which file should be beamed?") );
00035
00036 cmdLine = new QLineEdit( this );
00037
00038 QPushButton *browserButton;
00039 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
00040 connect( browserButton, SIGNAL(released() ), this , SLOT(browse() ) );
00041
00042 chNameLine = new QLineEdit( this );
00043
00044 sendButton = new QPushButton( this );
00045 sendButton->setText( tr( "Send" ) );
00046
00047 layout->addWidget(info);
00048 layout->addWidget(cmdLine);
00049 layout->addWidget(browserButton);
00050 layout->addWidget(chNameLine);
00051 layout->addWidget(sendButton);
00052
00053 connect( sendButton, SIGNAL( clicked() ), this, SLOT( sendData() ) );
00054
00055 }
00056
00057 ObexDialog::~ObexDialog() {
00058 }
00059
00060 void ObexDialog::browse() {
00061
00062 MimeTypes types;
00063 QStringList all;
00064 all << "*/*";
00065 types.insert("All Files", all );
00066
00067 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 );
00068 cmdLine->setText( str );
00069
00070 }
00071
00072 void ObexDialog::sendData() {
00073 QString fileURL = cmdLine->text();
00074 QString file = QFileInfo( fileURL ).fileName();
00075 QString modifiedName = chNameLine->text();
00076
00077
00078 OProcess* obexSend = new OProcess();
00079 if ( !modifiedName.isEmpty() ) {
00080 *obexSend << "ussp-push" << m_device << fileURL << modifiedName;
00081 } else {
00082 *obexSend << "ussp-push" << m_device << fileURL << file;
00083 }
00084 if (!obexSend->start(OProcess::DontCare, OProcess::AllOutput) ) {
00085 owarn << "could not start" << oendl;
00086 delete obexSend;
00087 }
00088
00089
00090
00091 }