summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/obexdialog.cpp
blob: 46a0e3d74aca961886d386d7b6ae5a185e1fa12d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

#include "obexdialog.h"
#include <qpushbutton.h>
#include <qmultilineedit.h>
#include <qlineedit.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qfileinfo.h>

#include <qpe/resource.h>

#include <opie/oprocess.h>
#include <opie/ofiledialog.h>

using namespace OpieTooth;

ObexDialog::ObexDialog( QWidget* parent,  const char* name, bool modal, WFlags fl, const QString& device )
    : QDialog( parent, name, modal, fl ) {

    if ( !name )
	setName( "ObexDialog" );
    setCaption( tr( "beam files " ) ) ;

    m_device = device;

    layout = new QVBoxLayout( this );

    QLabel* info = new QLabel( this );
    info->setText( tr("Which file should be beamed?") );

    cmdLine = new QLineEdit( this );

    QPushButton *browserButton;
    browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
    connect( browserButton, SIGNAL(released() ), this , SLOT(browse() ) );

    chNameLine = new QLineEdit( this );

    sendButton = new QPushButton( this );
    sendButton->setText( tr( "Send" ) );

    layout->addWidget(info);
    layout->addWidget(cmdLine);
    layout->addWidget(browserButton);
    layout->addWidget(chNameLine);
    layout->addWidget(sendButton);

    connect( sendButton, SIGNAL( clicked() ), this,  SLOT( sendData() ) );

}

ObexDialog::~ObexDialog() {
}

void ObexDialog::browse() {

    MimeTypes types;
    QStringList all;
    all << "*/*";
    types.insert("All Files", all );

    QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 );
    cmdLine->setText( str );

}

void ObexDialog::sendData() {
    QString fileURL = cmdLine->text();
    QString file = QFileInfo( fileURL ).fileName();
    QString modifiedName = chNameLine->text();

       // vom popupmenu beziehen
    OProcess* obexSend = new OProcess();
    if ( !modifiedName.isEmpty() ) {
        *obexSend << "ussp-push" << m_device << fileURL << modifiedName;
    } else {
        *obexSend << "ussp-push" << m_device << fileURL << file;
    }
    if (!obexSend->start(OProcess::DontCare, OProcess::AllOutput) ) {
        qWarning("could not start");
        delete obexSend;
    }



}