summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-12 18:55:56 (UTC)
committer zecke <zecke>2004-09-12 18:55:56 (UTC)
commit46a2a6d2f0046b6971cae371453705f6177fc93e (patch) (unidiff)
treeefb29d94d733716631f65820249e81691ff55761
parent36a4f75e1f4e5a3858749779ea26a3fe3154d1f0 (diff)
downloadopie-46a2a6d2f0046b6971cae371453705f6177fc93e.zip
opie-46a2a6d2f0046b6971cae371453705f6177fc93e.tar.gz
opie-46a2a6d2f0046b6971cae371453705f6177fc93e.tar.bz2
-Kill all owarn statements as they're not needed/useful anymore
-Kill all hardcoding to latin1 and use the system encoding/decoding
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/obex.cc28
-rw-r--r--core/obex/obexsend.cpp7
-rw-r--r--core/obex/receiver.cpp18
3 files changed, 9 insertions, 44 deletions
diff --git a/core/obex/obex.cc b/core/obex/obex.cc
index 7c40b90..5dfcfb5 100644
--- a/core/obex/obex.cc
+++ b/core/obex/obex.cc
@@ -33,9 +33,8 @@ Obex::~Obex() {
33} 33}
34void Obex::receive() { 34void Obex::receive() {
35 m_receive = true; 35 m_receive = true;
36 m_outp = QString::null; 36 m_outp = QString::null;
37 owarn << "Receive" << oendl;
38 m_rec = new OProcess(); 37 m_rec = new OProcess();
39 *m_rec << "irobex_palm3"; 38 *m_rec << "irobex_palm3";
40 // connect to the necessary slots 39 // connect to the necessary slots
41 connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ), 40 connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ),
@@ -44,38 +43,31 @@ void Obex::receive() {
44 connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), 43 connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
45 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); 44 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) );
46 45
47 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 46 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
48 owarn << "could not start :(" oendl;
49 emit done( false ); 47 emit done( false );
50 delete m_rec; 48 delete m_rec;
51 m_rec = 0; 49 m_rec = 0;
52 } 50 }
53// emit currentTry(m_count );
54
55} 51}
52
56void Obex::send( const QString& fileName) { // if currently receiving stop it send receive 53void Obex::send( const QString& fileName) { // if currently receiving stop it send receive
57 m_count = 0; 54 m_count = 0;
58 m_file = fileName; 55 m_file = fileName;
59 owarn << "send " << fileName.latin1() << oendl;
60 if (m_rec != 0 ) { 56 if (m_rec != 0 ) {
61 owarn << "running" oendl;
62 if (m_rec->isRunning() ) { 57 if (m_rec->isRunning() ) {
63 emit error(-1 ); 58 emit error(-1 );
64 owarn << "is running" << oendl;
65 delete m_rec; 59 delete m_rec;
66 m_rec = 0; 60 m_rec = 0;
67 61
68 }else{ 62 }else{
69 owarn << "is not running" << oendl;
70 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending 63 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending
71 return; 64 return;
72 } 65 }
73 } 66 }
74 sendNow(); 67 sendNow();
75} 68}
76void Obex::sendNow(){ 69void Obex::sendNow(){
77 owarn << "sendNow" << oendl;
78 if ( m_count >= 25 ) { // could not send 70 if ( m_count >= 25 ) { // could not send
79 emit error(-1 ); 71 emit error(-1 );
80 emit sent(false); 72 emit sent(false);
81 return; 73 return;
@@ -92,9 +84,8 @@ void Obex::sendNow(){
92 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); 84 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) );
93 85
94 // now start it 86 // now start it
95 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { 87 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) {
96 owarn << "could not send" << oendl;
97 m_count = 25; 88 m_count = 25;
98 emit error(-1 ); 89 emit error(-1 );
99 delete m_send; 90 delete m_send;
100 m_send=0; 91 m_send=0;
@@ -104,28 +95,26 @@ void Obex::sendNow(){
104 emit currentTry( m_count ); 95 emit currentTry( m_count );
105} 96}
106 97
107void Obex::slotExited(OProcess* proc ){ 98void Obex::slotExited(OProcess* proc ){
108 if (proc == m_rec ) { // receive process 99 if (proc == m_rec ) // receive process
109 received(); 100 received();
110 }else if ( proc == m_send ) { 101 else if ( proc == m_send )
111 sendEnd(); 102 sendEnd();
112 } 103
113} 104}
114void Obex::slotStdOut(OProcess* proc, char* buf, int len){ 105void Obex::slotStdOut(OProcess* proc, char* buf, int len){
115 if ( proc == m_rec ) { // only receive 106 if ( proc == m_rec ) { // only receive
116 QByteArray ar( len ); 107 QByteArray ar( len );
117 memcpy( ar.data(), buf, len ); 108 memcpy( ar.data(), buf, len );
118 owarn << "parsed: " << ar.data() << oendl;
119 m_outp.append( ar ); 109 m_outp.append( ar );
120 } 110 }
121} 111}
122 112
123void Obex::received() { 113void Obex::received() {
124 if (m_rec->normalExit() ) { 114 if (m_rec->normalExit() ) {
125 if ( m_rec->exitStatus() == 0 ) { // we got one 115 if ( m_rec->exitStatus() == 0 ) { // we got one
126 QString filename = parseOut(); 116 QString filename = parseOut();
127 owarn << "ACHTUNG " << filename.latin1() << oendl;
128 emit receivedFile( filename ); 117 emit receivedFile( filename );
129 } 118 }
130 }else{ 119 }else{
131 emit done(false); 120 emit done(false);
@@ -139,15 +128,13 @@ void Obex::sendEnd() {
139 if (m_send->normalExit() ) { 128 if (m_send->normalExit() ) {
140 if ( m_send->exitStatus() == 0 ) { 129 if ( m_send->exitStatus() == 0 ) {
141 delete m_send; 130 delete m_send;
142 m_send=0; 131 m_send=0;
143 owarn << "done" << oendl;
144 emit sent(true); 132 emit sent(true);
145 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready 133 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready
146 // let's try it again 134 // let's try it again
147 delete m_send; 135 delete m_send;
148 m_send = 0; 136 m_send = 0;
149 owarn << "try sending again" << oendl;
150 sendNow(); 137 sendNow();
151 } 138 }
152 }else { 139 }else {
153 emit error( -1 ); 140 emit error( -1 );
@@ -162,16 +149,12 @@ QString Obex::parseOut( ){
162 for (it = list.begin(); it != list.end(); ++it ) { 149 for (it = list.begin(); it != list.end(); ++it ) {
163 if ( (*it).startsWith("Wrote" ) ) { 150 if ( (*it).startsWith("Wrote" ) ) {
164 int pos = (*it).findRev('(' ); 151 int pos = (*it).findRev('(' );
165 if ( pos > 0 ) { 152 if ( pos > 0 ) {
166 owarn << pos << " " << (*it).mid(6 ).latin1() << oendl;
167 owarn << (*it).length() << " " << (*it).length()-pos << oendl;
168 153
169 path = (*it).remove( pos, (*it).length() - pos ); 154 path = (*it).remove( pos, (*it).length() - pos );
170 owarn << path.latin1() << oendl;
171 path = path.mid(6 ); 155 path = path.mid(6 );
172 path = path.stripWhiteSpace(); 156 path = path.stripWhiteSpace();
173 owarn << "path " << path.latin1() << oendl;
174 } 157 }
175 } 158 }
176 } 159 }
177 return path; 160 return path;
@@ -179,9 +162,8 @@ QString Obex::parseOut( ){
179/** 162/**
180 * when sent is done slotError is called we will start receive again 163 * when sent is done slotError is called we will start receive again
181 */ 164 */
182void Obex::slotError() { 165void Obex::slotError() {
183 owarn << "slotError" << oendl;
184 if ( m_receive ) 166 if ( m_receive )
185 receive(); 167 receive();
186}; 168};
187void Obex::setReceiveEnabled( bool receive ) { 169void Obex::setReceiveEnabled( bool receive ) {
@@ -192,12 +174,10 @@ void Obex::setReceiveEnabled( bool receive ) {
192} 174}
193 175
194void Obex::shutDownReceive() { 176void Obex::shutDownReceive() {
195 if (m_rec != 0 ) { 177 if (m_rec != 0 ) {
196 owarn << "running" << oendl;
197 if (m_rec->isRunning() ) { 178 if (m_rec->isRunning() ) {
198 emit error(-1 ); 179 emit error(-1 );
199 owarn << "is running" << oendl;
200 delete m_rec; 180 delete m_rec;
201 m_rec = 0; 181 m_rec = 0;
202 } 182 }
203 } 183 }
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp
index f3dd11c..675c5e4 100644
--- a/core/obex/obexsend.cpp
+++ b/core/obex/obexsend.cpp
@@ -104,9 +104,8 @@ void SendWidget::send( const QString& file, const QString& desc ) {
104 QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); 104 QCopEnvelope e3("QPE/Bluetooth", "listDevices()");
105 } 105 }
106} 106}
107void SendWidget::slotIrDaDevices( const QStringList& list) { 107void SendWidget::slotIrDaDevices( const QStringList& list) {
108 owarn << "slot it irda devices " << oendl;
109 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { 108 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) {
110 int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); 109 int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") );
111 m_irDa.insert( id, (*it) ); 110 m_irDa.insert( id, (*it) );
112 } 111 }
@@ -122,19 +121,17 @@ void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) {
122 m_bt.insert( id, Pair( it.key(), it.data() ) ); 121 m_bt.insert( id, Pair( it.key(), it.data() ) );
123 } 122 }
124 m_devBox->removeDevice( m_btDeSearch ); 123 m_devBox->removeDevice( m_btDeSearch );
125} 124}
126void SendWidget::slotSelectedDevice( int name, int dev ) { 125void SendWidget::slotSelectedDevice( int name, int ) {
127 owarn << "Start beam? " << name << " " << dev << "" << oendl;
128 if ( name == m_irDeSearch ) { 126 if ( name == m_irDeSearch ) {
129 for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) 127 for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it )
130 m_devBox->removeDevice( it.key() ); 128 m_devBox->removeDevice( it.key() );
131 129
132 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); 130 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
133 } 131 }
134} 132}
135void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { 133void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) {
136 owarn << "dispatch irda " << str.data() << "" << oendl;
137 if ( str == "devices(QStringList)" ) { 134 if ( str == "devices(QStringList)" ) {
138 QDataStream stream( ar, IO_ReadOnly ); 135 QDataStream stream( ar, IO_ReadOnly );
139 QStringList list; 136 QStringList list;
140 stream >> list; 137 stream >> list;
@@ -147,9 +144,8 @@ void SendWidget::dispatchBt( const QCString&, const QByteArray& ) {
147void SendWidget::slotIrError( int ) { 144void SendWidget::slotIrError( int ) {
148 145
149} 146}
150void SendWidget::slotIrSent( bool b) { 147void SendWidget::slotIrSent( bool b) {
151 owarn << "irda sent!!" << oendl;
152 QString text = b ? tr("Sent") : tr("Failure"); 148 QString text = b ? tr("Sent") : tr("Failure");
153 m_devBox->setStatus( m_irDaIt.key(), text ); 149 m_devBox->setStatus( m_irDaIt.key(), text );
154 ++m_irDaIt; 150 ++m_irDaIt;
155 slotStartIrda(); 151 slotStartIrda();
@@ -204,9 +200,8 @@ void DeviceBox::setStatus( int id, const QString& status ) {
204 m_dev[id].setStatus(status ); 200 m_dev[id].setStatus(status );
205 setText( allText() ); 201 setText( allText() );
206} 202}
207void DeviceBox::setSource( const QString& str ) { 203void DeviceBox::setSource( const QString& str ) {
208 owarn << "SetSource:" << str.toInt() << "" << oendl;
209 int id = str.toInt(); 204 int id = str.toInt();
210 emit selectedDevice( id, m_dev[id].device() ); 205 emit selectedDevice( id, m_dev[id].device() );
211} 206}
212int DeviceBox::idFor ( int id ) { 207int DeviceBox::idFor ( int id ) {
diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp
index d4ae323..7d9a42a 100644
--- a/core/obex/receiver.cpp
+++ b/core/obex/receiver.cpp
@@ -75,19 +75,17 @@ void Receiver::tidyUp( QString& _file, const QString& ending) {
75 75
76 if ( fd == -1 ) 76 if ( fd == -1 )
77 return; 77 return;
78 78
79 (void)::strncat( foo, ending.latin1(), 4 ); 79 (void)::strncat( foo, QFile::encodeName(ending), 4 );
80 _file = QString::fromLatin1( foo ); 80 _file = QString::fromLocal8Bit( foo );
81 QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) ); 81 QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) );
82 owarn << "Executing: " << cmd << "" << oendl; 82 (void)::system( QFile::encodeName(cmd) );
83 (void)::system( cmd.latin1() );
84 83
85 cmd = QString("rm %1").arg( Global::shellQuote(file) ); 84 cmd = QString("rm %1").arg( Global::shellQuote(file) );
86 (void)::system( cmd.latin1() ); 85 (void)::system( QFile::encodeName(cmd) );
87} 86}
88int Receiver::checkFile( QString& file ) { 87int Receiver::checkFile( QString& file ) {
89 owarn << "check file!! " << file << "" << oendl;
90 int ret; 88 int ret;
91 QString ending; 89 QString ending;
92 90
93 if (file.right(4) == ".vcs" ) { 91 if (file.right(4) == ".vcs" ) {
@@ -110,9 +108,8 @@ int Receiver::checkFile( QString& file ) {
110 * At this point we can also remove umlaute from the filename 108 * At this point we can also remove umlaute from the filename
111 */ 109 */
112 tidyUp( file, ending ); 110 tidyUp( file, ending );
113 111
114 owarn << "check it now " << ret << "" << oendl;
115 return ret; 112 return ret;
116} 113}
117 114
118/* TRANSLATOR OpieObex::OtherHandler */ 115/* TRANSLATOR OpieObex::OtherHandler */
@@ -151,9 +148,8 @@ OtherHandler::~OtherHandler() {
151void OtherHandler::handle( const QString& file ) { 148void OtherHandler::handle( const QString& file ) {
152 m_file = file; 149 m_file = file;
153 m_na->setText(file); 150 m_na->setText(file);
154 DocLnk lnk(file); 151 DocLnk lnk(file);
155 owarn << " " << lnk.type() << " " << lnk.icon() << "" << oendl;
156 152
157 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() ); 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() );
158 m_view->setText( str ); 154 m_view->setText( str );
159} 155}
@@ -194,15 +190,9 @@ QString OtherHandler::targetName( const QString& file ) {
194} 190}
195 191
196/* fast cpy */ 192/* fast cpy */
197void OtherHandler::copy(const QString& src, const QString& file) { 193void OtherHandler::copy(const QString& src, const QString& file) {
198 owarn << "src " << src << ", dest " << file << "" << oendl;
199 FileManager *fm; 194 FileManager *fm;
200 if(!fm->copyFile(src,file)) { 195 if(!fm->copyFile(src,file)) {
201 owarn << "Copy failed" << oendl; 196 owarn << "Copy failed" << oendl;
202 } 197 }
203
204// QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )).
205// arg( Global::shellQuote( file ) );
206// ::system( cmd.latin1() );
207 // done
208} 198}