1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
2003-11-06 23:27:05 +08:00
|
|
|
* Copyright (C) 1997 Daniel Risacher
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2000-01-16 23:38:38 +08:00
|
|
|
* GUMP - Gimp Useless Mail Plugin (or Gump Useless Mail Plugin if you prefer)
|
|
|
|
* version about .85 I would say... give or take a few decimal points
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* by Adrian Likins <adrian@gimp.org>
|
|
|
|
* MIME encapsulation by Reagan Blundell <reagan@emails.net>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Based heavily on gz.c by Daniel Risacher
|
|
|
|
*
|
|
|
|
* Lets you choose to send a image to the mail from the file save as dialog.
|
|
|
|
* images are piped to uuencode and then to mail...
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This works fine for .99.10. I havent actually tried it in combination with
|
|
|
|
* the gz plugin, but it works with all other file types. I will eventually get
|
|
|
|
* around to making sure it works with gz.
|
|
|
|
*
|
|
|
|
* To use: 1) image->File->mail image
|
|
|
|
* 2) when the mail dialog popups up, fill it out. Only to: and filename are required
|
|
|
|
* note: the filename needs to a type that the image can be saved as. otherwise
|
|
|
|
* you will just send an empty message.
|
|
|
|
* 3) click ok and it should be on its way
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* NOTE: You probabaly need sendmail installed. If your sendmail is in an odd spot
|
|
|
|
* you can change the #define below. If you use qmail or other MTA's, and this
|
|
|
|
* works after changing the MAILER, let me know how well or what changes were
|
|
|
|
* needed.
|
|
|
|
*
|
|
|
|
* NOTE: Uuencode is needed. If it is in the path, it should work fine as is. Other-
|
|
|
|
* wise just change the UUENCODE.
|
|
|
|
*
|
|
|
|
*
|
2003-11-06 23:27:05 +08:00
|
|
|
* TODO: 1) the aforementioned abilty to specify the
|
2000-01-16 23:38:38 +08:00
|
|
|
* uuencode filename *done*
|
|
|
|
* 2) someway to do this without tmp files
|
|
|
|
* * wont happen anytime soon*
|
|
|
|
* 3) MIME? *done*
|
|
|
|
* 4) a pointlessly snazzier dialog
|
2003-11-06 23:27:05 +08:00
|
|
|
* 5) make sure it works with gz
|
2000-01-16 23:38:38 +08:00
|
|
|
* * works for .xcfgz but not .xcf.gz *
|
2003-11-06 23:27:05 +08:00
|
|
|
* 6) add an option to choose if mail get
|
2000-01-16 23:38:38 +08:00
|
|
|
* uuencode or not (or MIME'ed for that matter)
|
|
|
|
* 7) realtime preview
|
|
|
|
* 8) better entry for comments *done*
|
2003-11-06 23:27:05 +08:00
|
|
|
* 9) list of frequently used addreses
|
2000-01-16 23:38:38 +08:00
|
|
|
* 10) openGL compliance
|
|
|
|
* 11) better handling of filesave errors
|
2003-11-06 23:27:05 +08:00
|
|
|
*
|
2000-01-16 23:38:38 +08:00
|
|
|
*
|
|
|
|
* Version history
|
|
|
|
* .5 - 6/30/97 - inital relese
|
|
|
|
* .51 - 7/3/97 - fixed a few spelling errors and the like
|
|
|
|
* .65 - 7/4/97 - a fairly significant revision. changed it from a file
|
|
|
|
* plugin to an image plugin.
|
|
|
|
* - Changed some strcats into strcpy to be a bit more robust.
|
|
|
|
* - added the abilty to specify the filename you want it sent as
|
|
|
|
* - no more annoying hassles with the file saves as dialog
|
|
|
|
* - plugin now registers itself as <image>/File/Mail image
|
|
|
|
* .7 - 9/12/97 - (RB) added support for MIME encapsulation
|
|
|
|
* .71 - 9/17/97 - (RB) included Base64 encoding functions from mpack
|
|
|
|
* instead of using external program.
|
|
|
|
* - General cleanup of the MIME handling code.
|
|
|
|
* .80 - 6/23/98 - Added a text box so you can compose real messages.
|
|
|
|
* .85 - 3/19/99 - Added a "From:" field. Made it check gimprc for a
|
2003-11-06 23:27:05 +08:00
|
|
|
* "gump-from" token and use it. Also made "run with last
|
2000-01-16 23:38:38 +08:00
|
|
|
* values" work.
|
|
|
|
* As always: The utility of this plugin is left as an exercise for the reader
|
|
|
|
*
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define ENCAPSULATION_UUENCODE 0
|
|
|
|
#define ENCAPSULATION_MIME 1
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
#define BUFFER_SIZE 256
|
|
|
|
|
2000-01-07 18:39:33 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2002-05-28 08:59:27 +08:00
|
|
|
#ifndef SENDMAIL
|
|
|
|
#define SENDMAIL "/usr/lib/sendmail"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef UUENCODE
|
|
|
|
#define UUENCODE "uuencode"
|
|
|
|
#endif
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
1999-05-17 20:27:10 +08:00
|
|
|
#include <sys/types.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
1999-05-17 20:27:10 +08:00
|
|
|
#ifdef __EMX__
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <process.h>
|
|
|
|
#endif
|
2000-01-07 18:39:33 +08:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2000-01-09 04:00:10 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-05-30 00:35:47 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-02 01:01:18 +08:00
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
static void query (void);
|
2003-07-02 20:03:08 +08:00
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
|
|
|
|
|
|
|
static GimpPDBStatusType save_image (const gchar *filename,
|
|
|
|
gint32 image_ID,
|
|
|
|
gint32 drawable_ID,
|
|
|
|
gint32 run_mode);
|
|
|
|
|
|
|
|
static gint save_dialog (void);
|
|
|
|
static void mail_entry_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void mesg_body_callback (GtkTextBuffer *buffer,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static gint valid_file (const gchar *filename);
|
|
|
|
static void create_headers (FILE *mailpipe);
|
|
|
|
static gchar * find_extension (const gchar *filename);
|
|
|
|
static gint to64 (FILE *infile,
|
|
|
|
FILE *outfile);
|
|
|
|
static void output64chunk (gint c1,
|
|
|
|
gint c2,
|
|
|
|
gint c3,
|
|
|
|
gint pads,
|
|
|
|
FILE *outfile);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-16 23:38:38 +08:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run, /* run_proc */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
2000-01-16 23:38:38 +08:00
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
gchar receipt[BUFFER_SIZE];
|
|
|
|
gchar subject[BUFFER_SIZE];
|
|
|
|
gchar comment[BUFFER_SIZE];
|
|
|
|
gchar from[BUFFER_SIZE];
|
|
|
|
gchar filename[BUFFER_SIZE];
|
2000-01-16 23:38:38 +08:00
|
|
|
gint encapsulation;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
m_info;
|
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
static m_info mail_info =
|
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
/* I would a assume there is a better way to do this, but this works for now */
|
|
|
|
"\0",
|
|
|
|
"\0",
|
|
|
|
"\0",
|
|
|
|
"\0",
|
1999-03-19 17:12:36 +08:00
|
|
|
"\0",
|
1997-11-25 06:05:25 +08:00
|
|
|
ENCAPSULATION_MIME, /* Change this to ENCAPSULATION_UUENCODE
|
|
|
|
if you prefer that as the default */
|
|
|
|
};
|
|
|
|
|
2001-09-17 20:01:27 +08:00
|
|
|
static gchar * mesg_body = NULL;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
MAIN ()
|
|
|
|
|
|
|
|
static void
|
2000-01-16 23:38:38 +08:00
|
|
|
query (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpParamDef args[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
|
|
|
|
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" },
|
|
|
|
{ GIMP_PDB_STRING, "filename", "The name of the file to save the image in" },
|
|
|
|
{ GIMP_PDB_STRING, "receipt", "The email address to send to" },
|
|
|
|
{ GIMP_PDB_STRING, "from", "The email address for the From: field" },
|
|
|
|
{ GIMP_PDB_STRING, "subject", "The subject" },
|
|
|
|
{ GIMP_PDB_STRING, "comment", "The Comment" },
|
|
|
|
{ GIMP_PDB_INT32, "encapsulation", "Uuencode, MIME" }
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
1999-05-30 00:35:47 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_install_procedure ("plug_in_mail_image",
|
2000-01-31 10:32:30 +08:00
|
|
|
"pipe files to uuencode then mail them",
|
|
|
|
"You need to have uuencode and mail installed",
|
1997-11-25 06:05:25 +08:00
|
|
|
"Adrian Likins, Reagan Blundell",
|
|
|
|
"Adrian Likins, Reagan Blundell, Daniel Risacher, Spencer Kimball and Peter Mattis",
|
|
|
|
"1995-1997",
|
2003-07-17 23:47:18 +08:00
|
|
|
N_("<Image>/File/_Mail Image..."),
|
1997-11-25 06:05:25 +08:00
|
|
|
"RGB*, GRAY*, INDEXED*",
|
2000-08-22 09:26:57 +08:00
|
|
|
GIMP_PLUGIN,
|
2001-12-06 10:28:58 +08:00
|
|
|
G_N_ELEMENTS (args), 0,
|
2000-05-02 01:01:18 +08:00
|
|
|
args, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-07-02 20:03:08 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-08-25 23:38:38 +08:00
|
|
|
static GimpParam values[2];
|
2001-12-29 21:26:29 +08:00
|
|
|
GimpRunMode run_mode;
|
2000-08-25 23:38:38 +08:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
2001-12-29 21:26:29 +08:00
|
|
|
gint32 image_ID;
|
|
|
|
gint32 drawable_ID;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
run_mode = param[0].data.d_int32;
|
|
|
|
image_ID = param[1].data.d_image;
|
1997-11-25 06:05:25 +08:00
|
|
|
drawable_ID = param[2].data.d_drawable;
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
|
|
|
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (strcmp (name, "plug_in_mail_image") == 0)
|
|
|
|
{
|
|
|
|
switch (run_mode)
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_get_data ("plug_in_mail_image", &mail_info);
|
|
|
|
if (!save_dialog ())
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_CANCEL;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Make sure all the arguments are there! */
|
1999-03-19 17:12:36 +08:00
|
|
|
if (nparams != 9)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
|
|
|
else
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* this hasnt been tested yet */
|
2000-01-26 01:46:56 +08:00
|
|
|
strncpy (mail_info.filename, param[3].data.d_string, BUFFER_SIZE);
|
|
|
|
strncpy (mail_info.receipt, param[4].data.d_string, BUFFER_SIZE);
|
|
|
|
strncpy (mail_info.receipt, param[5].data.d_string, BUFFER_SIZE);
|
|
|
|
strncpy (mail_info.subject, param[6].data.d_string, BUFFER_SIZE);
|
|
|
|
strncpy (mail_info.comment, param[7].data.d_string, BUFFER_SIZE);
|
1999-03-19 17:12:36 +08:00
|
|
|
mail_info.encapsulation = param[8].data.d_int32;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
break;
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_get_data ("plug_in_mail_image", &mail_info);
|
|
|
|
break;
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
status = save_image (mail_info.filename,
|
|
|
|
image_ID,
|
|
|
|
drawable_ID,
|
|
|
|
run_mode);
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
2000-08-01 08:38:38 +08:00
|
|
|
gimp_set_data ("plug_in_mail_image", &mail_info, sizeof(m_info));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
values[0].data.d_status = status;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpPDBStatusType
|
2003-07-02 20:03:08 +08:00
|
|
|
save_image (const gchar *filename,
|
|
|
|
gint32 image_ID,
|
|
|
|
gint32 drawable_ID,
|
|
|
|
gint32 run_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
gchar *ext;
|
|
|
|
gchar *tmpname;
|
|
|
|
gchar mailcmdline[512];
|
|
|
|
gint pid;
|
2000-11-09 05:58:22 +08:00
|
|
|
gint wpid;
|
2000-01-26 01:46:56 +08:00
|
|
|
gint process_status;
|
|
|
|
FILE *mailpipe;
|
|
|
|
FILE *infile;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (NULL == (ext = find_extension (filename)))
|
2000-08-22 09:26:57 +08:00
|
|
|
return GIMP_PDB_CALLING_ERROR;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* get a temp name with the right extension and save into it. */
|
2000-08-25 23:38:38 +08:00
|
|
|
tmpname = gimp_temp_name (ext + 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* construct the "sendmail user@location" line */
|
2002-05-28 08:59:27 +08:00
|
|
|
strcpy (mailcmdline, SENDMAIL);
|
1997-11-25 06:05:25 +08:00
|
|
|
strcat (mailcmdline, " ");
|
|
|
|
strcat (mailcmdline, mail_info.receipt);
|
|
|
|
|
|
|
|
/* create a pipe to sendmail */
|
1999-05-17 20:27:10 +08:00
|
|
|
#ifndef __EMX__
|
1997-11-25 06:05:25 +08:00
|
|
|
mailpipe = popen (mailcmdline, "w");
|
1999-05-17 20:27:10 +08:00
|
|
|
#else
|
|
|
|
mailpipe = popen (mailcmdline, "wb");
|
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
create_headers (mailpipe);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* This is necessary to make the comments and headers work correctly. Not real sure why */
|
2003-11-06 23:27:05 +08:00
|
|
|
fflush (mailpipe);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-25 23:38:38 +08:00
|
|
|
if (! (gimp_file_save (run_mode,
|
|
|
|
image_ID,
|
|
|
|
drawable_ID,
|
2003-11-06 23:27:05 +08:00
|
|
|
tmpname,
|
2000-08-25 23:38:38 +08:00
|
|
|
tmpname) && valid_file (tmpname)) )
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
unlink (tmpname);
|
1999-10-28 06:16:20 +08:00
|
|
|
g_free (tmpname);
|
2000-08-25 23:38:38 +08:00
|
|
|
return GIMP_PDB_EXECUTION_ERROR;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
if (mail_info.encapsulation == ENCAPSULATION_UUENCODE)
|
|
|
|
{
|
1999-05-17 20:27:10 +08:00
|
|
|
#ifndef __EMX__
|
1997-11-25 06:05:25 +08:00
|
|
|
/* fork off a uuencode process */
|
|
|
|
if ((pid = fork ()) < 0)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("fork() failed: %s", g_strerror (errno));
|
2000-01-26 01:46:56 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
return GIMP_PDB_EXECUTION_ERROR;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else if (pid == 0)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
|
|
|
if (-1 == dup2 (fileno (mailpipe), fileno (stdout)))
|
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("dup2() failed: %s", g_strerror (errno));
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
execlp (UUENCODE, UUENCODE, tmpname, filename, NULL);
|
|
|
|
/* What are we doing here? exec must have failed */
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("exec failed: uuencode: %s", g_strerror (errno));
|
2000-01-26 01:46:56 +08:00
|
|
|
|
|
|
|
/* close the pipe now */
|
|
|
|
pclose (mailpipe);
|
|
|
|
g_free (tmpname);
|
|
|
|
_exit (127);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
1999-05-17 20:27:10 +08:00
|
|
|
#else /* __EMX__ */
|
|
|
|
int tfd;
|
|
|
|
/* save fileno(stdout) */
|
|
|
|
tfd = dup (fileno (stdout));
|
|
|
|
if (dup2 (fileno (mailpipe), fileno (stdout)) == -1)
|
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("dup2() failed: %s", g_strerror (errno));
|
2000-01-26 01:46:56 +08:00
|
|
|
close (tfd);
|
1999-10-28 06:16:20 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
return GIMP_PDB_EXECUTION_ERROR;
|
1999-05-17 20:27:10 +08:00
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
fcntl (tfd, F_SETFD, FD_CLOEXEC);
|
1999-05-17 20:27:10 +08:00
|
|
|
pid = spawnlp (P_NOWAIT, UUENCODE, UUENCODE, tmpname, filename, NULL);
|
|
|
|
/* restore fileno(stdout) */
|
|
|
|
dup2 (tfd, fileno (stdout));
|
2000-01-26 01:46:56 +08:00
|
|
|
close (tfd);
|
1999-05-17 20:27:10 +08:00
|
|
|
if (pid == -1)
|
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("spawn failed: %s", g_strerror (errno));
|
1999-10-28 06:16:20 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
return GIMP_PDB_EXECUTION_ERROR;
|
1999-05-17 20:27:10 +08:00
|
|
|
}
|
|
|
|
#endif
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2000-11-09 05:58:22 +08:00
|
|
|
wpid = waitpid (pid, &process_status, 0);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-11-09 05:58:22 +08:00
|
|
|
if ((wpid < 0)
|
|
|
|
|| !WIFEXITED (process_status)
|
|
|
|
|| (WEXITSTATUS (process_status) != 0))
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message ("mail didnt work or something on file\n'%s'", tmpname);
|
2000-01-26 01:46:56 +08:00
|
|
|
g_free (tmpname);
|
2000-08-22 09:26:57 +08:00
|
|
|
return GIMP_PDB_EXECUTION_ERROR;
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* This must be MIME stuff. Base64 away... */
|
1997-11-25 06:05:25 +08:00
|
|
|
infile = fopen(tmpname,"r");
|
|
|
|
to64(infile,mailpipe);
|
|
|
|
/* close off mime */
|
2000-01-26 01:46:56 +08:00
|
|
|
if( mail_info.encapsulation == ENCAPSULATION_MIME )
|
|
|
|
{
|
|
|
|
fprintf (mailpipe, "\n--GUMP-MIME-boundary--\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* delete the tmpfile that was generated */
|
|
|
|
unlink (tmpname);
|
1999-10-28 06:16:20 +08:00
|
|
|
g_free (tmpname);
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
return GIMP_PDB_SUCCESS;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gint
|
2000-01-07 18:39:33 +08:00
|
|
|
save_dialog (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-09-17 20:01:27 +08:00
|
|
|
GtkWidget *dlg;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkWidget *text_view;
|
|
|
|
GtkTextBuffer *text_buffer;
|
2003-11-06 23:27:05 +08:00
|
|
|
gchar buffer[BUFFER_SIZE];
|
|
|
|
gchar *gump_from;
|
|
|
|
gboolean run;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-02 01:01:18 +08:00
|
|
|
gimp_ui_init ("mail", FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-03-19 17:12:36 +08:00
|
|
|
/* check gimprc for a preffered "From:" address */
|
2003-11-06 23:27:05 +08:00
|
|
|
gump_from = gimp_gimprc_query ("gump-from");
|
1999-03-19 17:12:36 +08:00
|
|
|
|
2000-08-01 08:38:38 +08:00
|
|
|
if (gump_from)
|
|
|
|
{
|
|
|
|
strncpy (mail_info.from, gump_from, BUFFER_SIZE);
|
|
|
|
g_free (gump_from);
|
|
|
|
}
|
2000-01-07 18:39:33 +08:00
|
|
|
|
|
|
|
dlg = gimp_dialog_new (_("Send to Mail"), "mail",
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL, 0,
|
2000-05-23 01:10:28 +08:00
|
|
|
gimp_standard_help_func, "filters/mail.html",
|
2000-01-07 18:39:33 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2000-01-07 18:39:33 +08:00
|
|
|
|
|
|
|
NULL);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* table */
|
1999-11-27 02:03:59 +08:00
|
|
|
table = gtk_table_new (7, 2, FALSE);
|
2000-08-28 08:42:32 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 6);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), table, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
1999-11-27 02:03:59 +08:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* to: dialog */
|
|
|
|
entry = gtk_entry_new ();
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_widget_set_size_request (entry, 200, -1);
|
2000-01-26 01:46:56 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%s", mail_info.receipt);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
2000-04-19 21:24:11 +08:00
|
|
|
_("Recipient:"), 1.0, 0.5,
|
2000-01-31 11:13:02 +08:00
|
|
|
entry, 1, FALSE);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (entry, "changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (mail_entry_callback),
|
|
|
|
&mail_info.receipt);
|
1999-03-19 17:12:36 +08:00
|
|
|
|
1999-11-27 02:03:59 +08:00
|
|
|
/* From entry */
|
1999-03-19 17:12:36 +08:00
|
|
|
entry = gtk_entry_new ();
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_widget_set_size_request (entry, 200, -1);
|
2000-01-26 01:46:56 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%s", mail_info.from);
|
1999-03-19 17:12:36 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
2000-04-19 21:24:11 +08:00
|
|
|
_("Sender:"), 1.0, 0.5,
|
2000-01-31 11:13:02 +08:00
|
|
|
entry, 1, FALSE);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (entry, "changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (mail_entry_callback),
|
|
|
|
&mail_info.from);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Subject entry */
|
|
|
|
entry = gtk_entry_new ();
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_widget_set_size_request (entry, 200, -1);
|
2000-01-26 01:46:56 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%s", mail_info.subject);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
|
2000-01-26 01:46:56 +08:00
|
|
|
_("Subject:"), 1.0, 0.5,
|
2000-01-31 11:13:02 +08:00
|
|
|
entry, 1, FALSE);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (entry, "changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (mail_entry_callback),
|
|
|
|
&mail_info.subject);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-27 02:03:59 +08:00
|
|
|
/* Comment entry */
|
1997-11-25 06:05:25 +08:00
|
|
|
entry = gtk_entry_new ();
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_widget_set_size_request (entry, 200, -1);
|
2000-01-26 01:46:56 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%s", mail_info.comment);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
|
2000-01-26 01:46:56 +08:00
|
|
|
_("Comment:"), 1.0, 0.5,
|
2000-01-31 11:13:02 +08:00
|
|
|
entry, 1, FALSE);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (entry, "changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (mail_entry_callback),
|
|
|
|
&mail_info.comment);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-27 02:03:59 +08:00
|
|
|
/* Filename entry */
|
1997-11-25 06:05:25 +08:00
|
|
|
entry = gtk_entry_new ();
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_widget_set_size_request (entry, 200, -1);
|
2000-01-26 01:46:56 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%s", mail_info.filename);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
|
2000-01-26 01:46:56 +08:00
|
|
|
_("Filename:"), 1.0, 0.5,
|
2000-01-31 11:13:02 +08:00
|
|
|
entry, 1, FALSE);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (entry, "changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (mail_entry_callback),
|
|
|
|
&mail_info.filename);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-29 06:22:56 +08:00
|
|
|
/* comment */
|
2001-09-17 20:01:27 +08:00
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 4);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), scrolled_window,
|
|
|
|
0, 2, 5, 6,
|
|
|
|
GTK_EXPAND | GTK_FILL,
|
|
|
|
GTK_EXPAND | GTK_FILL,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (scrolled_window);
|
|
|
|
|
|
|
|
text_buffer = gtk_text_buffer_new (NULL);
|
|
|
|
|
|
|
|
text_view = gtk_text_view_new_with_buffer (text_buffer);
|
|
|
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
|
|
|
|
gtk_widget_show (text_view);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_object_unref (text_buffer);
|
2001-09-17 20:01:27 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (text_buffer, "changed",
|
2001-09-17 20:01:27 +08:00
|
|
|
G_CALLBACK (mesg_body_callback),
|
|
|
|
NULL);
|
1998-07-29 06:22:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Encapsulation label */
|
1999-05-30 00:35:47 +08:00
|
|
|
label = gtk_label_new (_("Encapsulation:"));
|
2000-01-09 04:00:10 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
2000-01-16 23:38:38 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 6, 7,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1999-11-27 02:03:59 +08:00
|
|
|
gtk_widget_show (label);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
/* Encapsulation radiobuttons */
|
2003-11-15 02:05:39 +08:00
|
|
|
vbox = gimp_int_radio_group_new (FALSE, NULL,
|
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
|
|
|
&mail_info.encapsulation,
|
|
|
|
mail_info.encapsulation,
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-15 02:05:39 +08:00
|
|
|
_("Uuencode"), ENCAPSULATION_UUENCODE, NULL,
|
|
|
|
_("MIME"), ENCAPSULATION_MIME, NULL,
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2003-11-15 02:05:39 +08:00
|
|
|
NULL);
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), vbox, 1, 2, 6, 8,
|
2000-01-16 23:38:38 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_widget_show (vbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gtk_widget_show (dlg);
|
2000-01-16 23:38:38 +08:00
|
|
|
|
2003-11-12 02:11:56 +08:00
|
|
|
run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
gtk_widget_destroy (dlg);
|
|
|
|
|
|
|
|
return run;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static gint
|
2003-07-02 20:03:08 +08:00
|
|
|
valid_file (const gchar *filename)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
int stat_res;
|
|
|
|
struct stat buf;
|
|
|
|
|
|
|
|
stat_res = stat (filename, &buf);
|
|
|
|
|
|
|
|
if ((0 == stat_res) && (buf.st_size > 0))
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
static gchar *
|
2003-07-02 20:03:08 +08:00
|
|
|
find_content_type (const gchar *filename)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-16 23:38:38 +08:00
|
|
|
/* This function returns a MIME Content-type: value based on the
|
|
|
|
filename it is given. */
|
2003-07-02 20:03:08 +08:00
|
|
|
const gchar *type_mappings[20] =
|
2000-01-16 23:38:38 +08:00
|
|
|
{
|
|
|
|
"gif" , "image/gif",
|
|
|
|
"jpg" , "image/jpeg",
|
|
|
|
"jpeg", "image/jpeg",
|
|
|
|
"tif" , "image/tiff",
|
|
|
|
"tiff", "image/tiff",
|
|
|
|
"png" , "image/png",
|
|
|
|
"g3" , "image/g3fax",
|
|
|
|
"ps", "application/postscript",
|
|
|
|
"eps", "application/postscript",
|
|
|
|
NULL, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
gchar *ext;
|
2003-07-02 20:03:08 +08:00
|
|
|
gchar *mimetype = g_new (gchar, 100);
|
2000-01-16 23:38:38 +08:00
|
|
|
gint i=0;
|
|
|
|
|
|
|
|
ext = find_extension (filename);
|
|
|
|
if (!ext)
|
|
|
|
{
|
|
|
|
strcpy (mimetype, "application/octet-stream");
|
|
|
|
return mimetype;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-01-16 23:38:38 +08:00
|
|
|
|
|
|
|
while (type_mappings[i])
|
|
|
|
{
|
|
|
|
if (strcmp (ext+1, type_mappings[i]) == 0)
|
|
|
|
{
|
|
|
|
strcpy (mimetype, type_mappings[i + 1]);
|
|
|
|
return mimetype;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-01-16 23:38:38 +08:00
|
|
|
i += 2;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-01-16 23:38:38 +08:00
|
|
|
strcpy (mimetype, "image/x-");
|
|
|
|
strncat (mimetype, ext + 1, 91);
|
|
|
|
mimetype[99] = '\0';
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
return mimetype;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
static gchar *
|
2003-07-02 20:03:08 +08:00
|
|
|
find_extension (const gchar *filename)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-16 23:38:38 +08:00
|
|
|
gchar *filename_copy;
|
|
|
|
gchar *ext;
|
|
|
|
|
|
|
|
/* this whole routine needs to be redone so it works for xccfgz and gz files*/
|
|
|
|
/* not real sure where to start...... */
|
|
|
|
/* right now saving for .xcfgz works but not .xcf.gz */
|
|
|
|
/* this is all pretty close to straight from gz. It needs to be changed to */
|
|
|
|
/* work better for this plugin */
|
1997-11-25 06:05:25 +08:00
|
|
|
/* ie, FIXME */
|
|
|
|
|
|
|
|
/* we never free this copy - aren't we evil! */
|
|
|
|
filename_copy = malloc (strlen (filename) + 1);
|
|
|
|
strcpy (filename_copy, filename);
|
|
|
|
|
|
|
|
/* find the extension, boy! */
|
|
|
|
ext = strrchr (filename_copy, '.');
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (!ext || ext[1] == 0 || strchr (ext, '/'))
|
|
|
|
{
|
2003-06-13 22:37:00 +08:00
|
|
|
g_message (_("some sort of error with the file extension or lack thereof"));
|
2003-11-06 23:27:05 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (0 != strcmp(ext,".gz"))
|
2003-11-06 23:27:05 +08:00
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
return ext;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* we found somehting, loop back, and look again */
|
|
|
|
*ext = 0;
|
|
|
|
ext = strrchr (filename_copy, '.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ext;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-01-26 01:46:56 +08:00
|
|
|
mail_entry_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
strncpy ((gchar *) data, gtk_entry_get_text (GTK_ENTRY (widget)), BUFFER_SIZE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static void
|
2001-09-17 20:01:27 +08:00
|
|
|
mesg_body_callback (GtkTextBuffer *buffer,
|
|
|
|
gpointer data)
|
1998-07-29 06:22:56 +08:00
|
|
|
{
|
2001-09-26 20:52:12 +08:00
|
|
|
GtkTextIter start_iter;
|
|
|
|
GtkTextIter end_iter;
|
2001-09-17 20:01:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
if (mesg_body)
|
|
|
|
g_free (mesg_body);
|
2001-11-20 22:46:44 +08:00
|
|
|
|
|
|
|
gtk_text_buffer_get_bounds (buffer, &start_iter, &end_iter);
|
2001-09-17 20:01:27 +08:00
|
|
|
mesg_body = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
1998-07-29 06:22:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2000-01-16 23:38:38 +08:00
|
|
|
create_headers (FILE *mailpipe)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* create all the mail header stuff. Feel free to add your own */
|
|
|
|
/* It is advisable to leave the X-Mailer header though, as */
|
|
|
|
/* there is a possibilty of a Gimp mail scanner/reader in the */
|
|
|
|
/* future. It will probabaly need that header. */
|
|
|
|
|
|
|
|
fprintf (mailpipe, "To: %s \n", mail_info.receipt);
|
|
|
|
fprintf (mailpipe, "Subject: %s \n", mail_info.subject);
|
1999-03-19 17:12:36 +08:00
|
|
|
fprintf (mailpipe, "From: %s \n", mail_info.from);
|
|
|
|
fprintf (mailpipe, "X-Mailer: GIMP Useless Mail Program v.85\n");
|
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
if (mail_info.encapsulation == ENCAPSULATION_MIME )
|
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
fprintf (mailpipe, "MIME-Version: 1.0\n");
|
|
|
|
fprintf (mailpipe, "Content-type: multipart/mixed; boundary=GUMP-MIME-boundary\n");
|
2000-01-16 23:38:38 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
fprintf (mailpipe, "\n\n");
|
2000-01-16 23:38:38 +08:00
|
|
|
if (mail_info.encapsulation == ENCAPSULATION_MIME )
|
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
fprintf (mailpipe, "--GUMP-MIME-boundary\n");
|
|
|
|
fprintf (mailpipe, "Content-type: text/plain; charset=US-ASCII\n\n");
|
2000-01-16 23:38:38 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
fprintf (mailpipe, mail_info.comment);
|
|
|
|
fprintf (mailpipe, "\n\n");
|
2001-09-17 20:01:27 +08:00
|
|
|
if (mesg_body)
|
2003-11-06 23:27:05 +08:00
|
|
|
fprintf (mailpipe, mesg_body);
|
1998-07-29 06:22:56 +08:00
|
|
|
fprintf (mailpipe, "\n\n");
|
2000-01-16 23:38:38 +08:00
|
|
|
if (mail_info.encapsulation == ENCAPSULATION_MIME )
|
|
|
|
{
|
2003-07-02 20:03:08 +08:00
|
|
|
gchar *content = find_content_type (mail_info.filename);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
fprintf (mailpipe, "--GUMP-MIME-boundary\n");
|
|
|
|
fprintf (mailpipe, "Content-type: %s\n",content);
|
|
|
|
fprintf (mailpipe, "Content-transfer-encoding: base64\n");
|
2003-07-02 20:03:08 +08:00
|
|
|
fprintf (mailpipe, "Content-disposition: attachment; filename=\"%s\"\n",
|
|
|
|
mail_info.filename);
|
1997-11-25 06:05:25 +08:00
|
|
|
fprintf (mailpipe, "Content-description: %s\n\n",mail_info.filename);
|
2003-07-02 20:03:08 +08:00
|
|
|
|
|
|
|
g_free (content);
|
2000-01-16 23:38:38 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following code taken from codes.c in the mpack-1.5 distribution
|
2003-11-06 23:27:05 +08:00
|
|
|
* by Carnegie Mellon University.
|
|
|
|
*
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
|
|
|
* (C) Copyright 1993,1994 by Carnegie Mellon University
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
|
|
|
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
|
|
|
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
|
|
|
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
Permission to use, copy, modify, and distribute this material
|
|
|
|
for any purpose and without fee is hereby granted, provided
|
|
|
|
that the above copyright notice and this permission notice
|
|
|
|
appear in all copies, and that the name of Bellcore not be
|
|
|
|
used in advertising or publicity pertaining to this
|
|
|
|
material without the specific, prior written permission
|
|
|
|
of an authorized representative of Bellcore. BELLCORE
|
|
|
|
MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
|
|
|
|
OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
|
1997-11-25 06:05:25 +08:00
|
|
|
WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. */
|
|
|
|
|
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
static gchar basis_64[] =
|
|
|
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
static gint
|
|
|
|
to64 (FILE *infile,
|
2003-11-06 23:27:05 +08:00
|
|
|
FILE *outfile)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
gint c1, c2, c3, ct = 0, written = 0;
|
2000-01-16 23:38:38 +08:00
|
|
|
|
|
|
|
while ((c1 = getc (infile)) != EOF)
|
|
|
|
{
|
|
|
|
c2 = getc (infile);
|
|
|
|
if (c2 == EOF)
|
|
|
|
{
|
|
|
|
output64chunk (c1, 0, 0, 2, outfile);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
c3 = getc (infile);
|
|
|
|
if (c3 == EOF)
|
|
|
|
{
|
|
|
|
output64chunk (c1, c2, 0, 1, outfile);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
output64chunk (c1, c2, c3, 0, outfile);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
2000-01-16 23:38:38 +08:00
|
|
|
ct += 4;
|
|
|
|
if (ct > 71)
|
|
|
|
{
|
|
|
|
putc ('\n', outfile);
|
|
|
|
written += 73;
|
|
|
|
ct = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
2000-01-16 23:38:38 +08:00
|
|
|
if (ct)
|
|
|
|
{
|
|
|
|
putc ('\n', outfile);
|
|
|
|
ct++;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-01-16 23:38:38 +08:00
|
|
|
|
|
|
|
return written + ct;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-01-16 23:38:38 +08:00
|
|
|
output64chunk (gint c1,
|
|
|
|
gint c2,
|
|
|
|
gint c3,
|
|
|
|
gint pads,
|
|
|
|
FILE *outfile)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-16 23:38:38 +08:00
|
|
|
putc (basis_64[c1>>2], outfile);
|
|
|
|
putc (basis_64[((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)], outfile);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-01-16 23:38:38 +08:00
|
|
|
if (pads == 2)
|
|
|
|
{
|
|
|
|
putc ('=', outfile);
|
|
|
|
putc ('=', outfile);
|
|
|
|
}
|
|
|
|
else if (pads)
|
|
|
|
{
|
|
|
|
putc (basis_64[((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)], outfile);
|
|
|
|
putc ('=', outfile);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
putc (basis_64[((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)], outfile);
|
|
|
|
putc (basis_64[c3 & 0x3F], outfile);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|