diff --git a/Makefile.custom b/Makefile.custom index 8f3be87..783101f 100644 --- a/Makefile.custom +++ b/Makefile.custom @@ -316,10 +316,24 @@ endif # ---------------------------------------------------------------------------- .SUFFIXES: .q .p .g - -%.q : %.c ; $(CC) -o $@ -E $< $(CPPFLAGS) $(MCE_CFLAGS) -%.p : %.q ; cproto -s < $< | prettyproto.py > $@ -%.g : %.q ; cproto < $< | prettyproto.py > $@ +.PRECIOUS: .q + +PROTO_CPPFLAGS += -DAPP_SYNC +PROTO_CPPFLAGS += -DAPP_SYNC_DBUS +PROTO_CPPFLAGS += -DCONNMAN +PROTO_CPPFLAGS += -DDEAD_CODE +PROTO_CPPFLAGS += -DDEBIAN +PROTO_CPPFLAGS += -DMEEGOLOCK +PROTO_CPPFLAGS += -DOFONO +PROTO_CPPFLAGS += -DSYSTEMD +PROTO_CPPFLAGS += -DUSE_MER_SSU +PROTO_CPPFLAGS += -DCONNMAN_WORKS_BETTER=1 +PROTO_CPPFLAGS += -DVERBOSE_WAKELOCKING=1 + +%.q : CPPFLAGS += $(PROTO_CPPFLAGS) +%.q : %.c ; $(CC) -o $@ -E $< $(CPPFLAGS) -O +%.p : %.q prettyproto.groups ; cproto -s < $< | prettyproto.py > $@ +%.g : %.q prettyproto.groups ; cproto < $< | prettyproto.py > $@ clean:: $(RM) *.[qpg] src/*.[qpg] utils/*.[qpg] diff --git a/src/usb_moded-android.c b/src/usb_moded-android.c index 4ec4ded..5145dce 100644 --- a/src/usb_moded-android.c +++ b/src/usb_moded-android.c @@ -1,7 +1,7 @@ /** * @file usb_moded-android.c * - * Copyright (C) 2013-2018 Jolla. All rights reserved. + * Copyright (C) 2013-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Simo Piiroinen @@ -34,11 +34,14 @@ #include /* ========================================================================= * - * Functions + * Prototypes * ========================================================================= */ -/* -- android -- */ +/* ------------------------------------------------------------------------- * + * ANDROID + * ------------------------------------------------------------------------- */ +static bool android_write_file (const char *path, const char *text); bool android_in_use (void); static bool android_probe (void); gchar *android_get_serial (void); diff --git a/src/usb_moded-android.h b/src/usb_moded-android.h index b0a7ecd..168ad6e 100644 --- a/src/usb_moded-android.h +++ b/src/usb_moded-android.h @@ -1,7 +1,7 @@ /** * @file usb_moded-android.h * - * Copyright (C) 2013-2018 Jolla. All rights reserved. + * Copyright (C) 2013-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Simo Piiroinen @@ -44,7 +44,9 @@ * Prototypes * ========================================================================= */ -/* -- android -- */ +/* ------------------------------------------------------------------------- * + * ANDROID + * ------------------------------------------------------------------------- */ bool android_in_use (void); gchar *android_get_serial (void); diff --git a/src/usb_moded-appsync-dbus-private.h b/src/usb_moded-appsync-dbus-private.h index 1df7ef4..3b1e9b8 100644 --- a/src/usb_moded-appsync-dbus-private.h +++ b/src/usb_moded-appsync-dbus-private.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2018 Jolla Ltd. + * Copyright (C) 2018-2019 Jolla Ltd. * * Author: Philippe De Swert * Author: Philippe De Swert @@ -33,7 +33,9 @@ * Prototypes * ========================================================================= */ -/* -- dbusappsync -- */ +/* ------------------------------------------------------------------------- * + * DBUSAPPSYNC + * ------------------------------------------------------------------------- */ gboolean dbusappsync_init_connection(void); gboolean dbusappsync_init (void); diff --git a/src/usb_moded-appsync-dbus.c b/src/usb_moded-appsync-dbus.c index 9be0f6d..214a629 100644 --- a/src/usb_moded-appsync-dbus.c +++ b/src/usb_moded-appsync-dbus.c @@ -2,7 +2,7 @@ * @file usb_moded-dbus.c * * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2013-2018 Jolla Ltd. + * Copyright (C) 2013-2019 Jolla Ltd. * * @author: Philippe De Swert * @author: Philippe De Swert @@ -38,7 +38,9 @@ * Prototypes * ========================================================================= */ -/* -- dbusappsync -- */ +/* ------------------------------------------------------------------------- * + * DBUSAPPSYNC + * ------------------------------------------------------------------------- */ static void dbusappsync_release_name (void); static gboolean dbusappsync_obtain_name (void); diff --git a/src/usb_moded-appsync.c b/src/usb_moded-appsync.c index 8715614..d4206a1 100644 --- a/src/usb_moded-appsync.c +++ b/src/usb_moded-appsync.c @@ -2,7 +2,7 @@ * @file usb_moded-appsync.c * * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2013-2018 Jolla Ltd. + * Copyright (C) 2013-2019 Jolla Ltd. * * @author: Philippe De Swert * @author: Philippe De Swert @@ -40,27 +40,27 @@ * Prototypes * ========================================================================= */ -/* -- appsync -- */ - -static void appsync_free_elem (list_elem_t *elem); -static void appsync_free_elem_cb (gpointer elem, gpointer user_data); -void appsync_free_appsync_list (void); -static gint appsync_list_sort_func (gconstpointer a, gconstpointer b); -void appsync_read_list (int diag); -static list_elem_t *appsync_read_file (const gchar *filename, int diag); -int appsync_activate_sync (const char *mode); -int appsync_activate_sync_post (const char *mode); -int appsync_mark_active (const gchar *name, int post); - +/* ------------------------------------------------------------------------- * + * APPSYNC + * ------------------------------------------------------------------------- */ + +static void appsync_free_elem (list_elem_t *elem); +static void appsync_free_elem_cb (gpointer elem, gpointer user_data); +void appsync_free_appsync_list (void); +static gint appsync_list_sort_func (gconstpointer a, gconstpointer b); +void appsync_read_list (int diag); +static list_elem_t *appsync_read_file (const gchar *filename, int diag); +int appsync_activate_sync (const char *mode); +int appsync_activate_sync_post (const char *mode); +int appsync_mark_active (const gchar *name, int post); #ifdef APP_SYNC_DBUS -static gboolean appsync_enumerate_usb_cb (gpointer data); -static void appsync_start_enumerate_usb_timer (void); -static void appsync_cancel_enumerate_usb_timer(void); -static void appsync_enumerate_usb (void); -#endif - -void appsync_stop_apps (int post); -int appsync_stop (gboolean force); +static gboolean appsync_enumerate_usb_cb (gpointer data); +static void appsync_start_enumerate_usb_timer (void); +static void appsync_cancel_enumerate_usb_timer(void); +static void appsync_enumerate_usb (void); +#endif // APP_SYNC_DBUS +void appsync_stop_apps (int post); +int appsync_stop (gboolean force); /* ========================================================================= * * Data diff --git a/src/usb_moded-appsync.h b/src/usb_moded-appsync.h index 967199a..c2b7610 100644 --- a/src/usb_moded-appsync.h +++ b/src/usb_moded-appsync.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2013-2018 Jolla Ltd. + * Copyright (C) 2013-2019 Jolla Ltd. * * author: Philippe De Swert * author: Philippe De Swert @@ -74,14 +74,16 @@ typedef struct list_elem_t * Prototypes * ========================================================================= */ -/* -- appsync -- */ +/* ------------------------------------------------------------------------- * + * APPSYNC + * ------------------------------------------------------------------------- */ void appsync_free_appsync_list (void); void appsync_read_list (int diag); int appsync_activate_sync (const char *mode); int appsync_activate_sync_post(const char *mode); int appsync_mark_active (const gchar *name, int post); -int appsync_stop (gboolean force); void appsync_stop_apps (int post); +int appsync_stop (gboolean force); #endif /* USB_MODED_APPSYNC_H_ */ diff --git a/src/usb_moded-common.c b/src/usb_moded-common.c index 414637c..a4e87db 100644 --- a/src/usb_moded-common.c +++ b/src/usb_moded-common.c @@ -35,11 +35,15 @@ typedef struct modemapping_t * Prototypes * ========================================================================= */ -/* -- cable -- */ +/* ------------------------------------------------------------------------- * + * CABLE_STATE + * ------------------------------------------------------------------------- */ const char *cable_state_repr(cable_state_t state); -/* -- common -- */ +/* ------------------------------------------------------------------------- * + * COMMON + * ------------------------------------------------------------------------- */ const char *common_map_mode_to_hardware (const char *internal_mode); const char *common_map_mode_to_external (const char *internal_mode); diff --git a/src/usb_moded-common.h b/src/usb_moded-common.h index d8d06fe..fb67358 100644 --- a/src/usb_moded-common.h +++ b/src/usb_moded-common.h @@ -34,14 +34,18 @@ typedef enum waitres_t } waitres_t; /* ========================================================================= * - * Functions + * Prototypes * ========================================================================= */ -/* -- cable -- */ +/* ------------------------------------------------------------------------- * + * CABLE_STATE + * ------------------------------------------------------------------------- */ const char *cable_state_repr(cable_state_t state); -/* -- common -- */ +/* ------------------------------------------------------------------------- * + * COMMON + * ------------------------------------------------------------------------- */ const char *common_map_mode_to_hardware (const char *internal_mode); const char *common_map_mode_to_external (const char *internal_mode); diff --git a/src/usb_moded-config-private.h b/src/usb_moded-config-private.h index 643ae03..e3e8449 100644 --- a/src/usb_moded-config-private.h +++ b/src/usb_moded-config-private.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2012-2018 Jolla. All rights reserved. + * Copyright (C) 2012-2019 Jolla. All rights reserved. * * Author: Philippe De Swert * Author: Philippe De Swert @@ -53,7 +53,9 @@ * Prototypes * ========================================================================= */ -/* -- config -- */ +/* ------------------------------------------------------------------------- * + * CONFIG + * ------------------------------------------------------------------------- */ char *config_find_mounts (void); int config_find_sync (void); @@ -65,8 +67,8 @@ char *config_get_trigger_subsystem (void); char *config_get_trigger_mode (void); char *config_get_trigger_property (void); char *config_get_trigger_value (void); +char *config_get_conf_string (const gchar *entry, const gchar *key); char *config_get_mode_setting (void); -int config_value_changed (GKeyFile *settingsfile, const char *entry, const char *key, const char *new_value); set_config_result_t config_set_config_setting (const char *entry, const char *key, const char *value); set_config_result_t config_set_mode_setting (const char *mode); set_config_result_t config_set_hide_mode_setting (const char *mode); @@ -83,7 +85,6 @@ char *config_get_android_product_id (void); char *config_get_hidden_modes (void); char *config_get_mode_whitelist (void); int config_is_roaming_not_allowed (void); -char *config_get_conf_string (const gchar *entry, const gchar *key); /* ========================================================================= * * Macros diff --git a/src/usb_moded-config.c b/src/usb_moded-config.c index e1ba4aa..dcf3bfa 100644 --- a/src/usb_moded-config.c +++ b/src/usb_moded-config.c @@ -2,7 +2,7 @@ * @file usb_moded-config.c * * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2012-2018 Jolla. All rights reserved. + * Copyright (C) 2012-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Philippe De Swert @@ -57,7 +57,9 @@ * Prototypes * ========================================================================= */ -/* -- config -- */ +/* ------------------------------------------------------------------------- * + * CONFIG + * ------------------------------------------------------------------------- */ static int config_validate_ip (const char *ipadd); char *config_find_mounts (void); diff --git a/src/usb_moded-configfs.c b/src/usb_moded-configfs.c index 537237b..8abb66d 100644 --- a/src/usb_moded-configfs.c +++ b/src/usb_moded-configfs.c @@ -1,7 +1,7 @@ /** * @file usb_moded-configfs.c * - * Copyright (C) 2018 Jolla. All rights reserved. + * Copyright (C) 2018-2019 Jolla. All rights reserved. * * @author: Simo Piiroinen * @@ -64,7 +64,9 @@ * Prototypes * ========================================================================= */ -/* -- configfs -- */ +/* ------------------------------------------------------------------------- * + * CONFIGFS + * ------------------------------------------------------------------------- */ static gchar *configfs_get_conf (const char *key, const char *def); static void configfs_read_configuration (void); @@ -75,6 +77,9 @@ static const char *configfs_config_path (char *buff, size_t size, con static bool configfs_mkdir (const char *path); static bool configfs_rmdir (const char *path); static const char *configfs_register_function (const char *function); +#ifdef DEAD_CODE +static bool configfs_unregister_function (const char *function); +#endif //DEAD_CODE static const char *configfs_add_unit (const char *function, const char *unit); static bool configfs_remove_unit (const char *function, const char *unit); static bool configfs_enable_function (const char *function); @@ -86,6 +91,9 @@ static bool configfs_probe (void); static const char *configfs_udc_enable_value (void); static bool configfs_write_file (const char *path, const char *text); static bool configfs_read_file (const char *path, char *buff, size_t size); +#ifdef DEAD_CODE +static bool configfs_read_udc (char *buff, size_t size); +#endif // DEAD_CODE static bool configfs_write_udc (const char *text); bool configfs_set_udc (bool enable); bool configfs_init (void); diff --git a/src/usb_moded-configfs.h b/src/usb_moded-configfs.h index 2be0560..96d9dd2 100644 --- a/src/usb_moded-configfs.h +++ b/src/usb_moded-configfs.h @@ -1,7 +1,7 @@ /** * @file usb_moded-configfs.h * - * Copyright (C) 2018 Jolla. All rights reserved. + * Copyright (C) 2018-2019 Jolla. All rights reserved. * * @author: Simo Piiroinen * @@ -29,7 +29,9 @@ * Prototypes * ========================================================================= */ -/* -- configfs -- */ +/* ------------------------------------------------------------------------- * + * CONFIGFS + * ------------------------------------------------------------------------- */ bool configfs_in_use (void); bool configfs_set_udc (bool enable); diff --git a/src/usb_moded-control.c b/src/usb_moded-control.c index 4dab271..ac971df 100644 --- a/src/usb_moded-control.c +++ b/src/usb_moded-control.c @@ -37,7 +37,9 @@ * Prototypes * ========================================================================= */ -/* -- usbmoded -- */ +/* ------------------------------------------------------------------------- * + * CONTROL + * ------------------------------------------------------------------------- */ void control_rethink_usb_charging_fallback(void); const char *control_get_external_mode (void); diff --git a/src/usb_moded-control.h b/src/usb_moded-control.h index bc09f44..4e50ccf 100644 --- a/src/usb_moded-control.h +++ b/src/usb_moded-control.h @@ -27,7 +27,13 @@ # include "usb_moded.h" # include "usb_moded-common.h" -/* -- usbmoded -- */ +/* ========================================================================= * + * Prototypes + * ========================================================================= */ + +/* ------------------------------------------------------------------------- * + * CONTROL + * ------------------------------------------------------------------------- */ void control_rethink_usb_charging_fallback(void); const char *control_get_external_mode (void); @@ -37,7 +43,7 @@ void control_clear_target_mode (void); const char *control_get_usb_mode (void); void control_clear_internal_mode (void); void control_set_usb_mode (const char *mode); -void control_mode_switched (const char *override); +void control_mode_switched (const char *mode); void control_select_usb_mode (void); void control_set_cable_state (cable_state_t cable_state); cable_state_t control_get_cable_state (void); diff --git a/src/usb_moded-dbus-private.h b/src/usb_moded-dbus-private.h index dc6da43..65501ec 100644 --- a/src/usb_moded-dbus-private.h +++ b/src/usb_moded-dbus-private.h @@ -53,7 +53,9 @@ typedef void (*usb_moded_get_name_owner_fn)(const char *owner); * Prototypes * ========================================================================= */ -/* -- umdbus -- */ +/* ------------------------------------------------------------------------- * + * UMDBUS + * ------------------------------------------------------------------------- */ DBusConnection *umdbus_get_connection (void); gboolean umdbus_init_connection (void); diff --git a/src/usb_moded-dbus.c b/src/usb_moded-dbus.c index d8c6d1a..3cbd3a4 100644 --- a/src/usb_moded-dbus.c +++ b/src/usb_moded-dbus.c @@ -55,7 +55,9 @@ * Prototypes * ========================================================================= */ -/* -- umdbus -- */ +/* ------------------------------------------------------------------------- * + * UMDBUS + * ------------------------------------------------------------------------- */ static void umdbus_send_config_signal (const char *section, const char *key, const char *value); static DBusHandlerResult umdbus_msg_handler (DBusConnection *const connection, DBusMessage *const msg, gpointer const user_data); @@ -68,9 +70,9 @@ static DBusMessage *umdbus_new_signal (const char *signa static int umdbus_send_signal_ex (const char *signal_name, const char *content); static void umdbus_send_legacy_signal (const char *state_ind); void umdbus_send_current_state_signal (const char *state_ind); -static bool umsdbus_append_basic_entry (DBusMessageIter *iter, const char *key, int type, const void *val); -static bool umsdbus_append_int32_entry (DBusMessageIter *iter, const char *key, int val); -static bool umsdbus_append_string_entry (DBusMessageIter *iter, const char *key, const char *val); +static bool umdbus_append_basic_entry (DBusMessageIter *iter, const char *key, int type, const void *val); +static bool umdbus_append_int32_entry (DBusMessageIter *iter, const char *key, int val); +static bool umdbus_append_string_entry (DBusMessageIter *iter, const char *key, const char *val); static bool umdbus_append_mode_details (DBusMessage *msg, const char *mode_name); static void umdbus_send_mode_details_signal (const char *mode_name); void umdbus_send_target_state_signal (const char *state_ind); @@ -933,7 +935,7 @@ void umdbus_send_current_state_signal(const char *state_ind) * @return true on success, false on failure */ static bool -umsdbus_append_basic_entry(DBusMessageIter *iter, const char *key, +umdbus_append_basic_entry(DBusMessageIter *iter, const char *key, int type, const void *val) { LOG_REGISTER_CONTEXT; @@ -993,12 +995,12 @@ umsdbus_append_basic_entry(DBusMessageIter *iter, const char *key, * @return true on success, false on failure */ static bool -umsdbus_append_int32_entry(DBusMessageIter *iter, const char *key, int val) +umdbus_append_int32_entry(DBusMessageIter *iter, const char *key, int val) { LOG_REGISTER_CONTEXT; dbus_int32_t arg = val; - return umsdbus_append_basic_entry(iter, key, DBUS_TYPE_INT32, &arg); + return umdbus_append_basic_entry(iter, key, DBUS_TYPE_INT32, &arg); } /** Append string key, variant:string value dict entry to dbus iterator @@ -1010,14 +1012,14 @@ umsdbus_append_int32_entry(DBusMessageIter *iter, const char *key, int val) * @return true on success, false on failure */ static bool -umsdbus_append_string_entry(DBusMessageIter *iter, const char *key, +umdbus_append_string_entry(DBusMessageIter *iter, const char *key, const char *val) { LOG_REGISTER_CONTEXT; if( !val ) val = ""; - return umsdbus_append_basic_entry(iter, key, DBUS_TYPE_STRING, &val); + return umdbus_append_basic_entry(iter, key, DBUS_TYPE_STRING, &val); } /** Append dynamic mode configuration to dbus message @@ -1059,7 +1061,7 @@ umdbus_append_mode_details(DBusMessage *msg, const char *mode_name) /* Note: mode_name is special case: It needs to be valid even * if the mode does not have dynamic configuration. */ - if( !umsdbus_append_string_entry(&dict, "mode_name", mode_name) ) + if( !umdbus_append_string_entry(&dict, "mode_name", mode_name) ) goto bailout_dict; /* For the rest of the mode attrs we use fallback data if there @@ -1067,10 +1069,10 @@ umdbus_append_mode_details(DBusMessage *msg, const char *mode_name) */ #define ADD_STR(name) \ - if( !umsdbus_append_string_entry(&dict, #name, data ? data->name : 0) )\ + if( !umdbus_append_string_entry(&dict, #name, data ? data->name : 0) )\ goto bailout_dict; #define ADD_INT(name) \ - if( !umsdbus_append_int32_entry(&dict, #name, data ? data->name : 0) )\ + if( !umdbus_append_int32_entry(&dict, #name, data ? data->name : 0) )\ goto bailout_dict; /* Attributes that we presume to be needed */ diff --git a/src/usb_moded-devicelock.c b/src/usb_moded-devicelock.c index a86ad97..1c87fef 100644 --- a/src/usb_moded-devicelock.c +++ b/src/usb_moded-devicelock.c @@ -2,7 +2,7 @@ * @file: usb_moded-devicelock.c * * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2013-2018 Jolla Ltd. + * Copyright (C) 2013-2019 Jolla Ltd. * * @author: Philippe De Swert * @author: Philippe De Swert @@ -61,7 +61,9 @@ typedef enum devicelock_state_t * Prototypes * ========================================================================= */ -/* -- devicelock -- */ +/* ------------------------------------------------------------------------- * + * DEVICELOCK + * ------------------------------------------------------------------------- */ static const char *devicelock_state_repr (devicelock_state_t state); bool devicelock_have_export_permission(void); diff --git a/src/usb_moded-devicelock.h b/src/usb_moded-devicelock.h index a5daa70..a5c31ae 100644 --- a/src/usb_moded-devicelock.h +++ b/src/usb_moded-devicelock.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2013-2018 Jolla Ltd. + * Copyright (C) 2013-2019 Jolla Ltd. * * Author: Philippe De Swert * Author: Vesa Halttunen @@ -57,10 +57,12 @@ * Prototypes * ========================================================================= */ -/* -- devicelock -- */ +/* ------------------------------------------------------------------------- * + * DEVICELOCK + * ------------------------------------------------------------------------- */ -bool devicelock_have_export_permission(void); -bool devicelock_start_listener (void); -void devicelock_stop_listener (void); +bool devicelock_have_export_permission(void); +bool devicelock_start_listener (void); +void devicelock_stop_listener (void); #endif /* USB_MODED_DEVICELOCK_H_ */ diff --git a/src/usb_moded-dsme.c b/src/usb_moded-dsme.c index 990be4f..49e50b1 100644 --- a/src/usb_moded-dsme.c +++ b/src/usb_moded-dsme.c @@ -1,7 +1,7 @@ /** * @file usb_moded-dsme.c * - * Copyright (C) 2013-2018 Jolla. All rights reserved. + * Copyright (C) 2013-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Jonni Rainisto @@ -62,64 +62,59 @@ ",arg0='"DSME_DBUS_SERVICE"'" /* ========================================================================= * - * Functionality + * Prototypes * ========================================================================= */ /* ------------------------------------------------------------------------- * - * DSME_STATE_TRACKING + * DSME_STATE * ------------------------------------------------------------------------- */ -static const char *dsme_state_repr (dsme_state_t state); -static dsme_state_t dsme_state_parse (const char *name); - -static void dsme_state_update (dsme_state_t state); -static bool dsme_state_is_shutdown (void); -static bool dsme_state_is_user (void); +static const char *dsme_state_repr (dsme_state_t state); +static dsme_state_t dsme_state_parse (const char *name); +static void dsme_state_update (dsme_state_t state); +static bool dsme_state_is_shutdown(void); +static bool dsme_state_is_user (void); /* ------------------------------------------------------------------------- * - * DSME_SOCKET_IPC + * DSME_SOCKET * ------------------------------------------------------------------------- */ -static bool dsme_socket_send_message (void *msg); -static void dsme_socket_processwd_pong (void); -static void dsme_socket_processwd_init (void); -static void dsme_socket_processwd_quit (void); -static void dsme_socket_query_state (void); - -static gboolean dsme_socket_recv_cb (GIOChannel *source, GIOCondition condition, gpointer data); -static bool dsme_socket_is_connected (void); -static bool dsme_socket_connect (void); -static void dsme_socket_disconnect (void); +static bool dsme_socket_send_message (gpointer msg); +static void dsme_socket_processwd_pong(void); +static void dsme_socket_processwd_init(void); +static void dsme_socket_processwd_quit(void); +static void dsme_socket_query_state (void); +static gboolean dsme_socket_recv_cb (GIOChannel *source, GIOCondition condition, gpointer data); +static bool dsme_socket_is_connected (void); +static bool dsme_socket_connect (void); +static void dsme_socket_disconnect (void); /* ------------------------------------------------------------------------- * - * DSME_DBUS_IPC + * DSME_DBUS * ------------------------------------------------------------------------- */ -static void dsme_dbus_device_state_update (const char *state); -static void dsme_dbus_device_state_query_cb (DBusPendingCall *pending, void *aptr); -static void dsme_dbus_device_state_query (void); -static void dsme_dbus_device_state_cancel (void); -static void dsme_dbus_device_state_signal (DBusMessage *msg); - -static bool dsme_dbus_name_owner_available (void); -static void dsme_dbus_name_owner_update (const char *owner); -static void dsme_dbus_name_owner_query_cb (const char *owner); -static void dsme_dbus_name_owner_query (void); -static void dsme_dbus_name_owner_cancel (void); -static void dsme_dbus_name_owner_signal (DBusMessage *msg); - -static DBusHandlerResult dsme_dbus_filter_cb (DBusConnection *con, DBusMessage *msg, void *user_data); - -static bool dsme_dbus_init (void); -static void dsme_dbus_quit (void); +static void dsme_dbus_device_state_update (const char *state); +static void dsme_dbus_device_state_query_cb(DBusPendingCall *pending, void *aptr); +static void dsme_dbus_device_state_query (void); +static void dsme_dbus_device_state_cancel (void); +static void dsme_dbus_device_state_signal (DBusMessage *msg); +static bool dsme_dbus_name_owner_available (void); +static void dsme_dbus_name_owner_update (const char *owner); +static void dsme_dbus_name_owner_query_cb (const char *owner); +static void dsme_dbus_name_owner_query (void); +static void dsme_dbus_name_owner_cancel (void); +static void dsme_dbus_name_owner_signal (DBusMessage *msg); +static DBusHandlerResult dsme_dbus_filter_cb (DBusConnection *con, DBusMessage *msg, void *user_data); +static bool dsme_dbus_init (void); +static void dsme_dbus_quit (void); /* ------------------------------------------------------------------------- * - * MODULE_API + * DSME * ------------------------------------------------------------------------- */ -gboolean dsme_listener_start (void); -void dsme_listener_stop (void); -gboolean dsme_in_user_state (void); +gboolean dsme_start_listener(void); +void dsme_stop_listener(void); +gboolean dsme_in_user_state(void); /* ========================================================================= * * DSME_STATE_TRACKING @@ -858,7 +853,7 @@ dsme_dbus_quit(void) * ========================================================================= */ gboolean -dsme_listener_start(void) +dsme_start_listener(void) { LOG_REGISTER_CONTEXT; @@ -866,7 +861,7 @@ dsme_listener_start(void) } void -dsme_listener_stop(void) +dsme_stop_listener(void) { LOG_REGISTER_CONTEXT; diff --git a/src/usb_moded-dsme.h b/src/usb_moded-dsme.h index 11c3ff8..c7e6de1 100644 --- a/src/usb_moded-dsme.h +++ b/src/usb_moded-dsme.h @@ -1,7 +1,7 @@ /** * @file usb_moded-dsme.h * - * Copyright (C) 2013-2018 Jolla. All rights reserved. + * Copyright (C) 2013-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Simo Piiroinen @@ -34,10 +34,12 @@ * Prototypes * ========================================================================= */ -/* -- dsme -- */ +/* ------------------------------------------------------------------------- * + * DSME + * ------------------------------------------------------------------------- */ -gboolean dsme_listener_start(void); -void dsme_listener_stop (void); -gboolean dsme_in_user_state (void); +gboolean dsme_start_listener(void); +void dsme_stop_listener(void); +gboolean dsme_in_user_state(void); #endif /* USB_MODED_DSME_H_ */ diff --git a/src/usb_moded-dyn-config.c b/src/usb_moded-dyn-config.c index e7d99cf..1873b1d 100644 --- a/src/usb_moded-dyn-config.c +++ b/src/usb_moded-dyn-config.c @@ -2,7 +2,7 @@ * @file usb_moded-dyn-mode.c * * Copyright (C) 2011 Nokia Corporation. All rights reserved. - * Copyright (C) 2013-2018 Jolla. All rights reserved. + * Copyright (C) 2013-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Philippe De Swert @@ -36,13 +36,15 @@ * Prototypes * ========================================================================= */ -/* -- dynconfig -- */ +/* ------------------------------------------------------------------------- * + * UTILITY + * ------------------------------------------------------------------------- */ -void dynconfig_free_list_item(mode_list_elem_t *list_item); -void dynconfig_free_mode_list(GList *modelist); -static gint dynconfig_compare_modes (gconstpointer a, gconstpointer b); -GList *dynconfig_read_mode_list(int diag); -static mode_list_elem_t *dynconfig_read_mode_file(const gchar *filename); +void dynconfig_free_list_item(mode_list_elem_t *list_item); +void dynconfig_free_mode_list(GList *modelist); +static gint dynconfig_compare_modes (gconstpointer a, gconstpointer b); +GList *dynconfig_read_mode_list(int diag); +static mode_list_elem_t *dynconfig_read_mode_file(const gchar *filename); /* ========================================================================= * * Functions diff --git a/src/usb_moded-dyn-config.h b/src/usb_moded-dyn-config.h index ba79f01..2f6174b 100644 --- a/src/usb_moded-dyn-config.h +++ b/src/usb_moded-dyn-config.h @@ -1,7 +1,7 @@ /* * * Copyright (C) 2011 Nokia Corporation. All rights reserved. - * Copyright (C) 2013-2018 Jolla Ltd. + * Copyright (C) 2013-2019 Jolla Ltd. * * author: Philippe De Swert * author: Philippe De Swert @@ -125,7 +125,9 @@ typedef struct mode_list_elem_t * Prototypes * ========================================================================= */ -/* -- dynconfig -- */ +/* ------------------------------------------------------------------------- * + * UTILITY + * ------------------------------------------------------------------------- */ void dynconfig_free_list_item(mode_list_elem_t *list_item); void dynconfig_free_mode_list(GList *modelist); diff --git a/src/usb_moded-log.c b/src/usb_moded-log.c index b64e3c3..948e6f5 100644 --- a/src/usb_moded-log.c +++ b/src/usb_moded-log.c @@ -2,7 +2,7 @@ * @file usb_moded-log.c * * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2016-2018 Jolla Ltd. + * Copyright (C) 2016-2019 Jolla Ltd. * * @author: Philippe De Swert * @author: Simo Piiroinen @@ -39,7 +39,9 @@ * Prototypes * ========================================================================= */ -/* -- log -- */ +/* ------------------------------------------------------------------------- * + * LOG + * ------------------------------------------------------------------------- */ static char *log_strip (char *str); static void log_gettime (struct timeval *tv); diff --git a/src/usb_moded-log.h b/src/usb_moded-log.h index 79ad469..0eb4521 100644 --- a/src/usb_moded-log.h +++ b/src/usb_moded-log.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2016-2018 Jolla Ltd. + * Copyright (C) 2016-2019 Jolla Ltd. * * Author: Philippe De Swert * Author: Simo Piiroinen @@ -70,7 +70,9 @@ void context_leave(void *aptr); * Prototypes * ========================================================================= */ -/* -- log -- */ +/* ------------------------------------------------------------------------- * + * LOG + * ------------------------------------------------------------------------- */ void log_emit_va (const char *file, const char *func, int line, int lev, const char *fmt, va_list va); void log_emit_real (const char *file, const char *func, int line, int lev, const char *fmt, ...); diff --git a/src/usb_moded-mac.c b/src/usb_moded-mac.c index 2550051..7ea0830 100644 --- a/src/usb_moded-mac.c +++ b/src/usb_moded-mac.c @@ -1,7 +1,7 @@ /** * @file usb_moded-mac.c * - * Copyright (C) 2013-2018 Jolla. All rights reserved. + * Copyright (C) 2013-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Simo Piiroinen @@ -33,7 +33,9 @@ * Prototypes * ========================================================================= */ -/* -- mac -- */ +/* ------------------------------------------------------------------------- * + * MAC + * ------------------------------------------------------------------------- */ static void mac_random_ether_addr (unsigned char *addr); void mac_generate_random_mac(void); diff --git a/src/usb_moded-mac.h b/src/usb_moded-mac.h index 6cb9d78..626c123 100644 --- a/src/usb_moded-mac.h +++ b/src/usb_moded-mac.h @@ -1,7 +1,7 @@ /** * @file usb_moded-mac.h * - * Copyright (C) 2013-2018 Jolla. All rights reserved. + * Copyright (C) 2013-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Simo Piiroinen @@ -28,7 +28,9 @@ * Prototypes * ========================================================================= */ -/* -- mac -- */ +/* ------------------------------------------------------------------------- * + * MAC + * ------------------------------------------------------------------------- */ void mac_generate_random_mac(void); char *mac_read_mac (void); diff --git a/src/usb_moded-modesetting.c b/src/usb_moded-modesetting.c index 6c4d639..f2197c5 100644 --- a/src/usb_moded-modesetting.c +++ b/src/usb_moded-modesetting.c @@ -48,29 +48,44 @@ #include #include #include +#include /* ========================================================================= * - * Prototypes + * Types * ========================================================================= */ -/* -- modesetting -- */ - -static void modesetting_track_value (const char *path, const char *text); -void modesetting_verify_values (void); - -static char *modesetting_strip (char *str); -static char *modesetting_read_from_file (const char *path, size_t maxsize); -int modesetting_write_to_file_real (const char *file, int line, const char *func, const char *path, const char *text); - -static bool modesetting_enter_mass_storage_mode (mode_list_elem_t *data); -static int modesetting_leave_mass_storage_mode (mode_list_elem_t *data); -static void modesetting_report_mass_storage_blocker(const char *mountpoint, int try); +typedef struct storage_info_t +{ + gchar *si_mountpoint; + gchar *si_mountdevice;; +} storage_info_t; -bool modesetting_enter_dynamic_mode (void); -void modesetting_leave_dynamic_mode (void); +/* ========================================================================= * + * Prototypes + * ========================================================================= */ -void modesetting_init (void); -void modesetting_quit (void); +/* ------------------------------------------------------------------------- * + * MODESETTING + * ------------------------------------------------------------------------- */ + +static void modesetting_track_value (const char *path, const char *text); +void modesetting_verify_values (void); +static char *modesetting_strip (char *str); +static char *modesetting_read_from_file (const char *path, size_t maxsize); +int modesetting_write_to_file_real (const char *file, int line, const char *func, const char *path, const char *text); +bool modesetting_is_mounted (const char *mountpoint); +bool modesetting_mount (const char *mountpoint); +bool modesetting_unmount (const char *mountpoint); +static gchar *modesetting_mountdev (const char *mountpoint); +static void modesetting_free_storage_info (storage_info_t *info); +static storage_info_t *modesetting_get_storage_info (size_t *pcount); +static bool modesetting_enter_mass_storage_mode (mode_list_elem_t *data); +static int modesetting_leave_mass_storage_mode (mode_list_elem_t *data); +static void modesetting_report_mass_storage_blocker(const char *mountpoint, int try); +bool modesetting_enter_dynamic_mode (void); +void modesetting_leave_dynamic_mode (void); +void modesetting_init (void); +void modesetting_quit (void); /* ========================================================================= * * Data @@ -280,22 +295,6 @@ int modesetting_write_to_file_real(const char *file, int line, const char *func, return err; } -#include - -typedef struct storage_info_t -{ - gchar *si_mountpoint; - gchar *si_mountdevice;; -} storage_info_t; - -static void modesetting_free_storage_info(storage_info_t *info); -static storage_info_t * modesetting_get_storage_info(size_t *pcount); - -bool modesetting_is_mounted(const char *mountpoint); -bool modesetting_mount(const char *mountpoint); -bool modesetting_unmount(const char *mountpoint); -char *modesetting_mountdev(const char *mountpoint); - bool modesetting_is_mounted(const char *mountpoint) { LOG_REGISTER_CONTEXT; @@ -323,7 +322,7 @@ bool modesetting_unmount(const char *mountpoint) return common_system(cmd) == 0; } -gchar *modesetting_mountdev(const char *mountpoint) +static gchar *modesetting_mountdev(const char *mountpoint) { LOG_REGISTER_CONTEXT; diff --git a/src/usb_moded-modesetting.h b/src/usb_moded-modesetting.h index 4ae9c46..7c3a997 100644 --- a/src/usb_moded-modesetting.h +++ b/src/usb_moded-modesetting.h @@ -2,7 +2,7 @@ * @file usb_moded-modesetting.h * * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2013-2018 Jolla Ltd. + * Copyright (C) 2013-2019 Jolla Ltd. * * @author: Philippe De Swert * @author: Philippe De Swert @@ -35,10 +35,15 @@ * Prototypes * ========================================================================= */ -/* -- modesetting -- */ +/* ------------------------------------------------------------------------- * + * MODESETTING + * ------------------------------------------------------------------------- */ void modesetting_verify_values (void); int modesetting_write_to_file_real(const char *file, int line, const char *func, const char *path, const char *text); +bool modesetting_is_mounted (const char *mountpoint); +bool modesetting_mount (const char *mountpoint); +bool modesetting_unmount (const char *mountpoint); bool modesetting_enter_dynamic_mode(void); void modesetting_leave_dynamic_mode(void); void modesetting_init (void); diff --git a/src/usb_moded-modules.c b/src/usb_moded-modules.c index 156acef..a4df19d 100644 --- a/src/usb_moded-modules.c +++ b/src/usb_moded-modules.c @@ -2,7 +2,7 @@ * @file usb_moded-modules.c * * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2012-2018 Jolla. All rights reserved. + * Copyright (C) 2012-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Philippe De Swert @@ -42,13 +42,17 @@ * Prototypes * ========================================================================= */ -/* -- modules -- */ - -bool modules_init (void); -bool modules_in_use (void); -void modules_quit (void); -int modules_load_module (const char *module); -int modules_unload_module (const char *module); +/* ------------------------------------------------------------------------- * + * MODULES + * ------------------------------------------------------------------------- */ + +static bool modules_have_module (const char *module); +bool modules_in_use (void); +static bool modules_probe (void); +bool modules_init (void); +void modules_quit (void); +int modules_load_module (const char *module); +int modules_unload_module(const char *module); /* ========================================================================= * * Data diff --git a/src/usb_moded-modules.h b/src/usb_moded-modules.h index b53da16..b375e51 100644 --- a/src/usb_moded-modules.h +++ b/src/usb_moded-modules.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2013-2018 Jolla Ltd. + * Copyright (C) 2013-2019 Jolla Ltd. * * Author: Philippe De Swert * Author: Philippe De Swert @@ -46,12 +46,14 @@ * Prototypes * ========================================================================= */ -/* -- modules -- */ +/* ------------------------------------------------------------------------- * + * MODULES + * ------------------------------------------------------------------------- */ -bool modules_in_use (void); -bool modules_init (void); -void modules_quit (void); -int modules_load_module (const char *module); -int modules_unload_module (const char *module); +bool modules_in_use (void); +bool modules_init (void); +void modules_quit (void); +int modules_load_module (const char *module); +int modules_unload_module(const char *module); #endif /* USB_MODED_MODULES_H_ */ diff --git a/src/usb_moded-network.c b/src/usb_moded-network.c index cffb6f8..8f3c1b9 100644 --- a/src/usb_moded-network.c +++ b/src/usb_moded-network.c @@ -2,7 +2,7 @@ * @file usb-moded_network.c : (De)activates network depending on the network setting system. * * Copyright (C) 2011 Nokia Corporation. All rights reserved. - * Copyright (C) 2012-2018 Jolla. All rights reserved. + * Copyright (C) 2012-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Philippe De Swert @@ -73,7 +73,9 @@ typedef struct ipforward_data_t * Prototypes * ========================================================================= */ -/* -- network -- */ +/* ------------------------------------------------------------------------- * + * NETWORK + * ------------------------------------------------------------------------- */ static void network_free_ipforward_data (ipforward_data_t *ipforward); static int network_check_interface (char *interface); @@ -87,9 +89,22 @@ int network_up (mode_list_elem_t *data); int network_down (mode_list_elem_t *data); int network_update (void); -/* -- connman -- */ +/* ------------------------------------------------------------------------- * + * UTILITY + * ------------------------------------------------------------------------- */ + +#ifdef OFONO +static int get_roaming (void); +#endif // OFONO + +#if CONNMAN_WORKS_BETTER +static int append_variant(DBusMessageIter *iter, const char *property, int type, const char *value); +#endif // CONNMAN_WORKS_BETTER + +/* ------------------------------------------------------------------------- * + * CONNMAN + * ------------------------------------------------------------------------- */ -#ifdef CONNMAN static gboolean connman_try_set_tethering (DBusConnection *connection, const char *path, gboolean on); gboolean connman_set_tethering (const char *path, gboolean on); static char *connman_parse_manager_reply (DBusMessage *reply, const char *req_service); @@ -98,7 +113,6 @@ static int connman_set_cellular_online (DBusConnection *dbus_conn_connman, static int connman_wifi_power_control (DBusConnection *dbus_conn_connman, int on); static int connman_get_connection_data (ipforward_data_t *ipforward); static int connman_reset_state (void); -#endif /* ========================================================================= * * Data diff --git a/src/usb_moded-network.h b/src/usb_moded-network.h index 10166ce..1e0347a 100644 --- a/src/usb_moded-network.h +++ b/src/usb_moded-network.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2011 Nokia Corporation. All rights reserved. - * Copyright (C) 2013-2018 Jolla Ltd. + * Copyright (C) 2013-2019 Jolla Ltd. * * Author: Philippe De Swert * Author: Philippe De Swert @@ -33,13 +33,17 @@ * Prototypes * ========================================================================= */ -/* -- connman -- */ +/* ------------------------------------------------------------------------- * + * CONNMAN + * ------------------------------------------------------------------------- */ # ifdef CONNMAN gboolean connman_set_tethering(const char *path, gboolean on); # endif -/* -- network -- */ +/* ------------------------------------------------------------------------- * + * NETWORK + * ------------------------------------------------------------------------- */ int network_set_up_dhcpd(mode_list_elem_t *data); int network_up (mode_list_elem_t *data); diff --git a/src/usb_moded-sigpipe.c b/src/usb_moded-sigpipe.c index c464c7d..9a6d41f 100644 --- a/src/usb_moded-sigpipe.c +++ b/src/usb_moded-sigpipe.c @@ -2,7 +2,7 @@ * @file usb_moded-sigpipe.c * * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2012-2018 Jolla. All rights reserved. + * Copyright (C) 2012-2019 Jolla. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the Lesser GNU General Public License @@ -33,7 +33,9 @@ * Prototypes * ========================================================================= */ -/* -- sigpipe -- */ +/* ------------------------------------------------------------------------- * + * SIGPIPE + * ------------------------------------------------------------------------- */ static gboolean sigpipe_read_signal_cb(GIOChannel *channel, GIOCondition condition, gpointer data); static void sigpipe_trap_signal_cb(int sig); diff --git a/src/usb_moded-sigpipe.h b/src/usb_moded-sigpipe.h index e16488b..84a570d 100644 --- a/src/usb_moded-sigpipe.h +++ b/src/usb_moded-sigpipe.h @@ -2,7 +2,7 @@ * @file usb_moded-sigpipe.c * * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2012-2018 Jolla. All rights reserved. + * Copyright (C) 2012-2019 Jolla. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the Lesser GNU General Public License @@ -24,7 +24,13 @@ #include -/* -- sigpipe -- */ +/* ========================================================================= * + * Prototypes + * ========================================================================= */ + +/* ------------------------------------------------------------------------- * + * SIGPIPE + * ------------------------------------------------------------------------- */ bool sigpipe_init(void); diff --git a/src/usb_moded-ssu.c b/src/usb_moded-ssu.c index 4f1ca7e..731447e 100644 --- a/src/usb_moded-ssu.c +++ b/src/usb_moded-ssu.c @@ -1,7 +1,7 @@ /** * @file usb_moded-ssu.c * - * Copyright (C) 2016-2018 Jolla. All rights reserved. + * Copyright (C) 2016-2019 Jolla. All rights reserved. * * @author: Simo Piiroinen * @@ -33,7 +33,9 @@ * Prototypes * ========================================================================= */ -/* -- ssu -- */ +/* ------------------------------------------------------------------------- * + * SSU + * ------------------------------------------------------------------------- */ static void ssu_free_handle (void); static ssusysinfo_t *ssu_get_handle (void); diff --git a/src/usb_moded-ssu.h b/src/usb_moded-ssu.h index 81ab749..827d7af 100644 --- a/src/usb_moded-ssu.h +++ b/src/usb_moded-ssu.h @@ -1,7 +1,7 @@ /** * @file usb_moded-ssu.h * - * Copyright (C) 2016-2018 Jolla. All rights reserved. + * Copyright (C) 2016-2019 Jolla. All rights reserved. * * @author: Simo Piiroinen * @@ -29,7 +29,9 @@ * Prototypes * ========================================================================= */ -/* -- ssu -- */ +/* ------------------------------------------------------------------------- * + * SSU + * ------------------------------------------------------------------------- */ gchar *ssu_get_manufacturer_name(void); gchar *ssu_get_product_name (void); diff --git a/src/usb_moded-systemd.c b/src/usb_moded-systemd.c index 8e87a42..f411c36 100644 --- a/src/usb_moded-systemd.c +++ b/src/usb_moded-systemd.c @@ -1,7 +1,7 @@ /** * @file usb_moded-systemd.c * - * Copyright (C) 2013-2018 Jolla oy. All rights reserved. + * Copyright (C) 2013-2019 Jolla oy. All rights reserved. * * @author: Philippe De Swert * @author: Slava Monich @@ -39,7 +39,9 @@ * Prototypes * ========================================================================= */ -/* -- systemd -- */ +/* ------------------------------------------------------------------------- * + * SYSTEMD + * ------------------------------------------------------------------------- */ gboolean systemd_control_service(const char *name, const char *method); gboolean systemd_control_start (void); diff --git a/src/usb_moded-systemd.h b/src/usb_moded-systemd.h index d8c2a7e..faf80e0 100644 --- a/src/usb_moded-systemd.h +++ b/src/usb_moded-systemd.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2018 Jolla Oy. All rights reserved. + * Copyright (C) 2013-2019 Jolla Oy. All rights reserved. * * author: Philippe De Swert * author: Simo Piiroinen @@ -35,7 +35,9 @@ * Prototypes * ========================================================================= */ -/* -- systemd -- */ +/* ------------------------------------------------------------------------- * + * SYSTEMD + * ------------------------------------------------------------------------- */ gboolean systemd_control_service(const char *name, const char *method); gboolean systemd_control_start (void); diff --git a/src/usb_moded-trigger.c b/src/usb_moded-trigger.c index 7e0ef42..ce8da4c 100644 --- a/src/usb_moded-trigger.c +++ b/src/usb_moded-trigger.c @@ -2,7 +2,7 @@ * @file usb_moded-trigger.c * * Copyright (C) 2011 Nokia Corporation. All rights reserved. - * Copyright (C) 2014-2018 Jolla Ltd. + * Copyright (C) 2014-2019 Jolla Ltd. * * @author: Philippe De Swert * @author: Philippe De Swert @@ -40,13 +40,15 @@ * Prototypes * ========================================================================= */ -/* -- trigger -- */ +/* ------------------------------------------------------------------------- * + * TRIGGER + * ------------------------------------------------------------------------- */ static void trigger_udev_error_cb (gpointer data); -static gboolean trigger_udev_input_cb (GIOChannel *iochannel, GIOCondition cond, gpointer data); -static void trigger_parse_udev_properties(struct udev_device *dev); bool trigger_init (void); +static gboolean trigger_udev_input_cb (GIOChannel *iochannel, GIOCondition cond, gpointer data); void trigger_stop (void); +static void trigger_parse_udev_properties(struct udev_device *dev); /* ========================================================================= * * Data diff --git a/src/usb_moded-trigger.h b/src/usb_moded-trigger.h index 6a15980..d8c53ad 100644 --- a/src/usb_moded-trigger.h +++ b/src/usb_moded-trigger.h @@ -2,7 +2,7 @@ * @file usb_moded-trigger.h * * Copyright (C) 2011 Nokia Corporation. All rights reserved. - * Copyright (C) 2018 Jolla Ltd. + * Copyright (C) 2018-2019 Jolla Ltd. * * @author: Philippe De Swert * @author: Simo Piiroinen @@ -31,9 +31,11 @@ * Prototypes * ========================================================================= */ -/* -- trigger -- */ +/* ------------------------------------------------------------------------- * + * TRIGGER + * ------------------------------------------------------------------------- */ -bool trigger_init(void); -void trigger_stop(void); +bool trigger_init(void); +void trigger_stop(void); #endif /* USB_MODED_TRIGGER_H_ */ diff --git a/src/usb_moded-udev.c b/src/usb_moded-udev.c index d66fb48..8e76e21 100644 --- a/src/usb_moded-udev.c +++ b/src/usb_moded-udev.c @@ -42,7 +42,9 @@ * Prototypes * ========================================================================= */ -/* -- umudev -- */ +/* ------------------------------------------------------------------------- * + * UMUDEV + * ------------------------------------------------------------------------- */ static gboolean umudev_cable_state_timer_cb (gpointer aptr); static void umudev_cable_state_stop_timer (void); @@ -51,14 +53,13 @@ static bool umudev_cable_state_connected (void); static cable_state_t umudev_cable_state_get (void); static void umudev_cable_state_set (cable_state_t state); static void umudev_cable_state_changed (void); -static void umudev_cable_state_from_udev (cable_state_t state); - -static void umudev_io_error_cb (gpointer data); -static gboolean umudev_io_input_cb (GIOChannel *iochannel, GIOCondition cond, gpointer data); -static void umudev_parse_properties (struct udev_device *dev, bool initial); -static int umudev_score_as_power_supply(const char *syspath); -gboolean umudev_init (void); -void umudev_quit (void); +static void umudev_cable_state_from_udev (cable_state_t curr); +static void umudev_io_error_cb (gpointer data); +static gboolean umudev_io_input_cb (GIOChannel *iochannel, GIOCondition cond, gpointer data); +static void umudev_parse_properties (struct udev_device *dev, bool initial); +static int umudev_score_as_power_supply (const char *syspath); +gboolean umudev_init (void); +void umudev_quit (void); /* ========================================================================= * * Data diff --git a/src/usb_moded-udev.h b/src/usb_moded-udev.h index 8039fd1..3ccd814 100644 --- a/src/usb_moded-udev.h +++ b/src/usb_moded-udev.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2018 Jolla Ltd. + * Copyright (C) 2018-2019 Jolla Ltd. * * Author: Philippe De Swert * @author: Simo Piiroinen @@ -36,7 +36,9 @@ * Prototypes * ========================================================================= */ -/* -- umudev -- */ +/* ------------------------------------------------------------------------- * + * UMUDEV + * ------------------------------------------------------------------------- */ gboolean umudev_init(void); void umudev_quit(void); diff --git a/src/usb_moded-util.c b/src/usb_moded-util.c index 2e74838..235c118 100644 --- a/src/usb_moded-util.c +++ b/src/usb_moded-util.c @@ -1,7 +1,7 @@ /** * @file usb_moded-util.c * - * Copyright (C) 2013-2018 Jolla. All rights reserved. + * Copyright (C) 2013-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Philippe De Swert @@ -34,7 +34,9 @@ * Prototypes * ========================================================================= */ -/* -- util -- */ +/* ------------------------------------------------------------------------- * + * UTIL + * ------------------------------------------------------------------------- */ static int util_query_mode (void); static int util_get_modelist (void); @@ -47,6 +49,12 @@ static int util_set_unhide_mode_config(char *mode); static int util_get_hiddenlist (void); static int util_handle_network (char *network); +/* ------------------------------------------------------------------------- * + * MAIN + * ------------------------------------------------------------------------- */ + +int main(int argc, char *argv[]); + /* ========================================================================= * * Data * ========================================================================= */ diff --git a/src/usb_moded-worker.c b/src/usb_moded-worker.c index e93bb3f..f5cfc2c 100644 --- a/src/usb_moded-worker.c +++ b/src/usb_moded-worker.c @@ -1,7 +1,7 @@ /** * @file usb_moded-worker.c * - * Copyright (C) 2013-2018 Jolla. All rights reserved. + * Copyright (C) 2013-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Simo Piiroinen @@ -44,39 +44,43 @@ * Prototypes * ========================================================================= */ -/* -- worker -- */ - -static bool worker_thread_p (void); -bool worker_bailing_out (void); -static bool worker_mode_is_mtp_mode (const char *mode); -static bool worker_is_mtpd_running (void); -static bool worker_stop_mtpd (void); -static bool worker_start_mtpd (void); -static bool worker_switch_to_charging (void); -const char *worker_get_kernel_module (void); -bool worker_set_kernel_module (const char *module); -void worker_clear_kernel_module (void); -mode_list_elem_t *worker_get_usb_mode_data (void); -void worker_set_usb_mode_data (mode_list_elem_t *data); -static const char *worker_get_activated_mode_locked(void); -static bool worker_set_activated_mode_locked(const char *mode); -static const char *worker_get_requested_mode_locked(void); -static bool worker_set_requested_mode_locked(const char *mode); -void worker_request_hardware_mode (const char *mode); -void worker_clear_hardware_mode (void); -static void worker_execute (void); -void worker_switch_to_mode (const char *mode); -static guint worker_add_iowatch (int fd, bool close_on_unref, GIOCondition cnd, GIOFunc io_cb, gpointer aptr); -static void *worker_thread_cb (void *aptr); -static gboolean worker_notify_cb (GIOChannel *chn, GIOCondition cnd, gpointer data); -static bool worker_start_thread (void); -static void worker_stop_thread (void); -static void worker_delete_eventfd (void); -static bool worker_create_eventfd (void); -bool worker_init (void); -void worker_quit (void); -void worker_wakeup (void); -static void worker_notify (void); +/* ------------------------------------------------------------------------- * + * WORKER + * ------------------------------------------------------------------------- */ + +static bool worker_thread_p (void); +bool worker_bailing_out (void); +static bool worker_mode_is_mtp_mode (const char *mode); +static bool worker_is_mtpd_running (void); +static bool worker_mtpd_running_p (void *aptr); +static bool worker_mtpd_stopped_p (void *aptr); +static bool worker_stop_mtpd (void); +static bool worker_start_mtpd (void); +static bool worker_switch_to_charging (void); +const char *worker_get_kernel_module (void); +bool worker_set_kernel_module (const char *module); +void worker_clear_kernel_module (void); +mode_list_elem_t *worker_get_usb_mode_data (void); +void worker_set_usb_mode_data (mode_list_elem_t *data); +static const char *worker_get_activated_mode_locked(void); +static bool worker_set_activated_mode_locked(const char *mode); +static const char *worker_get_requested_mode_locked(void); +static bool worker_set_requested_mode_locked(const char *mode); +void worker_request_hardware_mode (const char *mode); +void worker_clear_hardware_mode (void); +static void worker_execute (void); +void worker_switch_to_mode (const char *mode); +static guint worker_add_iowatch (int fd, bool close_on_unref, GIOCondition cnd, GIOFunc io_cb, gpointer aptr); +static void *worker_thread_cb (void *aptr); +static gboolean worker_notify_cb (GIOChannel *chn, GIOCondition cnd, gpointer data); +static bool worker_start_thread (void); +static void worker_stop_thread (void); +static void worker_delete_eventfd (void); +static bool worker_create_eventfd (void); +bool worker_init (void); +void worker_quit (void); +void worker_wakeup (void); +static void worker_notify (void); /* ========================================================================= * * Data diff --git a/src/usb_moded-worker.h b/src/usb_moded-worker.h index db958ac..89e2e9f 100644 --- a/src/usb_moded-worker.h +++ b/src/usb_moded-worker.h @@ -1,7 +1,7 @@ /** * @file usb_moded-worker.h * - * Copyright (C) 2013-2018 Jolla. All rights reserved. + * Copyright (C) 2013-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Simo Piiroinen @@ -36,19 +36,21 @@ * Prototypes * ========================================================================= */ -/* -- worker -- */ - -bool worker_bailing_out (void); -const char *worker_get_kernel_module (void); -bool worker_set_kernel_module (const char *module); -void worker_clear_kernel_module (void); -mode_list_elem_t *worker_get_usb_mode_data (void); -void worker_set_usb_mode_data (mode_list_elem_t *data); -void worker_request_hardware_mode(const char *mode); -void worker_clear_hardware_mode (void); -void worker_switch_to_mode (const char *mode); -bool worker_init (void); -void worker_quit (void); -void worker_wakeup (void); +/* ------------------------------------------------------------------------- * + * WORKER + * ------------------------------------------------------------------------- */ + +bool worker_bailing_out (void); +const char *worker_get_kernel_module (void); +bool worker_set_kernel_module (const char *module); +void worker_clear_kernel_module (void); +mode_list_elem_t *worker_get_usb_mode_data (void); +void worker_set_usb_mode_data (mode_list_elem_t *data); +void worker_request_hardware_mode(const char *mode); +void worker_clear_hardware_mode (void); +void worker_switch_to_mode (const char *mode); +bool worker_init (void); +void worker_quit (void); +void worker_wakeup (void); #endif /* USB_MODED_WORKER_H_ */ diff --git a/src/usb_moded.c b/src/usb_moded.c index 99e9d89..03995d9 100644 --- a/src/usb_moded.c +++ b/src/usb_moded.c @@ -102,7 +102,9 @@ * Prototypes * ========================================================================= */ -/* -- usbmoded -- */ +/* ------------------------------------------------------------------------- * + * USBMODED + * ------------------------------------------------------------------------- */ GList *usbmoded_get_modelist (void); void usbmoded_load_modelist (void); @@ -116,10 +118,10 @@ int usbmoded_get_cable_connection_delay(void); static gboolean usbmoded_allow_suspend_timer_cb (gpointer aptr); void usbmoded_allow_suspend (void); void usbmoded_delay_suspend (void); +bool usbmoded_can_export (void); bool usbmoded_init_done_p (void); void usbmoded_set_init_done (bool reached); void usbmoded_probe_init_done (void); -bool usbmoded_can_export (void); void usbmoded_exit_mainloop (int exitcode); void usbmoded_handle_signal (int signum); static bool usbmoded_init (void); @@ -127,6 +129,12 @@ static void usbmoded_cleanup (void); static void usbmoded_usage (void); static void usbmoded_parse_options (int argc, char *argv[]); +/* ------------------------------------------------------------------------- * + * MAIN + * ------------------------------------------------------------------------- */ + +int main(int argc, char *argv[]); + /* ========================================================================= * * Data * ========================================================================= */ @@ -520,7 +528,7 @@ static bool usbmoded_init(void) /* DSME listener maintains in-user-mode state and is relevant * only when MEEGOLOCK configure option has been chosen. */ #ifdef MEEGOLOCK - if( !dsme_listener_start() ) { + if( !dsme_start_listener() ) { log_crit("dsme tracking could not be started"); goto EXIT; } @@ -674,7 +682,7 @@ static void usbmoded_cleanup(void) /* Stop tracking device state */ #ifdef MEEGOLOCK - dsme_listener_stop(); + dsme_stop_listener(); #endif /* Stop udev listener */ diff --git a/src/usb_moded.h b/src/usb_moded.h index 6ab0094..c5b8e2d 100644 --- a/src/usb_moded.h +++ b/src/usb_moded.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2010 Nokia Corporation. All rights reserved. - * Copyright (C) 2012-2018 Jolla. All rights reserved. + * Copyright (C) 2012-2019 Jolla. All rights reserved. * * @author: Philippe De Swert * @author: Philippe De Swert @@ -57,10 +57,12 @@ (USB_MODED_SUSPEND_DELAY_DEFAULT_MS * 2) /* ========================================================================= * - * Functions + * Prototypes * ========================================================================= */ -/* -- usbmoded -- */ +/* ------------------------------------------------------------------------- * + * USBMODED + * ------------------------------------------------------------------------- */ GList *usbmoded_get_modelist (void); void usbmoded_load_modelist (void); @@ -73,11 +75,17 @@ void usbmoded_set_cable_connection_delay(int delay_ms); int usbmoded_get_cable_connection_delay(void); void usbmoded_allow_suspend (void); void usbmoded_delay_suspend (void); +bool usbmoded_can_export (void); bool usbmoded_init_done_p (void); void usbmoded_set_init_done (bool reached); void usbmoded_probe_init_done (void); -bool usbmoded_can_export (void); void usbmoded_exit_mainloop (int exitcode); void usbmoded_handle_signal (int signum); +/* ------------------------------------------------------------------------- * + * MAIN + * ------------------------------------------------------------------------- */ + +int main(int argc, char *argv[]); + #endif /* USB_MODED_H_ */