Skip to content

Commit

Permalink
obexd: const obex_service_driver instances and API
Browse files Browse the repository at this point in the history
  • Loading branch information
evelikov-work authored and Vudentz committed Jan 19, 2024
1 parent 0c3c674 commit ae8f9c9
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion obexd/client/mns.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ static ssize_t event_report_write(void *obj, const void *buf, size_t count)
return count;
}

static struct obex_service_driver mns = {
static const struct obex_service_driver mns = {
.name = "Message Notification server",
.service = OBEX_MNS,
.target = MNS_TARGET,
Expand Down
4 changes: 2 additions & 2 deletions obexd/plugins/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

struct bluetooth_profile {
struct obex_server *server;
struct obex_service_driver *driver;
const struct obex_service_driver *driver;
char *uuid;
char *path;
};
Expand Down Expand Up @@ -355,7 +355,7 @@ static void *bluetooth_start(struct obex_server *server, int *err)
const GSList *l;

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;
const char *uuid;

Expand Down
2 changes: 1 addition & 1 deletion obexd/plugins/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static void ftp_reset(struct obex_session *os, void *user_data)
manager_emit_transfer_completed(ftp->transfer);
}

static struct obex_service_driver ftp = {
static const struct obex_service_driver ftp = {
.name = "File Transfer server",
.service = OBEX_FTP,
.target = FTP_TARGET,
Expand Down
2 changes: 1 addition & 1 deletion obexd/plugins/irmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ static const struct obex_mime_type_driver irmc_driver = {
.read = irmc_read,
};

static struct obex_service_driver irmc = {
static const struct obex_service_driver irmc = {
.name = "IRMC Sync server",
.service = OBEX_IRMC,
.target = IRMC_TARGET,
Expand Down
2 changes: 1 addition & 1 deletion obexd/plugins/mas.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ static void *notification_registration_open(const char *name, int oflag,
return mas;
}

static struct obex_service_driver mas = {
static const struct obex_service_driver mas = {
.name = "Message Access server",
.service = OBEX_MAS,
.target = MAS_TARGET,
Expand Down
2 changes: 1 addition & 1 deletion obexd/plugins/opp.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static void opp_reset(struct obex_session *os, void *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",
.service = OBEX_OPP,
.connect = opp_connect,
Expand Down
2 changes: 1 addition & 1 deletion obexd/plugins/pbap.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ static int pbap_chkput(struct obex_session *os, void *user_data)
return -EBADR;
}

static struct obex_service_driver pbap = {
static const struct obex_service_driver pbap = {
.name = "Phonebook Access server",
.service = OBEX_PBAP,
.target = PBAP_TARGET,
Expand Down
2 changes: 1 addition & 1 deletion obexd/plugins/pcsuite.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void pcsuite_disconnect(struct obex_session *os, void *user_data)
g_free(pcsuite);
}

static struct obex_service_driver pcsuite = {
static const struct obex_service_driver pcsuite = {
.name = "Nokia OBEX PC Suite Services",
.service = OBEX_PCSUITE,
.channel = PCSUITE_CHANNEL,
Expand Down
2 changes: 1 addition & 1 deletion obexd/plugins/syncevolution.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ static const struct obex_mime_type_driver synce_driver = {
.write = synce_write,
};

static struct obex_service_driver synce = {
static const struct obex_service_driver synce = {
.name = "OBEX server for SyncML, using SyncEvolution",
.service = OBEX_SYNCEVOLUTION,
.channel = SYNCEVOLUTION_CHANNEL,
Expand Down
2 changes: 1 addition & 1 deletion obexd/src/obex-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct obex_session {
void *object;
gboolean aborted;
int err;
struct obex_service_driver *service;
const struct obex_service_driver *service;
void *service_data;
struct obex_server *server;
gboolean checked;
Expand Down
2 changes: 1 addition & 1 deletion obexd/src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int obex_server_init(void)
}

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);
}
Expand Down
20 changes: 10 additions & 10 deletions obexd/src/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@

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 *who, unsigned int who_size)
{
GSList *l;

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 */
if (who != NULL && memncmp0(who, who_size, driver->who,
Expand All @@ -57,23 +57,23 @@ GSList *obex_service_driver_list(uint16_t services)
return drivers;

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) {
list = g_slist_append(list, driver);
list = g_slist_append(list, (gpointer)driver);
services &= ~driver->service;
}
}

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;

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)
return driver;
Expand All @@ -82,7 +82,7 @@ static struct obex_service_driver *find_driver(uint16_t service)
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) {
error("Invalid driver");
Expand All @@ -99,14 +99,14 @@ int obex_service_driver_register(struct obex_service_driver *driver)

/* Drivers that support who has priority */
if (driver->who)
drivers = g_slist_prepend(drivers, driver);
drivers = g_slist_prepend(drivers, (gpointer)driver);
else
drivers = g_slist_append(drivers, driver);
drivers = g_slist_append(drivers, (gpointer)driver);

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)) {
error("Unable to unregister: No such driver %p", driver);
Expand Down
6 changes: 3 additions & 3 deletions obexd/src/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ struct obex_service_driver {
void (*reset) (struct obex_session *os, void *user_data);
};

int obex_service_driver_register(struct obex_service_driver *driver);
void obex_service_driver_unregister(struct obex_service_driver *driver);
int obex_service_driver_register(const struct obex_service_driver *driver);
void obex_service_driver_unregister(const struct obex_service_driver *driver);
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 *who, unsigned int who_size);

0 comments on commit ae8f9c9

Please sign in to comment.