Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
f79f5200
Commit
f79f5200
authored
13 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
#2020 Disable screensaver during call
parent
87ef24a2
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
gnome/src/actions.c
+16
-0
16 additions, 0 deletions
gnome/src/actions.c
gnome/src/dbus/dbus.c
+138
-1
138 additions, 1 deletion
gnome/src/dbus/dbus.c
gnome/src/dbus/dbus.h
+10
-0
10 additions, 0 deletions
gnome/src/dbus/dbus.h
with
164 additions
and
1 deletion
gnome/src/actions.c
+
16
−
0
View file @
f79f5200
...
@@ -62,6 +62,7 @@
...
@@ -62,6 +62,7 @@
#include
"statusicon.h"
#include
"statusicon.h"
#include
"unused.h"
#include
"unused.h"
#include
"widget/imwidget.h"
#include
"widget/imwidget.h"
#include
"sliders.h"
static
GHashTable
*
ip2ip_profile
;
static
GHashTable
*
ip2ip_profile
;
...
@@ -378,6 +379,11 @@ sflphone_hang_up()
...
@@ -378,6 +379,11 @@ sflphone_hang_up()
calltree_update_call
(
history_tab
,
selectedCall
);
calltree_update_call
(
history_tab
,
selectedCall
);
statusbar_update_clock
(
""
);
statusbar_update_clock
(
""
);
// Allow screen saver to start
guint
nbcall
=
calllist_get_size
(
current_calls_tab
);
if
(
nbcall
==
1
)
dbus_screensaver_uninhibit
();
}
}
void
void
...
@@ -385,6 +391,11 @@ sflphone_pick_up()
...
@@ -385,6 +391,11 @@ sflphone_pick_up()
{
{
callable_obj_t
*
selectedCall
=
calltab_get_selected_call
(
active_calltree_tab
);
callable_obj_t
*
selectedCall
=
calltab_get_selected_call
(
active_calltree_tab
);
// Disable screensaver if the list is empty call
guint
nbcall
=
calllist_get_size
(
current_calls_tab
);
if
(
nbcall
==
0
)
dbus_screensaver_inhibit
();
if
(
!
selectedCall
)
{
if
(
!
selectedCall
)
{
sflphone_new_call
();
sflphone_new_call
();
return
;
return
;
...
@@ -627,6 +638,11 @@ process_dialing(callable_obj_t *c, guint keyval, gchar *key)
...
@@ -627,6 +638,11 @@ process_dialing(callable_obj_t *c, guint keyval, gchar *key)
callable_obj_t
*
callable_obj_t
*
sflphone_new_call
()
sflphone_new_call
()
{
{
// Disable screensaver if the list is empty call
guint
nbcall
=
calllist_get_size
(
current_calls_tab
);
if
(
nbcall
==
0
)
dbus_screensaver_inhibit
();
callable_obj_t
*
current_selected_call
=
calltab_get_selected_call
(
current_calls_tab
);
callable_obj_t
*
current_selected_call
=
calltab_get_selected_call
(
current_calls_tab
);
if
((
current_selected_call
!=
NULL
)
&&
(
current_selected_call
->
_confID
==
NULL
))
if
((
current_selected_call
!=
NULL
)
&&
(
current_selected_call
->
_confID
==
NULL
))
...
...
This diff is collapsed.
Click to expand it.
gnome/src/dbus/dbus.c
+
138
−
1
View file @
f79f5200
...
@@ -56,6 +56,8 @@
...
@@ -56,6 +56,8 @@
static
DBusGProxy
*
call_proxy
;
static
DBusGProxy
*
call_proxy
;
static
DBusGProxy
*
config_proxy
;
static
DBusGProxy
*
config_proxy
;
static
DBusGProxy
*
instance_proxy
;
static
DBusGProxy
*
instance_proxy
;
// static DBusGProxy *session_manager_proxy;
static
GDBusProxy
*
session_manager_proxy
;
/* Returns TRUE if there was an error, FALSE otherwise */
/* Returns TRUE if there was an error, FALSE otherwise */
static
gboolean
check_error
(
GError
*
error
)
static
gboolean
check_error
(
GError
*
error
)
...
@@ -567,14 +569,56 @@ error_alert(DBusGProxy *proxy UNUSED, int err, void *foo UNUSED)
...
@@ -567,14 +569,56 @@ error_alert(DBusGProxy *proxy UNUSED, int err, void *foo UNUSED)
gtk_widget_show
(
dialog
);
gtk_widget_show
(
dialog
);
}
}
static
void
screensaver_dbus_proxy_new_cb
(
GObject
*
source
UNUSED
,
GAsyncResult
*
result
,
gpointer
user_data
UNUSED
)
{
DEBUG
(
"DBUS: Session manager connection callback"
);
session_manager_proxy
=
g_dbus_proxy_new_for_bus_finish
(
result
,
NULL
);
if
(
session_manager_proxy
==
NULL
)
ERROR
(
"DBUS: Error, could not initialize gnome session manager"
);
}
#define GS_SERVICE "org.gnome.SessionManager"
#define GS_PATH "/org/gnome/SessionManager"
#define GS_INTERFACE "org.gnome.SessionManager"
gboolean
dbus_connect_session_manager
(
DBusGConnection
*
connection
)
{
if
(
connection
==
NULL
)
{
ERROR
(
"DBUS: Error connection is NULL"
);
return
FALSE
;
}
/*
session_manager_proxy = dbus_g_proxy_new_for_name(connection,
"org.gnome.SessionManager", "/org/gnome/SessionManager/Inhibitor",
"org.gnome.SessionManager.Inhibitor");
if(session_manager_proxy == NULL) {
ERROR("DBUS: Error, could not create session manager proxy");
return FALSE;
}
*/
g_dbus_proxy_new_for_bus
(
G_BUS_TYPE_SESSION
,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
,
NULL
,
GS_SERVICE
,
GS_PATH
,
GS_INTERFACE
,
NULL
,
screensaver_dbus_proxy_new_cb
,
NULL
);
DEBUG
(
"DBUS: Connected to gnome session manager"
);
return
TRUE
;
}
gboolean
dbus_connect
(
GError
**
error
)
gboolean
dbus_connect
(
GError
**
error
)
{
{
g_type_init
();
g_type_init
();
DBusGConnection
*
connection
=
dbus_g_bus_get
(
DBUS_BUS_SESSION
,
error
);
DBusGConnection
*
connection
=
dbus_g_bus_get
(
DBUS_BUS_SESSION
,
error
);
if
(
connection
==
NULL
)
if
(
connection
==
NULL
)
{
ERROR
(
"DBUS: Error, could not establish connection with session bus"
);
return
FALSE
;
return
FALSE
;
}
/* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */
/* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */
...
@@ -758,6 +802,12 @@ gboolean dbus_connect(GError **error)
...
@@ -758,6 +802,12 @@ gboolean dbus_connect(GError **error)
dbus_g_proxy_set_default_timeout
(
config_proxy
,
DEFAULT_DBUS_TIMEOUT
);
dbus_g_proxy_set_default_timeout
(
config_proxy
,
DEFAULT_DBUS_TIMEOUT
);
#endif
#endif
gboolean
status
=
dbus_connect_session_manager
(
connection
);
if
(
status
==
FALSE
)
{
ERROR
(
"DBUS: Error, could not connect to gnome session manager"
);
return
FALSE
;
}
return
TRUE
;
return
TRUE
;
}
}
...
@@ -1767,3 +1817,90 @@ dbus_send_text_message(const gchar *callID, const gchar *message)
...
@@ -1767,3 +1817,90 @@ dbus_send_text_message(const gchar *callID, const gchar *message)
org_sflphone_SFLphone_CallManager_send_text_message
(
call_proxy
,
callID
,
message
,
&
error
);
org_sflphone_SFLphone_CallManager_send_text_message
(
call_proxy
,
callID
,
message
,
&
error
);
check_error
(
error
);
check_error
(
error
);
}
}
static
guint
cookie
;
#define GNOME_SESSION_NO_IDLE_FLAG 8
static
void
screensaver_inhibit_cb
(
GObject
*
source_object
,
GAsyncResult
*
res
,
gpointer
user_data
UNUSED
)
{
DEBUG
(
"Screensaver: Inhibit callback"
);
GDBusProxy
*
proxy
=
G_DBUS_PROXY
(
source_object
);
// ScreenSaver *screensaver = (ScreenSaver *) user_data;
GVariant
*
value
;
GError
*
error
=
NULL
;
value
=
g_dbus_proxy_call_finish
(
proxy
,
res
,
&
error
);
if
(
!
value
)
{
ERROR
(
"Screensaver: Error: inhibiting the screensaver: %s"
,
error
->
message
);
g_error_free
(
error
);
return
;
}
/* save the cookie */
if
(
g_variant_is_of_type
(
value
,
G_VARIANT_TYPE
(
"(u)"
)))
g_variant_get
(
value
,
"(u)"
,
&
cookie
);
else
cookie
=
0
;
g_variant_unref
(
value
);
}
static
void
screensaver_uninhibit_cb
(
GObject
*
source_object
,
GAsyncResult
*
res
,
gpointer
user_data
UNUSED
)
{
DEBUG
(
"Screensaver: Uninhibit callback"
);
GDBusProxy
*
proxy
=
G_DBUS_PROXY
(
source_object
);
// ScreenSaver *screensaver = (ScreenSaver *) user_data;
GVariant
*
value
;
GError
*
error
=
NULL
;
value
=
g_dbus_proxy_call_finish
(
proxy
,
res
,
&
error
);
if
(
!
value
)
{
ERROR
(
"Screensaver: Error uninhibiting the screensaver: %s"
,
error
->
message
);
g_error_free
(
error
);
return
;
}
/* clear the cookie */
cookie
=
0
;
g_variant_unref
(
value
);
}
void
dbus_screensaver_inhibit
(
void
)
{
guint
xid
=
0
;
DEBUG
(
"Screensaver: inhibit"
);
const
gchar
*
appname
=
g_get_application_name
();
if
(
appname
==
NULL
)
{
ERROR
(
"Screensaver: Could not retreive application name"
);
return
;
}
GVariant
*
parameters
=
g_variant_new
(
"(susu)"
,
appname
,
xid
,
"Phone call ongoing"
,
GNOME_SESSION_NO_IDLE_FLAG
);
if
(
parameters
==
NULL
)
{
ERROR
(
"Screensaver: Could not create session manager inhibit parameters"
);
return
;
}
g_dbus_proxy_call
(
session_manager_proxy
,
"Inhibit"
,
parameters
,
G_DBUS_CALL_FLAGS_NO_AUTO_START
,
-
1
,
NULL
,
screensaver_inhibit_cb
,
NULL
);
}
void
dbus_screensaver_uninhibit
(
void
)
{
DEBUG
(
"Screensaver: uninhibit"
);
GVariant
*
parameters
=
g_variant_new
(
"(u)"
,
cookie
);
if
(
parameters
==
NULL
)
{
ERROR
(
"Screensaver: Could not create session manager uninhibit parameters"
);
return
;
};
g_dbus_proxy_call
(
session_manager_proxy
,
"Uninhibit"
,
g_variant_new
(
"(u)"
,
cookie
),
G_DBUS_CALL_FLAGS_NO_AUTO_START
,
-
1
,
NULL
,
screensaver_uninhibit_cb
,
NULL
);
}
This diff is collapsed.
Click to expand it.
gnome/src/dbus/dbus.h
+
10
−
0
View file @
f79f5200
...
@@ -561,4 +561,14 @@ gboolean dbus_start_recorded_file_playback(const gchar *);
...
@@ -561,4 +561,14 @@ gboolean dbus_start_recorded_file_playback(const gchar *);
*/
*/
void
dbus_stop_recorded_file_playback
(
const
gchar
*
);
void
dbus_stop_recorded_file_playback
(
const
gchar
*
);
/**
* Prevent Gnome Session Manager from entering in screen-saver mode
*/
void
dbus_screensaver_inhibit
(
void
);
/**
* Allow Gnome Session Manager to enter in screen-saver mode
*/
void
dbus_screensaver_uninhibit
(
void
);
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment