// The following code was send to me by Michael Hawley (c)
// Carefully modified by Sven Lehmann to fit at Zoom.app

/*
 * Implement the "suggestion" box, to catch user's comments,
 * and also a simple tracking mechanism, to send a blip of
 * mail from the first-time user.  This is akin to releasing
 * helium balloons with postcards that say "If you find me,
 * send this card back to . . ." -- it should be interesting
 * to the community to track the free flow of software on
 * the ethernet.
 *
 * If you have any concerns about this, please check with me.
 *
 * Michael Hawley
 * mike@media-lab.mit.edu
 */

static char *stripnl(char *s)
{
    char	*p;

    	for (p=s;*p;p++) if (*p == '\n' || *p == '\r') *p = '\0';
    	return s;
}

char *execstr(s) char *s;
{
    FILE	*f = popen(s,"r");
    char	*p = s;

    *s = '\0';
    	if (f) {
        	while (fgets(p,256,f))
            	stripnl(p), p += strlen(p);
        	pclose(f);
    	}
    return s;
}

- suggestion: sender
{
	#define call(a,b) [s performRemoteMethod: a with: b length: strlen(b) + 1]

    char	subj[256], w[256] = "whoami";
    char	body[4096]= "Sven:\n\n"
						"A handy bit of software!  Using your"
						" magnificient\napplication gives me fun for days"
						" and enjoys my soul.\nNevertheless, I have these"
						" scrimpy electronic comments:\n\n\n"
						"   <insert accolades & suggestions here>\n\n\n"
						"             parsimoniously,\n"
						"                             ";

    id	s = [NXApp appSpeaker];

    NXPortFromName("Mail", NULL);	// make sure app is launched
    [s setSendPort: NXPortFromName("MailSendDemo", NULL)];

    sprintf(subj, "Comments and suggestions for BibTeXfrontend (V%s)",
			 "0.99f");
    strcat(body, execstr(w)); strcat(body, "\n");
    call("setTo:", "giesen@informatik.uni-koblenz.de");
    call("setSubject:", subj);
    call("setBody:", body);

    return self;
}
