[Libreoffice-commits] .: android/sdremote sd/CppunitTest_sd_uimpress.mk sd/Library_sd.mk sd/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Aug 20 02:21:35 PDT 2012
android/sdremote/AndroidManifest.xml | 2
android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java | 27 +
android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java | 115 ++++++
android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java | 28 -
android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java | 21 -
sd/CppunitTest_sd_uimpress.mk | 4
sd/Library_sd.mk | 10
sd/source/ui/remotecontrol/BluetoothServer.cxx | 175 ++++++++++
sd/source/ui/remotecontrol/BluetoothServer.hxx | 34 +
sd/source/ui/remotecontrol/Server.cxx | 2
sd/source/ui/remotecontrol/bluetooth/bluetooth.h | 68 +++
sd/source/ui/remotecontrol/bluetooth/rfcomm.h | 46 ++
12 files changed, 489 insertions(+), 43 deletions(-)
New commits:
commit 95ebf4e3b3702d5820ba4bbea3ff5eae5e12fe62
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Mon Aug 20 11:18:35 2012 +0200
Bluetooth discovery and attempts at communication.
Change-Id: I88e261b7d0f830f67166d4eaf592298015b1c5ae
diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml
index 796cf81..04255fd 100644
--- a/android/sdremote/AndroidManifest.xml
+++ b/android/sdremote/AndroidManifest.xml
@@ -5,6 +5,8 @@
android:versionName="0.1-Alpha" >
<uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.BLUETOOTH" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-sdk
android:minSdkVersion="14"
diff --git a/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
index a239312..f6f9514 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
@@ -67,7 +67,7 @@ public class SelectorActivity extends Activity {
@Override
public void onBackPressed() {
- mCommunicationService.stopFindingServers();
+ mCommunicationService.stopSearching();
Intent aIntent = new Intent(this, CommunicationService.class);
stopService(aIntent);
super.onBackPressed();
@@ -76,6 +76,10 @@ public class SelectorActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
+ mNetworkList.removeAllViews();
+ mBluetoothList.removeAllViews();
+ mNetworkServers.clear();
+ mBluetoothServers.clear();
doBindService();
}
@@ -84,7 +88,7 @@ public class SelectorActivity extends Activity {
// TODO Auto-generated method stub
super.onPause();
if (mCommunicationService != null) {
- mCommunicationService.stopFindingServers();
+ mCommunicationService.stopSearching();
}
doUnbindService();
}
@@ -105,7 +109,7 @@ public class SelectorActivity extends Activity {
IBinder aService) {
mCommunicationService = ((CommunicationService.CBinder) aService)
.getService();
- mCommunicationService.startFindingServers();
+ mCommunicationService.startSearching();
}
@Override
@@ -137,15 +141,20 @@ public class SelectorActivity extends Activity {
// Bluetooth -- Remove old
for (Entry<Server, View> aEntry : mBluetoothServers.entrySet()) {
if (!Arrays.asList(aServers).contains(aEntry.getKey())) {
+ System.out.println("Removing view "
+ + aEntry.getKey().getName());
mBluetoothServers.remove(aEntry.getKey());
- mBluetoothList.removeView(aEntry.getValue());
+ mBluetoothList.removeView((View) aEntry.getValue()
+ .getParent());
}
}
// Network -- Remove old
for (Entry<Server, View> aEntry : mNetworkServers.entrySet()) {
if (!Arrays.asList(aServers).contains(aEntry.getKey())) {
- mNetworkServers.remove(aEntry.getKey());
- mNetworkList.removeView(aEntry.getValue());
+ System.out.println("Removing view");
+ mNetworkServers.remove(aEntry.getKey().getName());
+ mNetworkList.removeView((View) aEntry.getValue()
+ .getParent());
}
}
// Add all new
@@ -156,7 +165,7 @@ public class SelectorActivity extends Activity {
LinearLayout aLayout = aIsBluetooth ? mBluetoothList
: mNetworkList;
- if (!aMap.containsValue(aServer)) {
+ if (!aMap.containsKey(aServer)) {
View aView = getLayoutInflater()
.inflate(R.layout.activity_selector_sublayout_server,
null);
@@ -166,7 +175,7 @@ public class SelectorActivity extends Activity {
aText.setOnClickListener(mClickListener);
aText.setText(aServer.getName());
aLayout.addView(aView);
- aMap.put(aServer, aView);
+ aMap.put(aServer, aText);
}
}
@@ -188,7 +197,7 @@ public class SelectorActivity extends Activity {
@Override
public void onClick(View aView) {
- mCommunicationService.stopFindingServers();
+ mCommunicationService.stopSearching();
Server aDesiredServer = null;
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java
new file mode 100644
index 0000000..bfe10a9
--- /dev/null
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java
@@ -0,0 +1,115 @@
+package org.libreoffice.impressremote.communication;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+import org.libreoffice.impressremote.communication.Server.Protocol;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+
+public class BluetoothFinder {
+
+ // TODO: add removal of cached items
+ private Context mContext;
+
+ private static final String CHARSET = "UTF-8";
+
+ BluetoothAdapter mAdapter;
+
+ public BluetoothFinder(Context aContext) {
+ mContext = aContext;
+ mAdapter = BluetoothAdapter.getDefaultAdapter();
+
+ }
+
+ public void startFinding() {
+ System.out.println("BT:Discovery starting");
+ IntentFilter aFilter = new IntentFilter(
+ BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
+ aFilter.addAction(BluetoothDevice.ACTION_FOUND);
+ mContext.registerReceiver(mReceiver, aFilter);
+
+ mAdapter.enable();
+ mAdapter.startDiscovery();
+ }
+
+ public void stopFinding() {
+ mAdapter.cancelDiscovery();
+ mContext.unregisterReceiver(mReceiver);
+ }
+
+ private HashMap<String, Server> mServerList = new HashMap<String, Server>();
+
+ public Collection<Server> getServerList() {
+ return mServerList.values();
+ }
+
+ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent aIntent) {
+ // TODO Auto-generated method stub
+ System.out.println("Received intent");
+ System.out.println(aIntent.getAction());
+ if (aIntent.getAction().equals(BluetoothDevice.ACTION_FOUND)) {
+ BluetoothDevice aDevice = (BluetoothDevice) aIntent.getExtras()
+ .get(BluetoothDevice.EXTRA_DEVICE);
+ Server aServer = new Server(Protocol.BLUETOOTH,
+ aDevice.getAddress(), aDevice.getName(),
+ System.currentTimeMillis());
+ mServerList.put(aServer.getAddress(), aServer);
+ System.out.println("Added " + aServer.getName());
+ System.out.println("Now we have: " + mServerList.size());
+ Intent aNIntent = new Intent(
+ CommunicationService.MSG_SERVERLIST_CHANGED);
+ mContext.sendBroadcast(aNIntent);
+ // System.out.println("Found " + aDevice.getName());
+ // try {
+ // // "f36d0a20-e876-11e1-aff1-0800200c9a66"
+ // BluetoothSocket aSocket = aDevice
+ // .createRfcommSocketToServiceRecord(UUID
+ // .fromString("00001101-0000-1000-8000-00805F9B34FB"));
+ // aSocket.connect();
+ // } catch (IOException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // System.out.println("Fallback");
+ // Method m;
+ // try {
+ // m = aDevice.getClass().getMethod("createRfcommSocket",
+ // new Class[] { int.class });
+ // BluetoothSocket aFSocket = (BluetoothSocket) m.invoke(
+ // aDevice, 1);
+ //
+ // mAdapter.cancelDiscovery();
+ // aFSocket.connect();
+ // } catch (NoSuchMethodException e1) {
+ // // TODO Auto-generated catch block
+ // e1.printStackTrace();
+ // } catch (IllegalArgumentException e1) {
+ // // TODO Auto-generated catch block
+ // e1.printStackTrace();
+ // } catch (IllegalAccessException e1) {
+ // // TODO Auto-generated catch block
+ // e1.printStackTrace();
+ // } catch (InvocationTargetException e1) {
+ // // TODO Auto-generated catch block
+ // e1.printStackTrace();
+ // } catch (IOException e1) {
+ // // TODO Auto-generated catch block
+ // e1.printStackTrace();
+ // }
+ // System.out.println("Fallback complete");
+ //
+ // }
+ }
+
+ }
+
+ };
+}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
index 677028c..b25fcc0 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
@@ -8,6 +8,8 @@
*/
package org.libreoffice.impressremote.communication;
+import java.util.ArrayList;
+
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
@@ -87,14 +89,17 @@ public class CommunicationService extends Service implements Runnable {
if (mState == State.CONNECTING || mState == State.CONNECTED) {
disconnect();
}
- mFinder.startFinding();
+ mNetworkFinder.startFinding();
+ mBluetoothFinder.startFinding();
mState = State.SEARCHING;
}
+ new BluetoothFinder(this);
}
public void stopSearching() {
synchronized (mConnectionVariableMutex) {
- mFinder.stopFinding();
+ mNetworkFinder.stopFinding();
+ mBluetoothFinder.stopFinding();
mState = State.DISCONNECTED;
}
}
@@ -102,7 +107,8 @@ public class CommunicationService extends Service implements Runnable {
public void connectTo(Server aServer) {
synchronized (mConnectionVariableMutex) {
if (mState == State.SEARCHING) {
- mFinder.stopFinding();
+ mNetworkFinder.stopFinding();
+ mBluetoothFinder.stopFinding();
mState = State.DISCONNECTED;
}
mServerDesired = aServer;
@@ -150,7 +156,8 @@ public class CommunicationService extends Service implements Runnable {
private Receiver mReceiver = new Receiver(this);
- private ServerFinder mFinder = new ServerFinder(this);
+ private ServerFinder mNetworkFinder = new ServerFinder(this);
+ private BluetoothFinder mBluetoothFinder = new BluetoothFinder(this);
@Override
public IBinder onBind(Intent intent) {
@@ -179,15 +186,10 @@ public class CommunicationService extends Service implements Runnable {
}
public Server[] getServers() {
- return mFinder.getServerList();
- }
-
- public void startFindingServers() {
- mFinder.startFinding();
- }
-
- public void stopFindingServers() {
- mFinder.stopFinding();
+ ArrayList<Server> aServers = new ArrayList<Server>();
+ aServers.addAll(mNetworkFinder.getServerList());
+ aServers.addAll(mBluetoothFinder.getServerList());
+ return aServers.toArray(new Server[aServers.size()]);
}
public SlideShow getSlideShow() {
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java
index 7405a25..67a8862 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java
@@ -6,11 +6,11 @@ import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
+import java.util.Collection;
import java.util.HashMap;
import android.content.Context;
import android.content.Intent;
-import android.support.v4.content.LocalBroadcastManager;
public class ServerFinder {
@@ -42,9 +42,7 @@ public class ServerFinder {
try {
String aCommand = null;
String aName = null;
- System.out.println("SF:Reading");
mSocket.receive(aPacket);
- System.out.println("SF:Received");
int i;
for (i = 0; i < aBuffer.length; i++) {
if (aPacket.getData()[i] == '\n') {
@@ -69,10 +67,6 @@ public class ServerFinder {
System.currentTimeMillis());
mServerList.put(aServer.getAddress(), aServer);
- //System.out.println("SF FOUND: IP="
- //+ aPacket.getAddress().toString() + " HOSTNAME="
- //+ aName);
-
Intent aIntent = new Intent(
CommunicationService.MSG_SERVERLIST_CHANGED);
mContext.sendBroadcast(aIntent);
@@ -92,9 +86,6 @@ public class ServerFinder {
mFinishRequested = false;
- Intent aIntent = new Intent(CommunicationService.MSG_SERVERLIST_CHANGED);
- LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent);
-
if (mListenerThread == null) {
mListenerThread = new Thread() {
@Override
@@ -104,9 +95,7 @@ public class ServerFinder {
mSocket = new DatagramSocket();
mSocket.setSoTimeout(1000 * 10);
while (!mFinishRequested) {
- System.out.println("SF:Looping");
if (System.currentTimeMillis() - aTime > SEARCH_INTERVAL) {
- System.out.println("SF:Sending");
String aString = "LOREMOTE_SEARCH\n";
DatagramPacket aPacket = new DatagramPacket(
aString.getBytes(CHARSET),
@@ -121,9 +110,7 @@ public class ServerFinder {
mServerList.remove(aServer.getAddress());
Intent aIntent = new Intent(
CommunicationService.MSG_SERVERLIST_CHANGED);
- LocalBroadcastManager.getInstance(
- mContext)
- .sendBroadcast(aIntent);
+ mContext.sendBroadcast(aIntent);
}
}
@@ -156,7 +143,7 @@ public class ServerFinder {
}
}
- public Server[] getServerList() {
- return mServerList.values().toArray(new Server[mServerList.size()]);
+ public Collection<Server> getServerList() {
+ return mServerList.values();
}
}
diff --git a/sd/CppunitTest_sd_uimpress.mk b/sd/CppunitTest_sd_uimpress.mk
index ee9046f..7519186 100644
--- a/sd/CppunitTest_sd_uimpress.mk
+++ b/sd/CppunitTest_sd_uimpress.mk
@@ -80,6 +80,10 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_uimpress,\
))
endif
+$(eval $(call gb_CppunitTest_use_externals,sd_uimpress,\
+ gtk \
+))
+
$(eval $(call gb_CppunitTest_add_exception_objects,sd_uimpress,\
sd/qa/unit/uimpress \
))
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk
index 283971c..3b82a0f 100644
--- a/sd/Library_sd.mk
+++ b/sd/Library_sd.mk
@@ -60,10 +60,6 @@ $(eval $(call gb_Library_set_include,sd,\
-I$(WORKDIR)/SdiTarget/sd/sdi \
))
-$(eval $(call gb_Library_use_externals,sd,\
- libxml2 \
-))
-
$(eval $(call gb_Library_add_defs,sd,\
-DSD_DLLIMPLEMENTATION \
))
@@ -109,6 +105,11 @@ $(eval $(call gb_Library_use_libraries,sd,\
$(gb_STDLIBS) \
))
+$(eval $(call gb_Library_use_externals,sd,\
+ gtk \
+ libxml2 \
+))
+
ifeq ($(OS),WNT)
$(eval $(call gb_Library_use_libraries,sd,\
ws2_32 \
@@ -327,6 +328,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\
sd/source/ui/presenter/PresenterPreviewCache \
sd/source/ui/presenter/PresenterTextView \
sd/source/ui/presenter/SlideRenderer \
+ sd/source/ui/remotecontrol/BluetoothServer \
sd/source/ui/remotecontrol/BufferedStreamSocket \
sd/source/ui/remotecontrol/Communicator \
sd/source/ui/remotecontrol/DiscoveryService \
diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx b/sd/source/ui/remotecontrol/BluetoothServer.cxx
new file mode 100644
index 0000000..3cd8cbc
--- /dev/null
+++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx
@@ -0,0 +1,175 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#include "BluetoothServer.hxx"
+#include <stdio.h>
+
+#include <gio/gio.h>
+#include <stdint.h>
+#include <sys/unistd.h>
+#include <sys/socket.h>
+#include <tools/debug.hxx>
+#include <tools/stream.hxx>
+
+#ifdef LINUX
+#include "bluetooth/bluetooth.h"
+#include "bluetooth/rfcomm.h"
+#endif
+
+using namespace sd;
+
+BluetoothServer::BluetoothServer():
+ Thread( "BluetoothServer" )
+{
+
+}
+
+BluetoothServer::~BluetoothServer()
+{
+}
+
+void BluetoothServer::execute()
+{
+#ifdef LINUX
+// g_type_init();
+// GError* aError = NULL;
+// GDBusConnection* aConnection = g_bus_get_sync( G_BUS_TYPE_SYSTEM, NULL, &aError );
+// if ( aError )
+// {
+// fprintf( stderr, aError->message );
+// g_error_free( aError );
+// }
+// GDBusObjectManager* aManager = g_dbus_object_manager_client_new_sync( aConnection,
+// G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, "org.bluez.Manager", "/org/bluez",
+// NULL, NULL, NULL, NULL, &aError );
+// if ( aError )
+// {
+// fprintf( stderr, aError->message );
+// g_error_free( aError );
+// }
+//
+// GVariant *aRet = g_dbus_connection_call_sync( aConnection,
+// "org.bluez", "/", "org.bluez.Database",
+// "AddServiceRecordFromXml",
+// g_variant_new ("s",
+// ""),,
+// G_VARIANT_TYPE_UINT32,
+// G_DBUS_CALL_FLAGS_NONE, -1, NULL, &aError);
+// g_variant_unref( aRet );
+// fprintf( stderr, "Manager gotten\n" );
+//
+// // Name for default adapter
+// GVariant *aAdapter = g_dbus_connection_call_sync( aConnection,
+// "org.bluez", "/", "org.bluez.Manager",
+// "DefaultAdapter", NULL,
+// G_VARIANT_TYPE_TUPLE,
+// G_DBUS_CALL_FLAGS_NONE, -1, NULL, &aError);
+// GVariant *aAdapterName = g_variant_get_child_value( aAdapter, 0 );
+// if ( aError )
+// {
+// fprintf( stderr, aError->message );
+// g_error_free( aError );
+// }
+// fprintf( stderr, (const char*) g_variant_get_string( aAdapterName, NULL ) );
+
+
+
+
+// g_type_init();
+// GError* aError = NULL;
+// GDBusConnection* aConnection = g_bus_get_sync( G_BUS_TYPE_SYSTEM, NULL, &aError );
+// fprintf( stderr, "Connection gotten\n" );
+// if ( aError )
+// {
+// fprintf( stderr, aError->message );
+// g_error_free( aError );
+// }
+// // GDBusObjectManager* aManager = g_dbus_object_manager_client_new_sync( aConnection,
+// // G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, "org.bluez.Manager", "/org/bluez",
+// // NULL, NULL, NULL, NULL, &aError );
+// // if ( aError )
+// // {
+// // fprintf( stderr, aError->message );
+// // g_error_free( aError );
+// // }
+// fprintf( stderr, "Manager gotten\n" );
+//
+// // Name for default adapter
+// GVariant *aAdapter = g_dbus_connection_call_sync( aConnection,
+// "org.bluez", "/", "org.bluez.Manager",
+// "DefaultAdapter", NULL,
+// G_VARIANT_TYPE_TUPLE,
+// G_DBUS_CALL_FLAGS_NONE, -1, NULL, &aError);
+// GVariant *aAdapterName = g_variant_get_child_value( aAdapter, 0 );
+// if ( aError )
+// {
+// fprintf( stderr, aError->message );
+// g_error_free( aError );
+// }
+// fprintf( stderr, (const char*) g_variant_get_string( aAdapterName, NULL ) );
+
+
+ // ---------------- DEVICE ADDRESS
+ int aSocket;
+ if ( (aSocket = socket( AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM )) < 0 )
+ {
+ // Error
+ return;
+ }
+
+ sockaddr_rc aAddr;
+ aAddr.rc_family = AF_BLUETOOTH;
+// aAddr.rc_bdaddr = *BDADDR_ANY;
+ aAddr.rc_channel = 1;
+
+ if ( bind( aSocket, (sockaddr*) &aAddr, sizeof(aAddr)) < 0 ) {
+ close( aSocket );
+ return;
+ }
+
+ if ( listen( aSocket, 1 ) < 0 )
+ {
+ close( aSocket );
+ return;
+ }
+
+ sockaddr_rc aRemoteAddr;
+ socklen_t aRemoteAddrLen = sizeof(aRemoteAddr);
+ if ( accept(aSocket, (sockaddr*) &aRemoteAddr, &aRemoteAddrLen) < 0 )
+ {
+ close( aSocket );
+ return;
+ } else {
+ fprintf( stderr, "Accepted Bluetooth\n" );
+ }
+
+#endif
+
+#ifdef WIN32
+
+#endif
+
+#ifdef MACOSX
+
+#endif
+}
+
+
+BluetoothServer *sd::BluetoothServer::spServer = NULL;
+
+void BluetoothServer::setup()
+{
+ if (spServer)
+ return;
+
+ spServer = new BluetoothServer();
+ spServer->launch();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/sd/source/ui/remotecontrol/BluetoothServer.hxx b/sd/source/ui/remotecontrol/BluetoothServer.hxx
new file mode 100644
index 0000000..b95d862
--- /dev/null
+++ b/sd/source/ui/remotecontrol/BluetoothServer.hxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef _SD_IMPRESSREMOTE_BLUETOOTHSERVER_HXX
+#define _SD_IMPRESSREMOTE_BLUETOOTHSERVER_HXX
+
+#include <salhelper/thread.hxx>
+
+namespace sd
+{
+ class BluetoothServer:
+ public salhelper::Thread
+ {
+ public:
+ static void setup();
+ private:
+ BluetoothServer();
+ ~BluetoothServer();
+ static BluetoothServer *spServer;
+
+
+ public:
+ private:
+ void execute();
+ };
+}
+
+#endif // _SD_IMPRESSREMOTE_BLUETOOTHSERVER_HXX
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
index e7a361e..d353a1b 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -20,6 +20,7 @@
#include "Listener.hxx"
#include "Receiver.hxx"
#include "RemoteServer.hxx"
+#include "BluetoothServer.hxx"
using namespace std;
using namespace sd;
@@ -210,6 +211,7 @@ void SdDLL::RegisterRemotes()
sd::RemoteServer::setup();
sd::DiscoveryService::setup();
+ sd::BluetoothServer::setup();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/remotecontrol/bluetooth/bluetooth.h b/sd/source/ui/remotecontrol/bluetooth/bluetooth.h
new file mode 100644
index 0000000..db6cf30
--- /dev/null
+++ b/sd/source/ui/remotecontrol/bluetooth/bluetooth.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Bluez header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to Android. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __BLUETOOTH_H
+#define __BLUETOOTH_H
+
+#ifdef __cplusplus
+#endif
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <endian.h>
+#include <byteswap.h>
+#ifndef AF_BLUETOOTH
+#define AF_BLUETOOTH 31
+#define PF_BLUETOOTH AF_BLUETOOTH
+#endif
+#ifndef SOL_BLUETOOTH
+#define SOL_BLUETOOTH 274
+#endif
+#define BTPROTO_L2CAP 0
+#define BTPROTO_HCI 1
+#define BTPROTO_SCO 2
+#define BTPROTO_RFCOMM 3
+#define BTPROTO_BNEP 4
+#define BTPROTO_CMTP 5
+#define BTPROTO_HIDP 6
+#define BTPROTO_AVDTP 7
+#define SOL_HCI 0
+#define SOL_L2CAP 6
+#define SOL_SCO 17
+#define SOL_RFCOMM 18
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define htobs(d) (d)
+#define htobl(d) (d)
+#define btohs(d) (d)
+#define btohl(d) (d)
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#define htobs(d) bswap_16(d)
+#define htobl(d) bswap_32(d)
+#define btohs(d) bswap_16(d)
+#define btohl(d) bswap_32(d)
+#else
+#error "Unknown byte order"
+#endif
+#define bt_get_unaligned(ptr) ({ struct __attribute__((packed)) { typeof(*(ptr)) __v; } *__p = (void *) (ptr); __p->__v; })
+#define bt_put_unaligned(val, ptr) do { struct __attribute__((packed)) { typeof(*(ptr)) __v; } *__p = (void *) (ptr); __p->__v = (val); } while(0)
+#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
+#define BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
+#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
+#ifdef __cplusplus
+#endif
+typedef struct {
+ uint8_t b[6];
+} __attribute__((packed)) bdaddr_t;
+static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
+{
+ memcpy(dst, src, sizeof(bdaddr_t));
+}
+#endif
diff --git a/sd/source/ui/remotecontrol/bluetooth/rfcomm.h b/sd/source/ui/remotecontrol/bluetooth/rfcomm.h
new file mode 100644
index 0000000..bfa304f
--- /dev/null
+++ b/sd/source/ui/remotecontrol/bluetooth/rfcomm.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Bluez header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to Android. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __RFCOMM_H
+#define __RFCOMM_H
+
+#ifdef __cplusplus
+#endif
+#include <sys/socket.h>
+#define RFCOMM_DEFAULT_MTU 127
+#define RFCOMM_PSM 3
+#define RFCOMM_CONN_TIMEOUT (HZ * 30)
+#define RFCOMM_DISC_TIMEOUT (HZ * 20)
+#define RFCOMM_CONNINFO 0x02
+#define RFCOMM_LM 0x03
+#define RFCOMM_LM_MASTER 0x0001
+#define RFCOMM_LM_AUTH 0x0002
+#define RFCOMM_LM_ENCRYPT 0x0004
+#define RFCOMM_LM_TRUSTED 0x0008
+#define RFCOMM_LM_RELIABLE 0x0010
+#define RFCOMM_LM_SECURE 0x0020
+#define RFCOMM_MAX_DEV 256
+#define RFCOMMCREATEDEV _IOW('R', 200, int)
+#define RFCOMMRELEASEDEV _IOW('R', 201, int)
+#define RFCOMMGETDEVLIST _IOR('R', 210, int)
+#define RFCOMMGETDEVINFO _IOR('R', 211, int)
+#define RFCOMM_REUSE_DLC 0
+#define RFCOMM_RELEASE_ONHUP 1
+#define RFCOMM_HANGUP_NOW 2
+#define RFCOMM_TTY_ATTACHED 3
+#ifdef __cplusplus
+#endif
+struct sockaddr_rc {
+ sa_family_t rc_family;
+ bdaddr_t rc_bdaddr;
+ uint8_t rc_channel;
+};
+#endif
More information about the Libreoffice-commits
mailing list