* [PATCH 1/3] Simplify options for including/excluding plugins
@ 2011-05-25 15:39 Luiz Augusto von Dentz
2011-05-25 15:39 ` [PATCH 2/3] Remove unused obex.conf Luiz Augusto von Dentz
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2011-05-25 15:39 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
Plugins options are now handle with --plugin(-p)/--noplugin(-P) which
takes a string set containing the plugin names separated by ',',':' or
' 'similar to bluetoothd, ofono and connman.
---
src/main.c | 68 +++++++++++++++------------------------------------------
src/obexd.h | 2 +-
src/plugin.c | 51 +++++++++++++++++++++++++++++++++++++++++-
3 files changed, 68 insertions(+), 53 deletions(-)
diff --git a/src/main.c b/src/main.c
index 8154e3b..e1ce442 100644
--- a/src/main.c
+++ b/src/main.c
@@ -75,16 +75,11 @@ static char *option_debug = NULL;
static char *option_root = NULL;
static char *option_root_setup = NULL;
static char *option_capability = NULL;
+static char *option_plugin = NULL;
+static char *option_noplugin = NULL;
static gboolean option_autoaccept = FALSE;
-static gboolean option_opp = FALSE;
-static gboolean option_ftp = FALSE;
-static gboolean option_pbap = FALSE;
-static gboolean option_irmc = FALSE;
-static gboolean option_pcsuite = FALSE;
static gboolean option_symlinks = FALSE;
-static gboolean option_syncevolution = FALSE;
-static gboolean option_mas = FALSE;
static gboolean parse_debug(const char *key, const char *value,
gpointer user_data, GError **error)
@@ -114,20 +109,10 @@ static GOptionEntry options[] = {
"Specify capability file", "FILE" },
{ "auto-accept", 'a', 0, G_OPTION_ARG_NONE, &option_autoaccept,
"Automatically accept push requests" },
- { "opp", 'o', 0, G_OPTION_ARG_NONE, &option_opp,
- "Enable Object Push server" },
- { "ftp", 'f', 0, G_OPTION_ARG_NONE, &option_ftp,
- "Enable File Transfer server" },
- { "pbap", 'p', 0, G_OPTION_ARG_NONE, &option_pbap,
- "Enable Phonebook Access server" },
- { "irmc", 'i', 0, G_OPTION_ARG_NONE, &option_irmc,
- "Enable IrMC Sync server" },
- { "pcsuite", 's', 0, G_OPTION_ARG_NONE, &option_pcsuite,
- "Enable PC Suite Services server" },
- { "syncevolution", 'e', 0, G_OPTION_ARG_NONE, &option_syncevolution,
- "Enable OBEX server for SyncEvolution" },
- { "mas", 'm', 0, G_OPTION_ARG_NONE, &option_mas,
- "Enable Message Access server" },
+ { "plugin", 'p', 0, G_OPTION_ARG_STRING, &option_plugin,
+ "Specify plugins to load", "NAME,..." },
+ { "noplugin", 'P', 0, G_OPTION_ARG_STRING, &option_noplugin,
+ "Specify plugins not to load", "NAME,..." },
{ NULL },
};
@@ -212,16 +197,6 @@ int main(int argc, char *argv[])
}
}
- if (option_opp == FALSE && option_ftp == FALSE &&
- option_pbap == FALSE &&
- option_irmc == FALSE &&
- option_syncevolution == FALSE &&
- option_mas == FALSE) {
- fprintf(stderr, "No server selected (use either "
- "--opp, --ftp, --pbap, --irmc, --mas, or --syncevolution)\n");
- exit(EXIT_FAILURE);
- }
-
__obex_log_init("obexd", option_debug, option_detach);
DBG("Entering main loop");
@@ -251,39 +226,32 @@ int main(int argc, char *argv[])
}
}
- plugin_init();
-
if (option_capability == NULL)
option_capability = g_strdup(DEFAULT_CAP_FILE);
- if (option_opp == TRUE)
- obex_server_init(OBEX_OPP, option_root, FALSE,
+ plugin_init(option_plugin, option_noplugin);
+
+ obex_server_init(OBEX_OPP, option_root, FALSE,
option_autoaccept, option_symlinks,
NULL);
- if (option_ftp == TRUE)
- obex_server_init(OBEX_FTP, option_root, TRUE,
+ obex_server_init(OBEX_FTP, option_root, TRUE,
option_autoaccept, option_symlinks,
option_capability);
- if (option_pbap == TRUE)
- obex_server_init(OBEX_PBAP, NULL, TRUE, FALSE, FALSE, NULL);
-
- if (option_pcsuite == TRUE)
- obex_server_init(OBEX_PCSUITE, option_root, TRUE,
+ obex_server_init(OBEX_PCSUITE, option_root, TRUE,
option_autoaccept, option_symlinks,
option_capability);
- if (option_irmc == TRUE)
- obex_server_init(OBEX_IRMC, NULL, TRUE, FALSE, FALSE,
- option_capability);
+ obex_server_init(OBEX_PBAP, NULL, TRUE, FALSE, FALSE,
+ option_capability);
+
+ obex_server_init(OBEX_IRMC, NULL, TRUE, FALSE, FALSE,
+ option_capability);
- if (option_syncevolution == TRUE)
- obex_server_init(OBEX_SYNCEVOLUTION, NULL, TRUE, FALSE,
- FALSE, NULL);
+ obex_server_init(OBEX_SYNCEVOLUTION, NULL, TRUE, FALSE, FALSE, NULL);
- if (option_mas == TRUE)
- obex_server_init(OBEX_MAS, NULL, TRUE, FALSE, FALSE, NULL);
+ obex_server_init(OBEX_MAS, NULL, TRUE, FALSE, FALSE, NULL);
if (!root_folder_setup(option_root, option_root_setup)) {
error("Unable to setup root folder %s", option_root);
diff --git a/src/obexd.h b/src/obexd.h
index df21f00..37106b7 100644
--- a/src/obexd.h
+++ b/src/obexd.h
@@ -21,7 +21,7 @@
*
*/
-gboolean plugin_init(void);
+gboolean plugin_init(const char *pattern, const char *exclude);
void plugin_cleanup(void);
gboolean manager_init(void);
diff --git a/src/plugin.c b/src/plugin.c
index 14a569f..c8ec642 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -79,10 +79,39 @@ static gboolean add_plugin(void *handle, struct obex_plugin_desc *desc)
return TRUE;
}
+static gboolean check_plugin(struct obex_plugin_desc *desc,
+ char **patterns, char **excludes)
+{
+ if (excludes) {
+ for (; *excludes; excludes++)
+ if (g_pattern_match_simple(*excludes, desc->name))
+ break;
+ if (*excludes) {
+ info("Excluding %s", desc->name);
+ return FALSE;
+ }
+ }
+
+ if (patterns) {
+ for (; *patterns; patterns++)
+ if (g_pattern_match_simple(*patterns, desc->name))
+ break;
+ if (*patterns == NULL) {
+ info("Ignoring %s", desc->name);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+
#include "builtin.h"
-gboolean plugin_init(void)
+gboolean plugin_init(const char *pattern, const char *exclude)
{
+ gchar **patterns = NULL;
+ gchar **excludes = NULL;
GDir *dir;
const char *file;
unsigned int i;
@@ -90,10 +119,21 @@ gboolean plugin_init(void)
if (strlen(PLUGINDIR) == 0)
return FALSE;
+ if (pattern)
+ patterns = g_strsplit_set(pattern, ":, ", -1);
+
+ if (exclude)
+ excludes = g_strsplit_set(exclude, ":, ", -1);
+
DBG("Loading builtin plugins");
- for (i = 0; __obex_builtin[i]; i++)
+ for (i = 0; __obex_builtin[i]; i++) {
+ if (check_plugin(__obex_builtin[i],
+ patterns, excludes) == FALSE)
+ continue;
+
add_plugin(NULL, __obex_builtin[i]);
+ }
DBG("Loading plugins %s", PLUGINDIR);
@@ -129,11 +169,18 @@ gboolean plugin_init(void)
continue;
}
+ if (check_plugin(desc, patterns, excludes) == FALSE) {
+ dlclose(handle);
+ continue;
+ }
+
if (add_plugin(handle, desc) == FALSE)
dlclose(handle);
}
g_dir_close(dir);
+ g_strfreev(patterns);
+ g_strfreev(excludes);
return TRUE;
}
--
1.7.5.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] Remove unused obex.conf
2011-05-25 15:39 [PATCH 1/3] Simplify options for including/excluding plugins Luiz Augusto von Dentz
@ 2011-05-25 15:39 ` Luiz Augusto von Dentz
2011-05-25 15:40 ` [PATCH 3/3] Improve usage documentation for some options Luiz Augusto von Dentz
2011-05-29 18:25 ` [PATCH 1/3] Simplify options for including/excluding plugins Johan Hedberg
2 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2011-05-25 15:39 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
obexd currently does not support configuration files.
---
Makefile.am | 2 +-
src/obex.conf | 20 --------------------
2 files changed, 1 insertions(+), 21 deletions(-)
delete mode 100644 src/obex.conf
diff --git a/Makefile.am b/Makefile.am
index 8d8fdc6..0be6c33 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -138,7 +138,7 @@ INCLUDES = -I$(builddir)/src -I$(srcdir)/src -I$(srcdir)/plugins \
CLEANFILES = $(service_DATA) $(builtin_files)
-EXTRA_DIST = src/genbuiltin $(doc_files) $(test_files) src/obex.conf \
+EXTRA_DIST = src/genbuiltin $(doc_files) $(test_files) \
src/obexd.service.in client/obex-client.service.in \
plugins/phonebook-dummy.c plugins/phonebook-ebook.c \
plugins/phonebook-tracker.c \
diff --git a/src/obex.conf b/src/obex.conf
deleted file mode 100644
index 12f88b6..0000000
--- a/src/obex.conf
+++ /dev/null
@@ -1,20 +0,0 @@
-# Configuration file for the OBEX Daemon
-[General]
-
-EnabledTransports=Bluetooth
-
-[Bluetooth]
-Enable=OPUSH
-
-# Object Push Server options
-[OPUSH]
-name=OBEX Object Push Server
-channel=9
-folder=/tmp
-auto_accept=true
-
-# FTP Server options
-# [FTP]
-# name=OBEX FTP Server
-# channel=10
-# folder=/tmp
--
1.7.5.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] Improve usage documentation for some options
2011-05-25 15:39 [PATCH 1/3] Simplify options for including/excluding plugins Luiz Augusto von Dentz
2011-05-25 15:39 ` [PATCH 2/3] Remove unused obex.conf Luiz Augusto von Dentz
@ 2011-05-25 15:40 ` Luiz Augusto von Dentz
2011-05-25 17:17 ` Anderson Lizardo
2011-05-29 18:25 ` [PATCH 1/3] Simplify options for including/excluding plugins Johan Hedberg
2 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2011-05-25 15:40 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
src/main.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/main.c b/src/main.c
index e1ce442..5b30f07 100644
--- a/src/main.c
+++ b/src/main.c
@@ -100,13 +100,17 @@ static GOptionEntry options[] = {
G_OPTION_ARG_CALLBACK, parse_debug,
"Enable debug information output", "DEBUG" },
{ "root", 'r', 0, G_OPTION_ARG_STRING, &option_root,
- "Specify root folder location", "PATH" },
+ "Specify root folder location. Both absolute"
+ "and relative can be use, but relative paths"
+ "are assume to be relative to user $HOME"
+ "folder", "PATH" },
{ "root-setup", 'S', 0, G_OPTION_ARG_STRING, &option_root_setup,
"Root folder setup script", "SCRIPT" },
{ "symlinks", 'l', 0, G_OPTION_ARG_NONE, &option_symlinks,
"Enable symlinks on root folder" },
{ "capability", 'c', 0, G_OPTION_ARG_STRING, &option_capability,
- "Specify capability file", "FILE" },
+ "Specify capability file, use '!' mark for"
+ "scripts", "FILE" },
{ "auto-accept", 'a', 0, G_OPTION_ARG_NONE, &option_autoaccept,
"Automatically accept push requests" },
{ "plugin", 'p', 0, G_OPTION_ARG_STRING, &option_plugin,
--
1.7.5.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] Improve usage documentation for some options
2011-05-25 15:40 ` [PATCH 3/3] Improve usage documentation for some options Luiz Augusto von Dentz
@ 2011-05-25 17:17 ` Anderson Lizardo
2011-05-25 19:45 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 6+ messages in thread
From: Anderson Lizardo @ 2011-05-25 17:17 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Wed, May 25, 2011 at 11:40 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> ---
> src/main.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/main.c b/src/main.c
> index e1ce442..5b30f07 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -100,13 +100,17 @@ static GOptionEntry options[] = {
> G_OPTION_ARG_CALLBACK, parse_debug,
> "Enable debug information output", "DEBUG" },
> { "root", 'r', 0, G_OPTION_ARG_STRING, &option_root,
> - "Specify root folder location", "PATH" },
> + "Specify root folder location. Both absolute"
> + "and relative can be use, but relative paths"
> + "are assume to be relative to user $HOME"
> + "folder", "PATH" },
IIRC, you should add the spaces to the string if you want them on the
printed string, otherwise you will see:
absoluteand
pathsare
etc.
> { "root-setup", 'S', 0, G_OPTION_ARG_STRING, &option_root_setup,
> "Root folder setup script", "SCRIPT" },
> { "symlinks", 'l', 0, G_OPTION_ARG_NONE, &option_symlinks,
> "Enable symlinks on root folder" },
> { "capability", 'c', 0, G_OPTION_ARG_STRING, &option_capability,
> - "Specify capability file", "FILE" },
> + "Specify capability file, use '!' mark for"
> + "scripts", "FILE" },
Same here.
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] Improve usage documentation for some options
2011-05-25 17:17 ` Anderson Lizardo
@ 2011-05-25 19:45 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2011-05-25 19:45 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
Hi,
On Wed, May 25, 2011 at 8:17 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> Hi Luiz,
>
> On Wed, May 25, 2011 at 11:40 AM, Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> ---
>> src/main.c | 8 ++++++--
>> 1 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/main.c b/src/main.c
>> index e1ce442..5b30f07 100644
>> --- a/src/main.c
>> +++ b/src/main.c
>> @@ -100,13 +100,17 @@ static GOptionEntry options[] = {
>> G_OPTION_ARG_CALLBACK, parse_debug,
>> "Enable debug information output", "DEBUG" },
>> { "root", 'r', 0, G_OPTION_ARG_STRING, &option_root,
>> - "Specify root folder location", "PATH" },
>> + "Specify root folder location. Both absolute"
>> + "and relative can be use, but relative paths"
>> + "are assume to be relative to user $HOME"
>> + "folder", "PATH" },
>
> IIRC, you should add the spaces to the string if you want them on the
> printed string, otherwise you will see:
>
> absoluteand
> pathsare
> etc.
It sure does need the extra spaces, gonna fix them, thanks.
>> { "root-setup", 'S', 0, G_OPTION_ARG_STRING, &option_root_setup,
>> "Root folder setup script", "SCRIPT" },
>> { "symlinks", 'l', 0, G_OPTION_ARG_NONE, &option_symlinks,
>> "Enable symlinks on root folder" },
>> { "capability", 'c', 0, G_OPTION_ARG_STRING, &option_capability,
>> - "Specify capability file", "FILE" },
>> + "Specify capability file, use '!' mark for"
>> + "scripts", "FILE" },
>
> Same here.
>
> Regards,
> --
> Anderson Lizardo
> Instituto Nokia de Tecnologia - INdT
> Manaus - Brazil
>
--
Luiz Augusto von Dentz
Computer Engineer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] Simplify options for including/excluding plugins
2011-05-25 15:39 [PATCH 1/3] Simplify options for including/excluding plugins Luiz Augusto von Dentz
2011-05-25 15:39 ` [PATCH 2/3] Remove unused obex.conf Luiz Augusto von Dentz
2011-05-25 15:40 ` [PATCH 3/3] Improve usage documentation for some options Luiz Augusto von Dentz
@ 2011-05-29 18:25 ` Johan Hedberg
2 siblings, 0 replies; 6+ messages in thread
From: Johan Hedberg @ 2011-05-29 18:25 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Wed, May 25, 2011, Luiz Augusto von Dentz wrote:
> Plugins options are now handle with --plugin(-p)/--noplugin(-P) which
> takes a string set containing the plugin names separated by ',',':' or
> ' 'similar to bluetoothd, ofono and connman.
> ---
> src/main.c | 68 +++++++++++++++------------------------------------------
> src/obexd.h | 2 +-
> src/plugin.c | 51 +++++++++++++++++++++++++++++++++++++++++-
> 3 files changed, 68 insertions(+), 53 deletions(-)
All three patches have been pushed. Thanks.
Johan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-05-29 18:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-25 15:39 [PATCH 1/3] Simplify options for including/excluding plugins Luiz Augusto von Dentz
2011-05-25 15:39 ` [PATCH 2/3] Remove unused obex.conf Luiz Augusto von Dentz
2011-05-25 15:40 ` [PATCH 3/3] Improve usage documentation for some options Luiz Augusto von Dentz
2011-05-25 17:17 ` Anderson Lizardo
2011-05-25 19:45 ` Luiz Augusto von Dentz
2011-05-29 18:25 ` [PATCH 1/3] Simplify options for including/excluding plugins Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox