[grilo-plugins] lua-factory: Add more keys to grl.get_options()



commit c95d353fe20ac212504f4448168eb40cc124fbc0
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Apr 19 13:55:06 2014 +0200

    lua-factory: Add more keys to grl.get_options()
    
    Make it possible to get the query/search strings, or the media ID
    for the operation, as well as the operation type.
    
    This is useful when the entry point needs to launch an async operation
    to cache a manifest for example.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728882

 src/lua-factory/grl-lua-library.c |   41 +++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/src/lua-factory/grl-lua-library.c b/src/lua-factory/grl-lua-library.c
index 2e19050..da968d1 100644
--- a/src/lua-factory/grl-lua-library.c
+++ b/src/lua-factory/grl-lua-library.c
@@ -578,6 +578,29 @@ grl_l_operation_get_options (lua_State *L)
   g_return_val_if_fail (os != NULL, 0);
   option = lua_tostring (L, 1);
 
+  if (g_strcmp0 (option, "type") == 0) {
+    const char *type;
+    switch (os->op_type) {
+    case LUA_SEARCH:
+      type = "search";
+      break;
+    case LUA_BROWSE:
+      type = "browse";
+      break;
+    case LUA_QUERY:
+      type = "query";
+      break;
+    case LUA_RESOLVE:
+      type = "resolve";
+      break;
+    default:
+      g_assert_not_reached ();
+    }
+
+    lua_pushstring (L, type);
+    return 1;
+  }
+
   if (g_strcmp0 (option, "count") == 0) {
     gint count = grl_operation_options_get_count (os->options);
 
@@ -672,6 +695,24 @@ grl_l_operation_get_options (lua_State *L)
     return 1;
   }
 
+  if (g_strcmp0 (option, "media-id") == 0 &&
+      os->op_type == LUA_BROWSE) {
+    lua_pushstring (L, os->string);
+    return 1;
+  }
+
+  if (g_strcmp0 (option, "query") == 0 &&
+      os->op_type == LUA_QUERY) {
+    lua_pushstring (L, os->string);
+    return 1;
+  }
+
+  if (g_strcmp0 (option, "search") == 0 &&
+      os->op_type == LUA_SEARCH) {
+    lua_pushstring (L, os->string);
+    return 1;
+  }
+
   luaL_error (L, "'%s' is not available nor implemented.", option);
   return 0;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]