usb_moded  0.86.0+mer57
Data Structures | Typedefs | Functions
usb_moded-common.c File Reference
#include "usb_moded-common.h"
#include "usb_moded.h"
#include "usb_moded-config-private.h"
#include "usb_moded-dbus-private.h"
#include "usb_moded-log.h"
#include "usb_moded-modes.h"
#include "usb_moded-worker.h"
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>

Go to the source code of this file.

Data Structures

struct  modemapping_t
 

Typedefs

typedef struct modemapping_t modemapping_t
 

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

Typedef Documentation

◆ modemapping_t

typedef struct modemapping_t modemapping_t

Mapping usb mode from internal to hardware/broadcast use

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 323 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 574 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 503 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 519 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 465 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 403 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 342 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 240 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 251 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 229 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 262 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 360 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 535 of file usb_moded-common.c.