static gboolean conf_security = TRUE;
+struct connect_req {
+ struct btd_device *device;
+ struct btd_profile *profile;
+ btd_profile_cb cb;
+};
+
static void read_config(const char *file)
{
GKeyFile *keyfile;
conf_security ? "true" : "false");
}
+static void connect_profile_cb(struct btd_device *device, int err,
+ const char *pdev, void *data)
+{
+ struct connect_req *req = data;
+
+ req->cb(req->profile, req->device, err);
+
+ g_free(req);
+}
+
+static int connect_profile(struct btd_device *dev, struct btd_profile *profile,
+ uint16_t id, btd_profile_cb cb)
+{
+ struct connect_req *req;
+ int err;
+
+ DBG("path %s id %u", device_get_path(dev), id);
+
+ req = g_new0(struct connect_req, 1);
+ req->device = dev;
+ req->profile = profile;
+ req->cb = cb;
+
+ err = connection_connect(dev, BNEP_SVC_PANU, NULL, connect_profile_cb,
+ req);
+ if (err < 0) {
+ g_free(req);
+ return err;
+ }
+
+ return 0;
+}
+
+static int disconnect_profile(struct btd_device *dev,
+ struct btd_profile *profile,
+ uint16_t id, btd_profile_cb cb)
+{
+ int err;
+
+ DBG("path %s id %u", device_get_path(dev), id);
+
+ err = connection_disconnect(dev, id, NULL);
+ if (err < 0)
+ return err;
+
+ if (cb)
+ cb(profile, dev, 0);
+
+ return 0;
+}
+
static int panu_probe(struct btd_profile *p, struct btd_device *device,
GSList *uuids)
{
connection_unregister(device);
}
+static int panu_connect(struct btd_device *dev, struct btd_profile *profile,
+ btd_profile_cb cb)
+{
+ return connect_profile(dev, profile, BNEP_SVC_PANU, cb);
+}
+
+static int panu_disconnect(struct btd_device *dev, struct btd_profile *profile,
+ btd_profile_cb cb)
+{
+ return disconnect_profile(dev, profile, BNEP_SVC_PANU, cb);
+}
+
static int panu_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
{
const gchar *path = adapter_get_path(adapter);
return connection_register(device, BNEP_SVC_GN);
}
+static int gn_connect(struct btd_device *dev, struct btd_profile *profile,
+ btd_profile_cb cb)
+{
+ return connect_profile(dev, profile, BNEP_SVC_GN, cb);
+}
+
+static int gn_disconnect(struct btd_device *dev, struct btd_profile *profile,
+ btd_profile_cb cb)
+{
+ return disconnect_profile(dev, profile, BNEP_SVC_GN, cb);
+}
+
static int gn_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
{
const gchar *path = adapter_get_path(adapter);
return connection_register(device, BNEP_SVC_NAP);
}
+static int nap_connect(struct btd_device *dev, struct btd_profile *profile,
+ btd_profile_cb cb)
+{
+ return connect_profile(dev, profile, BNEP_SVC_NAP, cb);
+}
+
+static int nap_disconnect(struct btd_device *dev, struct btd_profile *profile,
+ btd_profile_cb cb)
+{
+ return disconnect_profile(dev, profile, BNEP_SVC_NAP, cb);
+}
+
static int nap_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
{
const gchar *path = adapter_get_path(adapter);
.remote_uuids = BTD_UUIDS(PANU_UUID),
.device_probe = panu_probe,
.device_remove = network_remove,
+ .connect = panu_connect,
+ .disconnect = panu_disconnect,
.adapter_probe = panu_server_probe,
.adapter_remove = panu_server_remove,
};
.remote_uuids = BTD_UUIDS(GN_UUID),
.device_probe = gn_probe,
.device_remove = network_remove,
+ .connect = gn_connect,
+ .disconnect = gn_disconnect,
.adapter_probe = gn_server_probe,
.adapter_remove = gn_server_remove,
};
.remote_uuids = BTD_UUIDS(NAP_UUID),
.device_probe = nap_probe,
.device_remove = network_remove,
+ .connect = nap_connect,
+ .disconnect = nap_disconnect,
.adapter_probe = nap_server_probe,
.adapter_remove = nap_server_remove,
};