*
* 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
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
%{
static MsgInfo *msginfo = NULL;
static PrefsAccount *account = NULL;
+#ifdef USE_ENCHANT
static gchar default_dictionary[BUFFSIZE];
+#endif
static gboolean *visible = NULL;
static gboolean dry_run = FALSE;
static gint maxsize = 0;
static gint stacksize = 0;
static GHashTable *var_table = NULL;
+static GList *attachments = NULL;
typedef struct st_buffer
{
extern int quote_fmt_firsttime;
extern int line;
+extern int escaped_string;
static void add_visibility(gboolean val)
{
return current->buffer;
}
+GList *quote_fmt_get_attachments_list(void)
+{
+ return attachments;
+}
+
+gint quote_fmt_get_line(void)
+{
+ return line;
+}
+
gint quote_fmt_get_cursor_pos(void)
{
return cursor_pos;
g_hash_table_destroy(var_table);
var_table = NULL;
}
+ if (attachments) {
+ GList *cur = attachments;
+ while (cur) {
+ g_free(cur->data);
+ cur = g_list_next(cur);
+ }
+ g_list_free(attachments);
+ attachments = NULL;
+ }
}
+#ifdef USE_ENCHANT
void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str,
const gchar *my_body, gboolean my_dry_run,
PrefsAccount *compose_account,
+ gboolean string_is_escaped,
GtkAspell *compose_gtkaspell)
+#else
+void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str,
+ const gchar *my_body, gboolean my_dry_run,
+ PrefsAccount *compose_account,
+ gboolean string_is_escaped)
+#endif
{
- gchar *dict = gtkaspell_get_default_dictionary(compose_gtkaspell);
quote_str = my_quote_str;
body = my_body;
msginfo = info;
account = compose_account;
+#ifdef USE_ENCHANT
+ gchar *dict = gtkaspell_get_default_dictionary(compose_gtkaspell);
if (dict)
strncpy2(default_dictionary, dict, sizeof(default_dictionary));
else
*default_dictionary = '\0';
+#endif
dry_run = my_dry_run;
stacksize = 0;
add_visibility(TRUE);
clear_buffer();
error = 0;
line = 1;
+ escaped_string = string_is_escaped;
if (!var_table)
var_table = g_hash_table_new_full(g_str_hash, g_str_equal,
if (body)
fp = str_open_as_stream(body);
else {
- if (procmime_msginfo_is_encrypted(msginfo))
+ if (MSG_IS_ENCRYPTED(msginfo->flags))
fp = procmime_get_first_encrypted_text_content(msginfo);
else
fp = procmime_get_first_text_content(msginfo);
g_free(text);
}
+static void quote_fmt_attach_file(const gchar *filename)
+{
+ attachments = g_list_append(attachments, g_strdup(filename));
+}
+
static gchar *quote_fmt_complete_address(const gchar *addr)
{
gint count;
%token SHOW_EOL SHOW_QUESTION_MARK SHOW_EXCLAMATION_MARK SHOW_PIPE SHOW_OPARENT SHOW_CPARENT
%token SHOW_ACCOUNT_FULL_NAME SHOW_ACCOUNT_MAIL_ADDRESS SHOW_ACCOUNT_NAME SHOW_ACCOUNT_ORGANIZATION
%token SHOW_ACCOUNT_DICT
-%token SHOW_DICT
+%token SHOW_DICT SHOW_TAGS
%token SHOW_ADDRESSBOOK_COMPLETION_FOR_CC
%token SHOW_ADDRESSBOOK_COMPLETION_FOR_FROM
%token SHOW_ADDRESSBOOK_COMPLETION_FOR_TO
%token QUERY_NOT_TO_FOUND_IN_ADDRESSBOOK
/* other tokens */
%token INSERT_FILE INSERT_PROGRAMOUTPUT INSERT_USERINPUT
+%token ATTACH_FILE
%token OPARENT CPARENT
%token CHARACTER
%token SHOW_DATE_EXPR
character_or_special
| query
| query_not
- | insert ;
+ | insert
+ | attach ;
character_or_special:
special
}
| string CHARACTER
{
- int len;
+ size_t len;
strncpy($$, $1, sizeof($$));
$$[sizeof($$) - 1] = '\0';
}
| SHOW_ACCOUNT_DICT
{
+#ifdef USE_ENCHANT
if (account && account->enable_default_dictionary) {
gchar *dictname = g_path_get_basename(account->default_dictionary);
INSERT(dictname);
g_free(dictname);
}
+#endif
}
| SHOW_DICT
{
+#ifdef USE_ENCHANT
INSERT(default_dictionary);
+#endif
+ }
+ | SHOW_TAGS
+ {
+ gchar *tags = procmsg_msginfo_get_tags_str(msginfo);
+ if (tags) {
+ INSERT(tags);
+ }
+ g_free(tags);
}
| SHOW_BACKSLASH
{
}
| SET_CURSOR_POS
{
- cursor_pos = current->bufsize;
+ if (current->buffer)
+ cursor_pos = g_utf8_strlen(current->buffer, -1);
+ else
+ cursor_pos = 0;
}
| SHOW_ADDRESSBOOK_COMPLETION_FOR_CC
{
}
| QUERY_ACCOUNT_DICT
{
+#ifdef USE_ENCHANT
add_visibility(account != NULL && account->enable_default_dictionary == TRUE &&
account->default_dictionary != NULL && *account->default_dictionary != '\0');
+#else
+ add_visibility(FALSE);
+#endif
}
OPARENT quote_fmt CPARENT
{
}
| QUERY_DICT
{
+#ifdef USE_ENCHANT
add_visibility(*default_dictionary != '\0');
+#else
+ add_visibility(FALSE);
+#endif
}
OPARENT quote_fmt CPARENT
{
}
| QUERY_NOT_ACCOUNT_DICT
{
+#ifdef USE_ENCHANT
add_visibility(account == NULL || account->enable_default_dictionary == FALSE
|| *account->default_dictionary == '\0');
+#else
+ add_visibility(FALSE);
+#endif
}
OPARENT quote_fmt CPARENT
{
}
| QUERY_NOT_DICT
{
+#ifdef USE_ENCHANT
add_visibility(*default_dictionary == '\0');
+#else
+ add_visibility(FALSE);
+#endif
}
OPARENT quote_fmt CPARENT
{
quote_fmt_insert_user_input(sub_expr.buffer);
}
};
+
+attach:
+ ATTACH_FILE
+ {
+ current = &sub_expr;
+ clear_buffer();
+ }
+ OPARENT sub_expr CPARENT
+ {
+ current = &main_expr;
+ if (!dry_run) {
+ quote_fmt_attach_file(sub_expr.buffer);
+ }
+ };