Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
usb-moded
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mer-core
usb-moded
Commits
22a0f778
Commit
22a0f778
authored
Apr 01, 2016
by
martinjones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[hidden modes] Add interface to get list of hidden modes. Contributes to MER#1540
parent
1bcc68ee
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
103 additions
and
12 deletions
+103
-12
docs/usb_moded-doc.txt
docs/usb_moded-doc.txt
+1
-1
src/com.meego.usb_moded.xml
src/com.meego.usb_moded.xml
+14
-0
src/usb_moded-config-private.h
src/usb_moded-config-private.h
+1
-0
src/usb_moded-config.c
src/usb_moded-config.c
+14
-7
src/usb_moded-dbus-private.h
src/usb_moded-dbus-private.h
+3
-0
src/usb_moded-dbus.c
src/usb_moded-dbus.c
+21
-0
src/usb_moded-dbus.h
src/usb_moded-dbus.h
+2
-0
src/usb_moded-modes.h
src/usb_moded-modes.h
+1
-0
src/usb_moded-util.c
src/usb_moded-util.c
+35
-4
src/usb_moded.c
src/usb_moded.c
+11
-0
No files found.
docs/usb_moded-doc.txt
View file @
22a0f778
...
...
@@ -415,4 +415,4 @@ For example
hide=developer_mode,bastard_mode
Modes can also be set and removed through dbus (one mode at a time)
See usb_moded_util (-i and -u)
See usb_moded_util (-
v, -
i and -u)
src/com.meego.usb_moded.xml
View file @
22a0f778
...
...
@@ -30,6 +30,17 @@
<method
name=
"get_modes"
>
<arg
name=
"modes"
type=
"s"
direction=
"out"
/>
</method>
<method
name=
"hide_mode"
>
<arg
name=
"mode"
type=
"s"
direction=
"in"
/>
<arg
name=
"mode"
type=
"s"
direction=
"out"
/>
</method>
<method
name=
"unhide_mode"
>
<arg
name=
"mode"
type=
"s"
direction=
"in"
/>
<arg
name=
"mode"
type=
"s"
direction=
"out"
/>
</method>
<method
name=
"get_hidden"
>
<arg
name=
"modes"
type=
"s"
direction=
"out"
/>
</method>
<method
name=
"rescue_off"
/>
<signal
name=
"sig_usb_state_ind"
>
<arg
name=
"mode"
type=
"s"
/>
...
...
@@ -45,5 +56,8 @@
<arg
name=
"key"
type=
"s"
/>
<arg
name=
"value"
type=
"s"
/>
</signal>
<signal
name=
"sig_usb_hidden_modes_ind"
>
<arg
name=
"modes"
type=
"s"
/>
</signal>
</interface>
</node>
src/usb_moded-config-private.h
View file @
22a0f778
...
...
@@ -28,4 +28,5 @@ char * get_mode_setting(void);
set_config_result_t
set_mode_setting
(
const
char
*
mode
);
set_config_result_t
set_hide_mode_setting
(
const
char
*
mode
);
set_config_result_t
set_unhide_mode_setting
(
const
char
*
mode
);
char
*
get_hidden_modes
(
void
);
set_config_result_t
set_network_setting
(
const
char
*
config
,
const
char
*
setting
);
src/usb_moded-config.c
View file @
22a0f778
...
...
@@ -434,6 +434,8 @@ static const char * make_hidden_modes_string(const char *hidden, int hide)
for
(
i
=
0
;
hidden_mode_split
[
i
]
!=
NULL
;
i
++
)
{
if
(
strlen
(
hidden_mode_split
[
i
])
==
0
)
continue
;
if
(
!
strcmp
(
hidden_mode_split
[
i
],
hidden
))
{
/* if hiding a mode that is already hidden do nothing */
...
...
@@ -442,13 +444,14 @@ static const char * make_hidden_modes_string(const char *hidden, int hide)
if
(
!
hide
)
continue
;
}
if
(
strlen
(
modelist_str
->
str
)
!=
0
)
modelist_str
=
g_string_append
(
modelist_str
,
","
);
modelist_str
=
g_string_append
(
modelist_str
,
hidden_mode_split
[
i
]);
if
(
hidden_mode_split
[
i
+
1
]
!=
NULL
)
modelist_str
=
g_string_append
(
modelist_str
,
","
);
}
if
(
hide
)
{
modelist_str
=
g_string_append
(
modelist_str
,
","
);
if
(
strlen
(
modelist_str
->
str
)
!=
0
)
modelist_str
=
g_string_append
(
modelist_str
,
","
);
modelist_str
=
g_string_append
(
modelist_str
,
hidden
);
}
...
...
@@ -461,8 +464,10 @@ set_config_result_t set_hide_mode_setting(const char *mode)
set_config_result_t
ret
;
ret
=
set_config_setting
(
MODE_SETTING_ENTRY
,
MODE_HIDE_KEY
,
make_hidden_modes_string
(
mode
,
1
));
if
(
ret
==
SET_CONFIG_UPDATED
)
send_supported_modes_signal
();
if
(
ret
==
SET_CONFIG_UPDATED
)
{
send_hidden_modes_signal
();
send_supported_modes_signal
();
}
return
(
ret
);
}
...
...
@@ -471,8 +476,10 @@ set_config_result_t set_unhide_mode_setting(const char *mode)
set_config_result_t
ret
;
ret
=
set_config_setting
(
MODE_SETTING_ENTRY
,
MODE_HIDE_KEY
,
make_hidden_modes_string
(
mode
,
0
));
if
(
ret
==
SET_CONFIG_UPDATED
)
send_supported_modes_signal
();
if
(
ret
==
SET_CONFIG_UPDATED
)
{
send_hidden_modes_signal
();
send_supported_modes_signal
();
}
return
(
ret
);
}
...
...
src/usb_moded-dbus-private.h
View file @
22a0f778
...
...
@@ -32,3 +32,6 @@ int usb_moded_send_error_signal(const char *error);
/* send supported modes signal system bus */
int
usb_moded_send_supported_modes_signal
(
const
char
*
supported_modes
);
/* send hidden modes signal system bus */
int
usb_moded_send_hidden_modes_signal
(
const
char
*
hidden_modes
);
src/usb_moded-dbus.c
View file @
22a0f778
...
...
@@ -244,6 +244,15 @@ error_reply:
}
dbus_error_free
(
&
err
);
}
else
if
(
!
strcmp
(
member
,
USB_MODE_HIDDEN_GET
))
{
char
*
config
=
get_hidden_modes
();
if
(
!
config
)
config
=
strdup
(
""
);
if
((
reply
=
dbus_message_new_method_return
(
msg
)))
dbus_message_append_args
(
reply
,
DBUS_TYPE_STRING
,
&
config
,
DBUS_TYPE_INVALID
);
free
(
config
);
}
else
if
(
!
strcmp
(
member
,
USB_MODE_NETWORK_SET
))
{
char
*
config
=
0
,
*
setting
=
0
;
...
...
@@ -499,3 +508,15 @@ int usb_moded_send_supported_modes_signal(const char *supported_modes)
{
return
(
usb_moded_dbus_signal
(
USB_MODE_SUPPORTED_MODES_SIGNAL_NAME
,
supported_modes
));
}
/**
* Send regular usb_moded hidden mode list signal
*
* @return 0 on success, 1 on failure
* @param hidden_modes list of supported modes
*
*/
int
usb_moded_send_hidden_modes_signal
(
const
char
*
hidden_modes
)
{
return
(
usb_moded_dbus_signal
(
USB_MODE_HIDDEN_MODES_SIGNAL_NAME
,
hidden_modes
));
}
src/usb_moded-dbus.h
View file @
22a0f778
...
...
@@ -37,6 +37,7 @@
#define USB_MODE_CONFIG_SIGNAL_NAME "sig_usb_config_ind"
#define USB_MODE_ERROR_SIGNAL_NAME "sig_usb_state_error_ind"
#define USB_MODE_SUPPORTED_MODES_SIGNAL_NAME "sig_usb_supported_modes_ind"
#define USB_MODE_HIDDEN_MODES_SIGNAL_NAME "sig_usb_hidden_modes_ind"
/* supported methods */
#define USB_MODE_STATE_REQUEST "mode_request"
/* returns the current mode */
...
...
@@ -45,6 +46,7 @@
#define USB_MODE_LIST "get_modes"
/* returns a comma-separated list of supported modes for ui's */
#define USB_MODE_HIDE "hide_mode"
/* hide a mode */
#define USB_MODE_UNHIDE "unhide_mode"
/* unhide a mode */
#define USB_MODE_HIDDEN_GET "get_hidden"
/* return the hidden modes */
#define USB_MODE_STATE_SET "set_mode"
/* set a mode (only works when connected) */
#define USB_MODE_CONFIG_SET "set_config"
/* set the mode that needs to be activated in the config file */
#define USB_MODE_NETWORK_SET "net_config"
/* set the network config in the config file */
...
...
src/usb_moded-modes.h
View file @
22a0f778
...
...
@@ -46,3 +46,4 @@
#define MODE_CHARGER "dedicated_charger"
void
send_supported_modes_signal
(
void
);
void
send_hidden_modes_signal
(
void
);
src/usb_moded-util.c
View file @
22a0f778
...
...
@@ -240,6 +240,31 @@ static int set_unhide_mode_config (char *mode)
return
1
;
}
static
int
get_hiddenlist
(
void
)
{
DBusMessage
*
req
=
NULL
,
*
reply
=
NULL
;
char
*
ret
=
0
;
if
((
req
=
dbus_message_new_method_call
(
USB_MODE_SERVICE
,
USB_MODE_OBJECT
,
USB_MODE_INTERFACE
,
USB_MODE_HIDDEN_GET
))
!=
NULL
)
{
if
((
reply
=
dbus_connection_send_with_reply_and_block
(
conn
,
req
,
-
1
,
NULL
))
!=
NULL
)
{
dbus_message_get_args
(
reply
,
NULL
,
DBUS_TYPE_STRING
,
&
ret
,
DBUS_TYPE_INVALID
);
dbus_message_unref
(
reply
);
}
dbus_message_unref
(
req
);
}
if
(
ret
)
{
printf
(
"hidden modes are = %s
\n
"
,
ret
);
return
0
;
}
/* not everything went as planned, return error */
return
1
;
}
static
int
handle_network
(
char
*
network
)
{
char
*
operation
=
0
,
*
setting
=
0
,
*
value
=
0
;
...
...
@@ -314,7 +339,7 @@ static int handle_network(char *network)
int
main
(
int
argc
,
char
*
argv
[])
{
int
query
=
0
,
network
=
0
,
setmode
=
0
,
config
=
0
;
int
modelist
=
0
,
mode_configured
=
0
,
hide
=
0
,
unhide
=
0
;
int
modelist
=
0
,
mode_configured
=
0
,
hide
=
0
,
unhide
=
0
,
hiddenlist
=
0
;
int
res
=
1
,
opt
,
rescue
=
0
;
char
*
option
=
0
;
...
...
@@ -324,7 +349,7 @@ int main (int argc, char *argv[])
exit
(
1
);
}
while
((
opt
=
getopt
(
argc
,
argv
,
"c:dhi:mn:qrs:u:"
))
!=
-
1
)
while
((
opt
=
getopt
(
argc
,
argv
,
"c:dhi:mn:qrs:u:
v
"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'c'
:
...
...
@@ -359,6 +384,9 @@ int main (int argc, char *argv[])
unhide
=
1
;
option
=
optarg
;
break
;
case
'v'
:
hiddenlist
=
1
;
break
;
case
'h'
:
default:
fprintf
(
stderr
,
"
\n
Usage: %s -<option> <args>
\n\n
\
...
...
@@ -371,8 +399,9 @@ int main (int argc, char *argv[])
\t
-m to get the list of supported modes,
\n
\
\t
-q to query the current mode,
\n
\
\t
-r turn rescue mode off,
\n
\
\t
-s to set/activate a mode
\n
\
\t
-u unhide a mode
\n
"
,
\t
-s to set/activate a mode,
\n
\
\t
-u unhide a mode,
\n
\
\t
-v to get the list of hidden modes
\n
"
,
argv
[
0
]);
exit
(
1
);
}
...
...
@@ -407,6 +436,8 @@ int main (int argc, char *argv[])
res
=
set_hide_mode_config
(
option
);
else
if
(
unhide
)
res
=
set_unhide_mode_config
(
option
);
else
if
(
hiddenlist
)
res
=
get_hiddenlist
();
/* subfunctions will return 1 if an error occured, print message */
if
(
res
)
...
...
src/usb_moded.c
View file @
22a0f778
...
...
@@ -714,6 +714,16 @@ void send_supported_modes_signal(void)
g_free
(
mode_list
);
}
void
send_hidden_modes_signal
(
void
)
{
/* Send hidden modes signal */
gchar
*
mode_list
=
get_hidden_modes
();
if
(
mode_list
)
{
usb_moded_send_hidden_modes_signal
(
mode_list
);
g_free
(
mode_list
);
}
}
/** Pipe fd for transferring signals to mainloop context */
static
int
sigpipe_fd
=
-
1
;
...
...
@@ -997,6 +1007,7 @@ int main(int argc, char* argv[])
#endif
/* SYSTEMD */
send_supported_modes_signal
();
send_hidden_modes_signal
();
if
(
hw_fallback
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment