summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-01-22 12:34:38 -0500
committerChris Michael <cp.michael@samsung.com>2015-01-26 08:37:08 -0500
commit5a62a760c064ed233bca054eaeb3ad5a1d51cb5d (patch)
treef13bd899ae6708601e78d569034d2c8e3e3f8660 /src/lib/ecore_drm
parentf046a60a487d71facf5ec4cc06f78599eb65a371 (diff)
ecore-drm: Store session name inside dev structure and don't
take/release session control inside dbus functions Summary: These changes move the storage of session name to inside the Ecore_Drm_Device structure and remove calls to take/release session control to outside of the dbus code @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_drm')
-rw-r--r--src/lib/ecore_drm/ecore_drm_dbus.c54
1 files changed, 15 insertions, 39 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_dbus.c b/src/lib/ecore_drm/ecore_drm_dbus.c
index 292879eee1..b79d7d8b48 100644
--- a/src/lib/ecore_drm/ecore_drm_dbus.c
+++ b/src/lib/ecore_drm/ecore_drm_dbus.c
@@ -2,7 +2,6 @@
2 2
3static int _dbus_init_count = 0; 3static int _dbus_init_count = 0;
4 4
5static const char *dsession;
6static Eldbus_Connection *dconn; 5static Eldbus_Connection *dconn;
7static Eldbus_Object *dobj; 6static Eldbus_Object *dobj;
8 7
@@ -30,11 +29,14 @@ _ecore_drm_dbus_device_pause_done(uint32_t major, uint32_t minor)
30} 29}
31 30
32static void 31static void
33_cb_session_removed(void *ctxt EINA_UNUSED, const Eldbus_Message *msg) 32_cb_session_removed(void *data, const Eldbus_Message *msg)
34{ 33{
34 Ecore_Drm_Device *dev;
35 const char *errname, *errmsg; 35 const char *errname, *errmsg;
36 const char *sid; 36 const char *sid;
37 37
38 if (!(dev = data)) return;
39
38 if (eldbus_message_error_get(msg, &errname, &errmsg)) 40 if (eldbus_message_error_get(msg, &errname, &errmsg))
39 { 41 {
40 ERR("Eldbus Message Error: %s %s", errname, errmsg); 42 ERR("Eldbus Message Error: %s %s", errname, errmsg);
@@ -43,8 +45,11 @@ _cb_session_removed(void *ctxt EINA_UNUSED, const Eldbus_Message *msg)
43 45
44 if (eldbus_message_arguments_get(msg, "s", &sid)) 46 if (eldbus_message_arguments_get(msg, "s", &sid))
45 { 47 {
46 if (!strcmp(sid, dsession)) 48 if (!strcmp(sid, dev->session))
47 ERR("\tCurrent Session Removed!!"); 49 {
50 WRN("\tCurrent Session Removed!!");
51 _ecore_drm_logind_restore(dev);
52 }
48 } 53 }
49} 54}
50 55
@@ -116,19 +121,13 @@ _cb_properties_changed(void *data EINA_UNUSED, Eldbus_Proxy *proxy EINA_UNUSED,
116 } 121 }
117} 122}
118 123
119static Eina_Bool 124Eina_Bool
120_ecore_drm_dbus_session_take(const char *session) 125_ecore_drm_dbus_session_take(const char *session)
121{ 126{
122 Eldbus_Proxy *proxy; 127 Eldbus_Proxy *proxy;
123 Eldbus_Message *msg, *reply; 128 Eldbus_Message *msg, *reply;
124 const char *errname, *errmsg; 129 const char *errname, *errmsg;
125 130
126 if ((session) && (strcmp(session, dsession)))
127 {
128 ERR("Invalid session: %s", session);
129 return EINA_FALSE;
130 }
131
132 /* try to get the Session proxy */ 131 /* try to get the Session proxy */
133 if (!(proxy = eldbus_proxy_get(dobj, "org.freedesktop.login1.Session"))) 132 if (!(proxy = eldbus_proxy_get(dobj, "org.freedesktop.login1.Session")))
134 { 133 {
@@ -155,19 +154,13 @@ _ecore_drm_dbus_session_take(const char *session)
155 return EINA_TRUE; 154 return EINA_TRUE;
156} 155}
157 156
158static Eina_Bool 157Eina_Bool
159_ecore_drm_dbus_session_release(const char *session) 158_ecore_drm_dbus_session_release(const char *session)
160{ 159{
161 Eldbus_Proxy *proxy; 160 Eldbus_Proxy *proxy;
162 Eldbus_Message *msg, *reply; 161 Eldbus_Message *msg, *reply;
163 const char *errname, *errmsg; 162 const char *errname, *errmsg;
164 163
165 if ((session) && (strcmp(session, dsession)))
166 {
167 ERR("Invalid session: %s", session);
168 return EINA_FALSE;
169 }
170
171 /* try to get the Session proxy */ 164 /* try to get the Session proxy */
172 if (!(proxy = eldbus_proxy_get(dobj, "org.freedesktop.login1.Session"))) 165 if (!(proxy = eldbus_proxy_get(dobj, "org.freedesktop.login1.Session")))
173 { 166 {
@@ -300,7 +293,7 @@ _ecore_drm_dbus_device_take_no_pending(uint32_t major, uint32_t minor, Eina_Bool
300} 293}
301 294
302int 295int
303_ecore_drm_dbus_init(const char *session) 296_ecore_drm_dbus_init(Ecore_Drm_Device *dev)
304{ 297{
305 Eldbus_Proxy *proxy; 298 Eldbus_Proxy *proxy;
306 int ret = 0; 299 int ret = 0;
@@ -308,7 +301,7 @@ _ecore_drm_dbus_init(const char *session)
308 301
309 if (++_dbus_init_count != 1) return _dbus_init_count; 302 if (++_dbus_init_count != 1) return _dbus_init_count;
310 303
311 if (!session) return --_dbus_init_count; 304 if (!dev->session) return --_dbus_init_count;
312 305
313 /* try to init eldbus */ 306 /* try to init eldbus */
314 if (!eldbus_init()) 307 if (!eldbus_init())
@@ -317,8 +310,6 @@ _ecore_drm_dbus_init(const char *session)
317 return --_dbus_init_count; 310 return --_dbus_init_count;
318 } 311 }
319 312
320 dsession = eina_stringshare_add(session);
321
322 /* try to get the dbus connection */ 313 /* try to get the dbus connection */
323 if (!(dconn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM))) 314 if (!(dconn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM)))
324 { 315 {
@@ -327,7 +318,7 @@ _ecore_drm_dbus_init(const char *session)
327 } 318 }
328 319
329 /* assemble dbus path */ 320 /* assemble dbus path */
330 ret = asprintf(&dpath, "/org/freedesktop/login1/session/%s", session); 321 ret = asprintf(&dpath, "/org/freedesktop/login1/session/%s", dev->session);
331 if (ret < 0) 322 if (ret < 0)
332 { 323 {
333 ERR("Could not assemble dbus path"); 324 ERR("Could not assemble dbus path");
@@ -349,7 +340,7 @@ _ecore_drm_dbus_init(const char *session)
349 } 340 }
350 341
351 eldbus_proxy_signal_handler_add(proxy, "SessionRemoved", 342 eldbus_proxy_signal_handler_add(proxy, "SessionRemoved",
352 _cb_session_removed, NULL); 343 _cb_session_removed, dev);
353 344
354 /* try to get the Session proxy */ 345 /* try to get the Session proxy */
355 if (!(proxy = eldbus_proxy_get(dobj, "org.freedesktop.login1.Session"))) 346 if (!(proxy = eldbus_proxy_get(dobj, "org.freedesktop.login1.Session")))
@@ -374,17 +365,8 @@ _ecore_drm_dbus_init(const char *session)
374 eldbus_proxy_event_callback_add(proxy, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED, 365 eldbus_proxy_event_callback_add(proxy, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
375 _cb_properties_changed, NULL); 366 _cb_properties_changed, NULL);
376 367
377 if (!_ecore_drm_dbus_session_take(dsession))
378 {
379 ERR("Failed to take control of session");
380 goto session_err;
381 }
382
383 return _dbus_init_count; 368 return _dbus_init_count;
384 369
385session_err:
386 eldbus_proxy_event_callback_del(proxy, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
387 _cb_properties_changed, NULL);
388proxy_err: 370proxy_err:
389 eldbus_object_unref(dobj); 371 eldbus_object_unref(dobj);
390obj_err: 372obj_err:
@@ -392,7 +374,6 @@ obj_err:
392path_err: 374path_err:
393 eldbus_connection_unref(dconn); 375 eldbus_connection_unref(dconn);
394conn_err: 376conn_err:
395 eina_stringshare_del(dsession);
396 eldbus_shutdown(); 377 eldbus_shutdown();
397 return --_dbus_init_count; 378 return --_dbus_init_count;
398} 379}
@@ -402,17 +383,12 @@ _ecore_drm_dbus_shutdown(void)
402{ 383{
403 if (--_dbus_init_count != 0) return _dbus_init_count; 384 if (--_dbus_init_count != 0) return _dbus_init_count;
404 385
405 /* release control of the session */
406 _ecore_drm_dbus_session_release(dsession);
407
408 /* release dbus object */ 386 /* release dbus object */
409 if (dobj) eldbus_object_unref(dobj); 387 if (dobj) eldbus_object_unref(dobj);
410 388
411 /* release the dbus connection */ 389 /* release the dbus connection */
412 if (dconn) eldbus_connection_unref(dconn); 390 if (dconn) eldbus_connection_unref(dconn);
413 391
414 eina_stringshare_del(dsession);
415
416 /* shutdown eldbus library */ 392 /* shutdown eldbus library */
417 eldbus_shutdown(); 393 eldbus_shutdown();
418 394