usb_moded 0.86.0+mer64
usb_moded-appsync.h File Reference
#include <stdbool.h>

Go to the source code of this file.

Functions

void appsync_switch_configuration (void)
void appsync_free_configuration (void)
void appsync_load_configuration (void)
int appsync_activate_pre (const char *mode)
int appsync_activate_post (const char *mode)
int appsync_mark_active (const char *name, int post)
void appsync_deactivate_pre (void)
void appsync_deactivate_post (void)
void appsync_deactivate_all (bool force)

Detailed Description

Copyright (c) 2010 Nokia Corporation. All rights reserved. Copyright (c) 2013 - 2020 Jolla Ltd. Copyright (c) 2020 Open Mobile Platform LLC.

Author
Philippe De Swert phili.nosp@m.ppe..nosp@m.de-sw.nosp@m.ert@.nosp@m.nokia.nosp@m..com
Philippe De Swert phdes.nosp@m.wer@.nosp@m.lumi..nosp@m.maa
Philippe De Swert phili.nosp@m.pped.nosp@m.eswer.nosp@m.t@gm.nosp@m.ail.c.nosp@m.om
Philippe De Swert phili.nosp@m.ppe..nosp@m.deswe.nosp@m.rt@j.nosp@m.ollam.nosp@m.obil.nosp@m.e.com
Simo Piiroinen simo..nosp@m.piir.nosp@m.oinen.nosp@m.@jol.nosp@m.lamob.nosp@m.ile..nosp@m.com

This program is free software; you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the Lesser GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Definition in file usb_moded-appsync.h.

Function Documentation

◆ appsync_activate_post()

int appsync_activate_post ( const char * mode)

Activate post-enum applications for given mode

Starts all configured applications that have matching mode trigger and are scheduled to occur after usb enumeration.

Parameters
modeName of usb-mode
Returns
0 on succes, or 1 in case of failures

Definition at line 551 of file usb_moded-appsync.c.

◆ appsync_activate_pre()

int appsync_activate_pre ( const char * mode)

Activate pre-enum applications for given mode

Starts all configured applications that have matching mode trigger and are scheduled to occur before usb enumeration.

Parameters
modeName of usb-mode
Returns
0 on succes, or 1 in case of failures

Definition at line 426 of file usb_moded-appsync.c.

◆ appsync_deactivate_all()

void appsync_deactivate_all ( bool force)

Stop all applications that (could) have been started by usb-moded

Parameters
force0=started apps, 1=all configured apps

Normally, when force=0 is used, this function is used on mode exit to stop applications that are known to have been started on mode entry.

Using force=1 param is mainly useful during usb-moded startup, as a way to cleanup applications that might have been left running as a concequence of for example usb-moded crash.

Definition at line 824 of file usb_moded-appsync.c.

◆ appsync_deactivate_post()

void appsync_deactivate_post ( void )

Stop all applications that were started in post-enum phase

Definition at line 806 of file usb_moded-appsync.c.

◆ appsync_deactivate_pre()

void appsync_deactivate_pre ( void )

Stop all applications that were started in pre-enum phase

Definition at line 797 of file usb_moded-appsync.c.

◆ appsync_free_configuration()

void appsync_free_configuration ( void )

Release appsync configuration data

Definition at line 347 of file usb_moded-appsync.c.

◆ appsync_load_configuration()

void appsync_load_configuration ( void )

Load appsync configuration data

Appsync configuration files are read on usb-moded startup and whenever SIGHUP is sent to usb-moded.

Appsync configuration data is stateful and accessed both from worker and control threads. Due to this special care must be taken when configuration changes due to SIGHUP. Freshly loaded data is set aside and taken in use by calling appsync_switch_configuration() in an apprioriate time - presently when worker thread is executing mode transition and has cleaned up previously active usb mode.

Definition at line 380 of file usb_moded-appsync.c.

◆ appsync_mark_active()

int appsync_mark_active ( const char * name,
int post )

Set application state as successfully started

Parameters
nameApplication name
post0=pre-enum app, or 1=post-enum app

Update bookkeeping so that applications that are started when a mode is activated can be stopped when the mode is deactivated later on.

See also
appsync_deactivate_pre(), appsync_deactivate_post(), and appsync_deactivate_all()

Note: If usb-moded is configured to use APP_SYNC_DBUS, usb enumeration actions are triggered when the last pre-enum app gets marked as active.

Returns
0 on success, or -1 on failure

Definition at line 690 of file usb_moded-appsync.c.

◆ appsync_switch_configuration()

void appsync_switch_configuration ( void )

Take previously loaded appsync configuration in use

Definition at line 328 of file usb_moded-appsync.c.