-rw-r--r-- | noncore/apps/opie-console/filereceive.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/filereceive.cpp b/noncore/apps/opie-console/filereceive.cpp index e517862..e387273 100644 --- a/noncore/apps/opie-console/filereceive.cpp +++ b/noncore/apps/opie-console/filereceive.cpp | |||
@@ -1,157 +1,162 @@ | |||
1 | #include <unistd.h> | 1 | #include <unistd.h> |
2 | #include <fcntl.h> | 2 | #include <fcntl.h> |
3 | #include <signal.h> | 3 | #include <signal.h> |
4 | #include <errno.h> | 4 | #include <errno.h> |
5 | 5 | ||
6 | #include <qsocketnotifier.h> | 6 | #include <qsocketnotifier.h> |
7 | 7 | ||
8 | #include "io_layer.h" | 8 | #include "io_layer.h" |
9 | #include "procctl.h" | 9 | #include "procctl.h" |
10 | #include "filereceive.h" | 10 | #include "filereceive.h" |
11 | 11 | ||
12 | FileReceive::FileReceive( Type t, IOLayer* lay, const QString& dir ) | 12 | FileReceive::FileReceive( Type t, IOLayer* lay, const QString& dir ) |
13 | : ReceiveLayer(lay, dir ), m_type( t ) | 13 | : ReceiveLayer(lay, dir ), m_type( t ) |
14 | { | 14 | { |
15 | m_fd = -1; | 15 | m_fd = -1; |
16 | m_not = 0l; | 16 | m_not = 0l; |
17 | m_proc = 0l; | 17 | m_proc = 0l; |
18 | } | 18 | } |
19 | FileReceive::~FileReceive() { | 19 | FileReceive::~FileReceive() { |
20 | } | 20 | } |
21 | void FileReceive::receive() { | 21 | void FileReceive::receive() { |
22 | receive( currentDir() ); | 22 | receive( currentDir() ); |
23 | } | 23 | } |
24 | void FileReceive::receive( const QString& dir ) { | 24 | void FileReceive::receive( const QString& dir ) { |
25 | m_prog = -1; | 25 | m_prog = -1; |
26 | m_fd = layer()->rawIO(); | 26 | m_fd = layer()->rawIO(); |
27 | m_curDir = dir; | 27 | m_curDir = dir; |
28 | 28 | ||
29 | if (pipe( m_comm ) < 0 ) | 29 | if (pipe( m_comm ) < 0 ) |
30 | m_comm[0] = m_comm[1] = 0; | 30 | m_comm[0] = m_comm[1] = 0; |
31 | if (pipe( m_info ) < 0 ) | 31 | if (pipe( m_info ) < 0 ) |
32 | m_info[0] = m_info[1] = 0; | 32 | m_info[0] = m_info[1] = 0; |
33 | 33 | ||
34 | m_pid = fork(); | 34 | m_pid = fork(); |
35 | switch( m_pid ) { | 35 | switch( m_pid ) { |
36 | case -1: | 36 | case -1: |
37 | //emit error | 37 | //emit error |
38 | slotExec(); | 38 | slotExec(); |
39 | break; | 39 | break; |
40 | /* child */ | 40 | /* child */ |
41 | case 0: { | 41 | case 0: { |
42 | setupChild(); | 42 | setupChild(); |
43 | char* typus = NULL; | 43 | char* typus = NULL; |
44 | switch(m_type ) { | 44 | switch(m_type ) { |
45 | case SZ: | 45 | case SZ: |
46 | break; | 46 | break; |
47 | case SX: | 47 | case SX: |
48 | typus = "-X"; | 48 | typus = "-X"; |
49 | break; | 49 | break; |
50 | case SY: | 50 | case SY: |
51 | typus = "--ymodem"; | 51 | typus = "--ymodem"; |
52 | break; | 52 | break; |
53 | } | 53 | } |
54 | 54 | ||
55 | /* we should never return from here */ | 55 | /* we should never return from here */ |
56 | execlp("rz", "rz", typus, NULL ); | 56 | if( m_type == SX ) |
57 | // FIXME: file name should be configurable - currently we ensure it | ||
58 | // doesn't get overwritten by -E (--rename) | ||
59 | execlp("rz", "rz", typus, "--overwrite", QObject::tr("SynchronizedFile").latin1(), NULL ); | ||
60 | else | ||
61 | execlp("rz", "rz", typus, "--overwrite", NULL ); | ||
57 | 62 | ||
58 | char resultByte = 1; | 63 | char resultByte = 1; |
59 | if (m_info[1] ) | 64 | if (m_info[1] ) |
60 | ::write(m_info[1], &resultByte, 1 ); | 65 | ::write(m_info[1], &resultByte, 1 ); |
61 | 66 | ||
62 | _exit( -1 ); | 67 | _exit( -1 ); |
63 | break; | 68 | break; |
64 | } | 69 | } |
65 | default: { | 70 | default: { |
66 | if ( m_info[1] ) | 71 | if ( m_info[1] ) |
67 | close( m_info[1] ); | 72 | close( m_info[1] ); |
68 | 73 | ||
69 | if ( m_info[0] ) for (;;) { | 74 | if ( m_info[0] ) for (;;) { |
70 | char resultByte; int len; | 75 | char resultByte; int len; |
71 | len = read(m_info[0], &resultByte, 1 ); | 76 | len = read(m_info[0], &resultByte, 1 ); |
72 | /* len == 1 start up failed */ | 77 | /* len == 1 start up failed */ |
73 | if ( len == 1 ) { | 78 | if ( len == 1 ) { |
74 | emit error( StartError, tr("Could not start") ); | 79 | emit error( StartError, tr("Could not start") ); |
75 | return; | 80 | return; |
76 | } | 81 | } |
77 | if ( len == -1 ) | 82 | if ( len == -1 ) |
78 | if ( (errno == ECHILD ) || (errno == EINTR ) ) | 83 | if ( (errno == ECHILD ) || (errno == EINTR ) ) |
79 | continue; | 84 | continue; |
80 | 85 | ||
81 | // len == 0 or something like this | 86 | // len == 0 or something like this |
82 | break; | 87 | break; |
83 | } | 88 | } |
84 | 89 | ||
85 | if ( m_info[0] ) | 90 | if ( m_info[0] ) |
86 | close( m_info[0] ); | 91 | close( m_info[0] ); |
87 | 92 | ||
88 | m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); | 93 | m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); |
89 | connect(m_not, SIGNAL(activated(int) ), | 94 | connect(m_not, SIGNAL(activated(int) ), |
90 | this, SLOT(slotRead() ) ); | 95 | this, SLOT(slotRead() ) ); |
91 | if ( pipe(m_term) < 0 ) | 96 | if ( pipe(m_term) < 0 ) |
92 | m_term[0] = m_term[1] = 0; | 97 | m_term[0] = m_term[1] = 0; |
93 | 98 | ||
94 | ProcCtl::self()->add(m_pid, m_term[1] ); | 99 | ProcCtl::self()->add(m_pid, m_term[1] ); |
95 | m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); | 100 | m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); |
96 | connect(m_proc, SIGNAL(activated(int) ), | 101 | connect(m_proc, SIGNAL(activated(int) ), |
97 | this, SLOT(slotExec() ) ); | 102 | this, SLOT(slotExec() ) ); |
98 | 103 | ||
99 | } | 104 | } |
100 | break; | 105 | break; |
101 | 106 | ||
102 | } | 107 | } |
103 | 108 | ||
104 | } | 109 | } |
105 | void FileReceive::cancel() { | 110 | void FileReceive::cancel() { |
106 | ::kill(m_pid, 9 ); | 111 | ::kill(m_pid, 9 ); |
107 | } | 112 | } |
108 | void FileReceive::setupChild() { | 113 | void FileReceive::setupChild() { |
109 | changeDir( currentDir() ); | 114 | changeDir( currentDir() ); |
110 | /* | 115 | /* |
111 | * we do not want to read from our | 116 | * we do not want to read from our |
112 | * information channel | 117 | * information channel |
113 | */ | 118 | */ |
114 | if (m_info[0] ) | 119 | if (m_info[0] ) |
115 | close(m_info[0] ); | 120 | close(m_info[0] ); |
116 | /* | 121 | /* |
117 | * FD_CLOEXEC will close the | 122 | * FD_CLOEXEC will close the |
118 | * fd on successfull exec | 123 | * fd on successfull exec |
119 | */ | 124 | */ |
120 | if (m_info[1] ) | 125 | if (m_info[1] ) |
121 | fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); | 126 | fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); |
122 | 127 | ||
123 | if (m_comm[0] ) | 128 | if (m_comm[0] ) |
124 | close( m_comm[0] ); | 129 | close( m_comm[0] ); |
125 | /* | 130 | /* |
126 | * now set the communication | 131 | * now set the communication |
127 | * m_fd STDIN_FILENO | 132 | * m_fd STDIN_FILENO |
128 | * STDOUT_FILENO | 133 | * STDOUT_FILENO |
129 | * STDERR_FILENO | 134 | * STDERR_FILENO |
130 | */ | 135 | */ |
131 | dup2( m_fd, STDIN_FILENO ); | 136 | dup2( m_fd, STDIN_FILENO ); |
132 | dup2( m_fd, STDOUT_FILENO ); | 137 | dup2( m_fd, STDOUT_FILENO ); |
133 | dup2( m_comm[1], STDERR_FILENO ); | 138 | dup2( m_comm[1], STDERR_FILENO ); |
134 | } | 139 | } |
135 | void FileReceive::slotRead() { | 140 | void FileReceive::slotRead() { |
136 | QByteArray ar(4096); | 141 | QByteArray ar(4096); |
137 | int len = read(m_comm[0], ar.data(), 4096 ); | 142 | int len = read(m_comm[0], ar.data(), 4096 ); |
138 | for (int i = 0; i < len; i++ ) { | 143 | for (int i = 0; i < len; i++ ) { |
139 | // printf("%c", ar[i] ); | 144 | // printf("%c", ar[i] ); |
140 | } | 145 | } |
141 | ar.resize( len ); | 146 | ar.resize( len ); |
142 | QString str( ar ); | 147 | QString str( ar ); |
143 | } | 148 | } |
144 | void FileReceive::slotExec() { | 149 | void FileReceive::slotExec() { |
145 | char buf[2]; | 150 | char buf[2]; |
146 | ::read(m_term[0], buf, 1 ); | 151 | ::read(m_term[0], buf, 1 ); |
147 | delete m_proc; | 152 | delete m_proc; |
148 | delete m_not; | 153 | delete m_not; |
149 | m_not = m_proc = 0l; | 154 | m_not = m_proc = 0l; |
150 | close( m_term[0] ); | 155 | close( m_term[0] ); |
151 | close( m_term[1] ); | 156 | close( m_term[1] ); |
152 | close( m_comm[0] ); | 157 | close( m_comm[0] ); |
153 | close( m_comm[1] ); | 158 | close( m_comm[1] ); |
154 | layer()->closeRawIO(m_fd); | 159 | layer()->closeRawIO(m_fd); |
155 | emit received(QString::null); | 160 | emit received(QString::null); |
156 | 161 | ||
157 | } | 162 | } |
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index ac5b1d0..f89723c 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp | |||
@@ -1,261 +1,266 @@ | |||
1 | #include <qlayout.h> | 1 | #include <qlayout.h> |
2 | #include <qcombobox.h> | 2 | #include <qcombobox.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <qprogressbar.h> | 7 | #include <qprogressbar.h> |
8 | #include <qradiobutton.h> | 8 | #include <qradiobutton.h> |
9 | #include <qbuttongroup.h> | 9 | #include <qbuttongroup.h> |
10 | 10 | ||
11 | #include <opie/ofiledialog.h> | 11 | #include <opie/ofiledialog.h> |
12 | 12 | ||
13 | #include "file_layer.h" | 13 | #include "file_layer.h" |
14 | #include "receive_layer.h" | 14 | #include "receive_layer.h" |
15 | #include "metafactory.h" | 15 | #include "metafactory.h" |
16 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | 17 | ||
18 | #include "transferdialog.h" | 18 | #include "transferdialog.h" |
19 | 19 | ||
20 | TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *name) | 20 | TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *name) |
21 | : QDialog(parent, 0l, true), m_win(mainwindow) | 21 | : QDialog(parent, 0l, true), m_win(mainwindow) |
22 | { | 22 | { |
23 | m_lay = 0l; | 23 | m_lay = 0l; |
24 | m_recvlay = 0l; | 24 | m_recvlay = 0l; |
25 | QVBoxLayout *vbox, *vbox2; | 25 | QVBoxLayout *vbox, *vbox2; |
26 | QHBoxLayout *hbox, *hbox2, *hbox3; | 26 | QHBoxLayout *hbox, *hbox2, *hbox3; |
27 | QLabel *file, *mode, *progress, *status; | 27 | QLabel *file, *mode, *progress, *status; |
28 | QButtonGroup *group; | 28 | QButtonGroup *group; |
29 | QRadioButton *mode_send, *mode_receive; | 29 | QRadioButton *mode_send, *mode_receive; |
30 | 30 | ||
31 | m_autocleanup = 0; | 31 | m_autocleanup = 0; |
32 | 32 | ||
33 | group = new QButtonGroup(QObject::tr("Transfer mode"), this); | 33 | group = new QButtonGroup(QObject::tr("Transfer mode"), this); |
34 | mode_send = new QRadioButton(QObject::tr("Send"), group); | 34 | mode_send = new QRadioButton(QObject::tr("Send"), group); |
35 | mode_receive = new QRadioButton(QObject::tr("Receive"), group); | 35 | mode_receive = new QRadioButton(QObject::tr("Receive"), group); |
36 | group->insert(mode_send, id_send); | 36 | group->insert(mode_send, id_send); |
37 | group->insert(mode_receive, id_receive); | 37 | group->insert(mode_receive, id_receive); |
38 | vbox2 = new QVBoxLayout(group, 2); | 38 | vbox2 = new QVBoxLayout(group, 2); |
39 | vbox2->addSpacing(10); | 39 | vbox2->addSpacing(10); |
40 | hbox3 = new QHBoxLayout(vbox2, 2); | 40 | hbox3 = new QHBoxLayout(vbox2, 2); |
41 | hbox3->add(mode_send); | 41 | hbox3->add(mode_send); |
42 | hbox3->add(mode_receive); | 42 | hbox3->add(mode_receive); |
43 | mode_send->setChecked(true); | 43 | mode_send->setChecked(true); |
44 | m_transfermode = id_send; | 44 | m_transfermode = id_send; |
45 | 45 | ||
46 | file = new QLabel(QObject::tr("Send file"), this); | 46 | file = new QLabel(QObject::tr("Send file"), this); |
47 | mode = new QLabel(QObject::tr("Transfer protocol"), this); | 47 | mode = new QLabel(QObject::tr("Transfer protocol"), this); |
48 | progress = new QLabel(QObject::tr("Progress"), this); | 48 | progress = new QLabel(QObject::tr("Progress"), this); |
49 | status = new QLabel(QObject::tr("Status"), this); | 49 | status = new QLabel(QObject::tr("Status"), this); |
50 | 50 | ||
51 | statusbar = new QLabel(QObject::tr("Ready"), this); | 51 | statusbar = new QLabel(QObject::tr("Ready"), this); |
52 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 52 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
53 | 53 | ||
54 | protocol = new QComboBox(this); | 54 | protocol = new QComboBox(this); |
55 | QStringList list = m_win->factory()->fileTransferLayers(); | 55 | QStringList list = m_win->factory()->fileTransferLayers(); |
56 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) | 56 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) |
57 | protocol->insertItem((*it)); | 57 | protocol->insertItem((*it)); |
58 | 58 | ||
59 | filename = new QLineEdit(this); | 59 | filename = new QLineEdit(this); |
60 | 60 | ||
61 | progressbar = new QProgressBar(this); | 61 | progressbar = new QProgressBar(this); |
62 | progressbar->setProgress(0); | 62 | progressbar->setProgress(0); |
63 | 63 | ||
64 | selector = new QPushButton("...", this); | 64 | selector = new QPushButton("...", this); |
65 | ok = new QPushButton(QObject::tr("Start transfer"), this); | 65 | ok = new QPushButton(QObject::tr("Start transfer"), this); |
66 | cancel = new QPushButton(QObject::tr("Cancel"), this); | 66 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
67 | 67 | ||
68 | vbox = new QVBoxLayout(this, 2); | 68 | vbox = new QVBoxLayout(this, 2); |
69 | vbox->add(group); | 69 | vbox->add(group); |
70 | vbox->add(file); | 70 | vbox->add(file); |
71 | hbox = new QHBoxLayout(vbox, 0); | 71 | hbox = new QHBoxLayout(vbox, 0); |
72 | hbox->add(filename); | 72 | hbox->add(filename); |
73 | hbox->add(selector); | 73 | hbox->add(selector); |
74 | vbox->add(mode); | 74 | vbox->add(mode); |
75 | vbox->add(protocol); | 75 | vbox->add(protocol); |
76 | vbox->add(progress); | 76 | vbox->add(progress); |
77 | vbox->add(progressbar); | 77 | vbox->add(progressbar); |
78 | vbox->add(status); | 78 | vbox->add(status); |
79 | vbox->add(statusbar); | 79 | vbox->add(statusbar); |
80 | vbox->addStretch(1); | 80 | vbox->addStretch(1); |
81 | hbox2 = new QHBoxLayout(vbox, 2); | 81 | hbox2 = new QHBoxLayout(vbox, 2); |
82 | hbox2->add(ok); | 82 | hbox2->add(ok); |
83 | hbox2->add(cancel); | 83 | hbox2->add(cancel); |
84 | 84 | ||
85 | setCaption(QObject::tr("File transfer")); | 85 | setCaption(QObject::tr("File transfer")); |
86 | show(); | 86 | show(); |
87 | 87 | ||
88 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); | 88 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); |
89 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); | 89 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); |
90 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); | 90 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); |
91 | connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); | 91 | connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); |
92 | } | 92 | } |
93 | 93 | ||
94 | TransferDialog::~TransferDialog() | 94 | TransferDialog::~TransferDialog() |
95 | { | 95 | { |
96 | } | 96 | } |
97 | 97 | ||
98 | void TransferDialog::slotFilename() | 98 | void TransferDialog::slotFilename() |
99 | { | 99 | { |
100 | QString f; | 100 | QString f; |
101 | 101 | ||
102 | f = OFileDialog::getOpenFileName(0); | 102 | f = OFileDialog::getOpenFileName(0); |
103 | if(!f.isNull()) filename->setText(f); | 103 | if(!f.isNull()) filename->setText(f); |
104 | } | 104 | } |
105 | 105 | ||
106 | void TransferDialog::slotTransfer() | 106 | void TransferDialog::slotTransfer() |
107 | { | 107 | { |
108 | if((m_transfermode == id_send) && (filename->text().isEmpty())) | 108 | if((m_transfermode == id_send) && (filename->text().isEmpty())) |
109 | { | 109 | { |
110 | QMessageBox::information(this, | 110 | QMessageBox::information(this, |
111 | QObject::tr("Attention"), | 111 | QObject::tr("Attention"), |
112 | QObject::tr("No file has been specified.")); | 112 | QObject::tr("No file has been specified.")); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | 115 | ||
116 | ok->setEnabled(false); | 116 | ok->setEnabled(false); |
117 | 117 | ||
118 | cleanup(); | 118 | cleanup(); |
119 | m_autocleanup = 0; | 119 | m_autocleanup = 0; |
120 | 120 | ||
121 | if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); | 121 | if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); |
122 | else statusbar->setText(QObject::tr("Receiving...")); | 122 | else statusbar->setText(QObject::tr("Receiving...")); |
123 | 123 | ||
124 | if(m_transfermode == id_send) | 124 | if(m_transfermode == id_send) |
125 | { | 125 | { |
126 | m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); | 126 | m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); |
127 | m_lay->sendFile(filename->text()); | 127 | m_lay->sendFile(filename->text()); |
128 | 128 | ||
129 | connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), | 129 | connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), |
130 | SLOT(slotProgress(const QString&, int, int, int, int, int))); | 130 | SLOT(slotProgress(const QString&, int, int, int, int, int))); |
131 | connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); | 131 | connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); |
132 | connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); | 132 | connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); |
133 | } | 133 | } |
134 | else | 134 | else |
135 | { | 135 | { |
136 | m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); | 136 | m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); |
137 | m_recvlay->receive(); | 137 | m_recvlay->receive(); |
138 | 138 | ||
139 | connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)), | 139 | connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)), |
140 | SLOT(slotProgress(const QString&, int, int, int, int, int))); | 140 | SLOT(slotProgress(const QString&, int, int, int, int, int))); |
141 | connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); | 141 | connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); |
142 | connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); | 142 | connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | void TransferDialog::cleanup() | 146 | void TransferDialog::cleanup() |
147 | { | 147 | { |
148 | if(m_lay) | 148 | if(m_lay) |
149 | { | 149 | { |
150 | m_lay->cancel(); | 150 | m_lay->cancel(); |
151 | delete m_lay; | 151 | delete m_lay; |
152 | m_lay = 0l; | 152 | m_lay = 0l; |
153 | } | 153 | } |
154 | if(m_recvlay) | 154 | if(m_recvlay) |
155 | { | 155 | { |
156 | m_recvlay->cancel(); | 156 | m_recvlay->cancel(); |
157 | delete m_recvlay; | 157 | delete m_recvlay; |
158 | m_recvlay = 0l; | 158 | m_recvlay = 0l; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | void TransferDialog::slotCancel() | 162 | void TransferDialog::slotCancel() |
163 | { | 163 | { |
164 | ok->setEnabled(true); | 164 | ok->setEnabled(true); |
165 | statusbar->setText(QObject::tr("Ready")); | 165 | statusbar->setText(QObject::tr("Ready")); |
166 | 166 | ||
167 | if((m_lay) || (m_recvlay)) | 167 | if((m_lay) || (m_recvlay)) |
168 | { | 168 | { |
169 | cleanup(); | 169 | cleanup(); |
170 | if(m_autocleanup) close(); | 170 | if(m_autocleanup) close(); |
171 | else | 171 | else |
172 | { | 172 | { |
173 | QMessageBox::information(this, | 173 | QMessageBox::information(this, |
174 | QObject::tr("Cancelled"), | 174 | QObject::tr("Cancelled"), |
175 | QObject::tr("The file transfer has been cancelled.")); | 175 | QObject::tr("The file transfer has been cancelled.")); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | else | 178 | else |
179 | { | 179 | { |
180 | close(); | 180 | close(); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) | 184 | void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) |
185 | { | 185 | { |
186 | progressbar->setProgress(progress); | 186 | progressbar->setProgress(progress); |
187 | } | 187 | } |
188 | 188 | ||
189 | void TransferDialog::slotError(int error, const QString& message) | 189 | void TransferDialog::slotError(int error, const QString& message) |
190 | { | 190 | { |
191 | statusbar->setText(QObject::tr("Ready")); | 191 | statusbar->setText(QObject::tr("Ready")); |
192 | 192 | ||
193 | switch(error) | 193 | switch(error) |
194 | { | 194 | { |
195 | case FileTransferLayer::NotSupported: | 195 | case FileTransferLayer::NotSupported: |
196 | QMessageBox::critical(this, | 196 | QMessageBox::critical(this, |
197 | QObject::tr("Error"), | 197 | QObject::tr("Error"), |
198 | QObject::tr("Operation not supported.")); | 198 | QObject::tr("Operation not supported.")); |
199 | break; | 199 | break; |
200 | case FileTransferLayer::StartError: | 200 | case FileTransferLayer::StartError: |
201 | QMessageBox::critical(this, | 201 | QMessageBox::critical(this, |
202 | QObject::tr("Error"), | 202 | QObject::tr("Error"), |
203 | QObject::tr("Transfer could not be started.")); | 203 | QObject::tr("Transfer could not be started.")); |
204 | break; | 204 | break; |
205 | case FileTransferLayer::NoError: | 205 | case FileTransferLayer::NoError: |
206 | QMessageBox::critical(this, | 206 | QMessageBox::critical(this, |
207 | QObject::tr("Error"), | 207 | QObject::tr("Error"), |
208 | QObject::tr("No error.")); | 208 | QObject::tr("No error.")); |
209 | break; | 209 | break; |
210 | case FileTransferLayer::Undefined: | 210 | case FileTransferLayer::Undefined: |
211 | QMessageBox::critical(this, | 211 | QMessageBox::critical(this, |
212 | QObject::tr("Error"), | 212 | QObject::tr("Error"), |
213 | QObject::tr("Undefined error occured.")); | 213 | QObject::tr("Undefined error occured.")); |
214 | break; | 214 | break; |
215 | case FileTransferLayer::Incomplete: | 215 | case FileTransferLayer::Incomplete: |
216 | QMessageBox::critical(this, | 216 | QMessageBox::critical(this, |
217 | QObject::tr("Error"), | 217 | QObject::tr("Error"), |
218 | QObject::tr("Incomplete transfer.")); | 218 | QObject::tr("Incomplete transfer.")); |
219 | break; | 219 | break; |
220 | case FileTransferLayer::Unknown: | 220 | case FileTransferLayer::Unknown: |
221 | default: | 221 | default: |
222 | QMessageBox::critical(this, | 222 | QMessageBox::critical(this, |
223 | QObject::tr("Error"), | 223 | QObject::tr("Error"), |
224 | QObject::tr("Unknown error occured.")); | 224 | QObject::tr("Unknown error occured.")); |
225 | break; | 225 | break; |
226 | } | 226 | } |
227 | 227 | ||
228 | m_autocleanup = 1; | 228 | m_autocleanup = 1; |
229 | } | 229 | } |
230 | 230 | ||
231 | void TransferDialog::slotSent() | 231 | void TransferDialog::slotSent() |
232 | { | 232 | { |
233 | progressbar->setProgress(100); | ||
233 | QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); | 234 | QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); |
234 | ok->setEnabled(true); | 235 | ok->setEnabled(true); |
236 | progressbar->setProgress(0); | ||
235 | statusbar->setText(QObject::tr("Ready")); | 237 | statusbar->setText(QObject::tr("Ready")); |
236 | m_autocleanup = 1; | 238 | m_autocleanup = 1; |
237 | } | 239 | } |
238 | 240 | ||
239 | void TransferDialog::slotReceived(const QString& file) | 241 | void TransferDialog::slotReceived(const QString& file) |
240 | { | 242 | { |
241 | QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); | 243 | progressbar->setProgress(100); |
244 | QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received.")); | ||
245 | //QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); | ||
242 | ok->setEnabled(true); | 246 | ok->setEnabled(true); |
247 | progressbar->setProgress(0); | ||
243 | statusbar->setText(QObject::tr("Ready")); | 248 | statusbar->setText(QObject::tr("Ready")); |
244 | m_autocleanup = 1; | 249 | m_autocleanup = 1; |
245 | } | 250 | } |
246 | 251 | ||
247 | void TransferDialog::slotMode(int id) | 252 | void TransferDialog::slotMode(int id) |
248 | { | 253 | { |
249 | if(id == id_send) | 254 | if(id == id_send) |
250 | { | 255 | { |
251 | selector->setEnabled(true); | 256 | selector->setEnabled(true); |
252 | filename->setEnabled(true); | 257 | filename->setEnabled(true); |
253 | } | 258 | } |
254 | else | 259 | else |
255 | { | 260 | { |
256 | selector->setEnabled(false); | 261 | selector->setEnabled(false); |
257 | filename->setEnabled(false); | 262 | filename->setEnabled(false); |
258 | } | 263 | } |
259 | m_transfermode = id; | 264 | m_transfermode = id; |
260 | } | 265 | } |
261 | 266 | ||