+ return getEngine().getSource();
+}
+
+void ExternalEncryptionServer::dbusRegisterObject(GDBusConnection *connection)
+{
+ GError *err = NULL;
+ GDBusNodeInfo *dbusIntrospectionData = g_dbus_node_info_new_for_xml(introspectionXml, &err);
+ if (dbusIntrospectionData == NULL) {
+ ERROR(SINK, "Dbus introspection data creation failed: " << err->message);
+ return;
+ }
+
+ const GDBusInterfaceVTable interfaceVtable =
+ {
+ ode::dbusMethodCall,
+ NULL,
+ NULL
+ };
+
+ /*
+ * Test:
+ * dbus-send --system --type=method_call --print-reply --dest=org.tizen.ode
+ * /org/tizen/ode/ExternalEncryption org.tizen.ode.ExternalEncryption.UpdateCardStatus
+ * string:"/media/SDCardA1" int32:1
+ */
+ guint registrationId = g_dbus_connection_register_object(connection,
+ "/org/tizen/ode/ExternalEncryption",
+ dbusIntrospectionData->interfaces[0],
+ &interfaceVtable,
+ this,
+ NULL,
+ &err);
+ if (registrationId == 0)
+ ERROR(SINK, "Dbus object registration failed: " << err->message);
+
+ g_dbus_node_info_unref(dbusIntrospectionData);
+}
+
+void ExternalEncryptionServer::dbusMethodCall(const gchar *,
+ GVariant *params,
+ GDBusMethodInvocation *invocation)
+{
+ RequestLifetime rl(server);
+
+ const gchar *mountPoint;
+ gint32 cardStatus;
+
+ g_variant_get(params, "(&si)", &mountPoint, &cardStatus);
+
+ switch (cardStatus) {
+ case 0:
+ DEBUG(SINK, "Card unmounted " << mountPoint);
+ {
+ int ret = ::vconf_unset(VCONFKEY_SDE_MOUNT_POINT);
+ if (ret != 0)
+ ERROR(SINK, "vconf_set_str() failed with " << ret);
+
+ engine.reset();
+ }
+ break;
+ case 1:
+ DEBUG(SINK, "Card mounted " << mountPoint);
+ {
+ int ret = ::vconf_set_str(VCONFKEY_SDE_MOUNT_POINT, mountPoint);
+ if (ret != 0)
+ ERROR(SINK, "vconf_set_str() failed with " << ret);
+ else if (isEncrypted())
+ spawnUI();
+ }
+ break;
+ default:
+ ERROR(SINK, "Unsupported card status: " << cardStatus);
+ g_dbus_method_invocation_return_error(invocation,
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_INVALID_ARGS,
+ "Unsupported card status");
+ return;
+ }
+ g_dbus_method_invocation_return_value(invocation, NULL);