Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-04-29 15:43:35 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-04-29 15:43:35 (GMT)
commit31f4885f8e25b4313fd2e5b581b2a355b28c9ac0 (patch)
tree2e5ffc0520fb13f59b8a1b8883a99106585b1f60
parentdd6c13fdbed6e4f3027872aa01b1c0fc1f46d2ab (diff)
Implement get_filename
-rw-r--r--datastore/datastore.cpp67
-rw-r--r--datastore/datastore.h1
2 files changed, 68 insertions, 0 deletions
diff --git a/datastore/datastore.cpp b/datastore/datastore.cpp
index b910821..d543b8b 100644
--- a/datastore/datastore.cpp
+++ b/datastore/datastore.cpp
@@ -102,6 +102,54 @@ DataStore::get_properties()
return properties;
}
+std::auto_ptr<std::string>
+DataStore::get_filename()
+{
+ GNASH_REPORT_FUNCTION;
+
+ DBusGConnection *connection;
+ GError *error;
+ DBusGProxy *proxy;
+ gchar *file_name;
+
+ error = NULL;
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION,
+ &error);
+ if (connection == NULL)
+ {
+ g_printerr ("Failed to open connection to bus: %s\n",
+ error->message);
+ g_error_free (error);
+ exit (1);
+ }
+
+ proxy = dbus_g_proxy_new_for_name (connection,
+ DS_DBUS_SERVICE,
+ DS_DBUS_PATH,
+ DS_DBUS_INTERFACE);
+
+ error = NULL;
+ if (!dbus_g_proxy_call (proxy, "get_filename", &error,
+ G_TYPE_STRING, _object_id.c_str(), G_TYPE_INVALID,
+ G_TYPE_STRING, &file_name, G_TYPE_INVALID))
+ {
+ if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION)
+ g_printerr ("Caught remote method exception %s: %s",
+ dbus_g_error_get_name (error),
+ error->message);
+ else
+ g_printerr ("Error: %s\n", error->message);
+ g_error_free (error);
+ exit (1);
+ }
+
+ g_object_unref (proxy);
+
+ log_debug("%s", file_name);
+ std::auto_ptr<std::string> file_name_s(new std::string(file_name));
+ return file_name_s;
+}
+
as_value
datastore_get_properties(const fn_call& fn)
{
@@ -132,11 +180,30 @@ datastore_get_properties(const fn_call& fn)
return as_value(as_properties);
}
+as_value
+datastore_get_filename(const fn_call& fn)
+{
+ GNASH_REPORT_FUNCTION;
+ boost::intrusive_ptr<DataStore> ptr = ensureType<DataStore>(fn.this_ptr);
+ assert(ptr);
+
+ if ( fn.nargs > 0 )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::stringstream ss; fn.dump_args(ss);
+ log_aserror("DataStore.get_properties(%s): all arguments discarded", ss.str().c_str());
+ );
+ }
+
+ return as_value(*ptr->get_filename().get());
+}
+
static void
attachInterface(as_object *obj)
{
GNASH_REPORT_FUNCTION;
obj->init_member("get_properties", new builtin_function(datastore_get_properties));
+ obj->init_member("get_filename", new builtin_function(datastore_get_filename));
}
static as_value
diff --git a/datastore/datastore.h b/datastore/datastore.h
index 9ad9fe9..aaa986f 100644
--- a/datastore/datastore.h
+++ b/datastore/datastore.h
@@ -31,6 +31,7 @@ public:
DataStore(std::string &object_id);
~DataStore();
Properties *get_properties();
+ std::auto_ptr<std::string> get_filename();
private:
std::string _object_id;
};