From: Sam Hartman Date: Tue, 21 Jun 2011 21:03:04 +0000 (-0400) Subject: vala for dbus-client X-Git-Tag: debian/0.0.2+20110913-1~7 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=470928bf32ca1ee8e9cc58773f62f91b8843eb35;p=moonshot-ui.git vala for dbus-client --- diff --git a/src/dbus-client.c b/src/dbus-client.c new file mode 100644 index 0000000..418b96b --- /dev/null +++ b/src/dbus-client.c @@ -0,0 +1,680 @@ +/* dbus-client.c generated by valac 0.10.4, the Vala compiler + * generated from dbus-client.vala, do not modify */ + + +#include +#include +#include +#include +#include +#include +#include +#include + + +#define TYPE_MOONSHOT (moonshot_get_type ()) +#define MOONSHOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MOONSHOT, Moonshot)) +#define IS_MOONSHOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MOONSHOT)) +#define MOONSHOT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_MOONSHOT, MoonshotIface)) + +typedef struct _Moonshot Moonshot; +typedef struct _MoonshotIface MoonshotIface; +typedef struct _DBusObjectVTable _DBusObjectVTable; +#define _g_free0(var) (var = (g_free (var), NULL)) +typedef struct _MoonshotDBusProxy MoonshotDBusProxy; +typedef DBusGProxyClass MoonshotDBusProxyClass; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +#define _dbus_g_connection_unref0(var) ((var == NULL) ? NULL : (var = (dbus_g_connection_unref (var), NULL))) +#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) + +struct _MoonshotIface { + GTypeInterface parent_iface; + gboolean (*get_identity) (Moonshot* self, const char* nai, const char* password, const char* service, char** nai_out, char** password_out, char** certificate_out, GError** error); +}; + +struct _DBusObjectVTable { + void (*register_object) (DBusConnection*, const char*, void*); +}; + +struct _MoonshotDBusProxy { + DBusGProxy parent_instance; + gboolean disposed; +}; + + + +Moonshot* moonshot_dbus_proxy_new (DBusGConnection* connection, const char* name, const char* path); +GType moonshot_get_type (void) G_GNUC_CONST; +gboolean moonshot_get_identity (Moonshot* self, const char* nai, const char* password, const char* service, char** nai_out, char** password_out, char** certificate_out, GError** error); +static void _vala_dbus_register_object (DBusConnection* connection, const char* path, void* object); +static void _vala_dbus_unregister_object (gpointer connection, GObject* object); +void moonshot_dbus_register_object (DBusConnection* connection, const char* path, void* object); +void _moonshot_dbus_unregister (DBusConnection* connection, void* _user_data_); +DBusHandlerResult moonshot_dbus_message (DBusConnection* connection, DBusMessage* message, void* object); +static DBusHandlerResult _dbus_moonshot_introspect (Moonshot* self, DBusConnection* connection, DBusMessage* message); +static DBusHandlerResult _dbus_moonshot_property_get_all (Moonshot* self, DBusConnection* connection, DBusMessage* message); +static DBusHandlerResult _dbus_moonshot_get_identity (Moonshot* self, DBusConnection* connection, DBusMessage* message); +GType moonshot_dbus_proxy_get_type (void) G_GNUC_CONST; +DBusHandlerResult moonshot_dbus_proxy_filter (DBusConnection* connection, DBusMessage* message, void* user_data); +enum { + MOONSHOT_DBUS_PROXY_DUMMY_PROPERTY +}; +static gboolean moonshot_dbus_proxy_get_identity (Moonshot* self, const char* nai, const char* password, const char* service, char** nai_out, char** password_out, char** certificate_out, GError** error); +static void moonshot_dbus_proxy_moonshot__interface_init (MoonshotIface* iface); +static void moonshot_dbus_proxy_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); +static void moonshot_dbus_proxy_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); +void _vala_main (void); + +static const DBusObjectPathVTable _moonshot_dbus_path_vtable = {_moonshot_dbus_unregister, moonshot_dbus_message}; +static const _DBusObjectVTable _moonshot_dbus_vtable = {moonshot_dbus_register_object}; + + +gboolean moonshot_get_identity (Moonshot* self, const char* nai, const char* password, const char* service, char** nai_out, char** password_out, char** certificate_out, GError** error) { + return MOONSHOT_GET_INTERFACE (self)->get_identity (self, nai, password, service, nai_out, password_out, certificate_out, error); +} + + +static void _vala_dbus_register_object (DBusConnection* connection, const char* path, void* object) { + const _DBusObjectVTable * vtable; + vtable = g_type_get_qdata (G_TYPE_FROM_INSTANCE (object), g_quark_from_static_string ("DBusObjectVTable")); + if (vtable) { + vtable->register_object (connection, path, object); + } else { + g_warning ("Object does not implement any D-Bus interface"); + } +} + + +static void _vala_dbus_unregister_object (gpointer connection, GObject* object) { + char* path; + path = g_object_steal_data ((GObject*) object, "dbus_object_path"); + dbus_connection_unregister_object_path (connection, path); + g_free (path); +} + + +void _moonshot_dbus_unregister (DBusConnection* connection, void* _user_data_) { +} + + +static DBusHandlerResult _dbus_moonshot_introspect (Moonshot* self, DBusConnection* connection, DBusMessage* message) { + DBusMessage* reply; + DBusMessageIter iter; + GString* xml_data; + char** children; + int i; + reply = dbus_message_new_method_return (message); + dbus_message_iter_init_append (reply, &iter); + xml_data = g_string_new ("\n"); + g_string_append (xml_data, "\n\n \n \n \n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n \n \n \n \n \n \n \n \n \n\n"); + dbus_connection_list_registered (connection, g_object_get_data ((GObject *) self, "dbus_object_path"), &children); + for (i = 0; children[i]; i++) { + g_string_append_printf (xml_data, "\n", children[i]); + } + dbus_free_string_array (children); + g_string_append (xml_data, "\n"); + dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &xml_data->str); + g_string_free (xml_data, TRUE); + if (reply) { + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + return DBUS_HANDLER_RESULT_HANDLED; + } else { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } +} + + +static DBusHandlerResult _dbus_moonshot_property_get_all (Moonshot* self, DBusConnection* connection, DBusMessage* message) { + DBusMessage* reply; + DBusMessageIter iter, reply_iter, subiter; + char* interface_name; + const char* _tmp0_; + if (strcmp (dbus_message_get_signature (message), "s")) { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + dbus_message_iter_init (message, &iter); + reply = dbus_message_new_method_return (message); + dbus_message_iter_init_append (reply, &reply_iter); + dbus_message_iter_get_basic (&iter, &_tmp0_); + dbus_message_iter_next (&iter); + interface_name = g_strdup (_tmp0_); + if (strcmp (interface_name, "org.janet.Moonshot") == 0) { + dbus_message_iter_open_container (&reply_iter, DBUS_TYPE_ARRAY, "{sv}", &subiter); + dbus_message_iter_close_container (&reply_iter, &subiter); + } else { + dbus_message_unref (reply); + reply = NULL; + } + g_free (interface_name); + if (reply) { + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + return DBUS_HANDLER_RESULT_HANDLED; + } else { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } +} + + +static DBusHandlerResult _dbus_moonshot_get_identity (Moonshot* self, DBusConnection* connection, DBusMessage* message) { + DBusMessageIter iter; + GError* error; + char* nai = NULL; + const char* _tmp1_; + char* password = NULL; + const char* _tmp2_; + char* service = NULL; + const char* _tmp3_; + char* nai_out = NULL; + char* password_out = NULL; + char* certificate_out = NULL; + gboolean result; + DBusMessage* reply; + const char* _tmp4_; + const char* _tmp5_; + const char* _tmp6_; + dbus_bool_t _tmp7_; + error = NULL; + if (strcmp (dbus_message_get_signature (message), "sss")) { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + dbus_message_iter_init (message, &iter); + dbus_message_iter_get_basic (&iter, &_tmp1_); + dbus_message_iter_next (&iter); + nai = g_strdup (_tmp1_); + dbus_message_iter_get_basic (&iter, &_tmp2_); + dbus_message_iter_next (&iter); + password = g_strdup (_tmp2_); + dbus_message_iter_get_basic (&iter, &_tmp3_); + dbus_message_iter_next (&iter); + service = g_strdup (_tmp3_); + result = moonshot_get_identity (self, nai, password, service, &nai_out, &password_out, &certificate_out, &error); + if (error) { + if (error->domain == DBUS_GERROR) { + switch (error->code) { + case DBUS_GERROR_FAILED: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.Failed", error->message); + break; + case DBUS_GERROR_NO_MEMORY: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.NoMemory", error->message); + break; + case DBUS_GERROR_SERVICE_UNKNOWN: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.ServiceUnknown", error->message); + break; + case DBUS_GERROR_NAME_HAS_NO_OWNER: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.NameHasNoOwner", error->message); + break; + case DBUS_GERROR_NO_REPLY: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.NoReply", error->message); + break; + case DBUS_GERROR_IO_ERROR: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.IOError", error->message); + break; + case DBUS_GERROR_BAD_ADDRESS: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.BadAddress", error->message); + break; + case DBUS_GERROR_NOT_SUPPORTED: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.NotSupported", error->message); + break; + case DBUS_GERROR_LIMITS_EXCEEDED: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.LimitsExceeded", error->message); + break; + case DBUS_GERROR_ACCESS_DENIED: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.AccessDenied", error->message); + break; + case DBUS_GERROR_AUTH_FAILED: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.AuthFailed", error->message); + break; + case DBUS_GERROR_NO_SERVER: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.NoServer", error->message); + break; + case DBUS_GERROR_TIMEOUT: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.Timeout", error->message); + break; + case DBUS_GERROR_NO_NETWORK: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.NoNetwork", error->message); + break; + case DBUS_GERROR_ADDRESS_IN_USE: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.AddressInUse", error->message); + break; + case DBUS_GERROR_DISCONNECTED: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.Disconnected", error->message); + break; + case DBUS_GERROR_INVALID_ARGS: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.InvalidArgs", error->message); + break; + case DBUS_GERROR_FILE_NOT_FOUND: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.FileNotFound", error->message); + break; + case DBUS_GERROR_FILE_EXISTS: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.FileExists", error->message); + break; + case DBUS_GERROR_UNKNOWN_METHOD: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.UnknownMethod", error->message); + break; + case DBUS_GERROR_TIMED_OUT: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.TimedOut", error->message); + break; + case DBUS_GERROR_MATCH_RULE_NOT_FOUND: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.MatchRuleNotFound", error->message); + break; + case DBUS_GERROR_MATCH_RULE_INVALID: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.MatchRuleInvalid", error->message); + break; + case DBUS_GERROR_SPAWN_EXEC_FAILED: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.Spawn.ExecFailed", error->message); + break; + case DBUS_GERROR_SPAWN_FORK_FAILED: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.Spawn.ForkFailed", error->message); + break; + case DBUS_GERROR_SPAWN_CHILD_EXITED: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.Spawn.ChildExited", error->message); + break; + case DBUS_GERROR_SPAWN_CHILD_SIGNALED: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.Spawn.ChildSignaled", error->message); + break; + case DBUS_GERROR_SPAWN_FAILED: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.Spawn.Failed", error->message); + break; + case DBUS_GERROR_UNIX_PROCESS_ID_UNKNOWN: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.UnixProcessIdUnknown", error->message); + break; + case DBUS_GERROR_INVALID_SIGNATURE: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.InvalidSignature", error->message); + break; + case DBUS_GERROR_INVALID_FILE_CONTENT: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.InvalidFileContent", error->message); + break; + case DBUS_GERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown", error->message); + break; + case DBUS_GERROR_REMOTE_EXCEPTION: + reply = dbus_message_new_error (message, "org.freedesktop.DBus.Error.RemoteException", error->message); + break; + } + } + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + return DBUS_HANDLER_RESULT_HANDLED; + } + reply = dbus_message_new_method_return (message); + dbus_message_iter_init_append (reply, &iter); + _g_free0 (nai); + _g_free0 (password); + _g_free0 (service); + _tmp4_ = nai_out; + dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &_tmp4_); + _g_free0 (nai_out); + _tmp5_ = password_out; + dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &_tmp5_); + _g_free0 (password_out); + _tmp6_ = certificate_out; + dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &_tmp6_); + _g_free0 (certificate_out); + _tmp7_ = result; + dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &_tmp7_); + if (reply) { + dbus_connection_send (connection, reply, NULL); + dbus_message_unref (reply); + return DBUS_HANDLER_RESULT_HANDLED; + } else { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } +} + + +DBusHandlerResult moonshot_dbus_message (DBusConnection* connection, DBusMessage* message, void* object) { + DBusHandlerResult result; + result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect")) { + result = _dbus_moonshot_introspect (object, connection, message); + } else if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Properties", "GetAll")) { + result = _dbus_moonshot_property_get_all (object, connection, message); + } else if (dbus_message_is_method_call (message, "org.janet.Moonshot", "GetIdentity")) { + result = _dbus_moonshot_get_identity (object, connection, message); + } + if (result == DBUS_HANDLER_RESULT_HANDLED) { + return result; + } else { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } +} + + +void moonshot_dbus_register_object (DBusConnection* connection, const char* path, void* object) { + if (!g_object_get_data (object, "dbus_object_path")) { + g_object_set_data (object, "dbus_object_path", g_strdup (path)); + dbus_connection_register_object_path (connection, path, &_moonshot_dbus_path_vtable, object); + g_object_weak_ref (object, _vala_dbus_unregister_object, connection); + } +} + + +static void moonshot_base_init (MoonshotIface * iface) { + static gboolean initialized = FALSE; + if (!initialized) { + initialized = TRUE; + g_type_set_qdata (TYPE_MOONSHOT, g_quark_from_static_string ("DBusObjectVTable"), (void*) (&_moonshot_dbus_vtable)); + } +} + + +GType moonshot_get_type (void) { + static volatile gsize moonshot_type_id__volatile = 0; + if (g_once_init_enter (&moonshot_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (MoonshotIface), (GBaseInitFunc) moonshot_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL }; + GType moonshot_type_id; + moonshot_type_id = g_type_register_static (G_TYPE_INTERFACE, "Moonshot", &g_define_type_info, 0); + g_type_interface_add_prerequisite (moonshot_type_id, G_TYPE_OBJECT); + g_type_set_qdata (moonshot_type_id, g_quark_from_string ("ValaDBusInterfaceProxyType"), &moonshot_dbus_proxy_get_type); + g_once_init_leave (&moonshot_type_id__volatile, moonshot_type_id); + } + return moonshot_type_id__volatile; +} + + +G_DEFINE_TYPE_EXTENDED (MoonshotDBusProxy, moonshot_dbus_proxy, DBUS_TYPE_G_PROXY, 0, G_IMPLEMENT_INTERFACE (TYPE_MOONSHOT, moonshot_dbus_proxy_moonshot__interface_init) ); +Moonshot* moonshot_dbus_proxy_new (DBusGConnection* connection, const char* name, const char* path) { + Moonshot* self; + self = g_object_new (moonshot_dbus_proxy_get_type (), "connection", connection, "name", name, "path", path, "interface", "org.janet.Moonshot", NULL); + return self; +} + + +static GObject* moonshot_dbus_proxy_construct (GType gtype, guint n_properties, GObjectConstructParam* properties) { + GObject* self; + DBusGConnection *connection; + char* path; + char* filter; + self = G_OBJECT_CLASS (moonshot_dbus_proxy_parent_class)->constructor (gtype, n_properties, properties); + g_object_get (self, "connection", &connection, NULL); + g_object_get (self, "path", &path, NULL); + dbus_connection_add_filter (dbus_g_connection_get_connection (connection), moonshot_dbus_proxy_filter, self, NULL); + filter = g_strdup_printf ("type='signal',path='%s',interface='org.janet.Moonshot'", path); + dbus_bus_add_match (dbus_g_connection_get_connection (connection), filter, NULL); + dbus_g_connection_unref (connection); + g_free (path); + g_free (filter); + return self; +} + + +DBusHandlerResult moonshot_dbus_proxy_filter (DBusConnection* connection, DBusMessage* message, void* user_data) { + if (dbus_message_has_path (message, dbus_g_proxy_get_path (user_data))) { + } + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + + +static void moonshot_dbus_proxy_dispose (GObject* self) { + DBusGConnection *connection; + if (((MoonshotDBusProxy*) self)->disposed) { + return; + } + ((MoonshotDBusProxy*) self)->disposed = TRUE; + g_object_get (self, "connection", &connection, NULL); + dbus_connection_remove_filter (dbus_g_connection_get_connection (connection), moonshot_dbus_proxy_filter, self); + G_OBJECT_CLASS (moonshot_dbus_proxy_parent_class)->dispose (self); +} + + +static void moonshot_dbus_proxy_class_init (MoonshotDBusProxyClass* klass) { + G_OBJECT_CLASS (klass)->constructor = moonshot_dbus_proxy_construct; + G_OBJECT_CLASS (klass)->dispose = moonshot_dbus_proxy_dispose; + G_OBJECT_CLASS (klass)->get_property = moonshot_dbus_proxy_get_property; + G_OBJECT_CLASS (klass)->set_property = moonshot_dbus_proxy_set_property; +} + + +static void moonshot_dbus_proxy_init (MoonshotDBusProxy* self) { +} + + +static gboolean moonshot_dbus_proxy_get_identity (Moonshot* self, const char* nai, const char* password, const char* service, char** nai_out, char** password_out, char** certificate_out, GError** error) { + DBusError _dbus_error; + DBusGConnection *_connection; + DBusMessage *_message, *_reply; + DBusMessageIter _iter; + const char* _tmp0_; + const char* _tmp1_; + const char* _tmp2_; + char* _nai_out; + const char* _tmp3_; + char* _password_out; + const char* _tmp4_; + char* _certificate_out; + const char* _tmp5_; + gboolean _result; + dbus_bool_t _tmp6_; + if (((MoonshotDBusProxy*) self)->disposed) { + g_set_error (error, DBUS_GERROR, DBUS_GERROR_DISCONNECTED, "%s", "Connection is closed"); + return FALSE; + } + _message = dbus_message_new_method_call (dbus_g_proxy_get_bus_name ((DBusGProxy*) self), dbus_g_proxy_get_path ((DBusGProxy*) self), "org.janet.Moonshot", "GetIdentity"); + dbus_message_iter_init_append (_message, &_iter); + _tmp0_ = nai; + dbus_message_iter_append_basic (&_iter, DBUS_TYPE_STRING, &_tmp0_); + _tmp1_ = password; + dbus_message_iter_append_basic (&_iter, DBUS_TYPE_STRING, &_tmp1_); + _tmp2_ = service; + dbus_message_iter_append_basic (&_iter, DBUS_TYPE_STRING, &_tmp2_); + g_object_get (self, "connection", &_connection, NULL); + dbus_error_init (&_dbus_error); + _reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (_connection), _message, -1, &_dbus_error); + dbus_g_connection_unref (_connection); + dbus_message_unref (_message); + if (dbus_error_is_set (&_dbus_error)) { + GQuark _edomain = 0; + gint _ecode = 0; + if (strstr (_dbus_error.name, "org.freedesktop.DBus.Error") == _dbus_error.name) { + const char* _tmp7_; + _edomain = DBUS_GERROR; + _tmp7_ = _dbus_error.name + 27; + if (strcmp (_tmp7_, "Failed") == 0) { + _ecode = DBUS_GERROR_FAILED; + } else if (strcmp (_tmp7_, "NoMemory") == 0) { + _ecode = DBUS_GERROR_NO_MEMORY; + } else if (strcmp (_tmp7_, "ServiceUnknown") == 0) { + _ecode = DBUS_GERROR_SERVICE_UNKNOWN; + } else if (strcmp (_tmp7_, "NameHasNoOwner") == 0) { + _ecode = DBUS_GERROR_NAME_HAS_NO_OWNER; + } else if (strcmp (_tmp7_, "NoReply") == 0) { + _ecode = DBUS_GERROR_NO_REPLY; + } else if (strcmp (_tmp7_, "IOError") == 0) { + _ecode = DBUS_GERROR_IO_ERROR; + } else if (strcmp (_tmp7_, "BadAddress") == 0) { + _ecode = DBUS_GERROR_BAD_ADDRESS; + } else if (strcmp (_tmp7_, "NotSupported") == 0) { + _ecode = DBUS_GERROR_NOT_SUPPORTED; + } else if (strcmp (_tmp7_, "LimitsExceeded") == 0) { + _ecode = DBUS_GERROR_LIMITS_EXCEEDED; + } else if (strcmp (_tmp7_, "AccessDenied") == 0) { + _ecode = DBUS_GERROR_ACCESS_DENIED; + } else if (strcmp (_tmp7_, "AuthFailed") == 0) { + _ecode = DBUS_GERROR_AUTH_FAILED; + } else if (strcmp (_tmp7_, "NoServer") == 0) { + _ecode = DBUS_GERROR_NO_SERVER; + } else if (strcmp (_tmp7_, "Timeout") == 0) { + _ecode = DBUS_GERROR_TIMEOUT; + } else if (strcmp (_tmp7_, "NoNetwork") == 0) { + _ecode = DBUS_GERROR_NO_NETWORK; + } else if (strcmp (_tmp7_, "AddressInUse") == 0) { + _ecode = DBUS_GERROR_ADDRESS_IN_USE; + } else if (strcmp (_tmp7_, "Disconnected") == 0) { + _ecode = DBUS_GERROR_DISCONNECTED; + } else if (strcmp (_tmp7_, "InvalidArgs") == 0) { + _ecode = DBUS_GERROR_INVALID_ARGS; + } else if (strcmp (_tmp7_, "FileNotFound") == 0) { + _ecode = DBUS_GERROR_FILE_NOT_FOUND; + } else if (strcmp (_tmp7_, "FileExists") == 0) { + _ecode = DBUS_GERROR_FILE_EXISTS; + } else if (strcmp (_tmp7_, "UnknownMethod") == 0) { + _ecode = DBUS_GERROR_UNKNOWN_METHOD; + } else if (strcmp (_tmp7_, "TimedOut") == 0) { + _ecode = DBUS_GERROR_TIMED_OUT; + } else if (strcmp (_tmp7_, "MatchRuleNotFound") == 0) { + _ecode = DBUS_GERROR_MATCH_RULE_NOT_FOUND; + } else if (strcmp (_tmp7_, "MatchRuleInvalid") == 0) { + _ecode = DBUS_GERROR_MATCH_RULE_INVALID; + } else if (strcmp (_tmp7_, "Spawn.ExecFailed") == 0) { + _ecode = DBUS_GERROR_SPAWN_EXEC_FAILED; + } else if (strcmp (_tmp7_, "Spawn.ForkFailed") == 0) { + _ecode = DBUS_GERROR_SPAWN_FORK_FAILED; + } else if (strcmp (_tmp7_, "Spawn.ChildExited") == 0) { + _ecode = DBUS_GERROR_SPAWN_CHILD_EXITED; + } else if (strcmp (_tmp7_, "Spawn.ChildSignaled") == 0) { + _ecode = DBUS_GERROR_SPAWN_CHILD_SIGNALED; + } else if (strcmp (_tmp7_, "Spawn.Failed") == 0) { + _ecode = DBUS_GERROR_SPAWN_FAILED; + } else if (strcmp (_tmp7_, "UnixProcessIdUnknown") == 0) { + _ecode = DBUS_GERROR_UNIX_PROCESS_ID_UNKNOWN; + } else if (strcmp (_tmp7_, "InvalidSignature") == 0) { + _ecode = DBUS_GERROR_INVALID_SIGNATURE; + } else if (strcmp (_tmp7_, "InvalidFileContent") == 0) { + _ecode = DBUS_GERROR_INVALID_FILE_CONTENT; + } else if (strcmp (_tmp7_, "SELinuxSecurityContextUnknown") == 0) { + _ecode = DBUS_GERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN; + } else if (strcmp (_tmp7_, "RemoteException") == 0) { + _ecode = DBUS_GERROR_REMOTE_EXCEPTION; + } + } + g_set_error (error, _edomain, _ecode, "%s", _dbus_error.message); + dbus_error_free (&_dbus_error); + return FALSE; + } + if (strcmp (dbus_message_get_signature (_reply), "sssb")) { + g_set_error (error, DBUS_GERROR, DBUS_GERROR_INVALID_SIGNATURE, "Invalid signature, expected \"%s\", got \"%s\"", "sssb", dbus_message_get_signature (_reply)); + dbus_message_unref (_reply); + return FALSE; + } + dbus_message_iter_init (_reply, &_iter); + dbus_message_iter_get_basic (&_iter, &_tmp3_); + dbus_message_iter_next (&_iter); + _nai_out = g_strdup (_tmp3_); + *nai_out = _nai_out; + dbus_message_iter_get_basic (&_iter, &_tmp4_); + dbus_message_iter_next (&_iter); + _password_out = g_strdup (_tmp4_); + *password_out = _password_out; + dbus_message_iter_get_basic (&_iter, &_tmp5_); + dbus_message_iter_next (&_iter); + _certificate_out = g_strdup (_tmp5_); + *certificate_out = _certificate_out; + dbus_message_iter_get_basic (&_iter, &_tmp6_); + dbus_message_iter_next (&_iter); + _result = _tmp6_; + dbus_message_unref (_reply); + return _result; +} + + +static void moonshot_dbus_proxy_moonshot__interface_init (MoonshotIface* iface) { + iface->get_identity = moonshot_dbus_proxy_get_identity; +} + + +static void moonshot_dbus_proxy_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { +} + + +static void moonshot_dbus_proxy_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { +} + + +void _vala_main (void) { + GError * _inner_error_ = NULL; + { + char* nai_out; + char* password_out; + char* certificate_out; + DBusGConnection* conn; + Moonshot* demo; + char* _tmp0_ = NULL; + gboolean _tmp1_; + char* _tmp2_; + char* _tmp3_ = NULL; + gboolean _tmp4_; + char* _tmp5_; + char* _tmp6_ = NULL; + gboolean _tmp7_; + char* _tmp8_; + gboolean _tmp9_; + nai_out = NULL; + password_out = NULL; + certificate_out = NULL; + conn = dbus_g_bus_get (DBUS_BUS_SESSION, &_inner_error_); + if (_inner_error_ != NULL) { + _g_free0 (certificate_out); + _g_free0 (password_out); + _g_free0 (nai_out); + if (_inner_error_->domain == DBUS_GERROR) { + goto __catch0_dbus_gerror; + } + _g_free0 (certificate_out); + _g_free0 (password_out); + _g_free0 (nai_out); + g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return; + } + demo = moonshot_dbus_proxy_new (conn, "org.janet.Moonshot", "/org/janet/moonshot"); + _tmp9_ = (_tmp7_ = (_tmp4_ = (_tmp1_ = moonshot_get_identity (demo, "username@issuer", "pass", "service", &_tmp0_, &_tmp3_, &_tmp6_, &_inner_error_), nai_out = (_tmp2_ = _tmp0_, _g_free0 (nai_out), _tmp2_), _tmp1_), password_out = (_tmp5_ = _tmp3_, _g_free0 (password_out), _tmp5_), _tmp4_), certificate_out = (_tmp8_ = _tmp6_, _g_free0 (certificate_out), _tmp8_), _tmp7_); + if (_inner_error_ != NULL) { + _g_object_unref0 (demo); + _dbus_g_connection_unref0 (conn); + _g_free0 (certificate_out); + _g_free0 (password_out); + _g_free0 (nai_out); + if (_inner_error_->domain == DBUS_GERROR) { + goto __catch0_dbus_gerror; + } + _g_object_unref0 (demo); + _dbus_g_connection_unref0 (conn); + _g_free0 (certificate_out); + _g_free0 (password_out); + _g_free0 (nai_out); + g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return; + } + if (_tmp9_) { + fprintf (stdout, "%s %s %s\n", nai_out, password_out, certificate_out); + } else { + fprintf (stdout, "The nai, password or service doesnt match the selected id_card\n"); + } + _g_object_unref0 (demo); + _dbus_g_connection_unref0 (conn); + _g_free0 (certificate_out); + _g_free0 (password_out); + _g_free0 (nai_out); + } + goto __finally0; + __catch0_dbus_gerror: + { + GError * e; + e = _inner_error_; + _inner_error_ = NULL; + { + fprintf (stderr, "%s\n", e->message); + _g_error_free0 (e); + } + } + __finally0: + if (_inner_error_ != NULL) { + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return; + } +} + + +int main (int argc, char ** argv) { + g_type_init (); + _vala_main (); + return 0; +} + + + + diff --git a/src_dbus_client_vala.stamp b/src_dbus_client_vala.stamp new file mode 100644 index 0000000..e69de29