~ubuntu-branches/ubuntu/quantal/texmacs/quantal

« back to all changes in this revision

Viewing changes to src/System/Link/connection.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Atsuhito KOHDA, Kamaraju Kusumanchi, kohda
  • Date: 2009-04-26 19:35:14 UTC
  • mfrom: (1.1.10 upstream) (4.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090426193514-9yo3oggdslgdls4b
Tags: 1:1.0.7.2-1
[Kamaraju Kusumanchi <kamaraju@gmail.com>]
* New upstream release
* texmacs crashes if /usr/share/texmacs/TeXmacs/misc/pixmaps/unknown.ps
  is not present. Do not remove it. (Closes: #484073, #497021)
* update patches 03_mupad.dpatch, 04_axiom.dpatch, 11-desktop-file.dpatch
* fix the mime problem in gnome. Thanks to Andrea Gamba for the fix.
[kohda]
* Refined a fix for the mime problem in gnome a bit.
* Try to fix /bin/sh problem (debian/fixsh) but it is not complete fix yet.
* Try to fix hard coded settings for ipa fonts(patches/09_ipa.dpatch), 
  especially for Debian where no ipa fonts exist yet.
* Fixed obsolete Build-Depends: changed libltdl3-dev to 
  libltdl-dev | libltdl7-dev (the latter for Ubuntu?)

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
* CONNECTION_DEAD (usually) or CONNECTION_DYING (if we are still
12
12
* waiting for some residual output from the plugin).
13
13
*******************************************************************************
14
 
* This software falls under the GNU general public license and comes WITHOUT
15
 
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
16
 
* If you don't have this file, write to the Free Software Foundation, Inc.,
17
 
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
14
* This software falls under the GNU general public license version 3 or later.
 
15
* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
 
16
* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
18
17
******************************************************************************/
19
18
 
20
19
#include "connect.hpp"
38
37
  string  session;       // name of the session
39
38
  tm_link ln;            // the underlying link
40
39
  int     status;        // status of the connection
 
40
  int     prev_status;   // last notified status
41
41
  texmacs_input tm_in;   // texmacs input handler for data from child
42
42
  texmacs_input tm_err;  // texmacs input handler for errors from child
43
43
 
57
57
 
58
58
connection_rep::connection_rep (string name2, string session2, tm_link ln2):
59
59
  rep<connection> (name2 * "-" * session2),
60
 
  name (name2), session (session2), ln (ln2), status (CONNECTION_DEAD),
 
60
  name (name2), session (session2), ln (ln2),
 
61
  status (CONNECTION_DEAD), prev_status (CONNECTION_DEAD),
61
62
  tm_in ("output"), tm_err ("error") {}
62
63
 
63
64
string
139
140
******************************************************************************/
140
141
 
141
142
void
 
143
connection_notify (connection con, string ch, tree t) {
 
144
  if (t == "") return;
 
145
  call ("connection-notify",
 
146
        object (con->name),
 
147
        object (con->session),
 
148
        object (ch),
 
149
        object (t));
 
150
}
 
151
 
 
152
void
 
153
connection_notify_status (connection con) {
 
154
  int status=
 
155
    (con->status == CONNECTION_DYING? WAITING_FOR_OUTPUT: con->status);
 
156
  if (status == con->prev_status) return;
 
157
  call ("connection-notify-status",
 
158
        object (con->name),
 
159
        object (con->session),
 
160
        object (status));
 
161
  con->prev_status= status;
 
162
}
 
163
 
 
164
void
142
165
listen_to_connections () {
143
166
  iterator<string> it= iterate (connection::instances);
144
167
  while (it->busy()) {
145
168
    string name= it->next ();
146
169
    connection con (name);
147
 
    if ((con->status == WAITING_FOR_INPUT) ||
148
 
        (con->status == WAITING_FOR_OUTPUT))
149
 
      {
150
 
        tree t= connection_handlers (con->name);
151
 
        int i, n= N(t);
152
 
        if (n>0) con->read (LINK_ERR);
153
 
        for (i=0; i<n; i++) {
154
 
          tree doc= con->tm_err->get (t[i][0]->label);
155
 
          if (doc != "") call (t[i][1]->label, doc);
156
 
        }
 
170
    connection_notify_status (con);
 
171
    if (con->status != CONNECTION_DEAD) {
 
172
      con->read (LINK_ERR);
 
173
      connection_notify (con, "error", con->tm_err->get ("error"));
 
174
      con->read (LINK_OUT);
 
175
      connection_notify (con, "output", con->tm_in->get ("output"));
 
176
      connection_notify (con, "prompt", con->tm_in->get ("prompt"));
 
177
      connection_notify (con, "input", con->tm_in->get ("input"));
 
178
      tree t= connection_handlers (con->name);
 
179
      int i, n= N(t);
 
180
      for (i=0; i<n; i++) {
 
181
        tree doc= con->tm_in->get (t[i][0]->label);
 
182
        if (doc != "") call (t[i][1]->label, doc);
 
183
        doc= con->tm_err->get (t[i][0]->label);
 
184
        if (doc != "") call (t[i][1]->label, doc);
157
185
      }
 
186
    }
 
187
    connection_notify_status (con);
158
188
  }
159
189
}
160
190
 
186
216
 
187
217
string
188
218
connection_start (string name, string session, bool again) {
189
 
  // cout << "Start " << name << ", " << session << ", " << again << "\n";
 
219
  // cout << "Start " << name << ", " << session << "\n";
190
220
  if (!connection_declared (name))
191
221
    return "Error: connection " * name * " has not been declared";
192
222
 
197
227
    tree t= connection_info (name, session);
198
228
    if (is_tuple (t, "pipe", 1)) {
199
229
      tm_link ln= make_pipe_link (t[1]->label);
200
 
      con= new connection_rep (name, session, ln);
 
230
      con= tm_new<connection_rep> (name, session, ln);
201
231
    }
202
232
    else if (is_tuple (t, "socket", 2)) {
203
233
      tm_link ln= make_socket_link (t[1]->label, as_int (t[2]->label));
204
 
      con= new connection_rep (name, session, ln);
 
234
      con= tm_new<connection_rep> (name, session, ln);
205
235
    }
206
236
    else if (is_tuple (t, "dynlink", 3)) {
207
237
      tm_link ln=
208
238
        make_dynamic_link (t[1]->label, t[2]->label, t[3]->label, session);
209
 
      con= new connection_rep (name, session, ln);
 
239
      con= tm_new<connection_rep> (name, session, ln);
210
240
    }
211
241
  }
212
242