usb_moded 0.86.0+mer64
usb_moded-common.h File Reference
#include <stdio.h>
#include <stdbool.h>
#include <glib.h>

Go to the source code of this file.

Typedefs

typedef enum mode_list_type_t mode_list_type_t
 

Enumerations

enum  mode_list_type_t { SUPPORTED_MODES_LIST , AVAILABLE_MODES_LIST }
 

Functions

void common_send_supported_modes_signal (void)
 
void common_send_available_modes_signal (void)
 
void common_send_hidden_modes_signal (void)
 
void common_send_whitelisted_modes_signal (void)
 
void common_acquire_wakelock (const char *wakelock_name)
 
void common_release_wakelock (const char *wakelock_name)
 
int common_system_ (const char *file, int line, const char *func, const char *command)
 
FILE * common_popen_ (const char *file, int line, const char *func, const char *command, const char *type)
 
bool common_msleep_ (const char *file, int line, const char *func, unsigned msec)
 
bool common_modename_is_internal (const char *modename)
 
bool common_modename_is_static (const char *modename)
 
int common_valid_mode (const char *mode)
 
gchar * common_get_mode_list (mode_list_type_t type, uid_t uid)
 

Detailed Description

Copyright (c) 2010 Nokia Corporation. All rights reserved. Copyright (c) 2012 - 2021 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 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-common.h.

Typedef Documentation

◆ mode_list_type_t

Mode list types

Enumeration Type Documentation

◆ mode_list_type_t

Mode list types

Enumerator
SUPPORTED_MODES_LIST 

All configured modes

AVAILABLE_MODES_LIST 

Configured modes that can be activated

Definition at line 40 of file usb_moded-common.h.

Function Documentation

◆ common_acquire_wakelock()

void common_acquire_wakelock ( const char * wakelock_name)

Acquire wakelock via sysfs

Wakelock must be released via common_release_wakelock().

Automatically terminating wakelock is used, so that we do not block suspend indefinately in case usb_moded gets stuck or crashes.

Note: The name should be unique within the system.

Parameters
wakelock_nameWake lock to be acquired

Definition at line 324 of file usb_moded-common.c.

◆ common_get_mode_list()

gchar * common_get_mode_list ( mode_list_type_t type,
uid_t uid )

make a list of all available usb modes

Parameters
typeThe type of list to return. Supported or available.
uidUid of the process requesting the information; this is used to limit allowed modes, 0 returns all
Returns
a comma-separated list of modes (MODE_ASK not included as it is not a real mode)

Definition at line 575 of file usb_moded-common.c.

◆ common_modename_is_internal()

bool common_modename_is_internal ( const char * modename)

Check if given usb mode is internal

Parameters
modenamename of a more
Returns
true if mode is internal, false otherwise

Definition at line 504 of file usb_moded-common.c.

◆ common_modename_is_static()

bool common_modename_is_static ( const char * modename)

Check if given usb mode is static

Parameters
modenamename of a more
Returns
true if mode is static, false otherwise

Definition at line 520 of file usb_moded-common.c.

◆ common_msleep_()

bool common_msleep_ ( const char * file,
int line,
const char * func,
unsigned msec )

Wrapper to give visibility to blocking sleeps usb-moded is making

Definition at line 466 of file usb_moded-common.c.

◆ common_popen_()

FILE * common_popen_ ( const char * file,
int line,
const char * func,
const char * command,
const char * type )

Wrapper to give visibility subprocesses usb-moded is invoking via popen()

Definition at line 404 of file usb_moded-common.c.

◆ common_release_wakelock()

void common_release_wakelock ( const char * wakelock_name)

Release wakelock via sysfs

Parameters
wakelock_nameWake lock to be released

Definition at line 343 of file usb_moded-common.c.

◆ common_send_available_modes_signal()

void common_send_available_modes_signal ( void )

Send available modes signal

Definition at line 241 of file usb_moded-common.c.

◆ common_send_hidden_modes_signal()

void common_send_hidden_modes_signal ( void )

Send hidden modes signal

Definition at line 252 of file usb_moded-common.c.

◆ common_send_supported_modes_signal()

void common_send_supported_modes_signal ( void )

Send supported modes signal

Definition at line 230 of file usb_moded-common.c.

◆ common_send_whitelisted_modes_signal()

void common_send_whitelisted_modes_signal ( void )

Send whitelisted modes signal

Definition at line 263 of file usb_moded-common.c.

◆ common_system_()

int common_system_ ( const char * file,
int line,
const char * func,
const char * command )

Wrapper to give visibility to blocking system() calls usb-moded is making

Definition at line 361 of file usb_moded-common.c.

◆ common_valid_mode()

int common_valid_mode ( const char * mode)

check if a given usb_mode exists

Parameters
modeThe mode to look for
Returns
0 if mode exists, 1 if it does not exist

Definition at line 536 of file usb_moded-common.c.