chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / keydis.c
index e921f794ac163eced28d3e1ea1a1052e1395e521..9a7bd45398c00b86f8363bcb931ea1d6263dd673 100644 (file)
@@ -10,6 +10,18 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.5  2008/02/23 11:48:37  james
+ * *** empty log message ***
+ *
+ * Revision 1.4  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
+ * Revision 1.3  2008/02/15 23:52:12  james
+ * *** empty log message ***
+ *
+ * Revision 1.2  2008/02/15 03:32:07  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/14 02:46:44  james
  * *** empty log message ***
  *
@@ -21,10 +33,11 @@ static char rcsid[] = "$Id$";
 
 #include "project.h"
 
+#define CMD_BUFLEN     128
+
 typedef struct
 {
   KEYDIS_SIGNATURE;
-  Context *c;
 } KeyDis_VT102;
 
 typedef struct
@@ -42,7 +55,7 @@ keydis_close (KeyDis * t)
 
 
 static int
-keydis_ipc_key (KeyDis * _t, int key)
+keydis_ipc_key (KeyDis * _t, Context * c, int key)
 {
   KeyDis_IPC *t = (KeyDis_IPC *) _t;
 
@@ -50,22 +63,135 @@ keydis_ipc_key (KeyDis * _t, int key)
 }
 
 static int
-keydis_vt102_key (KeyDis * _t, int key)
+keydis_ipc_set_baud (KeyDis * _t, Context * c, int baud)
+{
+  KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+  ipc_msg_send_setbaud (t->s, baud);
+
+  return 0;
+}
+
+static int
+keydis_ipc_send_break (KeyDis * _t, Context * c)
+{
+  KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+  ipc_msg_send_sendbreak (t->s);
+
+  return 0;
+}
+
+static int
+keydis_ipc_set_flow (KeyDis * _t, Context * c, int flow)
+{
+  KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+  ipc_msg_send_setflow (t->s, flow);
+
+  return 0;
+}
+
+
+static int
+keydis_ipc_set_ansi (KeyDis * _t, Context * c, int ansi)
+{
+  KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+  vt102_set_ansi (c->v, ansi);
+
+  ipc_msg_send_setansi (t->s, ansi);
+
+  return 0;
+}
+
+
+static int
+keydis_ipc_hangup (KeyDis * _t, Context * c)
+{
+  KeyDis_IPC *t = (KeyDis_IPC *) _t;
+
+  ipc_msg_send_hangup (t->s);
+
+  return 0;
+}
+
+static int
+keydis_vt102_key (KeyDis * _t, Context * c, int key)
+{
+  KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+  vt102_send (c, key);
+  return 0;
+}
+
+static int
+keydis_vt102_set_baud (KeyDis * _t, Context * c, int baud)
+{
+  KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+  tty_set_baud (c->t, baud);
+  tty_parse_reset (c);
+
+  log_f (c->l, "<baud changed to %d>", baud);
+
+  return 0;
+}
+
+static int
+keydis_vt102_send_break (KeyDis * _t, Context * c)
+{
+  KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+  tty_send_break (c->t);
+
+  return 0;
+}
+
+static int
+keydis_vt102_set_flow (KeyDis * _t, Context * c, int flow)
+{
+  KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+  tty_set_flow (c->t, flow);
+
+  return 0;
+}
+
+static int
+keydis_vt102_set_ansi (KeyDis * _t, Context * c, int ansi)
+{
+  KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
+
+  if (c->v)
+    c->v->xn_glitch = ansi ? 0 : 1;
+  return 0;
+}
+
+
+static int
+keydis_vt102_hangup (KeyDis * _t, Context * c)
 {
   KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
 
-  vt102_send (t->c, key);
+  tty_hangup (c->t);
+
   return 0;
 }
 
 
+
 KeyDis *
-keydis_vt102_new (Context * c)
+keydis_vt102_new (void)
 {
   KeyDis_VT102 *t = malloc (sizeof (KeyDis_VT102));
   t->key = keydis_vt102_key;
   t->close = keydis_close;
-  t->c = c;
+  t->set_baud = keydis_vt102_set_baud;
+  t->send_break = keydis_vt102_send_break;
+  t->set_flow = keydis_vt102_set_flow;
+  t->set_ansi = keydis_vt102_set_ansi;
+  t->hangup = keydis_vt102_hangup;
   return (KeyDis *) t;
 }
 
@@ -76,6 +202,35 @@ keydis_ipc_new (Socket * s)
   KeyDis_IPC *t = malloc (sizeof (KeyDis_IPC));
   t->key = keydis_ipc_key;
   t->close = keydis_close;
+  t->set_baud = keydis_ipc_set_baud;
+  t->send_break = keydis_ipc_send_break;
+  t->set_flow = keydis_ipc_set_flow;
+  t->set_ansi = keydis_ipc_set_ansi;
+  t->hangup = keydis_ipc_hangup;
   t->s = s;
   return (KeyDis *) t;
 }
+
+
+
+
+
+
+int
+keydis_key (KeyDis * t, Context * c, int key)
+{
+
+  if (!c->d)
+    return t->key (t, c, key);
+
+  cmd_show_status (c->d, c);
+
+  if (c->d->active)
+    return cmd_key (c->d, c, key);
+
+  if (key == CMD_KEY)
+    return cmd_activate (c->d, c);
+
+
+  return t->key (t, c, key);
+}