/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail team
*
* 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
#ifdef HAVE_NETWORKMANAGER_SUPPORT
#include <NetworkManager.h>
#endif
+#ifdef HAVE_VALGRIND
+#include <valgrind.h>
+#endif
#include "claws.h"
#include "main.h"
#include "nntp-thread.h"
#endif
#include "stock_pixmap.h"
-#ifdef HAVE_VALGRIND
-#include "valgrind.h"
-#endif
#ifdef USE_GNUTLS
# include "ssl.h"
#endif
static gboolean went_offline_nm;
#endif
+#if !defined(NM_CHECK_VERSION)
+#define NM_CHECK_VERSION(x,y,z) 0
+#endif
+
#ifdef HAVE_DBUS_GLIB
static DBusGProxy *awn_proxy = NULL;
#endif
static gint lock_socket_remove (void);
static void lock_socket_input_cb (gpointer data,
gint source,
- GdkInputCondition condition);
+ GIOCondition condition);
static void open_compose_new (const gchar *address,
GPtrArray *attach_files);
gtk_widget_show(hack);
}
- xdisplay = gdk_display_get_default();
+ xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
sn_display = sn_display_new(xdisplay,
sn_error_trap_push,
sn_error_trap_pop);
(*sc_ice_installed_handler) (connection);
}
static gboolean sc_process_ice_messages (GIOChannel *source,
- GIOCondition condition,
- gpointer data)
+ GIOCondition condition,
+ gpointer data)
{
IceConn connection = (IceConn) data;
IceProcessMessagesStatus status;
"/org/freedesktop/NetworkManager",
"org.freedesktop.NetworkManager");
if (nm_proxy) {
+#if NM_CHECK_VERSION(0,8,992)
+ dbus_g_proxy_add_signal(nm_proxy, "StateChanged", G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(nm_proxy, "StateChanged",
+ G_CALLBACK(networkmanager_state_change_cb),
+ NULL,NULL);
+#else
dbus_g_proxy_add_signal(nm_proxy, "StateChange", G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(nm_proxy, "StateChange",
G_CALLBACK(networkmanager_state_change_cb),
NULL,NULL);
+#endif
}
#endif
install_dbus_status_handler();
/* register the callback of unix domain socket input */
lock_socket_tag = claws_input_add(lock_socket,
- GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI,
lock_socket_input_cb,
mainwin, TRUE);
num_plugins++;
}
main_window_cursor_normal(mainwin);
+ main_window_popup(mainwin);
alertpanel_warning(ngettext(
"The following plugin failed to load. "
"Check the Plugins configuration "
claws_done();
}
+#define G_STRING_APPEND_ENCODED_URI(gstring,source) \
+ { \
+ gchar tmpbuf[BUFFSIZE]; \
+ encode_uri(tmpbuf, BUFFSIZE, (source)); \
+ g_string_append((gstring), tmpbuf); \
+ }
+
+#define G_PRINT_EXIT(msg) \
+ { \
+ g_print(msg); \
+ exit(1); \
+ }
+
+static GString * parse_cmd_compose_from_file(const gchar *fn)
+{
+ GString *headers = g_string_new(NULL);
+ GString *body = g_string_new(NULL);
+ gchar *to = NULL;
+ gchar *h;
+ gchar *v;
+ gchar fb[BUFFSIZE];
+ FILE *fp;
+ gboolean isstdin;
+
+ if (fn == NULL || *fn == '\0')
+ G_PRINT_EXIT(_("Missing filename\n"));
+ isstdin = (*fn == '-' && *(fn + 1) == '\0');
+ if (isstdin)
+ fp = stdin;
+ else {
+ fp = g_fopen(fn, "r");
+ if (!fp)
+ G_PRINT_EXIT(_("Cannot open filename for reading\n"));
+ }
+
+ while (fgets(fb, sizeof(fb), fp)) {
+ gchar *tmp;
+ strretchomp(fb);
+ if (*fb == '\0')
+ break;
+ h = fb;
+ while (*h && *h != ':') { ++h; } /* search colon */
+ if (*h == '\0')
+ G_PRINT_EXIT(_("Malformed header\n"));
+ v = h + 1;
+ while (*v && *v == ' ') { ++v; } /* trim value start */
+ *h = '\0';
+ tmp = g_ascii_strdown(fb, -1); /* get header name */
+ if (!strcmp(tmp, "to")) {
+ if (to != NULL)
+ G_PRINT_EXIT(_("Duplicated 'To:' header\n"));
+ to = g_strdup(v);
+ } else {
+ g_string_append_c(headers, '&');
+ g_string_append(headers, tmp);
+ g_string_append_c(headers, '=');
+#if GLIB_CHECK_VERSION(2,16,0)
+ g_string_append_uri_escaped(headers, v, NULL, TRUE);
+#else
+ G_STRING_APPEND_ENCODED_URI(headers, v);
+#endif
+ }
+ g_free(tmp);
+ }
+ if (to == NULL)
+ G_PRINT_EXIT(_("Missing required 'To:' header\n"));
+ g_string_append(body, to);
+ g_free(to);
+ g_string_append(body, "?body=");
+ while (fgets(fb, sizeof(fb), fp)) {
+#if GLIB_CHECK_VERSION(2,16,0)
+ g_string_append_uri_escaped(body, fb, NULL, TRUE);
+#else
+ G_STRING_APPEND_ENCODED_URI(body, fb);
+#endif
+ }
+ if (!isstdin)
+ fclose(fp);
+ /* append the remaining headers */
+ g_string_append(body, headers->str);
+ g_string_free(headers, TRUE);
+
+ return body;
+}
+
+#undef G_STRING_APPEND_ENCODED_URI
+#undef G_PRINT_EXIT
+
static void parse_cmd_opt(int argc, char *argv[])
{
gint i;
cmd.receive_all = TRUE;
} else if (!strncmp(argv[i], "--receive", 9)) {
cmd.receive = TRUE;
+ } else if (!strncmp(argv[i], "--compose-from-file", 19)) {
+ const gchar *p = (i+1 < argc)?argv[i+1]:NULL;
+
+ GString *mailto = parse_cmd_compose_from_file(p);
+ cmd.compose = TRUE;
+ cmd.compose_mailto = mailto->str;
+ i++;
} else if (!strncmp(argv[i], "--compose", 9)) {
const gchar *p = (i+1 < argc)?argv[i+1]:NULL;
g_print(_("Usage: %s [OPTION]...\n"), base);
g_print("%s\n", _(" --compose [address] open composition window"));
+ g_print("%s\n", _(" --compose-from-file file\n"
+ " open composition window with data from given file;\n"
+ " use - as file name for reading from standard input;\n"
+ " content format: headers first (To: required) until an\n"
+ " empty line, then mail body until end of file."));
g_print("%s\n", _(" --subscribe [uri] subscribe to the given URI if possible"));
g_print("%s\n", _(" --attach file1 [file2]...\n"
" open composition window with specified files\n"
static void lock_socket_input_cb(gpointer data,
gint source,
- GdkInputCondition condition)
+ GIOCondition condition)
{
MainWindow *mainwin = (MainWindow *)data;
gint sock;
g_propagate_error(error, tmp_error);
return TRUE;
}
-
- return (state == NM_STATE_CONNECTED || state == NM_STATE_UNKNOWN);
+#if NM_CHECK_VERSION(0,8,992)
+ return (state == NM_STATE_CONNECTED_LOCAL ||
+ state == NM_STATE_CONNECTED_SITE ||
+ state == NM_STATE_CONNECTED_GLOBAL ||
+ state == NM_STATE_UNKNOWN);
+#else
+ return (state == NM_STATE_CONNECTED ||
+ state == NM_STATE_UNKNOWN);
+#endif
}
#endif