Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int zero_arg_variable_return_dbus_call(DBusGProxy * proxy, char * remoteMethod)
- {
- char *string;
- gint integer;
- gboolean booleanRet;
- GError *error = NULL;
- int pushCount =0 ;
- while (1)
- {
- // try string
- if (!dbus_g_proxy_call (proxy, remoteMethod, &error, G_TYPE_INVALID,
- G_TYPE_STRING, &string, G_TYPE_INVALID))
- {
- //ignore error and move on
- g_error_free (error);
- error=NULL;
- }
- else
- {
- lua_pushstring(luaState,string);
- g_free (string);
- pushCount++;
- break;
- }
- // try int
- if (!dbus_g_proxy_call (proxy, remoteMethod, &error, G_TYPE_INVALID,
- G_TYPE_INT, &integer, G_TYPE_INVALID))
- {
- //ignore error and move on
- g_error_free (error);
- error=NULL;
- }
- else
- {
- lua_pushnumber(luaState,integer);
- pushCount++;
- break;
- }
- //try boolean
- if (!dbus_g_proxy_call (proxy, remoteMethod, &error, G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &booleanRet, G_TYPE_INVALID))
- {
- // last type to try -clear error outside
- }
- else
- {
- lua_pushboolean(luaState,booleanRet);
- pushCount++;
- break;
- }
- //give up
- // remote method failed:
- // push error message to top of stack
- //PUSH_ERROR_MESSAGE(FUNCTION_CALL_ERROR,error->message);
- // free resources
- g_error_free (error);
- // better free the proxy before we exit
- closeProxy(proxy);
- // signal error
- //lua_error(luaState);
- //return prematurely - shouldn't reach here as we push the error to lua
- //lets just return nothing if we dont find the right type
- return 0;
- }
- /* Cleanup */
- closeProxy(proxy);
- //indicate one object was returned
- return pushCount;
- }
Add Comment
Please, Sign In to add comment