Diffstat (limited to 'core/applets/obex/processwrapper.cc') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | core/applets/obex/processwrapper.cc | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/core/applets/obex/processwrapper.cc b/core/applets/obex/processwrapper.cc deleted file mode 100755 index ebc7794..0000000 --- a/core/applets/obex/processwrapper.cc +++ b/dev/null | |||
@@ -1,114 +0,0 @@ | |||
1 | // | ||
2 | m_rec == KProcess | ||
3 | m_count = int // the number of tries to recieve | ||
4 | m_send == KProcess | ||
5 | m_file == QString filename to send | ||
6 | m_outp == the output of the process | ||
7 | |||
8 | // | ||
9 | |||
10 | |||
11 | void receive() { | ||
12 | m_rec = new KProcess(); | ||
13 | *m_rec << "irobex_palm3"; | ||
14 | // connect to the necessary slots | ||
15 | connect(m_rec, SIGNAL(processExited(KProcess*) ), | ||
16 | this, SLOT(slotExited(KProcess*) ) ); | ||
17 | |||
18 | connect(m_rec, SIGNAL(receivedStdout(KProcess*, char*, int ) ), | ||
19 | this, SLOT(slotStdOut(KProcess*, char*, int) ) ); | ||
20 | |||
21 | if(!m_rec->start(KProcess::NotifyOnExit, KProcess::AllOutput) ) { | ||
22 | qWarning("could not start :("); | ||
23 | emit done( false ); | ||
24 | } | ||
25 | emit try(m_count ) | ||
26 | } | ||
27 | void send(const QString &fileName) { | ||
28 | m_count = 0; | ||
29 | m_file = fileName; | ||
30 | sendNow(); | ||
31 | } | ||
32 | void sendNow() { | ||
33 | if ( m_count >= 15 ) { // could not send | ||
34 | emit error(-1 ); | ||
35 | } | ||
36 | // KProcess inititialisation | ||
37 | m_send = new KProcess(); | ||
38 | m_send << "irobex_palm3"; | ||
39 | m_send << m_file; | ||
40 | |||
41 | // connect to slots Exited and and StdOut | ||
42 | connect(m_send, SIGNAL(processExited(KProcess*) ), | ||
43 | this, SLOT(slotExited(KProcess*)) ); | ||
44 | connect(m_send, SIGNAL(receivedStdout(KProcess*, char*, int ) ) | ||
45 | this, SLOT(slotStdOut(KProcess*, char*, int) ) ); | ||
46 | // now start it | ||
47 | if (!m_send->start(/*KProcess::NotifyOnExit, KProcess::AllOutput*/ ) ) { | ||
48 | m_count = 15; | ||
49 | emit error(-1 ); | ||
50 | } | ||
51 | // end | ||
52 | m_count++; | ||
53 | emit try( m_count ); | ||
54 | } | ||
55 | |||
56 | void recieved() { | ||
57 | if (m_rec->normalExit() ) { | ||
58 | if ( m_rec->exitStatus() == 0 ) { // we got one | ||
59 | QString filename = parseOut(); | ||
60 | emit recievedFile( filename ); | ||
61 | } | ||
62 | }else{ | ||
63 | emit error(-1); | ||
64 | }; | ||
65 | delete m_rec; | ||
66 | } | ||
67 | |||
68 | |||
69 | void slotExited(KProcess* proc) { | ||
70 | if (proc == m_rec ) { // recieve process | ||
71 | recieved(); | ||
72 | }else if ( proc == m_send ) { | ||
73 | send(); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | |||
78 | void send() { | ||
79 | if (m_send->normalExit() ) { | ||
80 | if ( m_send->exitStatus() == 0 ) { | ||
81 | delete m_send; | ||
82 | m_send=0; | ||
83 | emit sent(); | ||
84 | }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready | ||
85 | // let's try it again | ||
86 | delete m_send; | ||
87 | m_send = 0; | ||
88 | sendNow(); | ||
89 | } | ||
90 | }else { | ||
91 | emit error( -1 ); | ||
92 | delete m_send; | ||
93 | m_send = 0; | ||
94 | } | ||
95 | |||
96 | } | ||
97 | void parseOut() { | ||
98 | QStringList list = QStringList::split("\n", m_outp); | ||
99 | QStringList::Iterator it; | ||
100 | for (it = list.begin(); it != list.end(); ++it ) { | ||
101 | if ( (*it).startsWith("Wrote" ) ) { | ||
102 | QStringList pathes = QStringList::split(' ', (*it) ); | ||
103 | QString path = pathes[1]; | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | |||
108 | void slotStdOut(KProcess* proc, char* buf, int len) { | ||
109 | if ( proc == m_rec ) { // only recieve | ||
110 | QCString cstring( buf, len ); | ||
111 | m_outp.append( cstring.data() ); | ||
112 | } | ||
113 | |||
114 | } | ||