-2001-11-18 [hoa] 0.6.4claws21
+2001-11-04 [hoa] 0.6.4claws22
+
+ * src/grouplistdialog.c
+ change the names of the nodes in the tree
+
+ * src/compose.c
+ enhanced mailto syntax as described in
+ http://developer.netscape.com/viewsource/husted_mailto/mailto.html
+ (thanks to Jonathan Ware <jonathan_ware@gmx.co.uk>)
+
+ * src/utils.c
+ encode and decode URI (useful when opening URL into
+ netscape).
+
+2001-11-03 [hoa] 0.6.4claws21
* src/grouplistdialog.c
a new newsgroups list selection dialog box
with a CTree instead of a CList
-2001-11-18 [hoa] 0.6.4claws20
+2001-11-03 [hoa] 0.6.4claws20
* src/folderview.c
enable property and scoring options when right
MICRO_VERSION=4
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=claws21
+EXTRA_VERSION=claws22
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
dnl
return compose_generic_new(account, NULL, item);
}
+static void set_compose_entries(Compose * compose, const gchar * mailto)
+{
+ gchar * subject = NULL;
+ gchar * to = NULL;
+ gchar * cc = NULL;
+ gchar * bcc = NULL;
+ gchar * body = NULL;
+ gchar * p;
+ gchar * tmp_mailto;
+ gchar * cur;
+
+ Xstrdup_a(tmp_mailto, mailto, return);
+
+ cur = tmp_mailto;
+
+ p = strchr(cur, '?');
+ if (p != NULL) {
+ * p = 0;
+ cur = p + 1;
+ }
+ to = tmp_mailto;
+
+ while (p) {
+ char *field, *value;
+
+ field = cur;
+
+ p = strchr(cur, '=');
+ if (p == NULL)
+ break;
+ * p = 0;
+ cur = p + 1;
+
+ value = cur;
+
+ p = strchr(cur, '&');
+ if (p != NULL) {
+ * p = 0;
+ cur = p + 1;
+ }
+
+ if (value) {
+ if (g_strcasecmp(field, "subject")==0) {
+ Xstrdup_a(subject, value, );
+ if (subject != NULL)
+ decode_uri(subject, value);
+ }
+ else if (g_strcasecmp(field, "cc")==0)
+ cc = value;
+ else if (g_strcasecmp(field, "bcc")==0)
+ bcc = value;
+ else if (g_strcasecmp(field, "body")==0) {
+ Xstrdup_a(body, value, );
+ if (body != NULL)
+ decode_uri(body, value);
+ }
+ }
+ }
+
+ if (to) {
+ compose_entry_append(compose, to, COMPOSE_TO);
+ /*
+ gtk_widget_grab_focus(compose->text);
+ */
+ }
+
+ if (subject)
+ gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), subject);
+ if (cc)
+ compose_entry_append(compose, cc, COMPOSE_CC);
+ if (bcc)
+ compose_entry_append(compose, bcc, COMPOSE_BCC);
+ if (body) {
+ gtk_text_insert(GTK_TEXT(compose->text),
+ NULL, NULL, NULL, body, -1);
+ gtk_text_insert(GTK_TEXT(compose->text),
+ NULL, NULL, NULL, "\n", 1);
+ }
+}
+
Compose * compose_generic_new(PrefsAccount *account, const gchar *to, FolderItem *item)
{
Compose *compose;
if (item && item->prefs && item->prefs->enable_default_account)
account = account_find_from_id(item->prefs->default_account);
- if (!account) account = cur_account;
+ if (!account) account = cur_account;
g_return_val_if_fail(account != NULL, NULL);
compose = compose_create(account, COMPOSE_NEW);
if (account->protocol != A_NNTP) {
if (to) {
- compose_entry_append(compose, to, COMPOSE_TO);
+ set_compose_entries(compose, to);
+
} else if(item && item->prefs->enable_default_to) {
compose_entry_append(compose, item->prefs->default_to, COMPOSE_TO);
}
: msginfo->from ? msginfo->from : ""),
COMPOSE_TO);
if (compose->account->protocol == A_NNTP)
+ if (ignore_replyto)
+ compose_entry_append(compose,
+ msginfo->from ? msginfo->from : "",
+ COMPOSE_TO);
+ else
+ compose_entry_append(compose,
+ compose->followup_to ? compose->followup_to
+ : compose->newsgroups ? compose->newsgroups
+ : "",
+ COMPOSE_NEWSGROUPS);
+ /*
compose_entry_append(compose,
compose->followup_to ? compose->followup_to
: compose->newsgroups ? compose->newsgroups
: "",
COMPOSE_NEWSGROUPS);
+ */
if (msginfo->subject && *msginfo->subject) {
gchar *buf, *buf2, *p;
return g_strndup(name, p - name);
}
+static gchar * get_node_name(gchar * name)
+{
+ gchar * p;
+
+ p = (gchar *) strrchr(name, '.');
+ if (p == NULL)
+ return name;
+
+ return p + 1;
+}
+
static GtkCTreeNode * create_parent(GtkCTree * groups_tree, gchar * name)
{
gchar * cols[3];
if (hash_news_get_branch_node(name) != NULL)
return;
- cols[0] = name;
+ cols[0] = get_node_name(name);
cols[1] = "";
cols[2] = "";
count = 0;
snprintf(count_str, 10, "%i", count);
- cols[0] = info->name;
+ cols[0] = get_node_name(info->name);
cols[1] = count_str;
if (info->type == 'y')
cols[2] = "";
return ret;
}
+static gint is_unchanged_uri_char(char c)
+{
+ switch (c) {
+ case '(':
+ case ')':
+ case ',':
+ return 0;
+ default:
+ return 1;
+ }
+}
+
+void encode_uri(gchar * encoded_uri, gint bufsize, const gchar * uri)
+{
+ int i;
+ int k;
+
+ k = 0;
+ for(i = 0; i < strlen(uri) ; i++) {
+ if (is_unchanged_uri_char(uri[i])) {
+ if (k + 2 >= bufsize)
+ break;
+ encoded_uri[k++] = uri[i];
+ }
+ else {
+ char * hexa = "0123456789ABCDEF";
+
+ if (k + 4 >= bufsize)
+ break;
+ encoded_uri[k++] = '%';
+ encoded_uri[k++] = hexa[uri[i] / 16];
+ encoded_uri[k++] = hexa[uri[i] % 16];
+ }
+ }
+ encoded_uri[k] = 0;
+}
+
+/* Converts two-digit hexadecimal to decimal. Used for unescaping escaped
+ * characters
+ */
+static gint axtoi(const gchar *hexstr)
+{
+ gint Hi, Lo, Result;
+
+ Hi = hexstr[0];
+ if ('0' <= Hi && Hi <= '9') {
+ Hi -= '0';
+ } else
+ if ('a' <= Hi && Hi <= 'f') {
+ Hi -=('a'-10);
+ } else
+ if ('A' <= Hi && Hi <= 'F') {
+ Hi -= ('A'-10);
+ }
+
+ Lo = hexstr[1];
+ if ('0' <= Lo && Lo <='9') {
+ Lo -= '0';
+ } else
+ if ('a' <= Lo && Lo <= 'f') {
+ Lo -= ('a'-10);
+ } else
+ if ('A' <= Lo && Lo <= 'F') {
+ Lo -= ('A'-10);
+ }
+ Result = Lo + (16 * Hi);
+ return (Result);
+}
+
+
+/* Decodes URL-Encoded strings (i.e. strings in which spaces are replaced by
+ * plusses, and escape characters are used)
+ */
+
+void decode_uri(gchar * decoded_uri, const gchar * encoded_uri)
+{
+ const gchar * encoded;
+ gchar * decoded;
+
+ // strcpy(decoded_uri, encoded_uri);
+ // subst_char(decoded_uri, '+', ' ');
+
+ encoded = encoded_uri;
+ decoded = decoded_uri;
+
+ while (* encoded) {
+ if (* encoded == '%') {
+ encoded ++;
+ if (isxdigit(encoded[0])
+ && isxdigit(encoded[1])) {
+ * decoded = (gchar) axtoi(encoded);
+ decoded ++;
+ encoded += 2;
+ }
+ }
+ else if (* encoded == '+') {
+ * decoded = ' ';
+ decoded ++;
+ encoded ++;
+ }
+ else {
+ * decoded = * encoded;
+ decoded ++;
+ encoded ++;
+ }
+ }
+
+ * decoded = '\0';
+}
+
+
gint open_uri(const gchar *uri, const gchar *cmdline)
{
static gchar *default_cmdline = "netscape -remote openURL(%s,raise)";
gchar buf[BUFFSIZE];
gchar *p;
-
+ gchar encoded_uri[BUFFSIZE];
+
g_return_val_if_fail(uri != NULL, -1);
+ /* an option to choose whether to use encode_uri or not ? */
+ encode_uri(encoded_uri, BUFFSIZE, uri);
+
if (cmdline &&
(p = strchr(cmdline, '%')) && *(p + 1) == 's' &&
!strchr(p + 2, '%'))
- g_snprintf(buf, sizeof(buf), cmdline, uri);
+ g_snprintf(buf, sizeof(buf), cmdline, encoded_uri);
else {
if (cmdline)
g_warning(_("Open URI command line is invalid: `%s'"),
cmdline);
- g_snprintf(buf, sizeof(buf), default_cmdline, uri);
+ g_snprintf(buf, sizeof(buf), default_cmdline, encoded_uri);
}
-
+
execute_command_line(buf, TRUE);
return 0;