-rw-r--r-- | core/applets/irdaapplet/irda.cpp | 8 | ||||
-rw-r--r-- | core/applets/obex/libopieobex.control | 8 | ||||
-rw-r--r-- | core/applets/obex/obex.pro | 32 | ||||
-rw-r--r-- | core/applets/obex/obexdlg.ui | 279 | ||||
-rw-r--r-- | core/applets/obex/obeximpl.cc | 150 | ||||
-rw-r--r-- | core/applets/obex/obeximpl.h | 38 | ||||
-rw-r--r-- | core/applets/obex/obexinc.ui | 230 | ||||
-rwxr-xr-x | core/applets/obex/processwrapper.cc | 114 | ||||
-rw-r--r-- | core/obex/config.in (renamed from core/applets/obex/config.in) | 0 | ||||
-rw-r--r-- | core/obex/obex.cc (renamed from core/applets/obex/obex.cc) | 3 | ||||
-rw-r--r-- | core/obex/obex.h (renamed from core/applets/obex/obex.h) | 3 | ||||
-rw-r--r-- | core/obex/obexhandler.cpp | 65 | ||||
-rw-r--r-- | core/obex/obexhandler.h | 39 | ||||
-rw-r--r-- | core/obex/obeximpl.cpp | 28 | ||||
-rw-r--r-- | core/obex/obeximpl.h | 22 | ||||
-rw-r--r-- | core/obex/obexsend.cpp | 251 | ||||
-rw-r--r-- | core/obex/obexsend.h | 99 | ||||
-rw-r--r-- | core/obex/receiver.cpp | 166 | ||||
-rw-r--r-- | core/obex/receiver.h | 55 |
19 files changed, 732 insertions, 858 deletions
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp index 84c656f..a5b4bfc 100644 --- a/core/applets/irdaapplet/irda.cpp +++ b/core/applets/irdaapplet/irda.cpp | |||
@@ -131,139 +131,139 @@ bool IrdaApplet::setIrdaStatus ( bool b ) | |||
131 | 131 | ||
132 | if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) | 132 | if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) |
133 | return false; | 133 | return false; |
134 | 134 | ||
135 | return true; | 135 | return true; |
136 | } | 136 | } |
137 | 137 | ||
138 | bool IrdaApplet::checkIrdaDiscoveryStatus ( ) | 138 | bool IrdaApplet::checkIrdaDiscoveryStatus ( ) |
139 | { | 139 | { |
140 | QFile discovery ( "/proc/sys/net/irda/discovery" ); | 140 | QFile discovery ( "/proc/sys/net/irda/discovery" ); |
141 | 141 | ||
142 | QString streamIn = "0"; | 142 | QString streamIn = "0"; |
143 | 143 | ||
144 | if ( discovery. open ( IO_ReadOnly )) { | 144 | if ( discovery. open ( IO_ReadOnly )) { |
145 | QTextStream stream ( &discovery ); | 145 | QTextStream stream ( &discovery ); |
146 | streamIn = stream. read ( ); | 146 | streamIn = stream. read ( ); |
147 | } | 147 | } |
148 | 148 | ||
149 | return streamIn. toInt ( ) > 0; | 149 | return streamIn. toInt ( ) > 0; |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | bool IrdaApplet::setIrdaDiscoveryStatus ( bool d ) | 153 | bool IrdaApplet::setIrdaDiscoveryStatus ( bool d ) |
154 | { | 154 | { |
155 | QFile discovery ( "/proc/sys/net/irda/discovery" ); | 155 | QFile discovery ( "/proc/sys/net/irda/discovery" ); |
156 | 156 | ||
157 | if ( discovery. open ( IO_WriteOnly | IO_Raw )) { | 157 | if ( discovery. open ( IO_WriteOnly | IO_Raw )) { |
158 | discovery.putch ( d ? '1' : '0' ); | 158 | discovery.putch ( d ? '1' : '0' ); |
159 | return true; | 159 | return true; |
160 | } | 160 | } |
161 | return false; | 161 | return false; |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | bool IrdaApplet::setIrdaReceiveStatus ( bool d ) | 165 | bool IrdaApplet::setIrdaReceiveStatus ( bool d ) |
166 | { | 166 | { |
167 | QCopEnvelope e ( "QPE/Obex", "receive(int)" ); | 167 | QCopEnvelope e ( "QPE/Obex", "receive(int)" ); |
168 | e << ( d ? 1 : 0 ); | 168 | e << ( d ? 1 : 0 ); |
169 | 169 | ||
170 | m_receive_active = d; | 170 | m_receive_active = d; |
171 | m_receive_state_changed = true; | 171 | m_receive_state_changed = true; |
172 | 172 | ||
173 | return true; | 173 | return true; |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | void IrdaApplet::showDiscovered ( ) | 177 | void IrdaApplet::showDiscovered ( ) |
178 | { | 178 | { |
179 | static Sound snd_found ( "irdaapplet/irdaon" ); | 179 | //static Sound snd_found ( "irdaapplet/irdaon" ); |
180 | static Sound snd_lost ( "irdaapplet/irdaoff" ); | 180 | //static Sound snd_lost ( "irdaapplet/irdaoff" ); |
181 | 181 | ||
182 | QFile discovery ( "/proc/net/irda/discovery" ); | 182 | QFile discovery ( "/proc/net/irda/discovery" ); |
183 | 183 | ||
184 | if ( discovery. open ( IO_ReadOnly )) { | 184 | if ( discovery. open ( IO_ReadOnly )) { |
185 | bool qcopsend = false; | 185 | bool qcopsend = false; |
186 | 186 | ||
187 | QString discoveredDevice; | 187 | QString discoveredDevice; |
188 | QString deviceAddr; | 188 | QString deviceAddr; |
189 | 189 | ||
190 | // since it is /proc we _must_ use QTextStream | 190 | // since it is /proc we _must_ use QTextStream |
191 | QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); | 191 | QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); |
192 | 192 | ||
193 | QMap <QString, QString>::Iterator it; | 193 | QMap <QString, QString>::Iterator it; |
194 | 194 | ||
195 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) | 195 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) |
196 | it. data ( ). prepend ( "+++" ); | 196 | it. data ( ). prepend ( "+++" ); |
197 | 197 | ||
198 | for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { | 198 | for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { |
199 | const QString &line = *lit; | 199 | const QString &line = *lit; |
200 | 200 | ||
201 | if ( line. startsWith ( "nickname:" )) { | 201 | if ( line. startsWith ( "nickname:" )) { |
202 | discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); | 202 | discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); |
203 | deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); | 203 | deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); |
204 | 204 | ||
205 | // qDebug(discoveredDevice + "(" + deviceAddr + ")"); | 205 | // qDebug(discoveredDevice + "(" + deviceAddr + ")"); |
206 | 206 | ||
207 | if ( !m_devices. contains ( deviceAddr )) { | 207 | if ( !m_devices. contains ( deviceAddr )) { |
208 | popup ( tr( "Found:" ) + " " + discoveredDevice ); | 208 | popup ( tr( "Found:" ) + " " + discoveredDevice ); |
209 | snd_found. play ( ); | 209 | //snd_found. play ( ); |
210 | qcopsend = true; | 210 | qcopsend = true; |
211 | } | 211 | } |
212 | m_devices. replace ( deviceAddr, discoveredDevice ); | 212 | m_devices. replace ( deviceAddr, discoveredDevice ); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { | 216 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { |
217 | // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); | 217 | // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); |
218 | 218 | ||
219 | if ( it. data ( ). left ( 3 ) == "+++" ) { | 219 | if ( it. data ( ). left ( 3 ) == "+++" ) { |
220 | popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); | 220 | popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); |
221 | snd_lost. play ( ); | 221 | //snd_lost. play ( ); |
222 | 222 | ||
223 | QMap <QString, QString>::Iterator tmp = it; | 223 | QMap <QString, QString>::Iterator tmp = it; |
224 | tmp++; | 224 | tmp++; |
225 | m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator | 225 | m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator |
226 | it = tmp; | 226 | it = tmp; |
227 | 227 | ||
228 | qcopsend = true; | 228 | qcopsend = true; |
229 | } | 229 | } |
230 | else | 230 | else |
231 | it++; | 231 | it++; |
232 | } | 232 | } |
233 | // XXX if( qcopsend ) { | 233 | // XXX if( qcopsend ) { |
234 | QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); | 234 | QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); |
235 | e << ( m_devices. count ( ) > 0 ); | 235 | e << ( m_devices. count ( ) > 0 ); |
236 | // } | 236 | // } |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | void IrdaApplet::mousePressEvent ( QMouseEvent * ) | 240 | void IrdaApplet::mousePressEvent ( QMouseEvent * ) |
241 | { | 241 | { |
242 | QPopupMenu *menu = new QPopupMenu ( this ); | 242 | QPopupMenu *menu = new QPopupMenu ( this ); |
243 | QString cmd; | 243 | QString cmd; |
244 | 244 | ||
245 | /* Refresh active state */ | 245 | /* Refresh active state */ |
246 | timerEvent ( 0 ); | 246 | timerEvent ( 0 ); |
247 | 247 | ||
248 | //menu->insertItem( tr("More..."), 4 ); | 248 | //menu->insertItem( tr("More..."), 4 ); |
249 | 249 | ||
250 | if ( m_irda_active && !m_devices. isEmpty ( )) { | 250 | if ( m_irda_active && !m_devices. isEmpty ( )) { |
251 | menu-> insertItem ( tr( "Discovered Device:" ), 9 ); | 251 | menu-> insertItem ( tr( "Discovered Device:" ), 9 ); |
252 | 252 | ||
253 | for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) | 253 | for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) |
254 | menu-> insertItem ( *it ); | 254 | menu-> insertItem ( *it ); |
255 | 255 | ||
256 | menu-> insertSeparator ( ); | 256 | menu-> insertSeparator ( ); |
257 | } | 257 | } |
258 | 258 | ||
259 | menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); | 259 | menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); |
260 | 260 | ||
261 | if ( m_irda_active ) { | 261 | if ( m_irda_active ) { |
262 | menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); | 262 | menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); |
263 | menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); | 263 | menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); |
264 | } | 264 | } |
265 | 265 | ||
266 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); | 266 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); |
267 | QSize s = menu-> sizeHint ( ); | 267 | QSize s = menu-> sizeHint ( ); |
268 | 268 | ||
269 | p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )); | 269 | p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )); |
diff --git a/core/applets/obex/libopieobex.control b/core/applets/obex/libopieobex.control deleted file mode 100644 index 3fd0f77..0000000 --- a/core/applets/obex/libopieobex.control +++ b/dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | Files: plugins/obex/libopieobex.so* | ||
2 | Priority: optional | ||
3 | Section: opie/system | ||
4 | Maintainer: Holger Freyther <zecke@handhelds.org> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-$SUB_VERSION.1 | ||
7 | Depends: opie-base, openobex | libopenobex1 | ||
8 | Description: Irda obex lib | ||
diff --git a/core/applets/obex/obex.pro b/core/applets/obex/obex.pro deleted file mode 100644 index d7cc338..0000000 --- a/core/applets/obex/obex.pro +++ b/dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | TEMPLATE= lib | ||
2 | CONFIG += qt warn_on release | ||
3 | HEADERS= obex.h obeximpl.h | ||
4 | SOURCES= obex.cc obeximpl.cc | ||
5 | TARGET = opieobex | ||
6 | DESTDIR = $(OPIEDIR)/plugins/obex | ||
7 | INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/core/launcher | ||
8 | DEPENDPATH += ../$(OPIEDIR)/include | ||
9 | INTERFACES = obexinc.ui obexdlg.ui | ||
10 | LIBS += -lqpe -lopie | ||
11 | VERSION = 0.0.1 | ||
12 | |||
13 | TRANSLATIONS = ../../../i18n/de/libopieobex.ts \ | ||
14 | ../../../i18n/da/libopieobex.ts \ | ||
15 | ../../../i18n/xx/libopieobex.ts \ | ||
16 | ../../../i18n/en/libopieobex.ts \ | ||
17 | ../../../i18n/es/libopieobex.ts \ | ||
18 | ../../../i18n/fr/libopieobex.ts \ | ||
19 | ../../../i18n/hu/libopieobex.ts \ | ||
20 | ../../../i18n/ja/libopieobex.ts \ | ||
21 | ../../../i18n/ko/libopieobex.ts \ | ||
22 | ../../../i18n/no/libopieobex.ts \ | ||
23 | ../../../i18n/pl/libopieobex.ts \ | ||
24 | ../../../i18n/pt/libopieobex.ts \ | ||
25 | ../../../i18n/pt_BR/libopieobex.ts \ | ||
26 | ../../../i18n/sl/libopieobex.ts \ | ||
27 | ../../../i18n/zh_CN/libopieobex.ts \ | ||
28 | ../../../i18n/zh_TW/libopieobex.ts | ||
29 | |||
30 | |||
31 | |||
32 | include ( $(OPIEDIR)/include.pro ) | ||
diff --git a/core/applets/obex/obexdlg.ui b/core/applets/obex/obexdlg.ui deleted file mode 100644 index b367ffd..0000000 --- a/core/applets/obex/obexdlg.ui +++ b/dev/null | |||
@@ -1,279 +0,0 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>ObexDlg</class> | ||
3 | <author>me</author> | ||
4 | <widget> | ||
5 | <class>QWidget</class> | ||
6 | <property stdset="1"> | ||
7 | <name>name</name> | ||
8 | <cstring>Form1</cstring> | ||
9 | </property> | ||
10 | <property stdset="1"> | ||
11 | <name>geometry</name> | ||
12 | <rect> | ||
13 | <x>0</x> | ||
14 | <y>0</y> | ||
15 | <width>204</width> | ||
16 | <height>246</height> | ||
17 | </rect> | ||
18 | </property> | ||
19 | <property stdset="1"> | ||
20 | <name>caption</name> | ||
21 | <string>OBEX Sending</string> | ||
22 | </property> | ||
23 | <widget> | ||
24 | <class>QLayoutWidget</class> | ||
25 | <property stdset="1"> | ||
26 | <name>name</name> | ||
27 | <cstring>Layout5</cstring> | ||
28 | </property> | ||
29 | <property stdset="1"> | ||
30 | <name>geometry</name> | ||
31 | <rect> | ||
32 | <x>0</x> | ||
33 | <y>60</y> | ||
34 | <width>200</width> | ||
35 | <height>70</height> | ||
36 | </rect> | ||
37 | </property> | ||
38 | <vbox> | ||
39 | <property stdset="1"> | ||
40 | <name>margin</name> | ||
41 | <number>0</number> | ||
42 | </property> | ||
43 | <property stdset="1"> | ||
44 | <name>spacing</name> | ||
45 | <number>6</number> | ||
46 | </property> | ||
47 | <widget> | ||
48 | <class>QLabel</class> | ||
49 | <property stdset="1"> | ||
50 | <name>name</name> | ||
51 | <cstring>TextLabel1</cstring> | ||
52 | </property> | ||
53 | <property stdset="1"> | ||
54 | <name>text</name> | ||
55 | <string>Sending:</string> | ||
56 | </property> | ||
57 | </widget> | ||
58 | <spacer> | ||
59 | <property> | ||
60 | <name>name</name> | ||
61 | <cstring>Spacer6</cstring> | ||
62 | </property> | ||
63 | <property stdset="1"> | ||
64 | <name>orientation</name> | ||
65 | <enum>Vertical</enum> | ||
66 | </property> | ||
67 | <property stdset="1"> | ||
68 | <name>sizeType</name> | ||
69 | <enum>Fixed</enum> | ||
70 | </property> | ||
71 | <property> | ||
72 | <name>sizeHint</name> | ||
73 | <size> | ||
74 | <width>20</width> | ||
75 | <height>20</height> | ||
76 | </size> | ||
77 | </property> | ||
78 | </spacer> | ||
79 | <widget> | ||
80 | <class>QLabel</class> | ||
81 | <property stdset="1"> | ||
82 | <name>name</name> | ||
83 | <cstring>lblPath</cstring> | ||
84 | </property> | ||
85 | <property stdset="1"> | ||
86 | <name>text</name> | ||
87 | <string>filename</string> | ||
88 | </property> | ||
89 | <property stdset="1"> | ||
90 | <name>textFormat</name> | ||
91 | <enum>RichText</enum> | ||
92 | </property> | ||
93 | <property stdset="1"> | ||
94 | <name>alignment</name> | ||
95 | <set>AlignTop|AlignLeft</set> | ||
96 | </property> | ||
97 | <property> | ||
98 | <name>hAlign</name> | ||
99 | </property> | ||
100 | <property> | ||
101 | <name>vAlign</name> | ||
102 | </property> | ||
103 | </widget> | ||
104 | </vbox> | ||
105 | </widget> | ||
106 | <spacer> | ||
107 | <property> | ||
108 | <name>name</name> | ||
109 | <cstring>Spacer7</cstring> | ||
110 | </property> | ||
111 | <property stdset="1"> | ||
112 | <name>orientation</name> | ||
113 | <enum>Vertical</enum> | ||
114 | </property> | ||
115 | <property stdset="1"> | ||
116 | <name>sizeType</name> | ||
117 | <enum>Expanding</enum> | ||
118 | </property> | ||
119 | <property> | ||
120 | <name>sizeHint</name> | ||
121 | <size> | ||
122 | <width>20</width> | ||
123 | <height>20</height> | ||
124 | </size> | ||
125 | </property> | ||
126 | </spacer> | ||
127 | <spacer> | ||
128 | <property> | ||
129 | <name>name</name> | ||
130 | <cstring>Spacer8</cstring> | ||
131 | </property> | ||
132 | <property stdset="1"> | ||
133 | <name>orientation</name> | ||
134 | <enum>Vertical</enum> | ||
135 | </property> | ||
136 | <property stdset="1"> | ||
137 | <name>sizeType</name> | ||
138 | <enum>Expanding</enum> | ||
139 | </property> | ||
140 | <property> | ||
141 | <name>sizeHint</name> | ||
142 | <size> | ||
143 | <width>20</width> | ||
144 | <height>20</height> | ||
145 | </size> | ||
146 | </property> | ||
147 | </spacer> | ||
148 | <widget> | ||
149 | <class>QLayoutWidget</class> | ||
150 | <property stdset="1"> | ||
151 | <name>name</name> | ||
152 | <cstring>Layout6</cstring> | ||
153 | </property> | ||
154 | <property stdset="1"> | ||
155 | <name>geometry</name> | ||
156 | <rect> | ||
157 | <x>20</x> | ||
158 | <y>170</y> | ||
159 | <width>170</width> | ||
160 | <height>34</height> | ||
161 | </rect> | ||
162 | </property> | ||
163 | <hbox> | ||
164 | <property stdset="1"> | ||
165 | <name>margin</name> | ||
166 | <number>0</number> | ||
167 | </property> | ||
168 | <property stdset="1"> | ||
169 | <name>spacing</name> | ||
170 | <number>6</number> | ||
171 | </property> | ||
172 | <spacer> | ||
173 | <property> | ||
174 | <name>name</name> | ||
175 | <cstring>Spacer9</cstring> | ||
176 | </property> | ||
177 | <property stdset="1"> | ||
178 | <name>orientation</name> | ||
179 | <enum>Horizontal</enum> | ||
180 | </property> | ||
181 | <property stdset="1"> | ||
182 | <name>sizeType</name> | ||
183 | <enum>Expanding</enum> | ||
184 | </property> | ||
185 | <property> | ||
186 | <name>sizeHint</name> | ||
187 | <size> | ||
188 | <width>20</width> | ||
189 | <height>20</height> | ||
190 | </size> | ||
191 | </property> | ||
192 | </spacer> | ||
193 | <widget> | ||
194 | <class>QPushButton</class> | ||
195 | <property stdset="1"> | ||
196 | <name>name</name> | ||
197 | <cstring>PushButton2</cstring> | ||
198 | </property> | ||
199 | <property stdset="1"> | ||
200 | <name>text</name> | ||
201 | <string>&Cancel</string> | ||
202 | </property> | ||
203 | </widget> | ||
204 | <spacer> | ||
205 | <property> | ||
206 | <name>name</name> | ||
207 | <cstring>Spacer10</cstring> | ||
208 | </property> | ||
209 | <property stdset="1"> | ||
210 | <name>orientation</name> | ||
211 | <enum>Horizontal</enum> | ||
212 | </property> | ||
213 | <property stdset="1"> | ||
214 | <name>sizeType</name> | ||
215 | <enum>Expanding</enum> | ||
216 | </property> | ||
217 | <property> | ||
218 | <name>sizeHint</name> | ||
219 | <size> | ||
220 | <width>20</width> | ||
221 | <height>20</height> | ||
222 | </size> | ||
223 | </property> | ||
224 | </spacer> | ||
225 | </hbox> | ||
226 | </widget> | ||
227 | <spacer> | ||
228 | <property> | ||
229 | <name>name</name> | ||
230 | <cstring>Spacer11</cstring> | ||
231 | </property> | ||
232 | <property stdset="1"> | ||
233 | <name>orientation</name> | ||
234 | <enum>Vertical</enum> | ||
235 | </property> | ||
236 | <property stdset="1"> | ||
237 | <name>sizeType</name> | ||
238 | <enum>Expanding</enum> | ||
239 | </property> | ||
240 | <property> | ||
241 | <name>sizeHint</name> | ||
242 | <size> | ||
243 | <width>20</width> | ||
244 | <height>20</height> | ||
245 | </size> | ||
246 | </property> | ||
247 | </spacer> | ||
248 | <spacer> | ||
249 | <property> | ||
250 | <name>name</name> | ||
251 | <cstring>Spacer18</cstring> | ||
252 | </property> | ||
253 | <property stdset="1"> | ||
254 | <name>orientation</name> | ||
255 | <enum>Vertical</enum> | ||
256 | </property> | ||
257 | <property stdset="1"> | ||
258 | <name>sizeType</name> | ||
259 | <enum>Expanding</enum> | ||
260 | </property> | ||
261 | <property> | ||
262 | <name>sizeHint</name> | ||
263 | <size> | ||
264 | <width>20</width> | ||
265 | <height>20</height> | ||
266 | </size> | ||
267 | </property> | ||
268 | </spacer> | ||
269 | </widget> | ||
270 | <connections> | ||
271 | <connection> | ||
272 | <sender>PushButton2</sender> | ||
273 | <signal>clicked()</signal> | ||
274 | <receiver>Form1</receiver> | ||
275 | <slot>slotCancel()</slot> | ||
276 | </connection> | ||
277 | <slot access="public">slotCancel()</slot> | ||
278 | </connections> | ||
279 | </UI> | ||
diff --git a/core/applets/obex/obeximpl.cc b/core/applets/obex/obeximpl.cc deleted file mode 100644 index 88f2d44..0000000 --- a/core/applets/obex/obeximpl.cc +++ b/dev/null | |||
@@ -1,150 +0,0 @@ | |||
1 | |||
2 | #include <qdatastream.h> | ||
3 | #include <qmessagebox.h> | ||
4 | |||
5 | |||
6 | #include <qpe/qcom.h> | ||
7 | #include <qpe/applnk.h> | ||
8 | |||
9 | #include <qlabel.h> | ||
10 | |||
11 | #include "obex.h" | ||
12 | #include "obeximpl.h" | ||
13 | |||
14 | |||
15 | |||
16 | using namespace OpieObex; | ||
17 | |||
18 | ObexImpl::ObexImpl( ) | ||
19 | : QObject() { | ||
20 | // register to a channel | ||
21 | qWarning( "c'tor" ); | ||
22 | m_obex = new Obex(this, "obex"); | ||
23 | m_sendgui = new ObexDlg(); | ||
24 | m_recvgui = new ObexInc(); | ||
25 | m_chan = new QCopChannel("QPE/Obex" ); | ||
26 | connect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | ||
27 | this, SLOT(slotMessage(const QCString&, const QByteArray&) ) ); | ||
28 | connect(m_obex, SIGNAL(receivedFile(const QString& ) ), | ||
29 | this, SLOT(slotReceivedFile(const QString& ) ) ); | ||
30 | connect((QObject*) m_recvgui->InsertButton, SIGNAL(clicked()), | ||
31 | m_recvgui, SLOT( accept() )); | ||
32 | connect((QObject*) m_recvgui->RejectButton, SIGNAL(clicked()), | ||
33 | m_recvgui, SLOT( reject() )); | ||
34 | } | ||
35 | |||
36 | ObexImpl::~ObexImpl() { | ||
37 | delete m_obex; | ||
38 | delete m_chan; | ||
39 | delete m_sendgui; | ||
40 | delete m_recvgui; | ||
41 | } | ||
42 | |||
43 | QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | ||
44 | *iface = 0; | ||
45 | if( uuid == IID_QUnknown ) | ||
46 | *iface = this; | ||
47 | else if( uuid == IID_ObexInterface ) | ||
48 | *iface = this; | ||
49 | |||
50 | qWarning("query" ); | ||
51 | if(*iface ) | ||
52 | (*iface)->addRef(); | ||
53 | return QS_OK; | ||
54 | } | ||
55 | |||
56 | void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { | ||
57 | QDataStream stream( data, IO_ReadOnly ); | ||
58 | qWarning("Message %s", msg.data() ); | ||
59 | if(msg == "send(QString,QString,QString)" ) { | ||
60 | QString desc; | ||
61 | stream >> desc; | ||
62 | stream >> m_name; | ||
63 | m_sendgui->raise(); // should be on top | ||
64 | m_sendgui->showMaximized(); | ||
65 | m_sendgui->lblPath->setText(m_name); | ||
66 | connect( (QObject*)m_sendgui->PushButton2, SIGNAL(clicked()), | ||
67 | this, SLOT(slotCancelSend())); | ||
68 | m_obex->send(m_name ); | ||
69 | connect( (QObject*)m_obex, SIGNAL( sent() ), this, | ||
70 | SLOT( slotSent() ) ); | ||
71 | connect( (QObject*)m_obex, SIGNAL( error(int) ), this, | ||
72 | SLOT( slotSent() ) ); | ||
73 | }else if(msg == "receive(int)" ) { // open a GUI | ||
74 | //m_recvgui->showMaximized(); | ||
75 | int receiveD = 0; | ||
76 | stream >> receiveD; | ||
77 | if ( receiveD == 1) | ||
78 | m_obex->receive(); | ||
79 | else | ||
80 | m_obex->setReceiveEnabled( false ); | ||
81 | |||
82 | } else if (msg =="done(QString)") { | ||
83 | QString text; | ||
84 | stream >> text; | ||
85 | m_sendgui->lblPath->setText(tr("Done transfering " + text)); | ||
86 | |||
87 | } | ||
88 | } | ||
89 | |||
90 | void ObexImpl::slotCancelSend() { | ||
91 | // cancel sync process too | ||
92 | //m_obex->cancel(); // not ready yet | ||
93 | m_sendgui->hide(); | ||
94 | } | ||
95 | |||
96 | void ObexImpl::slotDone(bool) { | ||
97 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); //but this into a slot | ||
98 | e << m_name; | ||
99 | } | ||
100 | |||
101 | void ObexImpl::slotSent() { | ||
102 | m_sendgui->lblPath->setText("Done!"); | ||
103 | m_sendgui->hide(); | ||
104 | } | ||
105 | |||
106 | void ObexImpl::slotError( int errorCode) { | ||
107 | |||
108 | QString errorString = ""; | ||
109 | if (errorCode == -1) { | ||
110 | errorString = "test"; | ||
111 | } | ||
112 | qDebug("Error: " + errorString); | ||
113 | m_sendgui->hide(); | ||
114 | } | ||
115 | |||
116 | // Received a file via beam | ||
117 | // check for mime type and then either | ||
118 | // add to App via setDocument | ||
119 | void ObexImpl::slotReceivedFile( const QString &fileName ) { | ||
120 | qWarning("filename %s", fileName.latin1() ); | ||
121 | DocLnk lnk( fileName ); | ||
122 | QString exec = lnk.exec(); | ||
123 | qWarning("executing %s", exec.latin1() ); | ||
124 | if ( exec.isEmpty() || exec == "" ) { | ||
125 | qWarning("empty"); | ||
126 | if ( fileName.right(4) == ".vcf" ) | ||
127 | exec = "addressbook"; | ||
128 | else if ( fileName.right(4) == ".vcs" ) { | ||
129 | exec = "datebook"; | ||
130 | } | ||
131 | } // now prompt and then add it | ||
132 | |||
133 | m_recvgui->PixmapLabel->setPixmap( lnk.pixmap() ); | ||
134 | m_recvgui->AppLabel->setText( "<b>" + exec + "<b>" ); | ||
135 | m_recvgui->FileLabel->setText( lnk.name() ); | ||
136 | // m_recvgui->showMaximized(); | ||
137 | // if( m_recvgui->exec() == 0 ) { | ||
138 | QCString str= "QPE/Application/"; | ||
139 | str += exec.latin1(); | ||
140 | qWarning("channel %s", str.data() ); | ||
141 | QCopEnvelope e(str , "setDocument(QString)" ); | ||
142 | e << fileName; | ||
143 | //} | ||
144 | } | ||
145 | |||
146 | |||
147 | |||
148 | Q_EXPORT_INTERFACE() { | ||
149 | Q_CREATE_INSTANCE( ObexImpl ) | ||
150 | } | ||
diff --git a/core/applets/obex/obeximpl.h b/core/applets/obex/obeximpl.h deleted file mode 100644 index 78d5b25..0000000 --- a/core/applets/obex/obeximpl.h +++ b/dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | |||
2 | #ifndef OpieObexImpl_H | ||
3 | #define OpieObexImpl_H | ||
4 | |||
5 | #include <qobject.h> | ||
6 | #include <obexinterface.h> | ||
7 | #include "obexdlg.h" | ||
8 | #include "obexinc.h" | ||
9 | #include <qpe/qcopenvelope_qws.h> | ||
10 | |||
11 | namespace OpieObex { | ||
12 | class Obex; | ||
13 | class ObexImpl : public QObject, public ObexInterface { | ||
14 | Q_OBJECT | ||
15 | public: | ||
16 | ObexImpl(); | ||
17 | virtual ~ObexImpl(); | ||
18 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
19 | Q_REFCOUNT // for reference counting (macro ) | ||
20 | private: | ||
21 | ulong ref; | ||
22 | Obex* m_obex; // obex lib | ||
23 | QCopChannel *m_chan; | ||
24 | ObexDlg *m_sendgui; | ||
25 | ObexInc *m_recvgui; | ||
26 | QString m_name; | ||
27 | private slots: | ||
28 | void slotCancelSend(); | ||
29 | void slotMessage( const QCString&, const QByteArray& ); | ||
30 | void slotError(int ); | ||
31 | // void slotCurrentTry( unsigned int ); */ | ||
32 | void slotDone(bool); | ||
33 | void slotReceivedFile(const QString & ); | ||
34 | void slotSent(); | ||
35 | |||
36 | }; | ||
37 | }; | ||
38 | #endif | ||
diff --git a/core/applets/obex/obexinc.ui b/core/applets/obex/obexinc.ui deleted file mode 100644 index 4cc8056..0000000 --- a/core/applets/obex/obexinc.ui +++ b/dev/null | |||
@@ -1,230 +0,0 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>ObexInc</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>ObexInc</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>208</width> | ||
15 | <height>248</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>OBEX Receiving</string> | ||
21 | </property> | ||
22 | <widget> | ||
23 | <class>QLayoutWidget</class> | ||
24 | <property stdset="1"> | ||
25 | <name>name</name> | ||
26 | <cstring>Layout5</cstring> | ||
27 | </property> | ||
28 | <property stdset="1"> | ||
29 | <name>geometry</name> | ||
30 | <rect> | ||
31 | <x>90</x> | ||
32 | <y>100</y> | ||
33 | <width>79</width> | ||
34 | <height>68</height> | ||
35 | </rect> | ||
36 | </property> | ||
37 | <vbox> | ||
38 | <property stdset="1"> | ||
39 | <name>margin</name> | ||
40 | <number>0</number> | ||
41 | </property> | ||
42 | <property stdset="1"> | ||
43 | <name>spacing</name> | ||
44 | <number>6</number> | ||
45 | </property> | ||
46 | <widget> | ||
47 | <class>QLabel</class> | ||
48 | <property stdset="1"> | ||
49 | <name>name</name> | ||
50 | <cstring>AppLabel</cstring> | ||
51 | </property> | ||
52 | <property stdset="1"> | ||
53 | <name>text</name> | ||
54 | <string>TextLabel1</string> | ||
55 | </property> | ||
56 | </widget> | ||
57 | <widget> | ||
58 | <class>QLabel</class> | ||
59 | <property stdset="1"> | ||
60 | <name>name</name> | ||
61 | <cstring>FileLabel</cstring> | ||
62 | </property> | ||
63 | <property stdset="1"> | ||
64 | <name>text</name> | ||
65 | <string>Filename</string> | ||
66 | </property> | ||
67 | <property stdset="1"> | ||
68 | <name>alignment</name> | ||
69 | <set>AlignTop|AlignLeft</set> | ||
70 | </property> | ||
71 | <property> | ||
72 | <name>vAlign</name> | ||
73 | </property> | ||
74 | </widget> | ||
75 | </vbox> | ||
76 | </widget> | ||
77 | <widget> | ||
78 | <class>QLabel</class> | ||
79 | <property stdset="1"> | ||
80 | <name>name</name> | ||
81 | <cstring>TextLabel1</cstring> | ||
82 | </property> | ||
83 | <property stdset="1"> | ||
84 | <name>geometry</name> | ||
85 | <rect> | ||
86 | <x>30</x> | ||
87 | <y>30</y> | ||
88 | <width>161</width> | ||
89 | <height>41</height> | ||
90 | </rect> | ||
91 | </property> | ||
92 | <property stdset="1"> | ||
93 | <name>text</name> | ||
94 | <string>A file was beamed | ||
95 | to you.</string> | ||
96 | </property> | ||
97 | </widget> | ||
98 | <widget> | ||
99 | <class>QLabel</class> | ||
100 | <property stdset="1"> | ||
101 | <name>name</name> | ||
102 | <cstring>PixmapLabel</cstring> | ||
103 | </property> | ||
104 | <property stdset="1"> | ||
105 | <name>geometry</name> | ||
106 | <rect> | ||
107 | <x>30</x> | ||
108 | <y>100</y> | ||
109 | <width>40</width> | ||
110 | <height>40</height> | ||
111 | </rect> | ||
112 | </property> | ||
113 | <property stdset="1"> | ||
114 | <name>scaledContents</name> | ||
115 | <bool>true</bool> | ||
116 | </property> | ||
117 | </widget> | ||
118 | <widget> | ||
119 | <class>QLayoutWidget</class> | ||
120 | <property stdset="1"> | ||
121 | <name>name</name> | ||
122 | <cstring>Layout4</cstring> | ||
123 | </property> | ||
124 | <property stdset="1"> | ||
125 | <name>geometry</name> | ||
126 | <rect> | ||
127 | <x>0</x> | ||
128 | <y>210</y> | ||
129 | <width>246</width> | ||
130 | <height>33</height> | ||
131 | </rect> | ||
132 | </property> | ||
133 | <hbox> | ||
134 | <property stdset="1"> | ||
135 | <name>margin</name> | ||
136 | <number>0</number> | ||
137 | </property> | ||
138 | <property stdset="1"> | ||
139 | <name>spacing</name> | ||
140 | <number>6</number> | ||
141 | </property> | ||
142 | <spacer> | ||
143 | <property> | ||
144 | <name>name</name> | ||
145 | <cstring>Spacer9</cstring> | ||
146 | </property> | ||
147 | <property stdset="1"> | ||
148 | <name>orientation</name> | ||
149 | <enum>Horizontal</enum> | ||
150 | </property> | ||
151 | <property stdset="1"> | ||
152 | <name>sizeType</name> | ||
153 | <enum>Expanding</enum> | ||
154 | </property> | ||
155 | <property> | ||
156 | <name>sizeHint</name> | ||
157 | <size> | ||
158 | <width>20</width> | ||
159 | <height>20</height> | ||
160 | </size> | ||
161 | </property> | ||
162 | </spacer> | ||
163 | <widget> | ||
164 | <class>QPushButton</class> | ||
165 | <property stdset="1"> | ||
166 | <name>name</name> | ||
167 | <cstring>InsertButton</cstring> | ||
168 | </property> | ||
169 | <property stdset="1"> | ||
170 | <name>text</name> | ||
171 | <string>Insert</string> | ||
172 | </property> | ||
173 | </widget> | ||
174 | <spacer> | ||
175 | <property> | ||
176 | <name>name</name> | ||
177 | <cstring>Spacer11</cstring> | ||
178 | </property> | ||
179 | <property stdset="1"> | ||
180 | <name>orientation</name> | ||
181 | <enum>Horizontal</enum> | ||
182 | </property> | ||
183 | <property stdset="1"> | ||
184 | <name>sizeType</name> | ||
185 | <enum>Expanding</enum> | ||
186 | </property> | ||
187 | <property> | ||
188 | <name>sizeHint</name> | ||
189 | <size> | ||
190 | <width>20</width> | ||
191 | <height>20</height> | ||
192 | </size> | ||
193 | </property> | ||
194 | </spacer> | ||
195 | <widget> | ||
196 | <class>QPushButton</class> | ||
197 | <property stdset="1"> | ||
198 | <name>name</name> | ||
199 | <cstring>RejectButton</cstring> | ||
200 | </property> | ||
201 | <property stdset="1"> | ||
202 | <name>text</name> | ||
203 | <string>Reject</string> | ||
204 | </property> | ||
205 | </widget> | ||
206 | <spacer> | ||
207 | <property> | ||
208 | <name>name</name> | ||
209 | <cstring>Spacer10</cstring> | ||
210 | </property> | ||
211 | <property stdset="1"> | ||
212 | <name>orientation</name> | ||
213 | <enum>Horizontal</enum> | ||
214 | </property> | ||
215 | <property stdset="1"> | ||
216 | <name>sizeType</name> | ||
217 | <enum>Expanding</enum> | ||
218 | </property> | ||
219 | <property> | ||
220 | <name>sizeHint</name> | ||
221 | <size> | ||
222 | <width>20</width> | ||
223 | <height>20</height> | ||
224 | </size> | ||
225 | </property> | ||
226 | </spacer> | ||
227 | </hbox> | ||
228 | </widget> | ||
229 | </widget> | ||
230 | </UI> | ||
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 | } | ||
diff --git a/core/applets/obex/config.in b/core/obex/config.in index 4d1f43d..4d1f43d 100644 --- a/core/applets/obex/config.in +++ b/core/obex/config.in | |||
diff --git a/core/applets/obex/obex.cc b/core/obex/obex.cc index 43041f5..83d1faf 100644 --- a/core/applets/obex/obex.cc +++ b/core/obex/obex.cc | |||
@@ -24,158 +24,159 @@ Obex::~Obex() { | |||
24 | delete m_send; | 24 | delete m_send; |
25 | } | 25 | } |
26 | void Obex::receive() { | 26 | void Obex::receive() { |
27 | m_receive = true; | 27 | m_receive = true; |
28 | m_outp = QString::null; | 28 | m_outp = QString::null; |
29 | qWarning("Receive" ); | 29 | qWarning("Receive" ); |
30 | m_rec = new OProcess(); | 30 | m_rec = new OProcess(); |
31 | *m_rec << "irobex_palm3"; | 31 | *m_rec << "irobex_palm3"; |
32 | // connect to the necessary slots | 32 | // connect to the necessary slots |
33 | connect(m_rec, SIGNAL(processExited(OProcess*) ), | 33 | connect(m_rec, SIGNAL(processExited(OProcess*) ), |
34 | this, SLOT(slotExited(OProcess*) ) ); | 34 | this, SLOT(slotExited(OProcess*) ) ); |
35 | 35 | ||
36 | connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 36 | connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), |
37 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); | 37 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); |
38 | 38 | ||
39 | if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 39 | if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
40 | qWarning("could not start :("); | 40 | qWarning("could not start :("); |
41 | emit done( false ); | 41 | emit done( false ); |
42 | delete m_rec; | 42 | delete m_rec; |
43 | m_rec = 0; | 43 | m_rec = 0; |
44 | } | 44 | } |
45 | // emit currentTry(m_count ); | 45 | // emit currentTry(m_count ); |
46 | 46 | ||
47 | } | 47 | } |
48 | void Obex::send( const QString& fileName) { // if currently receiving stop it send receive | 48 | void Obex::send( const QString& fileName) { // if currently receiving stop it send receive |
49 | m_count = 0; | 49 | m_count = 0; |
50 | m_file = fileName; | 50 | m_file = fileName; |
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 | emit sent(false); | ||
72 | return; | 73 | return; |
73 | } | 74 | } |
74 | // OProcess inititialisation | 75 | // OProcess inititialisation |
75 | m_send = new OProcess(); | 76 | m_send = new OProcess(); |
76 | *m_send << "irobex_palm3"; | 77 | *m_send << "irobex_palm3"; |
77 | *m_send << m_file; | 78 | *m_send << m_file; |
78 | 79 | ||
79 | // connect to slots Exited and and StdOut | 80 | // connect to slots Exited and and StdOut |
80 | connect(m_send, SIGNAL(processExited(OProcess*) ), | 81 | connect(m_send, SIGNAL(processExited(OProcess*) ), |
81 | this, SLOT(slotExited(OProcess*)) ); | 82 | this, SLOT(slotExited(OProcess*)) ); |
82 | connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), | 83 | connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), |
83 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); | 84 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); |
84 | 85 | ||
85 | // now start it | 86 | // now start it |
86 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { | 87 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { |
87 | qWarning("could not send" ); | 88 | qWarning("could not send" ); |
88 | m_count = 25; | 89 | m_count = 25; |
89 | emit error(-1 ); | 90 | emit error(-1 ); |
90 | delete m_send; | 91 | delete m_send; |
91 | m_send=0; | 92 | m_send=0; |
92 | } | 93 | } |
93 | // end | 94 | // end |
94 | m_count++; | 95 | m_count++; |
95 | emit currentTry( m_count ); | 96 | emit currentTry( m_count ); |
96 | } | 97 | } |
97 | 98 | ||
98 | void Obex::slotExited(OProcess* proc ){ | 99 | void Obex::slotExited(OProcess* proc ){ |
99 | if (proc == m_rec ) { // receive process | 100 | if (proc == m_rec ) { // receive process |
100 | received(); | 101 | received(); |
101 | }else if ( proc == m_send ) { | 102 | }else if ( proc == m_send ) { |
102 | sendEnd(); | 103 | sendEnd(); |
103 | } | 104 | } |
104 | } | 105 | } |
105 | void Obex::slotStdOut(OProcess* proc, char* buf, int len){ | 106 | void Obex::slotStdOut(OProcess* proc, char* buf, int len){ |
106 | if ( proc == m_rec ) { // only receive | 107 | if ( proc == m_rec ) { // only receive |
107 | QCString cstring( buf, len ); | 108 | QCString cstring( buf, len ); |
108 | m_outp.append( cstring.data() ); | 109 | m_outp.append( cstring.data() ); |
109 | } | 110 | } |
110 | } | 111 | } |
111 | 112 | ||
112 | void Obex::received() { | 113 | void Obex::received() { |
113 | if (m_rec->normalExit() ) { | 114 | if (m_rec->normalExit() ) { |
114 | if ( m_rec->exitStatus() == 0 ) { // we got one | 115 | if ( m_rec->exitStatus() == 0 ) { // we got one |
115 | QString filename = parseOut(); | 116 | QString filename = parseOut(); |
116 | qWarning("ACHTUNG"); | 117 | qWarning("ACHTUNG"); |
117 | emit receivedFile( filename ); | 118 | emit receivedFile( filename ); |
118 | } | 119 | } |
119 | }else{ | 120 | }else{ |
120 | emit done(false); | 121 | emit done(false); |
121 | }; | 122 | }; |
122 | delete m_rec; | 123 | delete m_rec; |
123 | m_rec = 0; | 124 | m_rec = 0; |
124 | receive(); | 125 | receive(); |
125 | } | 126 | } |
126 | 127 | ||
127 | void Obex::sendEnd() { | 128 | void Obex::sendEnd() { |
128 | if (m_send->normalExit() ) { | 129 | if (m_send->normalExit() ) { |
129 | if ( m_send->exitStatus() == 0 ) { | 130 | if ( m_send->exitStatus() == 0 ) { |
130 | delete m_send; | 131 | delete m_send; |
131 | m_send=0; | 132 | m_send=0; |
132 | qWarning("done" ); | 133 | qWarning("done" ); |
133 | emit sent(); | 134 | emit sent(true); |
134 | }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready | 135 | }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready |
135 | // let's try it again | 136 | // let's try it again |
136 | delete m_send; | 137 | delete m_send; |
137 | m_send = 0; | 138 | m_send = 0; |
138 | qWarning("try sending again" ); | 139 | qWarning("try sending again" ); |
139 | sendNow(); | 140 | sendNow(); |
140 | } | 141 | } |
141 | }else { | 142 | }else { |
142 | emit error( -1 ); | 143 | emit error( -1 ); |
143 | delete m_send; | 144 | delete m_send; |
144 | m_send = 0; | 145 | m_send = 0; |
145 | } | 146 | } |
146 | } | 147 | } |
147 | QString Obex::parseOut( ){ | 148 | QString Obex::parseOut( ){ |
148 | QString path; | 149 | QString path; |
149 | QStringList list = QStringList::split("\n", m_outp); | 150 | QStringList list = QStringList::split("\n", m_outp); |
150 | QStringList::Iterator it; | 151 | QStringList::Iterator it; |
151 | for (it = list.begin(); it != list.end(); ++it ) { | 152 | for (it = list.begin(); it != list.end(); ++it ) { |
152 | if ( (*it).startsWith("Wrote" ) ) { | 153 | if ( (*it).startsWith("Wrote" ) ) { |
153 | int pos = (*it).findRev('(' ); | 154 | int pos = (*it).findRev('(' ); |
154 | if ( pos > 0 ) { | 155 | if ( pos > 0 ) { |
155 | qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ; | 156 | qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ; |
156 | qWarning("%d %d", (*it).length(), (*it).length()-pos ); | 157 | qWarning("%d %d", (*it).length(), (*it).length()-pos ); |
157 | 158 | ||
158 | path = (*it).remove( pos, (*it).length() - pos ); | 159 | path = (*it).remove( pos, (*it).length() - pos ); |
159 | qWarning("%s", path.latin1() ); | 160 | qWarning("%s", path.latin1() ); |
160 | path = path.mid(6 ); | 161 | path = path.mid(6 ); |
161 | path = path.stripWhiteSpace(); | 162 | path = path.stripWhiteSpace(); |
162 | qWarning("path %s", path.latin1() ); | 163 | qWarning("path %s", path.latin1() ); |
163 | } | 164 | } |
164 | } | 165 | } |
165 | } | 166 | } |
166 | return path; | 167 | return path; |
167 | } | 168 | } |
168 | /** | 169 | /** |
169 | * when sent is done slotError is called we will start receive again | 170 | * when sent is done slotError is called we will start receive again |
170 | */ | 171 | */ |
171 | void Obex::slotError() { | 172 | void Obex::slotError() { |
172 | qWarning("slotError"); | 173 | qWarning("slotError"); |
173 | if ( m_receive ) | 174 | if ( m_receive ) |
174 | receive(); | 175 | receive(); |
175 | }; | 176 | }; |
176 | void Obex::setReceiveEnabled( bool receive ) { | 177 | void Obex::setReceiveEnabled( bool receive ) { |
177 | if ( !receive ) { // | 178 | if ( !receive ) { // |
178 | m_receive = false; | 179 | m_receive = false; |
179 | shutDownReceive(); | 180 | shutDownReceive(); |
180 | } | 181 | } |
181 | } | 182 | } |
diff --git a/core/applets/obex/obex.h b/core/obex/obex.h index 781fca2..60f5d28 100644 --- a/core/applets/obex/obex.h +++ b/core/obex/obex.h | |||
@@ -1,85 +1,84 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #ifndef OpieObex_H | 3 | #ifndef OpieObex_H |
4 | #define OpieObex_H | 4 | #define OpieObex_H |
5 | 5 | ||
6 | #include <qobject.h> | 6 | #include <qobject.h> |
7 | 7 | ||
8 | class OProcess; | 8 | class OProcess; |
9 | class QCopChannel; | 9 | class QCopChannel; |
10 | namespace OpieObex { | 10 | namespace OpieObex { |
11 | class Obex : public QObject { | 11 | class Obex : public QObject { |
12 | Q_OBJECT | 12 | Q_OBJECT |
13 | public: | 13 | public: |
14 | /** | 14 | /** |
15 | * Obex c'tor look | 15 | * Obex c'tor look |
16 | */ | 16 | */ |
17 | Obex( QObject *parent, const char* name); | 17 | Obex( QObject *parent, const char* name); |
18 | /** | 18 | /** |
19 | * d'tor | 19 | * d'tor |
20 | */ | 20 | */ |
21 | ~Obex(); | 21 | ~Obex(); |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Starting listening to irda after enabled by the applet | 24 | * Starting listening to irda after enabled by the applet |
25 | * a signal gets emitted when recieved a file | 25 | * a signal gets emitted when recieved a file |
26 | */ | 26 | */ |
27 | void receive(); | 27 | void receive(); |
28 | void send( const QString& ); | 28 | void send( const QString& ); |
29 | void setReceiveEnabled( bool = false ); | 29 | void setReceiveEnabled( bool = false ); |
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(bool); |
50 | // private slots | ||
51 | void done(bool); | 50 | void done(bool); |
52 | 51 | ||
53 | private: | 52 | private: |
54 | uint m_count; | 53 | uint m_count; |
55 | QString m_file; | 54 | QString m_file; |
56 | QString m_outp; | 55 | QString m_outp; |
57 | OProcess *m_send; | 56 | OProcess *m_send; |
58 | OProcess *m_rec; | 57 | OProcess *m_rec; |
59 | bool m_receive : 1; | 58 | bool m_receive : 1; |
60 | void shutDownReceive(); | 59 | void shutDownReceive(); |
61 | 60 | ||
62 | private slots: | 61 | private slots: |
63 | 62 | ||
64 | /** | 63 | /** |
65 | * send over palm obex | 64 | * send over palm obex |
66 | */ | 65 | */ |
67 | 66 | ||
68 | //void send(const QString&); | 67 | //void send(const QString&); |
69 | 68 | ||
70 | // the process exited | 69 | // the process exited |
71 | void slotExited(OProcess* proc) ; | 70 | void slotExited(OProcess* proc) ; |
72 | void slotStdOut(OProcess*, char*, int); | 71 | void slotStdOut(OProcess*, char*, int); |
73 | void slotError(); | 72 | void slotError(); |
74 | 73 | ||
75 | private: | 74 | private: |
76 | void sendNow(); | 75 | void sendNow(); |
77 | QString parseOut(); | 76 | QString parseOut(); |
78 | void received(); | 77 | void received(); |
79 | void sendEnd(); | 78 | void sendEnd(); |
80 | 79 | ||
81 | }; | 80 | }; |
82 | }; | 81 | }; |
83 | 82 | ||
84 | 83 | ||
85 | #endif | 84 | #endif |
diff --git a/core/obex/obexhandler.cpp b/core/obex/obexhandler.cpp new file mode 100644 index 0000000..f71a233 --- a/dev/null +++ b/core/obex/obexhandler.cpp | |||
@@ -0,0 +1,65 @@ | |||
1 | #include <qcopchannel_qws.h> | ||
2 | |||
3 | #include <qpe/qcopenvelope_qws.h> | ||
4 | |||
5 | #include "obexsend.h" | ||
6 | #include "receiver.h" | ||
7 | #include "obexhandler.h" | ||
8 | |||
9 | using namespace OpieObex; | ||
10 | |||
11 | ObexHandler::ObexHandler() { | ||
12 | m_wasRec = false; | ||
13 | m_sender = 0l; | ||
14 | m_receiver = 0l; | ||
15 | QCopChannel* chan = new QCopChannel("QPE/Obex"); | ||
16 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | ||
17 | this, SLOT(irdaMessage(const QCString&, const QByteArray& ) ) ); | ||
18 | } | ||
19 | ObexHandler::~ObexHandler() { | ||
20 | delete m_sender; | ||
21 | delete m_receiver; | ||
22 | } | ||
23 | void ObexHandler::doSend(const QString& str, const QString& desc) { | ||
24 | delete m_sender; | ||
25 | m_sender = new SendWidget; | ||
26 | m_sender->raise(); | ||
27 | m_sender->showMaximized(); | ||
28 | connect(m_sender, SIGNAL(done() ), | ||
29 | this, SLOT(slotSent() ) ); | ||
30 | m_sender->send( str, desc ); | ||
31 | } | ||
32 | void ObexHandler::doReceive(bool b) { | ||
33 | if (m_receiver && b ) return; // we should enable receiver and it is on | ||
34 | else if (!m_receiver && !b ) return; // we should disbale receiver and it is off | ||
35 | else if (m_receiver && !b ) { | ||
36 | delete m_receiver; | ||
37 | m_receiver=0; | ||
38 | }else if (!m_receiver && b ) { | ||
39 | m_receiver= new Receiver; | ||
40 | } | ||
41 | } | ||
42 | void ObexHandler::slotSent() { | ||
43 | QString file = m_sender->file(); | ||
44 | delete m_sender; | ||
45 | m_sender = 0; | ||
46 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); | ||
47 | e << file; | ||
48 | doReceive(m_wasRec ); | ||
49 | m_wasRec = false; | ||
50 | } | ||
51 | void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) { | ||
52 | QDataStream stream( data, IO_ReadOnly ); | ||
53 | if ( msg == "send(QString,QString,QString)" ) { | ||
54 | QString name, desc; | ||
55 | stream >> name; | ||
56 | stream >> desc; | ||
57 | m_wasRec = (m_receiver != 0 ); | ||
58 | doReceive( false ); | ||
59 | doSend(name, desc); | ||
60 | }else if (msg == "receive(int)") { | ||
61 | int rec; | ||
62 | stream >> rec; | ||
63 | doReceive(rec); | ||
64 | } | ||
65 | } | ||
diff --git a/core/obex/obexhandler.h b/core/obex/obexhandler.h new file mode 100644 index 0000000..230c4f0 --- a/dev/null +++ b/core/obex/obexhandler.h | |||
@@ -0,0 +1,39 @@ | |||
1 | #ifndef OPIE_OBEX_HANDLER_H | ||
2 | #define OPIE_OBEX_HANDLER_H | ||
3 | |||
4 | #include <qobject.h> | ||
5 | #include <qstring.h> | ||
6 | |||
7 | namespace OpieObex { | ||
8 | /* | ||
9 | * The handler is responsible for handling receiving | ||
10 | * and sending | ||
11 | * It will connect to the IrDa QCOP channel and then | ||
12 | * wait for activation... | ||
13 | */ | ||
14 | class SendWidget; | ||
15 | class Receiver; | ||
16 | class ObexHandler : public QObject { | ||
17 | Q_OBJECT | ||
18 | public: | ||
19 | ObexHandler(); | ||
20 | ~ObexHandler(); | ||
21 | |||
22 | private slots: | ||
23 | void doSend(const QString&,const QString& ); | ||
24 | void doReceive(bool b); | ||
25 | void slotSent(); | ||
26 | |||
27 | private slots: // QCOP message | ||
28 | void irdaMessage( const QCString&, const QByteArray& ); | ||
29 | |||
30 | private: | ||
31 | SendWidget* m_sender; | ||
32 | Receiver* m_receiver; | ||
33 | bool m_wasRec : 1; | ||
34 | |||
35 | }; | ||
36 | } | ||
37 | |||
38 | |||
39 | #endif | ||
diff --git a/core/obex/obeximpl.cpp b/core/obex/obeximpl.cpp new file mode 100644 index 0000000..12a078f --- a/dev/null +++ b/core/obex/obeximpl.cpp | |||
@@ -0,0 +1,28 @@ | |||
1 | #include "obexhandler.h" | ||
2 | #include "obeximpl.h" | ||
3 | |||
4 | using namespace OpieObex; | ||
5 | |||
6 | ObexImpl::ObexImpl() { | ||
7 | m_handler = new ObexHandler; | ||
8 | } | ||
9 | ObexImpl::~ObexImpl() { | ||
10 | delete m_handler; | ||
11 | } | ||
12 | QRESULT ObexImpl::queryInterface( const QUuid& uuid, QUnknownInterface **iface ) { | ||
13 | *iface = 0; | ||
14 | if ( uuid == IID_QUnknown ) { | ||
15 | *iface = this; | ||
16 | }else if ( uuid == IID_ObexInterface ) | ||
17 | *iface = this; | ||
18 | |||
19 | if (*iface) | ||
20 | (*iface)->addRef(); | ||
21 | |||
22 | return QS_OK; | ||
23 | } | ||
24 | |||
25 | |||
26 | Q_EXPORT_INTERFACE() { | ||
27 | Q_CREATE_INSTANCE( ObexImpl ) | ||
28 | } | ||
diff --git a/core/obex/obeximpl.h b/core/obex/obeximpl.h new file mode 100644 index 0000000..604eb8f --- a/dev/null +++ b/core/obex/obeximpl.h | |||
@@ -0,0 +1,22 @@ | |||
1 | #ifndef OPIE_OBEX_IMPL_QUERY_H | ||
2 | #define OPIE_OBEX_IMPL_QUERY_H | ||
3 | |||
4 | #include <obexinterface.h> | ||
5 | |||
6 | namespace OpieObex { | ||
7 | class ObexHandler; | ||
8 | class ObexImpl : public ObexInterface { | ||
9 | public: | ||
10 | ObexImpl(); | ||
11 | virtual ~ObexImpl(); | ||
12 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
13 | Q_REFCOUNT | ||
14 | |||
15 | private: | ||
16 | ulong ref; | ||
17 | ObexHandler *m_handler; | ||
18 | |||
19 | }; | ||
20 | }; | ||
21 | |||
22 | #endif | ||
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp new file mode 100644 index 0000000..a2e4c16 --- a/dev/null +++ b/core/obex/obexsend.cpp | |||
@@ -0,0 +1,251 @@ | |||
1 | #include <qpushbutton.h> | ||
2 | #include <qlabel.h> | ||
3 | #include <qhbox.h> | ||
4 | #include <qlayout.h> | ||
5 | #include <qtimer.h> | ||
6 | |||
7 | #include <qcopchannel_qws.h> | ||
8 | |||
9 | #include <qpe/resource.h> | ||
10 | #include <qpe/qcopenvelope_qws.h> | ||
11 | |||
12 | #include "obex.h" | ||
13 | #include "obexsend.h" | ||
14 | |||
15 | using namespace OpieObex; | ||
16 | |||
17 | |||
18 | SendWidget::SendWidget( QWidget* parent, const char* name ) | ||
19 | : QWidget( parent, name ) { | ||
20 | initUI(); | ||
21 | } | ||
22 | SendWidget::~SendWidget() { | ||
23 | } | ||
24 | void SendWidget::initUI() { | ||
25 | m_obex = new Obex(this, "obex"); | ||
26 | connect(m_obex, SIGNAL(error(int) ), | ||
27 | this, SLOT(slotIrError(int) ) ); | ||
28 | connect(m_obex, SIGNAL(sent(bool) ), | ||
29 | this, SLOT(slotIrSent(bool) ) ); | ||
30 | connect(m_obex, SIGNAL(currentTry(unsigned int ) ), | ||
31 | this, SLOT(slotIrTry(unsigned int ) ) ); | ||
32 | |||
33 | QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); | ||
34 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | ||
35 | this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) ); | ||
36 | |||
37 | chan = new QCopChannel("QPE/BluetoothBack", this ); | ||
38 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | ||
39 | this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) ); | ||
40 | |||
41 | QVBoxLayout* lay = new QVBoxLayout(this); | ||
42 | |||
43 | QHBox* nameBox = new QHBox(this); | ||
44 | QLabel* name = new QLabel(nameBox); | ||
45 | name->setText( tr("<qt><h1>Sending:</h1></qt>") ); | ||
46 | name->setAlignment( AlignLeft | AlignTop ); | ||
47 | m_lblFile = new QLabel(nameBox); | ||
48 | lay->addWidget(nameBox, 0); | ||
49 | |||
50 | QFrame* frame = new QFrame(this); | ||
51 | frame->setFrameShape( QFrame::HLine ); | ||
52 | frame->setFrameShadow( QFrame::Sunken ); | ||
53 | lay->addWidget(frame, 10); | ||
54 | |||
55 | QLabel* devices = new QLabel(this); | ||
56 | devices->setText("<qt><b>Devices:</b></qt>"); | ||
57 | devices->setAlignment( AlignLeft | AlignTop ); | ||
58 | lay->addWidget( devices,10 ); | ||
59 | |||
60 | m_devBox = new DeviceBox(this); | ||
61 | lay->addWidget( m_devBox, 50 ); | ||
62 | connect(m_devBox, SIGNAL(selectedDevice(const QString&, int ) ), | ||
63 | this, SLOT(slotSelectedDevice(const QString&, int) ) ); | ||
64 | |||
65 | QPushButton *but = new QPushButton(this); | ||
66 | but->setText(tr("Done") ); | ||
67 | connect(but, SIGNAL(clicked() ), | ||
68 | this, SLOT(slotDone() ) ); | ||
69 | |||
70 | lay->addWidget( but ); | ||
71 | m_lay = lay; | ||
72 | |||
73 | // QT does not like if you add items to an layout which already exits.... | ||
74 | // and was layouted invalidate() does not help too | ||
75 | // so we use RichText.... | ||
76 | } | ||
77 | |||
78 | /* | ||
79 | * in send we'll first set everything up | ||
80 | * and then wait for a list of devices. | ||
81 | */ | ||
82 | void SendWidget::send( const QString& file, const QString& desc ) { | ||
83 | m_file = file; | ||
84 | m_irDa.clear(); | ||
85 | m_start = 0; | ||
86 | m_lblFile->setText(desc.isEmpty() ? file : desc ); | ||
87 | |||
88 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { | ||
89 | m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error ); | ||
90 | m_start++; | ||
91 | }else | ||
92 | m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search ); | ||
93 | |||
94 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { | ||
95 | m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error ); | ||
96 | m_start++; | ||
97 | }else | ||
98 | m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); | ||
99 | |||
100 | if (m_start != 2 ) { | ||
101 | QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); | ||
102 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); | ||
103 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | ||
104 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); | ||
105 | } | ||
106 | QTimer::singleShot(5000, this, SLOT(testIt() ) ); | ||
107 | } | ||
108 | void SendWidget::slotIrDaDevices( const QStringList& list) { | ||
109 | m_irDa = list; | ||
110 | m_start = 0; | ||
111 | for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) | ||
112 | m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); | ||
113 | m_devBox->removeDevice( tr("Search for IrDa Devices.") ); | ||
114 | |||
115 | slotStartIrda(); | ||
116 | } | ||
117 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { | ||
118 | m_bt = str; | ||
119 | for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { | ||
120 | m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); | ||
121 | } | ||
122 | m_devBox->removeDevice( tr("Searching for bluetooth Devices.") ); | ||
123 | } | ||
124 | void SendWidget::slotSelectedDevice( const QString& name, int dev ) { | ||
125 | qWarning("Start beam? %s %d", name.latin1(), dev ); | ||
126 | if ( name == tr("Search again for IrDa.") ) { | ||
127 | for (QStringList::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) | ||
128 | m_devBox->removeDevice( (*it) ); | ||
129 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | ||
130 | } | ||
131 | } | ||
132 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { | ||
133 | qWarning("dispatch irda %s", str.data() ); | ||
134 | if ( str == "listDevices(QStringList)" ) { | ||
135 | QDataStream stream( ar, IO_ReadOnly ); | ||
136 | QStringList list; | ||
137 | stream >> list; | ||
138 | slotIrDaDevices( list ); | ||
139 | } | ||
140 | } | ||
141 | void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { | ||
142 | |||
143 | } | ||
144 | void SendWidget::slotIrError( int ) { | ||
145 | |||
146 | } | ||
147 | void SendWidget::slotIrSent( bool b) { | ||
148 | QString text = b ? tr("Sent") : tr("Failure"); | ||
149 | m_devBox->setStatus( m_irDa[m_start], text ); | ||
150 | m_start++; | ||
151 | slotStartIrda(); | ||
152 | } | ||
153 | void SendWidget::slotIrTry(unsigned int trI) { | ||
154 | m_devBox->setStatus( m_irDa[m_start], tr("Try %1").arg( QString::number( trI ) ) ); | ||
155 | } | ||
156 | void SendWidget::slotStartIrda() { | ||
157 | if (m_start >= m_irDa.count() ) { | ||
158 | m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); | ||
159 | return; | ||
160 | } | ||
161 | m_devBox->setStatus( m_irDa[m_start], tr("Start sending") ); | ||
162 | m_obex->send( m_file ); | ||
163 | } | ||
164 | void SendWidget::slotDone() { | ||
165 | QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); | ||
166 | QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); | ||
167 | emit done(); | ||
168 | } | ||
169 | QString SendWidget::file()const { | ||
170 | return m_file; | ||
171 | } | ||
172 | DeviceBox::DeviceBox( QWidget* parent ) | ||
173 | : QTextBrowser( parent ) { | ||
174 | |||
175 | } | ||
176 | DeviceBox::~DeviceBox() { | ||
177 | |||
178 | } | ||
179 | void DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { | ||
180 | QString tex; | ||
181 | DeviceItem item( name, status, dev ); | ||
182 | m_dev.insert( name, item ); | ||
183 | tex = item.toString(); | ||
184 | m_devices.prepend(tex); | ||
185 | setText( text()+ "<br>"+tex ); | ||
186 | } | ||
187 | void DeviceBox::removeDevice( const QString& name ) { | ||
188 | if (!m_dev.contains(name) ) return; | ||
189 | m_devices.remove( m_dev[name].toString() ); | ||
190 | |||
191 | m_dev.remove(name); | ||
192 | setText( m_devices.join("<br>") ); | ||
193 | |||
194 | } | ||
195 | void DeviceBox::setStatus( const QString& name, const QString& status ) { | ||
196 | if ( !m_dev.contains(name) ) return; | ||
197 | DeviceItem dev = m_dev[name]; | ||
198 | QString ole = dev.toString(); | ||
199 | dev.setStatus( status ); | ||
200 | int index = m_devices.findIndex( ole ); | ||
201 | m_devices[index] = dev.toString(); | ||
202 | setText( m_devices.join("<br>") ); | ||
203 | } | ||
204 | void DeviceBox::setSource( const QString& str ) { | ||
205 | qWarning("SetSource:%s", str.latin1() ); | ||
206 | emit selectedDevice( str, m_dev[str].device() ); | ||
207 | } | ||
208 | |||
209 | |||
210 | DeviceItem::DeviceItem( const QString& name, | ||
211 | const QString& status, int dev) | ||
212 | { | ||
213 | m_name = name; | ||
214 | m_status = status; | ||
215 | m_dev = dev; | ||
216 | } | ||
217 | QString DeviceItem::name()const { | ||
218 | return m_name; | ||
219 | } | ||
220 | QString DeviceItem::status()const { | ||
221 | return m_status; | ||
222 | } | ||
223 | int DeviceItem::device()const { | ||
224 | return m_dev; | ||
225 | } | ||
226 | QString DeviceItem::pixmap()const{ | ||
227 | QString str; | ||
228 | switch(m_dev) { | ||
229 | case DeviceBox::IrDa: | ||
230 | str ="obex/irda"; | ||
231 | break; | ||
232 | case DeviceBox::BT: | ||
233 | str ="obex/bt"; | ||
234 | break; | ||
235 | case DeviceBox::Search: | ||
236 | str = "obex/search"; | ||
237 | break; | ||
238 | case DeviceBox::Error: | ||
239 | str = "editdelete"; | ||
240 | break; | ||
241 | }; | ||
242 | return str; | ||
243 | } | ||
244 | DeviceItem::~DeviceItem() { | ||
245 | } | ||
246 | void DeviceItem::setStatus(const QString& status ) { | ||
247 | m_status = status; | ||
248 | } | ||
249 | QString DeviceItem::toString()const { | ||
250 | return "<p><a href=\""+m_name +"\" ><img src=\""+pixmap()+"\" >"+m_name+" "+m_status+" </a></p>" ; | ||
251 | } | ||
diff --git a/core/obex/obexsend.h b/core/obex/obexsend.h new file mode 100644 index 0000000..fd819bc --- a/dev/null +++ b/core/obex/obexsend.h | |||
@@ -0,0 +1,99 @@ | |||
1 | #ifndef OPIE_OBEX_SEND_WIDGET_H | ||
2 | #define OPIE_OBEX_SEND_WIDGET_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qwidget.h> | ||
7 | #include <qvbox.h> | ||
8 | #include <qmap.h> | ||
9 | #include <qtextbrowser.h> | ||
10 | |||
11 | class QLabel; | ||
12 | class QVBoxLayout; | ||
13 | /** | ||
14 | * This is the new sending widget for Obex | ||
15 | * It will attemp to smart and be able to send | ||
16 | * it to multiple devices. | ||
17 | * It'll support BT + IrDa | ||
18 | */ | ||
19 | namespace OpieObex { | ||
20 | class DeviceBox; | ||
21 | class Obex; | ||
22 | class SendWidget : public QWidget{ | ||
23 | Q_OBJECT | ||
24 | public: | ||
25 | SendWidget( QWidget* parent = 0, const char* name = 0); | ||
26 | ~SendWidget(); | ||
27 | |||
28 | QString file()const; | ||
29 | |||
30 | public slots: | ||
31 | void send( const QString& file, const QString& desc ); | ||
32 | |||
33 | signals: | ||
34 | void done(); | ||
35 | |||
36 | private slots: // QCOP slots | ||
37 | /* IrDa Names*/ | ||
38 | void slotIrDaDevices( const QStringList& ); | ||
39 | /* Bt Names + BD-Addr */ | ||
40 | void slotBTDevices( const QMap<QString, QString>& ); | ||
41 | void slotSelectedDevice( const QString& name, int dev ); | ||
42 | void dispatchIrda( const QCString& str, const QByteArray& ar ); | ||
43 | void dispatchBt( const QCString& str, const QByteArray& ar ); | ||
44 | |||
45 | void slotIrError( int ); | ||
46 | void slotIrSent(bool); | ||
47 | void slotIrTry(unsigned int ); | ||
48 | void slotStartIrda(); | ||
49 | void slotDone(); | ||
50 | private: | ||
51 | void initUI(); | ||
52 | QLabel* m_lblFile; | ||
53 | DeviceBox* m_devBox; | ||
54 | QVBoxLayout* m_lay; | ||
55 | int m_start; | ||
56 | QStringList m_irDa; | ||
57 | QMap<QString, QString> m_bt; | ||
58 | QString m_file; | ||
59 | Obex* m_obex; | ||
60 | }; | ||
61 | class DeviceItem { | ||
62 | public: | ||
63 | DeviceItem( const QString& name = QString::null, | ||
64 | const QString& status = QString::null, int dev = 3); | ||
65 | ~DeviceItem(); | ||
66 | void setStatus( const QString& text ); | ||
67 | |||
68 | QString name()const; | ||
69 | QString status()const; | ||
70 | QString pixmap()const; | ||
71 | int device()const; | ||
72 | QString toString()const; | ||
73 | private: | ||
74 | QString m_name; | ||
75 | QString m_status; | ||
76 | int m_dev; | ||
77 | }; | ||
78 | class DeviceBox : public QTextBrowser { | ||
79 | Q_OBJECT | ||
80 | public: | ||
81 | enum Device { IrDa, BT, Search, Error }; | ||
82 | DeviceBox( QWidget* parent ); | ||
83 | ~DeviceBox(); | ||
84 | |||
85 | void setSource( const QString& str ); | ||
86 | void addDevice( const QString& name, int dev, | ||
87 | const QString& status = QString::null ); | ||
88 | void removeDevice( const QString& name ); | ||
89 | void setStatus( const QString& name, const QString& ); | ||
90 | signals: | ||
91 | void selectedDevice( const QString& name, int dev ); | ||
92 | private: | ||
93 | QMap<QString, DeviceItem> m_dev; | ||
94 | QStringList m_devices; | ||
95 | |||
96 | }; | ||
97 | } | ||
98 | |||
99 | #endif | ||
diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp new file mode 100644 index 0000000..50ee6cb --- a/dev/null +++ b/core/obex/receiver.cpp | |||
@@ -0,0 +1,166 @@ | |||
1 | #include <sys/types.h> | ||
2 | #include <sys/stat.h> | ||
3 | #include <sys/mman.h> | ||
4 | #include <unistd.h> | ||
5 | |||
6 | #include <fcntl.h> | ||
7 | |||
8 | #include <qfile.h> | ||
9 | #include <qfileinfo.h> | ||
10 | #include <qlabel.h> | ||
11 | #include <qhbox.h> | ||
12 | #include <qtextview.h> | ||
13 | #include <qpushbutton.h> | ||
14 | |||
15 | #include <qpe/applnk.h> | ||
16 | #include <qpe/qpeapplication.h> | ||
17 | #include <qpe/qcopenvelope_qws.h> | ||
18 | |||
19 | #include "obex.h" | ||
20 | #include "receiver.h" | ||
21 | |||
22 | using namespace OpieObex; | ||
23 | |||
24 | Receiver::Receiver() { | ||
25 | m_obex = new Obex(this, "Receiver"); | ||
26 | connect(m_obex, SIGNAL(receivedFile(const QString& ) ), | ||
27 | this, SLOT(slotReceived(const QString& ) ) ); | ||
28 | m_obex->receive(); | ||
29 | } | ||
30 | Receiver::~Receiver() { | ||
31 | m_obex->setReceiveEnabled( false ); | ||
32 | delete m_obex; | ||
33 | } | ||
34 | void Receiver::slotReceived( const QString& file ) { | ||
35 | int check = checkFile(file); | ||
36 | if ( check == AddressBook ) | ||
37 | handleAddr( file ); | ||
38 | else if ( check == Datebook ) | ||
39 | handleDateTodo( file ); | ||
40 | else | ||
41 | handleOther( file ); | ||
42 | } | ||
43 | void Receiver::handleAddr( const QString& str ) { | ||
44 | QCopEnvelope e("QPE/Application/addressbook", "setDocument(QString)" ); | ||
45 | e << str; | ||
46 | } | ||
47 | /* we can not say for sure if it's a VEevent ot VTodo */ | ||
48 | void Receiver::handleDateTodo( const QString& str ) { | ||
49 | QCopEnvelope e0("QPE/Application/todolist", "setDocument(QString)"); | ||
50 | e0 << str; | ||
51 | QCopEnvelope e1("QPE/Application/datebook", "setDocument(QString)" ); | ||
52 | e1 << str; | ||
53 | } | ||
54 | /* | ||
55 | * Handle other asks if it should accept the | ||
56 | * beamed object and creates a DocLnk | ||
57 | */ | ||
58 | void Receiver::handleOther( const QString& other ) { | ||
59 | OtherHandler* hand = new OtherHandler(); | ||
60 | hand->handle( other ); | ||
61 | } | ||
62 | int Receiver::checkFile( const QString& file ) { | ||
63 | int ret; | ||
64 | if (file.right(4) == ".vcs" ) { | ||
65 | ret = Datebook; | ||
66 | }else if ( file.right(4) == ".vcf") { | ||
67 | ret = AddressBook; | ||
68 | }else | ||
69 | ret = Other; | ||
70 | |||
71 | return ret; | ||
72 | } | ||
73 | |||
74 | OtherHandler::OtherHandler() | ||
75 | : QVBox() | ||
76 | { | ||
77 | QHBox* box = new QHBox(this); | ||
78 | QLabel* lbl = new QLabel(box); | ||
79 | lbl->setText(tr("<qt><b>Received:</b></qt>")); | ||
80 | m_na = new QLabel(box); | ||
81 | |||
82 | QFrame* frame = new QFrame(this); | ||
83 | frame->setFrameShape( QFrame::HLine ); | ||
84 | frame->setFrameShadow( QFrame::Sunken ); | ||
85 | |||
86 | m_view = new QTextView(this); | ||
87 | |||
88 | box = new QHBox(this); | ||
89 | QPushButton *but = new QPushButton(box); | ||
90 | but->setText(tr("Accept") ); | ||
91 | connect(but, SIGNAL(clicked() ), | ||
92 | this, SLOT(accept()) ); | ||
93 | |||
94 | but = new QPushButton(box); | ||
95 | but->setText(tr("Deny") ); | ||
96 | connect(but, SIGNAL(clicked() ), | ||
97 | this, SLOT(deny() ) ); | ||
98 | |||
99 | raise(); | ||
100 | showMaximized(); | ||
101 | } | ||
102 | OtherHandler::~OtherHandler() { | ||
103 | |||
104 | } | ||
105 | void OtherHandler::handle( const QString& file ) { | ||
106 | m_file = file; | ||
107 | m_na->setText(file); | ||
108 | DocLnk lnk(file); | ||
109 | |||
110 | 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() ); | ||
111 | m_view->setText( str ); | ||
112 | } | ||
113 | |||
114 | /* | ||
115 | * hehe evil evil mmap ahead :) | ||
116 | * we quickly copy the file and then we'll create a DocLnk for it | ||
117 | */ | ||
118 | void OtherHandler::accept() { | ||
119 | QString na = targetName( m_file ); | ||
120 | copy(m_file, na ); | ||
121 | DocLnk lnk(na); | ||
122 | lnk.writeLink(); | ||
123 | QFile::remove(m_file); | ||
124 | delete this; | ||
125 | } | ||
126 | void OtherHandler::deny() { | ||
127 | QFile::remove( m_file ); | ||
128 | delete this; | ||
129 | } | ||
130 | QString OtherHandler::targetName( const QString& file ) { | ||
131 | QFileInfo info( file ); | ||
132 | QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName(); | ||
133 | QString newFileBase = newFile; | ||
134 | |||
135 | int trie = 0; | ||
136 | while (QFile::exists(newFile + info.extension() ) ) { | ||
137 | newFile = newFileBase + "_"+QString::number(trie) ; | ||
138 | trie++; | ||
139 | } | ||
140 | newFile += info.extension(); | ||
141 | |||
142 | return newFile; | ||
143 | } | ||
144 | |||
145 | /* fast cpy */ | ||
146 | void OtherHandler::copy(const QString& src, const QString& file) { | ||
147 | int src_fd = ::open( QFile::encodeName( src ), O_RDONLY ); | ||
148 | int to_fd = ::open( QFile::encodeName( file), O_RDWR| O_CREAT| O_TRUNC, | ||
149 | S_IRUSR, S_IWUSR, S_IRGRP, S_IRGRP ); | ||
150 | |||
151 | struct stat stater; | ||
152 | ::fstat(src_fd, &stater ); | ||
153 | ::lseek(to_fd, stater.st_size-1, SEEK_SET ); | ||
154 | |||
155 | void *src_addr, *dest_addr; | ||
156 | src_addr = ::mmap(0, stater.st_size, PROT_READ, | ||
157 | MAP_FILE | MAP_SHARED, src_fd, 0 ); | ||
158 | dest_addr= ::mmap(0, stater.st_size, PROT_READ | PROT_WRITE, | ||
159 | MAP_FILE | MAP_PRIVATE, to_fd, 0 ); | ||
160 | |||
161 | ::memcpy(src_addr , dest_addr, stater.st_size ); | ||
162 | ::munmap(src_addr , stater.st_size ); | ||
163 | ::munmap(dest_addr, stater.st_size ); | ||
164 | |||
165 | // done | ||
166 | } | ||
diff --git a/core/obex/receiver.h b/core/obex/receiver.h new file mode 100644 index 0000000..5b20146 --- a/dev/null +++ b/core/obex/receiver.h | |||
@@ -0,0 +1,55 @@ | |||
1 | #ifndef OPIE_OBEX_RECEIVER_H | ||
2 | #define OPIE_OBEX_RECEIVER_H | ||
3 | |||
4 | #include <qobject.h> | ||
5 | #include <qvbox.h> | ||
6 | #include <qstring.h> | ||
7 | |||
8 | class QLabel; | ||
9 | class QTextView; | ||
10 | namespace OpieObex { | ||
11 | class Obex; | ||
12 | class OtherHandler; | ||
13 | class Receiver : public QObject { | ||
14 | Q_OBJECT | ||
15 | public: | ||
16 | enum { Datebook , AddressBook, Other }; | ||
17 | Receiver(); | ||
18 | ~Receiver(); | ||
19 | |||
20 | private: | ||
21 | void handleAddr(const QString& ); | ||
22 | void handleDateTodo(const QString& ); | ||
23 | void handleOther(const QString& ); | ||
24 | int checkFile( const QString& file ); | ||
25 | bool testDateTodo(const QString& file); | ||
26 | bool testAddressbook(const QString& file); | ||
27 | |||
28 | private slots: | ||
29 | void slotReceived( const QString& ); | ||
30 | |||
31 | private: | ||
32 | Obex* m_obex; | ||
33 | }; | ||
34 | |||
35 | class OtherHandler : public QVBox { | ||
36 | Q_OBJECT | ||
37 | public: | ||
38 | OtherHandler(); | ||
39 | ~OtherHandler(); | ||
40 | |||
41 | void handle( const QString& file ); | ||
42 | private slots: | ||
43 | void accept(); | ||
44 | void deny(); | ||
45 | private: | ||
46 | QString targetName( const QString& file ); | ||
47 | void copy( const QString& src, const QString& dest ); | ||
48 | QLabel* m_na; | ||
49 | QTextView* m_view; | ||
50 | QString m_file; | ||
51 | }; | ||
52 | } | ||
53 | |||
54 | |||
55 | #endif | ||