author | harlekin <harlekin> | 2002-06-14 10:30:25 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-14 10:30:25 (UTC) |
commit | a014866573fc86bf63544d1f692ccdd94c0d104f (patch) (unidiff) | |
tree | 26c91e69d84aed959b8163bb853966f67041063b | |
parent | cf54bc85d0e9846d64ca2a2af55fffc3d4e2f4ad (diff) | |
download | opie-a014866573fc86bf63544d1f692ccdd94c0d104f.zip opie-a014866573fc86bf63544d1f692ccdd94c0d104f.tar.gz opie-a014866573fc86bf63544d1f692ccdd94c0d104f.tar.bz2 |
fixed type and getting closer to finish
-rw-r--r-- | core/applets/obex/.cvsignore | 1 | ||||
-rw-r--r-- | core/applets/obex/obex.cc | 9 | ||||
-rw-r--r-- | core/applets/obex/obex.h | 2 | ||||
-rw-r--r-- | core/applets/obex/obeximpl.cc | 12 |
4 files changed, 17 insertions, 7 deletions
diff --git a/core/applets/obex/.cvsignore b/core/applets/obex/.cvsignore index c7899af..8fde018 100644 --- a/core/applets/obex/.cvsignore +++ b/core/applets/obex/.cvsignore | |||
@@ -1,6 +1,7 @@ | |||
1 | Makefile | 1 | Makefile |
2 | Makefile.in | ||
2 | moc* | 3 | moc* |
3 | obexdlg.cpp | 4 | obexdlg.cpp |
4 | obexdlg.h | 5 | obexdlg.h |
5 | obexinc.cpp | 6 | obexinc.cpp |
6 | obexinc.h | 7 | obexinc.h |
diff --git a/core/applets/obex/obex.cc b/core/applets/obex/obex.cc index fc0be3b..43041f5 100644 --- a/core/applets/obex/obex.cc +++ b/core/applets/obex/obex.cc | |||
@@ -51,113 +51,114 @@ void Obex::send( const QString& fileName) { // if currently receiving stop it se | |||
51 | qWarning("send"); | 51 | qWarning("send"); |
52 | if (m_rec != 0 ) { | 52 | if (m_rec != 0 ) { |
53 | qWarning("running"); | 53 | qWarning("running"); |
54 | if (m_rec->isRunning() ) { | 54 | if (m_rec->isRunning() ) { |
55 | emit error(-1 ); | 55 | emit error(-1 ); |
56 | qWarning("is running"); | 56 | qWarning("is running"); |
57 | delete m_rec; | 57 | delete m_rec; |
58 | m_rec = 0; | 58 | m_rec = 0; |
59 | 59 | ||
60 | }else{ | 60 | }else{ |
61 | qWarning("is not running"); | 61 | qWarning("is not running"); |
62 | emit error( -1 ); // we did not delete yet but it's not running slotExited is pending | 62 | emit error( -1 ); // we did not delete yet but it's not running slotExited is pending |
63 | return; | 63 | return; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | sendNow(); | 66 | sendNow(); |
67 | } | 67 | } |
68 | void Obex::sendNow(){ | 68 | void Obex::sendNow(){ |
69 | qWarning("sendNow"); | 69 | qWarning("sendNow"); |
70 | if ( m_count >= 25 ) { // could not send | 70 | if ( m_count >= 25 ) { // could not send |
71 | emit error(-1 ); | 71 | emit error(-1 ); |
72 | return; | 72 | return; |
73 | } | 73 | } |
74 | // OProcess inititialisation | 74 | // OProcess inititialisation |
75 | m_send = new OProcess(); | 75 | m_send = new OProcess(); |
76 | *m_send << "irobex_palm3"; | 76 | *m_send << "irobex_palm3"; |
77 | *m_send << m_file; | 77 | *m_send << m_file; |
78 | 78 | ||
79 | // connect to slots Exited and and StdOut | 79 | // connect to slots Exited and and StdOut |
80 | connect(m_send, SIGNAL(processExited(OProcess*) ), | 80 | connect(m_send, SIGNAL(processExited(OProcess*) ), |
81 | this, SLOT(slotExited(OProcess*)) ); | 81 | this, SLOT(slotExited(OProcess*)) ); |
82 | connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), | 82 | connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), |
83 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); | 83 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); |
84 | 84 | ||
85 | // now start it | 85 | // now start it |
86 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { | 86 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { |
87 | qWarning("could not send" ); | 87 | qWarning("could not send" ); |
88 | m_count = 25; | 88 | m_count = 25; |
89 | emit error(-1 ); | 89 | emit error(-1 ); |
90 | delete m_send; | 90 | delete m_send; |
91 | m_send=0; | 91 | m_send=0; |
92 | } | 92 | } |
93 | // end | 93 | // end |
94 | m_count++; | 94 | m_count++; |
95 | emit currentTry( m_count ); | 95 | emit currentTry( m_count ); |
96 | } | 96 | } |
97 | 97 | ||
98 | void Obex::slotExited(OProcess* proc ){ | 98 | void Obex::slotExited(OProcess* proc ){ |
99 | if (proc == m_rec ) { // recieve process | 99 | if (proc == m_rec ) { // receive process |
100 | recieved(); | 100 | received(); |
101 | }else if ( proc == m_send ) { | 101 | }else if ( proc == m_send ) { |
102 | sendEnd(); | 102 | sendEnd(); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | void Obex::slotStdOut(OProcess* proc, char* buf, int len){ | 105 | void Obex::slotStdOut(OProcess* proc, char* buf, int len){ |
106 | if ( proc == m_rec ) { // only recieve | 106 | if ( proc == m_rec ) { // only receive |
107 | QCString cstring( buf, len ); | 107 | QCString cstring( buf, len ); |
108 | m_outp.append( cstring.data() ); | 108 | m_outp.append( cstring.data() ); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | void Obex::recieved() { | 112 | void Obex::received() { |
113 | if (m_rec->normalExit() ) { | 113 | if (m_rec->normalExit() ) { |
114 | if ( m_rec->exitStatus() == 0 ) { // we got one | 114 | if ( m_rec->exitStatus() == 0 ) { // we got one |
115 | QString filename = parseOut(); | 115 | QString filename = parseOut(); |
116 | qWarning("ACHTUNG"); | ||
116 | emit receivedFile( filename ); | 117 | emit receivedFile( filename ); |
117 | } | 118 | } |
118 | }else{ | 119 | }else{ |
119 | emit done(false); | 120 | emit done(false); |
120 | }; | 121 | }; |
121 | delete m_rec; | 122 | delete m_rec; |
122 | m_rec = 0; | 123 | m_rec = 0; |
123 | receive(); | 124 | receive(); |
124 | } | 125 | } |
125 | 126 | ||
126 | void Obex::sendEnd() { | 127 | void Obex::sendEnd() { |
127 | if (m_send->normalExit() ) { | 128 | if (m_send->normalExit() ) { |
128 | if ( m_send->exitStatus() == 0 ) { | 129 | if ( m_send->exitStatus() == 0 ) { |
129 | delete m_send; | 130 | delete m_send; |
130 | m_send=0; | 131 | m_send=0; |
131 | qWarning("done" ); | 132 | qWarning("done" ); |
132 | emit sent(); | 133 | emit sent(); |
133 | }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready | 134 | }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready |
134 | // let's try it again | 135 | // let's try it again |
135 | delete m_send; | 136 | delete m_send; |
136 | m_send = 0; | 137 | m_send = 0; |
137 | qWarning("try sending again" ); | 138 | qWarning("try sending again" ); |
138 | sendNow(); | 139 | sendNow(); |
139 | } | 140 | } |
140 | }else { | 141 | }else { |
141 | emit error( -1 ); | 142 | emit error( -1 ); |
142 | delete m_send; | 143 | delete m_send; |
143 | m_send = 0; | 144 | m_send = 0; |
144 | } | 145 | } |
145 | } | 146 | } |
146 | QString Obex::parseOut( ){ | 147 | QString Obex::parseOut( ){ |
147 | QString path; | 148 | QString path; |
148 | QStringList list = QStringList::split("\n", m_outp); | 149 | QStringList list = QStringList::split("\n", m_outp); |
149 | QStringList::Iterator it; | 150 | QStringList::Iterator it; |
150 | for (it = list.begin(); it != list.end(); ++it ) { | 151 | for (it = list.begin(); it != list.end(); ++it ) { |
151 | if ( (*it).startsWith("Wrote" ) ) { | 152 | if ( (*it).startsWith("Wrote" ) ) { |
152 | int pos = (*it).findRev('(' ); | 153 | int pos = (*it).findRev('(' ); |
153 | if ( pos > 0 ) { | 154 | if ( pos > 0 ) { |
154 | qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ; | 155 | qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ; |
155 | qWarning("%d %d", (*it).length(), (*it).length()-pos ); | 156 | qWarning("%d %d", (*it).length(), (*it).length()-pos ); |
156 | 157 | ||
157 | path = (*it).remove( pos, (*it).length() - pos ); | 158 | path = (*it).remove( pos, (*it).length() - pos ); |
158 | qWarning("%s", path.latin1() ); | 159 | qWarning("%s", path.latin1() ); |
159 | path = path.mid(6 ); | 160 | path = path.mid(6 ); |
160 | path = path.stripWhiteSpace(); | 161 | path = path.stripWhiteSpace(); |
161 | qWarning("path %s", path.latin1() ); | 162 | qWarning("path %s", path.latin1() ); |
162 | } | 163 | } |
163 | } | 164 | } |
diff --git a/core/applets/obex/obex.h b/core/applets/obex/obex.h index 2ce44f2..781fca2 100644 --- a/core/applets/obex/obex.h +++ b/core/applets/obex/obex.h | |||
@@ -30,56 +30,56 @@ namespace OpieObex { | |||
30 | signals: | 30 | signals: |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * a signal | 33 | * a signal |
34 | * @param path The path to the recieved file | 34 | * @param path The path to the recieved file |
35 | */ | 35 | */ |
36 | void receivedFile( const QString& path); | 36 | void receivedFile( const QString& path); |
37 | /** | 37 | /** |
38 | * error signal if the program couldn't be started or the | 38 | * error signal if the program couldn't be started or the |
39 | * the connection timed out | 39 | * the connection timed out |
40 | */ | 40 | */ |
41 | void error( int ); | 41 | void error( int ); |
42 | /** | 42 | /** |
43 | * The current try to receive data | 43 | * The current try to receive data |
44 | */ | 44 | */ |
45 | void currentTry(unsigned int); | 45 | void currentTry(unsigned int); |
46 | /** | 46 | /** |
47 | * signal sent The file got beamed to the remote location | 47 | * signal sent The file got beamed to the remote location |
48 | */ | 48 | */ |
49 | void sent(); | 49 | void sent(); |
50 | // private slots | 50 | // private slots |
51 | void done(bool); | 51 | void done(bool); |
52 | 52 | ||
53 | private: | 53 | private: |
54 | uint m_count; | 54 | uint m_count; |
55 | QString m_file; | 55 | QString m_file; |
56 | QString m_outp; | 56 | QString m_outp; |
57 | OProcess *m_send; | 57 | OProcess *m_send; |
58 | OProcess *m_rec; | 58 | OProcess *m_rec; |
59 | bool m_receive : 1; | 59 | bool m_receive : 1; |
60 | void shutDownReceive(); | 60 | void shutDownReceive(); |
61 | 61 | ||
62 | private slots: | 62 | private slots: |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * send over palm obex | 65 | * send over palm obex |
66 | */ | 66 | */ |
67 | 67 | ||
68 | //void send(const QString&); | 68 | //void send(const QString&); |
69 | 69 | ||
70 | // the process exited | 70 | // the process exited |
71 | void slotExited(OProcess* proc) ; | 71 | void slotExited(OProcess* proc) ; |
72 | void slotStdOut(OProcess*, char*, int); | 72 | void slotStdOut(OProcess*, char*, int); |
73 | void slotError(); | 73 | void slotError(); |
74 | 74 | ||
75 | private: | 75 | private: |
76 | void sendNow(); | 76 | void sendNow(); |
77 | QString parseOut(); | 77 | QString parseOut(); |
78 | void recieved(); | 78 | void received(); |
79 | void sendEnd(); | 79 | void sendEnd(); |
80 | 80 | ||
81 | }; | 81 | }; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | 84 | ||
85 | #endif | 85 | #endif |
diff --git a/core/applets/obex/obeximpl.cc b/core/applets/obex/obeximpl.cc index 1a1c922..7df933a 100644 --- a/core/applets/obex/obeximpl.cc +++ b/core/applets/obex/obeximpl.cc | |||
@@ -1,136 +1,144 @@ | |||
1 | 1 | ||
2 | #include <qdatastream.h> | 2 | #include <qdatastream.h> |
3 | #include <qmessagebox.h> | 3 | #include <qmessagebox.h> |
4 | 4 | ||
5 | 5 | ||
6 | #include <qpe/qcom.h> | 6 | #include <qpe/qcom.h> |
7 | #include <qpe/applnk.h> | 7 | #include <qpe/applnk.h> |
8 | 8 | ||
9 | #include <qlabel.h> | 9 | #include <qlabel.h> |
10 | 10 | ||
11 | #include "obex.h" | 11 | #include "obex.h" |
12 | #include "obeximpl.h" | 12 | #include "obeximpl.h" |
13 | 13 | ||
14 | 14 | ||
15 | 15 | ||
16 | using namespace OpieObex; | 16 | using namespace OpieObex; |
17 | 17 | ||
18 | ObexImpl::ObexImpl( ) | 18 | ObexImpl::ObexImpl( ) |
19 | : QObject() { | 19 | : QObject() { |
20 | // register to a channel | 20 | // register to a channel |
21 | qWarning( "c'tor" ); | 21 | qWarning( "c'tor" ); |
22 | m_obex = new Obex(this, "obex"); | 22 | m_obex = new Obex(this, "obex"); |
23 | m_sendgui = new ObexDlg(); | 23 | m_sendgui = new ObexDlg(); |
24 | m_recvgui = new ObexInc(); | 24 | m_recvgui = new ObexInc(); |
25 | m_chan = new QCopChannel("QPE/Obex" ); | 25 | m_chan = new QCopChannel("QPE/Obex" ); |
26 | connect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | 26 | connect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ), |
27 | this, SLOT(slotMessage(const QCString&, const QByteArray&) ) ); | 27 | this, SLOT(slotMessage(const QCString&, const QByteArray&) ) ); |
28 | connect(m_obex, SIGNAL(receivedFile(const QString& ) ), | 28 | connect(m_obex, SIGNAL(receivedFile(const QString& ) ), |
29 | this, SLOT(slotReceivedFile(const QString& ) ) ); | 29 | this, SLOT(slotReceivedFile(const QString& ) ) ); |
30 | } | 30 | } |
31 | |||
31 | ObexImpl::~ObexImpl() { | 32 | ObexImpl::~ObexImpl() { |
32 | delete m_obex; | 33 | delete m_obex; |
33 | delete m_chan; | 34 | delete m_chan; |
34 | delete m_sendgui; | 35 | delete m_sendgui; |
35 | } | 36 | } |
37 | |||
36 | QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 38 | QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
37 | *iface = 0; | 39 | *iface = 0; |
38 | if( uuid == IID_QUnknown ) | 40 | if( uuid == IID_QUnknown ) |
39 | *iface = this; | 41 | *iface = this; |
40 | else if( uuid == IID_ObexInterface ) | 42 | else if( uuid == IID_ObexInterface ) |
41 | *iface = this; | 43 | *iface = this; |
42 | 44 | ||
43 | qWarning("query" ); | 45 | qWarning("query" ); |
44 | if(*iface ) | 46 | if(*iface ) |
45 | (*iface)->addRef(); | 47 | (*iface)->addRef(); |
46 | return QS_OK; | 48 | return QS_OK; |
47 | |||
48 | } | 49 | } |
50 | |||
49 | void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { | 51 | void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { |
50 | QDataStream stream( data, IO_ReadOnly ); | 52 | QDataStream stream( data, IO_ReadOnly ); |
51 | qWarning("Message %s", msg.data() ); | 53 | qWarning("Message %s", msg.data() ); |
52 | if(msg == "send(QString,QString,QString)" ) { | 54 | if(msg == "send(QString,QString,QString)" ) { |
53 | QString desc; | 55 | QString desc; |
54 | stream >> desc; | 56 | stream >> desc; |
55 | stream >> m_name; | 57 | stream >> m_name; |
56 | m_sendgui->raise(); // should be on top | 58 | m_sendgui->raise(); // should be on top |
57 | m_sendgui->showMaximized(); | 59 | m_sendgui->showMaximized(); |
58 | m_sendgui->lblPath->setText(m_name); | 60 | m_sendgui->lblPath->setText(m_name); |
59 | connect( (QObject*)m_sendgui->PushButton2, SIGNAL(clicked()), | 61 | connect( (QObject*)m_sendgui->PushButton2, SIGNAL(clicked()), |
60 | this, SLOT(slotCancelSend())); | 62 | this, SLOT(slotCancelSend())); |
61 | m_obex->send(m_name ); | 63 | m_obex->send(m_name ); |
62 | connect( (QObject*)m_obex, SIGNAL( sent() ), this, | 64 | connect( (QObject*)m_obex, SIGNAL( sent() ), this, |
63 | SLOT( slotSent() ) ); | 65 | SLOT( slotSent() ) ); |
64 | connect( (QObject*)m_obex, SIGNAL( error(int) ), this, | 66 | connect( (QObject*)m_obex, SIGNAL( error(int) ), this, |
65 | SLOT( slotSent() ) ); | 67 | SLOT( slotSent() ) ); |
66 | }else if(msg == "receive(int)" ) { // open a GUI | 68 | }else if(msg == "receive(int)" ) { // open a GUI |
67 | m_recvgui->showMaximized(); | 69 | //m_recvgui->showMaximized(); |
68 | int receiveD = 0; | 70 | int receiveD = 0; |
69 | stream >> receiveD; | 71 | stream >> receiveD; |
70 | if ( receiveD == 1) | 72 | if ( receiveD == 1) |
71 | m_obex->receive(); | 73 | m_obex->receive(); |
72 | else | 74 | else |
73 | m_obex->setReceiveEnabled( false ); | 75 | m_obex->setReceiveEnabled( false ); |
74 | 76 | ||
75 | } else if (msg =="done(QString)") { | 77 | } else if (msg =="done(QString)") { |
76 | QString text; | 78 | QString text; |
77 | stream >> text; | 79 | stream >> text; |
78 | m_sendgui->lblPath->setText(tr("Done transfering " + text)); | 80 | m_sendgui->lblPath->setText(tr("Done transfering " + text)); |
79 | 81 | ||
80 | } | 82 | } |
81 | } | 83 | } |
82 | 84 | ||
83 | void ObexImpl::slotCancelSend() { | 85 | void ObexImpl::slotCancelSend() { |
84 | // cancel sync process too | 86 | // cancel sync process too |
85 | //m_obex->cancel(); // not ready yet | 87 | //m_obex->cancel(); // not ready yet |
86 | m_sendgui->hide(); | 88 | m_sendgui->hide(); |
87 | } | 89 | } |
88 | 90 | ||
89 | void ObexImpl::slotDone(bool) { | 91 | void ObexImpl::slotDone(bool) { |
90 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); //but this into a slot | 92 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); //but this into a slot |
91 | e << m_name; | 93 | e << m_name; |
92 | } | 94 | } |
93 | 95 | ||
94 | void ObexImpl::slotSent() { | 96 | void ObexImpl::slotSent() { |
95 | m_sendgui->lblPath->setText("Done!"); | 97 | m_sendgui->lblPath->setText("Done!"); |
96 | m_sendgui->hide(); | 98 | m_sendgui->hide(); |
97 | } | 99 | } |
98 | 100 | ||
99 | void ObexImpl::slotError( int errorCode) { | 101 | void ObexImpl::slotError( int errorCode) { |
100 | 102 | ||
101 | QString errorString = ""; | 103 | QString errorString = ""; |
102 | if (errorCode == -1) { | 104 | if (errorCode == -1) { |
103 | errorString = "test"; | 105 | errorString = "test"; |
104 | } | 106 | } |
105 | qDebug("Error: " + errorString); | 107 | qDebug("Error: " + errorString); |
106 | m_sendgui->hide(); | 108 | m_sendgui->hide(); |
107 | } | 109 | } |
110 | |||
108 | // Received a file via beam | 111 | // Received a file via beam |
109 | // check for mime type and then either | 112 | // check for mime type and then either |
110 | // add to App via setDocument | 113 | // add to App via setDocument |
111 | void ObexImpl::slotReceivedFile( const QString &fileName ) { | 114 | void ObexImpl::slotReceivedFile( const QString &fileName ) { |
112 | qWarning("filename %s", fileName.latin1() ); | 115 | qWarning("filename %s", fileName.latin1() ); |
113 | DocLnk lnk( fileName ); | 116 | DocLnk lnk( fileName ); |
114 | QString exec = lnk.exec(); | 117 | QString exec = lnk.exec(); |
115 | qWarning("executing %s", exec.latin1() ); | 118 | qWarning("executing %s", exec.latin1() ); |
116 | if ( exec.isEmpty() || exec == "" ) { | 119 | if ( exec.isEmpty() || exec == "" ) { |
117 | qWarning("empty"); | 120 | qWarning("empty"); |
118 | if ( fileName.right(4) == ".vcf" ) | 121 | if ( fileName.right(4) == ".vcf" ) |
119 | exec = "addressbook"; | 122 | exec = "addressbook"; |
120 | else if ( fileName.right(4) == ".vcs" ) { | 123 | else if ( fileName.right(4) == ".vcs" ) { |
121 | exec = "datebook"; | 124 | exec = "datebook"; |
122 | } | 125 | } |
123 | } // now prompt and then add it | 126 | } // now prompt and then add it |
127 | |||
128 | m_recvgui->PixmapLabel->setPixmap(lnk.pixmap()); | ||
129 | m_recvgui->TextLabel1_2->setText(lnk.name()); | ||
130 | m_recvgui->showMaximized(); | ||
131 | |||
124 | QCString str= "QPE/Application/"; | 132 | QCString str= "QPE/Application/"; |
125 | str += exec.latin1(); | 133 | str += exec.latin1(); |
126 | qWarning("channel %s", str.data() ); | 134 | qWarning("channel %s", str.data() ); |
127 | QCopEnvelope e(str , "setDocument(QString)" ); | 135 | QCopEnvelope e(str , "setDocument(QString)" ); |
128 | e << fileName; | 136 | e << fileName; |
129 | 137 | ||
130 | } | 138 | } |
131 | 139 | ||
132 | 140 | ||
133 | Q_EXPORT_INTERFACE() | 141 | Q_EXPORT_INTERFACE() |
134 | { | 142 | { |
135 | Q_CREATE_INSTANCE( ObexImpl ) | 143 | Q_CREATE_INSTANCE( ObexImpl ) |
136 | } | 144 | } |