Commit d81b38c7 authored by Lucian Langa's avatar Lucian Langa
Browse files

make browsers use evolution proxy

parent 5606c9ce
2009-05-06 Lucian Langa <lucilanga@gnome.org>
* src/gecko-utils.cpp:
* src/gecko-utils.h:
* src/misc.c (print_hash), (free_hash), (sanitize_folder),
(gen_crc), (gen_md5), (extract_main_folder):
* src/network-soup.c:
* src/parser.c (parse_href), (update_channel):
* src/rss-config-factory.c (create_dialog_add),
(remove_feed_dialog), (iterate_import_file), (import_opml),
(create_import_dialog), (create_export_dialog),
(e_plugin_lib_get_configure_widget), (folder_factory),
(rss_config_control_new):
* src/rss.c (taskbar_op_new), (browser_write),
(create_user_pass_dialog), (proxy_auth_dialog),
(feed_new_from_xml), (mycall), (webkit_set_preferences),
(gecko_set_preferences), (gecko_click), (org_gnome_rss_browser),
(org_gnome_cooly_format_rss), (setup_feed),
(org_gnome_cooly_rss_startup), (org_gnome_cooly_rss),
(rss_finalize), (create_mail): cleanups part 4;
make browser use evolution proxy.
2009-05-06 Lucian Langa <lucilanga@gnome.org>
* src/parser.c (html_set_base), (parse_html),
......
......@@ -69,7 +69,7 @@ gecko_prefs_set_string (const gchar *key, const gchar *value)
return NS_SUCCEEDED(gPrefBranch->SetCharPref (key, value));
}
static gboolean
extern "C" gboolean
gecko_prefs_set_int (const gchar *key, gint value)
{
NS_ENSURE_TRUE (gPrefBranch, FALSE);
......
......@@ -27,6 +27,7 @@ G_BEGIN_DECLS
gboolean gecko_prefs_set_bool (const gchar *key, gboolean value);
gboolean gecko_prefs_set_string (const gchar *key, const gchar *value);
gboolean gecko_prefs_set_int (const gchar *key, const gint value);
gboolean gecko_init (void);
void gecko_shutdown (void);
void gecko_set_zoom (GtkWidget *moz, gfloat zoom);
......
......@@ -21,12 +21,14 @@
#define d(x)
#define _GNU_SOURCE
#include <stdint.h>
#include <string.h>
#include <glib.h>
#include <libedataserver/md5-utils.h>
#include <camel/camel-mime-utils.h>
#include "rss.h"
#include "misc.h"
int
......@@ -44,13 +46,13 @@ on_next_unread_item_activate(gpointer a)
static void
print_hash(gpointer key, gpointer value, gpointer user_data)
{
g_print("key:%s, value:%s\n", key, value);
g_print("key:%s, value:%s\n", (gchar *)key, (gchar *)value);
}
static void
free_hash(gpointer key, gpointer value, gpointer user_data)
{
g_print("FREE - key:%p, value:%p\n", key, value);
g_print("FREE - key:%p, value:%p\n", (gchar *)key, (gchar *)value);
// xmlFreeDoc(key);
}
......@@ -138,7 +140,7 @@ sanitize_folder(gchar *text)
while (*s == '.' && len)
{
str = g_string_erase (str, 0, 1);
s = str->str;
s = (unsigned char *)(str->str);
len--;
}
g_string_append_c(str, 0);
......@@ -294,7 +296,7 @@ gen_crc(const char *msg)
crc = 0xFFFFFFFF;
for (i = 0; i < strlen(msg); i++)
crc = ((crc >> 8) & 0x00FFFFFF) ^ crc_tab[(crc ^ *msg++) & 0xFF];
return g_strdup_printf("%x", (crc ^ 0xFFFFFFFF));
return g_strdup_printf("%x", (unsigned int)(crc ^ 0xFFFFFFFF));
}
gchar *
......@@ -311,7 +313,7 @@ gen_md5(gchar *buffer)
*f++ = tohex[c & 0xf];
}
*f++ = 0;
return g_strdup(res);
return g_strdup((gchar *)res);
}
static void
......@@ -369,8 +371,7 @@ gchar *extract_main_folder(gchar *folder)
gchar *base = g_strdup_printf("%s/", main_folder);
gchar **nnew;
gchar *tmp;
if (nnew = g_strsplit(folder, base, 0))
{
if ((nnew = g_strsplit(folder, base, 0))) {
g_free(base);
tmp = g_strdup(nnew[1]);
g_strfreev(nnew);
......
......@@ -34,6 +34,7 @@ gint proxy_type = 0;
extern rssfeed *rf;
extern GConfClient *rss_gconf;
EProxy *proxy;
SoupSession *webkit_session = NULL;
typedef struct {
NetStatusCallback user_cb;
......@@ -186,6 +187,19 @@ proxy_init(void)
return proxy;
}
void
proxify_webkit_session(EProxy *proxy, gchar *uri)
{
SoupURI *proxy_uri = NULL;
if (e_proxy_require_proxy_for_uri (proxy, uri)) {
proxy_uri = e_proxy_peek_uri_for (proxy, uri);
g_print("webkit proxified %s with %s:%d\n", uri, proxy_uri->host, proxy_uri->port);
} else
g_print("webkit no PROXY-%s\n", uri);
g_object_set (G_OBJECT (webkit_session), SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
}
//this will insert proxy in the session
void
......@@ -200,7 +214,6 @@ proxify_session(EProxy *proxy, SoupSession *session, gchar *uri)
g_print("no PROXY-%s\n", uri);
g_object_set (G_OBJECT (session), SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
}
guint
......
......@@ -248,8 +248,6 @@ parse_html(char *url, const char *html, int len)
static gchar *
parse_href (const gchar *s, const gchar *base)
{
gchar *retval;
gchar *tmp;
gchar *tmpurl;
if(s == NULL || *s == 0)
......@@ -1037,7 +1035,6 @@ update_channel(RDF *r)
xmlNodePtr el;
char *q = NULL;
char *b = NULL;
gchar *encl;
gchar *subj;
create_feed *CF;
CamelFolder *mail_folder;
......
......@@ -35,6 +35,7 @@
#include <mail/em-config.h>
#include <shell/evolution-config-control.h>
#include <e-util/e-error.h>
#include <bonobo/bonobo-shlib-factory.h>
#include "rss.h"
......@@ -462,7 +463,7 @@ create_dialog_add(gchar *text, gchar *feed_text)
case 3:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton6), 1);
break;
defaut:
default:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton4), 1);
break;
}
......@@ -825,6 +826,7 @@ delete_response(GtkWidget *selector, guint response, gpointer user_data)
rf->import = 0;
}
void
feeds_dialog_disable(GtkDialog *d, gpointer data)
{
GtkTreeSelection *selection;
......@@ -855,11 +857,8 @@ remove_feed_dialog(gchar *msg)
GtkWidget *dialog1;
GtkWidget *dialog_vbox1;
GtkWidget *vbox1;
GtkWidget *label1;
GtkWidget *checkbutton1;
GtkWidget *dialog_action_area1;
GtkWidget *cancelbutton1;
GtkWidget *okbutton1;
dialog1 = e_error_new(NULL, "org-gnome-evolution-rss:ask-delete-feed", msg, NULL);
gtk_window_set_keep_above(GTK_WINDOW(dialog1), TRUE);
......@@ -889,6 +888,7 @@ remove_feed_dialog(gchar *msg)
return dialog1;
}
void
feeds_dialog_delete(GtkDialog *d, gpointer data)
{
GtkTreeSelection *selection;
......@@ -1081,15 +1081,15 @@ iterate_import_file(xmlNode *src, gchar **url, xmlChar **title, guint type)
if (type == 0) {
src = html_find(src, "outline");
*url = xmlGetProp(src, "xmlUrl");
*title = xmlGetProp(src, "title");
*url = (gchar *)xmlGetProp(src, (xmlChar *)"xmlUrl");
*title = xmlGetProp(src, (xmlChar *)"title");
} else if (type == 1) {
xmlNode *my;
src = html_find(src, "member");
my = layer_find_pos(src, "member", "Agent");
*title = xmlCharStrdup(layer_find(my, "name", NULL));
my = html_find(my, "channel");
*url = xmlGetProp(my, "about");
*url = (gchar *)xmlGetProp(my, (xmlChar *)"about");
}
return src;
......@@ -1100,7 +1100,6 @@ import_opml(gchar *file)
{
gchar *url = NULL;
xmlChar *name = NULL;
xmlChar *buff = NULL;
guint total = 0;
guint current = 0;
guint type = 0; //file type
......@@ -1111,7 +1110,6 @@ import_opml(gchar *file)
xmlNode *src = (xmlNode *)xmlParseFile (file);
xmlNode *doc = src;
xmlNode *my = src;
gchar *msg = g_strdup(_("Importing feeds..."));
import_dialog = e_error_new((GtkWindow *)rf->preferences, "shell:importing", msg, NULL);
gtk_window_set_keep_above(GTK_WINDOW(import_dialog), TRUE);
......@@ -1130,10 +1128,9 @@ import_opml(gchar *file)
0);
gtk_widget_show_all(import_dialog);
g_free(msg);
if (src=src->children)
{
if ((src=src->children)) {
d(g_print("found %s\n", src->name));
if (!g_ascii_strcasecmp(src->name, "rdf")) {
if (!g_ascii_strcasecmp((char *)src->name, "rdf")) {
while (src) {
g_print("my cont:%s\n", src->content);
src=src->children;
......@@ -1142,7 +1139,7 @@ import_opml(gchar *file)
src = src->children;
d(g_print("group name:%s\n", layer_find(src, "name", NULL)));
src = src->next;
while (src = iterate_import_file(src, &url, &name, 1)) {
while ((src = iterate_import_file(src, &url, &name, 1))) {
if (url) {
total++;
xmlFree(url);
......@@ -1153,9 +1150,9 @@ import_opml(gchar *file)
type = 1;
}
}
else if (!g_ascii_strcasecmp(src->name, "opml")) {
else if (!g_ascii_strcasecmp((char *)src->name, "opml")) {
while (src = iterate_import_file(src, &url, &name, 0)) {
while ((src = iterate_import_file(src, &url, &name, 0))) {
if (url && strlen(url)) {
total++;
xmlFree(url);
......@@ -1184,7 +1181,7 @@ import_opml(gchar *file)
d(g_print("group name:%s\n", layer_find(src, "name", NULL)));
src = src->next;
}
while (src = iterate_import_file(src, &url, &name, type)) {
while ((src = iterate_import_file(src, &url, &name, type))) {
if (url && strlen(url)) {
g_print("url:%s\n", url);
if (rf->cancel)
......@@ -1193,12 +1190,12 @@ import_opml(gchar *file)
rf->cancel = 0;
goto out;
}
gtk_label_set_text(GTK_LABEL(import_label), name);
gtk_label_set_text(GTK_LABEL(import_label), (gchar *)name);
#if GTK_VERSION >= 2006000
gtk_label_set_ellipsize (GTK_LABEL (import_label), PANGO_ELLIPSIZE_START);
#endif
gtk_label_set_justify(GTK_LABEL(import_label), GTK_JUSTIFY_CENTER);
import_one_feed(url, name);
import_one_feed(url, (gchar *)name);
if (name) xmlFree(name);
if (url) xmlFree(url);
......@@ -1352,7 +1349,8 @@ create_import_dialog (void)
GtkWidget *button1;
GtkWidget *button2;
import_file_select = gtk_file_chooser_dialog_new (_("Select import file"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, NULL);
import_file_select = gtk_file_chooser_dialog_new (_("Select import file"),
NULL, GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL);
gtk_window_set_keep_above(GTK_WINDOW(import_file_select), TRUE);
gtk_window_set_modal (GTK_WINDOW (import_file_select), TRUE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (import_file_select), TRUE);
......@@ -1388,7 +1386,8 @@ create_export_dialog (void)
GtkWidget *button3;
GtkWidget *button4;
export_file_select = gtk_file_chooser_dialog_new (_("Select file to export"), NULL, GTK_FILE_CHOOSER_ACTION_SAVE, NULL);
export_file_select = gtk_file_chooser_dialog_new (_("Select file to export"),
NULL, GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL);
gtk_window_set_keep_above(GTK_WINDOW(export_file_select), TRUE);
g_object_set (export_file_select,
"local-only", FALSE,
......@@ -1634,7 +1633,6 @@ e_plugin_lib_get_configure_widget (EPlugin *epl)
{
GtkListStore *store;
GtkTreeIter iter;
GConfClient *gconf = gconf_client_get_default();
GtkWidget *hbox;
guint i;
......@@ -1681,7 +1679,7 @@ e_plugin_lib_get_configure_widget (EPlugin *epl)
break;
#endif
default:
g_printf("Selected render not supported! Failling back to default.\n");
g_print("Selected render not supported! Failling back to default.\n");
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), render);
}
......@@ -1766,15 +1764,10 @@ GtkWidget *
folder_factory (EPlugin *epl, EConfigHookItemFactoryData *data)
{
EMConfigTargetFolder *target= (EMConfigTargetFolder *)data->config->target;
CamelFolder *cml_folder = target->folder;
CamelService *service;
CamelProvider *provider;
GtkWidget *lbl_size, *lbl_size_val;
GtkListStore *model;
GtkVBox *vbx;
GtkHBox *hbx_size;
char *folder_name, *folder_size;
int mode;
char *folder_size;
GladeXML *gui;
char *gladefile;
......@@ -1825,7 +1818,6 @@ rss_config_control_new (void)
GtkListStore *store;
GtkTreeIter iter;
int i;
GtkCellRenderer *cell;
GtkTreeSelection *selection;
GtkTreeViewColumn *column;
......
......@@ -351,7 +351,6 @@ taskbar_op_new(gchar *message)
{
EActivityHandler *activity_handler = mail_component_peek_activity_handler (mail_component_peek ());
char *mcp = g_strdup_printf("%p", mail_component_peek());
static GdkPixbuf *progress_icon;
guint activity_id =
#if (EVOLUTION_VERSION >= 22306)
e_activity_handler_cancelable_operation_started(activity_handler, "evolution-mail",
......@@ -495,9 +494,12 @@ browser_write(gchar *string, gint length, gchar *base)
#endif
break;
case 1:
#ifdef HAVE_WEBKIT
proxify_webkit_session(proxy, base);
webkit_web_view_load_html_string(WEBKIT_WEB_VIEW(rf->mozembed),
str,
base);
#endif
break;
}
}
......@@ -544,7 +546,6 @@ textcb(NetStatusType status, gpointer statusdata, gpointer data)
GtkDialog *
create_user_pass_dialog(RSS_AUTH *auth)
{
GtkWidget *dialog1;
GtkWidget *username;
GtkWidget *password;
GtkWidget *checkbutton1;
......@@ -553,7 +554,6 @@ create_user_pass_dialog(RSS_AUTH *auth)
GtkWidget *widget;
GtkWidget *action_area;
GtkWidget *content_area;
gboolean visible;
AtkObject *a11y;
widget = gtk_dialog_new_with_buttons (
......@@ -741,7 +741,6 @@ gboolean
proxy_auth_dialog(gchar *title, gchar *user, gchar *pass)
{
GtkDialog *dialog;
guint resp;
RSS_AUTH *auth_info = g_new0(RSS_AUTH, 1);
auth_info->user = user;
......@@ -1075,9 +1074,8 @@ xml_set_bool (xmlNodePtr node, const char *name, gboolean *val)
gboolean
feed_new_from_xml(char *xml)
{
xmlNodePtr node, cur;
xmlNodePtr node;
xmlDocPtr doc;
gboolean changed = FALSE;
char *uid = NULL;
char *name = NULL;
char *url = NULL;
......@@ -1394,11 +1392,12 @@ mycall (GtkWidget *widget, GtkAllocation *event, gpointer data)
if(GTK_IS_WIDGET(po->mozembedwindow) && height > 0)
{
if (engine == 2)
#ifdef HAVE_GECKO
gtk_moz_embed_open_stream(GTK_MOZ_EMBED(rf->mozembed),
po->website, "text/html");
#endif
//browser_write("test", 4);
if (!browser_fetching) {
gint fill=0;
browser_fetching=1;
fetch_unblocking(
po->website,
......@@ -1450,10 +1449,19 @@ rss_mozilla_init(void)
}
#endif
#ifdef HAVE_GECKO
void
render_set_preferences(void)
webkit_set_preferences(void)
{
#ifdef HAVE_WEBKIT
webkit_session = webkit_get_default_session();
#endif
}
void
gecko_set_preferences(void)
{
#ifdef HAVE_GECKO
SoupURI *uri;
gecko_prefs_set_bool("javascript.enabled",
gconf_client_get_bool(rss_gconf, GCONF_KEY_HTML_JS, NULL));
gecko_prefs_set_bool("security.enable_java",
......@@ -1464,8 +1472,18 @@ render_set_preferences(void)
EVOLUTION_VERSION_STRING, VERSION);
gecko_prefs_set_string("general.useragent.extra.firefox", agstr);
g_free(agstr);
}
//I'm only forcing scheme here
uri = e_proxy_peek_uri_for(proxy, "http:///");
gecko_prefs_set_string("network.proxy.http", uri->host);
gecko_prefs_set_int("network.proxy.http_port", uri->port);
gecko_prefs_set_int("network.proxy.type", 1);
// soup_uri_free(uri);
// uri = e_proxy_peek_uri_for(proxy, "https:///");
// gecko_prefs_set_string("network.proxy.ssl", uri->host);
// gecko_prefs_set_int("network.proxy.ssl_port", uri->port);
// soup_uri_free(uri);
#endif
}
static void
rss_popup_zoom_in(EPopup *ep, EPopupItem *pitem, void *data)
......@@ -1548,7 +1566,6 @@ gecko_click(GtkMozEmbed *mozembed, gpointer dom_event, gpointer user_data)
GSList *menus = NULL;
EMPopup *emp;
gint i=0, menu_size;
EMPopupTargetURI *t;
EPopupTarget *target;
if (-1 == (button = gecko_get_mouse_event_button (dom_event))) {
......@@ -1590,10 +1607,7 @@ static gboolean
org_gnome_rss_browser (EMFormatHTML *efh, void *eb, EMFormatHTMLPObject *pobject)
{
struct _org_gnome_rss_controls_pobject *po = (struct _org_gnome_rss_controls_pobject *) pobject;
int width, height;
GtkRequisition req;
GtkWidget *moz;
GString *content;
// gtk_widget_size_request (efhd->priv->attachment_bar, &req);
guint engine = fallback_engine();
......@@ -1606,6 +1620,7 @@ org_gnome_rss_browser (EMFormatHTML *efh, void *eb, EMFormatHTMLPObject *pobject
#ifdef HAVE_WEBKIT
if (engine == 1) {
rf->mozembed = (GtkWidget *)webkit_web_view_new();
webkit_set_preferences();
gtk_container_add(GTK_CONTAINER(moz), GTK_WIDGET(rf->mozembed));
g_signal_connect (rf->mozembed, "populate-popup", G_CALLBACK (webkit_click), moz);
// gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(moz), GTK_WIDGET(rf->mozembed));
......@@ -1616,7 +1631,7 @@ org_gnome_rss_browser (EMFormatHTML *efh, void *eb, EMFormatHTMLPObject *pobject
#ifdef HAVE_GECKO
if (engine == 2) {
rf->mozembed = gtk_moz_embed_new();
render_set_preferences();
gecko_set_preferences();
/* FIXME add all those profile shits */
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(moz), GTK_WIDGET(rf->mozembed));
......@@ -1844,8 +1859,6 @@ void org_gnome_cooly_format_rss(void *ep, EMFormatHookTarget *t) //camelmimepart
category = (gchar *)camel_medium_get_header (CAMEL_MEDIUM(message), "X-Evolution-rss-category");
gchar *subject = camel_header_decode_string(camel_medium_get_header (CAMEL_MEDIUM (message),
"Subject"), NULL);
gchar *f = camel_header_decode_string(camel_medium_get_header (CAMEL_MEDIUM (message),
"From"), NULL);
gpointer is_html = NULL;
if (feedid)
......@@ -2226,10 +2239,8 @@ char *strcasestr(const char *a, const char *b)
gboolean
setup_feed(add_feed *feed)
{
CamelException ex;
guint ret = 0;
guint ttl;
guint ttl_multiply = 0;
RDF *r = NULL;
GString *post;
GError *err = NULL;
......@@ -3605,8 +3616,7 @@ void org_gnome_cooly_rss_startup(void *ep, EMPopupTargetSelect *t)
(CamelObjectEventHookFunc)store_folder_renamed, NULL);
camel_object_hook_event(store, "folder_deleted",
(CamelObjectEventHookFunc)store_folder_deleted, NULL);
CamelObject *session = mail_component_peek_session(NULL);
camel_object_hook_event(session, "online", (CamelObjectEventHookFunc)rss_online, NULL);
camel_object_hook_event(mail_component_peek_session(NULL), "online", (CamelObjectEventHookFunc)rss_online, NULL);
}
/* check if rss folders exists and create'em otherwise */
......@@ -3760,9 +3770,6 @@ org_gnome_cooly_rss(void *ep, EMEventTargetSendReceive *t)
org_gnome_cooly_rss(void *ep, EMPopupTargetSelect *t)
#endif
{
GtkWidget *readrss_dialog;
GtkWidget *readrss_label;
GtkWidget *readrss_progress;
GtkWidget *label,*progress_bar, *cancel_button, *status_label;
GtkWidget *recv_icon;
......@@ -3915,10 +3922,10 @@ rss_finalize(void)
if (rf->mozembed)
gtk_widget_destroy(rf->mozembed);
guint render = GPOINTER_TO_INT(
/* guint render = GPOINTER_TO_INT(
gconf_client_get_int(rss_gconf,
GCONF_KEY_HTML_RENDER,
NULL));
NULL));*/
#ifdef HAVE_GECKO
/*/really find a better way to deal with this//
//I do not know how to shutdown gecko (gtk_moz_embed_pop_startup)
......@@ -4056,7 +4063,7 @@ create_mail(create_feed *CF)
CamelMimeMessage *new = camel_mime_message_new();
CamelInternetAddress *addr;
CamelMessageInfo *info;
CamelException *ex;
CamelException *ex = NULL;
struct tm tm;
time_t time;
CamelDataWrapper *rtext;
......@@ -4533,14 +4540,14 @@ migrate_crc_md5(const char *name, gchar *url)
gchar *
decode_utf8_entities(gchar *str)
{
guint inlen, utf8len;
int inlen, utf8len;
gchar *buffer;
g_return_val_if_fail (str != NULL, NULL);
inlen = strlen(str);
utf8len = 5*inlen+1;
buffer = g_malloc0(utf8len);
UTF8ToHtml(buffer, &utf8len, str, &inlen);
UTF8ToHtml((unsigned char *)buffer, &utf8len, (unsigned char *)str, &inlen);
return buffer;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment