Commit 8eeee66a authored by Lucian Langa's avatar Lucian Langa
Browse files

move prototypes to header files part1

parent 8e02b09f
2009-05-05 Lucian Langa <lucilanga@gnome.org>
* src/Makefile.am: add misc.c and rss-config-factory.c to build list
* src/fetch.c (fetch_blocking), (fetch_unblocking): headers cleanup
* src/misc.c (check_if_match), (gen_crc):
* src/rss-config-factory.c (start_check_cb): move function here
* src/rss.c (browser_write), (browsercb),
(create_user_pass_dialog), (web_auth_dialog), (mycall),
(webkit_click), (gecko_click), (org_gnome_rss_browser),
(org_gnome_cooly_format_rss), (finish_website), (finish_comments),
(fetch_comments): fix wrongly defined headers
2009-05-03 Lucian Langa <lucilanga@gnome.org>
* src/gecko-utils.cpp:
......
......@@ -69,7 +69,9 @@ plugin_DATA = org-gnome-evolution-rss.eplug \
plugin_LTLIBRARIES = liborg-gnome-evolution-rss.la
SOURCES = rss.c
SOURCES = rss.c \
rss-config-factory.c \
misc.c
if HAVE_GECKO
SOURCES+= gecko-utils.cpp
endif
......
......@@ -63,9 +63,10 @@ am__installdirs = "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(bindir)" \
pluginLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(plugin_LTLIBRARIES)
liborg_gnome_evolution_rss_la_LIBADD =
am__liborg_gnome_evolution_rss_la_SOURCES_DIST = rss.c gecko-utils.cpp
am__liborg_gnome_evolution_rss_la_SOURCES_DIST = rss.c \
rss-config-factory.c misc.c gecko-utils.cpp
@HAVE_GECKO_TRUE@am__objects_1 = gecko-utils.lo
am__objects_2 = rss.lo $(am__objects_1)
am__objects_2 = rss.lo rss-config-factory.lo misc.lo $(am__objects_1)
am_liborg_gnome_evolution_rss_la_OBJECTS = $(am__objects_2)
liborg_gnome_evolution_rss_la_OBJECTS = \
$(am_liborg_gnome_evolution_rss_la_OBJECTS)
......@@ -346,7 +347,7 @@ plugin_DATA = org-gnome-evolution-rss.eplug \
org-gnome-evolution-rss.xml
plugin_LTLIBRARIES = liborg-gnome-evolution-rss.la
SOURCES = rss.c $(am__append_2)
SOURCES = rss.c rss-config-factory.c misc.c $(am__append_2)
liborg_gnome_evolution_rss_la_SOURCES = $(SOURCES)
liborg_gnome_evolution_rss_la_LDFLAGS = -module -avoid-version $(WEBKIT_LIBS) $(GECKO_LIBS) $(LIBSOUP_LIBS) $(NO_UNDEFINED_LIBS) $(NO_UNDEFINED)
#$(GECKO_RPATH)
......@@ -500,6 +501,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evolution-import-rss.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gecko-utils.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rss-config-factory.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rss.Plo@am__quote@
.c.o:
......
......@@ -23,7 +23,7 @@
#include "file-gio.h"
GString*
fetch_blocking(const char *url, GSList *headers, GString *post,
fetch_blocking(gchar *url, GSList *headers, GString *post,
NetStatusCallback cb, gpointer data,
GError **err) {
......@@ -61,7 +61,7 @@ error:
//FIXME gio callback hardcoded
gboolean
fetch_unblocking(const char *url, NetStatusCallback cb, gpointer data,
fetch_unblocking(gchar *url, NetStatusCallback cb, gpointer data,
gpointer cb2, gpointer cbdata2,
guint track,
GError **err)
......
/* Evoution RSS Reader Plugin
* Copyright (C) 2007 Lucian Langa <cooly@gnome.eu.org>
* Copyright (C) 2007-2009 Lucian Langa <cooly@gnome.eu.org>
*
* 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
......@@ -19,7 +19,15 @@
#ifndef __MISC_C_
#define __MISC_C_
#define d(x)
#include <stdint.h>
#include <string.h>
#include <glib.h>
#include <libedataserver/md5-utils.h>
#include <camel/camel-mime-utils.h>
#include "misc.h"
int
getNumericConfValue(gpointer a)
......@@ -46,6 +54,20 @@ free_hash(gpointer key, gpointer value, gpointer user_data)
// xmlFreeDoc(key);
}
gboolean
check_if_match (gpointer key, gpointer value, gpointer user_data)
{
char *sf_href = (char *)value;
char *int_uri = (char *)user_data;
d(g_print("checking hay:%s for neddle:%s\n", sf_href, int_uri));
if (!strcmp (sf_href, int_uri))
return TRUE; /* Quit calling the callback */
return FALSE; /* Continue calling the callback till end of table */
}
gchar *
strextr(gchar *text, gchar *substr)
{
......@@ -193,7 +215,7 @@ strplchr(gchar *source)
return string;
}
static gchar *
gchar *
markup_decode (gchar *str)
{
char *iterator, *temp;
......@@ -248,7 +270,7 @@ markup_decode (gchar *str)
return temp;
}
uint32_t
gchar *
gen_crc(const char *msg)
{
register unsigned long crc, poly;
......@@ -272,17 +294,17 @@ gen_crc(const char *msg)
crc = 0xFFFFFFFF;
for (i = 0; i < strlen(msg); i++)
crc = ((crc >> 8) & 0x00FFFFFF) ^ crc_tab[(crc ^ *msg++) & 0xFF];
return (crc ^ 0xFFFFFFFF);
return g_strdup_printf("%x", (crc ^ 0xFFFFFFFF));
}
static char *
gchar *
gen_md5(gchar *buffer)
{
unsigned char md5sum[16], res[17], *f;
int i;
const char tohex[16] = "0123456789abcdef";
unsigned char md5sum[16], res[17], *f;
int i;
const char tohex[16] = "0123456789abcdef";
md5_get_digest (buffer, strlen(buffer), md5sum);
md5_get_digest (buffer, strlen(buffer), md5sum);
for (i=0, f = res; i<16;i++)
{
unsigned int c = md5sum[i];
......
......@@ -24,7 +24,7 @@
#include "network.h"
#include "rss.h"
#include "misc.c"
#include "misc.h"
#define USE_PROXY FALSE
......@@ -456,7 +456,7 @@ out:
}
gboolean
net_get_unblocking(const char *url,
net_get_unblocking(gchar *url,
NetStatusCallback cb, gpointer data,
gpointer cb2, gpointer cbdata2,
guint track,
......@@ -554,7 +554,7 @@ soup_message_add_header_handler (msg,
}
GString*
net_post_blocking(const char *url, GSList *headers, GString *post,
net_post_blocking(gchar *url, GSList *headers, GString *post,
NetStatusCallback cb, gpointer data,
GError **err) {
#if LIBSOUP_VERSION < 2003000
......@@ -642,6 +642,78 @@ out:
return response;
}
gboolean
cancel_soup_sess(gpointer key, gpointer value, gpointer user_data)
{
#if LIBSOUP_VERSION < 2003000
SoupUri *uri = soup_message_get_uri((SoupMessage *)value);
#else
SoupURI *uri = soup_message_get_uri((SoupMessage *)value);
#endif
d(g_print("cancel url:%s%s?%s\n", uri->host, uri->path, uri->query?uri->query:""));
if (SOUP_IS_SESSION(key))
{
/* if (SOUP_IS_MESSAGE(value))
{
#if LIBSOUP_VERSION < 2003000
soup_message_set_status(value, SOUP_STATUS_CANCELLED);
soup_session_cancel_message(key, value);
#else
soup_session_cancel_message(key, value, SOUP_STATUS_CANCELLED);
#endif
}*/
soup_session_abort(key);
g_hash_table_find(rf->key_session,
remove_if_match,
user_data);
}
return TRUE;
}
void
remove_weak(gpointer key, gpointer value, gpointer user_data)
{
g_object_weak_unref(value, unblock_free, key);
}
void
abort_all_soup(void)
{
//abort all session
rf->cancel = 1;
rf->cancel_all = 1;
if (rf->abort_session)
{
g_hash_table_foreach(rf->abort_session, remove_weak, NULL);
g_hash_table_foreach_remove(rf->abort_session, cancel_soup_sess, NULL);
// g_hash_table_foreach(rf->abort_session, cancel_soup_sess, NULL);
g_hash_table_destroy(rf->session);
rf->session = g_hash_table_new(g_direct_hash, g_direct_equal);
}
if (rf->progress_bar)
{
gtk_progress_bar_set_fraction((GtkProgressBar *)rf->progress_bar, 1);
rf->progress_bar = NULL; //there's no need to update bar once we canceled feeds
}
if (rf->b_session)
{
/* if (SOUP_IS_MESSAGE(rf->b_msg_session))
{
#if LIBSOUP_VERSION < 2003000
soup_message_set_status(rf->b_msg_session, SOUP_STATUS_CANCELLED);
soup_session_cancel_message(rf->b_session, rf->b_msg_session);
#else
soup_session_cancel_message(rf->b_session, rf->b_msg_session, SOUP_STATUS_CANCELLED);
#endif
}*/
soup_session_abort(rf->b_session);
rf->b_session = NULL;
rf->b_msg_session = NULL;
}
rf->cancel_all = 0;
}
void
rss_soup_init(void)
{
......
......@@ -365,7 +365,7 @@ g_print("parser error 3_4 -> return NULL!!!\n");
/* returns node disregarding type
*/
static char *
char *
layer_find (xmlNodePtr node,
char *match,
char *fail)
......
......@@ -21,7 +21,7 @@
gchar *update_channel(RDF *r);
static char *layer_find (xmlNodePtr node, char *match, char *fail);
char *layer_find (xmlNodePtr node, char *match, char *fail);
static char *layer_find_innerelement (xmlNodePtr node, char *match, char *el, char *fail);
static gchar *layer_find_innerhtml (xmlNodePtr node, char *match, char *submatch, char *fail);
xmlNodePtr layer_find_pos (xmlNodePtr node, char *match, char *submatch);
......
......@@ -21,16 +21,42 @@
#include "config.h"
#endif
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <gconf/gconf-client.h>
#include <gdk/gdkkeysyms.h>
#include <camel/camel-folder.h>
#include <camel/camel-store.h>
#include <camel/camel-operation.h>
#include <camel/camel-provider.h>
#include <mail/em-event.h>
#include <mail/em-config.h>
#include <shell/evolution-config-control.h>
#include <bonobo/bonobo-shlib-factory.h>
#include "rss.h"
#include "misc.h"
#include "parser.h"
#define d(x)
static guint feed_enabled = 0;
static guint feed_validate = 0;
static guint feed_html = 0;
extern rssfeed *rf;
extern guint upgrade;
extern guint count;
extern gchar *buffer;
extern GSList *rss_list;
#define RSS_CONTROL_ID "OAFIID:GNOME_Evolution_RSS:" EVOLUTION_VERSION_STRING
#define FACTORY_ID "OAFIID:GNOME_Evolution_RSS_Factory:" EVOLUTION_VERSION_STRING
#define MAX_TTL 10000
......@@ -110,6 +136,14 @@ render_engine_changed (GtkComboBox *dropdown, GCallback *user_data)
#endif
}
static void
start_check_cb (GtkWidget *widget, gpointer data)
{
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
/* Save the new setting to gconf */
gconf_client_set_bool (rss_gconf, data, active, NULL);
}
static void
enable_toggle_cb(GtkCellRendererToggle *cell,
gchar *path_str,
......@@ -240,6 +274,7 @@ details_cb (GtkWidget *widget, gpointer data)
gtk_widget_show(details);
}
static void
construct_list(gpointer key, gpointer value, gpointer user_data)
{
......@@ -740,7 +775,6 @@ delete_feed_folder_alloc(gchar *old_name)
rf->reversed_feed_folders);
}
static void
delete_response(GtkWidget *selector, guint response, gpointer user_data)
{
......
......@@ -57,9 +57,9 @@ int rss_verbose_debug = 0;
#include <misc/e-activity-handler.h>
#include <mail/em-format.h>
#include <mail/em-format-html.h>
#include <mail/em-format.h>
#include <mail/em-format-hook.h>
#include <sys/types.h>
......@@ -76,15 +76,13 @@ int rss_verbose_debug = 0;
#endif
#include <glib.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <bonobo/bonobo-shlib-factory.h>
#include <glade/glade-xml.h>
#include <glade/glade.h>
#include <shell/evolution-config-control.h>
#include <shell/e-component-view.h>///
//#include <shell/e-component-view.h>///
#include <shell/es-event.h>
#include <camel/camel-data-cache.h>
#include <camel/camel-file-utils.h>
......@@ -137,11 +135,11 @@ int rss_verbose_debug = 0;
#include "network-soup.c"
#include "file-gio.c"
#include "fetch.c"
#include "misc.c"
#include "misc.h"
#if HAVE_DBUS
#include "dbus.c"
#endif
#include "rss-config-factory.c"
#include "rss-config-factory.h"
#include "rss-icon-factory.c"
#include "parser.c"
......@@ -185,6 +183,11 @@ gsize pixfilelen;
extern int xmlSubstituteEntitiesDefaultValue;
rssfeed *rf = NULL;
guint upgrade = 0; // set to 2 when initailization successfull
guint count = 0;
gchar *buffer = NULL;
GSList *rss_list = NULL;
gboolean inhibit_read = FALSE; //prevent mail selection when deleting folder
gboolean delete_op = FALSE; //delete in progress
gchar *commstream = NULL; //global comments stream
......@@ -200,17 +203,12 @@ gboolean setup_feed(add_feed *feed);
gchar *display_doc (RDF *r);
gchar *display_comments (RDF *r);
void check_folders(void);
gchar *strplchr(gchar *source);
static char *gen_md5(gchar *buffer);
CamelMimePart *file_to_message(const char *name);
void save_gconf_feed(void);
void check_feed_age(void);
static gboolean check_if_match (gpointer key, gpointer value, gpointer user_data);
static void del_days_cb (GtkWidget *widget, add_feed *data);
static void del_messages_cb (GtkWidget *widget, add_feed *data);
void get_feed_age(gpointer key, gpointer value);
gboolean cancel_soup_sess(gpointer key, gpointer value, gpointer user_data);
void abort_all_soup(void);
gchar *encode_html_entities(gchar *str);
static void
#if LIBSOUP_VERSION < 2003000
......@@ -225,33 +223,8 @@ finish_create_image (SoupMessage *msg, gchar *user_data);
finish_create_image (SoupSession *soup_sess, SoupMessage *msg, gchar *user_data);
#endif
gchar *get_main_folder(void);
void fetch_comments(gchar *url, CamelStream *stream);
struct _MailComponentPrivate {
GMutex *lock;
/* states/data used during shutdown */
enum { MC_QUIT_START, MC_QUIT_SYNC, MC_QUIT_THREADS } quit_state;
int quit_count;
int quit_expunge; /* expunge on quit this time around? */
char *base_directory;
void fetch_comments(gchar *url, EMFormatHTML *stream);
EMFolderTreeModel *model;
// EActivityHandler *activity_handler;
MailAsyncEvent *async_event;
GHashTable *store_hash; /* stores store_info objects by store */
// RuleContext *search_context;
char *context_path; /* current path for right-click menu */
CamelStore *local_store;
EComponentView *component_view;
};
static void
dialog_key_destroy (GtkWidget *widget, gpointer data);
guint fallback_engine(void);
......@@ -493,7 +466,7 @@ statuscb(NetStatusType status, gpointer statusdata, gpointer data)
}
}
static void
void
browser_write(gchar *string, gint length, gchar *base)
{
gchar *str = string;
......@@ -517,14 +490,14 @@ browser_write(gchar *string, gint length, gchar *base)
break;
case 1:
webkit_web_view_load_html_string(WEBKIT_WEB_VIEW(rf->mozembed),
string,
str,
base);
break;
}
}
static void
browsercb(NetStatusType status, gpointer statusdata, gint data)
browsercb(NetStatusType status, gpointer statusdata, gpointer data)
{
NetStatusProgress *progress = (NetStatusProgress*)statusdata;
switch (status) {
......@@ -533,7 +506,7 @@ browsercb(NetStatusType status, gpointer statusdata, gint data)
g_print("total:%d\n", progress->total);
g_print("curent:%d\n", progress->current);
g_print("--------------\n chunk: %d \n=============\n", progress->chunksize);
// browser_write(progress->chunk, progress->chunksize);
//browser_write(progress->chunk, progress->chunksize, data);
// browser_fill+=progress->chunksize;
break;
default:
......@@ -591,8 +564,8 @@ create_user_pass_dialog(RSS_AUTH *auth)
gtk_container_set_border_width (GTK_CONTAINER (widget), 12);
GtkWidget *password_dialog = GTK_DIALOG (widget);
action_area = gtk_dialog_get_action_area (password_dialog);
content_area = gtk_dialog_get_content_area (password_dialog);
action_area = gtk_dialog_get_action_area (GTK_DIALOG(password_dialog));
content_area = gtk_dialog_get_content_area (GTK_DIALOG(password_dialog));
/* Override GtkDialog defaults */
gtk_box_set_spacing (GTK_BOX (action_area), 12);
......@@ -746,11 +719,11 @@ web_auth_dialog(gchar *url)
else
del_up(url);
gtk_widget_destroy (dialog);
gtk_widget_destroy (GTK_WIDGET(dialog));
resp = 0;
break;
default:
gtk_widget_destroy (dialog);
gtk_widget_destroy (GTK_WIDGET(dialog));
resp = 1;
break;
}
......@@ -771,40 +744,6 @@ proxy_auth_dialog(gchar *title, gchar *user, gchar *pass)
gint result = gtk_dialog_run(GTK_DIALOG(dialog));
}
gboolean
cancel_soup_sess(gpointer key, gpointer value, gpointer user_data)
{
#if LIBSOUP_VERSION < 2003000
SoupUri *uri = soup_message_get_uri((SoupMessage *)value);
#else
SoupURI *uri = soup_message_get_uri((SoupMessage *)value);
#endif
d(g_print("cancel url:%s%s?%s\n", uri->host, uri->path, uri->query?uri->query:""));
if (SOUP_IS_SESSION(key))
{
/* if (SOUP_IS_MESSAGE(value))
{
#if LIBSOUP_VERSION < 2003000
soup_message_set_status(value, SOUP_STATUS_CANCELLED);
soup_session_cancel_message(key, value);
#else
soup_session_cancel_message(key, value, SOUP_STATUS_CANCELLED);
#endif
}*/
soup_session_abort(key);
g_hash_table_find(rf->key_session,
remove_if_match,
user_data);
}
return TRUE;
}
void
remove_weak(gpointer key, gpointer value, gpointer user_data)
{
g_object_weak_unref(value, unblock_free, key);
}
gboolean
timeout_soup(void)
{
......@@ -830,43 +769,6 @@ network_timeout(void)
0);
}
void
abort_all_soup(void)
{
//abort all session
rf->cancel = 1;
rf->cancel_all = 1;
if (rf->abort_session)
{
g_hash_table_foreach(rf->abort_session, remove_weak, NULL);
g_hash_table_foreach_remove(rf->abort_session, cancel_soup_sess, NULL);
// g_hash_table_foreach(rf->abort_session, cancel_soup_sess, NULL);
g_hash_table_destroy(rf->session);
rf->session = g_hash_table_new(g_direct_hash, g_direct_equal);
}
if (rf->progress_bar)
{
gtk_progress_bar_set_fraction((GtkProgressBar *)rf->progress_bar, 1);
rf->progress_bar = NULL; //there's no need to update bar once we canceled feeds
}
if (rf->b_session)
{
/* if (SOUP_IS_MESSAGE(rf->b_msg_session))
{
#if LIBSOUP_VERSION < 2003000
soup_message_set_status(rf->b_msg_session, SOUP_STATUS_CANCELLED);
soup_session_cancel_message(rf->b_session, rf->b_msg_session);
#else
soup_session_cancel_message(rf->b_session, rf->b_msg_session, SOUP_STATUS_CANCELLED);
#endif
}*/
soup_session_abort(rf->b_session);
rf->b_session = NULL;
rf->b_msg_session = NULL;
}
rf->cancel_all = 0;
}
static void
readrss_dialog_cb (GtkWidget *widget, gpointer data)
{
......@@ -986,20 +888,6 @@ save_gconf_feed(void)
gconf_client_suggest_sync (rss_gconf, NULL);
}
static gboolean
check_if_match (gpointer key, gpointer value, gpointer user_data)
{
char *sf_href = (char *)value;
char *int_uri = (char *)user_data;
d(g_print("checking hay:%s for neddle:%s\n", sf_href, int_uri));
if (!strcmp (sf_href, int_uri))
return TRUE; /* Quit calling the callback */
return FALSE; /* Continue calling the callback till end of table */
}
void
rss_select_folder(gchar *folder_name)
{
......@@ -1094,14 +982,6 @@ tree_cb (GtkWidget *widget, gpointer data)
}
}*/
static void
start_check_cb (GtkWidget *widget, gpointer data)
{
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
/* Save the new setting to gconf */
gconf_client_set_bool (rss_gconf, data, active, NULL);
}
static void
dialog_key_destroy (GtkWidget *widget, gpointer data)
{
......@@ -1522,7 +1402,7 @@ mycall (GtkWidget *widget, GtkAllocation *event, gpointer data)
fetch_unblocking(