Commit 6f6d4fc7 authored by spiiroin's avatar spiiroin

Merge branch 'mer1694_startup_and_exit' into 'master'

Fix issues related to usb-moded startup, exit and dbus usage



See merge request !20
parents 836d79fe f3a01678
...@@ -2,8 +2,11 @@ ...@@ -2,8 +2,11 @@
@file usb_moded-appsync.c @file usb_moded-appsync.c
Copyright (C) 2010 Nokia Corporation. All rights reserved. Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2013-2016 Jolla Ltd.
@author: Philippe De Swert <philippe.de-swert@nokia.com> @author: Philippe De Swert <philippe.de-swert@nokia.com>
@author: Philippe De Swert <philippe.deswert@jollamobile.com>
@author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
...@@ -259,9 +262,8 @@ int activate_sync(const char *mode) ...@@ -259,9 +262,8 @@ int activate_sync(const char *mode)
if(data->systemd) if(data->systemd)
{ {
if(!systemd_control_service(data->name, SYSTEMD_START)) if(!systemd_control_service(data->name, SYSTEMD_START))
mark_active(data->name, 0);
else
goto error; goto error;
mark_active(data->name, 0);
} }
else if(data->launch) else if(data->launch)
{ {
...@@ -320,7 +322,7 @@ int activate_sync_post(const char *mode) ...@@ -320,7 +322,7 @@ int activate_sync_post(const char *mode)
log_debug("launching post-enum-app %s\n", data->name); log_debug("launching post-enum-app %s\n", data->name);
if(data->systemd) if(data->systemd)
{ {
if(systemd_control_service(data->name, SYSTEMD_START)) if(!systemd_control_service(data->name, SYSTEMD_START))
goto error; goto error;
mark_active(data->name, 1); mark_active(data->name, 1);
} }
...@@ -442,14 +444,14 @@ static void appsync_stop_apps(int post) ...@@ -442,14 +444,14 @@ static void appsync_stop_apps(int post)
if(data->systemd && data->state == APP_STATE_ACTIVE && data->post == post) if(data->systemd && data->state == APP_STATE_ACTIVE && data->post == post)
{ {
log_debug("stopping %s-enum-app %s", post ? "post" : "pre", data->name); log_debug("stopping %s-enum-app %s", post ? "post" : "pre", data->name);
if(systemd_control_service(data->name, SYSTEMD_STOP)) if(!systemd_control_service(data->name, SYSTEMD_STOP))
log_debug("Failed to stop %s\n", data->name); log_debug("Failed to stop %s\n", data->name);
data->state = APP_STATE_DONTCARE; data->state = APP_STATE_DONTCARE;
} }
} }
} }
int appsync_stop(int force) int appsync_stop(gboolean force)
{ {
/* If force arg is used, stop all applications that /* If force arg is used, stop all applications that
* could have been started by usb-moded */ * could have been started by usb-moded */
......
/* /*
Copyright (C) 2010 Nokia Corporation. All rights reserved. Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2013-2016 Jolla Ltd.
author: Philippe De Swert <philippe.de-swert@nokia.com> author: Philippe De Swert <philippe.de-swert@nokia.com>
author: Philippe De Swert <philippe.deswert@jollamobile.com>
author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
...@@ -57,6 +60,6 @@ void readlist(int diag); ...@@ -57,6 +60,6 @@ void readlist(int diag);
int activate_sync(const char *mode); int activate_sync(const char *mode);
int activate_sync_post(const char *mode); int activate_sync_post(const char *mode);
int mark_active(const gchar *name, int post); int mark_active(const gchar *name, int post);
int appsync_stop(int force); int appsync_stop(gboolean force);
void free_appsync_list(void); void free_appsync_list(void);
void usb_moded_appsync_cleanup(void); void usb_moded_appsync_cleanup(void);
/* /*
Copyright (C) 2010 Nokia Corporation. All rights reserved. Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2013-2016 Jolla Ltd.
Author: Philippe De Swert <philippe.de-swert@nokia.com> Author: Philippe De Swert <philippe.de-swert@nokia.com>
Author: Philippe De Swert <philippe.deswert@jollamobile.com>
Author: Vesa Halttunen <vesa.halttunen@jollamobile.com>
Author: Martin Jones <martin.jones@jollamobile.com>
Author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
...@@ -18,8 +23,20 @@ ...@@ -18,8 +23,20 @@
02110-1301 USA 02110-1301 USA
*/ */
/* initialize dbus communication channels */ /** Logical name for org.freedesktop.DBus.GetNameOwner method */
gboolean usb_moded_dbus_init(void); #define DBUS_GET_NAME_OWNER_REQ "GetNameOwner"
/** Logical name for org.freedesktop.DBus.NameOwnerChanged signal */
#define DBUS_NAME_OWNER_CHANGED_SIG "NameOwnerChanged"
/* Connect to D-Bus System Bus */
gboolean usb_moded_dbus_init_connection(void);
/* Claim D-Bus Service Name */
gboolean usb_moded_dbus_init_service(void);
/* Get current SystemBus connection */
DBusConnection *usb_moded_dbus_get_connection(void);
/* cleanup usb on exit */ /* cleanup usb on exit */
void usb_moded_dbus_cleanup(void); void usb_moded_dbus_cleanup(void);
...@@ -35,3 +52,11 @@ int usb_moded_send_supported_modes_signal(const char *supported_modes); ...@@ -35,3 +52,11 @@ int usb_moded_send_supported_modes_signal(const char *supported_modes);
/* send hidden modes signal system bus */ /* send hidden modes signal system bus */
int usb_moded_send_hidden_modes_signal(const char *hidden_modes); int usb_moded_send_hidden_modes_signal(const char *hidden_modes);
/* Callback function type used with usb_moded_get_name_owner_async() */
typedef void (*usb_moded_get_name_owner_fn)(const char *owner);
/* Asynchronous GetNameOwner query */
gboolean usb_moded_get_name_owner_async(const char *name,
usb_moded_get_name_owner_fn cb,
DBusPendingCall **ppc);
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
@file usb_moded-dbus.c @file usb_moded-dbus.c
Copyright (C) 2010 Nokia Corporation. All rights reserved. Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2012-2015 Jolla. All rights reserved. Copyright (C) 2012-2016 Jolla. All rights reserved.
@author: Philippe De Swert <philippe.de-swert@nokia.com> @author: Philippe De Swert <philippe.de-swert@nokia.com>
@author: Philippe De Swert <philippe.deswert@jollamobile.com> @author: Philippe De Swert <philippe.deswert@jollamobile.com>
@author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
...@@ -44,6 +45,8 @@ ...@@ -44,6 +45,8 @@
#define INIT_DONE_MATCH "type='signal',interface='"INIT_DONE_INTERFACE"',member='"INIT_DONE_SIGNAL"'" #define INIT_DONE_MATCH "type='signal',interface='"INIT_DONE_INTERFACE"',member='"INIT_DONE_SIGNAL"'"
static DBusConnection *dbus_connection_sys = NULL; static DBusConnection *dbus_connection_sys = NULL;
static gboolean have_service_name = FALSE;
extern gboolean rescue_mode; extern gboolean rescue_mode;
/** /**
...@@ -52,7 +55,12 @@ extern gboolean rescue_mode; ...@@ -52,7 +55,12 @@ extern gboolean rescue_mode;
static void usb_moded_send_config_signal(const char *section, const char *key, const char *value) static void usb_moded_send_config_signal(const char *section, const char *key, const char *value)
{ {
log_debug(USB_MODE_CONFIG_SIGNAL_NAME ": %s %s %s\n", section, key, value); log_debug(USB_MODE_CONFIG_SIGNAL_NAME ": %s %s %s\n", section, key, value);
if (dbus_connection_sys) if( !have_service_name )
{
log_err("config notification without service: [%s] %s=%s",
section, key, value);
}
else if (dbus_connection_sys)
{ {
DBusMessage* msg = dbus_message_new_signal(USB_MODE_OBJECT, USB_MODE_INTERFACE, USB_MODE_CONFIG_SIGNAL_NAME); DBusMessage* msg = dbus_message_new_signal(USB_MODE_OBJECT, USB_MODE_INTERFACE, USB_MODE_CONFIG_SIGNAL_NAME);
if (msg) { if (msg) {
...@@ -451,7 +459,6 @@ error_reply: ...@@ -451,7 +459,6 @@ error_reply:
} }
} }
EXIT: EXIT:
if(reply) if(reply)
...@@ -467,18 +474,25 @@ EXIT: ...@@ -467,18 +474,25 @@ EXIT:
return status; return status;
} }
DBusConnection *usb_moded_dbus_get_connection(void)
{
DBusConnection *connection = 0;
if( dbus_connection_sys )
connection = dbus_connection_ref(dbus_connection_sys);
else
log_err("something asked for connection ref while unconnected");
return connection;
}
/** /**
* Init dbus for usb_moded * Establish D-Bus SystemBus connection
* *
* @return TRUE when everything went ok * @return TRUE when everything went ok
*/ */
gboolean usb_moded_dbus_init(void) gboolean usb_moded_dbus_init_connection(void)
{ {
gboolean status = FALSE; gboolean status = FALSE;
DBusError error; DBusError error = DBUS_ERROR_INIT;
int ret;
dbus_error_init(&error);
/* connect to system bus */ /* connect to system bus */
if ((dbus_connection_sys = dbus_bus_get(DBUS_BUS_SYSTEM, &error)) == NULL) if ((dbus_connection_sys = dbus_bus_get(DBUS_BUS_SYSTEM, &error)) == NULL)
...@@ -491,6 +505,35 @@ gboolean usb_moded_dbus_init(void) ...@@ -491,6 +505,35 @@ gboolean usb_moded_dbus_init(void)
if (!dbus_connection_add_filter(dbus_connection_sys, msg_handler, NULL, NULL)) if (!dbus_connection_add_filter(dbus_connection_sys, msg_handler, NULL, NULL))
goto EXIT; goto EXIT;
/* Listen to init-done signals */
dbus_bus_add_match(dbus_connection_sys, INIT_DONE_MATCH, 0);
/* Connect D-Bus to the mainloop */
dbus_connection_setup_with_g_main(dbus_connection_sys, NULL);
/* everything went fine */
status = TRUE;
EXIT:
dbus_error_free(&error);
return status;
}
/**
* Reserve "com.meego.usb_moded" D-Bus Service Name
*
* @return TRUE when everything went ok
*/
gboolean usb_moded_dbus_init_service(void)
{
gboolean status = FALSE;
DBusError error = DBUS_ERROR_INIT;
int ret;
if( !dbus_connection_sys ) {
goto EXIT;
}
/* Acquire D-Bus service */ /* Acquire D-Bus service */
ret = dbus_bus_request_name(dbus_connection_sys, USB_MODE_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &error); ret = dbus_bus_request_name(dbus_connection_sys, USB_MODE_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &error);
if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
...@@ -500,19 +543,8 @@ gboolean usb_moded_dbus_init(void) ...@@ -500,19 +543,8 @@ gboolean usb_moded_dbus_init(void)
log_debug("DBUS ERROR: %s, %s \n", error.name, error.message); log_debug("DBUS ERROR: %s, %s \n", error.name, error.message);
goto EXIT; goto EXIT;
} }
log_debug("claimed name %s", USB_MODE_SERVICE);
/* only match on signals/methods we support (if needed) have_service_name = TRUE;
dbus_bus_add_match(dbus_connection_sys, USB_MODE_INTERFACE, &error);
*/
/* Listen to init-done signals */
dbus_bus_add_match(dbus_connection_sys, INIT_DONE_MATCH, 0);
dbus_threads_init_default();
/* Connect D-Bus to the mainloop */
dbus_connection_setup_with_g_main(dbus_connection_sys, NULL);
/* everything went fine */ /* everything went fine */
status = TRUE; status = TRUE;
...@@ -521,20 +553,42 @@ EXIT: ...@@ -521,20 +553,42 @@ EXIT:
return status; return status;
} }
/** Release "com.meego.usb_moded" D-Bus Service Name
*/
static void usb_moded_dbus_cleanup_service(void)
{
if( !have_service_name )
goto EXIT;
have_service_name = FALSE;
log_debug("release name %s", USB_MODE_SERVICE);
if( dbus_connection_sys &&
dbus_connection_get_is_connected(dbus_connection_sys) )
{
dbus_bus_release_name(dbus_connection_sys, USB_MODE_SERVICE, NULL);
}
EXIT:
return;
}
/** /**
* Clean up the dbus connections on exit * Clean up the dbus connections on exit
* *
*/ */
void usb_moded_dbus_cleanup(void) void usb_moded_dbus_cleanup(void)
{ {
/* clean up system bus connection */ /* clean up system bus connection */
if (dbus_connection_sys != NULL) if (dbus_connection_sys != NULL)
{ {
dbus_bus_release_name(dbus_connection_sys, USB_MODE_SERVICE, NULL); usb_moded_dbus_cleanup_service();
dbus_connection_remove_filter(dbus_connection_sys, msg_handler, NULL);
dbus_connection_unref(dbus_connection_sys); dbus_connection_remove_filter(dbus_connection_sys, msg_handler, NULL);
dbus_connection_sys = NULL;
} dbus_connection_unref(dbus_connection_sys),
dbus_connection_sys = NULL;
}
} }
/** /**
...@@ -549,6 +603,12 @@ static int usb_moded_dbus_signal(const char *signal_type, const char *content) ...@@ -549,6 +603,12 @@ static int usb_moded_dbus_signal(const char *signal_type, const char *content)
int result = 1; int result = 1;
DBusMessage* msg = 0; DBusMessage* msg = 0;
if( !have_service_name )
{
log_err("sending signal without service: %s(%s)",
signal_type, content);
goto EXIT;
}
if(!dbus_connection_sys) if(!dbus_connection_sys)
{ {
log_err("Dbus system connection broken!\n"); log_err("Dbus system connection broken!\n");
...@@ -632,3 +692,104 @@ int usb_moded_send_hidden_modes_signal(const char *hidden_modes) ...@@ -632,3 +692,104 @@ int usb_moded_send_hidden_modes_signal(const char *hidden_modes)
{ {
return(usb_moded_dbus_signal(USB_MODE_HIDDEN_MODES_SIGNAL_NAME, hidden_modes)); return(usb_moded_dbus_signal(USB_MODE_HIDDEN_MODES_SIGNAL_NAME, hidden_modes));
} }
/** Async reply handler for usb_moded_get_name_owner_async()
*
* @param pc Pending call object pointer
* @param aptr Notify function to call (as a void pointer)
*/
static void usb_moded_get_name_owner_cb(DBusPendingCall *pc, void *aptr)
{
usb_moded_get_name_owner_fn cb = aptr;
DBusMessage *rsp = 0;
const char *dta = 0;
DBusError err = DBUS_ERROR_INIT;
if( !(rsp = dbus_pending_call_steal_reply(pc)) ) {
log_err("did not get reply");
goto EXIT;
}
if( dbus_set_error_from_message(&err, rsp) )
{
if( strcmp(err.name, DBUS_ERROR_NAME_HAS_NO_OWNER) )
log_err("error reply: %s: %s", err.name, err.message);
goto EXIT;
}
if( !dbus_message_get_args(rsp, &err,
DBUS_TYPE_STRING, &dta,
DBUS_TYPE_INVALID) )
{
if( strcmp(err.name, DBUS_ERROR_NAME_HAS_NO_OWNER) )
log_err("parse error: %s: %s", err.name, err.message);
goto EXIT;
}
EXIT:
/* Allways call the notification function. Equate any error
* situations with "service does not have an owner". */
cb(dta ?: "");
if( rsp ) dbus_message_unref(rsp);
dbus_error_free(&err);
}
/** Helper function for making async dbus name owner queries
*
* @param name D-Bus name to query
* @param cb Function to call when async reply is received
* @param ppc Where to store pending call object, or NULL
*
* @return TRUE if method call was sent, FALSE otherwise
*/
gboolean usb_moded_get_name_owner_async(const char *name,
usb_moded_get_name_owner_fn cb,
DBusPendingCall **ppc)
{
gboolean ack = FALSE;
DBusMessage *req = 0;
DBusPendingCall *pc = 0;
if(!dbus_connection_sys)
goto EXIT;
req = dbus_message_new_method_call(DBUS_INTERFACE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS,
DBUS_GET_NAME_OWNER_REQ);
if( !req ) {
log_err("could not create method call message");
goto EXIT;
}
if( !dbus_message_append_args(req,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INVALID) ) {
log_err("could not add method call parameters");
goto EXIT;
}
if( !dbus_connection_send_with_reply(dbus_connection_sys, req, &pc, -1) )
goto EXIT;
if( !pc )
goto EXIT;
if( !dbus_pending_call_set_notify(pc, usb_moded_get_name_owner_cb, cb, 0) )
goto EXIT;
ack = TRUE;
if( ppc )
*ppc = pc, pc = 0;
EXIT:
if( pc ) dbus_pending_call_unref(pc);
if( req ) dbus_message_unref(req);
return ack;
}
This diff is collapsed.
/* /*
Copyright (C) 2010 Nokia Corporation. All rights reserved. Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2013-2016 Jolla Ltd.
Author: Philippe De Swert <philippe.de-swert@nokia.com> Author: Philippe De Swert <philippe.de-swert@nokia.com>
Author: Vesa Halttunen <vesa.halttunen@jollamobile.com>
Author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
...@@ -23,15 +26,20 @@ ...@@ -23,15 +26,20 @@
/*============================================================================= */ /*============================================================================= */
#define DEVICELOCK_SERVICE "org.nemomobile.lipstick" #define DEVICELOCK_SERVICE "org.nemomobile.lipstick"
#define DEVICELOCK_REQUEST_PATH "/devicelock" #define DEVICELOCK_OBJECT "/devicelock"
#define DEVICELOCK_REQUEST_IF "org.nemomobile.lipstick.devicelock" #define DEVICELOCK_INTERFACE "org.nemomobile.lipstick.devicelock"
#define DEVICELOCK_STATE_REQ "state" #define DEVICELOCK_GET_STATE_REQ "state"
#define DEVICELOCK_STATE_CHANGED_SIG "stateChanged"
#define DEVICELOCK_LOCKED "Locked"
#define DEVICELOCK_STATE_CHANGED_MATCH\
#define MATCH_DEVICELOCK_SIGNALS\ "type='signal'"\
"type='signal'"\ ",interface='"DEVICELOCK_INTERFACE"'"\
",interface='"DEVICELOCK_REQUEST_IF"'"\ ",path='"DEVICELOCK_OBJECT"'"\
",path='"DEVICELOCK_REQUEST_PATH"'" ",member='"DEVICELOCK_STATE_CHANGED_SIG"'"
#define DEVICELOCK_NAME_OWNER_CHANGED_MATCH\
"type='signal'"\
",interface='"DBUS_INTERFACE_DBUS"'"\
",member='"DBUS_NAME_OWNER_CHANGED_SIG"'"\
",arg0='"DEVICELOCK_SERVICE"'"
This diff is collapsed.
/** /**
@file usb_moded-dsme.h @file usb_moded-dsme.h
Copyright (C) 2013 Jolla. All rights reserved. Copyright (C) 2013-2016 Jolla. All rights reserved.
@author: Philippe De Swert <philippe.deswert@jollamobile.com> @author: Philippe De Swert <philippe.deswert@jollamobile.com>
@author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
...@@ -20,4 +21,6 @@ ...@@ -20,4 +21,6 @@
02110-1301 USA 02110-1301 USA
*/ */
int is_in_user_state(void); gboolean is_in_user_state(void);
gboolean dsme_listener_start(void);
void dsme_listener_stop(void);
/* /*
Copyright (C) 2012 Nokia Corporation. All rights reserved. Copyright (C) 2012 Nokia Corporation. All rights reserved.
Copyright (C) 2013-2016 Jolla Ltd.
Author: Philippe De Swert <philippe.de-swert@nokia.com> Author: Philippe De Swert <philippe.de-swert@nokia.com>
Author: Philippe De Swert <philippe.deswert@jollamobile.com>
Author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
...@@ -23,6 +26,6 @@ ...@@ -23,6 +26,6 @@
*/ */
/*============================================================================= */ /*============================================================================= */
int usb_moded_get_export_permission(void); int usb_moded_get_export_permission(void);
int start_devicelock_listener(void); gboolean start_devicelock_listener(void);
int stop_devicelock_listener(void); void stop_devicelock_listener(void);
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
@file usb_moded-log.c @file usb_moded-log.c
Copyright (C) 2010 Nokia Corporation. All rights reserved. Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2016 Jolla Ltd.
@author: Philippe De Swert <philippe.de-swert@nokia.com> @author: Philippe De Swert <philippe.de-swert@nokia.com>
@author: Simo Piiroinen <simo.piiroinen@nokia.com> @author: Simo Piiroinen <simo.piiroinen@nokia.com>
@author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
...@@ -53,6 +56,14 @@ static char *strip(char *str) ...@@ -53,6 +56,14 @@ static char *strip(char *str)
return str; return str;
} }
static struct timeval log_begtime = { 0, 0 };
static void log_gettime(struct timeval *tv)
{
gettimeofday(tv, 0);
timersub(tv, &log_begtime, tv);
}
/** /**
* Print the logged messages to the selected output * Print the logged messages to the selected output
* *
...@@ -79,10 +90,10 @@ void log_emit_va(int lev, const char *fmt, va_list va) ...@@ -79,10 +90,10 @@ void log_emit_va(int lev, const char *fmt, va_list va)
#if LOG_ENABLE_TIMESTAMPS #if LOG_ENABLE_TIMESTAMPS
{ {
struct timeval tv; struct timeval tv;
gettimeofday(&tv, 0); log_gettime(&tv);
fprintf(stderr, "%ld.%06ld ", fprintf(stderr, "%3ld.%03ld ",
(long)tv.tv_sec, (long)tv.tv_sec,
(long)tv.tv_usec); (long)tv.tv_usec/1000);
} }
#endif #endif
...@@ -156,3 +167,10 @@ inline void log_set_level(int lev) ...@@ -156,3 +167,10 @@ inline void log_set_level(int lev)
log_level = lev; log_level = lev;
} }
/** Initialize logging */
void log_init(void)
{
/* Get reference time used for verbose logging */
if( !timerisset(&log_begtime) )
gettimeofday(&log_begtime, 0);
}
/* /*
Copyright (C) 2010 Nokia Corporation. All rights reserved. Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2016 Jolla Ltd.
Author: Philippe De Swert <philippe.de-swert@nokia.com> Author: Philippe De Swert <philippe.de-swert@nokia.com>
Author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
...@@ -44,6 +46,7 @@ enum ...@@ -44,6 +46,7 @@ enum
void log_set_level(int lev); void log_set_level(int lev);
int log_get_level(void); int log_get_level(void);
void log_init(void);
void log_emit_va(int lev, const char *fmt, va_list va); void log_emit_va(int lev, const char *fmt, va_list va);
void log_emit(int lev, const char *fmt, ...) __attribute__((format(printf,2,3))); void log_emit(int lev, const char *fmt, ...) __attribute__((format(printf,2,3)));
void log_debugf(const char *fmt, ...) __attribute__((format(printf,1,2))); void log_debugf(const char *fmt, ...) __attribute__((format(printf,1,2)));
......
...@@ -2,8 +2,13 @@ ...@@ -2,8 +2,13 @@
@file usb_moded-modesetting.c @file usb_moded-modesetting.c
Copyright (C) 2010 Nokia Corporation. All rights reserved. Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2013-2016 Jolla Ltd.
@author: Philippe De Swert <philippe.de-swert@nokia.com> @author: Philippe De Swert <philippe.de-swert@nokia.com>
@author: Philippe De Swert <philippe.deswert@jollamobile.com>
@author: Bernd Wachter <bernd.wachter@jollamobile.com>
@author: Slava Monich <slava.monich@jolla.com>
@author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
...@@ -567,7 +572,7 @@ int usb_moded_mode_cleanup(const char *module) ...@@ -567,7 +572,7 @@ int usb_moded_mode_cleanup(const char *module)
#ifdef APP_SYNC #ifdef APP_SYNC
/* Stop applications started due to entering this mode */ /* Stop applications started due to entering this mode */
appsync_stop(0); appsync_stop(FALSE);
#endif /* APP_SYNC */ #endif /* APP_SYNC */
if(!strcmp(module, MODULE_MASS_STORAGE)|| !strcmp(module, MODULE_FILE_STORAGE)) if(!strcmp(module, MODULE_MASS_STORAGE)|| !strcmp(module, MODULE_FILE_STORAGE))
......
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
@file usb_moded-modules.c @file usb_moded-modules.c
Copyright (C) 2010 Nokia Corporation. All rights reserved. Copyright (C) 2010 Nokia Corporation. All rights reserved.