usb_moded 0.86.0+mer64
usb_moded-control.c File Reference

Go to the source code of this file.

Macros

#define CONTROL_PENDING_USER_CHANGE_TIMEOUT   (3000)
 

Functions

uid_t control_get_user_for_mode (void)
 
void control_set_user_for_mode (uid_t uid)
 
const char * control_get_selected_mode (void)
 
void control_set_selected_mode (const char *mode)
 
bool control_select_mode (const char *mode)
 
const char * control_get_usb_mode (void)
 
void control_user_changed (void)
 
void control_device_lock_changed (void)
 
void control_device_state_changed (void)
 
void control_settings_changed (void)
 
void control_init_done_changed (void)
 
void control_set_enabled (bool enable)
 
void control_set_cable_state (cable_state_t cable_state)
 
cable_state_t control_get_cable_state (void)
 
bool control_get_connection_state (void)
 

Detailed Description

Copyright (c) 2013 - 2021 Jolla Ltd. Copyright (c) 2020 Open Mobile Platform LLC.

Author
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-control.c.

Macro Definition Documentation

◆ CONTROL_PENDING_USER_CHANGE_TIMEOUT

#define CONTROL_PENDING_USER_CHANGE_TIMEOUT   (3000)

How long to wait for device lock after user change [ms]

If device lock code is in use, the wait time needs to be long enough to cover user session change and subsequent device locking (ballpark 500 ms) and reasonable amount of variance caused by slower devices etc.

If device lock code is not in use, the wait is not terminated by device lock status changes and thus the time needs to be short enough not to cause confusion at user end.

Definition at line 53 of file usb_moded-control.c.

Function Documentation

◆ control_device_lock_changed()

void control_device_lock_changed ( void )

React to device lock state changes

Definition at line 479 of file usb_moded-control.c.

◆ control_device_state_changed()

void control_device_state_changed ( void )

React to device state changes

Definition at line 492 of file usb_moded-control.c.

◆ control_get_cable_state()

cable_state_t control_get_cable_state ( void )

get the usb connection status

Returns
CABLE_STATE_DISCONNECTED, ...

Definition at line 852 of file usb_moded-control.c.

◆ control_get_connection_state()

bool control_get_connection_state ( void )

Get if the cable (pc or charger) is connected or not

@ return true if connected, false if disconnected

Definition at line 870 of file usb_moded-control.c.

◆ control_get_selected_mode()

const char * control_get_selected_mode ( void )

get mode selected by user

Returns
selected mode, or NULL in case nothing is selected

Definition at line 287 of file usb_moded-control.c.

◆ control_get_usb_mode()

const char * control_get_usb_mode ( void )

get the usb mode

Returns
the currently set mode

Definition at line 332 of file usb_moded-control.c.

◆ control_get_user_for_mode()

uid_t control_get_user_for_mode ( void )

Get uid of the user that set the current mode

Returns
uid of user when current mode was set

Definition at line 157 of file usb_moded-control.c.

◆ control_init_done_changed()

void control_init_done_changed ( void )

React to init-done changes

Definition at line 511 of file usb_moded-control.c.

◆ control_select_mode()

bool control_select_mode ( const char * mode)

handle mode request from client / udev trigger

Parameters
modeThe requested USB mode
Returns
true if mode was accepted, false otherwise

Definition at line 313 of file usb_moded-control.c.

◆ control_set_cable_state()

void control_set_cable_state ( cable_state_t cable_state)

set the usb connection status

Parameters
cable_stateCABLE_STATE_DISCONNECTED, ...

Definition at line 828 of file usb_moded-control.c.

◆ control_set_enabled()

void control_set_enabled ( bool enable)

Enable/disable mode changes

Definition at line 527 of file usb_moded-control.c.

◆ control_set_selected_mode()

void control_set_selected_mode ( const char * mode)

set mode selected by user

Parameters
modeselected mode, or NULL to reset selection

Definition at line 297 of file usb_moded-control.c.

◆ control_set_user_for_mode()

void control_set_user_for_mode ( uid_t uid)

Set the uid of the user that set the current mode

Parameters
uidof current user

Definition at line 167 of file usb_moded-control.c.

◆ control_settings_changed()

void control_settings_changed ( void )

React to settings changes

Definition at line 502 of file usb_moded-control.c.

◆ control_user_changed()

void control_user_changed ( void )

React to current user change

Definition at line 451 of file usb_moded-control.c.