-rw-r--r-- | core/obex/obexsend.cpp | 29 | ||||
-rw-r--r-- | core/obex/receiver.cpp | 41 |
2 files changed, 37 insertions, 33 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index cd8d58e..f3dd11c 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp | |||
@@ -1,28 +1,29 @@ | |||
1 | #include "obex.h" | ||
2 | #include "obexsend.h" | ||
3 | using namespace OpieObex; | ||
4 | |||
5 | /* OPIE */ | ||
6 | #include <opie2/odebug.h> | ||
7 | #include <qpe/qcopenvelope_qws.h> | ||
8 | using namespace Opie::Core; | ||
9 | |||
10 | /* QT */ | ||
1 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
2 | #include <qlabel.h> | 12 | #include <qlabel.h> |
3 | #include <qlayout.h> | 13 | #include <qlayout.h> |
4 | #include <qtimer.h> | 14 | #include <qtimer.h> |
5 | 15 | ||
6 | |||
7 | #include <qpe/qcopenvelope_qws.h> | ||
8 | |||
9 | #include "obex.h" | ||
10 | #include "obexsend.h" | ||
11 | |||
12 | using namespace OpieObex; | ||
13 | |||
14 | /* TRANSLATOR OpieObex::SendWidget */ | 16 | /* TRANSLATOR OpieObex::SendWidget */ |
15 | 17 | ||
16 | |||
17 | SendWidget::SendWidget( QWidget* parent, const char* name ) | 18 | SendWidget::SendWidget( QWidget* parent, const char* name ) |
18 | : QWidget( parent, name ) { | 19 | : QWidget( parent, name ) { |
19 | initUI(); | 20 | initUI(); |
20 | } | 21 | } |
21 | SendWidget::~SendWidget() { | 22 | SendWidget::~SendWidget() { |
22 | } | 23 | } |
23 | void SendWidget::initUI() { | 24 | void SendWidget::initUI() { |
24 | m_obex = new Obex(this, "obex"); | 25 | m_obex = new Obex(this, "obex"); |
25 | connect(m_obex, SIGNAL(error(int) ), | 26 | connect(m_obex, SIGNAL(error(int) ), |
26 | this, SLOT(slotIrError(int) ) ); | 27 | this, SLOT(slotIrError(int) ) ); |
27 | connect(m_obex, SIGNAL(sent(bool) ), | 28 | connect(m_obex, SIGNAL(sent(bool) ), |
28 | this, SLOT(slotIrSent(bool) ) ); | 29 | this, SLOT(slotIrSent(bool) ) ); |
@@ -95,68 +96,68 @@ void SendWidget::send( const QString& file, const QString& desc ) { | |||
95 | m_start++; | 96 | m_start++; |
96 | }else | 97 | }else |
97 | m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); | 98 | m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); |
98 | 99 | ||
99 | if (m_start != 2 ) { | 100 | if (m_start != 2 ) { |
100 | QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); | 101 | QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); |
101 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); | 102 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); |
102 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 103 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
103 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); | 104 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); |
104 | } | 105 | } |
105 | } | 106 | } |
106 | void SendWidget::slotIrDaDevices( const QStringList& list) { | 107 | void SendWidget::slotIrDaDevices( const QStringList& list) { |
107 | qWarning("slot it irda devices "); | 108 | owarn << "slot it irda devices " << oendl; |
108 | for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { | 109 | for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { |
109 | int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); | 110 | int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); |
110 | m_irDa.insert( id, (*it) ); | 111 | m_irDa.insert( id, (*it) ); |
111 | } | 112 | } |
112 | m_devBox->removeDevice( m_irDeSearch ); | 113 | m_devBox->removeDevice( m_irDeSearch ); |
113 | m_irDaIt = m_irDa.begin(); | 114 | m_irDaIt = m_irDa.begin(); |
114 | 115 | ||
115 | slotStartIrda(); | 116 | slotStartIrda(); |
116 | } | 117 | } |
117 | 118 | ||
118 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { | 119 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { |
119 | for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { | 120 | for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { |
120 | int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); | 121 | int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); |
121 | m_bt.insert( id, Pair( it.key(), it.data() ) ); | 122 | m_bt.insert( id, Pair( it.key(), it.data() ) ); |
122 | } | 123 | } |
123 | m_devBox->removeDevice( m_btDeSearch ); | 124 | m_devBox->removeDevice( m_btDeSearch ); |
124 | } | 125 | } |
125 | void SendWidget::slotSelectedDevice( int name, int dev ) { | 126 | void SendWidget::slotSelectedDevice( int name, int dev ) { |
126 | qWarning("Start beam? %d %d", name, dev ); | 127 | owarn << "Start beam? " << name << " " << dev << "" << oendl; |
127 | if ( name == m_irDeSearch ) { | 128 | if ( name == m_irDeSearch ) { |
128 | for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) | 129 | for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) |
129 | m_devBox->removeDevice( it.key() ); | 130 | m_devBox->removeDevice( it.key() ); |
130 | 131 | ||
131 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 132 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
132 | } | 133 | } |
133 | } | 134 | } |
134 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { | 135 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { |
135 | qWarning("dispatch irda %s", str.data() ); | 136 | owarn << "dispatch irda " << str.data() << "" << oendl; |
136 | if ( str == "devices(QStringList)" ) { | 137 | if ( str == "devices(QStringList)" ) { |
137 | QDataStream stream( ar, IO_ReadOnly ); | 138 | QDataStream stream( ar, IO_ReadOnly ); |
138 | QStringList list; | 139 | QStringList list; |
139 | stream >> list; | 140 | stream >> list; |
140 | slotIrDaDevices( list ); | 141 | slotIrDaDevices( list ); |
141 | } | 142 | } |
142 | } | 143 | } |
143 | void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { | 144 | void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { |
144 | 145 | ||
145 | } | 146 | } |
146 | void SendWidget::slotIrError( int ) { | 147 | void SendWidget::slotIrError( int ) { |
147 | 148 | ||
148 | } | 149 | } |
149 | void SendWidget::slotIrSent( bool b) { | 150 | void SendWidget::slotIrSent( bool b) { |
150 | qWarning("irda sent!!"); | 151 | owarn << "irda sent!!" << oendl; |
151 | QString text = b ? tr("Sent") : tr("Failure"); | 152 | QString text = b ? tr("Sent") : tr("Failure"); |
152 | m_devBox->setStatus( m_irDaIt.key(), text ); | 153 | m_devBox->setStatus( m_irDaIt.key(), text ); |
153 | ++m_irDaIt; | 154 | ++m_irDaIt; |
154 | slotStartIrda(); | 155 | slotStartIrda(); |
155 | } | 156 | } |
156 | void SendWidget::slotIrTry(unsigned int trI) { | 157 | void SendWidget::slotIrTry(unsigned int trI) { |
157 | m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); | 158 | m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); |
158 | } | 159 | } |
159 | void SendWidget::slotStartIrda() { | 160 | void SendWidget::slotStartIrda() { |
160 | if (m_irDaIt == m_irDa.end() ) { | 161 | if (m_irDaIt == m_irDa.end() ) { |
161 | m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); | 162 | m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); |
162 | return; | 163 | return; |
@@ -195,25 +196,25 @@ int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) | |||
195 | void DeviceBox::removeDevice( int id ) { | 196 | void DeviceBox::removeDevice( int id ) { |
196 | if (!m_dev.contains(id) ) return; | 197 | if (!m_dev.contains(id) ) return; |
197 | 198 | ||
198 | m_dev.remove( id ); | 199 | m_dev.remove( id ); |
199 | setText( allText() ); | 200 | setText( allText() ); |
200 | } | 201 | } |
201 | void DeviceBox::setStatus( int id, const QString& status ) { | 202 | void DeviceBox::setStatus( int id, const QString& status ) { |
202 | if ( !m_dev.contains(id) ) return; | 203 | if ( !m_dev.contains(id) ) return; |
203 | m_dev[id].setStatus(status ); | 204 | m_dev[id].setStatus(status ); |
204 | setText( allText() ); | 205 | setText( allText() ); |
205 | } | 206 | } |
206 | void DeviceBox::setSource( const QString& str ) { | 207 | void DeviceBox::setSource( const QString& str ) { |
207 | qWarning("SetSource:%d", str.toInt() ); | 208 | owarn << "SetSource:" << str.toInt() << "" << oendl; |
208 | int id = str.toInt(); | 209 | int id = str.toInt(); |
209 | emit selectedDevice( id, m_dev[id].device() ); | 210 | emit selectedDevice( id, m_dev[id].device() ); |
210 | } | 211 | } |
211 | int DeviceBox::idFor ( int id ) { | 212 | int DeviceBox::idFor ( int id ) { |
212 | static int irId = 1501; | 213 | static int irId = 1501; |
213 | static int irBT = 1001; | 214 | static int irBT = 1001; |
214 | static int irSr = 501; | 215 | static int irSr = 501; |
215 | static int irEr = 0; | 216 | static int irEr = 0; |
216 | 217 | ||
217 | int ret = -1; | 218 | int ret = -1; |
218 | switch(id ) { | 219 | switch(id ) { |
219 | case IrDa: | 220 | case IrDa: |
diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp index ee2668b..8885256 100644 --- a/core/obex/receiver.cpp +++ b/core/obex/receiver.cpp | |||
@@ -1,33 +1,36 @@ | |||
1 | #include <sys/types.h> | 1 | #include "obex.h" |
2 | #include <sys/stat.h> | 2 | #include "receiver.h" |
3 | #include <sys/mman.h> | 3 | using namespace OpieObex; |
4 | #include <stdlib.h> // int system | ||
5 | #include <unistd.h> | ||
6 | 4 | ||
7 | #include <fcntl.h> | 5 | /* OPIE */ |
6 | #include <opie2/odebug.h> | ||
7 | #include <qpe/applnk.h> | ||
8 | #include <qpe/qpeapplication.h> | ||
9 | #include <qpe/qcopenvelope_qws.h> | ||
10 | using namespace Opie::Core; | ||
8 | 11 | ||
12 | /* QT */ | ||
9 | #include <qfileinfo.h> | 13 | #include <qfileinfo.h> |
10 | #include <qlabel.h> | 14 | #include <qlabel.h> |
11 | #include <qtextview.h> | 15 | #include <qtextview.h> |
12 | #include <qpushbutton.h> | 16 | #include <qpushbutton.h> |
13 | 17 | ||
14 | #include <qpe/applnk.h> | 18 | /* STD */ |
15 | #include <qpe/qpeapplication.h> | 19 | #include <sys/types.h> |
16 | #include <qpe/qcopenvelope_qws.h> | 20 | #include <sys/stat.h> |
17 | 21 | #include <sys/mman.h> | |
18 | #include "obex.h" | 22 | #include <stdlib.h> // int system |
19 | #include "receiver.h" | 23 | #include <unistd.h> |
20 | 24 | #include <fcntl.h> | |
21 | using namespace OpieObex; | ||
22 | 25 | ||
23 | /* TRANSLATOR OpieObex::Receiver */ | 26 | /* TRANSLATOR OpieObex::Receiver */ |
24 | 27 | ||
25 | Receiver::Receiver() { | 28 | Receiver::Receiver() { |
26 | m_obex = new Obex(this, "Receiver"); | 29 | m_obex = new Obex(this, "Receiver"); |
27 | connect(m_obex, SIGNAL(receivedFile(const QString&) ), | 30 | connect(m_obex, SIGNAL(receivedFile(const QString&) ), |
28 | this, SLOT(slotReceived(const QString&) ) ); | 31 | this, SLOT(slotReceived(const QString&) ) ); |
29 | m_obex->receive(); | 32 | m_obex->receive(); |
30 | } | 33 | } |
31 | Receiver::~Receiver() { | 34 | Receiver::~Receiver() { |
32 | m_obex->setReceiveEnabled( false ); | 35 | m_obex->setReceiveEnabled( false ); |
33 | delete m_obex; | 36 | delete m_obex; |
@@ -66,57 +69,57 @@ void Receiver::tidyUp( QString& _file, const QString& ending) { | |||
66 | QString file = _file; | 69 | QString file = _file; |
67 | char foo[24]; // big enough | 70 | char foo[24]; // big enough |
68 | (void)::strcpy(foo, "/tmp/opie-XXXXXX"); | 71 | (void)::strcpy(foo, "/tmp/opie-XXXXXX"); |
69 | 72 | ||
70 | int fd = ::mkstemp(foo); | 73 | int fd = ::mkstemp(foo); |
71 | 74 | ||
72 | if ( fd == -1 ) | 75 | if ( fd == -1 ) |
73 | return; | 76 | return; |
74 | 77 | ||
75 | (void)::strncat( foo, ending.latin1(), 4 ); | 78 | (void)::strncat( foo, ending.latin1(), 4 ); |
76 | _file = QString::fromLatin1( foo ); | 79 | _file = QString::fromLatin1( foo ); |
77 | QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) ); | 80 | QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) ); |
78 | qWarning("Executing: %s", cmd.latin1() ); | 81 | owarn << "Executing: " << cmd << "" << oendl; |
79 | (void)::system( cmd.latin1() ); | 82 | (void)::system( cmd.latin1() ); |
80 | 83 | ||
81 | cmd = QString("rm %1").arg( Global::shellQuote(file) ); | 84 | cmd = QString("rm %1").arg( Global::shellQuote(file) ); |
82 | (void)::system( cmd.latin1() ); | 85 | (void)::system( cmd.latin1() ); |
83 | } | 86 | } |
84 | int Receiver::checkFile( QString& file ) { | 87 | int Receiver::checkFile( QString& file ) { |
85 | qWarning("check file!! %s", file.latin1() ); | 88 | owarn << "check file!! " << file << "" << oendl; |
86 | int ret; | 89 | int ret; |
87 | QString ending; | 90 | QString ending; |
88 | 91 | ||
89 | if (file.right(4) == ".vcs" ) { | 92 | if (file.right(4) == ".vcs" ) { |
90 | ret = Datebook; | 93 | ret = Datebook; |
91 | ending = QString::fromLatin1(".vcs"); | 94 | ending = QString::fromLatin1(".vcs"); |
92 | }else if ( file.right(4) == ".vcf") { | 95 | }else if ( file.right(4) == ".vcf") { |
93 | ret = AddressBook; | 96 | ret = AddressBook; |
94 | ending = QString::fromLatin1(".vcf"); | 97 | ending = QString::fromLatin1(".vcf"); |
95 | }else | 98 | }else |
96 | ret = Other; | 99 | ret = Other; |
97 | 100 | ||
98 | 101 | ||
99 | if (ending.isEmpty() ) | 102 | if (ending.isEmpty() ) |
100 | return ret; | 103 | return ret; |
101 | 104 | ||
102 | /** | 105 | /** |
103 | * currently the parser is broken in regard of BASE64 encoding | 106 | * currently the parser is broken in regard of BASE64 encoding |
104 | * and M$ likes to send that. So we will executed a small | 107 | * and M$ likes to send that. So we will executed a small |
105 | * tidy up system sed script | 108 | * tidy up system sed script |
106 | * At this point we can also remove umlaute from the filename | 109 | * At this point we can also remove umlaute from the filename |
107 | */ | 110 | */ |
108 | tidyUp( file, ending ); | 111 | tidyUp( file, ending ); |
109 | 112 | ||
110 | qWarning("check it now %d", ret ); | 113 | owarn << "check it now " << ret << "" << oendl; |
111 | return ret; | 114 | return ret; |
112 | } | 115 | } |
113 | 116 | ||
114 | /* TRANSLATOR OpieObex::OtherHandler */ | 117 | /* TRANSLATOR OpieObex::OtherHandler */ |
115 | 118 | ||
116 | OtherHandler::OtherHandler() | 119 | OtherHandler::OtherHandler() |
117 | : QVBox() | 120 | : QVBox() |
118 | { | 121 | { |
119 | QHBox* box = new QHBox(this); | 122 | QHBox* box = new QHBox(this); |
120 | QLabel* lbl = new QLabel(box); | 123 | QLabel* lbl = new QLabel(box); |
121 | lbl->setText(tr("<qt><b>Received:</b></qt>")); | 124 | lbl->setText(tr("<qt><b>Received:</b></qt>")); |
122 | m_na = new QLabel(box); | 125 | m_na = new QLabel(box); |
@@ -139,25 +142,25 @@ OtherHandler::OtherHandler() | |||
139 | this, SLOT(deny() ) ); | 142 | this, SLOT(deny() ) ); |
140 | 143 | ||
141 | raise(); | 144 | raise(); |
142 | showMaximized(); | 145 | showMaximized(); |
143 | } | 146 | } |
144 | OtherHandler::~OtherHandler() { | 147 | OtherHandler::~OtherHandler() { |
145 | 148 | ||
146 | } | 149 | } |
147 | void OtherHandler::handle( const QString& file ) { | 150 | void OtherHandler::handle( const QString& file ) { |
148 | m_file = file; | 151 | m_file = file; |
149 | m_na->setText(file); | 152 | m_na->setText(file); |
150 | DocLnk lnk(file); | 153 | DocLnk lnk(file); |
151 | qWarning(" %s %s", lnk.type().latin1(), lnk.icon().latin1() ); | 154 | owarn << " " << lnk.type() << " " << lnk.icon() << "" << oendl; |
152 | 155 | ||
153 | QString str = tr("<p>You received a file of type %1 (<img src=\"%2\"> )What do you want to do?").arg(lnk.type() ).arg(lnk.icon() ); | 156 | QString str = tr("<p>You received a file of type %1 (<img src=\"%2\"> )What do you want to do?").arg(lnk.type() ).arg(lnk.icon() ); |
154 | m_view->setText( str ); | 157 | m_view->setText( str ); |
155 | } | 158 | } |
156 | 159 | ||
157 | /* | 160 | /* |
158 | * hehe evil evil mmap ahead :) | 161 | * hehe evil evil mmap ahead :) |
159 | * we quickly copy the file and then we'll create a DocLnk for it | 162 | * we quickly copy the file and then we'll create a DocLnk for it |
160 | */ | 163 | */ |
161 | void OtherHandler::accept() { | 164 | void OtherHandler::accept() { |
162 | QString na = targetName( m_file ); | 165 | QString na = targetName( m_file ); |
163 | copy(m_file, na ); | 166 | copy(m_file, na ); |
@@ -182,18 +185,18 @@ QString OtherHandler::targetName( const QString& file ) { | |||
182 | int trie = 0; | 185 | int trie = 0; |
183 | while (QFile::exists(newFile + "."+info.extension() ) ) { | 186 | while (QFile::exists(newFile + "."+info.extension() ) ) { |
184 | newFile = newFileBase + "_"+QString::number(trie) ; | 187 | newFile = newFileBase + "_"+QString::number(trie) ; |
185 | trie++; | 188 | trie++; |
186 | } | 189 | } |
187 | newFile += "." + info.extension(); | 190 | newFile += "." + info.extension(); |
188 | 191 | ||
189 | return newFile; | 192 | return newFile; |
190 | } | 193 | } |
191 | 194 | ||
192 | /* fast cpy */ | 195 | /* fast cpy */ |
193 | void OtherHandler::copy(const QString& src, const QString& file) { | 196 | void OtherHandler::copy(const QString& src, const QString& file) { |
194 | qWarning("src %s, dest %s", src.latin1(),file.latin1() ); | 197 | owarn << "src " << src << ", dest " << file << "" << oendl; |
195 | QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )). | 198 | QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )). |
196 | arg( Global::shellQuote( file ) ); | 199 | arg( Global::shellQuote( file ) ); |
197 | ::system( cmd.latin1() ); | 200 | ::system( cmd.latin1() ); |
198 | // done | 201 | // done |
199 | } | 202 | } |