config: fix inverted bit field check for a flag
[profile/ivi/murphy.git] / packaging.in / murphy.lua
index b286740..552b309 100644 (file)
@@ -576,12 +576,24 @@ end
 function regulateApplications(t, regulation)
     for k,v in pairs(ft(t)) do
 
-        -- iterate through the undefined and entertainment apps, see if
-        -- they have been overruled in local config
+        whitelisted = false
 
+        -- our local application config, which takes precedence
         local conf = getApplication(v.appid)
 
-        if conf and conf.resource_class ~= "player" then
+        if conf then
+            if conf.resource_class ~= "player" then
+                whitelisted = true
+            end
+
+              if conf.requisites and conf.requisites.screen then
+                if conf.requisites.screen.driving then
+                    whitelisted = true
+                end
+            end
+        end
+
+        if whitelisted then
             -- override, don't disable
             resmgr:disable_screen_by_appid("*", "*", v.appid, false, false)
         else
@@ -934,15 +946,28 @@ resmgr = resource_manager {
                                     -- our local application config, which takes precedence
                                     local conf = getApplication(ev.appid)
 
-                                    -- disable only non-whitelisted applications
-                                    if not conf or conf.resource_class == "player" then
-                                        if blacklisted then
-                                            if verbose > 0 then
-                                                print("disabling screen for " .. ev.appid)
+                                    if not conf then
+                                        blacklisted = true
+                                    else
+                                        if conf.resource_class == "player" then
+                                            blacklisted = true
+                                        end
+
+                                        -- check the exceptions
+                                        if conf.requisites and conf.requisites.screen then
+                                            if conf.requisites.screen.driving then
+                                                blacklisted = false
                                             end
-                                            resmgr:disable_screen_by_appid("*", "*", ev.appid, true, true)
                                         end
                                     end
+
+                                    -- disable only non-whitelisted applications
+                                                   if blacklisted then
+                                        if verbose > 0 then
+                                            print("disabling screen for " .. ev.appid)
+                                        end
+                                        resmgr:disable_screen_by_appid("*", "*", ev.appid, true, true)
+                                    end
                                 end
 
                              elseif event == "destroy" then
@@ -1575,9 +1600,48 @@ application {
     area            = "Center.Full",
     privileges      = { screen = "none", audio = "none" },
     resource_class  = "system",
+    requisites      = { screen = "driving", audio = "none" },
     screen_priority = 30
 }
 
+application {
+    appid           = "MediaPlayer",
+    area            = "Center.Full",
+    privileges      = { screen = "none", audio = "none" },
+    requisites      = { screen = "driving", audio = "none" },
+    resource_class  = "player",
+    screen_priority = 0
+}
+
+application {
+    appid           = "MyMediaPlayer",
+    area            = "Center.Full",
+    privileges      = { screen = "none", audio = "none" },
+    requisites      = { screen = "driving", audio = "none" },
+    resource_class  = "player",
+    screen_priority = 0
+}
+
+application {
+    appid           = "MeterWidget",
+    area            = "Center.Full",
+    privileges      = { screen = "none", audio = "none" },
+    requisites      = { screen = "driving", audio = "none" },
+    resource_class  = "player",
+    screen_priority = 0
+}
+
+application {
+    appid           = "org.tizen.ico.app-soundsample",
+    area            = "Center.Full",
+    privileges      = { screen = "none", audio = "none" },
+    -- uncomment the next line to make the app exempt from regulation
+    -- requisites      = { screen = "driving", audio = "none" },
+    resource_class  = "player",
+    screen_priority = 0
+}
+
+
 if sc then
     sc.client_handler = function (self, cid, msg)
         local command = msg.command
@@ -1662,8 +1726,10 @@ if sc then
                 local time = 200
                 if  msg.arg.anim_time then
                     local t = msg.arg.anim_time
+                    -- the actual time for the animation
                     time = m:AND(t, time_mask)
-                    nores = not m:AND(t, nores_mask)
+                    -- flag for ignoring resource control
+                    nores = m:AND(t, nores_mask)
                     if m:AND(t, raise_mask) then
                         msg.arg.raise = 1
                     elseif m:AND(t, lower_mask) then
@@ -1706,8 +1772,10 @@ if sc then
                 local time = 200
                 if msg.arg.anim_time then
                     local t = msg.arg.anim_time
+                    -- the actual time for the animation
                     time = m:AND(t, time_mask)
-                    nores = not m:AND(t, nores_mask)
+                    -- flag for ignoring resource control
+                    nores = m:AND(t, nores_mask)
                 end
                 if msg.arg.anim_name then
                     a.hide = { msg.arg.anim_name, time }
@@ -1999,6 +2067,7 @@ if sc then
                 elseif msg.res.input then
                     key = msg.res.input.name
                 elseif msg.res.window then
+                    -- alarm! this appars to be non-unique?
                     key = msg.res.window.resourceId
                 end
             end
@@ -2007,7 +2076,7 @@ if sc then
         end
 
         createResourceSet = function (ctl, client, msg)
-            cb = function(rset, data)
+            cb = function(rset)
 
                 -- m:info("*** resource_cb: client = '" .. msg.appid .. "'")
 
@@ -2017,8 +2086,8 @@ if sc then
                     requestType = msg.res.type
                 end
 
-                if data.filter_first then
-                    data.filter_first = false
+                if rset.data.filter_first then
+                    rset.data.filter_first = false
                     return
                 end
 
@@ -2030,12 +2099,15 @@ if sc then
                         rset.timer = m:Timer({
                             interval = 5000,
                             oneshot = true,
-                            callback = function (t, data)
-                                m:info("notification resource set timer expired")
+                            callback = function (t)
+                                m:info("notification timer expired")
 
-                                -- destroy the internal resource set
+                                if rset.data then
+                                    reply.res.window = rset.data.window
+                                end
 
-                                rset:destroy()
+                                rset:release()
+                                rset.timer = nil
 
                                 -- Send a "RELEASE" message to client.
                                 -- This triggers the resource deletion
@@ -2049,10 +2121,6 @@ if sc then
                                     }
                                 })
 
-                                if rset.data.window then
-                                    reply.res.window = rset.data.window
-                                end
-
                                 sc:send_message(client, reply)
                             end
                         })
@@ -2061,6 +2129,7 @@ if sc then
                     cmd = 0x00040002 -- release
                     if rset.timer then
                        rset.timer.callback = nil
+                       rset.timer = nil
                     end
                 end
 
@@ -2095,7 +2164,7 @@ if sc then
                 end
             end
 
-            rset = m:ResourceSet({
+            local rset = m:ResourceSet({
                     application_class = "player",
                     zone = "driver", -- msg.zone ("full")
                     callback = cb
@@ -2171,7 +2240,7 @@ if sc then
                 if not sets.cid then
                     sets.cid = {}
                 end
-                sets.cid.key = createResourceSet(self, cid, msg)
+                sets.cid[key] = createResourceSet(self, cid, msg)
             end
 
         elseif msg.command == 0x40012 then -- destroy_res
@@ -2181,6 +2250,7 @@ if sc then
             if key then
                 if sets.cid and sets.cid[key] then
                     sets.cid[key]:release()
+                    sets.cid[key].timer = nil
                     sets.cid[key] = nil -- garbage collecting
                 end
             end
@@ -2190,12 +2260,10 @@ if sc then
             key = getKey(msg)
 
             if key then
-                print("key is " .. tostring(key))
                 if not sets.cid then
                     sets.cid = {}
                 end
                 if not sets.cid[key] then
-                    print("creating a resource set")
                     sets.cid[key] = createResourceSet(self, cid, msg)
                 end
                 print("acquiring the resource set")
@@ -2210,19 +2278,16 @@ if sc then
             if key then
                 if sets.cid and sets.cid[key] then
                     sets.cid[key]:release()
-                end
 
-                if msg.appid == onscreen then
-                    -- in case of OnScreen, this actually means that the
-                    -- resource set is never used again; let gc do its job
-                    if sets.cid and sets.cid[key] then
+                    if msg.appid == onscreen then
+                        -- in case of OnScreen, this actually means that the
+                        -- resource set is never used again; let gc do its job
+                        sets.cid[key].timer = nil
                         sets.cid[key] = nil -- garbage collecting
                     end
                 end
-
             end
 
-
         elseif msg.command == 0x40003 then -- deprive_res
             print("command DEPRIVE_RES")