mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-15 16:24:28 +08:00
obexd: const obex_service_driver instances and API
This commit is contained in:
parent
0c3c674033
commit
ae8f9c9560
@ -346,7 +346,7 @@ static ssize_t event_report_write(void *obj, const void *buf, size_t count)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct obex_service_driver mns = {
|
static const struct obex_service_driver mns = {
|
||||||
.name = "Message Notification server",
|
.name = "Message Notification server",
|
||||||
.service = OBEX_MNS,
|
.service = OBEX_MNS,
|
||||||
.target = MNS_TARGET,
|
.target = MNS_TARGET,
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
struct bluetooth_profile {
|
struct bluetooth_profile {
|
||||||
struct obex_server *server;
|
struct obex_server *server;
|
||||||
struct obex_service_driver *driver;
|
const struct obex_service_driver *driver;
|
||||||
char *uuid;
|
char *uuid;
|
||||||
char *path;
|
char *path;
|
||||||
};
|
};
|
||||||
@ -355,7 +355,7 @@ static void *bluetooth_start(struct obex_server *server, int *err)
|
|||||||
const GSList *l;
|
const GSList *l;
|
||||||
|
|
||||||
for (l = server->drivers; l; l = l->next) {
|
for (l = server->drivers; l; l = l->next) {
|
||||||
struct obex_service_driver *driver = l->data;
|
const struct obex_service_driver *driver = l->data;
|
||||||
struct bluetooth_profile *profile;
|
struct bluetooth_profile *profile;
|
||||||
const char *uuid;
|
const char *uuid;
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ static void ftp_reset(struct obex_session *os, void *user_data)
|
|||||||
manager_emit_transfer_completed(ftp->transfer);
|
manager_emit_transfer_completed(ftp->transfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct obex_service_driver ftp = {
|
static const struct obex_service_driver ftp = {
|
||||||
.name = "File Transfer server",
|
.name = "File Transfer server",
|
||||||
.service = OBEX_FTP,
|
.service = OBEX_FTP,
|
||||||
.target = FTP_TARGET,
|
.target = FTP_TARGET,
|
||||||
|
@ -427,7 +427,7 @@ static const struct obex_mime_type_driver irmc_driver = {
|
|||||||
.read = irmc_read,
|
.read = irmc_read,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct obex_service_driver irmc = {
|
static const struct obex_service_driver irmc = {
|
||||||
.name = "IRMC Sync server",
|
.name = "IRMC Sync server",
|
||||||
.service = OBEX_IRMC,
|
.service = OBEX_IRMC,
|
||||||
.target = IRMC_TARGET,
|
.target = IRMC_TARGET,
|
||||||
|
@ -781,7 +781,7 @@ static void *notification_registration_open(const char *name, int oflag,
|
|||||||
return mas;
|
return mas;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct obex_service_driver mas = {
|
static const struct obex_service_driver mas = {
|
||||||
.name = "Message Access server",
|
.name = "Message Access server",
|
||||||
.service = OBEX_MAS,
|
.service = OBEX_MAS,
|
||||||
.target = MAS_TARGET,
|
.target = MAS_TARGET,
|
||||||
|
@ -155,7 +155,7 @@ static void opp_reset(struct obex_session *os, void *user_data)
|
|||||||
manager_emit_transfer_completed(user_data);
|
manager_emit_transfer_completed(user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct obex_service_driver driver = {
|
static const struct obex_service_driver driver = {
|
||||||
.name = "Object Push server",
|
.name = "Object Push server",
|
||||||
.service = OBEX_OPP,
|
.service = OBEX_OPP,
|
||||||
.connect = opp_connect,
|
.connect = opp_connect,
|
||||||
|
@ -634,7 +634,7 @@ static int pbap_chkput(struct obex_session *os, void *user_data)
|
|||||||
return -EBADR;
|
return -EBADR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct obex_service_driver pbap = {
|
static const struct obex_service_driver pbap = {
|
||||||
.name = "Phonebook Access server",
|
.name = "Phonebook Access server",
|
||||||
.service = OBEX_PBAP,
|
.service = OBEX_PBAP,
|
||||||
.target = PBAP_TARGET,
|
.target = PBAP_TARGET,
|
||||||
|
@ -231,7 +231,7 @@ static void pcsuite_disconnect(struct obex_session *os, void *user_data)
|
|||||||
g_free(pcsuite);
|
g_free(pcsuite);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct obex_service_driver pcsuite = {
|
static const struct obex_service_driver pcsuite = {
|
||||||
.name = "Nokia OBEX PC Suite Services",
|
.name = "Nokia OBEX PC Suite Services",
|
||||||
.service = OBEX_PCSUITE,
|
.service = OBEX_PCSUITE,
|
||||||
.channel = PCSUITE_CHANNEL,
|
.channel = PCSUITE_CHANNEL,
|
||||||
|
@ -436,7 +436,7 @@ static const struct obex_mime_type_driver synce_driver = {
|
|||||||
.write = synce_write,
|
.write = synce_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct obex_service_driver synce = {
|
static const struct obex_service_driver synce = {
|
||||||
.name = "OBEX server for SyncML, using SyncEvolution",
|
.name = "OBEX server for SyncML, using SyncEvolution",
|
||||||
.service = OBEX_SYNCEVOLUTION,
|
.service = OBEX_SYNCEVOLUTION,
|
||||||
.channel = SYNCEVOLUTION_CHANNEL,
|
.channel = SYNCEVOLUTION_CHANNEL,
|
||||||
|
@ -33,7 +33,7 @@ struct obex_session {
|
|||||||
void *object;
|
void *object;
|
||||||
gboolean aborted;
|
gboolean aborted;
|
||||||
int err;
|
int err;
|
||||||
struct obex_service_driver *service;
|
const struct obex_service_driver *service;
|
||||||
void *service_data;
|
void *service_data;
|
||||||
struct obex_server *server;
|
struct obex_server *server;
|
||||||
gboolean checked;
|
gboolean checked;
|
||||||
|
@ -82,7 +82,7 @@ int obex_server_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (l = drivers; l; l = l->next) {
|
for (l = drivers; l; l = l->next) {
|
||||||
struct obex_service_driver *driver = l->data;
|
const struct obex_service_driver *driver = l->data;
|
||||||
|
|
||||||
init_server(driver->service, transports);
|
init_server(driver->service, transports);
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,14 @@
|
|||||||
|
|
||||||
static GSList *drivers = NULL;
|
static GSList *drivers = NULL;
|
||||||
|
|
||||||
struct obex_service_driver *obex_service_driver_find(GSList *drivers,
|
const struct obex_service_driver *obex_service_driver_find(GSList *drivers,
|
||||||
const uint8_t *target, unsigned int target_size,
|
const uint8_t *target, unsigned int target_size,
|
||||||
const uint8_t *who, unsigned int who_size)
|
const uint8_t *who, unsigned int who_size)
|
||||||
{
|
{
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
for (l = drivers; l; l = l->next) {
|
for (l = drivers; l; l = l->next) {
|
||||||
struct obex_service_driver *driver = l->data;
|
const struct obex_service_driver *driver = l->data;
|
||||||
|
|
||||||
/* who is optional, so only check for it if not NULL */
|
/* who is optional, so only check for it if not NULL */
|
||||||
if (who != NULL && memncmp0(who, who_size, driver->who,
|
if (who != NULL && memncmp0(who, who_size, driver->who,
|
||||||
@ -57,10 +57,10 @@ GSList *obex_service_driver_list(uint16_t services)
|
|||||||
return drivers;
|
return drivers;
|
||||||
|
|
||||||
for (l = drivers; l && services; l = l->next) {
|
for (l = drivers; l && services; l = l->next) {
|
||||||
struct obex_service_driver *driver = l->data;
|
const struct obex_service_driver *driver = l->data;
|
||||||
|
|
||||||
if (driver->service & services) {
|
if (driver->service & services) {
|
||||||
list = g_slist_append(list, driver);
|
list = g_slist_append(list, (gpointer)driver);
|
||||||
services &= ~driver->service;
|
services &= ~driver->service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,12 +68,12 @@ GSList *obex_service_driver_list(uint16_t services)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct obex_service_driver *find_driver(uint16_t service)
|
static const struct obex_service_driver *find_driver(uint16_t service)
|
||||||
{
|
{
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
for (l = drivers; l; l = l->next) {
|
for (l = drivers; l; l = l->next) {
|
||||||
struct obex_service_driver *driver = l->data;
|
const struct obex_service_driver *driver = l->data;
|
||||||
|
|
||||||
if (driver->service == service)
|
if (driver->service == service)
|
||||||
return driver;
|
return driver;
|
||||||
@ -82,7 +82,7 @@ static struct obex_service_driver *find_driver(uint16_t service)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int obex_service_driver_register(struct obex_service_driver *driver)
|
int obex_service_driver_register(const struct obex_service_driver *driver)
|
||||||
{
|
{
|
||||||
if (!driver) {
|
if (!driver) {
|
||||||
error("Invalid driver");
|
error("Invalid driver");
|
||||||
@ -99,14 +99,14 @@ int obex_service_driver_register(struct obex_service_driver *driver)
|
|||||||
|
|
||||||
/* Drivers that support who has priority */
|
/* Drivers that support who has priority */
|
||||||
if (driver->who)
|
if (driver->who)
|
||||||
drivers = g_slist_prepend(drivers, driver);
|
drivers = g_slist_prepend(drivers, (gpointer)driver);
|
||||||
else
|
else
|
||||||
drivers = g_slist_append(drivers, driver);
|
drivers = g_slist_append(drivers, (gpointer)driver);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void obex_service_driver_unregister(struct obex_service_driver *driver)
|
void obex_service_driver_unregister(const struct obex_service_driver *driver)
|
||||||
{
|
{
|
||||||
if (!g_slist_find(drivers, driver)) {
|
if (!g_slist_find(drivers, driver)) {
|
||||||
error("Unable to unregister: No such driver %p", driver);
|
error("Unable to unregister: No such driver %p", driver);
|
||||||
|
@ -32,9 +32,9 @@ struct obex_service_driver {
|
|||||||
void (*reset) (struct obex_session *os, void *user_data);
|
void (*reset) (struct obex_session *os, void *user_data);
|
||||||
};
|
};
|
||||||
|
|
||||||
int obex_service_driver_register(struct obex_service_driver *driver);
|
int obex_service_driver_register(const struct obex_service_driver *driver);
|
||||||
void obex_service_driver_unregister(struct obex_service_driver *driver);
|
void obex_service_driver_unregister(const struct obex_service_driver *driver);
|
||||||
GSList *obex_service_driver_list(uint16_t services);
|
GSList *obex_service_driver_list(uint16_t services);
|
||||||
struct obex_service_driver *obex_service_driver_find(GSList *drivers,
|
const struct obex_service_driver *obex_service_driver_find(GSList *drivers,
|
||||||
const uint8_t *target, unsigned int target_size,
|
const uint8_t *target, unsigned int target_size,
|
||||||
const uint8_t *who, unsigned int who_size);
|
const uint8_t *who, unsigned int who_size);
|
||||||
|
Loading…
Reference in New Issue
Block a user