Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
77dae5bc
Commit
77dae5bc
authored
Dec 07, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
power: cosmetic revector
parent
002d2147
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
85 deletions
+98
-85
modules/misc/inhibit/power.c
modules/misc/inhibit/power.c
+98
-85
No files found.
modules/misc/inhibit/power.c
View file @
77dae5bc
...
...
@@ -33,107 +33,120 @@
#include <vlc_inhibit.h>
#include <dbus/dbus.h>
struct
vlc_inhibit_sys
enum
vlc_inhibit_api
{
DBusConnection
*
conn
;
dbus_uint32_t
cookie
[
2
];
FREEDESKTOP
,
/* KDE and GNOME <= 2.26 */
GNOME
,
/**< GNOME 2.26..3.4 */
};
static
void
Inhibit
(
vlc_inhibit_t
*
ih
,
unsigned
flags
)
static
const
char
dbus_service
[][
32
]
=
{
enum
{
FREEDESKTOP
=
0
,
/* as used by KDE and gnome <= 2.26 */
GNOME
=
1
,
/* as used by gnome > 2.26 */
};
static
const
char
dbus_service
[
2
][
32
]
=
{
[
FREEDESKTOP
]
=
"org.freedesktop.PowerManagement"
,
[
GNOME
]
=
"org.gnome.SessionManager"
,
};
};
static
const
char
dbus_path
[
2
][
33
]
=
{
static
const
char
dbus_path
[][
33
]
=
{
[
FREEDESKTOP
]
=
"/org/freedesktop/PowerManagement"
,
[
GNOME
]
=
"/org/gnome/SessionManager"
,
};
};
static
const
char
dbus_interface
[
2
][
40
]
=
{
static
const
char
dbus_interface
[][
40
]
=
{
[
FREEDESKTOP
]
=
"org.freedesktop.PowerManagement.Inhibit"
,
[
GNOME
]
=
"org.gnome.SessionManager"
,
};
};
static
const
char
dbus_method
[
2
][
2
][
10
]
=
{
{
static
const
char
dbus_method_uninhibit
[][
10
]
=
{
[
FREEDESKTOP
]
=
"UnInhibit"
,
[
GNOME
]
=
"Uninhibit"
,
},
{
[
FREEDESKTOP
]
=
"Inhibit"
,
[
GNOME
]
=
"Inhibit"
,
},
};
};
static
const
char
*
app
=
PACKAGE
;
static
const
char
*
reason
=
N_
(
"Playing some media."
);
struct
vlc_inhibit_sys
{
DBusConnection
*
conn
;
dbus_uint32_t
cookie
[
2
];
};
static
void
InhibitAPI
(
vlc_inhibit_t
*
ih
,
unsigned
flags
,
enum
vlc_inhibit_api
type
)
{
vlc_inhibit_sys_t
*
sys
=
ih
->
p_sys
;
DBusConnection
*
conn
=
sys
->
conn
;
const
bool
suspend
=
!!
flags
;
const
dbus_uint32_t
xid
=
0
;
// FIXME ?
const
dbus_uint32_t
gnome_flags
=
((
flags
&
VLC_INHIBIT_SUSPEND
)
?
8
:
0
)
|
((
flags
&
VLC_INHIBIT_DISPLAY
)
?
4
:
0
);
for
(
int
type
=
0
;
type
<
2
;
type
++
)
{
const
char
*
method
=
flags
?
"Inhibit"
:
dbus_method_uninhibit
[
type
];
dbus_bool_t
ret
;
DBusMessage
*
msg
=
dbus_message_new_method_call
(
dbus_service
[
type
],
dbus_path
[
type
],
dbus_interface
[
type
],
dbus_method
[
suspend
][
type
]
);
dbus_path
[
type
],
dbus_interface
[
type
],
method
);
if
(
unlikely
(
msg
==
NULL
))
return
;
if
(
suspend
)
{
if
(
type
==
FREEDESKTOP
)
ret
=
dbus_message_append_args
(
msg
,
DBUS_TYPE_STRING
,
&
app
,
if
(
flags
)
{
const
char
*
app
=
PACKAGE
;
const
char
*
reason
=
N_
(
"Playing some media."
);
switch
(
type
)
{
case
FREEDESKTOP
:
ret
=
dbus_message_append_args
(
msg
,
DBUS_TYPE_STRING
,
&
app
,
DBUS_TYPE_STRING
,
&
reason
,
DBUS_TYPE_INVALID
);
else
if
(
type
==
GNOME
)
ret
=
dbus_message_append_args
(
msg
,
DBUS_TYPE_STRING
,
&
app
,
break
;
case
GNOME
:
{
dbus_uint32_t
xid
=
0
;
// FIXME ?
dbus_uint32_t
gflags
=
((
flags
&
VLC_INHIBIT_SUSPEND
)
?
8
:
0
)
|
((
flags
&
VLC_INHIBIT_DISPLAY
)
?
4
:
0
);
ret
=
dbus_message_append_args
(
msg
,
DBUS_TYPE_STRING
,
&
app
,
DBUS_TYPE_UINT32
,
&
xid
,
DBUS_TYPE_STRING
,
&
reason
,
DBUS_TYPE_UINT32
,
&
gnome_
flags
,
DBUS_TYPE_UINT32
,
&
g
flags
,
DBUS_TYPE_INVALID
);
break
;
}
}
}
else
{
ret
=
false
;
if
(
sys
->
cookie
[
type
])
ret
=
dbus_message_append_args
(
msg
,
DBUS_TYPE_UINT32
,
&
sys
->
cookie
[
type
],
DBUS_TYPE_INVALID
);
ret
=
dbus_message_append_args
(
msg
,
DBUS_TYPE_UINT32
,
&
sys
->
cookie
[
type
],
DBUS_TYPE_INVALID
);
else
ret
=
false
;
}
if
(
!
ret
)
goto
end
;
goto
giveup
;
if
(
suspend
)
{
/* read reply */
/* blocks 50ms maximum */
if
(
flags
)
{
/* read reply */
DBusMessage
*
reply
=
dbus_connection_send_with_reply_and_block
(
conn
,
msg
,
50
,
NULL
);
conn
,
msg
,
50
,
NULL
);
if
(
unlikely
(
reply
==
NULL
))
goto
end
;
/* gpm is not active, or too slow. Better luck next time?
*/
goto
giveup
;
/* no reponse?!
*/
if
(
!
dbus_message_get_args
(
reply
,
NULL
,
DBUS_TYPE_UINT32
,
&
sys
->
cookie
[
type
],
DBUS_TYPE_INVALID
))
sys
->
cookie
[
type
]
=
0
;
dbus_message_unref
(
reply
);
dbus_message_unref
(
reply
);
}
else
{
/* just send and flush */
if
(
dbus_connection_send
(
conn
,
msg
,
NULL
))
{
sys
->
cookie
[
type
]
=
0
;
dbus_connection_flush
(
conn
);
}
dbus_connection_flush
(
conn
);
}
end:
dbus_message_unref
(
msg
);
}
giveup:
dbus_message_unref
(
msg
);
}
static
void
Inhibit
(
vlc_inhibit_t
*
ih
,
unsigned
flags
)
{
for
(
int
type
=
0
;
type
<
2
;
type
++
)
InhibitAPI
(
ih
,
flags
,
type
);
}
static
int
Open
(
vlc_object_t
*
obj
)
...
...
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