Commit 7e8147aadfcf7a5117195f0902c2e9c5945d0092
1 parent
eeddb160
Exists in
master
and in
1 other branch
+ Implementing IPC methods for linux.
Showing
1 changed file
with
42 additions
and
3 deletions
Show diff stats
src/linux/methods.c
| ... | ... | @@ -49,7 +49,18 @@ ipc3270_method_call (GDBusConnection *connection, |
| 49 | 49 | GDBusMethodInvocation *invocation, |
| 50 | 50 | gpointer user_data) |
| 51 | 51 | { |
| 52 | + | |
| 53 | + static const struct | |
| 54 | + { | |
| 55 | + const gchar *name; | |
| 56 | + int (*call)(H3270 *hSession, int keycode); | |
| 57 | + } int_methods[] = { | |
| 58 | + { "pfkey", lib3270_pfkey }, | |
| 59 | + { "pakey", lib3270_pakey } | |
| 60 | + }; | |
| 61 | + | |
| 52 | 62 | size_t ix; |
| 63 | + g_autoptr (GError) error = NULL; | |
| 53 | 64 | |
| 54 | 65 | // Check action table. |
| 55 | 66 | const LIB3270_ACTION_ENTRY * actions = lib3270_get_action_table(); |
| ... | ... | @@ -57,13 +68,11 @@ ipc3270_method_call (GDBusConnection *connection, |
| 57 | 68 | { |
| 58 | 69 | if(!g_ascii_strcasecmp(actions[ix].name,method_name)) { |
| 59 | 70 | |
| 60 | - g_autoptr (GError) error = NULL; | |
| 61 | - | |
| 62 | 71 | int rc = actions[ix].call(IPC3270(user_data)->hSession); |
| 63 | 72 | if(rc) |
| 64 | 73 | { |
| 65 | 74 | // Failed |
| 66 | - g_set_error(error,IPC3270(user_data)->error_domain,errno,"%s: %s",method_name,strerror(errno)); | |
| 75 | + g_set_error(&error,IPC3270(user_data)->error_domain,errno,"%s: %s",method_name,strerror(errno)); | |
| 67 | 76 | g_dbus_method_invocation_return_gerror(invocation, error); |
| 68 | 77 | } |
| 69 | 78 | else |
| ... | ... | @@ -72,9 +81,39 @@ ipc3270_method_call (GDBusConnection *connection, |
| 72 | 81 | g_dbus_method_invocation_return_value (invocation, g_variant_new_int16((gint16) 0)); |
| 73 | 82 | |
| 74 | 83 | } |
| 84 | + | |
| 85 | + return; | |
| 75 | 86 | } |
| 76 | 87 | } |
| 77 | 88 | |
| 89 | + // Check int methods | |
| 90 | + for(ix = 0; ix < G_N_ELEMENTS(int_methods); ix++) | |
| 91 | + { | |
| 92 | + if(!g_ascii_strcasecmp(int_methods[ix].name,method_name)) { | |
| 93 | + | |
| 94 | + gint value; | |
| 95 | + g_variant_get(parameters, "(i)", &value); | |
| 96 | + | |
| 97 | + int rc = int_methods[ix].call(IPC3270(user_data)->hSession, value); | |
| 98 | + if(rc) | |
| 99 | + { | |
| 100 | + // Failed | |
| 101 | + g_set_error(&error,IPC3270(user_data)->error_domain,errno,"%s: %s",method_name,strerror(errno)); | |
| 102 | + g_dbus_method_invocation_return_gerror(invocation, error); | |
| 103 | + } | |
| 104 | + else | |
| 105 | + { | |
| 106 | + // Suceeded | |
| 107 | + g_dbus_method_invocation_return_value (invocation, g_variant_new_int16((gint16) 0)); | |
| 108 | + | |
| 109 | + } | |
| 110 | + | |
| 111 | + return; | |
| 112 | + | |
| 113 | + } | |
| 114 | + | |
| 115 | + } | |
| 116 | + | |
| 78 | 117 | g_dbus_method_invocation_return_error ( |
| 79 | 118 | invocation, |
| 80 | 119 | G_DBUS_ERROR, | ... | ... |