Skip to content

Commit

Permalink
gconf made optional for the configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
philippedeswert committed Sep 11, 2011
1 parent 2f68a5d commit 36aed12
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 12 deletions.
14 changes: 11 additions & 3 deletions configure.ac
@@ -1,4 +1,4 @@
AC_INIT([usb_moded], [0.46])
AC_INIT([usb_moded], [0.47])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

AM_CONFIG_HEADER([config.h])
Expand Down Expand Up @@ -68,6 +68,14 @@ AC_ARG_ENABLE([bme], AS_HELP_STRING([--enable-bme], [Enable Nokia bme cable conn
esac],[bme=false])
AM_CONDITIONAL([BME], [test x$bme = xtrue])

AC_ARG_ENABLE([gconf], AS_HELP_STRING([--enable-gconf], [Use GConf for configuration storage @<:@default=false@:>@]),
[case "${enableval}" in
yes) gconf=true ; CFLAGS="-DGCONF -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -lgconf-2 $CFLAGS" ;;
no) conf=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-gconf]) ;;
esac],[gconf=false])
AM_CONDITIONAL([GCONF], [test x$gconf = xtrue])

AC_ARG_ENABLE([app_sync], AS_HELP_STRING([--enable-app-sync], [Enable application syncing @<:@default=false@:>@]),
[case "${enableval}" in
yes) app_sync=true ; CFLAGS="-DAPP_SYNC $CFLAGS" ;;
Expand All @@ -93,13 +101,13 @@ AC_ARG_ENABLE([udev], AS_HELP_STRING([--enable-udev], [Enable udev interface @<:
AM_CONDITIONAL([UDEV], [test x$udev = xtrue])



#TODO: Figure out how to check for this depending on the gconf flag
# gconf-2.0 >= 2.16.0
PKG_CHECK_MODULES([USB_MODED], [
glib-2.0 >= 2.24.0
dbus-1 >= 1.2.1
dbus-glib-1 >= 0.78
gobject-2.0 >= 2.16.6
gconf-2.0 >= 2.16.0
gio-2.0
])

Expand Down
7 changes: 7 additions & 0 deletions debian/changelog
@@ -1,3 +1,10 @@
usb-moded (0.47) unstable; urgency=low

* Make it possible to use the ini file for the mode setting also. This removes
the gconf dependency.

-- Philippe De Swert <philippe.de-swert@nokia.com> Sat, 10 Sep 2011 23:54:22 +0300

usb-moded (0.46) unstable; urgency=low

* Restart usb trigger if the socket gets destroyed. Fixes: NB#277395
Expand Down
2 changes: 1 addition & 1 deletion debian/rules
Expand Up @@ -23,7 +23,7 @@ configure-stamp:
dh_testdir
# Add here commands to configure the package.
if [ ! -x configure ]; then ./autogen.sh; fi
./configure --prefix=/usr --enable-nokia --enable-app-sync --enable-udev
./configure --prefix=/usr --enable-nokia --enable-app-sync --enable-udev --enable-gconf

touch configure-stamp

Expand Down
11 changes: 8 additions & 3 deletions src/Makefile.am
Expand Up @@ -16,10 +16,8 @@ usb_moded_SOURCES = \
usb_moded-dbus.c \
usb_moded-dbus.h \
usb_moded-dbus-private.h \
usb_moded-gconf.c \
usb_moded-gconf.h \
usb_moded-gconf-private.h \
usb_moded-hw-ab.h \
usb_moded-config-private.h \
usb_moded-modules.c \
usb_moded-modules.h \
usb_moded-log.h \
Expand All @@ -28,6 +26,13 @@ usb_moded_SOURCES = \
usb_moded-config.h \
usb_moded-modesetting.c \
usb_moded-modesetting.h

if GCONF
usb_moded_SOURCES += \
usb_moded-gconf.c \
usb_moded-gconf.h
endif

if HAL
usb_moded_SOURCES += \
usb_moded-hal.c
Expand Down
2 changes: 1 addition & 1 deletion src/usb_moded-appsync-dbus.c
Expand Up @@ -32,7 +32,7 @@
#include "usb_moded.h"
#include "usb_moded-log.h"
#include "usb_moded-modes.h"
#include "usb_moded-gconf-private.h"
#include "usb_moded-config-private.h"
#include "usb_moded-appsync.h"
#include "usb_moded-appsync-dbus.h"
#include "usb_moded-appsync-dbus-private.h"
Expand Down
Expand Up @@ -18,7 +18,7 @@
02110-1301 USA
*/
/*
* Gets information from Gconf for the usb modes
* Gets information from Gconf/ini file for the usb modes
*/

/*============================================================================= */
Expand Down
36 changes: 36 additions & 0 deletions src/usb_moded-config.c
Expand Up @@ -27,8 +27,10 @@

#include <glib.h>
#include <glib/gkeyfile.h>
#include <glib/gstdio.h>

#include "usb_moded-config.h"
#include "usb_moded-config-private.h"
#include "usb_moded-log.h"

static int get_conf_int(const gchar *entry, const gchar *key);
Expand Down Expand Up @@ -173,3 +175,37 @@ static const char * get_conf_string(const gchar *entry, const gchar *key)

}

#ifndef GCONF
const char * get_mode_setting(void)
{
return(get_conf_string(MODE_SETTING_ENTRY, MODE_SETTING_KEY));
}

int set_mode_setting(const char *mode)
{
GKeyFile *settingsfile;
gboolean test = FALSE;
int ret = 0;
gchar *keyfile;

settingsfile = g_key_file_new();
test = g_key_file_load_from_file(settingsfile, FS_MOUNT_CONFIG_FILE, G_KEY_FILE_NONE, NULL);
if(!test)
{
log_debug("No conffile.\n");
g_key_file_free(settingsfile);
return(ret);
}

g_key_file_set_string(settingsfile, MODE_SETTING_ENTRY, MODE_SETTING_KEY, mode);
keyfile = g_key_file_to_data (settingsfile, NULL, NULL);
/* free the settingsfile before writing things out to be sure
the contents will be correctly written to file afterwards.
Just a precaution. */
g_key_file_free(settingsfile);
ret = g_file_set_contents(FS_MOUNT_CONFIG_FILE, keyfile, -1, NULL);

return(ret);
}
#endif

2 changes: 2 additions & 0 deletions src/usb_moded-config.h
Expand Up @@ -22,6 +22,8 @@

#define FS_MOUNT_CONFIG_FILE "/etc/usb-moded/usb-moded.ini"

#define MODE_SETTING_ENTRY "usbmode"
#define MODE_SETTING_KEY "mode"
#define FS_MOUNT_DEFAULT "/dev/mmcblk0p1"
#define FS_MOUNT_ENTRY "mountpoints"
#define FS_MOUNT_KEY "mount"
Expand Down
2 changes: 1 addition & 1 deletion src/usb_moded-dbus.c
Expand Up @@ -31,7 +31,7 @@
#include "usb_moded-dbus-private.h"
#include "usb_moded.h"
#include "usb_moded-modes.h"
#include "usb_moded-gconf-private.h"
#include "usb_moded-config-private.h"
#include "usb_moded-log.h"

#ifdef NOKIA
Expand Down
2 changes: 1 addition & 1 deletion src/usb_moded-gconf.c
Expand Up @@ -34,7 +34,7 @@
#include <gconf/gconf-client.h>

#include "usb_moded-gconf.h"
#include "usb_moded-gconf-private.h"
#include "usb_moded-config-private.h"
#include "usb_moded-modes.h"
#include "usb_moded-log.h"
#include "usb_moded.h"
Expand Down
2 changes: 1 addition & 1 deletion src/usb_moded.c
Expand Up @@ -35,7 +35,6 @@
#include "usb_moded-dbus-private.h"
#include "usb_moded-hw-ab.h"
#include "usb_moded-gconf.h"
#include "usb_moded-gconf-private.h"
#include "usb_moded-modules.h"
#include "usb_moded-log.h"
#include "usb_moded-devicelock.h"
Expand All @@ -44,6 +43,7 @@
#include "usb_moded-appsync.h"
#include "usb_moded-trigger.h"
#include "usb_moded-config.h"
#include "usb_moded-config-private.h"

/* global definitions */

Expand Down

0 comments on commit 36aed12

Please sign in to comment.