AM_CPPFLAGS += -Isrc
AM_VALAFLAGS += \
- --pkg moonshot-msrpc --pkg msrpc-1.0 \
+ --pkg moonshot-msrpc --pkg msrpc-1.0 --pkg msrpc-1.0-extra \
--define=IPC_MSRPC
BUILT_SOURCES = libmoonshot/moonshot-msrpc.h \
DISTCLEANFILES = ${BUILT_SOURCES}
+export MIDL_NATIVE = ${MIDL}
+
libmoonshot/moonshot-msrpc.h: libmoonshot/moonshot-msrpc.idl libmoonshot/moonshot-msrpc.acf
- ${AM_V_GEN} ${MIDL_WRAPPER} -o libmoonshot -m "${MIDL}" $^
+ ${AM_V_GEN} ${MIDL_WRAPPER} -o libmoonshot -m ${top_builddir}/moonshot-midl $^
libmoonshot/moonshot-msrpc_s.c: libmoonshot/moonshot-msrpc.h
libmoonshot/moonshot-msrpc_c.c: libmoonshot/moonshot-msrpc.h
nodist_src_moonshot_SOURCES = \
- libmoonshot/moonshot-msrpc_s.c
+ libmoonshot/moonshot-msrpc_s.c \
+ libmoonshot/moonshot-msrpc_c.c
+
nodist_libmoonshot_libmoonshot_la_SOURCES = \
libmoonshot/moonshot-msrpc_c.c
#define MOONSHOT_ENDPOINT_NAME "/org/janet/Moonshot"
#define MOONSHOT_INSTALL_PATH_KEY "Software\\Moonshot"
+#define MOONSHOT_STARTUP_ARGS "--dbus-launched"
void *__RPC_USER MIDL_user_allocate (size_t size) {
return malloc (size);
LONG status;
BOOL success;
DWORD value_type;
+ DWORD commandline_length;
DWORD length;
+ char* commandline=NULL;
char* exe_path=NULL;
status = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
exe_path[length] = 0;
startup_info.cb = sizeof (startup_info);
+ commandline_length = length + 1 + sizeof(MOONSHOT_STARTUP_ARGS);
+ commandline = malloc(commandline_length + 1);
+ if (commandline == NULL) {
+ *error = moonshot_error_new
+ (MOONSHOT_ERROR_OS_ERROR,
+ "Out of memory allocating %d bytes for moonshot commandline.",
+ length);
+ goto cleanup;
+ }
+ snprintf(commandline, commandline_length, "%s %s", exe_path, MOONSHOT_STARTUP_ARGS);
+ commandline[commandline_length] = 0;
success = CreateProcess (exe_path,
- NULL,
+ commandline,
NULL,
NULL,
TRUE,
cleanup:
if (exe_path)
free(exe_path);
+ if (commandline)
+ free(commandline);
}
static void bind_rpc (MoonshotError **error)
*subject_alt_name_constraint_out = NULL;
RPC_TRY_EXCEPT {
- moonshot_get_identity_rpc (&call,
+ c_moonshot_get_identity_rpc (&call,
nai,
password,
service,
*subject_alt_name_constraint_out = NULL;
RPC_TRY_EXCEPT {
- moonshot_get_default_identity_rpc (&call,
+ c_moonshot_get_default_identity_rpc (&call,
nai_out,
password_out,
server_certificate_hash_out,
if (server_cert == NULL) server_cert = "";
RPC_TRY_EXCEPT {
- success = moonshot_install_id_card_rpc (display_name,
+ success = c_moonshot_install_id_card_rpc (display_name,
user_name,
password,
realm,
[in, string] const char *subject_alt,
[in, string] const char *server_cert,
int force_flat_file_store);
+
+ void moonshot_show_ui_rpc ();
}
--- /dev/null
+#!/bin/sh
+"$MIDL_NATIVE" -prefix client "c_" "$@"
private static MoonshotServer instance = null;
+ private static void log_function(uint status_code,
+ string format,
+ va_list args)
+ {
+ stdout.printf("RPC Error %u:\n ", status_code);
+ stdout.vprintf(format, args);
+ stdout.printf("\n");
+ stdout.flush();
+ }
+
public static void start (IdentityManagerApp app)
{
parent_app = app;
- Rpc.server_start (MoonshotRpcInterface.spec, "/org/janet/Moonshot", Rpc.Flags.PER_USER);
+ /* Rpc.server_start() would conveniently call Rpc.init() for us.
+ * Unfortunately, the default log function calls exit() on any
+ * error. We'd prefer to send a message to the existing server
+ * if there is one, so we need to use a custom log function.
+ */
+ Rpc.init();
+ Rpc.set_log_function(log_function);
+ if (Rpc.server_start (MoonshotRpcInterface.spec, "/org/janet/Moonshot", Rpc.Flags.PER_USER) != 0) {
+ /* Server failed to start; bind as client and send message to server to show ui */
+ uint status = Rpc.client_bind(ref MoonshotRpcInterface.binding_handle, "/org/janet/Moonshot", Rpc.Flags.PER_USER);
+ if (status != 0) {
+ /* total failure; log error message and bail */
+ GLib.log("Moonshot UI", GLib.LogLevelFlags.LEVEL_INFO, "Could neither launch server nor bind as client. status code: %u", status);
+ } else {
+ MoonshotRpcInterface.show_ui();
+ }
+ GLib.Process.exit(0);
+ }
}
public static MoonshotServer get_instance ()
return instance;
}
+ [CCode (cname = "moonshot_show_ui_rpc")]
+ public static void show_ui ()
+ {
+ Idle.add( () => {
+ parent_app.show();
+ parent_app.explicitly_launched = true;
+ return false;
+ });
+ }
+
[CCode (cname = "moonshot_get_identity_rpc")]
public static void get_identity (Rpc.AsyncCall call,
string nai,
string always_confirm;
}
- [CCode (cname = "moonshot_get_identity_rpc")]
+ [CCode (cname = "c_moonshot_show_ui_rpc")]
+ public extern void show_ui();
+
+ [CCode (cname = "c_moonshot_get_identity_rpc")]
public extern void get_identity (Rpc.AsyncCall call,
string nai,
string password,
ref string subject_name_constraint,
ref string subject_alt_name_constraint);
- [CCode (cname = "moonshot_get_default_identity_rpc")]
+ [CCode (cname = "c_moonshot_get_default_identity_rpc")]
public extern void get_default_identity (Rpc.AsyncCall call,
ref string nai_out,
ref string password_out);
--- /dev/null
+[CCode (cprefix = "rpc_", cheader_filename = "msrpc-mingw.h")]
+
+namespace Rpc {
+ [CCode (cname = "rpc_init")]
+ public void init ();
+}