+2007-11-14 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Remove trailing whitespace from source code.
+
2007-11-13 Ondrej Jirman <megous@megous.com>
** Fix for bug #494299
* Hans Petter Jansson <hpj@novell.com>
*/
-#include <config.h>
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
return g_strdup_printf (PAS_ID_PREFIX "%08lX%08X", time(NULL), c++);
}
-static void
+static void
set_revision (EContact *contact)
{
char time_string[25] = {0};
if (tm)
strftime (time_string, 100, "%Y-%m-%dT%H:%M:%SZ", tm);
e_contact_set (contact, E_CONTACT_REV, time_string);
-
+
}
static EBookBackendSyncStatus
char *id;
char *vcard;
const char *rev;
-
+
g_assert (bf);
g_assert (vcard_req);
g_assert (contact);
const char *search = query;
GList *contact_list = NULL;
EBookBackendSyncStatus status;
-
+
d(printf ("e_book_backend_file_get_contact_list (%s)\n", search));
status = GNOME_Evolution_Addressbook_Success;
if (e_book_backend_summary_is_summary_query (bf->priv->summary, search)) {
-
+
/* do a summary query */
GPtrArray *ids = e_book_backend_summary_search (bf->priv->summary, search);
int i;
}
g_object_unref (card_sexp);
-
+
if (db_error == DB_NOTFOUND) {
status = GNOME_Evolution_Addressbook_Success;
} else {
/* ref the book view because it'll be removed and unrefed
when/if it's stopped */
bonobo_object_ref (book_view);
-
+
db = bf->priv->file_db;
query = e_data_book_view_get_card_query (book_view);
DB *db = ctx->db;
DBT id_dbt, vcard_dbt;
int db_error = 0;
-
+
string_to_dbt (key, &id_dbt);
memset (&vcard_dbt, 0, sizeof (vcard_dbt));
vcard_dbt.flags = DB_DBT_MALLOC;
db_error = db->get (db, NULL, &id_dbt, &vcard_dbt, 0);
-
+
if (db_error != 0) {
EContact *contact;
char *id = id_dbt.data;
contact = e_contact_new ();
e_contact_set (contact, E_CONTACT_UID, id);
-
+
vcard_string = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
ctx->del_ids = g_list_append (ctx->del_ids,
vcard_string);
g_object_unref (contact);
-
+
g_free (vcard_dbt.data);
}
}
EContact *contact;
char *id = id_dbt.data;
char *vcard_string;
-
+
/* Remove fields the user can't change
* and can change without the rest of the
- * card changing
+ * card changing
*/
contact = create_contact (id_dbt.data, vcard_dbt.data);
#endif
vcard_string = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
g_object_unref (contact);
-
+
/* check what type of change has occurred, if any */
switch (e_dbhash_compare (ehash, id, vcard_string)) {
case E_DBHASH_STATUS_SAME:
g_free (i->data);
g_free (v->data);
- }
+ }
for (i = ctx.mod_ids, v = ctx.mod_cards; i != NULL; i = i->next, v = v->next){
char *id = i->data;
char *vcard = v->data;
e_book_backend_change_modify_new (vcard));
g_free (i->data);
- g_free (v->data);
+ g_free (v->data);
}
- for (i = ctx.del_ids, v = ctx.del_cards; i != NULL; i = i->next, v = v->next){
+ for (i = ctx.del_ids, v = ctx.del_cards; i != NULL; i = i->next, v = v->next){
char *id = i->data;
char *vcard = v->data;
-
+
e_dbhash_remove (ehash, id);
-
+
changes = g_list_prepend (changes,
e_book_backend_change_delete_new (vcard));
g_free (i->data);
GList **fields_out)
{
GList *fields = NULL;
-
+
fields = g_list_append (fields , g_strdup(e_contact_field_name (E_CONTACT_FILE_AS)));
*fields_out = fields;
return GNOME_Evolution_Addressbook_Success;
DB *db = bf->priv->file_db;
int db_error;
DBT version_name_dbt, version_dbt;
-
+
if (strcmp (old_version, "0.0")
&& strcmp (old_version, "0.1")) {
g_warning ("unsupported version '%s' found in PAS backend file\n",
env->set_errcall (env, file_errcall);
/* Set the allocation routines to the non-aborting GLib functions */
- env->set_alloc (env, (void *(*)(size_t))g_try_malloc,
+ env->set_alloc (env, (void *(*)(size_t))g_try_malloc,
(void *(*)(void *, size_t))g_try_realloc,
g_free);
#ifdef CREATE_DEFAULT_VCARD
EContact *contact = NULL;
EBookBackendSyncStatus status;
-
+
status = do_create (bf, XIMIAN_VCARD, &contact);
if (status != GNOME_Evolution_Addressbook_Success)
g_warning ("Cannot create default contact: %d", status);
}
bf->priv->file_db = db;
-
+
if (db_error != 0) {
bf->priv->file_db = NULL;
g_free (dirname);
{
return GNOME_Evolution_Addressbook_CouldNotCancel;
}
-static void
+static void
e_book_backend_file_set_mode (EBookBackend *backend, GNOME_Evolution_Addressbook_BookMode mode)
{
if (e_book_backend_is_loaded (backend)) {
}
}
-static void
+static void
e_book_backend_file_sync (EBookBackend *backend)
{
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
int db_error;
-
+
g_return_if_fail (bf != NULL);
-
+
if (bf->priv->file_db) {
db_error = bf->priv->file_db->sync (bf->priv->file_db, 0);
if (db_error != 0)
bf->priv->file_db->close (bf->priv->file_db, 0);
bf->priv->file_db = NULL;
}
-
+
G_LOCK (global_env);
global_env.ref_count--;
if (global_env.ref_count == 0) {
global_env.env = NULL;
}
G_UNLOCK (global_env);
-
+
if (bf->priv->summary) {
g_object_unref (bf->priv->summary);
bf->priv->summary = NULL;
}
- G_OBJECT_CLASS (e_book_backend_file_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_book_backend_file_parent_class)->dispose (object);
}
static void
g_free (bf->priv->filename);
g_free (bf->priv->dirname);
g_free (bf->priv->summary_filename);
-
+
g_free (bf->priv);
G_OBJECT_CLASS (e_book_backend_file_parent_class)->finalize (object);
sync_class->authenticate_user_sync = e_book_backend_file_authenticate_user;
sync_class->get_supported_fields_sync = e_book_backend_file_get_supported_fields;
sync_class->get_required_fields_sync = e_book_backend_file_get_required_fields;
-
+
object_class->dispose = e_book_backend_file_dispose;
object_class->finalize = e_book_backend_file_finalize;
#include "libedataserver/e-data-server-util.h"
#include "libedataserver/e-db3-utils.h"
#include "libedataserver/e-flag.h"
-#include "libedataserver/e-url.h"
+#include "libedataserver/e-url.h"
#include "libebook/e-contact.h"
#include "libedata-book/e-book-backend-sexp.h"
#include "libedata-book/e-data-book.h"
#include "e-gw-filter.h"
G_DEFINE_TYPE (EBookBackendGroupwise, e_book_backend_groupwise, E_TYPE_BOOK_BACKEND);
-
+
struct _EBookBackendGroupwisePrivate {
- EGwConnection *cnc;
+ EGwConnection *cnc;
char *uri;
char *container_id;
char *book_name;
void (*populate_contact_func)(EContact *contact, gpointer data);
void (*set_value_in_gw_item) (EGwItem *item, gpointer data);
void (*set_changes) (EGwItem *new_item, EGwItem *old_item);
-
-} mappings [] = {
-
+
+} mappings [] = {
+
{ E_CONTACT_UID, ELEMENT_TYPE_SIMPLE, "id"},
{ E_CONTACT_FILE_AS, ELEMENT_TYPE_SIMPLE, "name" },
{ E_CONTACT_FULL_NAME, ELEMENT_TYPE_COMPLEX, "full_name", populate_full_name, set_full_name_in_gw_item, set_full_name_changes},
{ E_CONTACT_EMAIL_1, ELEMENT_TYPE_COMPLEX, "email", populate_emails, set_emails_in_gw_item, set_emails_changes },
{ E_CONTACT_REV, ELEMENT_TYPE_SIMPLE, "modified_time"},
{ E_CONTACT_BOOK_URI, ELEMENT_TYPE_SIMPLE, "book_uri"}
-};
+};
static void
free_attr_list (GList *attr_list)
{
GList *l;
-
+
for (l = attr_list; l; l = g_list_next (l)) {
EVCardAttribute *attr = l->data;
e_vcard_attribute_free (attr);
}
-
+
g_list_free (attr_list);
}
-static void
+static void
populate_ims (EContact *contact, gpointer data)
{
GList *im_list;
GList *groupwise_list = NULL;
IMAddress *address;
EGwItem *item;
-
+
item = E_GW_ITEM (data);
im_list = e_gw_item_get_im_list (item);
if (address->service == NULL) {
continue;
}
-
+
if (g_str_equal (address->service, "icq")) {
im_field_id = E_CONTACT_IM_ICQ;
im_attr_list = &icq_list;
im_field_id = E_CONTACT_IM_JABBER;
im_attr_list = &jabber_list;
}
-
+
else if (g_str_equal (address->service, "nov")) {
im_field_id = E_CONTACT_IM_GROUPWISE;
im_attr_list = &groupwise_list;
e_vcard_attribute_add_value (attr, address->address);
*im_attr_list = g_list_append (*im_attr_list, attr);
}
-
+
e_contact_set_attributes (contact, E_CONTACT_IM_AIM, aim_list);
e_contact_set_attributes (contact, E_CONTACT_IM_JABBER, jabber_list);
e_contact_set_attributes (contact, E_CONTACT_IM_ICQ, icq_list);
e_contact_set_attributes (contact, E_CONTACT_IM_GADUGADU, gadugadu_list);
e_contact_set_attributes (contact, E_CONTACT_IM_MSN, msn_list);
e_contact_set_attributes (contact, E_CONTACT_IM_GROUPWISE, groupwise_list);
-
+
free_attr_list (aim_list);
free_attr_list (jabber_list);
free_attr_list (icq_list);
*im_list = g_list_append (*im_list, address);
}
g_list_free (list);
-
+
}
-static void
+static void
set_ims_in_gw_item (EGwItem *item, gpointer data)
{
EContact *contact;
GList *im_list = NULL;
-
+
contact = E_CONTACT (data);
-
+
append_ims_to_list (&im_list, contact, "aim", E_CONTACT_IM_AIM);
append_ims_to_list (&im_list, contact, "yahoo", E_CONTACT_IM_YAHOO);
append_ims_to_list (&im_list, contact, "gadu-gadu", E_CONTACT_IM_GADUGADU);
new_ims = e_gw_item_get_im_list (new_item);
if (old_ims && new_ims) {
-
+
old_ims_copy = g_list_copy (old_ims);
for ( ; new_ims != NULL; new_ims = g_list_next (new_ims)) {
-
+
im1 = new_ims->data;
temp = old_ims;
ims_matched = FALSE;
old_ims_copy = g_list_remove (old_ims_copy, im2);
break;
}
-
+
}
if (! ims_matched)
added_ims = g_list_append (added_ims, im1);
}
-
+
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_ADD, "ims", added_ims);
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_DELETE, "ims", old_ims_copy);
} else if (new_ims && !old_ims) {
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_ADD, "ims", g_list_copy (new_ims));
}
-
+
}
-static void
+static void
copy_postal_address_to_contact_address ( EContactAddress *contact_addr, PostalAddress *address)
{
contact_addr->address_format = NULL;
contact_addr->country = g_strdup (address->country);
}
-static void
+static void
copy_contact_address_to_postal_address (PostalAddress *address, EContactAddress *contact_addr)
{
/* ugh, contact addr has null terminated strings instead of NULLs*/
address->country = (contact_addr->country && *(contact_addr->country)) ? g_strdup (contact_addr->country) : NULL;
}
-static void
+static void
populate_address (EContact *contact, gpointer data)
{
PostalAddress *address;
EGwItem *item;
EContactAddress *contact_addr;
-
+
item = E_GW_ITEM (data);
-
+
address = e_gw_item_get_address (item, "Home");
contact_addr = NULL;
e_contact_set (contact, E_CONTACT_ADDRESS_HOME, contact_addr);
e_contact_address_free (contact_addr);
}
-
+
address = e_gw_item_get_address (item, "Office");
if (address) {
contact_addr = g_new0(EContactAddress, 1);
}
}
-static void
+static void
set_address_in_gw_item (EGwItem *item, gpointer data)
{
EContact *contact;
PostalAddress *address;
contact = E_CONTACT (data);
-
+
contact_address = e_contact_get (contact, E_CONTACT_ADDRESS_HOME);
if (contact_address) {
address = g_new0(PostalAddress, 1);
e_gw_item_set_address (item, "Home", address);
e_contact_address_free (contact_address);
}
-
+
contact_address = e_contact_get (contact, E_CONTACT_ADDRESS_WORK);
if (contact_address) {
address = g_new0(PostalAddress, 1);
return address_copy;
}
-static void
+static void
set_postal_address_change (EGwItem *new_item, EGwItem *old_item, char *address_type)
{
PostalAddress *old_postal_address;
char *s1, *s2;
update_postal_address = g_new0(PostalAddress, 1);
delete_postal_address = g_new0 (PostalAddress, 1);
-
+
new_postal_address = e_gw_item_get_address (new_item, address_type);
old_postal_address = e_gw_item_get_address (old_item, address_type);
if (new_postal_address && old_postal_address) {
delete_postal_address->street_address = g_strdup(s2);
else if (s1)
update_postal_address->street_address = g_strdup(s1);
-
+
s1 = new_postal_address->location;
s2 = old_postal_address->location;
if (!s1 && s2)
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_UPDATE, address_type, update_postal_address);
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_DELETE, address_type, delete_postal_address);
-
+
} else if (!new_postal_address && old_postal_address) {
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_DELETE, address_type, copy_postal_address(old_postal_address));
} else if (new_postal_address && !old_postal_address) {
}
}
-static void
+static void
set_address_changes (EGwItem *new_item , EGwItem *old_item)
{
set_postal_address_change (new_item, old_item, "Home");
set_postal_address_change (new_item, old_item, "Office");
}
-static void
+static void
populate_birth_date (EContact *contact, gpointer data)
{
EGwItem *item;
char *value ;
EContactDate *date;
-
+
item = E_GW_ITEM (data);
value = e_gw_item_get_field_value (item, "birthday");
if (value) {
}
}
-static void
+static void
set_birth_date_in_gw_item (EGwItem *item, gpointer data)
{
EContact *contact;
}
-static void
+static void
set_birth_date_changes (EGwItem *new_item, EGwItem *old_item)
{
char *new_birthday;
new_birthday = e_gw_item_get_field_value (new_item, "birthday");
old_birthday = e_gw_item_get_field_value (old_item, "birthday");
-
+
if (new_birthday && old_birthday) {
if (!g_str_equal (new_birthday, old_birthday))
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_UPDATE, "birthday", new_birthday);
};
-static void
+static void
populate_emails (EContact *contact, gpointer data)
{
GList *email_list;
email_list = e_gw_item_get_email_list(item);
for (i =0 ; i < 3 && email_list; i++, email_list = g_list_next (email_list)) {
- if (email_list->data)
+ if (email_list->data)
e_contact_set (contact, email_fields[i], email_list->data);
}
-}
+}
-static void
+static void
set_emails_in_gw_item (EGwItem *item, gpointer data)
{
GList *email_list;
email_list = g_list_append (email_list, g_strdup (email));
}
e_gw_item_set_email_list (item, email_list);
-}
+}
-static void
+static void
compare_string_lists ( GList *old_list, GList *new_list, GList **additions, GList **deletions)
{
GList *temp, *old_list_copy;
gboolean strings_matched;
char *string1, *string2;
-
+
if (old_list && new_list) {
old_list_copy = g_list_copy (old_list);
for ( ; new_list != NULL; new_list = g_list_next (new_list)) {
-
+
string1 = new_list->data;
temp = old_list;
strings_matched = FALSE;
}
*deletions = old_list_copy;
}
- else if (!new_list && old_list)
+ else if (!new_list && old_list)
*deletions = g_list_copy (old_list);
else if (new_list && !old_list)
*additions = g_list_copy (new_list);
}
-
-static void
+
+static void
set_emails_changes (EGwItem *new_item, EGwItem *old_item)
{
GList *old_email_list;
if (deleted_emails)
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_DELETE, "email", deleted_emails);
}
-
-static void
+
+static void
populate_full_name (EContact *contact, gpointer data)
{
EGwItem *item;
}
}
-static void
+static void
set_full_name_in_gw_item (EGwItem *item, gpointer data)
{
EContact *contact;
FullName *full_name;
contact = E_CONTACT (data);
-
+
name = e_contact_get (contact, E_CONTACT_FULL_NAME);
if(name) {
return full_name_copy;
}
-static void
+static void
set_full_name_changes (EGwItem *new_item, EGwItem *old_item)
{
FullName *old_full_name;
char *s1, *s2;
update_full_name = g_new0(FullName, 1);
delete_full_name = g_new0 (FullName, 1);
-
+
old_full_name = e_gw_item_get_full_name (old_item);
new_full_name = e_gw_item_get_full_name (new_item);
-
+
if (old_full_name && new_full_name) {
s1 = new_full_name->name_prefix;
s2 = old_full_name->name_prefix;
delete_full_name->middle_name = g_strdup(s2);
else if (s1)
update_full_name->middle_name = g_strdup(s1);
-
+
s1 = new_full_name->last_name;
s2 = old_full_name->last_name;
if(!s1 && s2)
update_full_name->name_suffix = g_strdup(s1);
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_UPDATE,"full_name", update_full_name);
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_DELETE,"full_name", delete_full_name);
-
+
} else if (!new_full_name && old_full_name) {
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_DELETE, "full_name", copy_full_name(old_full_name));
} else if (new_full_name && !old_full_name) {
}
}
-static void
+static void
populate_contact_members (EContact *contact, gpointer data)
{
EGwItem *item;
/* The item corresponding to this id is not found. This happens in case of
* importing, in imported file the stored id is corresponding to the address
* book from which the contact list was exported.
- */
+ */
id = NULL;
}
else
}
g_object_unref (temp_item);
}
-
- /* In groupwise there is no way to put arbitrary members into a group. There's no
- * mechanism for a group to contain members that are not already present in a system
+
+ /* In groupwise there is no way to put arbitrary members into a group. There's no
+ * mechanism for a group to contain members that are not already present in a system
* or personal addressbook as a contact, and so they cant be saved and will be lost.
- * In order to save them we first need to create groupwise based contacts for these
+ * In order to save them we first need to create groupwise based contacts for these
* arbitrary contacts and then add them as members to the group.
*/
-
+
temp = emails_without_ids ;
for (; temp != NULL; temp = g_list_next (temp)) {
EContact *new_contact = e_contact_new ();
EGwItem *new_item = e_gw_item_new_empty ();
FullName *full_name;
- e_contact_set (new_contact,E_CONTACT_FULL_NAME, e_contact_name_from_string (strdup (temp->data)));
+ e_contact_set (new_contact,E_CONTACT_FULL_NAME, e_contact_name_from_string (strdup (temp->data)));
e_contact_set (new_contact, E_CONTACT_EMAIL_1, strdup (temp->data));
e_contact_set (new_contact, E_CONTACT_IS_LIST, GINT_TO_POINTER (FALSE));
e_gw_item_set_item_type (new_item, E_GW_ITEM_TYPE_CONTACT);
full_name->last_name = NULL;
full_name->name_suffix = NULL;
e_gw_item_set_full_name (new_item, full_name);
-
+
for (i=0; i < G_N_ELEMENTS (mappings); i++) {
element_type = mappings[i].element_type;
if (element_type == ELEMENT_TYPE_SIMPLE) {
mappings[i].set_value_in_gw_item (new_item, new_contact);
}
}
-
+
}
id = NULL;
status = e_gw_connection_create_item (egwb->priv->cnc, new_item, &id);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_create_item (egwb->priv->cnc, new_item, &id);
-
+
if (status == E_GW_CONNECTION_STATUS_OK && id) {
e_contact_set (new_contact, E_CONTACT_UID, id);
e_book_backend_db_cache_add_contact (egwb->priv->file_db, new_contact);
e_gw_item_set_member_list (item, group_members);
}
-static void
+static void
set_member_changes (EGwItem *new_item, EGwItem *old_item, EBookBackendGroupwise *egwb)
{
GList *old_members, *new_members ;
member = (EGroupMember *)new_members->data;
new_ids = g_list_append (new_ids, member->id);
}
-
+
compare_string_lists (old_ids, new_ids, &additions, &deletions);
- if (additions)
+ if (additions)
e_gw_connection_add_members (egwb->priv->cnc, e_gw_item_get_id (old_item), additions);
if (deletions)
e_gw_connection_remove_members (egwb->priv->cnc, e_gw_item_get_id (old_item), deletions);
g_list_free (deletions);
}
-static void
+static void
set_organization_in_gw_item (EGwItem *item, EContact *contact, EBookBackendGroupwise *egwb)
{
char *organization_name;
int status;
char *id;
GList *items;
-
+
organization_name = e_contact_get (contact, E_CONTACT_ORG);
if (organization_name == NULL || strlen (organization_name) == 0)
return;
if (status != E_GW_CONNECTION_STATUS_OK)
return;
}
- if (id == NULL)
+ if (id == NULL)
return;
e_gw_item_set_field_value (item, "organization_id", id);
e_gw_item_set_field_value (item , "organization", organization_name);
}
}
-static void
+static void
set_categories_in_gw_item (EGwItem *item, EContact *contact, EBookBackendGroupwise *egwb)
{
GHashTable *categories_by_name;
if (!category_names->data || strlen(category_names->data) == 0 )
continue;
id = g_hash_table_lookup (categories_by_name, category_names->data);
- if (id)
+ if (id)
category_ids = g_list_append (category_ids, g_strdup (id));
else {
EGwItem *category_item;
if (status == E_GW_CONNECTION_STATUS_OK && id != NULL) {
char **components = g_strsplit (id, "@", -1);
char *temp_id = components[0];
-
+
g_hash_table_insert (categories_by_name, g_strdup (category_names->data), g_strdup(temp_id));
g_hash_table_insert (egwb->priv->categories_by_id, g_strdup(temp_id), g_strdup (category_names->data));
category_ids = g_list_append (category_ids, g_strdup(temp_id));
g_object_unref (category_item);
}
}
- e_gw_item_set_categories (item, category_ids);
+ e_gw_item_set_categories (item, category_ids);
}
-static void
+static void
set_categories_changes (EGwItem *new_item, EGwItem *old_item)
{
GList *old_category_list;
if (!categories_matched)
added_categories = g_list_append (added_categories, category1);
}
-
+
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_ADD, "categories", added_categories);
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_DELETE, "categories", old_categories_copy);
} else if (!new_category_list && old_category_list) {
}
}
-static void
+static void
fill_contact_from_gw_item (EContact *contact, EGwItem *item, GHashTable *categories_by_ids)
{
char* value;
int element_type;
int i;
gboolean is_contact_list;
-
+
is_contact_list = e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_GROUP ? TRUE: FALSE;
e_contact_set (contact, E_CONTACT_IS_LIST, GINT_TO_POINTER (is_contact_list));
if (is_contact_list)
g_list_free (category_names);
}
}
- else
+ else
mappings[i].populate_contact_func(contact, item);
}
}
case GNOME_Evolution_Addressbook_MODE_LOCAL :
e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
return;
-
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
-
+
+ case GNOME_Evolution_Addressbook_MODE_REMOTE :
+
if (egwb->priv->cnc == NULL) {
e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_AuthenticationRequired, NULL);
return;
item = e_gw_item_new_empty ();
e_gw_item_set_item_type (item, e_contact_get (contact, E_CONTACT_IS_LIST) ? E_GW_ITEM_TYPE_GROUP :E_GW_ITEM_TYPE_CONTACT);
e_gw_item_set_container_id (item, g_strdup(egwb->priv->container_id));
-
+
for (i = 0; i < G_N_ELEMENTS (mappings); i++) {
element_type = mappings[i].element_type;
if (element_type == ELEMENT_TYPE_SIMPLE) {
}
}
id = NULL;
- status = e_gw_connection_create_item (egwb->priv->cnc, item, &id);
- if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_create_item (egwb->priv->cnc, item, &id);
+ status = e_gw_connection_create_item (egwb->priv->cnc, item, &id);
+ if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+ status = e_gw_connection_create_item (egwb->priv->cnc, item, &id);
/* Make sure server has returned an id for the created contact */
if (status == E_GW_CONNECTION_STATUS_OK && id) {
egwb->priv->file_db->sync(egwb->priv->file_db, 0);
e_book_backend_summary_add_contact (egwb->priv->summary, contact);
e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_Success, contact);
-
+
}
else {
e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
printf ("\ne_book_backend_groupwise_remove_contacts...\n");
ebgw = E_BOOK_BACKEND_GROUPWISE (backend);
-
+
switch (ebgw->priv->mode) {
case GNOME_Evolution_Addressbook_MODE_LOCAL :
e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case GNOME_Evolution_Addressbook_MODE_REMOTE :
if (ebgw->priv->cnc == NULL) {
e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_AuthenticationRequired, NULL);
return;
}
-
+
if (!ebgw->priv->is_writable) {
e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_PermissionDenied, NULL);
return;
}
-
+
for ( ; id_list != NULL; id_list = g_list_next (id_list)) {
id = (char*) id_list->data;
e_gw_connection_remove_item (ebgw->priv->cnc, ebgw->priv->container_id, id);
}
}
-static void
+static void
set_changes_in_gw_item (EGwItem *new_item, EGwItem *old_item)
{
char* new_value;
g_return_if_fail (E_IS_GW_ITEM(new_item));
g_return_if_fail (E_IS_GW_ITEM(old_item));
-
+
for ( i = 0; i < G_N_ELEMENTS (mappings); i++) {
element_type = mappings[i].element_type;
if (element_type == ELEMENT_TYPE_SIMPLE) {
set_organization_changes_in_gw_item (new_item, old_item);
continue;
}
-
+
new_value = e_gw_item_get_field_value (new_item, mappings[i].element_name);
old_value = e_gw_item_get_field_value (old_item, mappings[i].element_name);
if (new_value && old_value) {
} else if (new_value && !old_value) {
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_ADD, mappings[i].element_name, new_value);
}
-
+
} else if (element_type == ELEMENT_TYPE_COMPLEX) {
if (mappings[i].field_id != E_CONTACT_EMAIL)
mappings[i].set_changes(new_item, old_item);
EDataBook *book,
guint32 opid,
const char *vcard)
-{
+{
EContact *contact;
EBookBackendGroupwise *egwb;
char *id;
int i;
if (enable_debug)
- printf ("\ne_book_backend_groupwise_modify_contact...\n");
+ printf ("\ne_book_backend_groupwise_modify_contact...\n");
egwb = E_BOOK_BACKEND_GROUPWISE (backend);
switch (egwb->priv->mode) {
e_data_book_respond_modify(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
return;
case GNOME_Evolution_Addressbook_MODE_REMOTE :
-
+
if (egwb->priv->cnc == NULL) {
e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_AuthenticationRequired, NULL);
return;
if (value && *value)
e_gw_item_set_field_value (new_item, mappings[i].element_name, value);
} else if (element_type == ELEMENT_TYPE_COMPLEX) {
- if (mappings[i].field_id == E_CONTACT_CATEGORIES)
+ if (mappings[i].field_id == E_CONTACT_CATEGORIES)
set_categories_in_gw_item (new_item, contact, egwb);
else if (mappings[i].field_id == E_CONTACT_EMAIL) {
if (e_contact_get (contact, E_CONTACT_IS_LIST))
mappings[i].set_value_in_gw_item (new_item, contact);
}
}
-
+
id = e_contact_get (contact, E_CONTACT_UID);
old_item = NULL;
status = e_gw_connection_get_item (egwb->priv->cnc, egwb->priv->container_id, id, NULL, &old_item);
-
+
if (old_item == NULL) {
e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_ContactNotFound, NULL);
return;
}
-
+
if (status != E_GW_CONNECTION_STATUS_OK) {
e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
return;
}
-
+
if (e_contact_get (contact, E_CONTACT_IS_LIST))
set_member_changes (new_item, old_item, egwb);
new_org = e_gw_item_get_field_value (new_item, "organization");
old_org = e_gw_item_get_field_value (old_item, "organization");
if (new_org && *new_org) {
-
+
if ((old_org == NULL) || (old_org && strcmp (new_org, old_org)) != 0)
set_organization_in_gw_item (new_item, contact, egwb);
}
-
+
set_changes_in_gw_item (new_item, old_item);
-
+
e_gw_item_set_item_type (new_item, e_gw_item_get_item_type (old_item));
status = e_gw_connection_modify_item (egwb->priv->cnc, id, new_item);
if (status == E_GW_CONNECTION_STATUS_OK) {
egwb->priv->file_db->sync(egwb->priv->file_db, 0);
e_book_backend_summary_add_contact (egwb->priv->summary, contact);
}
- else
+ else
e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
g_object_unref (new_item);
g_object_ref (old_item);
break;
}
}
-
+
static void
e_book_backend_groupwise_get_contact (EBookBackend *backend,
EDataBook *book,
char *vcard;
if (enable_debug)
- printf ("\ne_book_backend_groupwise_get_contact...\n");
+ printf ("\ne_book_backend_groupwise_get_contact...\n");
gwb = E_BOOK_BACKEND_GROUPWISE (backend);
}
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case GNOME_Evolution_Addressbook_MODE_REMOTE :
if (gwb->priv->cnc == NULL) {
e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
return;
return;
}
}
- e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_ContactNotFound, "");
+ e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_ContactNotFound, "");
return;
default :
break;
EGwFilter *filter;
gboolean is_filter_valid;
gboolean is_personal_book;
- int auto_completion;
+ int auto_completion;
char *search_string;
} EBookBackendGroupwiseSExpData;
gw_field_name = "emailList/email";
else if (g_str_equal (propname, "file_as") || g_str_equal (propname, "nickname"))
gw_field_name = "name";
-
+
if (gw_field_name) {
if (g_str_equal (gw_field_name, "fullName")) {
- e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_CONTAINS, "fullName/firstName", str);
+ e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_CONTAINS, "fullName/firstName", str);
e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_CONTAINS, "fullName/lastName", str);
if (sexp_data->is_personal_book) {
e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_CONTAINS, "fullName/displayName", str);
e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_OR, 3);
}
- else {
+ else {
e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_OR, 2);
}
}
- else {
+ else {
e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_CONTAINS, gw_field_name, str);
}
}
- else {
+ else {
sexp_data->is_filter_valid = FALSE;
}
}
char *propname = argv[0]->value.string;
char *str = argv[1]->value.string;
char *gw_field_name;
-
+
gw_field_name = NULL;
if (g_str_equal (propname, "full_name"))
gw_field_name = "fullName";
gw_field_name = "emailList/email";
else if (g_str_equal (propname, "file_as") || g_str_equal (propname, "nickname"))
gw_field_name = "name";
-
+
if (gw_field_name) {
if (g_str_equal (gw_field_name, "fullName")) {
- e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_EQUAL, "fullName/firstName", str);
+ e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_EQUAL, "fullName/firstName", str);
e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_EQUAL, "fullName/lastName", str);
if (sexp_data->is_personal_book) {
e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_EQUAL, "fullName/displayName", str);
e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_OR, 3);
}
- else {
+ else {
e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_OR, 2);
}
}
gw_field_name = "emailList/email";
sexp_data->auto_completion |= BEGINS_WITH_EMAIL;
}
- else if (g_str_equal (propname, "file_as")) {
+ else if (g_str_equal (propname, "file_as")) {
gw_field_name = "name";
sexp_data->auto_completion |= BEGINS_WITH_FILE_AS;
- } else if (g_str_equal (propname, "nickname")) {
+ } else if (g_str_equal (propname, "nickname")) {
gw_field_name = "name";
sexp_data->auto_completion |= BEGINS_WITH_NICK_NAME;
}
if (gw_field_name) {
-
+
if (g_str_equal (gw_field_name, "fullName")) {
- e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS, "fullName/firstName", str);
+ e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS, "fullName/firstName", str);
e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS, "fullName/lastName", str);
if (sexp_data->is_personal_book) {
e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS, "fullName/displayName", str);
e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_OR, 3);
}
- else {
+ else {
e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_OR, 2);
}
}
sexp_data = (EBookBackendGroupwiseSExpData *) data;
sexp_data->is_filter_valid = FALSE;
-
+
r = e_sexp_result_new(f, ESEXP_RES_BOOL);
-
- r->value.bool = FALSE;
+
+ r->value.bool = FALSE;
return r;
}
char *propname = argv[0]->value.string;
char *str = argv[1]->value.string;
char *gw_field_name;
-
+
gw_field_name = NULL;
if (g_str_equal (propname, "full_name"))
gw_field_name = "fullName";
gw_field_name = "name";
if (gw_field_name) {
-
+
if (g_str_equal (gw_field_name, "fullName")) {
- e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_EXISTS, "fullName/firstName", str);
+ e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_EXISTS, "fullName/firstName", str);
e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_EXISTS, "fullName/lastName", str);
if (sexp_data->is_personal_book) {
e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_EXISTS, "fullName/displayName", str);
e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_OR, 3);
}
- else {
+ else {
e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_OR, 2);
}
}
e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_EXISTS, gw_field_name, str);
}
}
- else {
+ else {
sexp_data->is_filter_valid = FALSE;
}
}
sexp = e_sexp_new();
filter = e_gw_filter_new ();
-
+
sexp_data = g_new0 (EBookBackendGroupwiseSExpData, 1);
sexp_data->filter = filter;
sexp_data->is_filter_valid = TRUE;
r = e_sexp_eval(sexp);
e_sexp_result_free(sexp, r);
e_sexp_unref (sexp);
-
+
if (sexp_data->is_filter_valid) {
if (sexp_data->auto_completion == AUTO_COMPLETION_QUERY)
*(gboolean *)is_auto_completion = TRUE;
printf ("\ne_book_backend_groupwise_get_contact_list...\n");
switch (egwb->priv->mode) {
-
+
case GNOME_Evolution_Addressbook_MODE_LOCAL :
if (!egwb->priv->file_db) {
e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
return;
}
-
- if (egwb->priv->is_summary_ready &&
+
+ if (egwb->priv->is_summary_ready &&
e_book_backend_summary_is_summary_query (egwb->priv->summary, query)) {
int i;
ids = e_book_backend_summary_search (egwb->priv->summary, query);
for (i = 0; i < ids->len; i ++) {
char *uid = g_ptr_array_index (ids, i);
- EContact *contact =
+ EContact *contact =
e_book_backend_db_cache_get_contact (egwb->priv->file_db, uid);
- contacts = g_list_append (contacts, contact);
+ contacts = g_list_append (contacts, contact);
}
g_ptr_array_free (ids, TRUE);
}
contacts = e_book_backend_db_cache_get_contacts (egwb->priv->file_db, query);
temp = contacts;
- for (; contacts != NULL; contacts = g_list_next(contacts)) {
- vcard_list = g_list_append (vcard_list,
- e_vcard_to_string (E_VCARD (contacts->data),
+ for (; contacts != NULL; contacts = g_list_next(contacts)) {
+ vcard_list = g_list_append (vcard_list,
+ e_vcard_to_string (E_VCARD (contacts->data),
EVC_FORMAT_VCARD_30));
g_object_unref (contacts->data);
}
if (temp)
g_list_free (temp);
return;
-
+
case GNOME_Evolution_Addressbook_MODE_REMOTE:
if (egwb->priv->cnc == NULL) {
e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_InvalidQuery,
vcard_list);
}
-
+
status = E_GW_CONNECTION_STATUS_OK;
if (egwb->priv->is_cache_ready ) {
- if (egwb->priv->is_summary_ready &&
+ if (egwb->priv->is_summary_ready &&
e_book_backend_summary_is_summary_query (egwb->priv->summary, query)) {
ids = e_book_backend_summary_search (egwb->priv->summary, query);
}
if (ids->len > 0) {
- status = e_gw_connection_get_items_from_ids (egwb->priv->cnc,
- egwb->priv->container_id,
- "name email default members",
+ status = e_gw_connection_get_items_from_ids (egwb->priv->cnc,
+ egwb->priv->container_id,
+ "name email default members",
ids, &gw_items);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_get_items_from_ids (egwb->priv->cnc,
- egwb->priv->container_id,
- "name email default members",
+ status = e_gw_connection_get_items_from_ids (egwb->priv->cnc,
+ egwb->priv->container_id,
+ "name email default members",
ids, &gw_items);
g_ptr_array_free (ids, TRUE);
}
match_needed = FALSE;
- } else {
+ } else {
if (strcmp (query, "(contains \"x-evolution-any-field\" \"\")") != 0)
- filter = e_book_backend_groupwise_build_gw_filter (egwb,
- query,
- &is_auto_completion,
+ filter = e_book_backend_groupwise_build_gw_filter (egwb,
+ query,
+ &is_auto_completion,
NULL);
if (filter)
match_needed = FALSE;
- status = e_gw_connection_get_items (egwb->priv->cnc,
- egwb->priv->container_id,
- "name email default members",
+ status = e_gw_connection_get_items (egwb->priv->cnc,
+ egwb->priv->container_id,
+ "name email default members",
filter, &gw_items);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_get_items (egwb->priv->cnc,
- egwb->priv->container_id,
- "name email default members",
+ status = e_gw_connection_get_items (egwb->priv->cnc,
+ egwb->priv->container_id,
+ "name email default members",
filter, &gw_items);
}
-
+
if (status != E_GW_CONNECTION_STATUS_OK) {
e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_OtherError,
NULL);
fill_contact_from_gw_item (contact, E_GW_ITEM (gw_items->data), egwb->priv->categories_by_id);
e_contact_set (contact, E_CONTACT_BOOK_URI, egwb->priv->original_uri);
if (match_needed && e_book_backend_sexp_match_contact (card_sexp, contact))
- vcard_list = g_list_append (vcard_list,
- e_vcard_to_string (E_VCARD (contact),
+ vcard_list = g_list_append (vcard_list,
+ e_vcard_to_string (E_VCARD (contact),
EVC_FORMAT_VCARD_30));
- else
- vcard_list = g_list_append (vcard_list,
- e_vcard_to_string (E_VCARD (contact),
+ else
+ vcard_list = g_list_append (vcard_list,
+ e_vcard_to_string (E_VCARD (contact),
EVC_FORMAT_VCARD_30));
g_object_unref (contact);
g_object_unref (gw_items->data);
return;
default :
break;
-
+
}
}
-
+
typedef struct {
EBookBackendGroupwise *bg;
GThread *thread;
}
static void
-get_contacts_from_cache (EBookBackendGroupwise *ebgw,
+get_contacts_from_cache (EBookBackendGroupwise *ebgw,
const char *query,
GPtrArray *ids,
- EDataBookView *book_view,
+ EDataBookView *book_view,
GroupwiseBackendSearchClosure *closure)
{
int i;
printf ("\nread contacts from cache for the ids found in summary\n");
for (i = 0; i < ids->len; i ++) {
char *uid;
- EContact *contact;
+ EContact *contact;
if (!e_flag_is_set (closure->running))
break;
}
}
if (e_flag_is_set (closure->running))
- e_data_book_view_notify_complete (book_view,
+ e_data_book_view_notify_complete (book_view,
GNOME_Evolution_Addressbook_Success);
}
-
+
static gpointer
book_view_thread (gpointer data)
{
printf ("start book view for %s \n", gwb->priv->book_name);
bonobo_object_ref (book_view);
e_flag_set (closure->running);
-
+
query = e_data_book_view_get_card_query (book_view);
if (enable_debug)
printf ("get view for query %s \n", query);
return NULL;
}
- if (gwb->priv->is_summary_ready &&
+ if (gwb->priv->is_summary_ready &&
e_book_backend_summary_is_summary_query (gwb->priv->summary, query)) {
if (enable_debug)
printf ("reading the uids from summary \n");
g_list_free (temp_list);
bonobo_object_unref (book_view);
return NULL;
-
+
case GNOME_Evolution_Addressbook_MODE_REMOTE :
-
+
if (gwb->priv->cnc == NULL) {
- e_data_book_view_notify_complete (book_view,
+ e_data_book_view_notify_complete (book_view,
GNOME_Evolution_Addressbook_AuthenticationRequired);
bonobo_object_unref (book_view);
- return NULL;
+ return NULL;
}
if (enable_debug)
filter = e_book_backend_groupwise_build_gw_filter (gwb, query, &is_auto_completion, &search_string);
view = "name email default members";
- if (is_auto_completion)
+ if (is_auto_completion)
view = "name email";
if (search_string) {
/* groupwise server supports only name, rebuild the filter */
filter = e_gw_filter_new ();
- e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS,
+ e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS,
"fullName/lastName", search_string);
- e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS,
+ e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_BEGINS,
"fullName/firstName", search_string);
e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_OR, 2);
g_free (search_string);
if (!gwb->priv->is_writable && !filter) {
e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
bonobo_object_unref (book_view);
- return NULL;
+ return NULL;
}
- else
+ else
status = E_GW_CONNECTION_STATUS_OK;
/* Check if the data is found on summary */
- if (gwb->priv->is_summary_ready &&
+ if (gwb->priv->is_summary_ready &&
e_book_backend_summary_is_summary_query (gwb->priv->summary, query)) {
if (enable_debug)
printf("reading the uids from summary file\n");
}
/*
- * Search for contact in cache, if not found, read from server
+ * Search for contact in cache, if not found, read from server
*/
if (ids && ids->len > 0) {
/* read from summary */
if (gwb->priv->is_cache_ready && !gwb->priv->is_writable) {
/* read from cache, only for system address book, as we refresh
- * only system address book, periodically.
- */
+ * only system address book, periodically.
+ */
if (enable_debug)
printf ("reading contacts from cache for the uids in summary \n");
if (!is_auto_completion)
- e_data_book_view_notify_status_message (book_view,
+ e_data_book_view_notify_status_message (book_view,
_("Searching..."));
get_contacts_from_cache (gwb, query, ids, book_view, closure);
g_ptr_array_free (ids, TRUE);
if (enable_debug)
printf ("reading contacts from server for the uids in summary \n");
if (!is_auto_completion)
- e_data_book_view_notify_status_message (book_view,
+ e_data_book_view_notify_status_message (book_view,
_("Searching..."));
- status = e_gw_connection_get_items_from_ids (gwb->priv->cnc,
- gwb->priv->container_id,
+ status = e_gw_connection_get_items_from_ids (gwb->priv->cnc,
+ gwb->priv->container_id,
view, ids, &gw_items);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_get_items_from_ids (gwb->priv->cnc,
- gwb->priv->container_id,
+ status = e_gw_connection_get_items_from_ids (gwb->priv->cnc,
+ gwb->priv->container_id,
view, ids, &gw_items);
if (enable_debug && status == E_GW_CONNECTION_STATUS_OK)
printf ("read contacts from server \n");
if (enable_debug)
printf ("summary not found, reading the contacts from server\n");
if (!is_auto_completion) {
- if (filter)
+ if (filter)
e_data_book_view_notify_status_message (book_view, _("Searching..."));
- else
+ else
e_data_book_view_notify_status_message (book_view, _("Loading..."));
}
- status = e_gw_connection_get_items (gwb->priv->cnc,
- gwb->priv->container_id,
+ status = e_gw_connection_get_items (gwb->priv->cnc,
+ gwb->priv->container_id,
view, filter, &gw_items);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_get_items (gwb->priv->cnc,
- gwb->priv->container_id,
+ status = e_gw_connection_get_items (gwb->priv->cnc,
+ gwb->priv->container_id,
view, filter, &gw_items);
}
}
temp_list = gw_items;
- for (; gw_items != NULL; gw_items = g_list_next(gw_items)) {
+ for (; gw_items != NULL; gw_items = g_list_next(gw_items)) {
if (!e_flag_is_set (closure->running)) {
for (;gw_items != NULL; gw_items = g_list_next (gw_items))
count ++;
contact = e_contact_new ();
- fill_contact_from_gw_item (contact,
- E_GW_ITEM (gw_items->data),
+ fill_contact_from_gw_item (contact,
+ E_GW_ITEM (gw_items->data),
gwb->priv->categories_by_id);
e_contact_set (contact, E_CONTACT_BOOK_URI, gwb->priv->original_uri);
- if (e_contact_get_const (contact, E_CONTACT_UID))
+ if (e_contact_get_const (contact, E_CONTACT_UID))
e_data_book_view_notify_update (book_view, contact);
- else
+ else
g_critical ("Id missing for item %s\n", (char *)e_contact_get_const (contact, E_CONTACT_FILE_AS));
g_object_unref(contact);
g_object_unref (gw_items->data);
printf ("\ne_book_backend_groupwise_start_book_view...\n");
closure->thread = g_thread_create (book_view_thread, book_view, FALSE, NULL);
e_flag_wait (closure->running);
-
+
/* at this point we know the book view thread is actually running */
}
-
+
static void
e_book_backend_groupwise_stop_book_view (EBookBackend *backend,
EDataBookView *book_view)
{
GroupwiseBackendSearchClosure *closure = get_closure (book_view);
-
+
if (enable_debug)
printf ("\ne_book_backend_groupwise_stop_book_view...\n");
e_flag_clear (closure->running);
printf ("\ne_book_backend_groupwise_get_changes...\n");
/* FIXME : provide implmentation */
-
+
}
static void
g_object_unref (iter);
g_object_unref (views);
-
+
return rv;
}
-static void
+static void
get_sequence_from_cache (DB *db,
gdouble *cache_first_sequence,
gdouble *cache_last_sequence,
*cache_first_sequence = strtod (g_strdup (vcard_dbt.data), NULL);
g_free (vcard_dbt.data);
}
-
+
string_to_dbt ("lastSequence", &uid_dbt);
memset (&vcard_dbt, 0, sizeof(vcard_dbt));
vcard_dbt.flags = DB_DBT_MALLOC;
printf("Read sequences from cache\n");
printf("firstSequence:%lf, lastSequence:%lf, lastPoRebuildTime:%lf\n", *cache_first_sequence, *cache_last_sequence, *cache_last_po_rebuild_time);
}
-
+
}
static void
-add_sequence_to_cache (DB *db,
+add_sequence_to_cache (DB *db,
gdouble first_sequence,
gdouble last_sequence,
gdouble last_po_rebuild_time)
if (db_error != 0) {
g_warning ("db->put failed with %d", db_error);
}
-
+
string_to_dbt ("lastTimePORebuild",&uid_dbt );
tmp = g_strdup_printf("%lf", last_po_rebuild_time);
string_to_dbt (tmp, &vcard_dbt);
EDataBookView *book_view;
EBookBackendGroupwisePrivate *priv = ebgw->priv;
char *status_msg;
-
+
status = e_gw_connection_get_items (ebgw->priv->cnc, ebgw->priv->container_id, "name email default members", NULL, &gw_items);
- if (status != E_GW_CONNECTION_STATUS_OK)
+ if (status != E_GW_CONNECTION_STATUS_OK)
return FALSE;
-
- for (; gw_items != NULL; gw_items = g_list_next(gw_items)) {
+
+ for (; gw_items != NULL; gw_items = g_list_next(gw_items)) {
contact_num++;
contact = e_contact_new ();
fill_contact_from_gw_item (contact, E_GW_ITEM (gw_items->data), ebgw->priv->categories_by_id);
}
g_object_unref(contact);
g_object_unref (gw_items->data);
-
+
}
-
+
e_book_backend_cache_set_populated (priv->cache);
priv->is_cache_ready=TRUE;
-
+
g_list_free (gw_items);
-
+
return NULL;
}*/
-/*FIXME using cursors for address book seems to be crashing server
+/*FIXME using cursors for address book seems to be crashing server
till it gets fixed we will use get items. cursor implementation is below */
static gpointer
printf("Building the cache for %s \n", ebgw->priv->book_name);
}
- status = e_gw_connection_create_cursor (priv->cnc, priv->container_id,
+ status = e_gw_connection_create_cursor (priv->cnc, priv->container_id,
"name email default members", NULL, &cursor);
if (status != E_GW_CONNECTION_STATUS_OK) {
if (enable_debug)
while (!done) {
- if (enable_debug)
+ if (enable_debug)
g_get_current_time(&tstart);
- status = e_gw_connection_read_cursor (priv->cnc, priv->container_id,
- cursor, TRUE, CURSOR_ITEM_LIMIT,
+ status = e_gw_connection_read_cursor (priv->cnc, priv->container_id,
+ cursor, TRUE, CURSOR_ITEM_LIMIT,
position, &gw_items);
if (enable_debug) {
g_get_current_time(&tend);
printf("e_gw_connection_read_cursor took %ld.%03ld seconds for %d contacts\n", diff / 1000, diff % 1000, CURSOR_ITEM_LIMIT);
}
- for (l = gw_items; l != NULL; l = g_list_next (l)) {
+ for (l = gw_items; l != NULL; l = g_list_next (l)) {
contact_num++;
contact = e_contact_new ();
- fill_contact_from_gw_item (contact, E_GW_ITEM (l->data),
+ fill_contact_from_gw_item (contact, E_GW_ITEM (l->data),
ebgw->priv->categories_by_id);
e_contact_set (contact, E_CONTACT_BOOK_URI, priv->original_uri);
e_book_backend_db_cache_add_contact (ebgw->priv->file_db, contact);
g_object_unref(contact);
g_object_unref (l->data);
-
+
}
if (!gw_items) {
e_book_backend_db_cache_set_populated (ebgw->priv->file_db);
priv->is_cache_ready=TRUE;
priv->is_summary_ready = TRUE;
}
-
+
g_list_free (gw_items);
gw_items = NULL;
position = E_GW_CURSOR_POSITION_CURRENT;
g_get_current_time(&end);
diff = end.tv_sec * 1000 + end.tv_usec/1000;
diff -= start.tv_sec * 1000 + start.tv_usec/1000;
- printf("completed building cache for %s in %ld.%03ld seconds for %d contacts\n",
+ printf("completed building cache for %s in %ld.%03ld seconds for %d contacts\n",
priv->book_name, diff / 1000, diff % 1000, contact_num);
}
return NULL;
if (enable_debug) {
g_get_current_time(&start);
- printf ("summary file not found or not up-to-date, building summary for %s\n",
+ printf ("summary file not found or not up-to-date, building summary for %s\n",
ebgw->priv->book_name);
}
if (temp_list)
g_list_free (temp_list);
ebgw->priv->is_summary_ready = TRUE;
-
+
if (enable_debug) {
g_get_current_time(&end);
diff = end.tv_sec * 1000 + end.tv_usec/1000;
diff -= start.tv_sec * 1000 + start.tv_usec/1000;
- printf("building summary for %s took %ld.%03ld seconds \n",
+ printf("building summary for %s took %ld.%03ld seconds \n",
ebgw->priv->book_name, diff / 1000, diff % 1000);
}
}
if (!ebgw)
return FALSE;
-
+
g_mutex_lock (ebgw->priv->update_cache_mutex);
if (enable_debug) {
tm = gmtime (&mod_time);
strftime (cache_time_string, 100, "%Y-%m-%dT%H:%M:%SZ", tm);
- if (e_book_backend_summary_load (ebgw->priv->summary) == FALSE ||
+ if (e_book_backend_summary_load (ebgw->priv->summary) == FALSE ||
e_book_backend_summary_is_up_to_date (ebgw->priv->summary, mod_time) == FALSE) {
/* build summary */
build_summary (ebgw);
}
-
+
filter = e_gw_filter_new ();
- e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_GREATERTHAN,
+ e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_GREATERTHAN,
"modified", cache_time_string);
- status = e_gw_connection_get_items (ebgw->priv->cnc, ebgw->priv->container_id,
+ status = e_gw_connection_get_items (ebgw->priv->cnc, ebgw->priv->container_id,
"name email default members", filter, &gw_items);
if (status != E_GW_CONNECTION_STATUS_OK) {
if (book_view)
g_mutex_unlock (ebgw->priv->update_cache_mutex);
return FALSE;
}
-
- for (; gw_items != NULL; gw_items = g_list_next(gw_items)) {
+
+ for (; gw_items != NULL; gw_items = g_list_next(gw_items)) {
const char *id;
contact = e_contact_new ();
- fill_contact_from_gw_item (contact, E_GW_ITEM (gw_items->data),
+ fill_contact_from_gw_item (contact, E_GW_ITEM (gw_items->data),
ebgw->priv->categories_by_id);
-
+
e_contact_set (contact, E_CONTACT_BOOK_URI, ebgw->priv->original_uri);
id = e_contact_get_const (contact, E_CONTACT_UID);
e_book_backend_db_cache_add_contact (ebgw->priv->file_db, contact);
e_book_backend_summary_add_contact (ebgw->priv->summary, contact);
}
-
+
g_object_unref(contact);
g_object_unref (gw_items->data);
}
-
+
ebgw->priv->is_cache_ready = TRUE;
ebgw->priv->is_summary_ready = TRUE;
-
+
ebgw->priv->file_db->sync(ebgw->priv->file_db, 0);
if (book_view) {
g_get_current_time(&end);
diff = end.tv_sec * 1000 + end.tv_usec/1000;
diff -= start.tv_sec * 1000 + start.tv_usec/1000;
- printf("updating the cache for %s complated in %ld.%03ld seconds for %d contacts\n",
+ printf("updating the cache for %s complated in %ld.%03ld seconds for %d contacts\n",
ebgw->priv->book_name, diff / 1000, diff % 1000, contact_num);
}
g_mutex_unlock (ebgw->priv->update_cache_mutex);
priv = ebgw->priv;
g_mutex_lock (priv->update_mutex);
-
+
if (enable_debug)
printf("\nupdating GroupWise system address book cache \n");
-
- /* builds or updates the cache for system address book */
+
+ /* builds or updates the cache for system address book */
status = e_gw_connection_get_items_delta_info (priv->cnc,
- ebgw->priv->container_id,
+ ebgw->priv->container_id,
&server_first_sequence,
- &server_last_sequence,
+ &server_last_sequence,
&server_last_po_rebuild_time);
if (status != E_GW_CONNECTION_STATUS_OK) {
if (enable_debug)
if (enable_debug)
printf ("sequence is reset, rebuilding cache...\n");
build_cache (ebgw);
- add_sequence_to_cache (priv->file_db, server_first_sequence,
+ add_sequence_to_cache (priv->file_db, server_first_sequence,
server_last_sequence, server_last_po_rebuild_time);
ebgw->priv->file_db->sync (ebgw->priv->file_db, 0);
g_mutex_unlock (priv->update_mutex);
get_sequence_from_cache(priv->file_db, &cache_first_sequence, &cache_last_sequence, &cache_last_po_rebuild_time);
/* check whether the all the sequences are available and also whether the PO is rebuilt */
- if (server_first_sequence > cache_last_sequence || cache_last_sequence == -1 ||
+ if (server_first_sequence > cache_last_sequence || cache_last_sequence == -1 ||
server_last_po_rebuild_time != cache_last_po_rebuild_time) {
/* build the cache again and update the cache with the sequence information */
if (enable_debug)
printf ("either the sequences missing or PO is rebuilt...rebuilding the cache\n");
build_cache (ebgw);
- add_sequence_to_cache (priv->file_db, server_first_sequence,
+ add_sequence_to_cache (priv->file_db, server_first_sequence,
server_last_sequence, server_last_po_rebuild_time);
ebgw->priv->file_db->sync (ebgw->priv->file_db, 0);
g_mutex_unlock (priv->update_mutex);
g_stat (cache_file_name, &buf);
g_free (cache_file_name);
mod_time = buf.st_mtime;
- if (e_book_backend_summary_load (ebgw->priv->summary) == FALSE ||
+ if (e_book_backend_summary_load (ebgw->priv->summary) == FALSE ||
e_book_backend_summary_is_up_to_date (ebgw->priv->summary, mod_time) == FALSE) {
/* build summary */
build_summary (ebgw);
printf("cache_last_sequence:%lf, server_last_sequence:%lf\n", cache_last_sequence, server_last_sequence);
printf("Calling get_items_delta\n");
}
- e_gw_connection_get_items_delta (priv->cnc,
- ebgw->priv->container_id,
- "name email sync", count,
- sequence,
+ e_gw_connection_get_items_delta (priv->cnc,
+ ebgw->priv->container_id,
+ "name email sync", count,
+ sequence,
&add_list, &delete_list);
if (add_list == NULL && delete_list == NULL) {
if (enable_debug)
printf("sequence differs but no changes found !!!\n");
- add_sequence_to_cache (priv->file_db, server_first_sequence,
+ add_sequence_to_cache (priv->file_db, server_first_sequence,
server_last_sequence, server_last_po_rebuild_time);
g_mutex_unlock (priv->update_mutex);
g_free (sequence);
printf("delete_list size:%d\n", g_list_length(delete_list));
}
- for (; delete_list != NULL; delete_list = g_list_next(delete_list)) {
+ for (; delete_list != NULL; delete_list = g_list_next(delete_list)) {
const char *id;
/* deleted from the server */
contact = e_contact_new ();
- fill_contact_from_gw_item (contact,
- E_GW_ITEM (delete_list->data),
+ fill_contact_from_gw_item (contact,
+ E_GW_ITEM (delete_list->data),
ebgw->priv->categories_by_id);
if (enable_debug)
printf("contact email:%s, contact name:%s\n", (char *) e_contact_get(contact, E_CONTACT_EMAIL_1), (char *) e_contact_get(contact, E_CONTACT_GIVEN_NAME));
- e_contact_set (contact,
- E_CONTACT_BOOK_URI,
+ e_contact_set (contact,
+ E_CONTACT_BOOK_URI,
priv->original_uri);
id = e_contact_get_const (contact, E_CONTACT_UID);
g_object_unref (delete_list->data);
}
- for (; add_list != NULL; add_list = g_list_next(add_list)) {
+ for (; add_list != NULL; add_list = g_list_next(add_list)) {
const char *id;
/* newly added to server */
contact = e_contact_new ();
- fill_contact_from_gw_item (contact,
- E_GW_ITEM (add_list->data),
+ fill_contact_from_gw_item (contact,
+ E_GW_ITEM (add_list->data),
ebgw->priv->categories_by_id);
/* When a distribution list is modified the server sends me a delete and add response.
if (e_contact_get (contact, E_CONTACT_IS_LIST)) {
if(enable_debug)
printf ("Contact List modified fetching the members of the contact list\n");
-
+
status = e_gw_connection_get_item (ebgw->priv->cnc, ebgw->priv->container_id, e_contact_get (contact, E_CONTACT_UID), "name email default members", &item);
g_object_unref (contact);
contact = e_contact_new ();
if (enable_debug)
printf("contact email:%s, contact name:%s\n", (char *)e_contact_get(contact, E_CONTACT_EMAIL_1),(char *) e_contact_get(contact, E_CONTACT_GIVEN_NAME));
- e_contact_set (contact,
- E_CONTACT_BOOK_URI,
+ e_contact_set (contact,
+ E_CONTACT_BOOK_URI,
priv->original_uri);
id = e_contact_get_const (contact, E_CONTACT_UID);
/* cache is updated, now adding the sequence information to the cache */
- add_sequence_to_cache (priv->file_db, server_first_sequence,
+ add_sequence_to_cache (priv->file_db, server_first_sequence,
server_last_sequence, server_last_po_rebuild_time);
g_list_free (add_list);
g_list_free (delete_list);
}
-
+
g_free (sequence);
g_free (count);
ebgw->priv->is_cache_ready = TRUE;
g_get_current_time(&end);
diff = end.tv_sec * 1000 + end.tv_usec/1000;
diff -= start.tv_sec * 1000 + start.tv_usec/1000;
- printf("updating GroupWise system address book cache took %ld.%03ld seconds for %d changes\n",
+ printf("updating GroupWise system address book cache took %ld.%03ld seconds for %d changes\n",
diff / 1000, diff % 1000, contact_num);
}
g_mutex_unlock(priv->update_mutex);
printf("book_name:%s\n", priv->book_name);
}
-
+
switch (ebgw->priv->mode) {
case GNOME_Evolution_Addressbook_MODE_LOCAL:
/* load summary file for offline use */
g_mkdir_with_parents (g_path_get_dirname (priv->summary_file_name), 0700);
- priv->summary = e_book_backend_summary_new (priv->summary_file_name,
+ priv->summary = e_book_backend_summary_new (priv->summary_file_name,
SUMMARY_FLUSH_TIMEOUT);
e_book_backend_summary_load (priv->summary);
e_book_backend_notify_writable (backend, FALSE);
- e_book_backend_notify_connection_status (backend, FALSE);
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_book_backend_notify_connection_status (backend, FALSE);
+ e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
return;
-
+
case GNOME_Evolution_Addressbook_MODE_REMOTE:
-
+
if (priv->cnc) { /*we have already authenticated to server */
printf("already authenticated\n");
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
return;
}
-
+
priv->cnc = e_gw_connection_new (priv->uri, user, passwd);
if (!E_IS_GW_CONNECTION(priv->cnc) && priv->use_ssl && g_str_equal (priv->use_ssl, "when-possible")) {
http_uri = g_strconcat ("http://", priv->uri + 8, NULL);
e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_AuthenticationFailed);
return;
}
-
+
id = NULL;
is_writable = FALSE;
- status = e_gw_connection_get_address_book_id (priv->cnc, priv->book_name, &id, &is_writable);
+ status = e_gw_connection_get_address_book_id (priv->cnc, priv->book_name, &id, &is_writable);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_get_address_book_id (priv->cnc, priv->book_name, &id, &is_writable);
+ status = e_gw_connection_get_address_book_id (priv->cnc, priv->book_name, &id, &is_writable);
if (status == E_GW_CONNECTION_STATUS_OK) {
if ( (id == NULL) && !priv->only_if_exists ) {
status = e_gw_connection_create_book (priv->cnc, priv->book_name, &id);
g_free(id);
e_book_backend_set_is_writable (backend, is_writable);
e_book_backend_notify_writable (backend, is_writable);
- e_book_backend_notify_connection_status (backend, TRUE);
+ e_book_backend_notify_connection_status (backend, TRUE);
priv->is_writable = is_writable;
e_gw_connection_get_categories (priv->cnc, &priv->categories_by_id, &priv->categories_by_name);
- if (!e_gw_connection_get_version(priv->cnc))
+ if (!e_gw_connection_get_version(priv->cnc))
e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_InvalidServerVersion);
else
- e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
+ e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
} else {
e_book_backend_set_is_loaded (backend, FALSE);
e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_NoSuchBook);
tmpfile = g_path_get_dirname (priv->summary_file_name);
g_mkdir_with_parents (tmpfile, 0700);
g_free (tmpfile);
- priv->summary = e_book_backend_summary_new (priv->summary_file_name,
+ priv->summary = e_book_backend_summary_new (priv->summary_file_name,
SUMMARY_FLUSH_TIMEOUT);
if (!ebgw->priv->file_db) {
t = g_thread_create ((GThreadFunc) update_address_book_deltas, ebgw, TRUE, NULL);
- /* spawn a thread to update the system address book cache
+ /* spawn a thread to update the system address book cache
* at given intervals
*/
cache_refresh_interval_set = g_getenv ("BOOK_CACHE_REFRESH_INTERVAL");
if (cache_refresh_interval_set) {
- cache_refresh_interval = g_ascii_strtod (cache_refresh_interval_set,
+ cache_refresh_interval = g_ascii_strtod (cache_refresh_interval_set,
NULL); /* use this */
cache_refresh_interval *= (60*1000);
}
g_thread_join (t);
if (enable_debug)
printf ("creating cache refresh thread for GW system book \n");
- priv->cache_timeout = g_timeout_add (cache_refresh_interval,
+ priv->cache_timeout = g_timeout_add (cache_refresh_interval,
(GSourceFunc) update_address_book_cache,
- (gpointer)ebgw);
+ (gpointer)ebgw);
}
}
else if (priv->is_writable) { /* for personal books we always cache */
}
g_thread_create ((GThreadFunc) build_cache, ebgw, FALSE, NULL);
}
- else if(priv->marked_for_offline) {
+ else if(priv->marked_for_offline) {
GThread *t;
if (enable_debug)
printf("else if marked_for_offline\n");
/* set the cache refresh time */
if (enable_debug)
printf ("creating cache refresh thread for GW system book \n");
- priv->cache_timeout = g_timeout_add (cache_refresh_interval,
+ priv->cache_timeout = g_timeout_add (cache_refresh_interval,
(GSourceFunc) update_address_book_cache,
- (gpointer)ebgw);
+ (gpointer)ebgw);
}
return;
default :
if (enable_debug)
printf ("\ne_book_backend_groupwise_get_required_fields...\n");
-
+
fields = g_list_append (fields, (char *)e_contact_field_name (E_CONTACT_FILE_AS));
e_data_book_respond_get_supported_fields (book, opid,
GNOME_Evolution_Addressbook_Success,
fields);
g_list_free (fields);
-
+
}
static void
if (enable_debug)
printf ("\ne_book_backend_groupwise_get_supported_fields...\n");
-
+
for (i = 0; i < G_N_ELEMENTS (mappings) ; i ++)
fields = g_list_append (fields, g_strdup (e_contact_field_name (mappings[i].field_id)));
fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_EMAIL_2)));
offline = e_source_get_property (source, "offline_sync");
if (offline && g_str_equal (offline, "1"))
priv->marked_for_offline = TRUE;
-
+
if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL && !priv->marked_for_offline ) {
return GNOME_Evolution_Addressbook_OfflineUnavailable;
}
-
+
uri = e_source_get_uri (source);
priv->original_uri = g_strdup (uri);
if(uri == NULL)
tokens = g_strsplit (uri, ";", 2);
g_free (uri);
- if (tokens[0])
+ if (tokens[0])
uri = g_strdup(tokens[0]);
book_name = g_strdup (tokens[1]);
if(book_name == NULL)
if (port == NULL)
port = "7191";
use_ssl = e_source_get_property (source, "use_ssl");
- if (use_ssl && !g_str_equal (use_ssl, "never"))
+ if (use_ssl && !g_str_equal (use_ssl, "never"))
priv->uri = g_strconcat ("https://", parsed_uri->host,":", port, "/soap", NULL );
- else
+ else
priv->uri = g_strconcat ("http://", parsed_uri->host,":", port, "/soap", NULL );
priv->use_ssl = g_strdup (use_ssl);
priv->only_if_exists = only_if_exists;
-
+
priv->book_name = book_name;
e_book_backend_set_is_loaded (E_BOOK_BACKEND (backend), TRUE);
- e_book_backend_set_is_writable (E_BOOK_BACKEND(backend), FALSE);
+ e_book_backend_set_is_writable (E_BOOK_BACKEND(backend), FALSE);
if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
e_book_backend_notify_writable (backend, FALSE);
- e_book_backend_notify_connection_status (backend, FALSE);
+ e_book_backend_notify_connection_status (backend, FALSE);
}
else {
e_book_backend_notify_connection_status (backend, TRUE);
}
-
+
for (i = 0; i < strlen (uri); i++) {
switch (uri[i]) {
case ':' :
}
}
- if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL)
+ if (priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL)
if (!e_book_backend_db_cache_exists (priv->original_uri)) {
g_free (uri);
e_uri_free (parsed_uri);
g_free (filename);
return GNOME_Evolution_Addressbook_OtherError;
}
-
+
g_static_mutex_lock(&global_env_lock);
if (global_env.ref_count > 0) {
env = global_env.env;
global_env.ref_count++;
- }
+ }
else {
db_error = db_env_create (&env, 0);
if (db_error != 0) {
g_free(dirname);
return GNOME_Evolution_Addressbook_OtherError;
}
-
+
db_error = db->open (db, NULL, filename, NULL, DB_HASH, DB_THREAD, 0666);
}
if (db_error != 0) {
int rv;
- /* the databade didn't exist, so we create the
+ /* the databade didn't exist, so we create the
directory then the .db */
rv = g_mkdir_with_parents (dirname, 0777);
if (rv == -1 && errno != EEXIST) {
g_free(dirname);
return GNOME_Evolution_Addressbook_OtherError;
}
-
+
e_book_backend_db_cache_set_filename (ebgw->priv->file_db, filename);
g_free(filename);
g_free(dirname);
e_uri_free (parsed_uri);
/*if (enable_debug) {
- printf ("summary file name = %s\ncache file name = %s \n",
+ printf ("summary file name = %s\ncache file name = %s \n",
priv->summary_file_name, e_file_cache_get_filename (E_FILE_CACHE(priv->cache)));
}*/
{
EBookBackendGroupwise *ebgw;
int status;
-
+
if (enable_debug)
printf ("\ne_book_backend_groupwise_remove...\n");
ebgw = E_BOOK_BACKEND_GROUPWISE (backend);
return;
}
status = e_gw_connection_remove_item (ebgw->priv->cnc, NULL, ebgw->priv->container_id);
- if (status == E_GW_CONNECTION_STATUS_OK)
+ if (status == E_GW_CONNECTION_STATUS_OK)
e_data_book_respond_remove (book, opid, GNOME_Evolution_Addressbook_Success);
else
e_data_book_respond_remove (book, opid, GNOME_Evolution_Addressbook_OtherError);
if (enable_debug)
printf ("\ne_book_backend_groupwise_get_static_capabilities...\n");
-
+
ebgw = E_BOOK_BACKEND_GROUPWISE (backend);
/* do-initialy-query is enabled for system address book also, so that we get the
- * book_view, which is needed for displaying cache update progress.
- * and null query is handled for system address book.
+ * book_view, which is needed for displaying cache update progress.
+ * and null query is handled for system address book.
*/
return g_strdup ("net,bulk-removes,do-initial-query,contact-lists");
}
-static void
+static void
e_book_backend_groupwise_get_supported_auth_methods (EBookBackend *backend, EDataBook *book, guint32 opid)
{
GList *auth_methods = NULL;
char *auth_method;
-
+
if (enable_debug)
printf ("\ne_book_backend_groupwise_get_supported_auth_methods...\n");
auth_method = g_strdup_printf ("plain/password");
e_data_book_respond_get_supported_auth_methods (book,
opid,
GNOME_Evolution_Addressbook_Success,
- auth_methods);
+ auth_methods);
g_free (auth_method);
g_list_free (auth_methods);
}
-static void
+static void
e_book_backend_groupwise_set_mode (EBookBackend *backend, int mode)
{
EBookBackendGroupwise *bg;
-
+
if (enable_debug)
printf ("\ne_book_backend_groupwise_set_mode...\n");
bg = E_BOOK_BACKEND_GROUPWISE (backend);
else if (mode == GNOME_Evolution_Addressbook_MODE_REMOTE) {
if (bg->priv->is_writable)
e_book_backend_notify_writable (backend, TRUE);
- else
+ else
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_notify_connection_status (backend, TRUE);
e_book_backend_notify_auth_required (backend);
if (enable_debug)
printf ("\ne_book_backend_groupwise_new...\n");
-
+
backend = g_object_new (E_TYPE_BOOK_BACKEND_GROUPWISE, NULL);
-
+
return E_BOOK_BACKEND (backend);
}
if (enable_debug)
printf ("\ne_book_backend_groupwise_dispose...\n");
-
+
bgw = E_BOOK_BACKEND_GROUPWISE (object);
-
+
if (bgw->priv) {
if (bgw->priv->file_db)
bgw->priv->file_db->close (bgw->priv->file_db, 0);
g_mutex_free (bgw->priv->update_mutex);
if (bgw->priv->update_cache_mutex)
g_mutex_free (bgw->priv->update_cache_mutex);
-
+
g_free (bgw->priv);
bgw->priv = NULL;
}
-
+
G_OBJECT_CLASS (e_book_backend_groupwise_parent_class)->dispose (object);
}
-
+
static void
e_book_backend_groupwise_class_init (EBookBackendGroupwiseClass *klass)
{
-
+
GObjectClass *object_class = G_OBJECT_CLASS (klass);
EBookBackendClass *parent_class;
e_book_backend_groupwise_init (EBookBackendGroupwise *backend)
{
EBookBackendGroupwisePrivate *priv;
-
+
priv= g_new0 (EBookBackendGroupwisePrivate, 1);
priv->is_writable = TRUE;
priv->is_cache_ready = FALSE;
priv->update_cache_mutex = g_mutex_new();
backend->priv = priv;
- if (g_getenv ("GROUPWISE_DEBUG")) {
+ if (g_getenv ("GROUPWISE_DEBUG")) {
if (atoi (g_getenv ("GROUPWISE_DEBUG")) == 2)
enable_debug = TRUE;
else
*
* Authors: Sivaiah Nallagatla <snallagatla@novell.com>
*/
-
+
#ifndef __E_BOOK_BACKEND_GROUPWISE_H__
#define __E_BOOK_BACKEND_GROUPWISE_H__
-
+
#include <libedata-book/e-book-backend-sync.h>
#include "db.h"
-
+
#define E_TYPE_BOOK_BACKEND_GROUPWISE (e_book_backend_groupwise_get_type ())
#define E_BOOK_BACKEND_GROUPWISE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK_BACKEND_GROUPWISE, EBookBackendGroupwise))
#define E_BOOK_BACKEND_GROUPWISE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_BOOK_BACKEND_GROUPWISE, EBookBackendGroupwiseClass))
#define E_IS_BOOK_BACKEND_GROUPWISE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK_BACKEND_GROUPWISE))
#define E_IS_BOOK_BACKEND_GROUPWISE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_BOOK_BACKEND_GROUPWISE))
-#define E_BOOK_BACKEND_GROUPWISE_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK_BACKEND_GROUPWISE, EBookBackenGroupwiseClass))
+#define E_BOOK_BACKEND_GROUPWISE_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK_BACKEND_GROUPWISE, EBookBackenGroupwiseClass))
typedef struct _EBookBackendGroupwisePrivate EBookBackendGroupwisePrivate;
-
+
typedef struct {
EBookBackend parent_object;
EBookBackendGroupwisePrivate *priv;
} EBookBackendGroupwise;
-
+
typedef struct {
EBookBackendClass parent_class;
} EBookBackendGroupwiseClass;
EBookBackend *e_book_backend_groupwise_new (void);
GType e_book_backend_groupwise_get_type (void);
-
+
#endif /* ! __E_BOOK_BACKEND_GROUPWISE_H__ */
-
+
#define DEBUG
#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
} EBookBackendLDAPUseTLS;
/* interval for our poll_ldap timeout */
-#define LDAP_POLL_INTERVAL 20
+#define LDAP_POLL_INTERVAL 20
/* timeout for ldap_result */
#define LDAP_RESULT_TIMEOUT_MILLIS 10
gboolean calEntrySupported;
gboolean evolutionPersonChecked;
gboolean marked_for_offline;
-
+
int mode;
/* our operations */
GStaticRecMutex op_hash_mutex;
COMPLEX_PROP (E_CONTACT_PHONE_HOME, "homePhone", homephone_populate, homephone_ber, homephone_compare),
STRING_PROP (E_CONTACT_PHONE_MOBILE, "mobile"),
E_STRING_PROP (E_CONTACT_PHONE_CAR, "carPhone"),
- STRING_PROP (E_CONTACT_PHONE_BUSINESS_FAX, "facsimileTelephoneNumber"),
- E_STRING_PROP (E_CONTACT_PHONE_HOME_FAX, "homeFacsimileTelephoneNumber"),
- E_STRING_PROP (E_CONTACT_PHONE_OTHER, "otherPhone"),
- E_STRING_PROP (E_CONTACT_PHONE_OTHER_FAX, "otherFacsimileTelephoneNumber"),
- STRING_PROP (E_CONTACT_PHONE_ISDN, "internationaliSDNNumber"),
+ STRING_PROP (E_CONTACT_PHONE_BUSINESS_FAX, "facsimileTelephoneNumber"),
+ E_STRING_PROP (E_CONTACT_PHONE_HOME_FAX, "homeFacsimileTelephoneNumber"),
+ E_STRING_PROP (E_CONTACT_PHONE_OTHER, "otherPhone"),
+ E_STRING_PROP (E_CONTACT_PHONE_OTHER_FAX, "otherFacsimileTelephoneNumber"),
+ STRING_PROP (E_CONTACT_PHONE_ISDN, "internationaliSDNNumber"),
STRING_PROP (E_CONTACT_PHONE_PAGER, "pager"),
E_STRING_PROP (E_CONTACT_PHONE_RADIO, "radio"),
E_STRING_PROP (E_CONTACT_PHONE_TELEX, "telex"),
STRING_PROP (E_CONTACT_ORG_UNIT, "ou"),
STRING_PROP (E_CONTACT_OFFICE, "roomNumber"),
STRING_PROP (E_CONTACT_TITLE, "title"),
- E_STRING_PROP (E_CONTACT_ROLE, "businessRole"),
- E_STRING_PROP (E_CONTACT_MANAGER, "managerName"),
- E_STRING_PROP (E_CONTACT_ASSISTANT, "assistantName"),
+ E_STRING_PROP (E_CONTACT_ROLE, "businessRole"),
+ E_STRING_PROP (E_CONTACT_MANAGER, "managerName"),
+ E_STRING_PROP (E_CONTACT_ASSISTANT, "assistantName"),
/* addresses */
COMPLEX_PROP (E_CONTACT_ADDRESS_LABEL_WORK, "postalAddress", work_address_populate, work_address_ber, work_address_compare),
STRING_PROP (E_CONTACT_HOMEPAGE_URL, "labeledURI"),
/* map nickname to displayName */
STRING_PROP (E_CONTACT_NICKNAME, "displayName"),
- E_STRING_PROP (E_CONTACT_SPOUSE, "spouseName"),
- E_STRING_PROP (E_CONTACT_NOTE, "note"),
- E_COMPLEX_PROP (E_CONTACT_ANNIVERSARY, "anniversary", anniversary_populate, anniversary_ber, anniversary_compare),
- E_COMPLEX_PROP (E_CONTACT_BIRTH_DATE, "birthDate", birthday_populate, birthday_ber, birthday_compare),
- E_STRING_PROP (E_CONTACT_MAILER, "mailer"),
+ E_STRING_PROP (E_CONTACT_SPOUSE, "spouseName"),
+ E_STRING_PROP (E_CONTACT_NOTE, "note"),
+ E_COMPLEX_PROP (E_CONTACT_ANNIVERSARY, "anniversary", anniversary_populate, anniversary_ber, anniversary_compare),
+ E_COMPLEX_PROP (E_CONTACT_BIRTH_DATE, "birthDate", birthday_populate, birthday_ber, birthday_compare),
+ E_STRING_PROP (E_CONTACT_MAILER, "mailer"),
E_STRING_PROP (E_CONTACT_FILE_AS, "fileAs"),
CORBA_exception_init(&ev);
GNOME_Evolution_Addressbook_Book_unref(corba_book, &ev);
-
+
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning("view_destroy: Exception unreffing "
"corba book.\n");
else if (!strcmp (query_prop, e_contact_field_name (E_CONTACT_CATEGORY_LIST) )) {
bl->priv->supported_fields = g_list_append (bl->priv->supported_fields, g_strdup (e_contact_field_name (E_CONTACT_CATEGORIES)));
}
-
+
}
}
}
if (blpriv->ldap) {
ldap_unbind (blpriv->ldap);
}
-
+
#ifdef SUNLDAP
if (bl->priv->use_tls != E_BOOK_BACKEND_LDAP_TLS_NO) {
- char *evolution_dir_path =
+ char *evolution_dir_path =
g_build_path ("/", g_get_home_dir (), ".evolution", NULL);
ldap_flag = ldapssl_client_init (evolution_dir_path, NULL);
g_free (evolution_dir_path);
}
#endif
-
+
blpriv->ldap = ldap_init (blpriv->ldap_host, blpriv->ldap_port);
#if defined (DEBUG) && defined (LDAP_OPT_DEBUG_LEVEL)
ldap_error = ldapssl_install_routines (blpriv->ldap);
} else
ldap_error = LDAP_NOT_SUPPORTED;
-
+
if (LDAP_SUCCESS == ldap_error) {
ldap_error = ldap_set_option (blpriv->ldap, LDAP_OPT_SSL, LDAP_OPT_ON );
ldap_set_option(blpriv->ldap, LDAP_OPT_RECONNECT, LDAP_OPT_ON );
ldap_error = ldapssl_install_routines (blpriv->ldap);
} else
ldap_error = LDAP_NOT_SUPPORTED;
-
+
if (LDAP_SUCCESS == ldap_error) {
ldap_error = ldap_set_option (blpriv->ldap, LDAP_OPT_SSL, LDAP_OPT_ON );
ldap_set_option(blpriv->ldap, LDAP_OPT_RECONNECT, LDAP_OPT_ON );
/* server doesn't support v3 binds, so let's
drop it down to v2 and try again. */
bl->priv->ldap_v3 = FALSE;
-
+
protocol_version = LDAP_VERSION2;
ldap_set_option (blpriv->ldap, LDAP_OPT_PROTOCOL_VERSION, &protocol_version);
LDAP_NO_SUCH_OBJECT, and GWIA's LDAP server (which
is v2 based and doesn't have a root dse) seems to
fail with LDAP_PARTIAL_RESULTS. */
- if (ldap_error == LDAP_SUCCESS
+ if (ldap_error == LDAP_SUCCESS
|| ldap_error == LDAP_PARTIAL_RESULTS
|| LDAP_NAME_ERROR (ldap_error)) {
blpriv->connected = TRUE;
static void
ldap_op_add (LDAPOp *op, EBookBackend *backend,
EDataBook *book, EDataBookView *view,
- int opid,
+ int opid,
int msgid,
LDAPOpHandler handler, LDAPOpDtor dtor)
{
if (bl->priv->ldap)
ldap_abandon (bl->priv->ldap, op->id);
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
-
+
if (op->dtor)
op->dtor (op);
else if (ldap_error == LDAP_ALREADY_EXISTS)
return GNOME_Evolution_Addressbook_ContactIdAlreadyExists;
else if(ldap_error == LDAP_TYPE_OR_VALUE_EXISTS )
- return GNOME_Evolution_Addressbook_ContactIdAlreadyExists;
+ return GNOME_Evolution_Addressbook_ContactIdAlreadyExists;
else
return GNOME_Evolution_Addressbook_OtherError;
}
else
mod->mod_op = LDAP_MOD_REPLACE;
}
-
+
mod->mod_type = g_strdup (prop_info[i].ldap_attr);
if (prop_info[i].prop_type & PROP_TYPE_STRING) {
LDAPMod **ldap_mods;
LDAP *ldap;
-
+
switch (bl->priv->mode) {
case GNOME_Evolution_Addressbook_MODE_LOCAL :
e_data_book_respond_create(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case GNOME_Evolution_Addressbook_MODE_REMOTE :
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
book_view = find_book_view (bl);
printf ("Create Contact: vcard = %s\n", vcard);
-
+
create_op->new_contact = e_contact_new_from_vcard (vcard);
-
+
create_op->dn = create_dn_from_contact (create_op->new_contact, bl->priv->ldap_rootdn);
e_contact_set (create_op->new_contact, E_CONTACT_UID, create_op->dn);
-
+
/* build our mods */
mod_array = build_mods_from_contacts (bl, NULL, create_op->new_contact, NULL);
-
+
#if 0
if (!mod_array) {
/* there's an illegal field in there. report
e_data_book_respond_create (book,
GNOME_Evolution_Addressbook_BookListener_UnsupportedField,
NULL);
-
+
g_free (create_op->dn);
g_object_unref (create_op->new_contact);
g_free (create_op);
return;
}
#endif
-
+
/* remove the NULL at the end */
g_ptr_array_remove (mod_array, NULL);
-
+
/* add our objectclass(es) */
if (e_contact_get (create_op->new_contact, E_CONTACT_IS_LIST))
add_objectclass_mod (bl, mod_array, NULL, TRUE);
else
add_objectclass_mod (bl, mod_array, NULL, FALSE);
-
+
/* then put the NULL back */
g_ptr_array_add (mod_array, NULL);
-
+
#ifdef LDAP_DEBUG_ADD
{
int i;
printf ("Sending the following to the server as ADD\n");
-
+
for (i = 0; g_ptr_array_index(mod_array, i); i ++) {
LDAPMod *mod = g_ptr_array_index(mod_array, i);
if (mod->mod_op & LDAP_MOD_DELETE)
printf ("ber ");
else
printf (" ");
-
+
printf (" %s:\n", mod->mod_type);
-
+
if (mod->mod_op & LDAP_MOD_BVALUES) {
int j;
for (j = 0; mod->mod_bvalues[j] && mod->mod_bvalues[j]->bv_val; j++)
}
else {
int j;
-
+
for (j = 0; mod->mod_values[j]; j++)
printf ("\t\t'%s'\n", mod->mod_values[j]);
}
}
}
#endif
-
+
ldap_mods = (LDAPMod**)mod_array->pdata;
ldap = bl->priv->ldap;
-
+
do {
book_view_notify_status (book_view, _("Adding contact to LDAP server..."));
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
+ g_static_rec_mutex_lock (&eds_ldap_handler_lock);
err = ldap_add_ext (ldap, create_op->dn, ldap_mods,
NULL, NULL, &create_contact_msgid);
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
-
+
} while (e_book_backend_ldap_reconnect (bl, book_view, err));
-
+
/* and clean up */
free_mods (mod_array);
-
+
if (LDAP_SUCCESS != err) {
response = ldap_error_to_response (err);
e_data_book_respond_create (create_op->op.book,
}
}
}
-
+
typedef struct {
LDAPOp op;
e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
g_free (remove_op);
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case GNOME_Evolution_Addressbook_MODE_REMOTE :
if (!bl->priv->ldap) {
e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
g_free (remove_op);
** the id we're deleting is the first and only id in the list.
*/
remove_op->id = g_strdup (ids->data);
-
+
do {
book_view_notify_status (book_view, _("Removing contact from LDAP server..."));
-
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
+
+ g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap_error = ldap_delete_ext (bl->priv->ldap,
remove_op->id,
NULL, NULL, &remove_msgid);
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
} while (e_book_backend_ldap_reconnect (bl, book_view, ldap_error));
-
+
if (ldap_error != LDAP_SUCCESS) {
e_data_book_respond_remove_contacts (remove_op->op.book,
opid,
}
break;
}
-
+
}
-
+
/*
** MODIFY
**
{
int i;
printf ("Sending the following to the server as MOD\n");
-
+
for (i = 0; g_ptr_array_index(mod_array, i); i ++) {
LDAPMod *mod = g_ptr_array_index(mod_array, i);
if (mod->mod_op & LDAP_MOD_DELETE)
printf ("ber ");
else
printf (" ");
-
+
printf (" %s:\n", mod->mod_type);
-
+
if (mod->mod_op & LDAP_MOD_BVALUES) {
int j;
for (j = 0; mod->mod_bvalues[j] && mod->mod_bvalues[j]->bv_val; j++)
return;
}
}
-
+
/* and clean up */
free_mods (mod_array);
}
}
ldap_memfree (ldap_error_msg);
- e_data_book_respond_get_contact (op->book,
+ e_data_book_respond_get_contact (op->book,
op->opid,
ldap_error_to_response (ldap_error),
"");
e_data_book_respond_get_contact(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, "");
return;
- case GNOME_Evolution_Addressbook_MODE_REMOTE :
+ case GNOME_Evolution_Addressbook_MODE_REMOTE :
if (enable_debug) {
printf("e_book_backend_ldap_get_contact ... \n");
get_contact_op = g_new0 (LDAPGetContactOp, 1);
book_view = find_book_view (bl);
- do {
+ do {
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap_error = ldap_search_ext (ldap, id,
LDAP_SCOPE_BASE,
vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
printf ("vcard = %s\n", vcard);
-
+
contact_list_op->contacts = g_list_append (contact_list_op->contacts,
vcard);
}
switch (bl->priv->mode) {
-
+
case GNOME_Evolution_Addressbook_MODE_LOCAL :
if (bl->priv->marked_for_offline && bl->priv->cache) {
GList *contacts;
e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_Success, vcard_strings);
return;
}
-
+
e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_RepositoryOffline,
NULL);
return;
-
+
case GNOME_Evolution_Addressbook_MODE_REMOTE:
ldap = bl->priv->ldap;
printf ("getting contact list with filter: %s\n", ldap_query);
- do {
+ do {
g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap_error = ldap_search_ext (ldap,
bl->priv->ldap_rootdn,
for (l = members; l != NULL; l = g_list_next (l)) {
EVCardAttribute *attr = l->data;
dn = NULL;
-
+
for (p = e_vcard_attribute_get_params (attr); p; p = p->next) {
EVCardAttributeParam *param = p->data;
const char *param_name = e_vcard_attribute_param_get_name (param);
-
+
if (!g_ascii_strcasecmp (param_name, EVC_X_DEST_CONTACT_UID)) {
GList *v = e_vcard_attribute_param_get_values (param);
dn = v ? v->data : NULL;
for (l1 = members_new; l1 != NULL; l1 = g_list_next (l1)) {
EVCardAttribute *attr_new = l1->data;
char *dn_new = NULL;
-
+
for (p_new = e_vcard_attribute_get_params (attr_new); p_new; p_new = p_new->next) {
EVCardAttributeParam *param = p_new->data;
const char *param_name1 = e_vcard_attribute_param_get_name (param);
-
+
if (!g_ascii_strcasecmp (param_name1, EVC_X_DEST_CONTACT_UID)) {
gboolean found = FALSE;
GList *v = e_vcard_attribute_param_get_values (param);
if (!g_ascii_strcasecmp (param_name2, EVC_X_DEST_CONTACT_UID)) {
GList *v2 = e_vcard_attribute_param_get_values (param2);
dn_cur = v2 ? v2->data : NULL;
-
+
if (dn_cur) {
if (!g_ascii_strcasecmp (dn_new, dn_cur)) {
found = TRUE;
}
}
}
- next_member:
+ next_member:
continue;
}
return TRUE;
} else {
equal = FALSE;
}
-
+
}
else {
equal = (!!photo1 == !!photo2);
strings = g_new0(char*, argc+3);
strings[0] = g_strdup ("(&");
strings[argc+3 - 2] = g_strdup (")");
-
+
for (i = 0; i < argc; i ++) {
GList *list_head = ldap_data->list;
if (!list_head)
ldap_data->list = g_list_prepend(ldap_data->list,
g_strdup_printf("(|(fileAs=%s*)(&(!(fileAs=*))(sn=%s*)))",
str, str));
- else
+ else
ldap_data->list = g_list_prepend(ldap_data->list,
g_strdup_printf("(sn=%s*)", str));
}
static EContact *
build_contact_from_entry (EBookBackendLDAP *bl,
- LDAPMessage *e,
+ LDAPMessage *e,
GList **existing_objectclasses)
{
EContact *contact = e_contact_new ();
e_contact_set (contact, E_CONTACT_IS_LIST, GINT_TO_POINTER (TRUE));
e_contact_set (contact, E_CONTACT_LIST_SHOW_ADDRESSES, GINT_TO_POINTER (TRUE));
}
- if (existing_objectclasses)
+ if (existing_objectclasses)
*existing_objectclasses = g_list_append (*existing_objectclasses, g_strdup (values[i]));
}
ldap_value_free (values);
grpattrs[2] = NULL;
/* search for member attributes */
/* get the e-mail id for each member and add them to the list */
-
- book_view = find_book_view (bl);
+
+ book_view = find_book_view (bl);
if (book_view)
view_limit = e_data_book_view_get_max_results (book_view);
if (view_limit == -1 || view_limit > bl->priv->ldap_limit)
values[j],
LDAP_SCOPE_BASE,
NULL,
- grpattrs, 0,
+ grpattrs, 0,
NULL,
NULL,
NULL,
if (email_values) {
printf ("email = %s \n", email_values[0]);
- *(member_info + j) =
- g_strdup_printf ("%s;%s;",
+ *(member_info + j) =
+ g_strdup_printf ("%s;%s;",
email_values[0], values[j]);
ldap_value_free (email_values);
}
if (cn_values) {
printf ("cn = %s \n", cn_values[0]);
- *(member_info + j) =
- g_strconcat (*(member_info + j),
+ *(member_info + j) =
+ g_strconcat (*(member_info + j),
cn_values [0], NULL);
ldap_value_free (cn_values);
}
}
}
while (e_book_backend_ldap_reconnect (bl, book_view, ldap_error));
-
+
if (ldap_error != LDAP_SUCCESS) {
- book_view_notify_status (book_view,
+ book_view_notify_status (book_view,
ldap_err2string(ldap_error));
continue;
}
}
- /* call populate function */
- info->populate_contact_func (contact, member_info);
-
+ /* call populate function */
+ info->populate_contact_func (contact, member_info);
+
for (j = 0; j < count; j++) {
g_free (*(member_info + j));
}
- g_free (member_info);
+ g_free (member_info);
}
ldap_value_free (values);
e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_Success);
return;
-
+
case GNOME_Evolution_Addressbook_MODE_REMOTE :
ldap_query = e_book_backend_ldap_build_query (bl, e_data_book_view_get_card_query (view));
op->aborted = FALSE;
bonobo_object_ref (view);
- ldap_op_add ((LDAPOp*)op, E_BOOK_BACKEND(bl), book, view,
+ ldap_op_add ((LDAPOp*)op, E_BOOK_BACKEND(bl), book, view,
0, search_msgid,
ldap_search_handler, ldap_search_dtor);
GList *l;
int contact_num = 0;
char *status_msg;
-
+
e_file_cache_clean (E_FILE_CACHE (bl->priv->cache));
e_file_cache_freeze_changes (E_FILE_CACHE (bl->priv->cache));
status_msg = g_strdup_printf (_("Downloading contacts (%d)... "),
contact_num);
e_data_book_view_notify_status_message (book_view, status_msg);
- g_free (status_msg);
+ g_free (status_msg);
}
e_book_backend_cache_add_contact (bl->priv->cache, contact);
}
gint ldap_error;
GTimeVal start, end;
unsigned long diff;
-
+
if (enable_debug) {
printf ("generating offline cache ... \n");
g_get_current_time (&start);
return;
}
- ldap_query = e_book_backend_ldap_build_query (book_backend_ldap,
+ ldap_query = e_book_backend_ldap_build_query (book_backend_ldap,
"(beginswith \"file_as\" \"\")");
do {
opid, status);
return ;
}
-
+
}
if (!g_ascii_strncasecmp (auth_method, LDAP_SIMPLE_PREFIX, strlen (LDAP_SIMPLE_PREFIX))) {
passwd);
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
/* Some ldap servers are returning (ex active directory ones) LDAP_SERVER_DOWN
- * when we try to do an ldap operation after being idle
+ * when we try to do an ldap operation after being idle
* for some time. This error is handled by poll_ldap in case of search operations
* We need to handle it explicitly for this bind call. We call reconnect so that
* we get a fresh ldap handle Fixes #67541 */
}
}
-
+
e_data_book_respond_authenticate_user (book,
opid,
ldap_error_to_response (ldap_error));
{
GList *fields = NULL;
-
-
+
+
/*FIMEME we should look at mandatory attributs in the schema
and return all those fields here */
fields = g_list_append (fields, (char *)e_contact_field_name (E_CONTACT_FILE_AS));
fields = g_list_append (fields, (char *)e_contact_field_name (E_CONTACT_FULL_NAME));
fields = g_list_append (fields, (char *)e_contact_field_name (E_CONTACT_FAMILY_NAME));
-
-
+
+
e_data_book_respond_get_required_fields (book,
opid,
GNOME_Evolution_Addressbook_Success,
return GNOME_Evolution_Addressbook_Success;
}
- else
+ else
e_book_backend_notify_connection_status (backend, TRUE);
/* Online */
}
#endif
-static void
+static void
e_book_backend_ldap_set_mode (EBookBackend *backend, int mode)
{
EBookBackendLDAP *bl = E_BOOK_BACKEND_LDAP (backend);
}
else if (mode == GNOME_Evolution_Addressbook_MODE_REMOTE) {
/* Go online */
-
+
e_book_backend_set_is_writable (backend, TRUE);
e_book_backend_notify_writable (backend, TRUE);
e_book_backend_notify_connection_status (backend, TRUE);
g_static_rec_mutex_unlock (&bl->priv->op_hash_mutex);
g_static_rec_mutex_free (&bl->priv->op_hash_mutex);
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
+ g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (bl->priv->ldap)
ldap_unbind (bl->priv->ldap);
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
parent_class->get_supported_auth_methods = e_book_backend_ldap_get_supported_auth_methods;
parent_class->cancel_operation = e_book_backend_ldap_cancel_operation;
parent_class->set_mode = e_book_backend_ldap_set_mode;
-
+
object_class->dispose = e_book_backend_ldap_dispose;
}
/* kind = TK_UNEXPCHAR; */
/* break; */
}
-
+
return kind;
}
for( ; *str != '\0'; LDAP_UTF8_INCR(str) ) {
if( ldap_x_utf8_to_ucs4( str ) == ldap_x_utf8_to_ucs4( chr ) ) {
return (char *) str;
- }
+ }
}
return NULL;
for( cset = set; *cset != '\0'; LDAP_UTF8_INCR(cset) ) {
if( ldap_x_utf8_to_ucs4( cstr ) == ldap_x_utf8_to_ucs4( cset ) ) {
return cstr - str;
- }
+ }
}
}
if( ldap_x_utf8_to_ucs4( cstr ) == ldap_x_utf8_to_ucs4( cset ) ) {
break;
- }
+ }
}
}
if ( ludp == NULL ) {
return;
}
-
+
if ( ludp->lud_scheme != NULL ) {
LDAP_FREE( ludp->lud_scheme );
}
* anything real.
*/
if( (p == NULL) && (q != NULL) && ((q = strchr( q, '?')) != NULL)) {
- q++;
+ q++;
/* ? immediately followed by question */
if( *q == '?') {
q++;
#include "libedataserver/e-flag.h"
#include "libebook/e-contact.h"
-
+
#include "libedata-book/e-data-book.h"
#include "libedata-book/e-data-book-view.h"
#include "libedata-book/e-book-backend-sexp.h"
/* XXX we need a way to say "we support everything", since the
vcf backend does */
for (i = 0; i < E_CONTACT_FIELD_LAST; i ++)
- fields = g_list_append (fields, (char*)e_contact_field_name (i));
+ fields = g_list_append (fields, (char*)e_contact_field_name (i));
*fields_out = fields;
return GNOME_Evolution_Addressbook_Success;
return GNOME_Evolution_Addressbook_CouldNotCancel;
}
-static void
+static void
e_book_backend_vcf_set_mode (EBookBackend *backend, int mode)
{
if (e_book_backend_is_loaded (backend)) {
bvcf->priv = NULL;
}
- G_OBJECT_CLASS (e_book_backend_vcf_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_book_backend_vcf_parent_class)->dispose (object);
}
static void
Jesse Pavel (jpavel@ximian.com)
Copyright 2000, Ximian, Inc.
- --------------------------------------------------
+ --------------------------------------------------
*/
#include <ctype.h>
}
-static void
+static void
e_address_western_remove_blank_lines (gchar *lines[], gint *linecntr)
{
gint cntr;
one spot to fill its old spot. */
e_address_western_shift_line (lines, cntr, *linecntr);
- /* Since we must check the newly shifted line, let's
+ /* Since we must check the newly shifted line, let's
not advance the counter on this next pass. */
cntr--;
}
}
}
-
+
static gboolean
e_address_western_is_po_box (gchar *line)
/* In which phase of processing are we? */
enum State { FIRSTCHAR, SECONDCHAR, WHITESPACE } state;
-
-
+
+
/* If the first two letters of the line are `p' and `o', and these
are in turn followed by whitespace before another letter, then I
will deem the line a representation of a PO Box address. */
-
+
gint cntr;
state = FIRSTCHAR;
{
gboolean retval;
int cntr;
-
+
if (strchr (line, ',') == NULL)
retval = FALSE; /* No comma. */
else {
int index;
-
+
/* Ensure that the first character after the comma is
a letter. */
index = strcspn (line, ",");
index++;
while (isspace(line[index]))
index++;
-
+
if (!isalpha (line[index]))
return FALSE; /* FIXME: ugly control flow. */
/* Go to the character immediately following the last
whitespace character. */
while (cntr >= 0 && isspace(line[cntr]))
- cntr--;
-
+ cntr--;
+
while (cntr >= 0 && !isspace(line[cntr]))
cntr--;
else
retval = FALSE;
}
- }
+ }
return retval;
}
{
/* Return everything from the beginning of the line to
the end of the first word that contains a number. */
-
+
int index;
index = 0;
while (!isdigit(line[index]))
index++;
-
+
while (isgraph(line[index]))
index++;
-
+
return g_strndup (line, index);
}
start++;
while (isspace(line[start]))
start++;
-
+
end = strlen(line) - 1;
while (isspace (line[end]))
end--;
end = strlen (line) - 1;
while (isspace(line[end]))
end--;
-
+
start = end;
end++;
while (!isspace(line[start]))
start--;
- start++;
+ start++;
/* Between start and end lie the string. */
return g_strndup ( (line+start), end-start);
if (in_address == NULL)
return NULL;
-
+
eaw = (EAddressWestern *)g_malloc (sizeof(EAddressWestern));
eaw->po_box = NULL;
eaw->extended = NULL;
eaw->region = NULL;
eaw->postal_code = NULL;
eaw->country = NULL;
-
+
address = g_strndup (in_address, 2047);
/* The first thing I'll do is divide the multiline input string
while (address[lineindex] != '\0') {
if (address[lineindex] == '\n')
linecntr++;
-
+
lineindex++;
}
}
}
}
- }
-
+ }
+
g_free (lines);
- g_free (address);
-
+ g_free (address);
+
return eaw;
-}
+}
/**
* e_address_western_free:
*
* Frees @eaw and its contents.
**/
-void
+void
e_address_western_free (EAddressWestern *eaw)
{
if (eaw == NULL)
return;
-
+
if (eaw->po_box != NULL)
g_free(eaw->po_box);
if (eaw->extended != NULL)
g_free(eaw->postal_code);
if (eaw->country != NULL)
g_free(eaw->country);
-
+
g_free (eaw);
}
G_BEGIN_DECLS
typedef struct {
-
+
/* Public */
char *po_box;
char *extended; /* I'm not sure what this is. */
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
static PortableServer_POA poa = NULL;
EBookListener *listener;
-
+
g_static_mutex_lock (&mutex);
if (poa == NULL)
poa = bonobo_poa_get_threaded (ORBIT_THREAD_HINT_ON_CONTEXT, _ebook_context, NULL);
g_static_mutex_unlock (&mutex);
-
+
listener = g_object_new (E_TYPE_BOOK_LISTENER, "poa", poa, NULL);
return listener;
int i;
qs = g_new0(EBookQuery*, argc);
-
+
for (i = 0; i < argc; i ++) {
GList *list_head = *list;
if (!list_head)
*list = g_list_delete_link(*list, list_head);
}
- *list = g_list_prepend(*list,
+ *list = g_list_prepend(*list,
e_book_query_and (argc, qs, TRUE));
g_free (qs);
int i;
qs = g_new0(EBookQuery*, argc);
-
+
for (i = 0; i < argc; i ++) {
GList *list_head = *list;
if (!list_head)
*list = g_list_delete_link(*list, list_head);
}
- *list = g_list_prepend(*list,
+ *list = g_list_prepend(*list,
e_book_query_or (argc, qs, TRUE));
g_free (qs);
e_sexp_encode_string (str, q->query.any_field_contains.value);
break;
}
-
+
g_string_append (str, ")");
E_BOOK_QUERY_ENDS_WITH,
/*
- Consider these "coming soon".
+ Consider these "coming soon".
E_BOOK_QUERY_LT,
E_BOOK_QUERY_LE,
g_mutex_unlock (listener->priv->idle_mutex);
bonobo_object_unref (listener);
-
+
return FALSE;
}
resp->op = op;
resp->status = E_BOOK_VIEW_STATUS_OK;
-
+
for ( i = 0; i < vcards->_length; i++ ) {
resp->contacts = g_list_prepend (resp->contacts, e_contact_new_from_vcard (vcards->_buffer[i]));
}
resp->contacts = g_list_reverse (resp->contacts);
-
+
e_book_view_listener_queue_response (listener, resp);
}
/* For StatusMessageEvent */
char *message;
-
+
};
EBookViewListener *e_book_view_listener_new (void);
GNOME_Evolution_Addressbook_BookView corba_book_view;
EBook *book;
-
+
EBookViewListener *listener;
int response_id;
g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_SOURCE_NOT_LOADED,
/* translators: the placeholders will be filled by
* function names, e.g.
- * "e_book_add_contact" on book before
+ * "e_book_add_contact" on book before
* "e_book_open */
_("\"%s\" on book before \"%s\""),
"e_book_add_contact", "e_book_open");
* @cb: function to call when the operation finishes
* @closure: data to pass to callback function
*
- * Adds @contact to @book without blocking.
+ * Adds @contact to @book without blocking.
*
* Return value: %TRUE if the operation was started, %FALSE otherwise.
**/
return do_commit_contact (TRUE,
book, contact, error,
NULL, NULL);
-
+
}
/**
}
else {
GList *l;
- EList *efields = e_list_new ((EListCopyFunc) g_strdup,
+ EList *efields = e_list_new ((EListCopyFunc) g_strdup,
(EListFreeFunc) g_free,
NULL);
}
else {
GList *l;
- EList *efields = e_list_new ((EListCopyFunc) g_strdup,
+ EList *efields = e_list_new ((EListCopyFunc) g_strdup,
(EListFreeFunc) g_free,
NULL);
}
else {
GList *l;
- EList *emethods = e_list_new ((EListCopyFunc) g_strdup,
+ EList *emethods = e_list_new ((EListCopyFunc) g_strdup,
(EListFreeFunc) g_free,
NULL);
g_warning (_("\"%s\" on book before \"%s\""),
"e_book_authenticate_user", "e_book_open");
}
-
+
return FALSE;
}
EBookOp *our_op;
EBookStatus status;
CORBA_Environment ev;
-
+
g_mutex_lock (book->priv->mutex);
if (book->priv->load_state != E_BOOK_SOURCE_LOADED) {
}
return FALSE;
}
-
+
CORBA_exception_free (&ev);
if (sync) {
return FALSE;
}
-
+
CORBA_exception_free (&ev);
if (sync) {
op->status = status;
op->view = e_book_view_new (corba_book_view, op->listener);
e_book_view_set_book (op->view, book);
-
+
bonobo_object_unref(BONOBO_OBJECT(op->listener));
if (op->synchronous) {
return FALSE;
}
-
+
CORBA_exception_free (&ev);
if (sync) {
return TRUE;
}
}
-
+
/**
* e_book_get_contacts:
* @book: an #EBook
return FALSE;
}
-
+
CORBA_exception_free (&ev);
if (sync) {
return FALSE;
}
-static gboolean
+static gboolean
e_book_idle_connection (gpointer data)
{
EBook *book = data;
return FALSE;
}
-static gboolean
+static gboolean
e_book_idle_auth_required (gpointer data)
{
EBook *book = data;
case GetSupportedAuthMethodsResponse:
e_book_response_get_supported_auth_methods (book, resp->opid, resp->status, resp->list);
break;
- case WritableStatusEvent:
+ case WritableStatusEvent:
book->priv->writable = resp->writable;
-
+
g_mutex_lock (book->priv->mutex);
if (book->priv->writable_idle_id == 0) {
g_object_ref (book);
}
g_mutex_unlock (book->priv->mutex);
break;
-
+
default:
g_error ("EBook: Unknown response code %d!\n",
resp->op);
backend_died_cb (EComponentListener *cl, gpointer user_data)
{
EBook *book = user_data;
-
+
book->priv->load_state = E_BOOK_SOURCE_NOT_LOADED;
g_signal_emit (book, e_book_signals [BACKEND_DIED], 0);
}
query = "repo_ids.has ('IDL:GNOME/Evolution/DataServer/BookFactory:" API_VERSION "')";
CORBA_exception_init (&ev);
-
+
info_list = bonobo_activation_query (query, NULL, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
for (l = factories; l; l = l->next) {
GNOME_Evolution_Addressbook_BookFactory factory = l->data;
CORBA_Environment ev;
-
+
CORBA_exception_init (&ev);
corba_book = GNOME_Evolution_Addressbook_BookFactory_getBook (factory, source_xml,
g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED,
_("%s: no factories available for URI `%s'"), "e_book_new", uri);
}
-
+
return rv;
}
/**
* e_book_is_writable:
* @book: an #EBook
- *
+ *
* Check if this book is writable.
- *
+ *
* Return value: %TRUE if this book is writable, otherwise %FALSE.
*/
gboolean
*
* Return value: %TRUE if this book is connected, otherwise %FALSE.
**/
-gboolean
+gboolean
e_book_is_online (EBook *book)
{
g_return_val_if_fail (book && E_IS_BOOK (book), FALSE);
* e_book_set_default_addressbook:
* @book: An #EBook pointer
* @error: A #GError pointer
- *
+ *
* sets the #ESource of the #EBook as the "default" addressbook. This is the source
* that will be loaded in the e_book_get_default_addressbook call.
- *
+ *
* Return value: %TRUE if the setting was stored in libebook's ESourceList, otherwise %FALSE.
*/
gboolean
* e_book_set_default_source:
* @source: An #ESource pointer
* @error: A #GError pointer
- *
+ *
* sets @source as the "default" addressbook. This is the source that
* will be loaded in the e_book_get_default_addressbook call.
- *
+ *
* Return value: %TRUE if the setting was stored in libebook's ESourceList, otherwise %FALSE.
*/
gboolean
e_book_get_addressbooks (ESourceList **addressbook_sources, GError **error)
{
GConfClient *gconf;
-
+
e_return_error_if_fail (addressbook_sources, E_BOOK_ERROR_INVALID_ARG, FALSE);
gconf = gconf_client_get_default();
uri = g_filename_to_uri (filename, NULL, NULL);
g_free (filename);
-
+
book = e_book_new_from_uri (uri, error);
g_free (uri);
bonobo_object_unref (book->priv->listener);
book->priv->listener = NULL;
}
-
+
g_free (book->priv->cap);
g_free (book->priv->uri);
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
-
+
e_book_signals [CONNECTION_STATUS] =
g_signal_new ("connection_status",
G_OBJECT_CLASS_TYPE (object_class),
const char *vcard_field_name;
const char *field_name; /* non translated */
const char *pretty_name; /* translated */
-
+
gboolean read_only;
int list_elem;
ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_TELEX, EVC_TEL, "telex", N_("Telex"), FALSE, EVC_X_TELEX, 0),
/* To translators: TTY is Teletypewriter */
ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_TTYTDD, EVC_TEL, "tty", N_("TTY"), FALSE, EVC_X_TTYTDD, 0),
-
+
/* Organizational fields */
LIST_ELEM_STR_FIELD (E_CONTACT_ORG, EVC_ORG, "org", N_("Organization"), FALSE, 0),
LIST_ELEM_STR_FIELD (E_CONTACT_ORG_UNIT, EVC_ORG, "org_unit", N_("Organizational Unit"), FALSE, 1),
/* Verify the table is correctly ordered */
g_assert (i == field_info[i].field_id);
-
+
if (field_info[i].t & E_CONTACT_FIELD_TYPE_STRING)
pspec = g_param_spec_string (field_info[i].field_name,
_(field_info[i].pretty_name),
static void
geo_setter (EContact *contact, EVCardAttribute *attr, void *data)
{
- EContactGeo *geo = data;
+ EContactGeo *geo = data;
char buf[G_ASCII_DTOSTR_BUF_SIZE];
e_vcard_attribute_add_value
if (!attr)
return NULL;
-
+
values = e_vcard_attribute_get_param (attr, EVC_ENCODING);
if (values && (g_ascii_strcasecmp (values->data, "b") == 0 ||
/* second for photo vCard 2.1 support */
g_ascii_strcasecmp (values->data, "base64") == 0)) {
- values = e_vcard_attribute_get_values_decoded (attr);
+ values = e_vcard_attribute_get_values_decoded (attr);
if (values && values->data) {
GString *s = values->data;
EContactPhoto *photo;
-
+
if (!s->len)
return NULL;
-
+
photo = g_new0 (EContactPhoto, 1);
photo->type = E_CONTACT_PHOTO_TYPE_INLINED;
photo->data.inlined.length = s->len;
switch (photo->type) {
case E_CONTACT_PHOTO_TYPE_INLINED:
g_return_if_fail (photo->data.inlined.length > 0);
-
+
e_vcard_attribute_add_param_with_value (attr,
e_vcard_attribute_param_new (EVC_ENCODING),
"b");
e_vcard_attribute_add_param_with_value (attr,
e_vcard_attribute_param_new (EVC_TYPE),
image_type);
-
+
e_vcard_attribute_add_value_decoded (attr, (char*)photo->data.inlined.data, photo->data.inlined.length);
break;
case E_CONTACT_PHOTO_TYPE_URI:
up via NSS, but that would require the additional NSS dep
here, and we'd have more than one process opening the
certdb, which is bad. *sigh* */
-
+
return NULL;
}
else {
/* we didn't find it - add a new attribute */
attr = e_vcard_attribute_new (NULL, info->vcard_field_name);
- if (!strcmp(info->vcard_field_name, "EMAIL") &&
- !info->attr_type1 &&
+ if (!strcmp(info->vcard_field_name, "EMAIL") &&
+ !info->attr_type1 &&
!info->attr_type2) {
/* Add default type */
e_vcard_attribute_add_param_with_value ( attr,
attr = e_vcard_attribute_new (NULL, info->vcard_field_name);
e_vcard_add_attribute (E_VCARD (contact), attr);
}
-
+
values = e_vcard_attribute_get_values (attr);
p = g_list_nth (values, info->list_elem);
{
const EContactFieldInfo *info = NULL;
gpointer data;
-
+
if (prop_id < 1 || prop_id >= E_CONTACT_FIELD_LAST) {
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
g_value_reset (value);
return;
}
-
+
info = &field_info[prop_id];
data = e_contact_get (E_CONTACT (object), prop_id);
/**
* e_contact_new_from_vcard:
* @vcard: a string representing a vcard
- *
+ *
* Creates a new #EContact based on a vcard.
*
* Return value: A new #EContact.
/**
* e_contact_field_id:
* @field_name: a string representing a contact field
- *
+ *
* Gets the #EContactField corresponding to the @field_name.
*
* Return value: An #EContactField corresponding to @field_name, or %0 if it doesn't exist.
e_contact_get (EContact *contact, EContactField field_id)
{
const EContactFieldInfo *info = NULL;
-
+
g_return_val_if_fail (contact && E_IS_CONTACT (contact), NULL);
g_return_val_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST, NULL);
if (attr) {
GList *v;
-
+
v = e_vcard_attribute_get_values (attr);
v = g_list_nth (v, info->list_elem);
-
+
return v ? g_strdup (v->data) : NULL;
}
}
g_return_val_if_fail (name_str != NULL, NULL);
western = e_name_western_parse (name_str ? name_str : "");
-
+
name->prefixes = g_strdup (western->prefix);
name->given = g_strdup (western->first );
name->additional = g_strdup (western->middle);
name->family = g_strdup (western->last );
name->suffixes = g_strdup (western->suffix);
-
+
e_name_western_free(western);
-
+
return name;
}
g_return_val_if_fail (n != NULL, NULL);
name = e_contact_name_new();
-
+
name->prefixes = g_strdup (n->prefixes);
name->given = g_strdup (n->given);
name->additional = g_strdup (n->additional);
name->family = g_strdup (n->family);
name->suffixes = g_strdup (n->suffixes);
-
+
return name;
}
length = t - str;
else
length = strlen(str);
-
+
if (length == 10 ) {
date->year = str[0] * 1000 + str[1] * 100 + str[2] * 10 + str[3] - '0' * 1111;
date->month = str[5] * 10 + str[6] - '0' * 11;
date->month = str[4] * 10 + str[5] - '0' * 11;
date->day = str[6] * 10 + str[7] - '0' * 11;
}
-
+
return date;
}
char *
e_contact_date_to_string (EContactDate *dt)
{
- if (dt)
+ if (dt)
return g_strdup_printf ("%04d-%02d-%02d",
CLAMP(dt->year, 1000, 9999),
CLAMP(dt->month, 1, 12),
/**
* e_contact_date_new:
- *
+ *
* Creates a new #EContactDate struct.
*
* Return value: A new #EContactDate struct.
{
if (!photo)
return;
-
+
switch (photo->type) {
case E_CONTACT_PHOTO_TYPE_INLINED:
g_free (photo->data.inlined.mime_type);
E_CONTACT_IM_YAHOO, /* Multi-valued */
E_CONTACT_IM_MSN, /* Multi-valued */
E_CONTACT_IM_ICQ, /* Multi-valued */
-
+
E_CONTACT_WANTS_HTML, /* boolean field */
/* fields used for describing contact lists. a contact list
E_CONTACT_IM_GADUGADU_WORK_3, /* Synthetic string field */
E_CONTACT_IM_GADUGADU, /* Multi-valued */
-
- E_CONTACT_GEO, /* structured field (EContactGeo) */
+
+ E_CONTACT_GEO, /* structured field (EContactGeo) */
E_CONTACT_TEL, /* list of strings */
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser 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
if (dest->priv) {
e_destination_clear (dest);
-
+
g_free (dest->priv);
dest->priv = NULL;
}
g_free (dest->priv->raw);
dest->priv->raw = NULL;
-
+
g_free (dest->priv->name);
dest->priv->name = NULL;
-
+
g_free (dest->priv->email);
dest->priv->email = NULL;
-
+
g_free (dest->priv->addr);
dest->priv->addr = NULL;
-
+
g_free (dest->priv->textrep);
dest->priv->textrep = NULL;
dest->priv->contact = NULL;
}
dest->priv->email_num = -1;
-
+
g_list_foreach (dest->priv->list_dests, (GFunc) g_object_unref, NULL);
g_list_free (dest->priv->list_dests);
dest->priv->list_dests = NULL;
struct _EDestinationPrivate *p;
g_return_val_if_fail (E_IS_DESTINATION (dest), TRUE);
-
+
p = dest->priv;
-
+
return !(p->contact != NULL
|| (p->source_uid && *p->source_uid)
|| (p->contact_uid && *p->contact_uid)
{
const struct _EDestinationPrivate *pa, *pb;
const char *na, *nb;
-
+
g_return_val_if_fail (E_IS_DESTINATION (a), FALSE);
g_return_val_if_fail (E_IS_DESTINATION (b), FALSE);
if (a == b)
return TRUE;
-
+
pa = a->priv;
pb = b->priv;
-
+
/* Check equality of contacts. */
if (pa->contact || pb->contact) {
if (! (pa->contact && pb->contact))
return FALSE;
-
+
if (pa->contact == pb->contact || !strcmp (e_contact_get_const (pa->contact, E_CONTACT_UID),
e_contact_get_const (pb->contact, E_CONTACT_UID)))
return TRUE;
-
+
return FALSE;
}
-
+
/* Just in case name returns NULL */
na = e_destination_get_name (a);
nb = e_destination_get_name (b);
if ((na || nb) && !(na && nb && ! utf8_casefold_collate (na, nb)))
return FALSE;
-
+
if (!g_ascii_strcasecmp (e_destination_get_email (a), e_destination_get_email (b)))
return TRUE;
else
dest->priv->contact_uid = e_contact_get (dest->priv->contact, E_CONTACT_UID);
dest->priv->email_num = email_num;
-
- g_signal_emit (dest, signals [CHANGED], 0);
+
+ g_signal_emit (dest, signals [CHANGED], 0);
}
-
+
}
/**
{
g_return_if_fail (dest && E_IS_DESTINATION (dest));
g_return_if_fail (uid != NULL);
-
+
if (dest->priv->contact_uid == NULL
|| strcmp (dest->priv->contact_uid, uid)
|| dest->priv->email_num != email_num) {
-
+
g_free (dest->priv->contact_uid);
dest->priv->contact_uid = g_strdup (uid);
dest->priv->email_num = email_num;
-
+
/* If we already have a contact, remove it unless it's uid matches the one
we just set. */
if (dest->priv->contact && strcmp (uid,
{
g_return_if_fail (dest && E_IS_DESTINATION (dest));
g_return_if_fail (uid != NULL);
-
+
if (dest->priv->source_uid == NULL
|| strcmp (dest->priv->source_uid, uid)) {
gboolean changed = FALSE;
g_return_if_fail (E_IS_DESTINATION (dest));
-
+
if (name == NULL) {
if (dest->priv->name != NULL) {
g_free (dest->priv->name);
dest->priv->name = g_strdup (name);
changed = TRUE;
}
-
+
if (changed) {
g_free (dest->priv->addr);
dest->priv->addr = NULL;
gboolean changed = FALSE;
g_return_if_fail (E_IS_DESTINATION (dest));
-
+
if (email == NULL) {
if (dest->priv->email != NULL) {
g_free (dest->priv->addr);
dest->priv->email = g_strdup (email);
changed = TRUE;
}
-
+
if (changed) {
g_free (dest->priv->addr);
dest->priv->addr = NULL;
e_destination_is_auto_recipient (const EDestination *dest)
{
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE);
-
+
return dest->priv->auto_recipient;
}
* e_destination_set_auto_recipient:
* @dest: an #EDestination
* @value: the auto recipient flag
- *
+ *
* Sets the flag indicating if @dest is an automatic recipient, meaning
* it was not explicitly specified by the user. This can be used
* to hide it from some UI elements.
e_destination_set_auto_recipient (EDestination *dest, gboolean value)
{
g_return_if_fail (dest && E_IS_DESTINATION (dest));
-
+
dest->priv->auto_recipient = value;
g_signal_emit (dest, signals [CHANGED], 0);
e_destination_get_contact (const EDestination *dest)
{
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
+
return dest->priv->contact;
}
e_destination_get_contact_uid (const EDestination *dest)
{
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
+
return dest->priv->contact_uid;
}
e_destination_get_email_num (const EDestination *dest)
{
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), -1);
-
+
if (dest->priv->contact == NULL && (dest->priv->source_uid == NULL || dest->priv->contact_uid == NULL))
return -1;
-
+
return dest->priv->email_num;
}
/**
* e_destination_get_name:
* @dest: an #EDestination
- *
+ *
* Gets the full name of @dest's addressee, or if the addressee is
* a contact list, the name the list was filed under.
*
struct _EDestinationPrivate *priv;
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
+
priv = (struct _EDestinationPrivate *)dest->priv; /* cast out const */
-
+
if (priv->name == NULL) {
if (priv->contact != NULL) {
priv->name = e_contact_get (priv->contact, E_CONTACT_FULL_NAME);
-
+
if (priv->name == NULL || *priv->name == '\0') {
g_free (priv->name);
priv->name = e_contact_get (priv->contact, E_CONTACT_FILE_AS);
}
-
+
if (priv->name == NULL || *priv->name == '\0') {
g_free (priv->name);
if (e_contact_get (priv->contact, E_CONTACT_IS_LIST))
if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) {
const char *camel_name = NULL;
-
+
camel_internet_address_get (addr, 0, &camel_name, NULL);
priv->name = g_strdup (camel_name);
}
-
+
camel_object_unref (CAMEL_OBJECT (addr));
}
}
-
+
return priv->name;
}
e_destination_get_email (const EDestination *dest)
{
struct _EDestinationPrivate *priv;
-
+
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
+
priv = (struct _EDestinationPrivate *)dest->priv; /* cast out const */
-
+
if (priv->email == NULL) {
if (priv->contact != NULL) {
/* Pull the address out of the card. */
if (e)
priv->email = g_strdup (e);
- }
+ }
if (email) {
g_list_foreach (email, (GFunc)g_free, NULL);
g_list_free (email);
}
-
+
} else if (priv->raw != NULL) {
CamelInternetAddress *addr = camel_internet_address_new ();
-
+
if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) {
const char *camel_email = NULL;
camel_internet_address_get (addr, 0, NULL, &camel_email);
priv->email = g_strdup (camel_email);
}
-
+
camel_object_unref (CAMEL_OBJECT (addr));
- }
-
+ }
+
/* Force e-mail to be non-null... */
if (priv->email == NULL) {
priv->email = g_strdup ("");
}
}
-
+
return priv->email;
}
struct _EDestinationPrivate *priv;
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
+
priv = (struct _EDestinationPrivate *)dest->priv; /* cast out const */
-
+
if (priv->addr == NULL) {
CamelInternetAddress *addr = camel_internet_address_new ();
-
+
if (e_destination_is_evolution_list (dest)) {
GList *iter = dest->priv->list_dests;
-
+
while (iter) {
EDestination *list_dest = E_DESTINATION (iter->data);
-
+
if (!e_destination_empty (list_dest) && !list_dest->priv->ignored) {
const char *name, *email;
name = e_destination_get_name (list_dest);
}
iter = g_list_next (iter);
}
-
+
priv->addr = camel_address_encode (CAMEL_ADDRESS (addr));
} else if (priv->raw) {
else /* this case loses i suppose, but there's
nothing we can do here */
camel_address_decode (CAMEL_ADDRESS (addr), name);
-
+
priv->addr = camel_address_encode (CAMEL_ADDRESS (addr));
}
-
+
camel_object_unref (CAMEL_OBJECT (addr));
}
-
+
return priv->addr;
}
{
g_return_if_fail (E_IS_DESTINATION (dest));
g_return_if_fail (raw != NULL);
-
+
if (dest->priv->raw == NULL || strcmp (dest->priv->raw, raw)) {
-
+
e_destination_clear (dest);
dest->priv->raw = g_strdup (raw);
e_destination_get_textrep (const EDestination *dest, gboolean include_email)
{
const char *name, *email;
-
+
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
+
if (dest->priv->raw)
return dest->priv->raw;
-
+
name = e_destination_get_name (dest);
email = e_destination_get_email (dest);
-
+
if (e_destination_from_contact (dest) && name != NULL && (!include_email || !email || !*email))
return name;
-
+
/* Make sure that our address gets quoted properly */
if (name && email && dest->priv->textrep == NULL) {
CamelInternetAddress *addr = camel_internet_address_new ();
-
+
camel_internet_address_add (addr, name, email);
g_free (dest->priv->textrep);
dest->priv->textrep = camel_address_format (CAMEL_ADDRESS (addr));
camel_object_unref (CAMEL_OBJECT (addr));
}
-
+
if (dest->priv->textrep != NULL)
return dest->priv->textrep;
if (email)
return email;
-
+
return "";
}
e_destination_list_show_addresses (const EDestination *dest)
{
g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE);
-
+
if (dest->priv->contact != NULL)
return GPOINTER_TO_UINT (e_contact_get (dest->priv->contact, E_CONTACT_LIST_SHOW_ADDRESSES));
-
+
return dest->priv->show_addresses;
}
e_destination_list_get_dests (const EDestination *dest)
{
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
+
if (!e_destination_is_evolution_list (dest))
return NULL;
e_destination_get_html_mail_pref (const EDestination *dest)
{
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE);
-
+
if (dest->priv->html_mail_override || dest->priv->contact == NULL)
return dest->priv->wants_html_mail;
-
+
return e_contact_get (dest->priv->contact, E_CONTACT_WANTS_HTML) ? TRUE : FALSE;
}
e_destination_set_html_mail_pref (EDestination *dest, gboolean flag)
{
g_return_if_fail (dest && E_IS_DESTINATION (dest));
-
+
dest->priv->html_mail_override = TRUE;
if (dest->priv->wants_html_mail != flag) {
dest->priv->wants_html_mail = flag;
char *str;
g_return_val_if_fail (destv, NULL);
-
+
/* Q: Please tell me this is only for assertion
reasons. If this is considered to be ok behavior then you
- shouldn't use g_return's. Just a reminder ;-)
-
+ shouldn't use g_return's. Just a reminder ;-)
+
A: Yes, this is just an assertion. (Though it does find the
length of the vector in the process...)
*/
g_return_val_if_fail (E_IS_DESTINATION (destv[len]), NULL);
len++;
}
-
+
strv = g_new0 (char *, len + 1);
for (i = 0, j = 0; destv[i]; i++) {
if (!e_destination_empty (destv[i])) {
strv[j++] = addr ? (char *) addr : "";
}
}
-
+
str = g_strjoinv (", ", strv);
-
+
g_free (strv);
-
+
return str;
}
{
xmlNodePtr dest_node;
const char *str;
-
+
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
+
dest_node = xmlNewNode (NULL, (xmlChar*)"destination");
-
+
str = e_destination_get_name (dest);
if (str)
xmlNewTextChild (dest_node, NULL, (xmlChar*)"name", (xmlChar*)str);
-
+
if (!e_destination_is_evolution_list (dest)) {
str = e_destination_get_email (dest);
if (str)
xmlNewTextChild (dest_node, NULL, (xmlChar*)"email", (xmlChar*)str);
} else {
GList *iter = dest->priv->list_dests;
-
+
while (iter) {
EDestination *list_dest = E_DESTINATION (iter->data);
xmlNodePtr list_node = xmlNewNode (NULL, (xmlChar*)"list_entry");
xmlNewTextChild (list_node, NULL, (xmlChar*)"name", escaped);
xmlFree (escaped);
}
-
+
str = e_destination_get_email (list_dest);
if (str) {
xmlChar *escaped = xmlEncodeEntitiesReentrant (NULL, (xmlChar*)str);
xmlNewTextChild (list_node, NULL, (xmlChar*)"email", escaped);
xmlFree (escaped);
}
-
+
xmlAddChild (dest_node, list_node);
-
+
iter = g_list_next (iter);
}
-
+
xmlNewProp (dest_node, (xmlChar*)"is_list", (xmlChar*)"yes");
- xmlNewProp (dest_node, (xmlChar*)"show_addresses",
+ xmlNewProp (dest_node, (xmlChar*)"show_addresses",
e_destination_list_show_addresses (dest) ? (xmlChar*)"yes" : (xmlChar*)"no");
}
-
+
str = e_destination_get_source_uid (dest);
if (str) {
xmlChar *escaped = xmlEncodeEntitiesReentrant (NULL, (xmlChar*)str);
xmlNewTextChild (dest_node, NULL, (xmlChar*)"source_uid", escaped);
xmlFree (escaped);
}
-
+
str = e_destination_get_contact_uid (dest);
if (str) {
char buf[16];
-
+
xmlNodePtr uri_node = xmlNewTextChild (dest_node, NULL, (xmlChar*)"card_uid", (xmlChar*)str);
g_snprintf (buf, 16, "%d", e_destination_get_email_num (dest));
xmlNewProp (uri_node, (xmlChar*)"email_num", (xmlChar*)buf);
}
-
+
xmlNewProp (dest_node, (xmlChar*)"html_mail", e_destination_get_html_mail_pref (dest) ? (xmlChar*)"yes" : (xmlChar*)"no");
-
+
xmlNewProp (dest_node, (xmlChar*)"auto_recipient",
e_destination_is_auto_recipient (dest) ? (xmlChar*)"yes" : (xmlChar*)"no");
-
+
return dest_node;
}
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE);
g_return_val_if_fail (node != NULL, FALSE);
-
+
if (strcmp ((char*)node->name, "destination"))
return FALSE;
-
+
tmp = (char*)xmlGetProp (node, (xmlChar*)"html_mail");
if (tmp) {
html_mail = !strcmp (tmp, "yes");
xmlFree (tmp);
}
-
+
tmp = (char*)xmlGetProp (node, (xmlChar*)"is_list");
if (tmp) {
is_list = !strcmp (tmp, "yes");
xmlFree (tmp);
}
-
+
tmp = (char*)xmlGetProp (node, (xmlChar*)"show_addresses");
if (tmp) {
show_addr = !strcmp (tmp, "yes");
xmlFree (tmp);
}
-
+
tmp = (char*)xmlGetProp (node, (xmlChar*)"auto_recipient");
if (tmp) {
auto_recip = !strcmp (tmp, "yes");
xmlFree (tmp);
}
-
+
node = node->xmlChildrenNode;
while (node) {
if (!strcmp ((char*)node->name, "name")) {
} else if (is_list && !strcmp ((char*)node->name, "list_entry")) {
xmlNodePtr subnode = node->xmlChildrenNode;
char *list_name = NULL, *list_email = NULL;
-
+
while (subnode) {
if (!strcmp ((char*)subnode->name, "name")) {
tmp = (char*)xmlNodeGetContent (subnode);
list_email = g_strdup (tmp);
xmlFree (tmp);
}
-
+
subnode = subnode->next;
}
-
+
if (list_name || list_email) {
EDestination *list_dest = e_destination_new ();
-
+
if (list_name)
e_destination_set_name (list_dest, list_name);
if (list_email)
e_destination_set_email (list_dest, list_email);
-
+
g_free (list_name);
g_free (list_email);
-
+
list_dests = g_list_append (list_dests, list_dest);
}
} else if (!strcmp ((char*)node->name, "source_uid")) {
g_free (card_uid);
card_uid = g_strdup (tmp);
xmlFree (tmp);
-
+
tmp = (char*)xmlGetProp (node, (xmlChar*)"email_num");
email_num = atoi (tmp);
xmlFree (tmp);
}
-
+
node = node->next;
}
-
+
e_destination_clear (dest);
-
+
if (name) {
e_destination_set_name (dest, name);
g_free (name);
}
if (list_dests)
dest->priv->list_dests = list_dests;
-
+
dest->priv->html_mail_override = TRUE;
dest->priv->wants_html_mail = html_mail;
-
+
dest->priv->show_addresses = show_addr;
-
+
dest->priv->auto_recipient = auto_recip;
-
+
return TRUE;
}
gboolean skip_white = FALSE;
char *xml, *r, *w;
- if (xml_in == NULL || size <= 0)
+ if (xml_in == NULL || size <= 0)
return NULL;
-
+
xml = g_strndup ((char*)xml_in, size);
r = w = xml;
-
+
while (*r) {
if (*r == '\n' || *r == '\r') {
skip_white = TRUE;
} else {
gunichar c = g_utf8_get_char (r);
gboolean is_space = g_unichar_isspace (c);
-
+
*w = *r;
-
+
if (!(skip_white && is_space))
w++;
if (!is_space)
}
r = g_utf8_next_char (r);
}
-
+
*w = '\0';
-
+
return xml;
}
char *str;
g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
-
+
dest_node = e_destination_xml_encode (dest);
if (dest_node == NULL)
return NULL;
-
+
dest_doc = xmlNewDoc ((xmlChar*)XML_DEFAULT_VERSION);
xmlDocSetRootElement (dest_doc, dest_node);
-
+
xmlDocDumpMemory (dest_doc, &buffer, &size);
xmlFreeDoc (dest_doc);
-
+
str = null_terminate_and_remove_extra_whitespace (buffer, size);
xmlFree (buffer);
-
+
return str;
}
if (!(str && *str))
return NULL;
-
+
dest_doc = xmlParseMemory ((char *) str, strlen (str));
if (dest_doc && dest_doc->xmlRootNode) {
dest = e_destination_new ();
}
}
xmlFreeDoc (dest_doc);
-
+
return dest;
}
if (destv == NULL || *destv == NULL)
return NULL;
-
+
destv_doc = xmlNewDoc ((xmlChar*)XML_DEFAULT_VERSION);
destv_node = xmlNewNode (NULL, (xmlChar*)"destinations");
xmlDocSetRootElement (destv_doc, destv_node);
-
+
for (i = 0; destv[i]; i++) {
if (! e_destination_empty (destv[i])) {
xmlNodePtr dest_node = e_destination_xml_encode (destv[i]);
xmlAddChild (destv_node, dest_node);
}
}
-
+
xmlDocDumpMemory (destv_doc, &buffer, &size);
xmlFreeDoc (destv_doc);
-
+
str = null_terminate_and_remove_extra_whitespace (buffer, size);
xmlFree (buffer);
-
+
return str;
}
xmlDocPtr destv_doc;
xmlNodePtr node;
EDestination **destv = NULL;
-
+
if (!(str && *str))
return NULL;
-
+
destv_doc = xmlParseMemory ((char *)str, strlen (str));
if (destv_doc == NULL)
return NULL;
-
+
node = destv_doc->xmlRootNode;
-
+
if (strcmp ((char*)node->name, "destinations"))
goto finished;
-
+
node = node->xmlChildrenNode;
-
+
dest_array = g_ptr_array_new ();
-
+
while (node) {
EDestination *dest;
-
+
dest = e_destination_new ();
if (e_destination_xml_decode (dest, node) && !e_destination_empty (dest)) {
g_ptr_array_add (dest_array, dest);
} else {
g_object_unref (dest);
}
-
+
node = node->next;
}
-
+
/* we need destv to be NULL terminated */
g_ptr_array_add (dest_array, NULL);
-
+
destv = (EDestination **) dest_array->pdata;
g_ptr_array_free (dest_array, FALSE);
-
+
finished:
xmlFreeDoc (destv_doc);
-
+
return destv;
}
e_destination_freev (EDestination **destv)
{
int i;
-
+
if (destv) {
for (i = 0; destv[i] != NULL; ++i) {
g_object_unref (destv[i]);
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser 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
#include <ctype.h>
#include <string.h>
#include <glib.h>
-
+
#include "e-name-western.h"
#include "e-name-western-tables.h"
/*
* What the fuck is wrong with glib's MAX macro.
- */
+ */
static int
e_name_western_max (const int a, const int b)
{
*/
word = e_name_western_get_words_at_idx (str, 0, 1);
- if (g_utf8_strlen (word, -1) > 2 &&
+ if (g_utf8_strlen (word, -1) > 2 &&
g_unichar_isalpha (g_utf8_get_char (word)) &&
g_unichar_isalpha (g_utf8_get_char (g_utf8_next_char (word))) &&
word [strlen (word) - 1] == '.')
middle = g_utf8_next_char (middle);
if (*middle == '\0')
return;
-
+
/*
* Search for the first space (or the terminating \0)
*/
while (g_unichar_isspace (g_utf8_get_char (middle)) &&
*middle != '\0')
middle = g_utf8_next_char (middle);
-
+
if (*middle == '\0')
return;
middle = name->full + idxs->nick_idx + strlen (name->nick);
middle = g_utf8_next_char (middle);
-
+
while (g_unichar_isspace (g_utf8_get_char (middle)) &&
*middle != '\0')
middle = g_utf8_next_char (middle);
g_free (word);
return;
}
-
+
idxs->middle_idx = middle - name->full;
name->middle = word;
}
break;
}
nextp = g_utf8_prev_char (nextp);
-
+
e_name_western_cleanup_string (& word);
if (e_name_western_word_is_suffix (word)) {
* to
* <Prefix> <First name> <Middle[+nick] name> <Last name> <Suffix>
*/
-
+
/*
* Grab the prefix from the beginning.
*/
while (g_unichar_isspace (g_utf8_get_char (p)) && *p != '\0')
p = g_utf8_next_char (p);
-
- /*
+
+ /*
Consider this case, "Br.Gate,Br. Gate,W". I know this is a damn
random name, but, I got this from the bug report of 317411.
-
+
comma = ",Br.Gate,W"
prefix = "Br.Gate,Br."
p = " Gate,W"
g_free (prefix);
return;
}
-
+
last = g_malloc0 (comma - p + 1);
strncpy (last, p, comma - p);
g_free (w->nick);
g_free (w->last);
g_free (w->suffix);
-
+
g_free (w->full);
g_free (w);
#define CRLF "\r\n"
-/** Encoding used in v-card
+/** Encoding used in v-card
* Note: v-card spec defines additional 7BIT 8BIT and X- encoding
*/
typedef enum {
/* Skip newline characters and return the next character.
- * This function takes care of folding lines, skipping
+ * This function takes care of folding lines, skipping
* newline characters if found, taking care of equal characters
* and other strange things.
*/
static char*
skip_newline (char *str, gboolean quoted_printable)
{
- char *p;
+ char *p;
char *next;
char *next2;
p = str;
/* read in the value */
str = g_string_new ("");
for( lp = skip_newline( *p, quoted_printable );
- *lp != '\n' && *lp != '\r' && *lp != '\0';
+ *lp != '\n' && *lp != '\r' && *lp != '\0';
lp = skip_newline( lp, quoted_printable ) ) {
if (*lp == '=' && quoted_printable) {
c = (((a>='a'?a-'a'+10:a-'0')&0x0f) << 4)
| ((b>='a'?b-'a'+10:b-'0')&0x0f);
-
+
g_string_append_c (str, c); /* add decoded byte (this is not a unicode yet) */
}
- else
+ else
{
g_string_append_c (str, a);
g_string_append_c (str, b);
}
-
+
lp++;
} else if (*lp == '\\') {
str = g_string_new ("");
for( lp = skip_newline( *p, *quoted_printable );
- *lp != '\n' && *lp != '\r' && *lp != '\0';
+ *lp != '\n' && *lp != '\r' && *lp != '\0';
lp = skip_newline( lp, *quoted_printable ) ) {
if (*lp == '"') {
} else if (*lp == ':') {
/* do nothing */
- } else {
+ } else {
skip_to_next_line( &lp );
break;
}
else {
/* we've got an attribute with a truly empty
attribute parameter. So it's of the form:
-
+
ATTR;[PARAM=value;]*;[PARAM=value;]*:
(note the extra ';')
g_warning ("invalid character found in parameter spec");
g_string_assign (str, "");
/* skip_until (&lp, ":;"); */
-
+
skip_to_next_line( &lp );
}
}
/* first read in the group/name */
str = g_string_new ("");
for( lp = skip_newline( *p, is_qp );
- *lp != '\n' && *lp != '\r' && *lp != '\0';
+ *lp != '\n' && *lp != '\r' && *lp != '\0';
lp = skip_newline( lp, is_qp ) ) {
if (*lp == ':' || *lp == ';') {
GString *string;
const gchar *remainder, *invalid;
gint remaining_bytes, valid_bytes;
-
+
string = NULL;
remainder = name;
remaining_bytes = strlen (name);
-
+
while (remaining_bytes != 0) {
- if (g_utf8_validate (remainder, remaining_bytes, &invalid))
+ if (g_utf8_validate (remainder, remaining_bytes, &invalid))
break;
valid_bytes = invalid - remainder;
-
- if (string == NULL)
+
+ if (string == NULL)
string = g_string_sized_new (remaining_bytes);
g_string_append_len (string, remainder, valid_bytes);
/* append U+FFFD REPLACEMENT CHARACTER */
g_string_append (string, "\357\277\275");
-
+
remaining_bytes -= valid_bytes + 1;
remainder = invalid + 1;
}
-
+
if (string == NULL)
return g_strdup (name);
-
+
g_string_append (string, remainder);
g_assert (g_utf8_validate (string->str, -1, NULL));
-
+
return g_string_free (string, FALSE);
}
char *buf ;
char *p;
EVCardAttribute *attr;
-
+
buf = make_valid_utf8 (str);
//buf = fold_lines (buf);
/**
* e_vcard_new:
- *
+ *
* Creates a new, blank #EVCard.
*
* Return value: A new, blank #EVCard.
* @attr_group: group name of attributes to be removed
* @attr_name: name of the arributes to be removed
*
- * Removes all the attributes with group name and attribute name equal to
+ * Removes all the attributes with group name and attribute name equal to
* passed in values. If @attr_group is %NULL or an empty string,
* it removes all the attributes with passed in name irrespective of
* their group names.
if (l == NULL) {
return;
}
-
+
attr->values = g_list_delete_link (attr->values, l);
}
g_return_if_fail (attr != NULL);
g_return_if_fail (param_name != NULL);
-
+
for (l = attr->params; l; l = l->next) {
param = l->data;
if (g_ascii_strcasecmp (e_vcard_attribute_param_get_name (param),
contains = FALSE;
params = attr->params;
par_name = param->name;
-
+
for (p = params; p; p = p->next) {
EVCardAttributeParam *param2 = p->data;
if (g_ascii_strcasecmp (param2->name, par_name) == 0) {
break;
}
}
-
+
if (!contains) {
attr->params = g_list_prepend (attr->params, param);
}
if (l == NULL) {
return;
}
-
+
param->values = g_list_delete_link (param->values, l);
if (param->values == NULL) {
e_vcard_attribute_param_free (param);
attrs = e_vcard_get_attributes (evc);
for (l = attrs; l; l = l->next) {
EVCardAttribute *attr;
-
+
attr = (EVCardAttribute *) l->data;
if (strcmp (attr->name, name) == 0)
return attr;
*
* Gets the list of values from @attr. The list and its
* contents are owned by @attr, and must not be freed.
- *
+ *
* Return value: A list of string values.
**/
GList*
/**
* e_vcard_attribute_get_params:
* @attr: an #EVCardAttribute
- *
+ *
* Gets the list of parameters from @attr. The list and its
* contents are owned by @attr, and must not be freed.
*
* e_vcard_attribute_get_param:
* @attr: an #EVCardAttribute
* @name: a parameter name
- *
+ *
* Gets the list of values for the paramater @name from @attr. The list and its
* contents are owned by @attr, and must not be freed.
*
e_vcard_attribute_get_param (EVCardAttribute *attr, const char *name)
{
GList *params, *p;
-
+
g_return_val_if_fail (attr != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
-
+
params = e_vcard_attribute_get_params (attr);
for (p = params; p; p = p->next) {
/**
* e_vcard_attribute_param_get_values:
* @param: an #EVCardAttributeParam
- *
+ *
* Gets the list of values from @param. The list and its
* contents are owned by @param, and must not be freed.
*
g_free (priv->uri);
priv->uri = NULL;
}
-
+
g_free (priv);
cache->priv = NULL;
obj = parent_class->constructor (type,
n_construct_properties,
construct_properties);
-
+
/* extract uid */
if (!g_ascii_strcasecmp ( g_param_spec_get_name (construct_properties->pspec), "uri")) {
uri = g_value_get_string (construct_properties->value);
e_book_backend_cache_new (const char *uri)
{
EBookBackendCache *cache;
-
+
cache = g_object_new (E_TYPE_BOOK_BACKEND_CACHE, "uri", uri, NULL);
return cache;
vcard_str = e_file_cache_get_object (E_FILE_CACHE (cache), uid);
if (vcard_str) {
contact = e_contact_new_from_vcard (vcard_str);
-
+
}
gboolean
e_book_backend_cache_remove_contact (EBookBackendCache *cache,
const char *uid)
-
+
{
gboolean retval;
EBookBackendCachePrivate *priv;
*
* Return value: %TRUE if the cache contains the contact, %FALSE otherwise.
**/
-gboolean
+gboolean
e_book_backend_cache_check_contact (EBookBackendCache *cache, const char *uid)
{
priv = cache->priv;
retval = FALSE;
- if (e_file_cache_get_object (E_FILE_CACHE (cache), uid))
+ if (e_file_cache_get_object (E_FILE_CACHE (cache), uid))
retval = TRUE;
return retval;
}
if (!sexp)
return NULL;
}
-
+
lcache = l = e_file_cache_get_objects (E_FILE_CACHE (cache));
else
g_object_unref (contact);
}
-
+
}
if (lcache)
g_slist_free (lcache);
{
GList *matching_contacts, *temp;
GPtrArray *ptr_array;
-
+
matching_contacts = e_book_backend_cache_get_contacts (cache, query);
ptr_array = g_ptr_array_new ();
-
+
temp = matching_contacts;
for (; matching_contacts != NULL; matching_contacts = g_list_next (matching_contacts)) {
g_ptr_array_add (ptr_array, e_contact_get (matching_contacts->data, E_CONTACT_UID));
g_object_unref (matching_contacts->data);
}
g_list_free (temp);
-
+
return ptr_array;
}
*
* Return value: %TRUE if cache exists, %FALSE if not.
**/
-gboolean
+gboolean
e_book_backend_cache_exists (const char *uri)
{
char *file_name;
gboolean exists = FALSE;
file_name = get_filename_from_uri (uri);
-
+
if (file_name && g_file_test (file_name, G_FILE_TEST_EXISTS)) {
exists = TRUE;
g_free (file_name);
}
-
+
return exists;
}
* e_book_backend_cache_set_populated:
* @cache: an #EBookBackendCache
*
- * Flags @cache as being populated - that is, it is up-to-date on the
+ * Flags @cache as being populated - that is, it is up-to-date on the
* contents of the book it's caching.
**/
void
{
g_return_if_fail (E_IS_BOOK_BACKEND_CACHE (cache));
e_file_cache_add_object (E_FILE_CACHE (cache), "populated", "TRUE");
-
+
}
/**
g_return_val_if_fail (E_IS_BOOK_BACKEND_CACHE (cache), FALSE);
if (e_file_cache_get_object (E_FILE_CACHE (cache), "populated"))
return TRUE;
- return FALSE;
+ return FALSE;
}
void
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* A class to cache address book conents on local file system
- *
+ *
* Copyright (C) 2004 Novell, Inc.
*
* Authors: Sivaiah Nallagatla <snallagatla@ximian.com>
#include "e-book-backend.h"
#include "e-book-backend-sexp.h"
-void
+void
string_to_dbt(const char *str, DBT *dbt)
{
memset(dbt, 0, sizeof(dbt));
* Set the filename for db cacahe file.
**/
-void
+void
e_book_backend_db_cache_set_filename(DB *db, const char *filename)
{
DBT uid_dbt, vcard_dbt;
if (db_error != 0) {
g_warning ("db->put failed with %d", db_error);
}
-
+
}
/**
string_to_dbt ("filename", &uid_dbt);
memset (&vcard_dbt, 0 , sizeof(vcard_dbt));
vcard_dbt.flags = DB_DBT_MALLOC;
-
+
db_error = db->get (db, NULL, &uid_dbt, &vcard_dbt, 0);
if (db_error != 0) {
g_warning ("db-<get failed with %d", db_error);
string_to_dbt (uid, &uid_dbt);
memset (&vcard_dbt, 0 , sizeof(vcard_dbt));
vcard_dbt.flags = DB_DBT_MALLOC;
-
+
db_error = db->get (db, NULL, &uid_dbt, &vcard_dbt,0);
- if (db_error != 0) {
+ if (db_error != 0) {
g_warning ("db->get failed with %d", db_error);
return NULL;
}
-
+
contact = e_contact_new_from_vcard ((const char *)vcard_dbt.data);
g_free (vcard_dbt.data);
return contact;
printf("name:%s, email:%s\n",
(char*)e_contact_get (contact, E_CONTACT_GIVEN_NAME),
(char*)e_contact_get (contact, E_CONTACT_EMAIL_1));
- return FALSE;
+ return FALSE;
}
string_to_dbt (uid, &uid_dbt);
-
+
vcard_str = e_vcard_to_string (E_VCARD(contact), EVC_FORMAT_VCARD_30);
string_to_dbt (vcard_str, &vcard_dbt);
g_free (vcard_str);
- if (db_error != 0) {
+ if (db_error != 0) {
g_warning ("db->put failed with %d", db_error);
return FALSE;
}
- else
+ else
return TRUE;
}
gboolean
e_book_backend_db_cache_remove_contact (DB *db,
const char *uid)
-
+
{
DBT uid_dbt;
int db_error;
string_to_dbt (uid, &uid_dbt);
db_error = db->del (db, NULL, &uid_dbt, 0);
- if (db_error != 0) {
+ if (db_error != 0) {
g_warning ("db->del failed with %d", db_error);
return FALSE;
}
- else
+ else
return TRUE;
}
*
* Return value: %TRUE if the cache contains the contact, %FALSE otherwise.
**/
-gboolean
+gboolean
e_book_backend_db_cache_check_contact (DB *db, const char *uid)
{
DBT uid_dbt, vcard_dbt;
string_to_dbt (uid, &uid_dbt);
memset (&vcard_dbt, 0 , sizeof(vcard_dbt));
vcard_dbt.flags = DB_DBT_MALLOC;
-
+
db_error = db->get (db, NULL, &uid_dbt, &vcard_dbt,0);
- if (db_error != 0)
+ if (db_error != 0)
return FALSE;
else {
free (vcard_dbt.data);
}
db_error = db->cursor (db, NULL, &dbc, 0);
- if (db_error != 0) {
+ if (db_error != 0) {
g_warning ("db->cursor failed with %d", db_error);
return NULL;
}
db_error = dbc->c_close (dbc);
if(db_error != 0)
g_warning ("db->c_close failed with %d", db_error);
-
+
if (sexp)
g_object_unref (sexp);
{
GList *matching_contacts, *temp;
GPtrArray *ptr_array;
-
+
matching_contacts = e_book_backend_db_cache_get_contacts (db, query);
ptr_array = g_ptr_array_new ();
-
+
temp = matching_contacts;
for (; matching_contacts != NULL; matching_contacts = g_list_next (matching_contacts)) {
g_ptr_array_add (ptr_array, e_contact_get (matching_contacts->data, E_CONTACT_UID));
g_object_unref (matching_contacts->data);
}
g_list_free (temp);
-
+
return ptr_array;
}
*
* Return value: %TRUE if cache exists, %FALSE if not.
**/
-gboolean
+gboolean
e_book_backend_db_cache_exists (const char *uri)
{
char *file_name;
gboolean exists = FALSE;
file_name = get_filename_from_uri (uri);
-
+
if (file_name && g_file_test (file_name, G_FILE_TEST_EXISTS))
exists = TRUE;
* e_book_backend_db_cache_set_populated:
* @backend: an #EBookBackend
*
- * Flags @cache as being populated - that is, it is up-to-date on the
+ * Flags @cache as being populated - that is, it is up-to-date on the
* contents of the book it's caching.
**/
void
string_to_dbt ("populated", &uid_dbt);
string_to_dbt ("TRUE", &vcard_dbt);
db_error = db->put (db, NULL, &uid_dbt, &vcard_dbt, 0);
- if (db_error != 0) {
+ if (db_error != 0) {
g_warning ("db->put failed with %d", db_error);
}
-
+
}
/**
{
DBT uid_dbt, vcard_dbt;
int db_error;
-
+
string_to_dbt ("populated", &uid_dbt);
memset(&vcard_dbt, 0, sizeof(vcard_dbt));
vcard_dbt.flags = DB_DBT_MALLOC;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- *
+/*
+ *
* Copyright (C) 2004 Novell, Inc.
*
* Authors: Devashish Sharma <sdevashish@novell.com>
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* pas-backend-card-sexp.c
* Copyright 1999, 2000, 2001, Ximian, Inc.
*
break;
}
}
-
+
g_list_foreach (aims, (GFunc)g_free, NULL);
g_list_free (aims);
name = e_contact_get_const (contact, E_CONTACT_FAMILY_NAME);
if (name && compare (name, str))
return TRUE;
-
+
name = e_contact_get_const (contact, E_CONTACT_GIVEN_NAME);
if (name && compare (name, str))
return TRUE;
compare_address (EContact *contact, const char *str,
char *(*compare)(const char*, const char*))
{
-
+
int i;
gboolean rv = FALSE;
(address->street && compare(address->street, str)) ||
(address->ext && compare(address->ext, str)) ||
(address->locality && compare(address->locality, str)) ||
- (address->region && compare(address->region, str)) ||
+ (address->region && compare(address->region, str)) ||
(address->code && compare(address->code, str)) ||
(address->country && compare(address->country, str));
-
+
e_contact_address_free (address);
-
+
if (rv)
break;
}
}
return rv;
-
+
}
static gboolean
if (any_field
|| !strcmp (prop_info_table[i].query_prop, propname)) {
info = &prop_info_table[i];
-
+
if (any_field && info->field_id == E_CONTACT_UID) {
/* We need to skip UID from any field contains search
- * any-field search should be supported for the
+ * any-field search should be supported for the
* visible fields only.
*/
truth = FALSE;
else if (info->prop_type == PROP_TYPE_NORMAL) {
const char *prop = NULL;
/* straight string property matches */
-
+
prop = e_contact_get_const (ctx->contact, info->field_id);
if (prop && compare(prop, argv[1]->value.string)) {
break;
}
}
-
+
}
r = e_sexp_result_new(f, ESEXP_RES_BOOL);
r->value.bool = truth;
for (i = 0; i < G_N_ELEMENTS (prop_info_table); i ++) {
if (!strcmp (prop_info_table[i].query_prop, propname)) {
info = &prop_info_table[i];
-
+
if (info->prop_type == PROP_TYPE_NORMAL) {
const char *prop = NULL;
/* searches where the query's property
maps directly to an ecard property */
-
+
prop = e_contact_get_const (ctx->contact, info->field_id);
if (prop && *prop)
break;
}
}
-
+
}
r = e_sexp_result_new(f, ESEXP_RES_BOOL);
r->value.bool = truth;
}
}
}
-
+
r = e_sexp_result_new(f, ESEXP_RES_BOOL);
r->value.bool = truth;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* pas-backend-card-sexp.h
* Copyright 2000, 2001, Ximian, Inc.
*
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* pas-backend-summary.c
* Copyright 2000, 2001, Ximian, Inc.
*
{
EBookBackendSummaryItem *new_item;
int i;
-
+
clear_items (summary);
if (!e_book_backend_summary_open (summary))
/* ID normally should not be NULL for a contact. */
/* Added this check as groupwise server sometimes returns
- * contacts with NULL id
+ * contacts with NULL id
*/
id = e_contact_get (contact, E_CONTACT_UID);
if (!id) {
g_warning ("failed to flush summary file to disk");
return TRUE; /* try again after the next timeout */
}
-
+
g_message ("Flushed summary to disk");
-
+
/* we only want this to execute once, so return FALSE and set
summary->flush_timeout to 0 */
summary->priv->flush_timeout = 0;
r = e_sexp_result_new(f, ESEXP_RES_BOOL);
r->value.bool = truth;
-
+
return r;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* pas-backend-summary.h
* Copyright 2000, 2001, Ximian, Inc.
*
* @opid: the unique ID of the operation
* @vcard: the string representation of a contact
* @contact: a pointer to a location to store the resulting #EContact
- *
+ *
* Modifies the contact specified by the ID embedded in @vcard, to
* reflect the full contents of @vcard.
*
*
* Gets a list of contacts from @book. The list and its elements must be freed
* by the caller.
- *
+ *
* Return value: An #EBookBackendSyncStatus indicating the outcome of the operation.
**/
EBookBackendSyncStatus
g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
g_return_val_if_fail (fields, GNOME_Evolution_Addressbook_OtherError);
-
+
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_required_fields_sync);
return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_required_fields_sync) (backend, book, opid, fields);
g_return_val_if_fail (E_IS_BOOK_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError);
g_return_val_if_fail (E_IS_DATA_BOOK (book), GNOME_Evolution_Addressbook_OtherError);
g_return_val_if_fail (fields, GNOME_Evolution_Addressbook_OtherError);
-
+
g_assert (E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_supported_fields_sync);
return (* E_BOOK_BACKEND_SYNC_GET_CLASS (backend)->get_supported_fields_sync) (backend, book, opid, fields);
/**
* e_book_backend_get_source:
* @backend: An addressbook backend.
- *
+ *
* Queries the source that an addressbook backend is serving.
- *
+ *
* Return value: ESource for the backend.
**/
ESource *
*/
if (!backend->priv->clients)
last_client_gone (backend);
-
+
g_mutex_unlock (backend->priv->clients_mutex);
g_object_unref (backend);
if (!backend->priv->clients) {
g_mutex_unlock (backend->priv->clients_mutex);
-
+
return FALSE;
}
-
+
for (l = backend->priv->clients; l; l = l->next) {
if (ORBit_small_get_connection_status (e_data_book_get_listener (l->data)) != ORBIT_CONNECTION_IN_PROC) {
g_mutex_unlock (backend->priv->clients_mutex);
-
+
return TRUE;
}
}
-
+
g_mutex_unlock (backend->priv->clients_mutex);
/* If we get here, all remaining clients are in proc */
e_book_backend_get_static_capabilities (EBookBackend *backend)
{
g_return_val_if_fail (E_IS_BOOK_BACKEND (backend), NULL);
-
+
g_assert (E_BOOK_BACKEND_GET_CLASS (backend)->get_static_capabilities);
return E_BOOK_BACKEND_GET_CLASS (backend)->get_static_capabilities (backend);
e_book_backend_is_writable (EBookBackend *backend)
{
g_return_val_if_fail (E_IS_BOOK_BACKEND (backend), FALSE);
-
+
return backend->priv->writable;
}
e_book_backend_set_is_writable (EBookBackend *backend, gboolean is_writable)
{
g_return_if_fail (E_IS_BOOK_BACKEND (backend));
-
+
backend->priv->writable = is_writable;
}
e_book_backend_is_removed (EBookBackend *backend)
{
g_return_val_if_fail (E_IS_BOOK_BACKEND (backend), FALSE);
-
+
return backend->priv->removed;
}
e_book_backend_set_is_removed (EBookBackend *backend, gboolean is_removed)
{
g_return_if_fail (E_IS_BOOK_BACKEND (backend));
-
+
backend->priv->removed = is_removed;
}
* Sets @backend's online/offline mode to @mode. Mode can be 1 for offline
* or 2 indicating that it is connected and online.
**/
-void
+void
e_book_backend_set_mode (EBookBackend *backend,
GNOME_Evolution_Addressbook_BookMode mode)
{
g_assert (E_BOOK_BACKEND_GET_CLASS (backend)->set_mode);
- (* E_BOOK_BACKEND_GET_CLASS (backend)->set_mode) (backend, mode);
+ (* E_BOOK_BACKEND_GET_CLASS (backend)->set_mode) (backend, mode);
}
* circumstances (for example before a live backup) and should not be used in
* normal use.
*/
-void
+void
e_book_backend_sync (EBookBackend *backend)
{
g_return_if_fail (E_IS_BOOK_BACKEND (backend));
-
+
if (E_BOOK_BACKEND_GET_CLASS (backend)->sync)
(* E_BOOK_BACKEND_GET_CLASS (backend)->sync) (backend);
}
*
* Notifies all backends clients about the current writable state.
**/
-void
+void
e_book_backend_notify_writable (EBookBackend *backend, gboolean is_writable)
{
EBookBackendPrivate *priv;
GList *clients;
-
+
priv = backend->priv;
priv->writable = is_writable;
g_mutex_lock (priv->clients_mutex);
-
+
for (clients = priv->clients; clients != NULL; clients = g_list_next (clients))
e_data_book_report_writable (E_DATA_BOOK (clients->data), is_writable);
* Notifies clients of @backend's connection status indicated by @is_online.
* Meant to be used by backend implementations.
**/
-void
+void
e_book_backend_notify_connection_status (EBookBackend *backend, gboolean is_online)
{
EBookBackendPrivate *priv;
GList *clients;
-
+
priv = backend->priv;
priv->online = is_online;
g_mutex_lock (priv->clients_mutex);
-
+
for (clients = priv->clients; clients != NULL; clients = g_list_next (clients))
e_data_book_report_connection_status (E_DATA_BOOK (clients->data), is_online);
{
EBookBackendPrivate *priv;
GList *clients;
-
+
priv = backend->priv;
g_mutex_lock (priv->clients_mutex);
-
+
for (clients = priv->clients; clients != NULL; clients = g_list_next (clients))
e_data_book_report_auth_required (E_DATA_BOOK (clients->data));
g_mutex_unlock (priv->clients_mutex);
void e_book_backend_notify_complete (EBookBackend *backend);
void e_book_backend_notify_writable (EBookBackend *backend, gboolean is_writable);
void e_book_backend_notify_connection_status (EBookBackend *backend, gboolean is_online);
-void e_book_backend_notify_auth_required (EBookBackend *backend);
+void e_book_backend_notify_auth_required (EBookBackend *backend);
void e_book_backend_sync (EBookBackend *backend);
GType e_book_backend_get_type (void);
/**
* e_data_book_factory_get_n_backends:
* @factory: An addressbook factory.
- *
+ *
* Queries the number of running addressbook backends in an addressbook factory.
- *
+ *
* Return value: Number of running backends.
**/
int
{
int n_backends;
gboolean out_of_proc = FALSE;
-
+
g_return_val_if_fail (factory != NULL, -1);
g_return_val_if_fail (E_IS_DATA_BOOK_FACTORY (factory), -1);
backend_factory = g_hash_table_lookup (factory->priv->backends, proto);
- g_free (proto);
+ g_free (proto);
g_free (canonical_uri);
return backend_factory;
EBookBackendFactory* backend_factory;
backend_factory = e_data_book_factory_lookup_backend_factory (factory, uri);
-
+
if (backend_factory == NULL) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_Addressbook_BookFactory_ProtocolNotSupported,
g_static_mutex_unlock (&mutex);
factory = g_object_new (E_TYPE_DATA_BOOK_FACTORY, "poa", poa, NULL);
-
+
e_data_book_factory_construct (factory);
return factory;
set_backend_online_status (gpointer key, gpointer value, gpointer data)
{
EBookBackend *backend;
-
+
backend = E_BOOK_BACKEND (value);
e_book_backend_set_mode (backend, GPOINTER_TO_INT (data));
}
e_data_book_factory_set_backend_mode (EDataBookFactory *factory, int mode)
{
EDataBookFactoryPrivate *priv = factory->priv;
-
-
+
+
g_mutex_lock (priv->map_mutex);
priv->mode = mode;
g_hash_table_foreach (priv->active_server_map, set_backend_online_status, GINT_TO_POINTER (priv->mode));
g_mutex_unlock (book_view->priv->pending_mutex);
return;
}
-
+
currently_in_view =
g_hash_table_lookup (book_view->priv->ids, id) != NULL;
want_in_view = e_book_backend_sexp_match_contact (
gboolean currently_in_view, want_in_view;
const char *id = NULL;
EContact *contact;
-
+
g_mutex_lock (book_view->priv->pending_mutex);
-
+
contact = e_contact_new_from_vcard (vcard);
id = e_contact_get_const (contact, E_CONTACT_UID);
if (!id) {
g_mutex_unlock (book_view->priv->pending_mutex);
return;
}
-
+
currently_in_view =
g_hash_table_lookup (book_view->priv->ids, id) != NULL;
want_in_view =
e_book_backend_sexp_match_contact (book_view->priv->card_sexp, contact);
-
+
if (want_in_view) {
if (currently_in_view)
notify_change (book_view, vcard);
if (currently_in_view)
notify_remove (book_view, id);
}
-
+
g_free (vcard);
g_object_unref (contact);
g_mutex_unlock (book_view->priv->pending_mutex);
e_data_book_view_notify_update_prefiltered_vcard (EDataBookView *book_view, const char *id, char *vcard)
{
gboolean currently_in_view;
-
+
g_mutex_lock (book_view->priv->pending_mutex);
-
+
currently_in_view =
g_hash_table_lookup (book_view->priv->ids, id) != NULL;
-
+
if (currently_in_view)
notify_change (book_view, vcard);
else
if (g_hash_table_lookup (book_view->priv->ids, id))
notify_remove (book_view, id);
-
+
g_mutex_unlock (book_view->priv->pending_mutex);
}
/**
* e_data_book_view_get_max_results:
* @book_view: an #EDataBookView
- *
+ *
* Gets the maximum number of results returned by
* @book_view's query.
*
* @backend: an #EBookBackend to view
* @listener: a CORBA listener to reveive notifications
* @card_query: an s-expression representing the query
- * @card_sexp:
+ * @card_sexp:
* @max_results: the maximum number of results for the query
*
* Return value: A new #EDataBookView.
g_static_mutex_unlock (&mutex);
book_view = g_object_new (E_TYPE_DATA_BOOK_VIEW, "poa", poa, NULL);
-
+
e_data_book_view_construct (book_view, backend, listener, card_query, card_sexp, max_results);
return book_view;
}
if (G_OBJECT_CLASS (e_data_book_view_parent_class)->dispose)
- G_OBJECT_CLASS (e_data_book_view_parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_data_book_view_parent_class)->dispose (object);
}
static void
EDataBook *book = E_DATA_BOOK (bonobo_object (servant));
int i;
GList *id_list = NULL;
-
+
for (i = 0; i < ids->_length; i ++)
id_list = g_list_append (id_list, ids->_buffer[i]);
}
e_book_backend_add_book_view (backend, view);
-
+
e_data_book_respond_get_book_view (book, opid, GNOME_Evolution_Addressbook_Success, view);
}
EDataBook *book = E_DATA_BOOK (bonobo_object (servant));
e_book_backend_get_required_fields (e_data_book_get_backend (book), book, opid);
-
+
}
static void
* Notify listeners that @book's online status has changed
* to @is_online.
**/
-void
+void
e_data_book_report_connection_status (EDataBook *book,
gboolean is_online)
{
GNOME_Evolution_Addressbook_BookListener_notifyConnectionStatus (
book->priv->listener, (CORBA_boolean) is_online, &ev);
-
+
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("e_data_book_report_connection_status: Exception "
"responding to BookListener!\n");
*
* Notify listeners that @book requires authentication.
**/
-void
+void
e_data_book_report_auth_required (EDataBook *book)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
-
+
GNOME_Evolution_Addressbook_BookListener_notifyAuthRequired (
book->priv->listener, &ev);
-
+
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("e_data_book_report_auth_required: Exception "
"responding to BookListener!\n");
CORBA_exception_free (&ev);
}
-
+
static void
e_data_book_construct (EDataBook *book,
EBookBackend *backend,
epv->getBookView = impl_GNOME_Evolution_Addressbook_Book_getBookView;
epv->getChanges = impl_GNOME_Evolution_Addressbook_Book_getChanges;
epv->cancelOperation = impl_GNOME_Evolution_Addressbook_Book_cancelOperation;
-
+
}
static void
printf ("failed\n");
else
printf ("passed\n");
-
+
return 0;
}
for (l = (GList*)ids; l; l = l->next) {
printf ("Removed contact: %s\n", (char*)l->data);
- }
+ }
}
static void
sequence_complete (EBookView *book_view, EBookViewStatus status)
{
printf ("sequence_complete (status == %d)\n", status);
-
+
g_main_loop_quit (loop);
}
gboolean status;
g_type_init ();
-
+
/*
** the actual ebook foo
*/
#include <libebook/e-book.h>
-int main (int argc, char **argv)
+int main (int argc, char **argv)
{
GError *err = NULL;
EBook *book = NULL;
/* then get the photo */
new_photo = e_contact_get (contact, E_CONTACT_PHOTO);
-
+
/* and compare */
if (new_photo->data.inlined.length != photo->data.inlined.length)
g_error ("photo lengths differ");
-
+
if (memcmp (new_photo->data.inlined.data, photo->data.inlined.data, photo->data.inlined.length))
g_error ("photo data differs");
printf ("photo test passed\n");
-
+
return 0;
}
#include <string.h>
#include <libebook/e-book.h>
-#define QUERY_STRING1
-#define QUERY_STRING2
+#define QUERY_STRING1
+#define QUERY_STRING2
static char* queries[] = {
"(exists \"full_name\")",
for (i = 0; i < G_N_ELEMENTS (queries); i ++) {
EBookQuery *query = e_book_query_from_string (queries[i]);
char *str;
-
+
str = e_book_query_to_string (query);
if (strcmp (str, queries[i])) {
for (l = (GList*)ids; l; l = l->next) {
printf ("Removed contact: %s\n", (char*)l->data);
- }
+ }
}
static void
printf ("passed\n");
else
printf ("failed\n");
-
+
return 0;
}
phone = e_contact_get_const (contact, E_CONTACT_PHONE_OTHER_FAX);
if (phone) printf ("other fax: %s\n", phone);
check (phone && !strcmp ("321-321-4321", phone), "other fax");
-
+
return 0;
}
ESource *source;
char *group_name;
char *ruri;
-
+
source_list = e_source_list_new_for_gconf (conf_client, conf_key);
group = e_source_list_peek_group_by_name (source_list, "CalDAV");
-
+
if (group == NULL) {
group = e_source_group_new ("CalDAV", "caldav://");
- e_source_list_add_group (source_list, group, -1);
+ e_source_list_add_group (source_list, group, -1);
}
-
+
ruri = g_strdup_printf ("%s/%s", hostname, arg_path);
source = e_source_new (arg_path, ruri);
e_source_set_property (source, "auth", "1");
e_source_set_property (source, "username", username);
e_source_group_add_source (group, source, -1);
-
+
e_source_list_sync (source_list, NULL);
g_object_unref (source);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Author: Christian Kellner <gicmo@gnome.org>
+ * Author: Christian Kellner <gicmo@gnome.org>
*/
#ifdef HAVE_CONFIG_H
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Author: Christian Kellner <gicmo@gnome.org>
+ * Author: Christian Kellner <gicmo@gnome.org>
*/
#ifndef E_CAL_BACKEND_CALDAV_FACTORY_H
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Author: Christian Kellner <gicmo@gnome.org>
+ * Author: Christian Kellner <gicmo@gnome.org>
*/
#include <config.h>
/* LibXML2 includes */
#include <libxml/parser.h>
#include <libxml/tree.h>
-#include <libxml/xpath.h>
+#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
/* LibSoup includes */
/* Private part of the ECalBackendHttp structure */
struct _ECalBackendCalDAVPrivate {
-
+
/* online/offline */
CalMode mode;
/* should we sync for offline mode? */
gboolean do_offline;
-
+
/* TRUE after caldav_open */
gboolean loaded;
/* the open status */
ECalBackendSyncStatus ostatus;
-
+
/* lock to protect cache */
GMutex *lock;
SlaveCommand slave_cmd;
GTimeVal refresh_time;
gboolean do_synch;
-
+
/* The main soup session */
SoupSession *session;
/* well, guess what */
gboolean read_only;
- /* whehter the synch function
+ /* whehter the synch function
* should report changes to the
* backend */
gboolean report_changes;
- /* clandar uri */
+ /* clandar uri */
char *uri;
/* Authentication info */
g_hash_table_insert (caldav_debug_table,
debug_key,
debug_value);
-
+
g_debug ("Adding %s to enabled debugging keys", debug_key);
}
while (*ptr != '\0') {
if (*ptr == ',' || *ptr == ':') {
-
+
add_debug_key (dbg, ptr);
if (*ptr == ',') {
caldav_debug_table = NULL;
}
}
-
+
return NULL;
}
caldav_debug_init ()
{
static GOnce debug_once = G_ONCE_INIT;
-
+
g_once (&debug_once,
caldav_debug_init_once,
NULL);
return TRUE;
}
- return FALSE;
+ return FALSE;
}
static void
if (msg->response.length) {
char *body;
- //needed for null terminal and truncation
+ //needed for null terminal and truncation
body = g_strndup (msg->response.body,
MIN (msg->response.length,
DEBUG_MAX_BODY_SIZE));
if (msg->request.length) {
char *body;
- //needed for null terminal and truncation
+ //needed for null terminal and truncation
body = g_strndup (msg->request.body,
MIN (msg->request.length,
DEBUG_MAX_BODY_SIZE));
/* ************************************************************************* */
/* Misc. utility functions */
-#define X_E_CALDAV "X-EVOLUTION-CALDAV-"
+#define X_E_CALDAV "X-EVOLUTION-CALDAV-"
static void
icomp_x_prop_set (icalcomponent *comp, const char *key, const char *value)
while (xprop) {
const char *str = icalproperty_get_x_name (xprop);
-
+
if (!strcmp (str, key)) {
icalcomponent_remove_property (comp, xprop);
icalproperty_free (xprop);
}
/* couldnt we be a bit smarter here and reuse the property? */
-
+
xprop = icalproperty_new_x (value);
icalproperty_set_x_name (xprop, key);
icalcomponent_add_property (comp, xprop);
icomp_x_prop_get (icalcomponent *comp, const char *key)
{
icalproperty *xprop;
-
+
/* Find the old one first */
xprop = icalcomponent_get_first_property (comp, ICAL_X_PROPERTY);
while (xprop) {
const char *str = icalproperty_get_x_name (xprop);
-
+
if (!strcmp (str, key)) {
break;
}
}
if (xprop) {
- return icalproperty_get_value_as_string (xprop);
+ return icalproperty_get_value_as_string (xprop);
}
-
+
return NULL;
}
icalcomponent *icomp;
icomp = e_cal_component_get_icalcomponent (comp);
-
+
icomp_x_prop_set (icomp, X_E_CALDAV "HREF", href);
}
{
icalcomponent *icomp;
char *str;
-
+
str = NULL;
icomp = e_cal_component_get_icalcomponent (comp);
-
+
str = (char *) icomp_x_prop_get (icomp, X_E_CALDAV "HREF");
-
+
return str;
}
icalcomponent *icomp;
icomp = e_cal_component_get_icalcomponent (comp);
-
+
icomp_x_prop_set (icomp, X_E_CALDAV "ETAG", etag);
{
icalcomponent *icomp;
char *str;
-
+
str = NULL;
icomp = e_cal_component_get_icalcomponent (comp);
-
+
str = (char *) icomp_x_prop_get (icomp, X_E_CALDAV "ETAG");
-
+
return str;
}
typedef enum {
-
+
/* object is in synch,
* now isnt that ironic? :) */
E_CAL_COMPONENT_IN_SYNCH = 0,
-
+
/* local changes */
E_CAL_COMPONENT_LOCALLY_CREATED,
E_CAL_COMPONENT_LOCALLY_DELETED,
- E_CAL_COMPONENT_LOCALLY_MODIFIED,
+ E_CAL_COMPONENT_LOCALLY_MODIFIED,
} ECalComponentSyncState;
/* oos = out of synch */
static void
-e_cal_component_set_synch_state (ECalComponent *comp,
+e_cal_component_set_synch_state (ECalComponent *comp,
ECalComponentSyncState state)
{
icalcomponent *icomp;
char *state_string;
-
+
icomp = e_cal_component_get_icalcomponent (comp);
-
+
state_string = g_strdup_printf ("%d", state);
-
+
icomp_x_prop_set (icomp, X_E_CALDAV "ETAG", state_string);
g_free (state_string);
}
-/* gen uid, set it internally and report it back so we can instantly
- * use it
+/* gen uid, set it internally and report it back so we can instantly
+ * use it
* and btw FIXME!!! */
static char *
e_cal_component_gen_href (ECalComponent *comp)
href = g_strconcat (iso, ".ics", NULL);
- g_free (iso);
-
- icomp = e_cal_component_get_icalcomponent (comp);
+ g_free (iso);
+
+ icomp = e_cal_component_get_icalcomponent (comp);
icomp_x_prop_set (icomp, X_E_CALDAV "HREF", href);
- return href;
-}
+ return href;
+}
/* ensure etag is quoted (to workaround potential server bugs) */
static char *
} else {
ret = g_strdup (etag);
}
-
+
return ret;
}
char *str;
char **sa;
char *tofree;
-
- sa = NULL;
+
+ sa = NULL;
list = soup_message_get_header_list (message->response_headers, header);
-
+
if (list == NULL || list->data == NULL) {
return NULL;
}
- /* Only do string manipulation if really necessary */
+ /* Only do string manipulation if really necessary */
if (list->next) {
- GString *stmp;
+ GString *stmp;
stmp = g_string_new ((gchar *) list->data);
-
+
while ((list = list->next)) {
g_string_append_printf (stmp, ",%s", (gchar *) list->data);
}
-
+
str = tofree = g_string_free (stmp, FALSE);
} else {
str = (char *) list->data;
g_assert (str != NULL);
sa = g_strsplit (str, ",", 20);
g_free (tofree);
-
+
return sa;
}
status_code_to_result (guint status_code)
{
ECalBackendSyncStatus result;
-
+
if (SOUP_STATUS_IS_SUCCESSFUL (status_code)) {
return GNOME_Evolution_Calendar_Success;
}
-
+
switch (status_code) {
case 404:
case 401:
result = GNOME_Evolution_Calendar_AuthenticationRequired;
break;
-
+
default:
result = GNOME_Evolution_Calendar_OtherError;
}
return result;
}
-
+
static gboolean
match_header (const char *header, const char *string)
{
g_assert (string != NULL);
-
+
if (header == NULL || header[0] == '\0') {
return FALSE;
}
-
+
/* skip leading whitespaces */
while (g_ascii_isspace (header[0])) {
header++;
check_state (ECalBackendCalDAV *cbdav, gboolean *online)
{
ECalBackendCalDAVPrivate *priv;
-
+
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
*online = FALSE;
-
+
if (priv->loaded != TRUE) {
return GNOME_Evolution_Calendar_OtherError;
}
if (priv->mode == CAL_MODE_LOCAL) {
-
+
if (! priv->do_offline) {
return GNOME_Evolution_Calendar_RepositoryOffline;
- }
-
+ }
+
} else {
- *online = TRUE;
+ *online = TRUE;
}
return GNOME_Evolution_Calendar_Success;
char *expr;
if (ctx == NULL) {
- return NULL;
- }
+ return NULL;
+ }
va_start (args, format);
expr = g_strdup_vprintf (format, args);
va_end (args);
-
+
result = xmlXPathEvalExpression ((xmlChar *) expr, ctx);
g_free (expr);
-
+
if (result == NULL) {
- return NULL;
+ return NULL;
}
-
- if (result->type == XPATH_NODESET &&
+
+ if (result->type == XPATH_NODESET &&
xmlXPathNodeSetIsEmpty (result->nodesetval)) {
xmlXPathFreeObject (result);
-
+
g_print ("No result\n");
-
+
return NULL;
}
-
+
return result;
}
#if 0
-static gboolean
+static gboolean
parse_status_node (xmlNodePtr node, guint *status_code)
{
xmlChar *content;
content = xmlNodeGetContent (node);
- res = soup_headers_parse_status_line ((char *) content,
+ res = soup_headers_parse_status_line ((char *) content,
NULL,
status_code,
NULL);
xp_object_get_string (xmlXPathObjectPtr result)
{
char *ret;
-
+
if (result == NULL || result->type != XPATH_STRING) {
- return NULL;
+ return NULL;
}
-
+
ret = g_strdup ((char *) result->stringval);
-
+
xmlXPathFreeObject (result);
return ret;
}
char *val;
if (result == NULL || result->type != XPATH_STRING) {
- return NULL;
+ return NULL;
}
val = (char *) result->stringval;
ret = g_strdup (ret);
g_debug ("found href: %s", ret);
-
+
xmlXPathFreeObject (result);
return ret;
}
{
char *ret;
char *str;
-
+
if (result == NULL || result->type != XPATH_STRING) {
- return NULL;
+ return NULL;
}
str = (char *) result->stringval;
ret = quote_etag (str);
-
+
xmlXPathFreeObject (result);
return ret;
}
{
gboolean res;
guint ret;
-
-
+
+
if (result == NULL || result->type != XPATH_STRING) {
- return 0;
+ return 0;
}
-
- res = soup_headers_parse_status_line ((char *) result->stringval,
+
+ res = soup_headers_parse_status_line ((char *) result->stringval,
NULL,
&ret,
NULL);
-
+
if (res != TRUE) {
- ret = 0;
+ ret = 0;
}
-
+
xmlXPathFreeObject (result);
return ret;
}
xp_object_get_number (xmlXPathObjectPtr result)
{
int ret;
-
+
if (result == NULL || result->type != XPATH_STRING) {
- return -1;
+ return -1;
}
-
+
ret = result->boolval;
-
+
xmlXPathFreeObject (result);
return ret;
}
};
static void
-caldav_object_free (CalDAVObject *object, gboolean free_object_itself)
+caldav_object_free (CalDAVObject *object, gboolean free_object_itself)
{
g_free (object->href);
g_free (object->etag);
g_return_val_if_fail (objs != NULL || len != NULL, FALSE);
res = TRUE;
- doc = xmlReadMemory (soup_message->response.body,
- soup_message->response.length,
- "response.xml",
- NULL,
+ doc = xmlReadMemory (soup_message->response.body,
+ soup_message->response.length,
+ "response.xml",
+ NULL,
0);
if (doc == NULL) {
xpctx = xmlXPathNewContext (doc);
- xmlXPathRegisterNs (xpctx, (xmlChar *) "D",
+ xmlXPathRegisterNs (xpctx, (xmlChar *) "D",
(xmlChar *) "DAV:");
- xmlXPathRegisterNs (xpctx, (xmlChar *) "C",
+ xmlXPathRegisterNs (xpctx, (xmlChar *) "C",
(xmlChar *) "urn:ietf:params:xml:ns:caldav");
- result = xpath_eval (xpctx, "/D:multistatus/D:response");
+ result = xpath_eval (xpctx, "/D:multistatus/D:response");
if (result == NULL || result->type != XPATH_NODESET) {
*len = 0;
n = xmlXPathNodeSetGetLength (result->nodesetval);
*len = n;
-
+
*objs = g_new0 (CalDAVObject, n);
-
+
for (i = 0; i < n; i++) {
CalDAVObject *object;
xmlXPathObjectPtr xpres;
-
+
object = *objs + i;
/* see if we got a status child in the response element */
object->status = xp_object_get_status (xpres);
if (object->status != 200) {
- continue;
+ continue;
}
xpres = xpath_eval (xpctx, XPATH_GETETAG, i + 1);
}
out:
- xmlXPathFreeContext (xpctx);
+ xmlXPathFreeContext (xpctx);
xmlFreeDoc (doc);
return res;
}
/* Authentication helpers for libsoup */
static void
-soup_authenticate (SoupSession *session,
+soup_authenticate (SoupSession *session,
SoupMessage *msg,
- const char *auth_type,
+ const char *auth_type,
const char *auth_realm,
- char **username,
- char **password,
+ char **username,
+ char **password,
gpointer data)
{
ECalBackendCalDAVPrivate *priv;
ECalBackendCalDAV *cbdav;
-
- cbdav = E_CAL_BACKEND_CALDAV (data);
+
+ cbdav = E_CAL_BACKEND_CALDAV (data);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
*username = priv->username;
*password = priv->password;
-
+
priv->username = NULL;
priv->password = NULL;
}
static void
-soup_reauthenticate (SoupSession *session,
+soup_reauthenticate (SoupSession *session,
SoupMessage *msg,
- const char *auth_type,
+ const char *auth_type,
const char *auth_realm,
- char **username,
- char **password,
+ char **username,
+ char **password,
gpointer data)
{
ECalBackendCalDAVPrivate *priv;
ECalBackendCalDAV *cbdav;
-
- cbdav = E_CAL_BACKEND_CALDAV (data);
+
+ cbdav = E_CAL_BACKEND_CALDAV (data);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
*username = priv->username;
*password = priv->password;
-
+
priv->username = NULL;
priv->password = NULL;
}
-static gint
+static gint
caldav_ignore_host(gconstpointer a, gconstpointer b)
{
- gchar *hostname = (gchar*)a,
+ gchar *hostname = (gchar*)a,
*ignore = (gchar*)b;
-
+
if (hostname && ignore)
return strcmp(hostname, ignore);
return -1;
}
-static void
+static void
caldav_set_session_proxy(ECalBackendCalDAVPrivate *priv)
{
GConfClient *conf_client;
SoupUri *uri_base;
-
+
if (priv->session == NULL)
return;
-
+
uri_base = soup_uri_new (priv->uri);
if (uri_base == NULL)
return;
-
+
/* set the outbound HTTP proxy, if configuration is set to do so */
conf_client = gconf_client_get_default ();
if (gconf_client_get_bool (conf_client, "/system/http_proxy/use_http_proxy", NULL)) {
char *server, *proxy_uri;
int port;
- GSList *ignore = gconf_client_get_list (conf_client,
+ GSList *ignore = gconf_client_get_list (conf_client,
"/system/http_proxy/ignore_hosts",
- GCONF_VALUE_STRING, NULL);
- if (ignore == NULL ||
+ GCONF_VALUE_STRING, NULL);
+ if (ignore == NULL ||
g_slist_find_custom(ignore, uri_base->host, caldav_ignore_host) == NULL) {
server = gconf_client_get_string (conf_client, "/system/http_proxy/host", NULL);
port = gconf_client_get_int (conf_client, "/system/http_proxy/port", NULL);
gboolean calendar_access;
gboolean put_allowed;
gboolean delete_allowed;
-
+
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
/* FIXME: setup text_uri */
-
+
message = soup_message_new (SOUP_METHOD_OPTIONS, priv->uri);
- soup_message_add_header (message->request_headers,
+ soup_message_add_header (message->request_headers,
"User-Agent", "Evolution/" VERSION);
message_setup_debug (message);
soup_session_send_message (priv->session, message);
-
+
if (! SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
g_object_unref (message);
return status_code_to_result (message->status_code);
}
-
+
/* parse the dav header, we are intreseted in the
* calendar-access bit only at the moment */
sa = sm_join_and_split_header (message, "DAV");
-
+
calendar_access = FALSE;
for (siter = sa; siter && *siter; siter++) {
-
+
if (match_header (*siter, "calendar-access")) {
calendar_access = TRUE;
break;
}
- }
-
+ }
+
g_strfreev (sa);
-
+
sa = sm_join_and_split_header (message, "Allow");
-
- /* parse the Allow header and look for PUT, DELETE at the
+
+ /* parse the Allow header and look for PUT, DELETE at the
* moment (maybe we should check more here, for REPORT eg) */
put_allowed = delete_allowed = FALSE;
for (siter = sa; siter && *siter; siter++) {
if (put_allowed && delete_allowed) {
break;
}
- }
-
+ }
+
g_strfreev (sa);
-
+
g_object_unref (message);
if (calendar_access) {
priv->do_synch = TRUE;
return GNOME_Evolution_Calendar_Success;
}
-
- return GNOME_Evolution_Calendar_NoSuchCal;
+
+ return GNOME_Evolution_Calendar_NoSuchCal;
}
static gboolean
caldav_server_list_objects (ECalBackendCalDAV *cbdav, CalDAVObject **objs, int *len)
-{
+{
ECalBackendCalDAVPrivate *priv;
xmlOutputBufferPtr buf;
SoupMessage *message;
xmlNsPtr nsdav;
xmlNsPtr nscd;
gboolean result;
-
+
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
-
- /* Maybe we should just do a g_strdup_printf here? */
+
+ /* Maybe we should just do a g_strdup_printf here? */
/* Prepare request body */
doc = xmlNewDoc ((xmlChar *) "1.0");
root = xmlNewNode (NULL, (xmlChar *) "calendar-query");
- nscd = xmlNewNs (root, (xmlChar *) "urn:ietf:params:xml:ns:caldav",
+ nscd = xmlNewNs (root, (xmlChar *) "urn:ietf:params:xml:ns:caldav",
(xmlChar *) "C");
xmlSetNs (root, nscd);
-
+
/* Add webdav tags */
nsdav = xmlNewNs (root, (xmlChar *) "DAV:", (xmlChar *) "D");
node = xmlNewTextChild (root, nsdav, (xmlChar *) "prop", NULL);
node = xmlNewTextChild (root, nscd, (xmlChar *) "filter", NULL);
node = xmlNewTextChild (node, nscd, (xmlChar *) "comp-filter", NULL);
xmlSetProp (node, (xmlChar *) "name", (xmlChar *) "VCALENDAR");
-
+
sn = xmlNewTextChild (node, nscd, (xmlChar *) "comp-filter", NULL);
xmlSetProp (sn, (xmlChar *) "name", (xmlChar *) "VEVENT");
/* ^^^ add timerange for performance? */
-
-
+
+
buf = xmlAllocOutputBuffer (NULL);
xmlNodeDumpOutput (buf, doc, root, 0, 1, NULL);
xmlOutputBufferFlush (buf);
/* Prepare the soup message */
message = soup_message_new ("REPORT", priv->uri);
- soup_message_add_header (message->request_headers,
+ soup_message_add_header (message->request_headers,
"User-Agent", "Evolution/" VERSION);
- soup_message_add_header (message->request_headers,
+ soup_message_add_header (message->request_headers,
"Depth", "1");
- soup_message_set_request (message,
+ soup_message_set_request (message,
"application/xml",
SOUP_BUFFER_USER_OWNED,
(char *) buf->buffer->content,
/* Send the request now */
soup_session_send_message (priv->session, message);
-
+
/* Clean up the memory */
xmlOutputBufferClose (buf);
xmlFreeDoc (doc);
g_warning ("Sever did not response with 207\n");
return FALSE;
}
-
+
/* Parse the response body */
result = parse_report_response (message, objs, len);
const char *hdr;
char *uri;
- priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
+ priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
result = GNOME_Evolution_Calendar_Success;
g_assert (object != NULL && object->href != NULL);
-
+
uri = caldav_generate_uri (cbdav, object->href);
message = soup_message_new (SOUP_METHOD_GET, uri);
g_free (uri);
- soup_message_add_header (message->request_headers,
+ soup_message_add_header (message->request_headers,
"User-Agent", "Evolution/" VERSION);
message_setup_debug (message);
soup_session_send_message (priv->session, message);
-
+
if (! SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
result = status_code_to_result (message->status_code);
g_object_unref (message);
}
hdr = soup_message_get_header (message->response_headers, "ETag");
-
+
if (hdr == NULL) {
g_warning ("UUHH no ETag, now that's bad!");
object->etag = NULL;
} else {
object->etag = quote_etag (hdr);
}
-
+
/* Need to NULL terminate the string, do we? */
object->cdata = g_malloc0 (message->response.length + 1);
memcpy (object->cdata, message->response.body, message->response.length);
g_object_unref (message);
-
+
return result;
}
const char *hdr;
char *uri;
- priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
+ priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
result = GNOME_Evolution_Calendar_Success;
hdr = NULL;
-
+
g_assert (object != NULL && object->cdata != NULL);
uri = caldav_generate_uri (cbdav, object->href);
message = soup_message_new (SOUP_METHOD_PUT, uri);
g_free (uri);
- soup_message_add_header (message->request_headers,
+ soup_message_add_header (message->request_headers,
"User-Agent", "Evolution/" VERSION);
/* For new items we use the If-None-Match so we don't
* acidently override resources, for item updates we
- * use the If-Match header to avoid the Lost-update
+ * use the If-Match header to avoid the Lost-update
* problem */
if (object->etag == NULL) {
- soup_message_add_header (message->request_headers,
+ soup_message_add_header (message->request_headers,
"If-None-Match", "*");
} else {
- soup_message_add_header (message->request_headers,
+ soup_message_add_header (message->request_headers,
"If-Match", object->etag);
}
-
- soup_message_set_request (message,
- "text/calendar",
- SOUP_BUFFER_USER_OWNED,
+
+ soup_message_set_request (message,
+ "text/calendar",
+ SOUP_BUFFER_USER_OWNED,
object->cdata,
strlen (object->cdata));
-
+
message_setup_debug (message);
soup_session_send_message (priv->session, message);
/* FIXME: sepcial case precondition errors ?*/
- result = status_code_to_result (message->status_code);
+ result = status_code_to_result (message->status_code);
- if (result == GNOME_Evolution_Calendar_Success) {
+ if (result == GNOME_Evolution_Calendar_Success) {
hdr = soup_message_get_header (message->response_headers,
"ETag");
}
-
+
if (hdr != NULL) {
g_free (object->etag);
object->etag = quote_etag (hdr);
g_warning ("Ups no Etag in put response");
}
-
+
g_object_unref (message);
- return result;
+ return result;
}
static ECalBackendSyncStatus
SoupMessage *message;
char *uri;
- priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
+ priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
result = GNOME_Evolution_Calendar_Success;
-
+
g_assert (object != NULL && object->href != NULL);
uri = caldav_generate_uri (cbdav, object->href);
message = soup_message_new (SOUP_METHOD_DELETE, uri);
g_free (uri);
-
- soup_message_add_header (message->request_headers,
+
+ soup_message_add_header (message->request_headers,
"User-Agent", "Evolution/" VERSION);
if (object->etag != NULL) {
- soup_message_add_header (message->request_headers,
+ soup_message_add_header (message->request_headers,
"If-Match", object->etag);
}
-
+
message_setup_debug (message);
soup_session_send_message (priv->session, message);
-
- result = status_code_to_result (message->status_code);
-
+
+ result = status_code_to_result (message->status_code);
+
g_object_unref (message);
return result;
}
-
+
/* ************************************************************************* */
/* Synchronization foo */
static gboolean
-synchronize_object (ECalBackendCalDAV *cbdav,
+synchronize_object (ECalBackendCalDAV *cbdav,
CalDAVObject *object,
ECalComponent *old_comp)
{
gboolean do_report;
gboolean res;
- comp = NULL;
+ comp = NULL;
res = TRUE;
result = caldav_server_get_object (cbdav, object);
-
+
if (result != GNOME_Evolution_Calendar_Success) {
g_warning ("Could not fetch object from server");
return FALSE;
}
- priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
+ priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
icomp = icalparser_parse_string (object->cdata);
kind = icalcomponent_isa (icomp);
bkend = E_CAL_BACKEND (cbdav);
-
+
if (kind == ICAL_VCALENDAR_COMPONENT) {
-
+
kind = e_cal_backend_get_kind (bkend);
subcomp = icalcomponent_get_first_component (icomp, kind);
comp = e_cal_component_new ();
- res = e_cal_component_set_icalcomponent (comp,
+ res = e_cal_component_set_icalcomponent (comp,
icalcomponent_new_clone (subcomp));
- if (res == TRUE) {
+ if (res == TRUE) {
e_cal_component_set_href (comp, object->href);
e_cal_component_set_etag (comp, object->etag);
} else {
g_object_unref (comp);
comp = NULL;
}
-
+
} else {
- res = FALSE;
+ res = FALSE;
}
-
+
icalcomponent_free (icomp);
if (res == FALSE) {
return res;
}
-
+
bcache = priv->cache;
do_report = priv->report_changes;
-
- if ((res = e_cal_backend_cache_put_component (bcache, comp))
+
+ if ((res = e_cal_backend_cache_put_component (bcache, comp))
&& do_report) {
char *new_cs = NULL;
char *old_cs = NULL;
e_cal_backend_notify_object_created (bkend, new_cs);
} else {
old_cs = e_cal_component_get_as_string (old_comp);
- e_cal_backend_notify_object_modified (bkend, old_cs, new_cs);
+ e_cal_backend_notify_object_modified (bkend, old_cs, new_cs);
}
-
+
g_free (new_cs);
g_free (old_cs);
}
g_object_unref (comp);
-
+
return res;
}
#define etags_match(_tag1, _tag2) ((_tag1 == _tag2) ? TRUE : \
g_str_equal (_tag1 != NULL ? _tag1 : "", \
- _tag2 != NULL ? _tag2 : ""))
+ _tag2 != NULL ? _tag2 : ""))
static void
synchronize_cache (ECalBackendCalDAV *cbdav)
gboolean res;
int len;
int i;
-
- priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
+
+ priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
bcache = priv->cache;
len = 0;
sobjs = NULL;
-
+
res = caldav_server_list_objects (cbdav, &sobjs, &len);
-
+
if (res == FALSE) {
/* FIXME: bloek! */
g_warning ("Could not synch server BLehh!");
hindex = g_hash_table_new (g_str_hash, g_str_equal);
cobjs = e_cal_backend_cache_get_components (bcache);
- /* build up a index for the href entry */
+ /* build up a index for the href entry */
for (citer = cobjs; citer; citer = g_list_next (citer)) {
ECalComponent *ccomp = E_CAL_COMPONENT (citer->data);
- const char *href;
-
+ const char *href;
+
href = e_cal_component_get_href (ccomp);
-
+
if (href == NULL) {
g_warning ("href of object NULL :(");
continue;
}
-
+
g_hash_table_insert (hindex, (gpointer) href, ccomp);
}
-
+
/* see if we have to upate or add some objects */
for (i = 0, object = sobjs; i < len; i++, object++) {
ECalComponent *ccomp;
res = TRUE;
ccomp = g_hash_table_lookup (hindex, object->href);
-
+
if (ccomp != NULL) {
- etag = e_cal_component_get_etag (ccomp);
- }
-
+ etag = e_cal_component_get_etag (ccomp);
+ }
+
if (!etag || !etags_match (etag, object->etag)) {
res = synchronize_object (cbdav, object, ccomp);
}
-
+
if (res == TRUE) {
cobjs = g_list_remove (cobjs, ccomp);
}
for (citer = cobjs; citer; citer = g_list_next (citer)) {
ECalComponent *comp;
const char *uid;
-
+
comp = E_CAL_COMPONENT (citer->data);
e_cal_component_get_uid (comp, &uid);
- if (e_cal_backend_cache_remove_component (bcache, uid, NULL) &&
+ if (e_cal_backend_cache_remove_component (bcache, uid, NULL) &&
priv->report_changes) {
char *str = e_cal_component_get_as_string (comp);
ECalComponentId *id = e_cal_component_get_id (comp);
-
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbdav),
+
+ e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbdav),
id, str, NULL);
e_cal_component_free_id (id);
g_free (str);
g_object_unref (comp);
}
-
+
g_hash_table_destroy (hindex);
g_list_free (cobjs);
-
+
}
/* ************************************************************************* */
-static gpointer
+static gpointer
synch_slave_loop (gpointer data)
{
ECalBackendCalDAVPrivate *priv;
ECalBackendCalDAV *cbdav;
-
- cbdav = E_CAL_BACKEND_CALDAV (data);
+
+ cbdav = E_CAL_BACKEND_CALDAV (data);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
- g_mutex_lock (priv->lock);
+ g_mutex_lock (priv->lock);
while (priv->slave_cmd != SLAVE_SHOULD_DIE) {
- GTimeVal alarm_clock;
+ GTimeVal alarm_clock;
if (priv->slave_cmd == SLAVE_SHOULD_SLEEP) {
/* just sleep until we get woken up again */
g_cond_wait (priv->cond, priv->lock);
-
+
/* check if we should die, work or sleep again */
continue;
}
- /* Ok here we go, do some real work
+ /* Ok here we go, do some real work
* Synch it baby one more time ...
*/
//d(g_print ("Synch-Slave: Goint to work ...\n")); XXX re-enable output please
- synchronize_cache (cbdav);
+ synchronize_cache (cbdav);
/* puhh that was hard, get some rest :) */
g_get_current_time (&alarm_clock);
alarm_clock.tv_sec += priv->refresh_time.tv_sec;
- g_cond_timed_wait (priv->cond,
- priv->lock,
+ g_cond_timed_wait (priv->cond,
+ priv->lock,
&alarm_clock);
}
- /* we got killed ... */
+ /* we got killed ... */
g_mutex_unlock (priv->lock);
- return NULL;
+ return NULL;
}
/* ************************************************************************* */
/* ********** ECalBackendSync virtual function implementation ************* */
static ECalBackendSyncStatus
-caldav_is_read_only (ECalBackendSync *backend,
- EDataCal *cal,
+caldav_is_read_only (ECalBackendSync *backend,
+ EDataCal *cal,
gboolean *read_only)
{
ECalBackendCalDAV *cbdav;
*read_only = priv->read_only;
}
- return GNOME_Evolution_Calendar_Success;
+ return GNOME_Evolution_Calendar_Success;
}
static ECalBackendSyncStatus
-caldav_get_cal_address (ECalBackendSync *backend,
- EDataCal *cal,
+caldav_get_cal_address (ECalBackendSync *backend,
+ EDataCal *cal,
char **address)
{
*address = NULL;
static ECalBackendSyncStatus
-caldav_get_ldap_attribute (ECalBackendSync *backend,
- EDataCal *cal,
+caldav_get_ldap_attribute (ECalBackendSync *backend,
+ EDataCal *cal,
char **attribute)
{
*attribute = NULL;
}
static ECalBackendSyncStatus
-caldav_get_alarm_email_address (ECalBackendSync *backend,
- EDataCal *cal,
+caldav_get_alarm_email_address (ECalBackendSync *backend,
+ EDataCal *cal,
char **address)
{
*address = NULL;
}
static ECalBackendSyncStatus
-caldav_get_static_capabilities (ECalBackendSync *backend,
- EDataCal *cal,
+caldav_get_static_capabilities (ECalBackendSync *backend,
+ EDataCal *cal,
char **capabilities)
{
*capabilities = g_strdup (CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS ","
CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
CAL_STATIC_CAPABILITY_NO_THISANDPRIOR);
-
+
return GNOME_Evolution_Calendar_Success;
}
static ECalBackendSyncStatus
initialize_backend (ECalBackendCalDAV *cbdav)
-{
+{
ECalBackendSyncStatus result;
ECalBackendCalDAVPrivate *priv;
ESource *source;
const char *os_val;
const char *uri;
gsize len;
-
+
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
-
+
result = GNOME_Evolution_Calendar_Success;
source = e_cal_backend_get_source (E_CAL_BACKEND (cbdav));
}
os_val = e_source_get_property (source, "auth");
-
+
if (os_val) {
priv->need_auth = TRUE;
}
-
+
os_val = e_source_get_property(source, "ssl");
uri = e_cal_backend_get_uri (E_CAL_BACKEND (cbdav));
} else {
priv->uri = g_strdup (uri);
- }
+ }
/* remove trailing slashes */
len = strlen (priv->uri);
result = GNOME_Evolution_Calendar_OtherError;
goto out;
}
-
+
}
priv->slave_cmd = SLAVE_SHOULD_SLEEP;
g_warning ("Could not create synch slave");
result = GNOME_Evolution_Calendar_OtherError;
}
-
- priv->report_changes = TRUE;
+
+ priv->report_changes = TRUE;
priv->synch_slave = slave;
- priv->loaded = TRUE;
+ priv->loaded = TRUE;
out:
return result;
}
static ECalBackendSyncStatus
-caldav_do_open (ECalBackendSync *backend,
- EDataCal *cal,
+caldav_do_open (ECalBackendSync *backend,
+ EDataCal *cal,
gboolean only_if_exists,
- const char *username,
+ const char *username,
const char *password)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
ECalBackendSyncStatus status;
-
+
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
status = GNOME_Evolution_Calendar_Success;
-
+
g_mutex_lock (priv->lock);
-
+
if (priv->loaded != TRUE) {
priv->ostatus = initialize_backend (cbdav);
- }
-
+ }
+
if (priv->ostatus != GNOME_Evolution_Calendar_Success) {
g_mutex_unlock (priv->lock);
return status;
g_mutex_unlock (priv->lock);
return GNOME_Evolution_Calendar_AuthenticationRequired;
}
-
+
priv->username = g_strdup (username);
priv->password = g_strdup (password);
priv->need_auth = FALSE;
}
-
+
if (! priv->do_offline && priv->mode == CAL_MODE_LOCAL) {
g_mutex_unlock (priv->lock);
- return GNOME_Evolution_Calendar_RepositoryOffline;
+ return GNOME_Evolution_Calendar_RepositoryOffline;
}
if (priv->mode == CAL_MODE_REMOTE) {
/* set forward proxy */
caldav_set_session_proxy (priv);
-
+
status = caldav_server_open_calendar (cbdav);
if (status == GNOME_Evolution_Calendar_Success) {
}
g_mutex_unlock (priv->lock);
-
+
return status;
}
static ECalBackendSyncStatus
-caldav_remove (ECalBackendSync *backend,
+caldav_remove (ECalBackendSync *backend,
EDataCal *cal)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
ECalBackendSyncStatus status;
- gboolean online;
-
+ gboolean online;
+
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
g_mutex_lock (priv->lock);
-
+
if (priv->loaded != TRUE) {
g_mutex_unlock (priv->lock);
return GNOME_Evolution_Calendar_Success;
}
-
+
status = check_state (cbdav, &online);
if (status != GNOME_Evolution_Calendar_Success) {
e_file_cache_remove (E_FILE_CACHE (priv->cache));
priv->cache = NULL;
- priv->loaded = FALSE;
+ priv->loaded = FALSE;
priv->slave_cmd = SLAVE_SHOULD_DIE;
g_cond_signal (priv->cond);
g_mutex_unlock (priv->lock);
-
+
return GNOME_Evolution_Calendar_Success;
}
static char *
-pack_cobj (ECalBackendCalDAV *cbdav, ECalComponent *ecomp)
+pack_cobj (ECalBackendCalDAV *cbdav, ECalComponent *ecomp)
{
ECalBackendCalDAVPrivate *priv;
icalcomponent *calcomp;
icalcomponent *icomp;
char *objstr;
-
+
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
icomp = e_cal_component_get_icalcomponent (ecomp);
}
objstr = icalcomponent_as_ical_string (calcomp);
-
+
g_assert (objstr);
-
+
return g_strdup (objstr);
-
+
}
static ECalBackendSyncStatus
-caldav_create_object (ECalBackendSync *backend,
- EDataCal *cal,
- char **calobj,
+caldav_create_object (ECalBackendSync *backend,
+ EDataCal *cal,
+ char **calobj,
char **uid)
{
ECalBackendCalDAV *cbdav;
ECalComponent *comp;
gboolean online;
char *href;
-
+
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
g_mutex_unlock (priv->lock);
return GNOME_Evolution_Calendar_InvalidObject;
}
-
+
if (online) {
CalDAVObject object;
-
- href = e_cal_component_gen_href (comp);
-
+
+ href = e_cal_component_gen_href (comp);
+
object.href = href;
object.etag = NULL;
object.cdata = pack_cobj (cbdav, comp);
e_cal_component_set_etag (comp, object.etag);
caldav_object_free (&object, FALSE);
-
+
} else {
/* mark component as out of synch */
- e_cal_component_set_synch_state (comp,
+ e_cal_component_set_synch_state (comp,
E_CAL_COMPONENT_LOCALLY_CREATED);
}
if (status != GNOME_Evolution_Calendar_Success) {
g_object_unref (comp);
g_mutex_unlock (priv->lock);
- return status;
+ return status;
}
-
+
/* We should prolly check for cache errors
* but when that happens we are kinda hosed anyway */
e_cal_backend_cache_put_component (priv->cache, comp);
*calobj = e_cal_component_get_as_string (comp);
-
+
g_mutex_unlock (priv->lock);
-
- return status;
+
+ return status;
}
static ECalBackendSyncStatus
-caldav_modify_object (ECalBackendSync *backend,
- EDataCal *cal,
+caldav_modify_object (ECalBackendSync *backend,
+ EDataCal *cal,
const char *calobj,
- CalObjModType mod,
+ CalObjModType mod,
char **old_object,
char **new_object)
{
ECalComponent *cache_comp;
gboolean online;
const char *uid = NULL;
-
+
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
g_mutex_unlock (priv->lock);
return GNOME_Evolution_Calendar_InvalidObject;
}
-
+
e_cal_component_get_uid (comp, &uid);
-
+
cache_comp = e_cal_backend_cache_get_component (priv->cache, uid, NULL);
if (cache_comp == NULL) {
g_mutex_unlock (priv->lock);
if (online) {
CalDAVObject object;
-
+
object.href = g_strdup (e_cal_component_get_href (cache_comp));
object.etag = g_strdup (e_cal_component_get_etag (cache_comp));
object.cdata = pack_cobj (cbdav, comp);
e_cal_component_set_etag (comp, object.etag);
caldav_object_free (&object, FALSE);
-
+
} else {
/* mark component as out of synch */
- e_cal_component_set_synch_state (comp,
+ e_cal_component_set_synch_state (comp,
E_CAL_COMPONENT_LOCALLY_MODIFIED);
}
if (status != GNOME_Evolution_Calendar_Success) {
g_object_unref (comp);
g_mutex_unlock (priv->lock);
- return status;
+ return status;
}
-
+
/* We should prolly check for cache errors
* but when that happens we are kinda hosed anyway */
e_cal_backend_cache_put_component (priv->cache, comp);
*old_object = e_cal_component_get_as_string (cache_comp);
*new_object = e_cal_component_get_as_string (comp);
-
+
g_mutex_unlock (priv->lock);
-
- return status;
+
+ return status;
}
static ECalBackendSyncStatus
-caldav_remove_object (ECalBackendSync *backend,
+caldav_remove_object (ECalBackendSync *backend,
EDataCal *cal,
- const char *uid,
+ const char *uid,
const char *rid,
- CalObjModType mod,
+ CalObjModType mod,
char **old_object,
char **object)
{
ECalBackendSyncStatus status;
ECalComponent *cache_comp;
gboolean online;
-
+
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
if (online) {
CalDAVObject caldav_object;
-
+
caldav_object.href = g_strdup (e_cal_component_get_href (cache_comp));
caldav_object.etag = g_strdup (e_cal_component_get_etag (cache_comp));
caldav_object.cdata = NULL;
status = caldav_server_delete_object (cbdav, &caldav_object);
caldav_object_free (&caldav_object, FALSE);
-
+
} else {
/* mark component as out of synch */
- e_cal_component_set_synch_state (cache_comp,
+ e_cal_component_set_synch_state (cache_comp,
E_CAL_COMPONENT_LOCALLY_DELETED);
}
if (status != GNOME_Evolution_Calendar_Success) {
g_mutex_unlock (priv->lock);
- return status;
+ return status;
}
-
+
*old_object = e_cal_component_get_as_string (cache_comp);
/* We should prolly check for cache errors
e_cal_backend_cache_remove_component (priv->cache, uid, rid);
/* FIXME: set new_object when removing instances of a recurring appointment */
-
+
g_mutex_unlock (priv->lock);
-
- return status;
+
+ return status;
}
static ECalBackendSyncStatus
{
icalcomponent *scomp;
icalcomponent_kind kind;
-
+
g_return_val_if_fail (icomp, GNOME_Evolution_Calendar_OtherError);
g_return_val_if_fail (objects, GNOME_Evolution_Calendar_OtherError);
-
+
kind = icalcomponent_isa (icomp);
-
+
if (kind == ekind) {
*objects = g_list_prepend (NULL, icomp);
return GNOME_Evolution_Calendar_Success;
}
*objects = NULL;
- scomp = icalcomponent_get_first_component (icomp,
+ scomp = icalcomponent_get_first_component (icomp,
ekind);
while (scomp) {
-
+
/* Remove components from toplevel here */
*objects = g_list_prepend (*objects, scomp);
icalcomponent_remove_component (icomp, scomp);
-
+
scomp = icalcomponent_get_next_component (icomp, ekind);
}
ECalComponent *ccomp;
struct icaltimetype now;
ECalComponentId *id;
- const char *uid;
+ const char *uid;
const char *rid;
char *ostr;
char *oostr;
-
+
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
backend = E_CAL_BACKEND (cbdav);
-
+
/* ctime, mtime */
now = icaltime_from_timet (time (NULL), 0);
e_cal_component_set_created (ecomp, &now);
ccomp = e_cal_backend_cache_get_component (priv->cache, uid, NULL);
if (ccomp != NULL) {
- oostr = e_cal_component_get_as_string (ccomp);
+ oostr = e_cal_component_get_as_string (ccomp);
} else {
oostr = NULL;
}
-
- ostr = e_cal_component_get_as_string (ecomp);
-
+
+ ostr = e_cal_component_get_as_string (ecomp);
+
status = GNOME_Evolution_Calendar_Success;
-
+
switch (method) {
-
+
case ICAL_METHOD_PUBLISH:
case ICAL_METHOD_REQUEST:
case ICAL_METHOD_REPLY:
href = e_cal_component_get_href (ccomp);
etag = e_cal_component_get_etag (ccomp);
-
+
object.href = g_strdup (href);
object.etag = g_strdup (etag);
} else {
object.href = e_cal_component_gen_href (ecomp);
}
-
+
object.cdata = pack_cobj (cbdav, ecomp);
status = caldav_server_put_object (cbdav, &object);
e_cal_component_set_etag (ecomp, object.etag);
caldav_object_free (&object, FALSE);
} else {
ECalComponentSyncState sstate;
-
+
if (ccomp) {
sstate = E_CAL_COMPONENT_LOCALLY_MODIFIED;
} else {
sstate = E_CAL_COMPONENT_LOCALLY_CREATED;
}
- e_cal_component_set_synch_state (ecomp, sstate);
+ e_cal_component_set_synch_state (ecomp, sstate);
}
-
+
if (status != GNOME_Evolution_Calendar_Success) {
break;
}
e_cal_backend_cache_put_component (priv->cache, ecomp);
-
+
if (ccomp) {
e_cal_backend_notify_object_modified (backend,
oostr);
} else {
-
+
e_cal_backend_notify_object_created (backend,
ostr);
}
-
+
break;
case ICAL_METHOD_CANCEL:
-
+
if (ccomp == NULL) {
status = GNOME_Evolution_Calendar_ObjectNotFound;
break;
}
-
+
/* FIXME: this is not working for instances
- * of recurring appointments - yet - */
+ * of recurring appointments - yet - */
if (online) {
CalDAVObject object;
const char *href;
href = e_cal_component_get_href (ccomp);
etag = e_cal_component_get_etag (ccomp);
-
+
object.href = g_strdup (href);
object.etag = g_strdup (etag);
object.cdata = NULL;
status = caldav_server_delete_object (cbdav,
&object);
-
+
caldav_object_free (&object, FALSE);
-
+
} else {
/* mark component as out of synch */
- e_cal_component_set_synch_state (ecomp,
+ e_cal_component_set_synch_state (ecomp,
E_CAL_COMPONENT_LOCALLY_DELETED);
-
- }
-
+
+ }
+
if (status != GNOME_Evolution_Calendar_Success) {
break;
}
rid);
id = e_cal_component_get_id (ccomp);
-
+
e_cal_backend_notify_object_removed (E_CAL_BACKEND (backend),
id,
oostr,
g_object_unref (ecomp);
g_free (ostr);
g_free (oostr);
-
+
if (ccomp) {
g_object_unref (ccomp);
}
static ECalBackendSyncStatus
caldav_receive_objects (ECalBackendSync *backend,
- EDataCal *cal,
+ EDataCal *cal,
const char *calobj)
{
ECalBackendCalDAV *cbdav;
GList *timezones;
GList *objects;
GList *iter;
-
+
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
-
+
icomp = icalparser_parse_string (calobj);
-
+
/* Try to parse cal object string */
if (icomp == NULL) {
return GNOME_Evolution_Calendar_InvalidObject;
/* Extract optional timezone compnents */
kind = ICAL_VTIMEZONE_COMPONENT;
status = extract_objects (icomp, kind, &timezones);
-
+
if (status == GNOME_Evolution_Calendar_Success) {
/* FIXME: */
/* Do something usefull with the timezone */
}
-
+
/* */
g_mutex_lock (priv->lock);
g_mutex_unlock (priv->lock);
return status;
}
-
+
tmethod = icalcomponent_get_method (icomp);
-
+
for (iter = objects; iter && ! is_error (status); iter = iter->next) {
icalcomponent *scomp;
ECalComponent *ecomp;
icalproperty_method method;
-
+
scomp = (icalcomponent *) iter->data;
ecomp = e_cal_component_new ();
if (icalcomponent_get_first_property (scomp,
ICAL_METHOD_PROPERTY)) {
-
+
method = icalcomponent_get_method (scomp);
} else {
method = tmethod;
}
-
- status = process_object (cbdav, ecomp, online, method);
-
+
+ status = process_object (cbdav, ecomp, online, method);
+
g_object_unref (ecomp);
}
g_list_free (objects);
g_list_free (timezones);
-
+
g_mutex_unlock (priv->lock);
- return status;
+ return status;
}
static ECalBackendSyncStatus
-caldav_send_objects (ECalBackendSync *backend,
+caldav_send_objects (ECalBackendSync *backend,
EDataCal *cal,
- const char *calobj,
+ const char *calobj,
GList **users,
char **modified_calobj)
-{
+{
*users = NULL;
*modified_calobj = g_strdup (calobj);
}
static ECalBackendSyncStatus
-caldav_get_default_object (ECalBackendSync *backend,
- EDataCal *cal,
+caldav_get_default_object (ECalBackendSync *backend,
+ EDataCal *cal,
char **object)
{
ECalComponent *comp;
-
+
comp = e_cal_component_new ();
e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
*object = e_cal_component_get_as_string (comp);
g_object_unref (comp);
-
+
return GNOME_Evolution_Calendar_Success;
}
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
ECalComponent *comp;
-
+
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
g_mutex_lock (priv->lock);
comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
g_mutex_unlock (priv->lock);
-
+
if (comp == NULL) {
*object = NULL;
return GNOME_Evolution_Calendar_ObjectNotFound;
*object = e_cal_component_get_as_string (comp);
g_object_unref (comp);
-
+
return GNOME_Evolution_Calendar_Success;
}
static ECalBackendSyncStatus
-caldav_get_timezone (ECalBackendSync *backend,
+caldav_get_timezone (ECalBackendSync *backend,
EDataCal *cal,
const char *tzid,
char **object)
if (!zone) {
zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (!zone) {
+ if (!zone) {
return GNOME_Evolution_Calendar_ObjectNotFound;
}
}
icalcomp = icaltimezone_get_component ((icaltimezone *) zone);
-
+
if (!icalcomp) {
return GNOME_Evolution_Calendar_InvalidObject;
}
-
+
*object = g_strdup (icalcomponent_as_ical_string (icalcomp));
return GNOME_Evolution_Calendar_Success;
}
static ECalBackendSyncStatus
-caldav_add_timezone (ECalBackendSync *backend,
+caldav_add_timezone (ECalBackendSync *backend,
EDataCal *cal,
const char *tzobj)
{
/* FIXME: implement me! */
g_warning ("function not implemented %s", G_STRFUNC);
- return GNOME_Evolution_Calendar_Success;
+ return GNOME_Evolution_Calendar_Success;
}
static ECalBackendSyncStatus
-caldav_set_default_zone (ECalBackendSync *backend,
+caldav_set_default_zone (ECalBackendSync *backend,
EDataCal *cal,
const char *tzobj)
{
/* FIXME: implement me! */
g_warning ("function not implemented %s", G_STRFUNC);
- return GNOME_Evolution_Calendar_Success;
+ return GNOME_Evolution_Calendar_Success;
}
static ECalBackendSyncStatus
-caldav_get_object_list (ECalBackendSync *backend,
+caldav_get_object_list (ECalBackendSync *backend,
EDataCal *cal,
const char *sexp_string,
GList **objects)
ECalBackend *bkend;
gboolean do_search;
GList *list, *iter;
-
+
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
if (sexp == NULL) {
return GNOME_Evolution_Calendar_InvalidQuery;
}
-
+
if (g_str_equal (sexp, "#t")) {
do_search = FALSE;
} else {
*objects = NULL;
bcache = priv->cache;
- g_mutex_lock (priv->lock);
-
+ g_mutex_lock (priv->lock);
+
list = e_cal_backend_cache_get_components (bcache);
bkend = E_CAL_BACKEND (backend);
-
+
for (iter = list; iter; iter = g_list_next (iter)) {
- ECalComponent *comp = E_CAL_COMPONENT (iter->data);
-
- if (do_search == FALSE ||
+ ECalComponent *comp = E_CAL_COMPONENT (iter->data);
+
+ if (do_search == FALSE ||
e_cal_backend_sexp_match_comp (sexp, comp, bkend)) {
char *str = e_cal_component_get_as_string (comp);
*objects = g_list_prepend (*objects, str);
g_list_free (list);
g_mutex_unlock (priv->lock);
-
- return GNOME_Evolution_Calendar_Success;
+
+ return GNOME_Evolution_Calendar_Success;
}
static void
-caldav_start_query (ECalBackend *backend,
+caldav_start_query (ECalBackend *backend,
EDataCalView *query)
{
ECalBackendCalDAV *cbdav;
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
-
+
sexp_string = e_data_cal_view_get_text (query);
sexp = e_cal_backend_sexp_new (sexp_string);
/* FIXME:check invalid sexp */
-
+
if (g_str_equal (sexp, "#t")) {
do_search = FALSE;
} else {
do_search = TRUE;
}
-
+
g_mutex_lock (priv->lock);
list = e_cal_backend_cache_get_components (priv->cache);
bkend = E_CAL_BACKEND (backend);
-
+
for (iter = list; iter; iter = g_list_next (iter)) {
- ECalComponent *comp = E_CAL_COMPONENT (iter->data);
-
- if (do_search == FALSE ||
+ ECalComponent *comp = E_CAL_COMPONENT (iter->data);
+
+ if (do_search == FALSE ||
e_cal_backend_sexp_match_comp (sexp, comp, bkend)) {
char *str = e_cal_component_get_as_string (comp);
e_data_cal_view_notify_objects_added_1 (query, str);
g_object_unref (sexp);
g_list_free (list);
-
+
e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_Success);
g_mutex_unlock (priv->lock);
return;
}
static ECalBackendSyncStatus
-caldav_get_free_busy (ECalBackendSync *backend,
- EDataCal *cal,
+caldav_get_free_busy (ECalBackendSync *backend,
+ EDataCal *cal,
GList *users,
- time_t start,
- time_t end,
+ time_t start,
+ time_t end,
GList **freebusy)
{
/* FIXME: implement me! */
g_warning ("function not implemented %s", G_STRFUNC);
- return GNOME_Evolution_Calendar_OtherError;
+ return GNOME_Evolution_Calendar_OtherError;
}
static ECalBackendSyncStatus
caldav_get_changes (ECalBackendSync *backend,
EDataCal *cal,
const char *change_id,
- GList **adds,
- GList **modifies,
+ GList **adds,
+ GList **modifies,
GList **deletes)
{
/* FIXME: implement me! */
g_warning ("function not implemented %s", G_STRFUNC);
- return GNOME_Evolution_Calendar_OtherError;
+ return GNOME_Evolution_Calendar_OtherError;
}
static gboolean
caldav_is_loaded (ECalBackend *backend)
-
+
{ ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
-
+
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
-
- return priv->mode;
+
+ return priv->mode;
}
static void
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
g_mutex_lock (priv->lock);
-
- /* We only support online and offline
+
+ /* We only support online and offline
* (is there something else?) */
if (mode != CAL_MODE_REMOTE &&
mode != CAL_MODE_LOCAL) {
- e_cal_backend_notify_mode (backend,
+ e_cal_backend_notify_mode (backend,
GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
cal_mode_to_corba (mode));
}
if (priv->mode == mode || priv->loaded == FALSE) {
priv->mode = mode;
- e_cal_backend_notify_mode (backend,
+ e_cal_backend_notify_mode (backend,
GNOME_Evolution_Calendar_CalListener_MODE_SET,
cal_mode_to_corba (mode));
g_mutex_unlock (priv->lock);
priv->slave_cmd = SLAVE_SHOULD_SLEEP;
}
- e_cal_backend_notify_mode (backend,
+ e_cal_backend_notify_mode (backend,
GNOME_Evolution_Calendar_CalListener_MODE_SET,
cal_mode_to_corba (mode));
}
static icaltimezone *
-caldav_internal_get_timezone (ECalBackend *backend,
+caldav_internal_get_timezone (ECalBackend *backend,
const char *tzid)
{
icaltimezone *zone;
if (!zone) {
zone = icaltimezone_get_utc_timezone ();
}
-
+
return zone;
}
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
-
+
cbdav = E_CAL_BACKEND_CALDAV (object);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
g_mutex_unlock (priv->lock);
return;
}
-
+
/* stop the slave */
priv->slave_cmd = SLAVE_SHOULD_DIE;
g_cond_signal (priv->cond);
g_mutex_lock (priv->lock);
g_object_unref (priv->session);
-
+
g_free (priv->username);
g_free (priv->password);
g_free (priv->uri);
if (priv->cache != NULL) {
g_object_unref (priv->cache);
}
-
+
priv->disposed = TRUE;
g_mutex_unlock (priv->lock);
-
+
if (G_OBJECT_CLASS (parent_class)->dispose)
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
-
+
cbdav = E_CAL_BACKEND_CALDAV (object);
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
g_mutex_free (priv->lock);
g_cond_free (priv->cond);
-
+
if (G_OBJECT_CLASS (parent_class)->finalize)
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
priv = E_CAL_BACKEND_CALDAV_GET_PRIVATE (cbdav);
priv->session = soup_session_sync_new ();
-
+
priv->disposed = FALSE;
priv->do_synch = FALSE;
priv->loaded = FALSE;
-
+
priv->cond = g_cond_new ();
priv->lock = g_mutex_new ();
priv->slave_cmd = SLAVE_SHOULD_SLEEP;
priv->refresh_time.tv_usec = 0;
priv->refresh_time.tv_sec = DEFAULT_REFRESH_TIME;
-
+
g_signal_connect (priv->session, "authenticate",
G_CALLBACK (soup_authenticate), cbdav);
g_signal_connect (priv->session, "reauthenticate",
G_CALLBACK (soup_reauthenticate), cbdav);
-
+
e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbdav), FALSE);
}
object_class->dispose = e_cal_backend_caldav_dispose;
object_class->finalize = e_cal_backend_caldav_finalize;
-
+
sync_class->is_read_only_sync = caldav_is_read_only;
sync_class->get_cal_address_sync = caldav_get_cal_address;
sync_class->get_alarm_email_address_sync = caldav_get_alarm_email_address;
sync_class->get_ldap_attribute_sync = caldav_get_ldap_attribute;
sync_class->get_static_capabilities_sync = caldav_get_static_capabilities;
-
+
sync_class->open_sync = caldav_do_open;
sync_class->remove_sync = caldav_remove;
-
+
sync_class->create_object_sync = caldav_create_object;
sync_class->modify_object_sync = caldav_modify_object;
sync_class->remove_object_sync = caldav_remove_object;
-
+
sync_class->discard_alarm_sync = caldav_discard_alarm;
sync_class->receive_objects_sync = caldav_receive_objects;
sync_class->send_objects_sync = caldav_send_objects;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Author: Christian Kellner <gicmo@gnome.org>
+ * Author: Christian Kellner <gicmo@gnome.org>
*/
#ifndef E_CAL_BACKEND_CALDAV_H
/* Private part of the ECalBackendContacts structure */
struct _ECalBackendContactsPrivate {
ESourceList *addressbook_sources;
-
+
GHashTable *addressbooks; /* UID -> BookRecord */
gboolean addressbook_loaded;
EBookView *book_view;
GHashTable *tracked_contacts; /* UID -> ContactRecord */
- GHashTable *zones;
+ GHashTable *zones;
icaltimezone *default_zone;
};
EBookQuery *query;
EBookView *book_view;
BookRecord *br;
-
+
book = e_book_new (source, NULL);
e_book_open (book, TRUE, NULL);
-
+
/* Create book view */
fields = g_list_append (fields, (char*)e_contact_field_name (E_CONTACT_FILE_AS));
fields = g_list_append (fields, (char*)e_contact_field_name (E_CONTACT_BIRTH_DATE));
{
if (!br)
return;
-
+
g_object_unref (br->book_view);
g_object_unref (br->book);
{
ContactRecord *cr = g_new0 (ContactRecord, 1);
char *comp_str;
-
+
cr->cbc = g_object_ref (cbc);
cr->contact = contact;
cr->comp_birthday = create_birthday (cbc, contact);
comp_str);
g_free (comp_str);
}
-
+
if (cr->comp_anniversary) {
comp_str = e_cal_component_get_as_string (cr->comp_anniversary);
}
g_object_ref (G_OBJECT (contact));
-
+
return cr;
}
id = e_cal_component_get_id (cr->comp_anniversary);
e_cal_backend_notify_object_removed (E_CAL_BACKEND (cr->cbc), id, comp_str, NULL);
-
+
e_cal_component_free_id (id);
g_free (comp_str);
g_object_unref (G_OBJECT (cr->comp_anniversary));
/* ContactRecordCB methods */
typedef struct _ContactRecordCB {
ECalBackendContacts *cbc;
- ECalBackendSExp *sexp;
+ ECalBackendSExp *sexp;
GList *result;
} ContactRecordCB;
{
g_list_foreach (cb_data->result, (GFunc) g_free, NULL);
g_list_free (cb_data->result);
-
+
g_free (cb_data);
}
source_added_cb (ESourceGroup *group, ESource *source, gpointer user_data)
{
ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (user_data);
-
+
g_return_if_fail (cbc);
add_source (cbc, source);
{
ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (user_data);
const char *uid = e_source_peek_uid (source);
-
+
g_return_if_fail (cbc);
g_hash_table_remove (cbc->priv->addressbooks, uid);
ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (user_data);
const gchar *base_uri;
GSList *i;
-
+
g_return_if_fail (cbc);
base_uri = e_source_group_peek_base_uri (group);
{
ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (user_data);
GSList *i = NULL;
-
+
g_return_if_fail (cbc);
-
+
/* Unload all address books from this group */
for (i = e_source_group_peek_sources (group); i; i = i->next) {
ESource *source = E_SOURCE (i->data);
const char *uid = e_source_peek_uid (source);
-
+
g_hash_table_remove (cbc->priv->addressbooks, uid);
}
}
for (i = contacts; i; i = i->next) {
EContact *contact = E_CONTACT (i->data);
const char *uid = e_contact_get_const (contact, E_CONTACT_UID);
-
+
/* Because this is a change of contact, then always remove old tracked data
and if possible, add with (possibly) new values.
*/
{
EContact *contact = E_CONTACT (i->data);
EContactDate *birthday, *anniversary;
-
+
birthday = e_contact_get (contact, E_CONTACT_BIRTH_DATE);
anniversary = e_contact_get (contact, E_CONTACT_ANNIVERSARY);
-
+
if (birthday || anniversary) {
ContactRecord *cr = contact_record_new (cbc, contact);
const char *uid = e_contact_get_const (contact, E_CONTACT_UID);
-
+
g_hash_table_insert (cbc->priv->tracked_contacts, g_strdup (uid), cr);
}
-
+
e_contact_date_free (birthday);
e_contact_date_free (anniversary);
}
ret.is_utc = FALSE;
ret.zone = NULL;
ret.is_daylight = FALSE;
-
+
ret.hour = ret.minute = ret.second = 0;
return ret;
return NULL;
ical_comp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-
+
/* Create the event object */
cal_comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (cal_comp, ical_comp);
/* Set uid */
d(g_message ("Creating UID: %s", uid));
e_cal_component_set_uid (cal_comp, uid);
-
+
/* Set all-day event's date from contact data */
itt = cdate_to_icaltime (cdate);
dt.value = &itt;
dt.tzid = NULL;
e_cal_component_set_dtstart (cal_comp, &dt);
-
+
itt = cdate_to_icaltime (cdate);
icaltime_adjust (&itt, 1, 0, 0, 0);
dt.value = &itt;
dt.tzid = NULL;
/* We have to add 1 day to DTEND, as it is not inclusive. */
e_cal_component_set_dtend (cal_comp, &dt);
-
+
/* Create yearly recurrence */
icalrecurrencetype_clear (&r);
r.freq = ICAL_YEARLY_RECURRENCE;
r.interval = 1;
recur_list.data = &r;
- recur_list.next = NULL;
+ recur_list.next = NULL;
e_cal_component_set_rrule_list (cal_comp, &recur_list);
/* Create summary */
comp_summary.value = summary;
comp_summary.altrep = NULL;
e_cal_component_set_summary (cal_comp, &comp_summary);
-
+
/* Set category and visibility */
if (g_str_has_suffix (uid, ANNIVERSARY_UID_EXT))
e_cal_component_set_categories (cal_comp, _("Anniversary"));
else if (g_str_has_suffix (uid, BIRTHDAY_UID_EXT))
e_cal_component_set_categories (cal_comp, _("Birthday"));
-
+
e_cal_component_set_classification (cal_comp, E_CAL_COMPONENT_CLASS_PRIVATE);
/* Birthdays/anniversaries are shown as free time */
e_cal_component_set_transparency (cal_comp, E_CAL_COMPONENT_TRANSP_TRANSPARENT);
-
+
/* Don't forget to call commit()! */
e_cal_component_commit_sequence (cal_comp);
-
+
return cal_comp;
}
uid = g_strdup_printf ("%s%s", (char *) e_contact_get_const (contact, E_CONTACT_UID), BIRTHDAY_UID_EXT);
summary = g_strdup_printf (_("Birthday: %s"), name);
-
+
cal_comp = create_component (cbc, uid, cdate, summary);
e_contact_date_free (cdate);
g_free (uid);
g_free (summary);
-
+
return cal_comp;
}
char *summary;
const char *name;
char *uid;
-
+
cdate = e_contact_get (contact, E_CONTACT_ANNIVERSARY);
name = e_contact_get_const (contact, E_CONTACT_FILE_AS);
uid = g_strdup_printf ("%s%s", (char *) e_contact_get_const (contact, E_CONTACT_UID), ANNIVERSARY_UID_EXT);
summary = g_strdup_printf (_("Anniversary: %s"), name);
-
+
cal_comp = create_component (cbc, uid, cdate, summary);
e_contact_date_free (cdate);
char **attribute)
{
*attribute = NULL;
-
+
return GNOME_Evolution_Calendar_Success;
}
char **object)
{
ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (backend);
- ECalBackendContactsPrivate *priv = cbc->priv;
+ ECalBackendContactsPrivate *priv = cbc->priv;
ContactRecord *record;
char *real_uid;
-
+
if (!uid)
return GNOME_Evolution_Calendar_ObjectNotFound;
else if (g_str_has_suffix (uid, ANNIVERSARY_UID_EXT))
record = g_hash_table_lookup (priv->tracked_contacts, real_uid);
g_free (real_uid);
-
+
if (!record)
return GNOME_Evolution_Calendar_ObjectNotFound;
if (record->comp_birthday && g_str_has_suffix (uid, BIRTHDAY_UID_EXT)) {
*object = e_cal_component_get_as_string (record->comp_birthday);
-
+
d(g_message ("Return birthday: %s", *object));
return GNOME_Evolution_Calendar_Success;
}
-
+
if (record->comp_anniversary && g_str_has_suffix (uid, ANNIVERSARY_UID_EXT)) {
*object = e_cal_component_get_as_string (record->comp_anniversary);
#if 0
icalproperty *prop;
icalparameter *param;
-
+
prop = icalproperty_new_organizer (address);
if (prop != NULL && cn != NULL) {
param = icalparameter_new_cn (cn);
- icalproperty_add_parameter (prop, param);
+ icalproperty_add_parameter (prop, param);
}
if (prop != NULL)
- icalcomponent_add_property (vfb, prop);
+ icalcomponent_add_property (vfb, prop);
#endif
-
+
icalcomponent_set_dtstart (vfb, icaltime_from_timet_with_zone (start, FALSE, utc_zone));
icalcomponent_set_dtend (vfb, icaltime_from_timet_with_zone (end, FALSE, utc_zone));
calobj = icalcomponent_as_ical_string (vfb);
*freebusy = g_list_append (NULL, g_strdup (calobj));
- icalcomponent_free (vfb);
-
+ icalcomponent_free (vfb);
+
/* WRITE ME */
return GNOME_Evolution_Calendar_Success;
}
e_cal_backend_contacts_receive_objects (ECalBackendSync *backend, EDataCal *cal,
const char *calobj)
{
- return GNOME_Evolution_Calendar_PermissionDenied;
+ return GNOME_Evolution_Calendar_PermissionDenied;
}
static ECalBackendSyncStatus
static CalMode
e_cal_backend_contacts_get_mode (ECalBackend *backend)
{
- return CAL_MODE_LOCAL;
+ return CAL_MODE_LOCAL;
}
static void
e_cal_backend_notify_mode (backend,
GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
GNOME_Evolution_Calendar_MODE_LOCAL);
-
+
}
static ECalBackendSyncStatus
gboolean *read_only)
{
*read_only = TRUE;
-
+
return GNOME_Evolution_Calendar_Success;
}
if (priv->addressbook_loaded)
return GNOME_Evolution_Calendar_Success;
-
+
if (priv->default_zone && priv->default_zone != icaltimezone_get_utc_timezone ()) {
icalcomponent *icalcomp = icaltimezone_get_component (priv->default_zone);
icaltimezone *zone = icaltimezone_new ();
ECalBackendContactsPrivate *priv;
icalcomponent *tz_comp;
icaltimezone *zone;
- char *tzid;
+ char *tzid;
cbcontacts = (ECalBackendContacts *) backend;
g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError);
priv = cbcontacts->priv;
-
+
tz_comp = icalparser_parse_string (tzobj);
if (!tz_comp)
return GNOME_Evolution_Calendar_InvalidObject;
if (icalcomponent_isa (tz_comp) != ICAL_VTIMEZONE_COMPONENT)
return GNOME_Evolution_Calendar_InvalidObject;
-
+
zone = icaltimezone_new ();
icaltimezone_set_component (zone, tz_comp);
tzid = icaltimezone_get_tzid (zone);
-
+
if (g_hash_table_lookup (priv->zones, tzid)) {
icaltimezone_free (zone, TRUE);
-
+
return GNOME_Evolution_Calendar_Success;
}
-
+
g_hash_table_insert (priv->zones, g_strdup (tzid), zone);
return GNOME_Evolution_Calendar_Success;
/* Don't call cb_data_free as that would destroy the results
* in *objects */
g_free (cb_data);
-
- return GNOME_Evolution_Calendar_Success;
+
+ return GNOME_Evolution_Calendar_Success;
}
static void
ECalBackendContactsPrivate *priv = cbc->priv;
ECalBackendSExp *sexp;
ContactRecordCB *cb_data;
-
+
sexp = e_data_cal_view_get_object_sexp (query);
if (!sexp) {
e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_InvalidQuery);
}
cb_data = contact_record_cb_new (cbc, sexp);
-
+
g_hash_table_foreach (priv->tracked_contacts, contact_record_cb, cb_data);
e_data_cal_view_notify_objects_added (query, cb_data->result);
contact_record_cb_free (cb_data);
-
+
e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_Success);
}
if (priv->default_zone && priv->default_zone != icaltimezone_get_utc_timezone ()) {
icaltimezone_free (priv->default_zone, 1);
}
-
+
priv->default_zone = NULL;
g_object_unref (priv->addressbook_sources);
g_hash_table_destroy (priv->addressbooks);
g_hash_table_destroy (priv->tracked_contacts);
g_hash_table_destroy (priv->zones);
-
+
g_free (priv);
cbc->priv = NULL;
g_free, (GDestroyNotify) book_record_free);
priv->tracked_contacts = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify)contact_record_free);
-
+
priv->zones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_zone);
priv->default_zone = icaltimezone_get_utc_timezone ();
-
+
cbc->priv = priv;
e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbc), TRUE);
/**
* e_cal_backend_contacts_get_type:
- * @void:
- *
+ * @void:
+ *
* Registers the #ECalBackendContacts class if necessary, and returns
* the type ID associated to it.
- *
+ *
* Return value: The type ID of the #ECalBackendContacts class.
**/
GType
/**
* e_cal_backend_file_events_get_type:
- * @void:
- *
+ * @void:
+ *
* Registers the #ECalBackendFileEvents class if necessary, and returns the type ID
* associated to it.
- *
+ *
* Return value: The type ID of the #ECalBackendFileEvents class.
**/
GType
/**
* e_cal_backend_file_journal_get_type:
- * @void:
- *
+ * @void:
+ *
* Registers the #ECalBackendFileJournal class if necessary, and returns the type ID
* associated to it.
- *
+ *
* Return value: The type ID of the #ECalBackendFileJournal class.
**/
GType
/**
* e_cal_backend_file_todos_get_type:
- * @void:
- *
+ * @void:
+ *
* Registers the #ECalBackendFileTodos class if necessary, and returns the type ID
* associated to it.
- *
+ *
* Return value: The type ID of the #ECalBackendFileTodos class.
**/
GType
char *uri;
/* Filename in the dir */
- char *file_name;
+ char *file_name;
gboolean read_only;
gboolean is_dirty;
guint dirty_idle_id;
GHashTable *comp_uid_hash;
GList *comp;
-
+
/* The calendar's default timezone, used for resolving DATE and
floating DATE-TIME values. */
icaltimezone *default_zone;
gchar *tmp, *backup_uristr;
char *buf;
ECalBackendFile *cbfile = user_data;
-
+
priv = cbfile->priv;
g_assert (priv->uri != NULL);
g_assert (priv->icalcomp != NULL);
gnome_vfs_uri_unref (uri);
goto error_malformed_uri;
}
-
+
backup_uristr = g_strconcat (tmp, "~", NULL);
backup_uri = gnome_vfs_uri_new (backup_uristr);
gnome_vfs_uri_unref (uri);
goto error_malformed_uri;
}
-
+
result = gnome_vfs_create_uri (&handle, backup_uri,
GNOME_VFS_OPEN_WRITE,
FALSE, 0666);
if (priv->file_name) {
g_free (priv->file_name);
priv->file_name = NULL;
- }
+ }
g_free (priv);
cbfile->priv = NULL;
ECalBackendFile *cbfile = (ECalBackendFile *) backend;
*read_only = cbfile->priv->read_only;
-
+
return GNOME_Evolution_Calendar_Success;
}
e_cal_backend_file_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, char **attribute)
{
*attribute = NULL;
-
+
return GNOME_Evolution_Calendar_Success;
}
* with it (although that would be a useful feature some day).
*/
*address = NULL;
-
+
return GNOME_Evolution_Calendar_Success;
}
CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
CAL_STATIC_CAPABILITY_DELEGATE_SUPPORTED ","
CAL_STATIC_CAPABILITY_NO_THISANDPRIOR);
-
+
return GNOME_Evolution_Calendar_Success;
}
{
ECalComponentRange range;
struct icaltimetype tt;
-
+
e_cal_component_get_recurid (comp, &range);
if (!range.datetime.value)
return icaltime_null_time ();
tt = *range.datetime.value;
e_cal_component_free_range (&range);
-
+
return tt;
}
g_warning ("The component does not have a valid UID skipping it\n");
return;
}
-
+
obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid);
if (e_cal_component_is_instance (comp)) {
const char *rid;
-
+
rid = e_cal_component_get_recurid_as_string (comp);
if (obj_data) {
if (g_hash_table_lookup (obj_data->recurrences, rid)) {
ECalComponent *comp;
icalcomp = icalcompiter_deref (&iter);
-
+
kind = icalcomponent_isa (icalcomp);
if (!(kind == ICAL_VEVENT_COMPONENT
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
-
+
master_uri = e_cal_backend_get_uri (backend);
/* FIXME Check the error conditions a little more elegantly here */
return NULL;
}
-
+
full_uri = g_strdup_printf ("%s/%s", master_uri, priv->file_name);
uri = gnome_vfs_uri_new (full_uri);
g_free (full_uri);
-
+
if (!uri)
return NULL;
g_free (str_uri);
return NULL;
- }
+ }
return str_uri;
}
if (!g_hash_table_lookup (context->new_uid_hash, uid)) {
icalcomponent *old_icomp;
gchar *old_obj_str;
- ECalComponent *comp;
+ ECalComponent *comp;
ECalComponentId *id;
/* Object was removed */
old_obj_str = icalcomponent_as_ical_string (old_icomp);
if (!old_obj_str)
return;
-
+
comp = e_cal_component_new_from_string (old_obj_str);
id = e_cal_component_get_id (comp);
-
+
e_cal_backend_notify_object_removed (context->backend, id, old_obj_str, NULL);
-
+
e_cal_component_free_id (id);
g_object_unref (comp);
}
ECalBackendFilePrivate *priv;
char *str_uri;
ECalBackendSyncStatus status;
-
+
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
status = GNOME_Evolution_Calendar_Success;
goto done;
}
-
+
str_uri = get_uri_string (E_CAL_BACKEND (backend));
if (!str_uri) {
status = GNOME_Evolution_Calendar_OtherError;
goto done;
}
-
+
if (g_access (str_uri, R_OK) == 0) {
status = open_cal (cbfile, str_uri);
if (g_access (str_uri, W_OK) != 0)
GDir *dir = NULL;
GError *error = NULL;
ECalBackendSyncStatus status = GNOME_Evolution_Calendar_Success;
-
+
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
if (g_rmdir (dirname) != 0) {
status = GNOME_Evolution_Calendar_OtherError;
}
-
+
done:
if (dir) {
g_dir_close (dir);
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
- return CAL_MODE_LOCAL;
+ return CAL_MODE_LOCAL;
}
/* Set_mode handler for the file backend */
e_cal_backend_notify_mode (backend,
GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
GNOME_Evolution_Calendar_MODE_LOCAL);
-
+
}
static ECalBackendSyncStatus
e_cal_backend_file_get_default_object (ECalBackendSync *backend, EDataCal *cal, char **object)
{
ECalComponent *comp;
-
+
comp = e_cal_component_new ();
switch (e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
g_object_unref (comp);
return GNOME_Evolution_Calendar_ObjectNotFound;
}
-
+
*object = e_cal_component_get_as_string (comp);
g_object_unref (comp);
-
+
return GNOME_Evolution_Calendar_Success;
}
icalcomponent_add_component (
vcalendar,
- icalcomponent_new_clone (e_cal_component_get_icalcomponent (recurrence)));
+ icalcomponent_new_clone (e_cal_component_get_icalcomponent (recurrence)));
}
/* Get_object_component handler for the file backend */
}
}
}
-
+
icalcomp = icaltimezone_get_component (zone);
if (!icalcomp) {
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
*objects = match_data.obj_list;
g_object_unref (match_data.obj_sexp);
-
- return GNOME_Evolution_Calendar_Success;
+
+ return GNOME_Evolution_Calendar_Success;
}
/* Gets the list of attachments */
static ECalBackendSyncStatus
-e_cal_backend_file_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, GSList **list)
+e_cal_backend_file_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, GSList **list)
{
-
+
/* TODO implement the function */
return GNOME_Evolution_Calendar_Success;
}
ipt.start = icaltime_from_timet_with_zone (instance_start, FALSE, utc_zone);
ipt.end = icaltime_from_timet_with_zone (instance_end, FALSE, utc_zone);
ipt.duration = icaldurationtype_null_duration ();
-
+
/* add busy information to the vfb component */
prop = icalproperty_new (ICAL_FREEBUSY_PROPERTY);
icalproperty_set_freebusy (prop, ipt);
-
+
param = icalparameter_new_fbtype (ICAL_FBTYPE_BUSY);
icalproperty_add_parameter (prop, param);
-
+
icalcomponent_add_property (vfb, prop);
return TRUE;
static icalcomponent *
create_user_free_busy (ECalBackendFile *cbfile, const char *address, const char *cn,
time_t start, time_t end)
-{
+{
ECalBackendFilePrivate *priv;
GList *l;
icalcomponent *vfb;
icaltimezone *utc_zone;
ECalBackendSExp *obj_sexp;
char *query, *iso_start, *iso_end;
-
+
priv = cbfile->priv;
/* create the (unique) VFREEBUSY object that we'll return */
if (address != NULL) {
icalproperty *prop;
icalparameter *param;
-
+
prop = icalproperty_new_organizer (address);
if (prop != NULL && cn != NULL) {
param = icalparameter_new_cn (cn);
- icalproperty_add_parameter (prop, param);
+ icalproperty_add_parameter (prop, param);
}
if (prop != NULL)
- icalcomponent_add_property (vfb, prop);
+ icalcomponent_add_property (vfb, prop);
}
utc_zone = icaltimezone_get_utc_timezone ();
icalcomponent_set_dtstart (vfb, icaltime_from_timet_with_zone (start, FALSE, utc_zone));
ECalComponent *comp = l->data;
icalcomponent *icalcomp, *vcalendar_comp;
icalproperty *prop;
-
+
icalcomp = e_cal_component_get_icalcomponent (comp);
if (!icalcomp)
continue;
transp_val == ICAL_TRANSP_TRANSPARENTNOCONFLICT)
continue;
}
-
+
if (!e_cal_backend_sexp_match_comp (obj_sexp, l->data, E_CAL_BACKEND (cbfile)))
continue;
-
+
vcalendar_comp = icalcomponent_get_parent (icalcomp);
e_cal_recur_generate_instances (comp, start, end,
free_busy_instance,
}
g_object_unref (obj_sexp);
- return vfb;
+ return vfb;
}
/* Get_free_busy handler for the file backend */
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
- gchar *address, *name;
+ gchar *address, *name;
icalcomponent *vfb;
char *calobj;
GList *l;
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
*freebusy = NULL;
-
+
if (users == NULL) {
if (e_cal_backend_mail_account_get_default (&address, &name)) {
vfb = create_user_free_busy (cbfile, address, name, start, end);
icalcomponent_free (vfb);
g_free (address);
g_free (name);
- }
+ }
} else {
for (l = users; l != NULL; l = l->next ) {
- address = l->data;
+ address = l->data;
if (e_cal_backend_mail_account_is_valid (address, &name)) {
vfb = create_user_free_busy (cbfile, address, name, start, end);
calobj = icalcomponent_as_ical_string (vfb);
icalcomponent_free (vfb);
g_free (name);
}
- }
+ }
}
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
return GNOME_Evolution_Calendar_Success;
}
-typedef struct
+typedef struct
{
ECalBackendFile *backend;
icalcomponent_kind kind;
e_cal_backend_file_compute_changes_foreach_key (const char *key, gpointer value, gpointer data)
{
ECalBackendFileComputeChangesData *be_data = data;
-
+
if (!lookup_component (be_data->backend, key)) {
ECalComponent *comp;
g_free (filename);
return GNOME_Evolution_Calendar_OtherError;
}
-
+
g_free (filename);
-
+
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
/* Calculate adds and modifies */
be_data.kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbfile));
be_data.deletes = NULL;
be_data.ehash = ehash;
-
+
e_xmlhash_foreach_key_remove (ehash, (EXmlHashRemoveFunc)e_cal_backend_file_compute_changes_foreach_key, &be_data);
-
+
*deletes = be_data.deletes;
e_xmlhash_write (ehash);
e_xmlhash_destroy (ehash);
-
+
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
return GNOME_Evolution_Calendar_Success;
}
ECalComponentDateTime dt;
icaltimezone *zone, *default_zone;
- /* Check dtstart, dtend and due's timezone, and convert it to local
+ /* Check dtstart, dtend and due's timezone, and convert it to local
* default timezone if the timezone is not in our builtin timezone
* list */
e_cal_component_get_dtstart (comp, &dt);
}
}
e_cal_component_free_datetime (&dt);
-
+
e_cal_component_get_due (comp, &dt);
if (dt.value && dt.tzid) {
zone = e_cal_backend_file_internal_get_timezone ((ECalBackend *)cbfile, dt.tzid);
e_cal_component_free_datetime (&dt);
e_cal_component_abort_sequence (comp);
-}
+}
static ECalBackendSyncStatus
e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, char **calobj, char **uid)
ECalComponent *comp;
const char *comp_uid;
struct icaltimetype current;
-
+
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
}
static ECalBackendSyncStatus
-e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, const char *calobj,
+e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, const char *calobj,
CalObjModType mod, char **old_object, char **new_object)
{
RemoveRecurrenceData rrdata;
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
-
+
g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal);
g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
}
/* add the detached instance */
- g_hash_table_insert (obj_data->recurrences,
+ g_hash_table_insert (obj_data->recurrences,
g_strdup (rid),
comp);
icalcomponent_add_component (priv->icalcomp,
priv->comp = g_list_prepend (priv->comp, obj_data->full_object);
/* add the new detached recurrence */
- g_hash_table_insert (obj_data->recurrences,
+ g_hash_table_insert (obj_data->recurrences,
g_strdup (e_cal_component_get_recurid_as_string (comp)),
comp);
icalcomponent_add_component (priv->icalcomp,
start = icalcomponent_get_dtstart (icalcomp);
- /* This means its a instance generated from master object. So replace
+ /* This means its a instance generated from master object. So replace
the dates stored dates from the master object */
- if (!recur.zone)
+ if (!recur.zone)
recur.zone = start.zone;
-
+
if (icaltime_compare_date_only (start, recur) == 0) {
ECalComponentDateTime m_sdate, m_endate;
if (icaltime_compare (start, recur) != 0) {
icaltimetype end = icalcomponent_get_dtend (icalcomp);
-
+
m_sdate.value->hour = start.hour;
m_sdate.value->minute = start.minute;
- m_sdate.value->second =
-
+ m_sdate.value->second =
+
m_endate.value->hour = end.hour;
m_endate.value->minute = end.minute;
m_endate.value->second = end.second;
e_cal_component_set_dtend (comp, &m_endate);
e_cal_component_set_recurid (comp, NULL);
e_cal_component_commit_sequence (comp);
- }
+ }
e_cal_component_set_recurid (comp, NULL);
*new_object = e_cal_component_get_as_string (comp);
}
-
+
/* Remove the old version */
if (old_object)
*old_object = e_cal_component_get_as_string (obj_data->full_object);
e_cal_util_remove_instances (e_cal_component_get_icalcomponent (obj_data->full_object),
icaltime_from_string (rid), CALOBJ_MOD_THIS);
- /* add the modified object to the beginning of the list,
+ /* add the modified object to the beginning of the list,
so that it's always before any detached instance we
might have */
icalcomponent_add_component (cbfile->priv->icalcomp,
/* FIXME remove this once we delete an instance from master object through
modify request by setting exception */
return e_cal_component_get_as_string (comp);
- }
+ }
}
return NULL;
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
return GNOME_Evolution_Calendar_ObjectNotFound;
}
-
+
if (rid && *rid)
recur_id = rid;
-
+
comp = obj_data->full_object;
switch (mod) {
rrdata.mod = mod;
g_hash_table_foreach_remove (obj_data->recurrences, (GHRFunc) remove_object_instance_cb, &rrdata);
- /* add the modified object to the beginning of the list,
+ /* add the modified object to the beginning of the list,
so that it's always before any detached instance we
might have */
priv->comp = g_list_prepend (priv->comp, comp);
typedef struct {
GHashTable *zones;
-
+
gboolean found;
} ECalBackendFileTzidData;
{
ECalBackendFileTzidData *tzdata = data;
const char *tzid;
-
+
tzid = icalparameter_get_tzid (param);
if (!tzid || g_hash_table_lookup (tzdata->zones, tzid))
tzdata->found = FALSE;
/*FIXME get the uri rather than computing the path */
attach_store = g_build_filename (g_get_home_dir (),
".evolution/calendar/local/system", NULL);
-
+
for (l = attach_list; l ; l = l->next) {
char *sfname = (char *)l->data;
char *filename, *new_filename;
subcomp = icalcomponent_get_first_component (toplevel_comp, ICAL_VTIMEZONE_COMPONENT);
while (subcomp) {
icaltimezone *zone;
-
+
zone = icaltimezone_new ();
if (icaltimezone_set_component (zone, subcomp))
g_hash_table_insert (tzdata.zones, g_strdup (icaltimezone_get_tzid (zone)), NULL);
-
+
subcomp = icalcomponent_get_next_component (toplevel_comp, ICAL_VTIMEZONE_COMPONENT);
- }
+ }
/* First we make sure all the components are usuable */
comps = del_comps = NULL;
subcomp = icalcomponent_get_first_component (toplevel_comp, ICAL_ANY_COMPONENT);
while (subcomp) {
icalcomponent_kind child_kind = icalcomponent_isa (subcomp);
-
+
if (child_kind != kind) {
/* remove the component from the toplevel VCALENDAR */
if (child_kind != ICAL_VTIMEZONE_COMPONENT)
subcomp = icalcomponent_get_next_component (toplevel_comp, ICAL_ANY_COMPONENT);
continue;
}
-
+
tzdata.found = TRUE;
icalcomponent_foreach_tzid (subcomp, check_tzids, &tzdata);
status = GNOME_Evolution_Calendar_InvalidObject;
goto error;
}
-
+
if (!icalcomponent_get_uid (subcomp)) {
if (toplevel_method == ICAL_METHOD_PUBLISH) {
status = GNOME_Evolution_Calendar_InvalidObject;
goto error;
}
-
+
}
-
+
comps = g_list_prepend (comps, subcomp);
subcomp = icalcomponent_get_next_component (toplevel_comp, ICAL_ANY_COMPONENT);
}
ECalBackendFileObject *obj_data;
subcomp = l->data;
-
+
/* Create the cal component */
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, subcomp);
case ICAL_METHOD_COUNTER:
status = GNOME_Evolution_Calendar_UnsupportedMethod;
goto error;
- break;
- case ICAL_METHOD_DECLINECOUNTER:
+ break;
+ case ICAL_METHOD_DECLINECOUNTER:
status = GNOME_Evolution_Calendar_UnsupportedMethod;
goto error;
break;
}
g_list_free (comps);
-
+
/* Now we remove the components we don't care about */
for (l = del_comps; l; l = l->next) {
subcomp = l->data;
-
+
icalcomponent_remove_component (toplevel_comp, subcomp);
- icalcomponent_free (subcomp);
+ icalcomponent_free (subcomp);
}
-
+
g_list_free (del_comps);
/* Merge the iCalendar components with our existing VCALENDAR,
/**
* e_cal_backend_file_get_type:
- * @void:
- *
+ * @void:
+ *
* Registers the #ECalBackendFile class if necessary, and returns the type ID
* associated to it.
- *
+ *
* Return value: The type ID of the #ECalBackendFile class.
**/
GType
e_cal_backend_file_set_file_name (ECalBackendFile *cbfile, const char *file_name)
{
ECalBackendFilePrivate *priv;
-
+
g_return_if_fail (cbfile != NULL);
g_return_if_fail (E_IS_CAL_BACKEND_FILE (cbfile));
g_return_if_fail (file_name != NULL);
if (priv->file_name)
g_free (priv->file_name);
-
+
priv->file_name = g_strdup (file_name);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
g_return_val_if_fail (cbfile != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND_FILE (cbfile), NULL);
- priv = cbfile->priv;
+ priv = cbfile->priv;
return priv->file_name;
}
ECalBackendFilePrivate *priv;
char *str_uri;
ECalBackendSyncStatus status;
-
+
priv = cbfile->priv;
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
-#ifdef CONFIG_H
+#ifdef CONFIG_H
#include <config.h>
#endif
static const gchar *
get_protocol (ECalBackendFactory *factory)
{
- return "google";
+ return "google";
}
static ECalBackend *
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
G_END_DECLS
-#endif
+#endif
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#endif
#define GDATA_SCHEMA "http://schemas.google.com/g/2005#"
-#define CACHE_REFRESH_INTERVAL 10000
+#define CACHE_REFRESH_INTERVAL 10000
/****************************************************** Google Connection Helper Functions ***********************************************/
static void utils_update_insertion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, EGoItem *item, GSList *cache_keys);
static void utils_update_deletion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, GSList *cache_keys);
-/**
+/**
*
* e_cal_backend_google_utils_populate_cache:
* @cbgo ECalBackendGoogle Object
* Populates the cache with intial values
- *
+ *
**/
static void
-e_cal_backend_google_utils_populate_cache (ECalBackendGoogle *cbgo)
+e_cal_backend_google_utils_populate_cache (ECalBackendGoogle *cbgo)
{
ECalComponent *comp=NULL;
ECalBackendCache *cache;
cache = e_cal_backend_google_get_cache (cbgo);
kind = e_cal_backend_get_kind (E_CAL_BACKEND(cbgo));
temp = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-
- item = e_cal_backend_google_get_item (cbgo);
+
+ item = e_cal_backend_google_get_item (cbgo);
entries = gdata_feed_get_entries (item->feed);
priv = cbgo->priv;
gchar *comp_str;
e_cal_component_commit_sequence (comp);
comp_str = e_cal_component_get_as_string (comp);
-
+
e_cal_backend_notify_object_created (E_CAL_BACKEND(cbgo), (const char *)comp_str);
e_cal_backend_cache_put_component (cache, comp);
g_object_unref (comp);
}
}
-
- e_cal_backend_notify_view_done (E_CAL_BACKEND(cbgo), GNOME_Evolution_Calendar_Success);
+
+ e_cal_backend_notify_view_done (E_CAL_BACKEND(cbgo), GNOME_Evolution_Calendar_Success);
}
/**
- *
+ *
* e_cal_backend_google_utils_create_cache:
- * @cbgo: ECalBackendGoogle
- * Creates / Updates Cache
- *
+ * @cbgo: ECalBackendGoogle
+ * Creates / Updates Cache
+ *
**/
-static gpointer
+static gpointer
e_cal_backend_google_utils_create_cache (ECalBackendGoogle *cbgo)
{
ESource *source;
const gchar *refresh_interval = NULL;
ECalBackendCache *cache;
- source = e_cal_backend_get_source (E_CAL_BACKEND (cbgo));
+ source = e_cal_backend_get_source (E_CAL_BACKEND (cbgo));
refresh_interval = e_source_get_property (source, "refresh");
cache = e_cal_backend_google_get_cache (cbgo);
e_cal_backend_cache_set_marker (cache);
} else
get_deltas_timeout (cbgo);
-
+
if (refresh_interval)
x = atoi (refresh_interval);
(gpointer)cbgo);
e_cal_backend_google_set_timeout_id (cbgo, timeout_id);
- return GINT_TO_POINTER (GNOME_Evolution_Calendar_Success);
+ return GINT_TO_POINTER (GNOME_Evolution_Calendar_Success);
}
/**
* e_cal_backend_google_utils_update:
*
- * @handle:
- * Call this to Update changes, made to the calendar.
+ * @handle:
+ * Call this to Update changes, made to the calendar.
*
- * Return value: TRUE if update is successful FALSE otherwise .
+ * Return value: TRUE if update is successful FALSE otherwise .
**/
-gboolean
+gboolean
e_cal_backend_google_utils_update (gpointer handle)
{
ECalBackendGoogle *cbgo;
cbgo = (ECalBackendGoogle *)handle;
priv = cbgo->priv;
-
+
cache = e_cal_backend_google_get_cache (cbgo);
item = e_cal_backend_google_get_item (cbgo);
service = e_cal_backend_google_get_service (cbgo);
uri = e_cal_backend_google_get_uri (cbgo);
-
+
item->feed = gdata_service_get_feed (GDATA_SERVICE(service), uri);
entries_list = gdata_feed_get_entries (item->feed);
cache_keys = e_cal_backend_cache_get_keys (cache);
- kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgo));
-
+ kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgo));
+
for (iter_list = entries_list; iter_list != NULL; iter_list = iter_list->next) {
gchar *id;
id = gdata_entry_get_id ((GDataEntry *)iter_list->data);
if (!(remove = g_slist_find_custom (cache_keys, iter_list->data, func))) {
uid_list = g_slist_prepend (uid_list, g_strdup ((gchar *)iter_list->data));
- needs_to_insert = TRUE;
+ needs_to_insert = TRUE;
}else {
- cache_keys = g_slist_remove_link (cache_keys, remove);
+ cache_keys = g_slist_remove_link (cache_keys, remove);
}
- if (remove)
+ if (remove)
g_slist_free (remove);
}
utils_update_insertion (cbgo, cache, item,uid_list);
needs_to_insert = FALSE;
}
-
+
if (ids_list) {
ids_list = NULL;
g_slist_free (ids_list);
}
-
+
if (uid_list) {
/*FIXME could crash while freeing*/
uid_list = NULL;
g_slist_free (uid_list);
}
-
+
if (entries_list) {
/* FIXME could crash while freeing */
entries_list = NULL;
}
ECalBackendSyncStatus
-e_cal_backend_google_utils_connect (ECalBackendGoogle *cbgo)
+e_cal_backend_google_utils_connect (ECalBackendGoogle *cbgo)
{
ECalBackendCache *cache;
EGoItem *item;
ESource *source;
GDataFeed *feed;
GDataGoogleService *service;
-
+
ECalSourceType source_type;
icalcomponent_kind kind;
icaltimezone *default_zone;
gchar *uri, *suri;
source = e_cal_backend_get_source (E_CAL_BACKEND(cbgo));
-
+
service = gdata_google_service_new ("cl", "evolution-client-0.0.1");
e_cal_backend_google_set_service (cbgo, service);
e_cal_backend_google_set_uri (cbgo, uri);
g_free (suri);
-
+
username = e_cal_backend_google_get_username (cbgo);
password = e_cal_backend_google_get_password (cbgo);
gdata_service_set_credentials (GDATA_SERVICE(service), username, password);
feed = gdata_service_get_feed (GDATA_SERVICE(service), uri);
-
+
if (!feed) {
g_critical ("%s, Authentication Failed \n ", G_STRLOC);
return GNOME_Evolution_Calendar_AuthenticationFailed;
}
-
+
entries = gdata_feed_get_entries (feed);
-
+
item = g_new0 (EGoItem, 1);
item->entry = e_cal_backend_google_get_entry (cbgo);
item->feed = feed;
-
+
cache = e_cal_backend_google_get_cache (cbgo);
service = e_cal_backend_google_get_service (cbgo);
e_cal_backend_google_set_item (cbgo, item);
-
+
/* For event sync */
if (cache && service) {
-
+
/* FIXME Get the current mode */
mode_changed = FALSE;
timeout_id = e_cal_backend_google_get_timeout_id (cbgo);
if (!mode_changed && !timeout_id) {
- GThread *t1;
+ GThread *t1;
- /*FIXME Set the mode to be changed */
+ /*FIXME Set the mode to be changed */
t1 = g_thread_create ((GThreadFunc)e_cal_backend_google_utils_update, cbgo, FALSE, NULL);
if (!t1) {
e_cal_backend_notify_error (E_CAL_BACKEND (cbgo), _("Could not create thread for getting deltas"));
timeout_id = g_timeout_add (CACHE_REFRESH_INTERVAL, (GSourceFunc) get_deltas_timeout, (gpointer)cbgo);
e_cal_backend_google_set_timeout_id (cbgo, timeout_id);
}
-
- return GNOME_Evolution_Calendar_Success;
- }
+
+ return GNOME_Evolution_Calendar_Success;
+ }
/* FIXME Set the mode to be changed */
kind = e_cal_backend_get_kind (E_CAL_BACKEND(cbgo));
switch (kind) {
default:
source_type = E_CAL_SOURCE_TYPE_EVENT;
}
-
+
/* Creating cache when in remote */
if (GDATA_IS_GOOGLE_SERVICE (service)) {
cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgo)),source_type);
return GNOME_Evolution_Calendar_OtherError;
}
- default_zone = e_cal_backend_google_get_default_zone (cbgo);
+ default_zone = e_cal_backend_google_get_default_zone (cbgo);
e_cal_backend_cache_put_default_timezone (cache, default_zone);
e_cal_backend_google_utils_create_cache (cbgo);
thread = g_thread_create ((GThreadFunc)e_cal_backend_google_utils_create_cache, (gpointer) cbgo, FALSE, &error);
e_cal_backend_notify_error (E_CAL_BACKEND (cbgo), _("Could not create thread for populating cache"));
return GNOME_Evolution_Calendar_OtherError;
- }
+ }
return GNOME_Evolution_Calendar_Success;
}
-/*************************************************** EGoItem Functions*********************************************/
+/*************************************************** EGoItem Functions*********************************************/
/**
* e_go_item_to_cal_component:
* @item a EGoItem object
* @cbgo a ECalBackendGoogle object
- *
+ *
* Creates a EGoItem from ECalComponent
**/
ECalComponentText text;
ECalComponentDateTime dt;
icaltimezone *default_zone;
- const char *description, *uid, *temp;
+ const char *description, *uid, *temp;
struct icaltimetype itt_utc, itt;
GSList *category_ids;
comp = e_cal_component_new ();
default_zone = e_cal_backend_google_get_default_zone (cbgo);
-
+
if (!default_zone)
g_message("Critical Default zone not set %s", G_STRLOC);
-
+
e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
/* Description*/
description = gdata_entry_get_content (item->entry);
if (description) {
- GSList l;
+ GSList l;
text.value = description;
text.altrep = NULL;
l.data = &text;
e_cal_component_set_description_list (comp, &l);
}
-
+
/*Creation*/
temp = gdata_entry_get_start_time (item->entry);
temp = gd_date_to_ical (g_strdup(temp));
-
+
if (temp) {
itt_utc = icaltime_from_string (temp);
itt_utc.zone = default_zone;
if (!icaltime_get_timezone (itt_utc))
icaltime_set_timezone (&itt_utc, icaltimezone_get_utc_timezone());
if (default_zone) {
- itt = icaltime_convert_to_zone (itt_utc, default_zone);
+ itt = icaltime_convert_to_zone (itt_utc, default_zone);
icaltime_set_timezone (&itt, default_zone);
e_cal_component_set_created (comp, &itt);
e_cal_component_set_dtstamp (comp, &itt);
}
dt.value = &itt;
dt.tzid = icaltimezone_get_tzid (default_zone);
- e_cal_component_set_dtstart (comp, &dt);
+ e_cal_component_set_dtstart (comp, &dt);
e_cal_component_set_created (comp, &itt_utc);
e_cal_component_set_dtstamp (comp, &itt_utc);
-
+
/* Summary of the Entry */
- text.value = gdata_entry_get_title (item->entry);
+ text.value = gdata_entry_get_title (item->entry);
text.altrep = NULL;
if (text.value != NULL)
e_cal_component_set_summary (comp, &text);
temp = NULL;
temp = gdata_entry_get_visibility (item->entry);
- if (temp)
+ if (temp)
e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PUBLIC);
else
e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_NONE);
/* Attendees */
GSList *go_attendee_list = NULL, *l = NULL, *attendee_list = NULL;
go_attendee_list = gdata_entry_get_attendee_list (item->entry);
-
+
if (go_attendee_list != NULL) {
-
+
for (l = go_attendee_list; l != NULL; l = l->next) {
- Attendee *go_attendee;
+ Attendee *go_attendee;
go_attendee = (Attendee *)l->data;
-
+
ECalComponentAttendee *attendee = g_new0 (ECalComponentAttendee, 1);
-
+
attendee->cn = g_strdup (go_attendee->attendee_value);
attendee->value = g_strconcat ("MAILTO:", go_attendee->attendee_email, NULL);
attendee->role = ICAL_ROLE_OPTPARTICIPANT;
attendee->status = ICAL_PARTSTAT_ACCEPTED;
-
- attendee_list = g_slist_prepend (attendee_list, attendee);
+
+ attendee_list = g_slist_prepend (attendee_list, attendee);
}
e_cal_component_set_attendee_list (comp, attendee_list);
- }
+ }
/* Location */
e_cal_component_set_location (comp, gdata_entry_get_location (item->entry));
itt_utc = icaltime_from_string (temp);
/*
- * TODO : Write a small func to check if its all day and set it to true , and check for it here .
- * Evolution Automatically recognises all day event from google . so why bother ?
- * Considering not to be a all day event . FIXME needs further work .
+ * TODO : Write a small func to check if its all day and set it to true , and check for it here .
+ * Evolution Automatically recognises all day event from google . so why bother ?
+ * Considering not to be a all day event . FIXME needs further work .
*/
if (FALSE) {
if (!icaltime_get_timezone (itt_utc))
icaltime_set_timezone (&itt_utc, icaltimezone_get_utc_timezone());
if (default_zone) {
- itt = icaltime_convert_to_zone (itt_utc, default_zone);
+ itt = icaltime_convert_to_zone (itt_utc, default_zone);
icaltime_set_timezone (&itt, default_zone);
dt.value = &itt;
dt.tzid = icaltimezone_get_tzid (default_zone);
dt.tzid = g_strdup ("UTC");
}
} else {
- itt = icaltime_convert_to_zone (itt_utc, default_zone);
+ itt = icaltime_convert_to_zone (itt_utc, default_zone);
icaltime_set_timezone (&itt, default_zone);
dt.value = &itt;
- dt.tzid = icaltimezone_get_tzid (default_zone);
+ dt.tzid = icaltimezone_get_tzid (default_zone);
}
}
/**
- *
+ *
* e_go_item_from_cal_component:
- * @cbgo a ECalBackendGoogle
+ * @cbgo a ECalBackendGoogle
* @comp a ECalComponent object
* Creates a ECalComponent from EGoItem
*
icaltimetype itt;
const char *uid;
const char *location;
-
+
priv = cbgo->priv;
GSList *list = NULL;
GDataEntry *entry;
item = g_new0 (EGoItem, 1);
- entry = gdata_entry_new ();
+ entry = gdata_entry_new ();
/* Summary */
e_cal_component_get_summary (comp, &text);
- if (text.value!=NULL)
+ if (text.value!=NULL)
gdata_entry_set_title (entry, text.value);
default_zone = e_cal_backend_google_get_default_zone (cbgo);
/* Start time */
e_cal_component_get_dtstart (comp, &dt);
- itt = icaltime_convert_to_zone (*dt.value, default_zone);
+ itt = icaltime_convert_to_zone (*dt.value, default_zone);
dt.value = &itt;
temp = g_strdup (get_date (dt));
gdata_entry_set_start_time (entry, temp);
/* End Time */
e_cal_component_get_dtend (comp, &dt);
- itt = icaltime_convert_to_zone (*dt.value, default_zone);
+ itt = icaltime_convert_to_zone (*dt.value, default_zone);
dt.value = &itt;
temp = g_strdup (get_date (dt));
gdata_entry_set_end_time (entry, temp);
/* Content / Description */
e_cal_component_get_description_list (comp, &list);
- ECalComponentText *t;
+ ECalComponentText *t;
if (list != NULL) {
t = (ECalComponentText *)list->data;
gdata_entry_set_content (entry, t->value);
}
- else
+ else
gdata_entry_set_content (entry, "");
- e_cal_component_get_uid (comp, &uid);
- gdata_entry_set_id (entry, g_strdup(uid));
+ e_cal_component_get_uid (comp, &uid);
+ gdata_entry_set_id (entry, g_strdup(uid));
/* Location */
e_cal_component_get_location (comp, &location);
if (location)
gdata_entry_set_location (entry , location);
- if (e_cal_backend_get_kind (E_CAL_BACKEND(cbgo)) == ICAL_VEVENT_COMPONENT)
+ if (e_cal_backend_get_kind (E_CAL_BACKEND(cbgo)) == ICAL_VEVENT_COMPONENT)
term = g_strconcat (GDATA_SCHEMA, "event", NULL);
- gdata_entry_create_categories (entry, g_strconcat (GDATA_SCHEMA, "kind", NULL),
+ gdata_entry_create_categories (entry, g_strconcat (GDATA_SCHEMA, "kind", NULL),
"label",
term);
/* Attendee */
GSList *attendee_list = NULL, *l = NULL;
- e_cal_component_get_attendee_list (comp, &attendee_list);
-
+ e_cal_component_get_attendee_list (comp, &attendee_list);
+
for (l = attendee_list; l!=NULL; l=l->next) {
ECalComponentAttendee *ecal_att;
ecal_att = (ECalComponentAttendee *)l->data;
/* TODO Convert ECalComponentAttendee to Attendee, and change during parsing to store the types */
-
+
}
/* FIXME For transparency and status */
}
/**
- *
+ *
* e_go_item_get_entry:
* @item a EGoItem
* Returns the GDataEntry object
- *
+ *
**/
GDataEntry *
/**
- *
+ *
* e_go_item_set_entry:
- * @item a EGoItem
- * @entry a GDataEntry
- * Sets the GDataEntry of EGoItem to entry
- *
+ * @item a EGoItem
+ * @entry a GDataEntry
+ * Sets the GDataEntry of EGoItem to entry
+ *
**/
void
e_go_item_set_entry (EGoItem *item, GDataEntry *entry)
* gdata_entry_get_entry_by_id:
* @entries List of entries
* @id id to retreive
- * Gets the specified entry
+ * Gets the specified entry
*
**/
GDataEntry *
-gdata_entry_get_entry_by_id (GSList *entries, const gchar *id)
+gdata_entry_get_entry_by_id (GSList *entries, const gchar *id)
{
GSList *l = NULL;
return l->data;
}
}
-
+
return NULL;
}
/***************************************************************** Utility Functions *********************************************/
-static gint
-utils_compare_ids (gconstpointer cache_id, gconstpointer modified_cache_id)
+static gint
+utils_compare_ids (gconstpointer cache_id, gconstpointer modified_cache_id)
{
return strcmp ((char *)cache_id, (char *)modified_cache_id);
}
-static gchar *
+static gchar *
utils_form_query (const gchar *query)
{
if (query!=NULL) {
}
static void
-utils_update_insertion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, EGoItem *item, GSList *uid_list)
+utils_update_insertion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, EGoItem *item, GSList *uid_list)
{
EGoItem *item_t;
ECalComponent *comp;
GSList *list = NULL, *entries_list = NULL;
GDataEntry *entry;
- gchar *temp;
+ gchar *temp;
comp = e_cal_component_new ();
item_t = g_new0 (EGoItem, 1);
for (list = uid_list; list != NULL; list = list->next) {
entry = gdata_entry_get_entry_by_id (entries_list, list->data);
item_t->entry = entry;
- comp = e_go_item_to_cal_component (item_t, cbgo);
-
+ comp = e_go_item_to_cal_component (item_t, cbgo);
+
if (comp) {
e_cal_component_commit_sequence (comp);
e_cal_backend_cache_put_component (cache, comp);
temp = e_cal_component_get_as_string (comp);
-
+
e_cal_backend_notify_object_created (E_CAL_BACKEND(cbgo), temp);
-
+
g_free (temp);
g_object_unref (comp);
}
}
-
+
g_free (item_t);
- if (list)
+ if (list)
g_slist_free (list);
if (entries_list)
g_slist_free (entries_list);
static void
-utils_update_deletion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, GSList *cache_keys)
+utils_update_deletion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, GSList *cache_keys)
{
ECalComponent *comp;
GSList *list;
g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE (cbgo));
g_return_if_fail (cache != NULL && cbgo != NULL);
g_return_if_fail (cache_keys != NULL);
-
+
for (list = cache_keys; list; list = g_slist_next (list)) {
ECalComponentId *id = NULL;
char *comp_str = NULL;
- comp = e_cal_backend_cache_get_component (cache, (const char *)list->data, NULL);
+ comp = e_cal_backend_cache_get_component (cache, (const char *)list->data, NULL);
comp_str = e_cal_component_get_as_string (comp);
id = e_cal_component_get_id (comp);
/**
* get_date: Returns date in gdata format '2006-04-17T17:00:00.000Z'
- * @dt a #ECalComponentDateTime value
+ * @dt a #ECalComponentDateTime value
**/
/* FIXME use proper functions to manipulate the dates */
gchar *
itt.is_utc = itt_u->is_utc;
itt.is_date = itt_u->is_date;
itt.is_daylight = itt_u->is_daylight;
- itt.zone = itt_u->zone;
+ itt.zone = itt_u->zone;
temp = icaltime_as_ical_string(itt);
second = (itt.second<10) ? g_strdup_printf ("0%d", itt.second):g_strdup_printf ("%d", itt.second);
temp = g_strdup_printf ("%d-%s-%sT%s:%s:%s.000", itt.year, month, day, hour, minute, second);
-
+
return g_strdup(temp);
}
static gboolean
-get_deltas_timeout (gpointer cbgo)
+get_deltas_timeout (gpointer cbgo)
{
GThread *thread;
-
+
if (!cbgo)
return FALSE;
/* FIXME */
}
- return TRUE;
+ return TRUE;
}
/**
- *
- * gd_date_to_ical:
+ *
+ * gd_date_to_ical:
* Helper Function to convert a gdata format date to ical date
- * @string date in gdata format eg: '2006-04-17T17:00:00.000Z'
- *
- **/
+ * @string date in gdata format eg: '2006-04-17T17:00:00.000Z'
+ *
+ **/
/* FIXME use proper functions to manipulate the dates */
static gchar *
gd_date_to_ical (gchar *string)
g_return_val_if_fail (string != NULL, "");
- /* Strip of the string to the gdata format */
- while (s[0] != '\0') {
+ /* Strip of the string to the gdata format */
+ while (s[0] != '\0') {
if ((s[0] != '-') && (s[0] != '+') && (s[0] != ':') && (s[0] != '.')) {
*string = *s;
string = string + 1;
s = s + 1;
count = count + 1;
- }else
+ }else
s = s + 1;
if (count == 15) {
- string[0] = '\0';
+ string[0] = '\0';
break;
}
- if (s[1] == '\0')
+ if (s[1] == '\0')
string[0] = '\0';
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
gdata_entry_get_entry_by_id (GSList *entries, const gchar *id);
ECalBackendSyncStatus
-e_cal_backend_google_utils_connect (ECalBackendGoogle *cbgo);
+e_cal_backend_google_utils_connect (ECalBackendGoogle *cbgo);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
icaltimezone *default_zone;
CalMode mode;
EGoItem *item;
-
+
gint timeout_id;
gchar *username;
gchar *password;
- gchar *uri;
+ gchar *uri;
gchar *feed;
-
+
gboolean read_only;
gboolean mode_changed;
-
+
};
gint compare_ids (gconstpointer cache_id, gconstpointer modified_cache_id);
gchar * form_query (const char *query);
-gint
-compare_ids (gconstpointer cache_id, gconstpointer modified_cache_id)
+gint
+compare_ids (gconstpointer cache_id, gconstpointer modified_cache_id)
{
return strcmp (cache_id, modified_cache_id);
}
e_cal_backend_google_internal_get_default_timezone (ECalBackend *backend)
{
ECalBackendGoogle *cbgo = E_CAL_BACKEND_GOOGLE (backend);
- return cbgo->priv->default_zone;
+ return cbgo->priv->default_zone;
}
static icaltimezone *
}
static ECalBackendSyncStatus
-e_cal_backend_google_get_free_busy (ECalBackendSync *backend,
- EDataCal *cal,
- GList *users,
- time_t start,
- time_t end,
+e_cal_backend_google_get_free_busy (ECalBackendSync *backend,
+ EDataCal *cal,
+ GList *users,
+ time_t start,
+ time_t end,
GList **free_busy)
{
-
+
/*FIXME*/
return GNOME_Evolution_Calendar_Success;
}
{
ECalBackendGoogle *cbgo;
ECalBackendGooglePrivate *priv;
-
+
cbgo = E_CAL_BACKEND_GOOGLE (backend);
priv = cbgo->priv;
-
+
g_mutex_lock (priv->mutex);
/* Remove the cache */
if (priv->cache) {
e_file_cache_remove (E_FILE_CACHE (priv->cache));
}
-
+
g_mutex_unlock (priv->mutex);
return GNOME_Evolution_Calendar_Success;
cbgo = E_CAL_BACKEND_GOOGLE (backend);
priv = cbgo->priv;
-
+
return priv->mode;
}
-static ECalBackendSyncStatus
+static ECalBackendSyncStatus
e_cal_backend_google_get_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid, char **object)
{
ECalBackendGoogle *cbgo;
return GNOME_Evolution_Calendar_ObjectNotFound;
}
-static ECalBackendSyncStatus
+static ECalBackendSyncStatus
e_cal_backend_google_get_object_list (ECalBackendSync *backend, EDataCal *cal, const char *sexp, GList **objects)
{
ECalBackendGoogle *cbgo;
ECalBackendSExp *cbsexp;
gboolean search_needed = TRUE;
- cbgo = E_CAL_BACKEND_GOOGLE (backend);
+ cbgo = E_CAL_BACKEND_GOOGLE (backend);
priv = cbgo->priv;
g_mutex_lock (priv->mutex);
if ((!search_needed) ||
(e_cal_backend_sexp_match_comp (cbsexp, comp, E_CAL_BACKEND (backend)))) {
*objects = g_list_append (*objects, e_cal_component_get_as_string (comp));
- }
- }
- }
-
+ }
+ }
+ }
+
g_object_unref (cbsexp);
g_list_foreach (components, (GFunc) g_object_unref, NULL);
g_list_free (components);
return GNOME_Evolution_Calendar_Success;
}
-static void
+static void
e_cal_backend_google_start_query (ECalBackend *backend, EDataCalView *query)
{
ECalBackendSyncStatus status;
/* free memory */
g_list_foreach (objects, (GFunc)g_free, NULL);
g_list_free (objects);
- }
+ }
e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_Success);
}
e_cal_backend_google_get_default_object (ECalBackendSync *backend, EDataCal *cal, char **object)
{
ECalComponent *comp;
-
+
comp = e_cal_component_new ();
switch (e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
case ICAL_VEVENT_COMPONENT:
}
*object = e_cal_component_get_as_string (comp);
-
+
if (comp)
g_object_unref (comp);
return GNOME_Evolution_Calendar_Success;
zone = icaltimezone_new ();
icaltimezone_set_component (zone, tz_comp);
- if (priv->default_zone)
+ if (priv->default_zone)
icaltimezone_free (priv->default_zone, 1);
priv->default_zone = zone;
e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_SET,
cal_mode_to_corba (mode));
return;
- }
+ }
g_mutex_lock (priv->mutex);
default:
e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
cal_mode_to_corba (mode));
- }
+ }
g_mutex_unlock (priv->mutex);
}
static ECalBackendSyncStatus
-e_cal_backend_google_receive_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj)
+e_cal_backend_google_receive_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj)
{
/* FIXME Not implemented */
return GNOME_Evolution_Calendar_Success;
}
/* Is read only handler for the google backend */
-static ECalBackendSyncStatus
+static ECalBackendSyncStatus
e_cal_backend_google_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
{
/* FIXME */
- *read_only = FALSE;
+ *read_only = FALSE;
return GNOME_Evolution_Calendar_Success;
}
priv = cbgo->priv;
/* FIXME */
- *address = g_strdup (priv->username);
+ *address = g_strdup (priv->username);
return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static ECalBackendSyncStatus
e_cal_backend_google_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, char **address)
{
/* Support email based alarms ? */
-
+
/* FIXME */
*address = NULL;
return GNOME_Evolution_Calendar_Success;
const char *uid=NULL, *rid=NULL;
GDataEntry *entry, *entry_from_server=NULL;
gchar *edit_link;
-
+
*old_object = NULL;
cbgo = E_CAL_BACKEND_GOOGLE (backend);
priv = cbgo->priv;
-
+
g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE (cbgo), GNOME_Evolution_Calendar_InvalidObject);
g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_InvalidObject);
if (priv->mode == CAL_MODE_LOCAL) {
/* FIXME */
return GNOME_Evolution_Calendar_RepositoryOffline;
- }
+ }
icalcomp = icalparser_parse_string (calobj);
if (!icalcomp)
item->feed = gdata_service_get_feed (GDATA_SERVICE(priv->service), priv->uri);
entry = item->entry;
- if (!item->feed) {
+ if (!item->feed) {
g_message ("CRITICAL: Could not find feed in EGoItem %s", G_STRLOC);
g_object_unref (comp);
return GNOME_Evolution_Calendar_OtherError;
return GNOME_Evolution_Calendar_OtherError;
}
- edit_link = gdata_entry_get_edit_link (entry_from_server);
- gdata_service_update_entry_with_link (GDATA_SERVICE (priv->service), entry, edit_link);
+ edit_link = gdata_entry_get_edit_link (entry_from_server);
+ gdata_service_update_entry_with_link (GDATA_SERVICE (priv->service), entry, edit_link);
break;
case CAL_MODE_LOCAL:
e_cal_backend_cache_put_component (priv->cache, comp);
*old_object = e_cal_component_get_as_string (cache_comp);
*new_object = e_cal_component_get_as_string (comp);
- g_object_unref (cache_comp);
+ g_object_unref (cache_comp);
g_object_unref (comp);
- return GNOME_Evolution_Calendar_Success;
+ return GNOME_Evolution_Calendar_Success;
}
cbgo = E_CAL_BACKEND_GOOGLE (backend);
priv = cbgo->priv;
item = priv->item;
-
+
*old_object = *object = NULL;
- /* FIXME */
- item->feed = gdata_service_get_feed (GDATA_SERVICE(priv->service), priv->uri);
-
+ /* FIXME */
+ item->feed = gdata_service_get_feed (GDATA_SERVICE(priv->service), priv->uri);
+
entries = gdata_feed_get_entries (item->feed);
-
+
if (priv->mode == CAL_MODE_REMOTE) {
ECalBackendSyncStatus status;
icalcomponent *icalcomp;
ECalComponentId *id;
-
+
status = e_cal_backend_google_get_object (backend, cal, uid, rid, &calobj);
-
+
if (status != GNOME_Evolution_Calendar_Success)
return status;
-
+
comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
id = e_cal_component_get_id (comp);
-
+
icalcomp = icalparser_parse_string (calobj);
if (!icalcomp) {
e_cal_backend_cache_remove_component (priv->cache, uid, rid);
e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgo), id, e_cal_component_get_as_string (comp), NULL);
-
+
entry = gdata_entry_get_entry_by_id (entries, uid);
-
- if (!entry)
- return GNOME_Evolution_Calendar_InvalidObject;
-
+
+ if (!entry)
+ return GNOME_Evolution_Calendar_InvalidObject;
+
gdata_service_delete_entry (GDATA_SERVICE(priv->service), entry);
*object = NULL;
*old_object = strdup (calobj);
}
if (calobj)
- g_free (calobj);
- if (entries)
+ g_free (calobj);
+ if (entries)
g_slist_free (entries);
-
+
return GNOME_Evolution_Calendar_Success;
}
ECalBackendGooglePrivate *priv;
icalcomponent *icalcomp;
ECalComponent *comp;
- EGoItem *item;
+ EGoItem *item;
GDataEntry *entry;
- const gchar *id;
+ const gchar *id;
cbgo = E_CAL_BACKEND_GOOGLE (backend);
-
+
g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo), GNOME_Evolution_Calendar_InvalidObject);
- g_return_val_if_fail (calobj != NULL && *calobj!=NULL,GNOME_Evolution_Calendar_InvalidObject);
+ g_return_val_if_fail (calobj != NULL && *calobj!=NULL,GNOME_Evolution_Calendar_InvalidObject);
priv = cbgo->priv;
if (priv->mode == CAL_MODE_LOCAL) {
/*FIXME call offline method */
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomp);
-
+
/* Check if object exists */
switch (priv->mode) {
case CAL_MODE_ANY:
case CAL_MODE_REMOTE:
/* Create an appointment */
-
+
item = e_go_item_from_cal_component (cbgo, comp);
entry = e_go_item_get_entry (item);
break;
default:
- break;
- }
+ break;
+ }
/* Go through the uid list to create the objects */
e_cal_component_commit_sequence (comp);
e_cal_backend_cache_put_component (priv->cache, comp);
- *calobj = e_cal_component_get_as_string (comp);
+ *calobj = e_cal_component_get_as_string (comp);
e_cal_backend_notify_object_created (E_CAL_BACKEND(cbgo), *calobj);
g_object_unref (comp);
return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static ECalBackendSyncStatus
e_cal_backend_google_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, char **attribute)
{
/* ldap attribute is specific to Sun ONE connector to get free busy information*/
/* return NULL here as google backend know how to get free busy information */
-
+
/* FIXME */
*attribute = NULL;
return GNOME_Evolution_Calendar_Success;
}
-static ECalBackendSyncStatus
+static ECalBackendSyncStatus
e_cal_backend_google_get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, char **capabilities)
{
/* FIXME */
source_type = E_CAL_SOURCE_TYPE_TODO;
source = "tasks";
break;
- case ICAL_VJOURNAL_COMPONENT:
- source_type = E_CAL_SOURCE_TYPE_JOURNAL;
+ case ICAL_VJOURNAL_COMPONENT:
+ source_type = E_CAL_SOURCE_TYPE_JOURNAL;
source = "journal";
break;
default:
source_type = E_CAL_SOURCE_TYPE_EVENT;
}
- /* Not for remote */
+ /* Not for remote */
if (priv->mode == CAL_MODE_LOCAL) {
ESource *esource;
const char *display_contents = NULL;
}
/* Dipose handler for google backend */
-static void
+static void
e_cal_backend_google_dispose (GObject *object)
{
ECalBackendGoogle *cbgo;
if (priv->mutex) {
g_mutex_free (priv->mutex);
- priv->mutex = NULL;
+ priv->mutex = NULL;
}
if (priv->username) {
icaltimezone_free (priv->default_zone, 1);
priv->default_zone = NULL;
}
-
+
if (priv->timeout_id) {
g_source_remove (priv->timeout_id);
priv->timeout_id = 0;
static void
e_cal_backend_google_init (ECalBackendGoogle *cbgo, ECalBackendGoogleClass *class)
{
- ECalBackendGooglePrivate *priv;
+ ECalBackendGooglePrivate *priv;
priv = g_new0 (ECalBackendGooglePrivate, 1);
e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbgo), TRUE);
}
-icaltimezone *
-e_cal_backend_google_get_default_zone (ECalBackendGoogle *cbgo)
+icaltimezone *
+e_cal_backend_google_get_default_zone (ECalBackendGoogle *cbgo)
{
g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo), NULL);
return cbgo->priv->default_zone;
parent_class = g_type_class_peek_parent (class);
object_class->dispose = e_cal_backend_google_dispose;
- object_class->finalize = e_cal_backend_google_finalize;
+ object_class->finalize = e_cal_backend_google_finalize;
sync_class->is_read_only_sync = e_cal_backend_google_is_read_only;
sync_class->get_cal_address_sync = e_cal_backend_google_get_cal_address;
sync_class->get_ldap_attribute_sync = e_cal_backend_google_get_ldap_attribute;
sync_class->get_static_capabilities_sync = e_cal_backend_google_get_static_capabilities;
sync_class->open_sync = e_cal_backend_google_open;
- sync_class->remove_sync = e_cal_backend_google_remove;
- sync_class->create_object_sync = e_cal_backend_google_create_object;
+ sync_class->remove_sync = e_cal_backend_google_remove;
+ sync_class->create_object_sync = e_cal_backend_google_create_object;
sync_class->modify_object_sync = e_cal_backend_google_modify_object;
- sync_class->remove_object_sync = e_cal_backend_google_remove_object;
+ sync_class->remove_object_sync = e_cal_backend_google_remove_object;
sync_class->discard_alarm_sync = e_cal_backend_google_discard_alarm;
sync_class->receive_objects_sync = e_cal_backend_google_receive_objects;
sync_class->send_objects_sync = e_cal_backend_google_send_objects;
/**
* e_cal_backend_google_get_type:
* @void:
- * Registers the #ECalBackendGoogle class if necessary and returns the type ID
+ * Registers the #ECalBackendGoogle class if necessary and returns the type ID
* associated with it
* Return value: The type id of the #ECalBackendGoogle class.
**/
0,
(GInstanceInitFunc) e_cal_backend_google_init
};
- e_cal_backend_google_type = g_type_register_static (E_TYPE_CAL_BACKEND_SYNC,
+ e_cal_backend_google_type = g_type_register_static (E_TYPE_CAL_BACKEND_SYNC,
"ECalBackendGoogle", &info, 0);
}
- return e_cal_backend_google_type;
+ return e_cal_backend_google_type;
}
/***************************************** Helper Functions ****************************************************/
/**
- * e_cal_backend_google_set_cache:
+ * e_cal_backend_google_set_cache:
* @cbgo a #ECalBackendGoogle object
* @cache a #ECalBackendCache
- *
+ *
**/
-void
-e_cal_backend_google_set_cache (ECalBackendGoogle *cbgo, ECalBackendCache *cache)
+void
+e_cal_backend_google_set_cache (ECalBackendGoogle *cbgo, ECalBackendCache *cache)
{
ECalBackendGooglePrivate *priv;
-
+
g_return_if_fail (cbgo != NULL);
g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo));
}
/**
- * e_cal_backend_google_set_item:
+ * e_cal_backend_google_set_item:
* @cbgo a #ECalBackendGoogle object
* @cache a #EGoItem *item
- *
+ *
**/
void
e_cal_backend_google_set_item (ECalBackendGoogle *cbgo, EGoItem *item)
{
ECalBackendGooglePrivate *priv;
-
+
g_return_if_fail (cbgo != NULL);
g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo));
-
+
priv = cbgo->priv;
priv->item = item;
}
/**
- * e_cal_backend_google_set_item:
+ * e_cal_backend_google_set_item:
* @cbgo a #ECalBackendGoogle object
* @cache a #EGoItem *item
* Sets the #EGoItem item on object
- *
- **/
+ *
+ **/
void
e_cal_backend_google_set_service (ECalBackendGoogle *cbgo, GDataGoogleService *service)
{
ECalBackendGooglePrivate *priv;
-
+
g_return_if_fail (cbgo != NULL);
g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo));
-
+
priv = cbgo->priv;
priv->service = service;
}
/**
- * e_cal_backend_google_set_uri:
+ * e_cal_backend_google_set_uri:
* @cbgo a #ECalBackendGoogle cbgo
* @uri Private uri , for accessing google calendar
* Sets the uri on cbgo
- *
- **/
-void
+ *
+ **/
+void
e_cal_backend_google_set_uri (ECalBackendGoogle *cbgo, gchar *uri)
{
ECalBackendGooglePrivate *priv;
-
+
g_return_if_fail (cbgo != NULL);
g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo));
}
/**
- * e_cal_backend_google_set_entry:
+ * e_cal_backend_google_set_entry:
* @cbgo a #ECalBackendGoogle object
* @entry a #GDataEntry entry
* Sets the entry on object
- *
- **/
-void
+ *
+ **/
+void
e_cal_backend_google_set_entry (ECalBackendGoogle *cbgo, GDataEntry *entry)
{
ECalBackendGooglePrivate *priv;
-
+
g_return_if_fail (cbgo != NULL);
g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo));
-
+
priv = cbgo->priv;
priv->entry = entry;
}
/**
- * e_cal_backend_google_set_timeout_id:
+ * e_cal_backend_google_set_timeout_id:
* @cbgo a #ECalBackendGoogle object
* @timeout_id a time out id
* Sets the timeout id on object
- *
- **/
+ *
+ **/
void
e_cal_backend_google_set_timeout_id (ECalBackendGoogle *cbgo,gint timeout_id )
{
ECalBackendGooglePrivate *priv;
priv = cbgo->priv;
-
- g_return_if_fail (cbgo != NULL);
+
+ g_return_if_fail (cbgo != NULL);
g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo));
-
+
priv->timeout_id = timeout_id;
}
/**
- * e_cal_backend_google_set_username:
+ * e_cal_backend_google_set_username:
* @cbgo a #ECalBackendGoogle object
- * @username username
- * Sets the username on object .
- *
- **/
+ * @username username
+ * Sets the username on object .
+ *
+ **/
void
e_cal_backend_google_set_username (ECalBackendGoogle *cbgo,gchar *username)
{
ECalBackendGooglePrivate *priv;
priv = cbgo->priv;
-
- g_return_if_fail (cbgo != NULL);
+
+ g_return_if_fail (cbgo != NULL);
g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo));
-
+
priv->username = username;
}
/**
- * e_cal_backend_google_set_password:
+ * e_cal_backend_google_set_password:
* @cbgo a #ECalBackendGoogle object
* @cache a #EGoItem *item
* Sets the #EGoItem item on object
- *
- **/
+ *
+ **/
void
e_cal_backend_google_set_password (ECalBackendGoogle *cbgo,gchar *password)
{
ECalBackendGooglePrivate *priv;
priv = cbgo->priv;
-
- g_return_if_fail (cbgo != NULL);
+
+ g_return_if_fail (cbgo != NULL);
g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo));
-
+
priv->password = password;
}
/**
- * e_cal_backend_google_get_cache:
+ * e_cal_backend_google_get_cache:
* @cbgo a #ECalBackendGoogle object
- * Gets the cache .
- *
- **/
+ * Gets the cache .
+ *
+ **/
ECalBackendCache *
-e_cal_backend_google_get_cache (ECalBackendGoogle *cbgo)
+e_cal_backend_google_get_cache (ECalBackendGoogle *cbgo)
{
ECalBackendGooglePrivate *priv;
-
+
g_return_val_if_fail (cbgo != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo), NULL);
-
+
priv = cbgo->priv;
return priv->cache;
}
/**
- * e_cal_backend_google_get_item:
+ * e_cal_backend_google_get_item:
* @cbgo a #ECalBackendGoogle object
- * Gets the #EGoItem . from cbgo
- **/
+ * Gets the #EGoItem . from cbgo
+ **/
EGoItem *
-e_cal_backend_google_get_item (ECalBackendGoogle *cbgo)
+e_cal_backend_google_get_item (ECalBackendGoogle *cbgo)
{
ECalBackendGooglePrivate *priv;
}
/**
- * e_cal_backend_google_get_service:
+ * e_cal_backend_google_get_service:
* @cbgo a #ECalBackendGoogle object
- * Gets the #GDataGoogleService service object .
- *
- **/
+ * Gets the #GDataGoogleService service object .
+ *
+ **/
GDataGoogleService *
e_cal_backend_google_get_service (ECalBackendGoogle *cbgo)
{
ECalBackendGooglePrivate *priv;
-
+
g_return_val_if_fail (cbgo != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo), NULL);
}
/**
- * e_cal_backend_google_set_item:
+ * e_cal_backend_google_set_item:
* @cbgo a #ECalBackendGoogle object
- * Gets the uri
- **/
+ * Gets the uri
+ **/
gchar *
e_cal_backend_google_get_uri (ECalBackendGoogle *cbgo)
{
ECalBackendGooglePrivate *priv;
-
+
g_return_val_if_fail (cbgo != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo), NULL);
}
/**
- * e_cal_backend_google_get_entry:
+ * e_cal_backend_google_get_entry:
* @cbgo a #ECalBackendGoogle object
- * Gets the #GDataEntry object.
- *
- **/
+ * Gets the #GDataEntry object.
+ *
+ **/
GDataEntry *
-e_cal_backend_google_get_entry (ECalBackendGoogle *cbgo)
-{
+e_cal_backend_google_get_entry (ECalBackendGoogle *cbgo)
+{
ECalBackendGooglePrivate *priv;
-
+
g_return_val_if_fail (cbgo != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo), NULL);
}
/**
- * e_cal_backend_google_get_timeout_id:
+ * e_cal_backend_google_get_timeout_id:
* @cbgo a #ECalBackendGoogle object
- * Gets the timeout id.
- *
- **/
+ * Gets the timeout id.
+ *
+ **/
gint
e_cal_backend_google_get_timeout_id (ECalBackendGoogle *cbgo)
{
g_return_val_if_fail (cbgo != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo), NULL);
-
+
priv = cbgo->priv;
return priv->timeout_id;
}
/**
- * e_cal_backend_google_get_username:
+ * e_cal_backend_google_get_username:
* @cbgo a #ECalBackendGoogle object
- * Gets the username
- *
- **/
+ * Gets the username
+ *
+ **/
gchar *
e_cal_backend_google_get_username (ECalBackendGoogle *cbgo)
{
g_return_val_if_fail (cbgo != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo), NULL);
-
+
priv = cbgo->priv;
return priv->username;
}
/**
- * e_cal_backend_google_get_password:
+ * e_cal_backend_google_get_password:
* @cbgo a #ECalBackendGoogle object
- * Gets the password
- **/
+ * Gets the password
+ **/
gchar *
e_cal_backend_google_get_password (ECalBackendGoogle *cbgo)
{
g_return_val_if_fail (cbgo != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo), NULL);
- /* FIXME Encrypt ? */
+ /* FIXME Encrypt ? */
priv = cbgo->priv;
return priv->password;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
- * Ebby Wiselyn <ebbywiselyn@gmail.com>
+/*
+ * Authors :
+ * Ebby Wiselyn <ebbywiselyn@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
struct _ECalBackendGoogle {
ECalBackendSync Backend;
-
+
/* private data */
ECalBackendGooglePrivate *priv;
};
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
* Harish Krishnaswamy <kharish@novell.com>
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#include "e-cal-backend-groupwise-utils.h"
#include "libedataserver/e-source-list.h"
-static gboolean
+static gboolean
get_recur_instance (ECalComponent *comp, time_t instance_start, time_t instance_end, gpointer data)
{
GSList **recur_dates = (GSList **) data;
const char *
e_cal_component_get_gw_id (ECalComponent *comp)
{
- icalproperty *prop;
-
+ icalproperty *prop;
+
prop = icalcomponent_get_first_property (e_cal_component_get_icalcomponent (comp),
ICAL_X_PROPERTY);
while (prop) {
return NULL;
}
-static void
+static void
set_categories_for_gw_item (EGwItem *item, GSList *category_names, ECalBackendGroupwise *cbgw)
{
GHashTable *categories_by_name, *categories_by_id;
categories_by_name = e_cal_backend_groupwise_get_categories_by_name (cbgw);
categories_by_id = e_cal_backend_groupwise_get_categories_by_id (cbgw);
cnc = e_cal_backend_groupwise_get_connection (cbgw);
-
+
g_return_if_fail (categories_by_id != NULL || categories_by_name != NULL || cnc != NULL);
-
+
for (; category_names != NULL; category_names = g_slist_next (category_names)) {
if (!category_names->data || strlen(category_names->data) == 0 )
continue;
if (status == E_GW_CONNECTION_STATUS_OK && id != NULL) {
char **components = g_strsplit (id, "@", -1);
char *temp_id = components[0];
-
+
g_hash_table_insert (categories_by_name, g_strdup (category_names->data), g_strdup(temp_id));
g_hash_table_insert (categories_by_id, g_strdup(temp_id), g_strdup (category_names->data));
category_ids = g_list_append (category_ids, g_strdup(temp_id));
while (icalprop) {
x_name = icalproperty_get_x_name (icalprop);
-
+
if (!strcmp (x_name, "X-EVOLUTION-OPTIONS-PRIORITY")) {
sendoptions_set = TRUE;
x_val = icalproperty_get_x (icalprop);
icaltime_set_timezone (&temp, default_zone);
temp = icaltime_convert_to_zone (temp, utc);
value = icaltime_as_ical_string (temp);
- e_gw_item_set_reply_within (item, (char *) value);
+ e_gw_item_set_reply_within (item, (char *) value);
}
} else if (!strcmp (x_name, "X-EVOLUTION-OPTIONS-EXPIRE")) {
const char *expire = NULL;
x_val = icalproperty_get_x (icalprop);
temp = icaltime_current_time_with_zone (default_zone ? default_zone : utc);
- icaltime_adjust (&temp, atoi (x_val), 0, 0, 0);
+ icaltime_adjust (&temp, atoi (x_val), 0, 0, 0);
icaltime_set_timezone (&temp, default_zone);
temp = icaltime_convert_to_zone (temp, utc);
expire = icaltime_as_ical_string (temp);
temp = icaltime_convert_to_zone (temp, utc);
delay = icaltime_as_ical_string (temp);
e_gw_item_set_delay_until (item, (char *) delay);
-
+
} else if (!strcmp (x_name, "X-EVOLUTION-OPTIONS-TRACKINFO")) {
sendoptions_set = TRUE;
x_val = icalproperty_get_x (icalprop);
break;
case 1: e_gw_item_set_notify_opened (item, E_GW_ITEM_NOTIFY_MAIL);
}
-
+
} else if (!strcmp (x_name, "X-EVOLUTION-OPTIONS-ACCEPTED")) {
int i = 0;
x_val = icalproperty_get_x (icalprop);
GSList *l;
e_cal_component_get_attachment_list (comp, &attach_file_list);
-
+
for (l = attach_file_list; l ; l = l->next) {
-
+
EGwItemAttachment *attach_item;
char *file_contents, *encoded_data;
gsize file_len;
/* Extract the simple file name from the
* attach_filename_full which is of the form
- * file://<path>/compuid-<simple filename>
+ * file://<path>/compuid-<simple filename>
*/
e_cal_component_get_uid (comp, &uid);
- filename = g_strrstr (attach_filename_full, uid);
+ filename = g_strrstr (attach_filename_full, uid);
if (filename == NULL) {
g_message ("DEBUG: This is an invalid attachment file\n");
g_free (attach_filename_full);
* message */
encoded_data = g_base64_encode (file_contents, file_len);
attach_item->data = encoded_data;
- attach_item->size = strlen (encoded_data);
+ attach_item->size = strlen (encoded_data);
g_free (file_contents);
attach_list = g_slist_append (attach_list, attach_item);
static icalproperty *
get_attendee_prop (icalcomponent *icalcomp, const char *attendee)
{
- icalproperty *prop;
+ icalproperty *prop;
for (prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
prop;
const char *attendees = NULL;
char **emails, **iter;
- for (icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY); icalprop;
+ for (icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY); icalprop;
icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY)) {
if (g_str_equal (icalproperty_get_x_name (icalprop), "X-EVOLUTION-RECIPIENTS")) {
break;
} else if (e_cal_component_has_attendees (comp)) {
GSList *attendee_list, *recipient_list = NULL, *al;
- e_cal_component_get_attendee_list (comp, &attendee_list);
+ e_cal_component_get_attendee_list (comp, &attendee_list);
for (al = attendee_list; al != NULL; al = al->next) {
ECalComponentAttendee *attendee = (ECalComponentAttendee *) al->data;
EGwItemRecipient *recipient;
-
+
if (delegate && (g_str_equal (attendee->value + 7, user_email) || !(attendee->delfrom && *attendee->delfrom)))
- continue;
-
+ continue;
+
if (delegate) {
- icalproperty *prop = get_attendee_prop (e_cal_component_get_icalcomponent (comp),
+ icalproperty *prop = get_attendee_prop (e_cal_component_get_icalcomponent (comp),
attendee->value);
- if (prop)
+ if (prop)
icalproperty_remove_parameter_by_kind (prop, ICAL_DELEGATEDFROM_PARAMETER);
}
-
+
recipient = g_new0 (EGwItemRecipient, 1);
/* len (MAILTO:) + 1 = 7 */
recipient->email = g_strdup (attendee->value + 7);
if (attendee->cn != NULL)
recipient->display_name = g_strdup (attendee->cn);
- if (attendee->role == ICAL_ROLE_REQPARTICIPANT)
+ if (attendee->role == ICAL_ROLE_REQPARTICIPANT)
recipient->type = E_GW_ITEM_RECIPIENT_TO;
else if (attendee->role == ICAL_ROLE_OPTPARTICIPANT)
recipient->type = E_GW_ITEM_RECIPIENT_CC;
recipient->status = E_GW_ITEM_STAT_ACCEPTED;
else if (attendee->status == ICAL_PARTSTAT_DECLINED)
recipient->status = E_GW_ITEM_STAT_DECLINED;
- else
+ else
recipient->status = E_GW_ITEM_STAT_NONE;
recipient_list = g_slist_append (recipient_list, recipient);
}
e_cal_component_free_attendee_list(attendee_list);
-
+
/* recipient_list shouldn't be freed. Look into the function below. */
e_gw_item_set_recipient_list (item, recipient_list);
}
-
+
if (e_cal_component_has_organizer (comp)) {
/* Send Options */
add_send_options_data_to_item (item, comp, default_zone);
}
-
+
if (!delegate && e_cal_component_has_organizer (comp)) {
ECalComponentOrganizer cal_organizer;
EGwItemOrganizer *organizer = NULL;
if (rrule_list) {
/* assumes only one rrule is present */
ical_recur = (struct icalrecurrencetype *) rrule_list->data;
-
+
g_message ("DEBUG: Processing rule\n%s\n", icalrecurrencetype_as_string (ical_recur));
/*set the data */
switch (ical_recur->freq) {
if (ical_recur->count != 0)
item_rrule->count = ical_recur->count;
else
- item_rrule->until = g_strdup (icaltime_as_ical_string (ical_recur->until));
+ item_rrule->until = g_strdup (icaltime_as_ical_string (ical_recur->until));
item_rrule->interval = ical_recur->interval;
GSList *l, *item_exdate_list = NULL;
icaltimezone *default_zone, *utc;
struct icaltimetype itt_utc;
-
+
e_cal_component_get_exdate_list (comp, &exdate_list);
default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
utc = icaltimezone_get_utc_timezone ();
for (l = exdate_list; l ; l = l->next) {
- ECalComponentDateTime *dt = (ECalComponentDateTime *) l->data;
+ ECalComponentDateTime *dt = (ECalComponentDateTime *) l->data;
if (dt->value) {
if (!icaltime_get_timezone (*(dt->value)))
icaltime_set_timezone (dt->value, default_zone ? default_zone : utc);
itt_utc = icaltime_convert_to_zone (*dt->value, utc);
item_exdate_list = g_slist_append (item_exdate_list, g_strdup (icaltime_as_ical_string (itt_utc)));
}
- }
+ }
e_gw_item_set_exdate_list (item, item_exdate_list);
e_cal_component_free_exdate_list (exdate_list);
}
- }
+ }
}
static EGwItem *
GSList *slist, *sl;
icaltimezone *default_zone, *utc;
struct icaltimetype itt_utc;
-
+
default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
utc = icaltimezone_get_utc_timezone ();
duration = abs (icaldurationtype_as_int (trigger.u.rel_duration));
e_gw_item_set_trigger (item, duration);
}
-
-
+
+
/* end date */
e_cal_component_get_dtend (comp, &dt);
itt_utc = icaltime_convert_to_zone (*dt.value, utc);
e_gw_item_set_due_date (item, icaltime_as_ical_string (itt_utc));
}
-
+
/* priority */
priority = NULL;
e_cal_component_get_priority (comp, &priority);
e_cal_component_free_priority (priority);
}
-
+
/* completed */
e_cal_component_get_completed (comp, &dt.value);
if (dt.value) {
/* set common properties */
/* GW server ID */
e_gw_item_set_id (item, e_cal_component_get_gw_id (comp));
-
-
+
+
/* UID */
e_cal_component_get_uid (comp, &uid);
e_gw_item_set_icalid (item, uid);
g_object_unref (item);
return NULL;
}
-
+
/* all day event */
if (dt.value && dt.value->is_date && e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_APPOINTMENT)
e_gw_item_set_is_allday_event (item, TRUE);
-
+
/* creation date */
e_cal_component_get_created (comp, &dt.value);
if (dt.value) {
if (!icaltime_get_timezone (*dt.value))
icaltime_set_timezone (dt.value, default_zone);
- itt_utc = icaltime_convert_to_zone (*dt.value, utc);
+ itt_utc = icaltime_convert_to_zone (*dt.value, utc);
e_gw_item_set_creation_date (item, icaltime_as_ical_string (itt_utc));
} else {
struct icaltimetype itt;
set_attendees_to_item (item, comp, default_zone, FALSE, NULL);
-
+
/* check if recurrences exist and update the item */
if (e_cal_component_has_recurrences (comp)) {
if (e_cal_component_has_rrules (comp))
else {
GSList *recur_dates = NULL;
-
+
if (dt.tzid)
- e_cal_recur_generate_instances (comp, -1, -1,get_recur_instance, &recur_dates, resolve_tzid_cb, NULL, (icaltimezone *) default_zone);
- else
- e_cal_recur_generate_instances (comp, -1, -1,get_recur_instance, &recur_dates, resolve_tzid_cb, NULL, utc);
+ e_cal_recur_generate_instances (comp, -1, -1,get_recur_instance, &recur_dates, resolve_tzid_cb, NULL, (icaltimezone *) default_zone);
+ else
+ e_cal_recur_generate_instances (comp, -1, -1,get_recur_instance, &recur_dates, resolve_tzid_cb, NULL, utc);
recur_dates = g_slist_delete_link (recur_dates, recur_dates);
-
+
e_gw_item_set_recurrence_dates (item, recur_dates);
}
}
-
+
/* attachments */
if (e_cal_component_has_attachments (comp)) {
- e_cal_backend_groupwise_set_attachments_from_comp (comp, item);
+ e_cal_backend_groupwise_set_attachments_from_comp (comp, item);
}
-
+
return item;
}
EGwItem *item;
icaltimezone *default_zone;
const char *user_email;
-
+
g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL);
default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
item = e_gw_item_new_empty ();
return item;
}
-/* Fetch data from the server and unencode it to the actual data
+/* Fetch data from the server and unencode it to the actual data
* and populate the attach_data
*/
static gboolean
cnc = e_cal_backend_groupwise_get_connection (cbgw);
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_CONNECTION);
- status = e_gw_connection_get_attachment (cnc, attach_item->id, 0, -1, (const char **) &data, &len);
+ status = e_gw_connection_get_attachment (cnc, attach_item->id, 0, -1, (const char **) &data, &len);
if (status != E_GW_CONNECTION_STATUS_OK ) {
g_warning ("Failed to read the attachment from the server\n");
GSList *comp_attachment_list = NULL;
const char *uid;
char *attach_file_url;
-
+
fetch_list = e_gw_item_get_attach_id_list (item);
if (fetch_list == NULL)
return; /* No attachments exist */
char *filename;
attach_item = (EGwItemAttachment *) l->data;
- attach_file_url = g_strconcat (e_cal_backend_groupwise_get_local_attachments_store (cbgw),
+ attach_file_url = g_strconcat (e_cal_backend_groupwise_get_local_attachments_store (cbgw),
"/", uid, "-", attach_item->name, NULL);
filename = g_filename_from_uri (attach_file_url, NULL, NULL);
return; /* Could not get the attachment from the server */
}
fd = g_open (filename, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600);
- if (fd == -1) {
+ if (fd == -1) {
/* skip gracefully */
g_warning ("DEBUG: could not serialize attachments\n");
} else if (write (fd, attach_item->data, attach_item->size) == -1) {
DAYS,
HOURS,
MINUTES
- } duration;
+ } duration;
ECalComponentAlarmTrigger trigger;
interval = gconf_client_get_int (gconf, CALENDAR_CONFIG_DEFAULT_REMINDER_INTERVAL, NULL);
units = gconf_client_get_string (gconf, CALENDAR_CONFIG_DEFAULT_REMINDER_UNITS, NULL);
- if (units == NULL)
+ if (units == NULL)
duration = MINUTES;
else {
if (!strcmp (units, "days"))
case MINUTES:
trigger.u.rel_duration.minutes = interval;
break;
- case HOURS:
+ case HOURS:
trigger.u.rel_duration.hours = interval;
break;
- case DAYS:
+ case DAYS:
trigger.u.rel_duration.days = interval;
break;
default:
icalcomponent_add_property (e_cal_component_get_icalcomponent (comp), icalprop);
}
-
+
if (e_gw_item_get_reply_request (item)) {
- char *reply_within;
+ char *reply_within;
const char *mess = e_gw_item_get_message (item);
char *value;
if (!icaltime_get_timezone (itt_utc))
icaltime_set_timezone (&itt_utc, icaltimezone_get_utc_timezone());
if (default_zone) {
- itt = icaltime_convert_to_zone (itt_utc, default_zone);
+ itt = icaltime_convert_to_zone (itt_utc, default_zone);
icaltime_set_timezone (&itt, default_zone);
e_cal_component_set_created (comp, &itt);
e_cal_component_set_dtstamp (comp, &itt);
}
}
g_free (t);
-
+
/* categories */
category_ids = e_gw_item_get_categories (item);
categories = NULL;
}
/* all day event */
- is_allday = e_gw_item_get_is_allday_event (item);
+ is_allday = e_gw_item_get_is_allday_event (item);
/* start date */
/* should i duplicate here ? */
t = e_gw_item_get_start_date (item);
if (t) {
itt_utc = icaltime_from_string (t);
-
+
if (!is_allday && (item_type != E_GW_ITEM_TYPE_NOTE)) {
if (!icaltime_get_timezone (itt_utc))
icaltime_set_timezone (&itt_utc, icaltimezone_get_utc_timezone());
if (default_zone) {
- itt = icaltime_convert_to_zone (itt_utc, default_zone);
+ itt = icaltime_convert_to_zone (itt_utc, default_zone);
icaltime_set_timezone (&itt, default_zone);
dt.value = &itt;
dt.tzid = icaltimezone_get_tzid (default_zone);
dt.value = &itt_utc;
dt.tzid = NULL;
dt.value->is_date = 1;
- }
+ }
e_cal_component_set_dtstart (comp, &dt);
- } else
+ } else
return NULL;
-
+
/* UID */
if (e_gw_item_get_recurrence_key (item) != 0) {
return NULL;
}
}
-
+
g_free (t);
/* classification */
attendee->role = ICAL_ROLE_REQPARTICIPANT;
else if (recipient->type == E_GW_ITEM_RECIPIENT_CC || recipient->type == E_GW_ITEM_RECIPIENT_BC)
attendee->role = ICAL_ROLE_OPTPARTICIPANT;
- else
+ else
attendee->role = ICAL_ROLE_NONE;
- /* FIXME needs a server fix on the interface
+ /* FIXME needs a server fix on the interface
* for getting cutype and the status */
attendee->cutype = ICAL_CUTYPE_INDIVIDUAL;
else if (recipient->status == E_GW_ITEM_STAT_DECLINED)
attendee->status = ICAL_PARTSTAT_DECLINED;
else
- attendee->status = ICAL_PARTSTAT_NEEDSACTION;
+ attendee->status = ICAL_PARTSTAT_NEEDSACTION;
- attendee_list = g_slist_append (attendee_list, attendee);
+ attendee_list = g_slist_append (attendee_list, attendee);
}
e_cal_component_set_attendee_list (comp, attendee_list);
organizer = e_gw_item_get_organizer (item);
if (organizer) {
ECalComponentOrganizer *cal_organizer;
-
+
cal_organizer = g_new0 (ECalComponentOrganizer, 1);
cal_organizer->cn = g_strdup (organizer->display_name);
cal_organizer->value = g_strconcat("MAILTO:", organizer->email, NULL);
if (!icaltime_get_timezone (itt_utc))
icaltime_set_timezone (&itt_utc, icaltimezone_get_utc_timezone());
if (default_zone) {
- itt = icaltime_convert_to_zone (itt_utc, default_zone);
+ itt = icaltime_convert_to_zone (itt_utc, default_zone);
icaltime_set_timezone (&itt, default_zone);
dt.value = &itt;
dt.tzid = icaltimezone_get_tzid (default_zone);
if (alarm_duration != 0) {
ECalComponentAlarm *alarm;
ECalComponentAlarmTrigger trigger;
-
+
alarm = e_cal_component_alarm_new ();
e_cal_component_alarm_set_action (alarm, E_CAL_COMPONENT_ALARM_DISPLAY);
trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;
e_cal_component_alarm_set_trigger (alarm, trigger);
e_cal_component_add_alarm (comp, alarm);
- } else
+ } else
set_default_alarms (comp);
break;
if (!icaltime_get_timezone (itt_utc))
icaltime_set_timezone (&itt_utc, icaltimezone_get_utc_timezone());
if (default_zone) {
- itt = icaltime_convert_to_zone (itt_utc, default_zone);
+ itt = icaltime_convert_to_zone (itt_utc, default_zone);
icaltime_set_timezone (&itt, default_zone);
dt.value = &itt;
dt.tzid = icaltimezone_get_tzid (default_zone);
/* EGwItem's completed is a boolean */
if (e_gw_item_get_completed (item)) {
percent = 100;
-
+
t = e_gw_item_get_completed_date (item);
if (t) {
itt_utc = icaltime_from_string (t);
if (!icaltime_get_timezone (itt_utc))
icaltime_set_timezone (&itt_utc, icaltimezone_get_utc_timezone());
if (default_zone) {
- itt = icaltime_convert_to_zone (itt_utc, default_zone);
+ itt = icaltime_convert_to_zone (itt_utc, default_zone);
icaltime_set_timezone (&itt, default_zone);
e_cal_component_set_completed (comp, &itt);
- } else
+ } else
e_cal_component_set_completed (comp, &itt_utc);
} else {
/* We are setting the completion date as the current time due to
itt = icaltime_today ();
e_cal_component_set_completed (comp,&itt);
}
- } else
+ } else
percent =0;
e_cal_component_set_percent (comp, &percent);
switch (type) {
- case E_CAL_COMPONENT_EVENT:
+ case E_CAL_COMPONENT_EVENT:
case E_CAL_COMPONENT_TODO:
case E_CAL_COMPONENT_JOURNAL:
if (!g_str_has_suffix (gw_id, container)) {
item_id = g_strconcat (e_cal_component_get_gw_id (comp), GW_EVENT_TYPE_ID, container, NULL);
need_to_get = TRUE;
-
+
}
- else
+ else
item_id = g_strdup (gw_id);
break;
default:
if (need_to_get) {
EGwItem *item = NULL;
-
+
status = e_gw_connection_get_item (cnc, container, item_id, "recipients message recipientStatus attachments default", &item);
if (status == E_GW_CONNECTION_STATUS_OK)
*created_comp = e_gw_item_to_cal_component (item, cbgw);
const char *email_id;
ECalComponentAttendee *attendee = NULL, *tmp;
-
+
e_cal_component_get_attendee_list (comp, &attendee_list);
for (l = attendee_list; l ; l = g_slist_next (l)) {
tmp = (ECalComponentAttendee *) (l->data);
email_id = tmp->value;
-
+
if (!g_ascii_strncasecmp (email_id, "mailto:", 7))
email_id += 7;
}
if (attendee_list)
e_cal_component_free_attendee_list (attendee_list);
-
+
}
else {
status = E_GW_CONNECTION_STATUS_INVALID_OBJECT;
*pstatus = partstat;
switch (partstat) {
ECalComponentTransparency transp;
-
- case ICAL_PARTSTAT_ACCEPTED:
+
+ case ICAL_PARTSTAT_ACCEPTED:
e_cal_component_get_transparency (comp, &transp);
if (transp == E_CAL_COMPONENT_TRANSP_OPAQUE) {
if (all_instances)
status = e_gw_connection_decline_request (cnc, item_id, NULL, recurrence_key);
else
status = e_gw_connection_decline_request (cnc, item_id, NULL, NULL);
-
+
break;
case ICAL_PARTSTAT_TENTATIVE:
if (all_instances)
default :
status = E_GW_CONNECTION_STATUS_INVALID_OBJECT;
-
+
}
break;
default:
return E_GW_CONNECTION_STATUS_INVALID_OBJECT;
}
-
+
return status;
}
}
static EGwConnectionStatus
-start_freebusy_session (EGwConnection *cnc, GList *users,
+start_freebusy_session (EGwConnection *cnc, GList *users,
time_t start, time_t end, const char **session)
{
SoupSoapMessage *msg;
"startFreeBusySessionRequest");
/* FIXME users is just a buch of user names - associate it with uid,
* email id apart from the name*/
-
- soup_soap_message_start_element (msg, "users", NULL, NULL);
+
+ soup_soap_message_start_element (msg, "users", NULL, NULL);
for ( l = users; l != NULL; l = g_list_next (l)) {
- soup_soap_message_start_element (msg, "user", NULL, NULL);
+ soup_soap_message_start_element (msg, "user", NULL, NULL);
e_gw_message_write_string_parameter (msg, "email", NULL, l->data);
soup_soap_message_end_element (msg);
}
utc = icaltimezone_get_utc_timezone ();
icaltime = icaltime_from_timet_with_zone (start, FALSE, utc);
start_date = icaltime_as_ical_string (icaltime);
-
+
icaltime = icaltime_from_timet_with_zone (end, FALSE, utc);
end_date = icaltime_as_ical_string (icaltime);
-
+
e_gw_message_write_string_parameter (msg, "startDate", NULL, start_date);
e_gw_message_write_string_parameter (msg, "endDate", NULL, end_date);
-
+
e_gw_message_write_footer (msg);
/* send message to server */
g_object_unref (response);
return status;
}
-
+
/* if status is OK - parse result, return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "freeBusySessionId");
if (!param) {
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
- *session = soup_soap_parameter_get_string_value (param);
+
+ *session = soup_soap_parameter_get_string_value (param);
/* free memory */
g_object_unref (response);
g_object_unref (msg);
return status;
}
-static EGwConnectionStatus
+static EGwConnectionStatus
close_freebusy_session (EGwConnection *cnc, const char *session)
{
SoupSoapMessage *msg;
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_CONNECTION);
/* Perform startFreeBusySession */
- status = start_freebusy_session (cnc, users, start, end, &session);
+ status = start_freebusy_session (cnc, users, start, end, &session);
/*FIXME log error messages */
if (status != E_GW_CONNECTION_STATUS_OK)
return status;
ECalComponentAttendee attendee;
GSList *attendee_list = NULL;
icalcomponent *icalcomp = NULL;
-
+
tmp = soup_soap_parameter_get_first_child_by_name (subparam, "email");
if (tmp)
email = soup_soap_parameter_get_string_value (tmp);
name = soup_soap_parameter_get_string_value (tmp);
comp = e_cal_component_new ();
- e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_FREEBUSY);
+ e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_FREEBUSY);
e_cal_component_commit_sequence (comp);
icalcomp = e_cal_component_get_icalcomponent (comp);
-
+
memset (&attendee, 0, sizeof (ECalComponentAttendee));
if (name)
attendee.cn = name;
if (email)
attendee.value = email;
-
+
attendee.cutype = ICAL_CUTYPE_INDIVIDUAL;
attendee.role = ICAL_ROLE_REQPARTICIPANT;
attendee.status = ICAL_PARTSTAT_NEEDSACTION;
/* XXX the uuid is not currently used. hence it is
* discarded */
- attendee_list = g_slist_append (attendee_list, &attendee);
+ attendee_list = g_slist_append (attendee_list, &attendee);
e_cal_component_set_attendee_list (comp, attendee_list);
-
+
param_blocks = soup_soap_parameter_get_first_child_by_name (subparam, "blocks");
if (!param_blocks) {
g_object_unref (response);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
for (subparam_block = soup_soap_parameter_get_first_child_by_name (param_blocks, "block");
subparam_block != NULL;
subparam_block = soup_soap_parameter_get_next_child_by_name (subparam_block, "block")) {
- /* process each block and create ECal free/busy components.*/
+ /* process each block and create ECal free/busy components.*/
SoupSoapParameter *tmp;
struct icalperiodtype ipt;
icalproperty *icalprop;
icaltimetype itt;
time_t t;
const char *start, *end, *accept_level;
-
+
memset (&ipt, 0, sizeof (struct icalperiodtype));
tmp = soup_soap_parameter_get_first_child_by_name (subparam_block, "startDate");
if (tmp) {
t = e_gw_connection_get_date_from_string (start);
itt = icaltime_from_timet_with_zone (t, 0, default_zone ? default_zone : NULL);
ipt.start = itt;
- }
+ }
tmp = soup_soap_parameter_get_first_child_by_name (subparam_block, "endDate");
if (tmp) {
e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_ADD, #fieldname, (gpointer) fieldname ); \
}G_STMT_END
-static void
+static void
set_categories_changes (EGwItem *new_item, EGwItem *old_item)
{
GList *old_category_list;
if (old_category_list && new_category_list) {
old_categories_copy = g_list_copy (old_category_list);
for ( ; new_category_list != NULL; new_category_list = g_list_next (new_category_list)) {
-
+
category1 = new_category_list->data;
temp = old_category_list;
categories_matched = FALSE;
old_categories_copy = g_list_remove (old_categories_copy, category2);
break;
}
-
+
}
if (!categories_matched)
added_categories = g_list_append (added_categories, category1);
}
-
+
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_ADD, "categories", added_categories);
e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_DELETE, "categories", old_categories_copy);
SET_DELTA(message);
SET_DELTA(classification);
-
+
SET_DELTA(start_date);
set_categories_changes (item, cache_item);
/*FIXME recipient_list modifications need go here after server starts
SET_DELTA(place);
trigger = e_gw_item_get_trigger (item);
cache_trigger = e_gw_item_get_trigger (cache_item);
- if (cache_trigger) {
- if (!trigger)
+ if (cache_trigger) {
+ if (!trigger)
e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_DELETE, "alarm", &cache_trigger);
else if (trigger != cache_trigger)
e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE, "alarm", &trigger);
- }
- else if (trigger)
+ }
+ else if (trigger)
e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_ADD, "alarm", &trigger);
is_allday = e_gw_item_get_is_allday_event (item);
cache_is_allday = e_gw_item_get_is_allday_event (cache_item);
}
-static void
+static void
add_return_value (EGwSendOptionsReturnNotify track, ESource *source, char *notify)
{
char *value;
-
+
switch (track) {
case E_GW_RETURN_NOTIFY_MAIL:
value = g_strdup ("mail");
break;
default:
- value = g_strdup ("none");
+ value = g_strdup ("none");
}
-
+
e_source_set_property (source, notify, value);
g_free (value), value = NULL;
}
cbgw = hold->cbgw;
opts = hold->opts;
source = e_cal_backend_get_source (E_CAL_BACKEND (cbgw));
- kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
+ kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
/* TODO implement send options for Notes */
if (kind == ICAL_VJOURNAL_COMPONENT)
} else {
source_list = e_source_list_new_for_gconf (gconf, "/apps/evolution/tasks/sources");
sopts = e_gw_sendoptions_get_status_tracking_options (opts, "task");
- }
-
+ }
+
uid = e_source_peek_uid (source);
source = e_source_list_peek_source_by_uid (source_list, uid);
if (gopts) {
if (gopts->reply_enabled) {
if (gopts->reply_convenient)
value = g_strdup ("convinient");
- else
+ else
value = g_strdup_printf ("%d",gopts->reply_within);
} else
value = g_strdup ("none");
e_source_set_property (source, "status-tracking", value);
g_free (value), value = NULL;
- add_return_value (sopts->opened, source, "return-open");
- add_return_value (sopts->accepted, source, "return-accept");
- add_return_value (sopts->declined, source, "return-decline");
- add_return_value (sopts->completed, source, "return-complete");
- }
+ add_return_value (sopts->opened, source, "return-open");
+ add_return_value (sopts->accepted, source, "return-accept");
+ add_return_value (sopts->declined, source, "return-decline");
+ add_return_value (sopts->completed, source, "return-complete");
+ }
e_source_list_sync (source_list, NULL);
gboolean
e_cal_backend_groupwise_utils_check_delegate (ECalComponent *comp, const char *email)
{
- icalproperty *prop;
+ icalproperty *prop;
icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp);
-
+
/*TODO remove the argument email */
prop = icalcomponent_get_first_property (icalcomp,
ICAL_X_PROPERTY);
prop = icalcomponent_get_next_property (e_cal_component_get_icalcomponent (comp),
ICAL_X_PROPERTY);
}
-
+
return FALSE;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/*
* Component related utility functions
*/
-
+
const char *e_cal_component_get_gw_id (ECalComponent *comp);
G_END_DECLS
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
* Harish Krishnaswamy <kharish@novell.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* timeout handler for syncing sendoptions */
guint sendoptions_sync_timeout;
-
+
/* fields for storing info while offline */
char *user_email;
char *local_attachments_store;
GHashTable *
e_cal_backend_groupwise_get_categories_by_id (ECalBackendGroupwise *cbgw) {
-
+
g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), NULL);
-
+
return cbgw->priv->categories_by_id;
}
static GMutex *mutex = NULL;
-static const char *
-get_element_type (icalcomponent_kind kind)
+static const char *
+get_element_type (icalcomponent_kind kind)
{
-
+
const char *type;
if (kind == ICAL_VEVENT_COMPONENT)
int cursor = 0;
guint32 total, num = 0;
int percent = 0, i;
- const char *position = E_GW_CURSOR_POSITION_END;
+ const char *position = E_GW_CURSOR_POSITION_END;
icalcomponent_kind kind;
const char *type;
EGwFilter* filter[3];
- char l_str[26];
+ char l_str[26];
char h_str[26];
icaltimetype temp;
struct tm tm;
g_mutex_lock (mutex);
- type = get_element_type (kind);
-
+ type = get_element_type (kind);
+
/* Fetch the data with a bias to present, near past/future */
temp = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
i = g_ascii_strtod (g_getenv ("PRELOAD_WINDOW_DAYS")? g_getenv ("PRELOAD_WINDOW_DAYS"):"15", NULL);
for (i = 0; i < 3; i++) {
status = e_gw_connection_create_cursor (priv->cnc,
- priv->container_id,
+ priv->container_id,
"recipients message recipientStatus attachments default peek", filter[i], &cursor);
if (status != E_GW_CONNECTION_STATUS_OK) {
e_cal_backend_groupwise_notify_error_code (cbgw, status);
position = E_GW_CURSOR_POSITION_END;
forward = FALSE;
}
-
+
while (!done) {
-
+
status = e_gw_connection_read_cursor (priv->cnc, priv->container_id, cursor, forward, CURSOR_ITEM_LIMIT, position, &list);
if (status != E_GW_CONNECTION_STATUS_OK) {
e_cal_backend_groupwise_notify_error_code (cbgw, status);
for (l = list; l != NULL; l = g_list_next(l)) {
EGwItem *item;
char *progress_string = NULL;
-
+
item = E_GW_ITEM (l->data);
comp = e_gw_item_to_cal_component (item, cbgw);
g_object_unref (item);
-
+
/* Show the progress information */
num++;
percent = ((float) num/total) * 100;
-
- /* FIXME The total obtained from the server is wrong. Sometimes the num can
+
+ /* FIXME The total obtained from the server is wrong. Sometimes the num can
be greater than the total. The following makes sure that the percentage is not >= 100 */
-
+
if (percent > 100)
- percent = 99;
+ percent = 99;
progress_string = g_strdup_printf (_("Loading %s items"), type);
e_cal_backend_notify_view_progress (E_CAL_BACKEND (cbgw), progress_string, percent);
-
+
if (E_IS_CAL_COMPONENT (comp)) {
char *comp_str;
-
+
e_cal_component_commit_sequence (comp);
- comp_str = e_cal_component_get_as_string (comp);
+ comp_str = e_cal_component_get_as_string (comp);
e_cal_backend_notify_object_created (E_CAL_BACKEND (cbgw), (const char *) comp_str);
g_free (comp_str);
e_cal_backend_cache_put_component (priv->cache, comp);
}
g_free (progress_string);
}
-
+
if (!list || g_list_length (list) == 0)
done = TRUE;
g_list_free (list);
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
- EGwConnection *cnc;
- ECalBackendCache *cache;
- EGwConnectionStatus status;
+ EGwConnection *cnc;
+ ECalBackendCache *cache;
+ EGwConnectionStatus status;
icalcomponent_kind kind;
GList *item_list, *total_list = NULL, *l;
GSList *cache_keys = NULL, *ls;
GPtrArray *uid_array = NULL;
char *time_string = NULL;
- char t_str [26];
+ char t_str [26];
const char *serv_time;
static GStaticMutex connecting = G_STATIC_MUTEX_INIT;
const char *time_interval_string;
const char *key = "attempts";
const char *attempts;
const char *position ;
-
+
EGwFilter *filter;
int time_interval;
cbgw = (ECalBackendGroupwise *) handle;
priv= cbgw->priv;
kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
- cnc = priv->cnc;
- cache = priv->cache;
+ cnc = priv->cnc;
+ cache = priv->cache;
item_list = NULL;
if (priv->mode == CAL_MODE_LOCAL)
e_cal_backend_cache_put_key_value (cache, key, GINT_TO_POINTER (failures));
}
- if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) {
+ if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) {
g_static_mutex_unlock (&connecting);
return TRUE;
}
}
if ((r_key = e_gw_item_get_recurrence_key (item)) != 0)
rid = e_cal_component_get_recurid_as_string (modified_comp);
-
- e_cal_component_get_uid (modified_comp, &uid);
+
+ e_cal_component_get_uid (modified_comp, &uid);
cache_comp = e_cal_backend_cache_get_component (cache, uid, rid);
e_cal_component_commit_sequence (modified_comp);
e_cal_component_commit_sequence (cache_comp);
time_interval_string = g_getenv ("GETQM_TIME_INTERVAL");
if (time_interval_string) {
time_interval = g_ascii_strtod (time_interval_string, NULL);
- }
+ }
if (attempts) {
tm.tm_min += (time_interval * g_ascii_strtod (attempts, NULL));
e_cal_backend_cache_put_key_value (cache, key, NULL);
g_list_free (item_list);
item_list = NULL;
}
-
+
/* handle deleted items here by going over the entire cache and
* checking for deleted items.*/
position = E_GW_CURSOR_POSITION_END;
}
cache_keys = e_cal_backend_cache_get_keys (cache);
-
+
done = FALSE;
while (!done) {
status = e_gw_connection_read_cal_ids (cnc, cbgw->priv->container_id, cursor, FALSE, CURSOR_ICALID_LIMIT, position, &item_list);
g_static_mutex_unlock (&connecting);
return TRUE;
}
-
+
if (!item_list || g_list_length (item_list) == 0)
done = TRUE;
else {
}
e_gw_connection_destroy_cursor (cnc, cbgw->priv->container_id, cursor);
e_file_cache_freeze_changes (E_FILE_CACHE (cache));
-
+
uid_array = g_ptr_array_new ();
for (l = total_list; l != NULL; l = l->next) {
EGwItemCalId *calid = (EGwItemCalId *) l->data;
const char *rid = NULL;
icaltimetype tt = icaltime_from_string (calid->ical_id);
if (!tt.is_date) {
- tt = icaltime_convert_to_zone (tt, priv->default_zone);
+ tt = icaltime_convert_to_zone (tt, priv->default_zone);
icaltime_set_timezone (&tt, priv->default_zone);
rid = icaltime_as_ical_string (tt);
} else
rid = calid->ical_id;
real_key = g_strconcat (calid->recur_key, "@", rid, NULL);
}
-
+
if (!calid->recur_key || real_key) {
recur_key = real_key;
func = (GCompareFunc) strcmp;
} else {
cache_keys = g_slist_remove_link (cache_keys, remove);
}
-
+
g_free (real_key);
}
for (ls = cache_keys; ls ; ls = g_slist_next (ls)) {
ECalComponent *comp = NULL;
icalcomponent *icalcomp = NULL;
-
- comp = e_cal_backend_cache_get_component (cache, (const char *) ls->data, NULL);
+
+ comp = e_cal_backend_cache_get_component (cache, (const char *) ls->data, NULL);
if (!comp)
continue;
if (kind == icalcomponent_isa (icalcomp)) {
char *comp_str = NULL;
ECalComponentId *id = e_cal_component_get_id (comp);
-
+
comp_str = e_cal_component_get_as_string (comp);
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw),
+ e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw),
id, comp_str, NULL);
e_cal_backend_cache_remove_component (cache, (const char *) id->uid, id->rid);
if (needs_to_get) {
e_gw_connection_get_items_from_ids (priv->cnc,
- priv->container_id,
+ priv->container_id,
"attachments recipients message recipientStatus default peek",
uid_array, &item_list);
char *tmp = NULL;
item = (EGwItem *) l->data;
- comp = e_gw_item_to_cal_component (item, cbgw);
+ comp = e_gw_item_to_cal_component (item, cbgw);
if (comp) {
e_cal_component_commit_sequence (comp);
sanitize_component (E_CAL_BACKEND_SYNC (cbgw), comp, (char *) e_gw_item_get_id (item));
g_object_unref (item);
}
- }
+ }
e_file_cache_thaw_changes (E_FILE_CACHE (cache));
g_ptr_array_free (uid_array, TRUE);
-
+
if (item_list) {
g_list_free (item_list);
item_list = NULL;
g_list_foreach (total_list, (GFunc) e_gw_item_free_cal_id, NULL);
g_list_free (total_list);
}
-
+
if (cache_keys) {
/*FIXME this is a memory leak, but free'ing it causes crash in gslice */
// g_slist_free (cache_keys);
}
-
+
g_static_mutex_unlock (&connecting);
- return TRUE;
+ return TRUE;
}
static gboolean
}
-static char*
+static char*
form_uri (ESource *source)
{
char *uri;
const char *port;
char *formed_uri;
const char *use_ssl;
-
+
EUri *parsed_uri;
uri = e_source_get_uri (source);
if (use_ssl && !g_str_equal (use_ssl, "never"))
formed_uri = g_strconcat ("https://", parsed_uri->host,":", port, "/soap", NULL );
- else
+ else
formed_uri = g_strconcat ("http://", parsed_uri->host,":", port, "/soap", NULL );
-
+
g_free (uri);
e_uri_free (parsed_uri);
return formed_uri;
}
-
+
static ECalBackendSyncStatus
cache_init (ECalBackendGroupwise *cbgw)
{
time_interval_string = g_getenv ("GETQM_TIME_INTERVAL");
if (time_interval_string) {
time_interval = g_ascii_strtod (time_interval_string, NULL);
- time_interval *= (60*1000);
-
+ time_interval *= (60*1000);
+
}
- cnc_status = e_gw_connection_get_settings (priv->cnc, &opts);
+ cnc_status = e_gw_connection_get_settings (priv->cnc, &opts);
if (cnc_status == E_GW_CONNECTION_STATUS_OK) {
GwSettings *hold = g_new0 (GwSettings, 1);
hold->cbgw = cbgw;
hold->opts = opts;
-
+
/* We now sync the sendoptions into e-source using the GLIB main loop. Doing this operation
in a thread causes crashes. */
priv->sendoptions_sync_timeout = g_idle_add ((GSourceFunc ) e_cal_backend_groupwise_store_settings, hold);
- } else
+ } else
g_warning (G_STRLOC ": Could not get the settings from the server");
-
+
/* get the list of category ids and corresponding names from the server */
cnc_status = e_gw_connection_get_categories (priv->cnc, &priv->categories_by_id, &priv->categories_by_name);
if (cnc_status != E_GW_CONNECTION_STATUS_OK) {
return GNOME_Evolution_Calendar_PermissionDenied;
} else {
char *utc_str;
-
+
utc_str = (char *) e_gw_connection_get_server_time (priv->cnc);
e_cal_backend_cache_set_marker (priv->cache);
e_cal_backend_cache_put_server_utc_time (priv->cache, utc_str);
} else {
g_warning (G_STRLOC ": Could not populate the cache");
/*FIXME why dont we do a notify here */
- return GNOME_Evolution_Calendar_PermissionDenied;
+ return GNOME_Evolution_Calendar_PermissionDenied;
}
}
}
static ECalBackendSyncStatus
-set_container_id_with_count (ECalBackendGroupwise *cbgw)
+set_container_id_with_count (ECalBackendGroupwise *cbgw)
{
ECalBackendGroupwisePrivate *priv;
GList *container_list = NULL, *l;
priv = cbgw->priv;
kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
-
+
switch (kind) {
case ICAL_VEVENT_COMPONENT:
case ICAL_VTODO_COMPONENT:
priv->container_id = NULL;
return GNOME_Evolution_Calendar_UnsupportedMethod;
}
-
+
status = e_gw_connection_get_container_list (priv->cnc, "folders", &container_list);
-
+
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_get_container_list (priv->cnc, "folders", &container_list);
-
+
if (status != E_GW_CONNECTION_STATUS_OK)
return GNOME_Evolution_Calendar_OtherError;
res = GNOME_Evolution_Calendar_ObjectNotFound;
for (l = container_list; l != NULL; l = l->next) {
EGwContainer *container = E_GW_CONTAINER (l->data);
-
- if (e_gw_container_get_is_system_folder (container) &&
+
+ if (e_gw_container_get_is_system_folder (container) &&
e_gw_container_get_container_type (container) == E_GW_CONTAINER_TYPE_CALENDAR) {
priv->container_id = g_strdup (e_gw_container_get_id (container));
return res;
}
-
+
static ECalBackendSyncStatus
connect_to_server (ECalBackendGroupwise *cbgw)
{
GError *error = NULL;
char *parent_user = NULL;
icalcomponent_kind kind;
-
+
priv = cbgw->priv;
source = e_cal_backend_get_source (E_CAL_BACKEND (cbgw));
if (!real_uri) {
e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Invalid server URI"));
return GNOME_Evolution_Calendar_NoSuchCal;
- }
+ }
kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
return GNOME_Evolution_Calendar_AuthenticationFailed;
}
-
+
priv->cnc = e_gw_connection_get_proxy_connection (cnc, parent_user, priv->password, priv->username, &permissions);
g_object_unref(cnc);
-
+
if (!priv->cnc) {
e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
return GNOME_Evolution_Calendar_AuthenticationFailed;
cbgw->priv->read_only = TRUE;
-
+
if (kind == ICAL_VEVENT_COMPONENT && (permissions & E_GW_PROXY_APPOINTMENT_WRITE) )
cbgw->priv->read_only = FALSE;
else if (kind == ICAL_VTODO_COMPONENT && (permissions & E_GW_PROXY_TASK_WRITE))
cbgw->priv->read_only = FALSE;
}
g_free (real_uri);
-
+
if (priv->cnc && priv->cache && priv->container_id) {
char *utc_str;
priv->mode = CAL_MODE_REMOTE;
/* get the ID for the container */
if (priv->container_id)
g_free (priv->container_id);
-
+
if ((status = set_container_id_with_count (cbgw)) != GNOME_Evolution_Calendar_Success) {
return status;
}
-
+
priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)), source_type);
if (!priv->cache) {
g_mutex_unlock (priv->mutex);
e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create thread for populating cache"));
return GNOME_Evolution_Calendar_OtherError;
- }
+ }
} else {
return GNOME_Evolution_Calendar_AuthenticationFailed;
}
- if (!e_gw_connection_get_version (priv->cnc))
+ if (!e_gw_connection_get_version (priv->cnc))
return GNOME_Evolution_Calendar_InvalidServerVersion;
return GNOME_Evolution_Calendar_Success;
e_cal_backend_groupwise_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
{
ECalBackendGroupwise *cbgw;
-
+
cbgw = E_CAL_BACKEND_GROUPWISE(backend);
*read_only = cbgw->priv->read_only;
-
+
return GNOME_Evolution_Calendar_Success;
}
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
-
+
cbgw = E_CAL_BACKEND_GROUPWISE(backend);
priv = cbgw->priv;
}
*address = g_strdup (priv->user_email);
-
+
return GNOME_Evolution_Calendar_Success;
}
{
/* ldap attribute is specific to Sun ONE connector to get free busy information*/
/* retun NULL here as group wise backend know how to get free busy information */
-
+
*attribute = NULL;
-
+
return GNOME_Evolution_Calendar_Success;
}
e_cal_backend_groupwise_get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, char **address)
{
/*group wise does not support email based alarms */
-
+
*address = NULL;
-
+
return GNOME_Evolution_Calendar_Success;
}
priv= cbgw->priv;
priv->read_only = TRUE;
- if (priv->timeout_id) {
+ if (priv->timeout_id) {
g_source_remove (priv->timeout_id);
priv->timeout_id =0;
- }
-
+ }
+
if (priv->cnc) {
g_object_unref (priv->cnc);
priv->cnc = NULL;
char *filename;
char *mangled_uri;
int i;
-
+
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
if (priv->mode == CAL_MODE_LOCAL) {
ESource *esource;
const char *display_contents = NULL;
-
- cbgw->priv->read_only = TRUE;
+
+ cbgw->priv->read_only = TRUE;
esource = e_cal_backend_get_source (E_CAL_BACKEND (cbgw));
display_contents = e_source_get_property (esource, "offline_sync");
-
+
if (!display_contents || !g_str_equal (display_contents, "1")) {
- g_mutex_unlock (priv->mutex);
+ g_mutex_unlock (priv->mutex);
return GNOME_Evolution_Calendar_RepositoryOffline;
}
if (!priv->cache) {
g_mutex_unlock (priv->mutex);
e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create cache file"));
-
+
return GNOME_Evolution_Calendar_OtherError;
}
}
-
+
e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
- g_mutex_unlock (priv->mutex);
+ g_mutex_unlock (priv->mutex);
return GNOME_Evolution_Calendar_Success;
}
mangled_uri,
NULL);
g_free (mangled_uri);
- priv->local_attachments_store =
+ priv->local_attachments_store =
g_filename_to_uri (filename, NULL, NULL);
g_free (filename);
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
-
+
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
}
g_mutex_lock (priv->mutex);
-
+
priv->mode_changed = TRUE;
switch (mode) {
case CAL_MODE_REMOTE :/* go online */
GNOME_Evolution_Calendar_MODE_REMOTE);
e_cal_backend_notify_readonly (backend, priv->read_only);
if(e_cal_backend_groupwise_is_loaded (backend))
- e_cal_backend_notify_auth_required(backend);
+ e_cal_backend_notify_auth_required(backend);
break;
case CAL_MODE_LOCAL : /* go offline */
static ECalBackendSyncStatus
e_cal_backend_groupwise_get_default_object (ECalBackendSync *backend, EDataCal *cal, char **object)
{
-
+
ECalComponent *comp;
-
+
comp = e_cal_component_new ();
switch (e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
icalcomp = icaltimezone_get_component (zone);
if (!icalcomp)
return GNOME_Evolution_Calendar_InvalidObject;
-
+
*object = g_strdup (icalcomponent_as_ical_string (icalcomp));
return GNOME_Evolution_Calendar_Success;
GList *components, *l;
ECalBackendSExp *cbsexp;
gboolean search_needed = TRUE;
-
+
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
if (status != E_GW_CONNECTION_STATUS_OK)
return GNOME_Evolution_Calendar_OtherError;
- return GNOME_Evolution_Calendar_Success;
+ return GNOME_Evolution_Calendar_Success;
}
typedef struct {
e_cal_backend_groupwise_compute_changes_foreach_key (const char *key, const char *value, gpointer data)
{
ECalBackendGroupwiseComputeChangesData *be_data = data;
-
+
if (!e_cal_backend_cache_get_component (be_data->backend->priv->cache, key, NULL)) {
ECalComponent *comp;
status = e_cal_backend_groupwise_get_object_list (E_CAL_BACKEND_SYNC (cbgw), NULL, NULL, &list);
if (status != GNOME_Evolution_Calendar_Success)
return status;
-
+
/* Calculate adds and modifies */
for (i = list; i != NULL; i = g_list_next (i)) {
const char *uid;
e_xmlhash_write (ehash);
e_xmlhash_destroy (ehash);
-
+
return GNOME_Evolution_Calendar_Success;
}
static icaltimezone *
e_cal_backend_groupwise_internal_get_default_timezone (ECalBackend *backend)
-{
+{
ECalBackendGroupwise *cbgw = E_CAL_BACKEND_GROUPWISE (backend);
-
+
return cbgw->priv->default_zone;
}
zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
if (!zone)
return icaltimezone_get_utc_timezone();
-
+
return zone;
}
ECalBackendGroupwise *cbgw;
icalproperty *icalprop;
int i;
- GString *str = g_string_new ("");;
-
+ GString *str = g_string_new ("");;
+
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
if (server_uid) {
break;
}
}
-
+
/* add the extra property to the component */
icalprop = icalproperty_new_x (str->str);
icalproperty_set_x_name (icalprop, "X-GWRECORDID");
case CAL_MODE_REMOTE :
/* when online, send the item to the server */
status = e_gw_connection_create_appointment (priv->cnc, priv->container_id, cbgw, comp, &uid_list);
-
+
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_create_appointment (priv->cnc, priv->container_id, cbgw, comp, &uid_list);
else
return GNOME_Evolution_Calendar_OtherError;
}
-
+
/* If delay deliver has been set, server will not send the uid */
if (!uid_list || ((e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_JOURNAL) && e_cal_component_has_organizer (comp))) {
*calobj = NULL;
g_object_unref (comp);
return GNOME_Evolution_Calendar_Success;
}
-
+
if (g_slist_length (uid_list) == 1) {
server_uid = (char *) uid_list->data;
- sanitize_component (backend, comp, server_uid);
+ sanitize_component (backend, comp, server_uid);
g_free (server_uid);
/* if successful, update the cache */
e_cal_backend_cache_put_component (priv->cache, comp);
*calobj = e_cal_component_get_as_string (comp);
} else {
- EGwConnectionStatus stat;
+ EGwConnectionStatus stat;
GList *list = NULL, *tmp;
GPtrArray *uid_array = g_ptr_array_new ();
for (l = uid_list; l; l = g_slist_next (l)) {
g_ptr_array_add (uid_array, l->data);
}
-
+
/* convert uid_list to GPtrArray and get the items in a list */
stat = e_gw_connection_get_items_from_ids (priv->cnc,
- priv->container_id,
+ priv->container_id,
"attachments recipients message recipientStatus default peek",
uid_array, &list);
g_ptr_array_free (uid_array, TRUE);
return GNOME_Evolution_Calendar_OtherError;
}
-
+
comp = g_object_ref ( (ECalComponent *) list->data );
/* convert items into components and add them to the cache */
for (i=0, tmp = list; tmp ; tmp = g_list_next (tmp), i++) {
EGwItem *item;
item = (EGwItem *) tmp->data;
- e_cal_comp = e_gw_item_to_cal_component (item, cbgw);
+ e_cal_comp = e_gw_item_to_cal_component (item, cbgw);
e_cal_component_commit_sequence (e_cal_comp);
sanitize_component (backend, e_cal_comp, g_ptr_array_index (uid_array, i));
e_cal_backend_cache_put_component (priv->cache, e_cal_comp);
-
+
if (i == 0) {
- *calobj = e_cal_component_get_as_string (e_cal_comp);
+ *calobj = e_cal_component_get_as_string (e_cal_comp);
}
if (i != 0) {
return GNOME_Evolution_Calendar_Success;
}
-static void
+static void
get_retract_data (ECalComponent *comp, const char **retract_comment, gboolean *all_instances)
{
icalcomponent *icalcomp = NULL;
}
static ECalBackendSyncStatus
-e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal, const char *calobj,
+e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal, const char *calobj,
CalObjModType mod, char **old_object, char **new_object)
{
ECalBackendGroupwise *cbgw;
in_offline (cbgw);
return GNOME_Evolution_Calendar_RepositoryOffline;
}
-
+
/* check the component for validity */
icalcomp = icalparser_parse_string (calobj);
if (!icalcomp)
return GNOME_Evolution_Calendar_ObjectNotFound;
}
- if (e_cal_component_has_attendees (comp) &&
+ if (e_cal_component_has_attendees (comp) &&
e_cal_backend_groupwise_utils_check_delegate (comp, e_gw_connection_get_user_email (priv->cnc))) {
const char *id = NULL, *recur_key = NULL;
if (mod == CALOBJ_MOD_ALL && e_cal_component_is_instance (comp)) {
recur_key = uid;
- }
+ }
id = e_gw_item_get_id (item);
- status = e_gw_connection_delegate_request (priv->cnc, item, id, NULL, NULL, recur_key);
+ status = e_gw_connection_delegate_request (priv->cnc, item, id, NULL, NULL, recur_key);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_delegate_request (priv->cnc, item, id, NULL, NULL, recur_key);
e_cal_backend_cache_put_component (priv->cache, comp);
*new_object = e_cal_component_get_as_string (comp);
break;
- }
+ }
item = e_gw_item_new_from_cal_component (priv->container_id, cbgw, comp);
cache_item = e_gw_item_new_from_cal_component (priv->container_id, cbgw, cache_comp);
if ( e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_TASK) {
gboolean completed, cache_completed;
-
+
completed = e_gw_item_get_completed (item);
cache_completed = e_gw_item_get_completed (cache_item);
if (completed && !cache_completed) {
/*FIXME return values. */
status = e_gw_connection_complete_request (priv->cnc, e_gw_item_get_id (item));
-
+
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_complete_request (priv->cnc, e_gw_item_get_id (item));
-
+
if (status != E_GW_CONNECTION_STATUS_OK) {
g_object_unref (comp);
g_object_unref (cache_comp);
break;
}
}
-
- e_gw_item_set_changes (item, cache_item);
+
+ e_gw_item_set_changes (item, cache_item);
/* the second argument is redundant */
status = e_gw_connection_modify_item (priv->cnc, e_gw_item_get_id (item), item);
-
+
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_modify_item (priv->cnc, e_gw_item_get_id (item), item);
}
static const char *
-get_gw_item_id (icalcomponent *icalcomp)
+get_gw_item_id (icalcomponent *icalcomp)
{
- icalproperty *icalprop;
+ icalproperty *icalprop;
/* search the component for the X-GWRECORDID property */
icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
ECalBackendSyncStatus status;
const char *id_to_remove = NULL;
icalcomponent *icalcomp;
-
+
status = e_cal_backend_groupwise_get_object (backend, cal, uid, rid, &calobj);
if (status != GNOME_Evolution_Calendar_Success)
return status;
}
if (mod == CALOBJ_MOD_THIS) {
- id_to_remove = get_gw_item_id (icalcomp);
+ id_to_remove = get_gw_item_id (icalcomp);
if (!id_to_remove) {
/* use the iCalId to remove the object */
id_to_remove = uid;
if (e_cal_component_has_attendees (E_CAL_COMPONENT (comp_list->data))) {
/* get recurrence key and send it to
* e_gw_connection_remove_recurrence_item */
-
- id_to_remove = get_gw_item_id (e_cal_component_get_icalcomponent (comp_list->data));
+
+ id_to_remove = get_gw_item_id (e_cal_component_get_icalcomponent (comp_list->data));
status = e_gw_connection_decline_request (priv->cnc, id_to_remove, NULL, uid);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_decline_request (priv->cnc, id_to_remove, NULL, uid);
} else {
- GList *item_ids = NULL;
-
+ GList *item_ids = NULL;
+
for (l = comp_list; l; l = l->next) {
ECalComponent *comp = E_CAL_COMPONENT (l->data);
- id_to_remove = get_gw_item_id (e_cal_component_get_icalcomponent (comp));
+ id_to_remove = get_gw_item_id (e_cal_component_get_icalcomponent (comp));
item_ids = g_list_append (item_ids, (char *) id_to_remove);
}
status = e_gw_connection_remove_items (priv->cnc, priv->container_id, item_ids);
-
+
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
status = e_gw_connection_remove_items (priv->cnc, priv->container_id, item_ids);
}
ECalComponent *comp = E_CAL_COMPONENT (l->data);
ECalComponentId *id = e_cal_component_get_id (comp);
- e_cal_backend_cache_remove_component (priv->cache, id->uid,
+ e_cal_backend_cache_remove_component (priv->cache, id->uid,
id->rid);
if (!id->rid || !g_str_equal (id->rid, rid))
e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw), id, e_cal_component_get_as_string (comp), NULL);
e_cal_component_free_id (id);
-
+
g_object_unref (comp);
-
+
}
/* Setting NULL would trigger another signal.
* We do not set the *object to NULL */
return GNOME_Evolution_Calendar_RepositoryOffline;
} else
return GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED;
-
+
}
/* This function is largely duplicated in
e_cal_component_get_uid (comp, &uid);
/*FIXME get the uri rather than computing the path */
attach_store = g_strdup (e_cal_backend_groupwise_get_local_attachments_store (cbgw));
-
+
for (l = attach_list; l ; l = l->next) {
char *sfname = (char *)l->data;
char *filename, *new_filename;
e_cal_component_set_attachment_list (comp, new_attach_list);
}
-static void
+static void
change_status (ECalComponent *comp, icalparameter_partstat status, const char *email)
-{
- icalproperty *prop;
+{
+ icalproperty *prop;
icalparameter *param;
gboolean found = FALSE;
icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp);
priv = cbgw->priv;
/* When the icalcomponent is obtained through the itip message rather
- * than from the SOAP protocol, the container id has to be explicitly
+ * than from the SOAP protocol, the container id has to be explicitly
* added to the xgwrecordid inorder to obtain the item id. */
icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
while (icalprop) {
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
method = icalcomponent_get_method (icalcomp);
-
+
/* handle attachments */
if (e_cal_component_has_attachments (comp))
fetch_attachments (cbgw, comp);
if (all_instances) {
const char *uid;
-
+
e_cal_component_get_uid (modif_comp, (const char **) &uid);
comps = e_cal_backend_cache_get_components_by_uid (priv->cache, uid);
comps = g_slist_append (comps, component);
found = TRUE;
}
-
+
e_cal_component_free_id (id);
}
-
+
for (l = comps; l != NULL; l = l->next) {
ECalComponent *component = E_CAL_COMPONENT (l->data);
char *comp_str = NULL;
change_status (component, pstatus, e_gw_connection_get_user_email (priv->cnc));
- e_cal_backend_cache_put_component (priv->cache, component);
+ e_cal_backend_cache_put_component (priv->cache, component);
comp_str = e_cal_component_get_as_string (component);
-
+
if (found)
e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbgw), comp_str, comp_str);
else
g_free (comp_str);
}
}
-
+
g_slist_foreach (comps, (GFunc) g_object_unref, NULL);
g_slist_free (comps);
- g_object_unref (comp);
+ g_object_unref (comp);
g_object_unref (modif_comp);
return GNOME_Evolution_Calendar_Success;
g_object_unref (comp);
return GNOME_Evolution_Calendar_ObjectNotFound;
}
-
+
switch (priv->mode) {
case CAL_MODE_ANY :
case CAL_MODE_REMOTE :
if (method == ICAL_METHOD_CANCEL) {
- const char *retract_comment = NULL;
+ const char *retract_comment = NULL;
gboolean all_instances = FALSE;
const char *id = NULL;
ECalComponentId *cid = e_cal_component_get_id (component);
char *object = e_cal_component_get_as_string (component);
- if (e_cal_backend_cache_remove_component (priv->cache, cid->uid,
+ if (e_cal_backend_cache_remove_component (priv->cache, cid->uid,
cid->rid))
e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw), cid, object, NULL);
-
+
e_cal_component_free_id (cid);
g_free (object);
g_object_unref (component);
cid = e_cal_component_get_id (comp);
icalcomp = e_cal_component_get_icalcomponent (comp);
object = e_cal_component_get_as_string (comp);
-
- if (e_cal_backend_cache_remove_component (priv->cache, cid->uid,
+
+ if (e_cal_backend_cache_remove_component (priv->cache, cid->uid,
cid->rid)) {
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw), cid,
+ e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw), cid,
object, NULL);
}
status = GNOME_Evolution_Calendar_RepositoryOffline;
break;
default:
- break;
+ break;
}
g_object_unref (comp);
status = send_object (cbgw, cal, icalcomp, method);
} else
status = GNOME_Evolution_Calendar_InvalidObject;
-
+
if (status == GNOME_Evolution_Calendar_Success) {
ECalComponent *comp;
comp = e_cal_component_new ();
-
+
if (e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp))) {
GSList *attendee_list = NULL, *tmp;
e_cal_component_get_attendee_list (comp, &attendee_list);
/* convert this into GList */
for (tmp = attendee_list; tmp; tmp = g_slist_next (tmp)) {
const char *attendee = tmp->data;
-
+
if (attendee)
*users = g_list_append (*users, g_strdup (attendee));
}
-
- g_object_unref (comp);
+
+ g_object_unref (comp);
}
*modified_calobj = g_strdup (calobj);
}
/**
* e_cal_backend_groupwise_get_type:
- * @void:
- *
+ * @void:
+ *
* Registers the #ECalBackendGroupwise class if necessary, and returns the type ID
* associated to it.
- *
+ *
* Return value: The type ID of the #ECalBackendGroupwise class.
**/
GType
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
icaltimezone_free (priv->default_zone, 1);
priv->default_zone = NULL;
}
-
+
if (priv->soup_session) {
soup_session_abort (priv->soup_session);
e_cal_backend_http_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
{
*read_only = TRUE;
-
+
return GNOME_Evolution_Calendar_Success;
}
e_cal_backend_http_get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, char **attribute)
{
*attribute = NULL;
-
+
return GNOME_Evolution_Calendar_Success;
}
* with it (although that would be a useful feature some day).
*/
*address = NULL;
-
+
return GNOME_Evolution_Calendar_Success;
}
/* Authentication helpers for libsoup */
static void
-soup_authenticate (SoupSession *session,
+soup_authenticate (SoupSession *session,
SoupMessage *msg,
- const char *auth_type,
+ const char *auth_type,
const char *auth_realm,
- char **username,
- char **password,
+ char **username,
+ char **password,
gpointer data)
{
ECalBackendHttpPrivate *priv;
ECalBackendHttp *cbhttp;
-
- cbhttp = E_CAL_BACKEND_HTTP (data);
+
+ cbhttp = E_CAL_BACKEND_HTTP (data);
priv = cbhttp->priv;
*username = priv->username;
*password = priv->password;
-
+
priv->username = NULL;
priv->password = NULL;
}
static void
-soup_reauthenticate (SoupSession *session,
+soup_reauthenticate (SoupSession *session,
SoupMessage *msg,
- const char *auth_type,
+ const char *auth_type,
const char *auth_realm,
- char **username,
- char **password,
+ char **username,
+ char **password,
gpointer data)
{
ECalBackendHttpPrivate *priv;
ECalBackendHttp *cbhttp;
-
- cbhttp = E_CAL_BACKEND_HTTP (data);
+
+ cbhttp = E_CAL_BACKEND_HTTP (data);
priv = cbhttp->priv;
*username = priv->username;
*password = priv->password;
-
+
priv->username = NULL;
priv->password = NULL;
}
G_CALLBACK (soup_authenticate), cbhttp);
g_signal_connect (priv->soup_session, "reauthenticate",
G_CALLBACK (soup_reauthenticate), cbhttp);
-
+
/* set the HTTP proxy, if configuration is set to do so */
conf_client = gconf_client_get_default ();
if (gconf_client_get_bool (conf_client, "/system/http_proxy/use_http_proxy", NULL)) {
if (priv->uri == NULL) {
ESource *source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
const char *secure_prop = e_source_get_property (source, "use_ssl");
-
+
priv->uri = webcal_to_http_method (e_cal_backend_get_uri (E_CAL_BACKEND (cbhttp)),
(secure_prop && g_str_equal(secure_prop, "1")));
}
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
ESource *source;
-
+
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
source = e_cal_backend_get_source (E_CAL_BACKEND (backend));
-
+
if (e_source_get_property (source, "auth") != NULL) {
if ((username == NULL || password == NULL)) {
return GNOME_Evolution_Calendar_AuthenticationRequired;
if (!priv->cache) {
e_cal_backend_notify_error (E_CAL_BACKEND(cbhttp), _("Could not create cache file"));
- return GNOME_Evolution_Calendar_OtherError;
+ return GNOME_Evolution_Calendar_OtherError;
}
-
+
if (priv->default_zone) {
e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
}
- if (priv->mode == CAL_MODE_LOCAL)
+ if (priv->mode == CAL_MODE_LOCAL)
return GNOME_Evolution_Calendar_Success;
-
+
g_idle_add ((GSourceFunc) begin_retrieval_cb, cbhttp);
}
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
-
+
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
priv = cbhttp->priv;
loaded = e_cal_backend_http_is_loaded (backend);
-
+
switch (mode) {
case CAL_MODE_LOCAL:
priv->mode = mode;
}
break;
case CAL_MODE_REMOTE:
- case CAL_MODE_ANY:
+ case CAL_MODE_ANY:
priv->mode = mode;
set_mode = cal_mode_to_corba (mode);
- if (loaded)
+ if (loaded)
g_idle_add ((GSourceFunc) begin_retrieval_cb, backend);
break;
-
+
priv->mode = CAL_MODE_REMOTE;
set_mode = GNOME_Evolution_Calendar_MODE_REMOTE;
break;
}
if (loaded) {
-
+
if (set_mode == GNOME_Evolution_Calendar_MODE_ANY)
e_cal_backend_notify_mode (backend,
GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
ECalBackendHttpPrivate *priv;
ECalBackendCache *cache;
char *query, *iso_start, *iso_end;
-
+
priv = cbhttp->priv;
cache = priv->cache;
gchar *address, *name;
icalcomponent *vfb;
char *calobj;
-
+
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
vfb = create_user_free_busy (cbhttp, address, name, start, end);
calobj = icalcomponent_as_ical_string (vfb);
*freebusy = g_list_append (*freebusy, g_strdup (calobj));
- icalcomponent_free (vfb);
+ icalcomponent_free (vfb);
g_free (address);
g_free (name);
}
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
-
+
cbhttp = E_CAL_BACKEND_HTTP (backend);
priv = cbhttp->priv;
}
static ECalBackendSyncStatus
-e_cal_backend_http_modify_object (ECalBackendSync *backend, EDataCal *cal, const char *calobj,
+e_cal_backend_http_modify_object (ECalBackendSync *backend, EDataCal *cal, const char *calobj,
CalObjModType mod, char **old_object, char **new_object)
{
ECalBackendHttp *cbhttp;
/**
* e_cal_backend_http_get_type:
- * @void:
- *
+ * @void:
+ *
* Registers the #ECalBackendHttp class if necessary, and returns the type ID
* associated to it.
- *
+ *
* Return value: The type ID of the #ECalBackendHttp class.
**/
GType
static ECalComponent* create_weather (ECalBackendWeather *cbw, WeatherForecast *report);
static ECalBackendSyncStatus
e_cal_backend_weather_add_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzobj);
-
+
/* Private part of the ECalBackendWeather structure */
struct _ECalBackendWeatherPrivate {
/* URI to get remote weather data from */
source = g_main_current_source ();
- if (priv->begin_retrival_id == g_source_get_id (source))
+ if (priv->begin_retrival_id == g_source_get_id (source))
priv->begin_retrival_id = 0;
if (priv->is_loading)
if (priv->city)
g_free (priv->city);
priv->city = g_strdup (strrchr (uri, '/') + 1);
-
+
if (!priv->cache) {
priv->cache = e_cal_backend_cache_new (uri, E_CAL_SOURCE_TYPE_EVENT);
/**
* e_cal_backend_weather_get_type:
- * @void:
+ * @void:
*
* Registers the #ECalBackendWeather class if necessary, and returns
* the type ID associated to it.
struct recur_id {
struct datetime recur_time;
-
+
icalparameter *range_param;
};
icalproperty *status;
GSList *attendee_list;
-
+
icalproperty *categories;
icalproperty *classification;
GSList *exrule_list; /* list of icalproperty objects */
struct organizer organizer;
-
+
icalproperty *geo;
icalproperty *last_modified;
icalproperty *percent;
icalproperty *priority;
struct recur_id recur_id;
-
+
GSList *rdate_list; /* list of struct period */
GSList *rrule_list; /* list of icalproperty objects */
{
ECalComponentPrivate *priv;
GSList *l;
-
+
priv = comp->priv;
if (!priv->icalcomp)
icalcomponent_free (priv->icalcomp);
priv->icalcomp = NULL;
}
-
+
/* Free the mappings */
priv->uid = NULL;
g_free (l->data);
g_slist_free (priv->attendee_list);
priv->attendee_list = NULL;
-
+
priv->categories = NULL;
priv->classification = NULL;
/* Scans an attachment property */
static void
-scan_attachment (GSList **attachment_list, icalproperty *prop)
+scan_attachment (GSList **attachment_list, icalproperty *prop)
{
struct attachment *attachment;
-
+
attachment = g_new (struct attachment, 1);
attachment->prop = prop;
/* Scans an attendee property */
static void
-scan_attendee (GSList **attendee_list, icalproperty *prop)
+scan_attendee (GSList **attendee_list, icalproperty *prop)
{
struct attendee *attendee;
-
+
attendee = g_new (struct attendee, 1);
attendee->prop = prop;
attendee->sentby_param = icalproperty_get_first_parameter (prop, ICAL_SENTBY_PARAMETER);
attendee->cn_param = icalproperty_get_first_parameter (prop, ICAL_CN_PARAMETER);
attendee->language_param = icalproperty_get_first_parameter (prop, ICAL_LANGUAGE_PARAMETER);
-
+
*attendee_list = g_slist_append (*attendee_list, attendee);
}
/* Scans and attendee property */
static void
-scan_organizer (ECalComponent *comp, struct organizer *organizer, icalproperty *prop)
+scan_organizer (ECalComponent *comp, struct organizer *organizer, icalproperty *prop)
{
organizer->prop = prop;
e_cal_component_strip_errors (ECalComponent *comp)
{
ECalComponentPrivate *priv;
-
+
g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
priv = comp->priv;
g_return_val_if_fail (priv->icalcomp != NULL, NULL);
-
+
id = g_new0 (ECalComponentId, 1);
id->uid = g_strdup (icalproperty_get_uid (priv->uid));
id->rid = g_strdup (e_cal_component_get_recurid_as_string (comp));
return id;
-}
+}
/**
* e_cal_component_get_uid:
if (icalattach_get_is_url (attachment->attach)) {
/* FIXME : this ref count is screwed up
* These structures are being leaked.
- */
+ */
icalattach_ref (attachment->attach);
data = icalattach_get_url (attachment->attach);
buf_size = strlen (data);
buf = g_malloc0 (buf_size+1);
- icalvalue_decode_ical_string (data, buf, buf_size);
+ icalvalue_decode_ical_string (data, buf, buf_size);
}
else
data = NULL;
buf_size = 2 * strlen ((char *)l->data);
buf = g_malloc0 (buf_size);
icalvalue_encode_ical_string (l->data, buf, buf_size);
- attachment->attach = icalattach_new_from_url ((char *) buf);
+ attachment->attach = icalattach_new_from_url ((char *) buf);
attachment->prop = icalproperty_new_attach (attachment->attach);
icalcomponent_add_property (icalcomp, attachment->prop);
g_free (buf);
/**
- * e_cal_component_get_attachment_list:
- * @comp: A calendar component object.
+ * e_cal_component_get_attachment_list:
+ * @comp: A calendar component object.
* @attachment_list: Return list of URLS to attachments.
- *
+ *
* Queries the attachment properties of the calendar component object. When done,
* the @attachment_list should be freed by calling #g_slist_free.
**/
e_cal_component_get_attachment_list (ECalComponent *comp, GSList **attachment_list)
{
ECalComponentPrivate *priv;
-
+
g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
g_return_if_fail (attachment_list != NULL);
/**
* e_cal_component_set_attachment_list:
- * @comp: A calendar component object.
+ * @comp: A calendar component object.
* @attachment_list: list of urls to attachment pointers.
*
* This currently handles only attachments that are urls
if (g_slist_length (priv->attachment_list) > 0)
return TRUE;
-
+
return FALSE;
}
*
* Return value: the number of attachments.
*/
-int
+int
e_cal_component_get_num_attachments (ECalComponent *comp)
{
ECalComponentPrivate *priv;
priv = comp->priv;
return g_slist_length (priv->attachment_list) > 0;
-
+
}
/**
dt->tzid = NULL;
dt->value = NULL;
-
+
g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
dt->tzid = NULL;
dt->value = NULL;
-
+
g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
dt->tzid = NULL;
dt->value = NULL;
-
+
g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
* e_cal_component_get_organizer:
* @comp: A calendar component object
* @organizer: A value for the organizer
- *
+ *
* Queries the organizer property of a calendar component object
**/
void
* e_cal_component_set_organizer:
* @comp: A calendar component object.
* @organizer: Value for the organizer property
- *
+ *
* Sets the organizer of a calendar component object
**/
void
/**
* e_cal_component_has_organizer:
* @comp: A calendar component object.
- *
+ *
* Check whether a calendar component object has an organizer or not.
- *
+ *
* Return value: TRUE if there is an organizer, FALSE otherwise.
**/
gboolean
return priv->organizer.prop != NULL;
}
-
+
/**
* e_cal_component_get_percent:
* @comp: A calendar component object.
* e_cal_component_get_recurid:
* @comp: A calendar component object.
* @recur_id: Return value for the recurrence id property
- *
+ *
* Queries the recurrence id property of a calendar component object.
**/
-void
+void
e_cal_component_get_recurid (ECalComponent *comp, ECalComponentRange *recur_id)
{
ECalComponentPrivate *priv;
priv = comp->priv;
g_return_if_fail (priv->icalcomp != NULL);
- get_datetime (&priv->recur_id.recur_time,
- icalproperty_get_recurrenceid,
+ get_datetime (&priv->recur_id.recur_time,
+ icalproperty_get_recurrenceid,
&recur_id->datetime);
}
return "0";
tt = *range.datetime.value;
e_cal_component_free_range (&range);
-
+
return icaltime_is_valid_time (tt) && !icaltime_is_null_time (tt) ?
icaltime_as_ical_string (tt) : "0";
}
* e_cal_component_set_recurid:
* @comp: A calendar component object.
* @recur_id: Value for the recurrence id property.
- *
+ *
* Sets the recurrence id property of a calendar component object.
**/
void
priv = comp->priv;
g_return_if_fail (priv->icalcomp != NULL);
-
+
set_datetime (comp, &priv->recur_id.recur_time,
icalproperty_new_recurrenceid,
icalproperty_set_recurrenceid,
if (!e_cal_component_has_recurrences (comp))
return TRUE;
-
+
e_cal_component_get_rrule_list (comp, &rrule_list);
len = g_slist_length (rrule_list);
if (len > 1
if (n_by_second != 0
|| n_by_minute != 0
|| n_by_hour != 0)
- goto cleanup;
+ goto cleanup;
switch (r->freq) {
case ICAL_DAILY_RECURRENCE:
if (pos != 0)
goto cleanup;
}
-
+
simple = TRUE;
break;
nth = r->by_month_day[0];
if (nth < 1 && nth != -1)
goto cleanup;
-
+
simple = TRUE;
-
+
} else if (n_by_day == 1) {
enum icalrecurrencetype_weekday weekday;
int pos;
} else {
goto cleanup;
}
-
+
simple = TRUE;
break;
|| n_by_month != 0
|| n_by_set_pos != 0)
goto cleanup;
-
+
simple = TRUE;
break;
*
* Return value: TRUE if it is an instance, FALSE if not.
*/
-gboolean
+gboolean
e_cal_component_is_instance (ECalComponent *comp)
{
ECalComponentPrivate *priv;
}
} else if (priv->summary.altrep_param) {
icalproperty_remove_parameter (priv->summary.prop, ICAL_ALTREP_PARAMETER);
- priv->summary.altrep_param = NULL;
+ priv->summary.altrep_param = NULL;
}
/* look for alarms that need a description */
a->value = icalproperty_get_attendee (attendee->prop);
if (attendee->member_param)
- a->member = icalparameter_get_member (attendee->member_param);
+ a->member = icalparameter_get_member (attendee->member_param);
if (attendee->cutype_param)
a->cutype = icalparameter_get_cutype (attendee->cutype_param);
else
else
attendee->rsvp_param = icalparameter_new_rsvp (ICAL_RSVP_FALSE);
icalproperty_add_parameter (attendee->prop, attendee->rsvp_param);
-
+
if (a->delfrom) {
attendee->delfrom_param = icalparameter_new_delegatedfrom (a->delfrom);
icalproperty_add_parameter (attendee->prop, attendee->delfrom_param);
}
/**
- * e_cal_component_get_attendee_list:
- * @comp: A calendar component object.
+ * e_cal_component_get_attendee_list:
+ * @comp: A calendar component object.
* @attendee_list: Return value for the attendee property.
* This should be freed using the e_cal_component_free_attendee_list ()
* function.
- *
+ *
* Queries the attendee properties of the calendar component object
**/
void
e_cal_component_get_attendee_list (ECalComponent *comp, GSList **attendee_list)
{
ECalComponentPrivate *priv;
-
+
g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
g_return_if_fail (attendee_list != NULL);
/**
* e_cal_component_set_attendee_list:
- * @comp: A calendar component object.
+ * @comp: A calendar component object.
* @attendee_list: Values for attendee properties
- *
+ *
* Sets the attendees of a calendar component object
**/
void
if (g_slist_length (priv->attendee_list) > 0)
return TRUE;
-
+
return FALSE;
}
* e_cal_component_get_location:
* @comp: A calendar component object
* @location: Return value for the location.
- *
+ *
* Queries the location property of a calendar component object.
**/
void
* e_cal_component_set_location:
* @comp: A calendar component object.
* @location: Location value.
- *
+ *
* Sets the location property of a calendar component object.
**/
void
*
* Frees an #ECalComponentRange structure.
*/
-void
+void
e_cal_component_free_range (ECalComponentRange *range)
{
g_return_if_fail (range != NULL);
g_free (id->uid);
id->uid = NULL;
}
-
+
if (id->rid) {
g_free (id->rid);
id->rid = NULL;
/**
* e_cal_component_free_attendee_list:
* @attendee_list: List of attendees.
- *
+ *
* Frees a list of #ECalComponentAttendee structures.
- *
+ *
**/
void
e_cal_component_free_attendee_list (GSList *attendee_list)
* e_cal_component_add_alarm:
* @comp: A calendar component.
* @alarm: An alarm.
- *
+ *
* Adds an alarm subcomponent to a calendar component. You should have created
* the @alarm by using e_cal_component_alarm_new(); it is invalid to use a
* #ECalComponentAlarm structure that came from e_cal_component_get_alarm(). After
* e_cal_component_remove_alarm:
* @comp: A calendar component.
* @auid: UID of the alarm to remove.
- *
+ *
* Removes an alarm subcomponent from a calendar component. If the alarm that
* corresponds to the specified @auid had been fetched with
* e_cal_component_get_alarm(), then those alarm structures will be invalid; you
ECalComponent *comp = E_CAL_COMPONENT (data);
ECalComponentPrivate *priv;
icalcomponent *alarm = value;
-
+
priv = comp->priv;
-
+
icalcomponent_remove_component (priv->icalcomp, alarm);
icalcomponent_free (alarm);
- return TRUE;
+ return TRUE;
}
/**
* e_cal_component_remove_all_alarms:
* @comp: A calendar component
- *
+ *
* Remove all alarms from the calendar component
**/
void
case ICAL_ATTENDEE_PROPERTY:
scan_attendee (&alarm->attendee_list, prop);
break;
-
+
case ICAL_X_PROPERTY:
xname = icalproperty_get_x_name (prop);
g_assert (xname != NULL);
alarm->repeat = NULL;
alarm->trigger = NULL;
alarm->attendee_list = NULL;
-
+
for (prop = icalcomponent_get_first_property (subcomp, ICAL_ANY_PROPERTY);
prop;
prop = icalcomponent_get_next_property (subcomp, ICAL_ANY_PROPERTY))
icalcompiter_next (&iter)) {
icalcomponent *subcomp;
icalproperty *prop;
-
+
subcomp = icalcompiter_deref (&iter);
for (prop = icalcomponent_get_first_property (subcomp, ICAL_X_PROPERTY);
prop;
prop = icalcomponent_get_next_property (subcomp, ICAL_X_PROPERTY)) {
const char *xname;
-
+
xname = icalproperty_get_x_name (prop);
g_assert (xname != NULL);
-
+
if (strcmp (xname, EVOLUTION_ALARM_UID_PROPERTY) == 0) {
const char *auid;
-
+
auid = alarm_uid_from_prop (prop);
l = g_list_append (l, g_strdup (auid));
}
alarm->repeat = NULL;
alarm->trigger = NULL;
alarm->attendee_list = NULL;
-
+
return alarm;
}
/**
* e_cal_component_alarm_clone:
* @alarm: An alarm subcomponent.
- *
+ *
* Creates a new alarm subcomponent by copying the information from another one.
- *
+ *
* Return value: A newly-created alarm subcomponent with the same values as the
* original one. Should be freed with e_cal_component_alarm_free().
**/
e_cal_component_alarm_free (ECalComponentAlarm *alarm)
{
GSList *l;
-
+
g_return_if_fail (alarm != NULL);
g_assert (alarm->icalcomp != NULL);
g_free (l->data);
g_slist_free (alarm->attendee_list);
alarm->attendee_list = NULL;
-
+
g_free (alarm);
}
* e_cal_component_alarm_get_attach:
* @alarm: An alarm.
* @attach: Return value for the attachment; should be freed using icalattach_unref().
- *
+ *
* Queries the attachment property of an alarm.
**/
void
* e_cal_component_alarm_set_attach:
* @alarm: An alarm.
* @attach: Attachment property or NULL to remove an existing property.
- *
+ *
* Sets the attachment property of an alarm.
**/
void
* e_cal_component_alarm_get_description:
* @alarm: An alarm.
* @description: Return value for the description property and its parameters.
- *
+ *
* Queries the description property of an alarm.
**/
void
* e_cal_component_alarm_set_description:
* @alarm: An alarm.
* @description: Description property and its parameters, or NULL for no description.
- *
+ *
* Sets the description property of an alarm.
**/
void
* e_cal_component_alarm_get_repeat:
* @alarm: An alarm.
* @repeat: Return value for the repeat/duration properties.
- *
+ *
* Queries the repeat/duration properties of an alarm.
**/
void
* @alarm: An alarm.
* @repeat: Repeat/duration values. To remove any repetitions from the alarm,
* set the @repeat.repetitions to 0.
- *
+ *
* Sets the repeat/duration values for an alarm.
**/
void
*
* Gets the list of attendees associated with an alarm.
*/
-void
+void
e_cal_component_alarm_get_attendee_list (ECalComponentAlarm *alarm, GSList **attendee_list)
{
g_return_if_fail (alarm != NULL);
-
+
get_attendee_list (alarm->attendee_list, attendee_list);
}
*
* Sets the list of attendees for an alarm.
*/
-void
+void
e_cal_component_alarm_set_attendee_list (ECalComponentAlarm *alarm, GSList *attendee_list)
{
g_return_if_fail (alarm != NULL);
*
* Return value: TRUE if there are attendees in the alarm, FALSE if not.
*/
-gboolean
+gboolean
e_cal_component_alarm_has_attendees (ECalComponentAlarm *alarm)
{
if (g_slist_length (alarm->attendee_list) > 0)
return TRUE;
-
- return FALSE;
+
+ return FALSE;
}
typedef struct {
ECalComponentRangeType type;
-
+
ECalComponentDateTime datetime;
} ECalComponentRange;
E_CAL_COMPONENT_TRANSP_UNKNOWN
} ECalComponentTransparency;
-/* Organizer & Attendee */
+/* Organizer & Attendee */
typedef struct {
const char *value;
-
+
const char *member;
icalparameter_cutype cutype;
icalparameter_role role;
icalparameter_partstat status;
gboolean rsvp;
-
+
const char *delto;
const char *delfrom;
const char *sentby;
const char *cn;
const char *language;
} ECalComponentAttendee;
-
+
typedef struct {
const char *value;
const char *sentby;
return E_CALENDAR_STATUS_INVALID_SERVER_VERSION;
case GNOME_Evolution_Calendar_NoSuchCal:
return E_CALENDAR_STATUS_NO_SUCH_CALENDAR;
-
+
case GNOME_Evolution_Calendar_OtherError:
default:
return E_CALENDAR_STATUS_OTHER_ERROR;
{
ECalListener *listener;
ECalListenerPrivate *priv;
-
+
listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
priv = listener->priv;
g_list_free (users);
}
-static void
+static void
impl_notifyDefaultObjectRequested (PortableServer_Servant servant,
const GNOME_Evolution_Calendar_CallStatus status,
const CORBA_char *object,
- CORBA_Environment *ev)
+ CORBA_Environment *ev)
{
ECalListener *listener;
ECalListenerPrivate *priv;
-
+
listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
priv = listener->priv;
g_signal_emit (G_OBJECT (listener), signals[DEFAULT_OBJECT], 0, convert_status (status), object);
}
-static void
+static void
impl_notifyObjectRequested (PortableServer_Servant servant,
const GNOME_Evolution_Calendar_CallStatus status,
const CORBA_char *object,
- CORBA_Environment *ev)
+ CORBA_Environment *ev)
{
ECalListener *listener;
ECalListenerPrivate *priv;
-
+
listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
priv = listener->priv;
list = NULL;
for (i = 0; i < seq->_length; i++) {
icalcomponent *comp;
-
+
comp = icalcomponent_new_from_string (seq->_buffer[i]);
if (!comp)
continue;
-
+
list = g_list_prepend (list, comp);
}
return list;
}
-static void
+static void
impl_notifyObjectListRequested (PortableServer_Servant servant,
const GNOME_Evolution_Calendar_CallStatus status,
const GNOME_Evolution_Calendar_stringlist *objects,
- CORBA_Environment *ev)
+ CORBA_Environment *ev)
{
ECalListener *listener;
ECalListenerPrivate *priv;
GList *object_list, *l;
-
+
listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
priv = listener->priv;
return;
object_list = build_object_list (objects);
-
+
g_signal_emit (G_OBJECT (listener), signals[OBJECT_LIST], 0, convert_status (status), object_list);
for (l = object_list; l; l = l->next)
g_list_free (object_list);
}
-static void
+static void
impl_notifyAttachmentListRequested (PortableServer_Servant servant,
const GNOME_Evolution_Calendar_CallStatus status,
const GNOME_Evolution_Calendar_stringlist *attachments,
- CORBA_Environment *ev)
+ CORBA_Environment *ev)
{
ECalListener *listener;
ECalListenerPrivate *priv;
GSList *a_list = NULL;
int i;
-
+
listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
priv = listener->priv;
{
ECalListener *listener;
ECalListenerPrivate *priv;
-
+
listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
priv = listener->priv;
if (!priv->notify)
return;
-
+
g_signal_emit (G_OBJECT (listener), signals[GET_TIMEZONE], 0, convert_status (status), object);
}
{
ECalListener *listener;
ECalListenerPrivate *priv;
-
+
listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
priv = listener->priv;
if (!priv->notify)
return;
-
+
g_signal_emit (G_OBJECT (listener), signals[ADD_TIMEZONE], 0, convert_status (status), tzid);
}
{
ECalListener *listener;
ECalListenerPrivate *priv;
-
+
listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
priv = listener->priv;
if (!priv->notify)
return;
-
+
g_signal_emit (G_OBJECT (listener), signals[SET_DEFAULT_TIMEZONE], 0, convert_status (status));
}
ECalListener *listener;
ECalListenerPrivate *priv;
GList *changes, *l;
-
+
listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
priv = listener->priv;
if (!priv->notify)
return;
-
+
changes = build_change_list (seq);
-
+
g_signal_emit (G_OBJECT (listener), signals[GET_CHANGES], 0, convert_status (status), changes);
for (l = changes; l; l = l->next)
g_object_unref (G_OBJECT (comp));
continue;
}
-
+
list = g_list_append (list, comp);
} else {
icalcomponent_free (icalcomp);
ECalListener *listener;
ECalListenerPrivate *priv;
GList *freebusy, *l;
-
+
listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
priv = listener->priv;
if (!priv->notify)
return;
-
+
freebusy = build_free_busy_list (seq);
-
+
g_signal_emit (G_OBJECT (listener), signals[GET_FREE_BUSY], 0, convert_status (status), freebusy);
for (l = freebusy; l; l = l->next)
g_list_free (freebusy);
}
-static void
+static void
impl_notifyQuery (PortableServer_Servant servant,
const GNOME_Evolution_Calendar_CallStatus status,
const GNOME_Evolution_Calendar_CalView query,
- CORBA_Environment *ev)
+ CORBA_Environment *ev)
{
ECalListener *listener;
ECalListenerPrivate *priv;
-
+
listener = E_CAL_LISTENER (bonobo_object_from_servant (servant));
priv = listener->priv;
if (!priv->notify)
return;
-
+
g_signal_emit (G_OBJECT (listener), signals[QUERY], 0, convert_status (status), query);
}
if (!priv->notify)
return;
-
+
g_signal_emit (G_OBJECT (listener), signals[AUTH_REQUIRED], 0);
}
G_STRUCT_OFFSET (ECalListenerClass, ldap_attribute),
NULL, NULL,
e_cal_marshal_VOID__INT_STRING,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING);
+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING);
signals[STATIC_CAPABILITIES] =
g_signal_new ("static_capabilities",
G_TYPE_FROM_CLASS (klass),
G_STRUCT_OFFSET (ECalListenerClass, open),
NULL, NULL,
g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ G_TYPE_NONE, 1, G_TYPE_INT);
signals[REMOVE] =
g_signal_new ("remove",
G_TYPE_FROM_CLASS (klass),
G_STRUCT_OFFSET (ECalListenerClass, modify_object),
NULL, NULL,
g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ G_TYPE_NONE, 1, G_TYPE_INT);
signals[REMOVE_OBJECT] =
g_signal_new ("remove_object",
G_TYPE_FROM_CLASS (klass),
* calendar changed modes.
* @fn_data: Closure data pointer that will be passed to the notification
* functions.
- *
+ *
* Creates a new #ECalListener object.
*
* Return value: A newly-created #ECalListener object.
g_return_val_if_fail (cal_set_mode_fn != NULL, NULL);
- listener = g_object_new (E_TYPE_CAL_LISTENER,
+ listener = g_object_new (E_TYPE_CAL_LISTENER,
"poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
NULL);
/**
* e_cal_listener_stop_notification:
* @listener: A calendar listener.
- *
+ *
* Informs a calendar listener that no further notification is desired. The
* callbacks specified when the listener was created will no longer be invoked
* after this function is called.
void (*object_list) (ECalListener *listener, ECalendarStatus status, GList **objects);
void (*attachment_list) (ECalListener *listener, ECalendarStatus status, GSList **objects);
-
+
void (*get_timezone) (ECalListener *listener, ECalendarStatus status, const char *object);
void (*add_timezone) (ECalListener *listener, ECalendarStatus status, const char *tzid);
void (*set_default_timezone) (ECalListener *listener, ECalendarStatus status, const char *tzid);
void (*get_changes) (ECalListener *listener, ECalendarStatus status, GList *changes);
void (*get_free_busy) (ECalListener *listener, ECalendarStatus status, GList *freebusy);
-
+
void (*query) (ECalListener *listener, ECalendarStatus status, GNOME_Evolution_Calendar_CalView query);
void (*auth_required) (ECalListener *listener);
if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_JOURNAL) {
icaltimetype start_t = icaltime_from_timet_with_zone (start, FALSE, default_timezone);
icaltimetype end_t = icaltime_from_timet_with_zone (end, FALSE, default_timezone);
-
+
if ((icaltime_compare_date_only (*dtstart.value, start_t) >= 0) && ((icaltime_compare_date_only (*dtstart.value, end_t) < 0)))
(* cb) (comp, dtstart_time, dtend_time, cb_data);
} else if ((end == -1 || dtstart_time < end) && dtend_time > start) {
cal_object_time_from_time (&event_start, dtstart_time, start_zone);
cal_object_time_from_time (&event_end, dtend_time, start_zone);
-
+
/* Calculate the duration of the event, which we use for all
occurrences. We can't just subtract start from end since that may
be affected by daylight-saving time. So we want a value of days
* @convert_end_date: TRUE if the saved end date needs to be converted to the
* given @zone timezone. This is needed if the DTSTART is a DATE or floating
* time.
- *
+ *
* Converts an #icalproperty to a #ECalRecurrence. This should be
* freed using the e_cal_recur_free() function.
- *
+ *
* Return value: #ECalRecurrence structure.
**/
static ECalRecurrence *
/**
* e_cal_recur_free:
* @r: A #ECalRecurrence structure.
- *
+ *
* Frees a #ECalRecurrence structure.
**/
static void
else if (cal_obj_time_compare_func (event_start, chunk_start) >= 0)
g_array_append_vals (occs, event_start, 1);
}
-
+
/* Expand each of the recurrence rules. */
for (elem = rrules; elem; elem = elem->next) {
icalproperty *prop;
while (lower < upper) {
middle = (lower + upper) >> 1;
-
+
rdate = &g_array_index (rdate_periods, CalObjRecurrenceDate,
middle);
cmp = cal_obj_time_compare_func (occ, &rdate->start);
-
+
if (cmp == 0)
break;
else if (cmp < 0)
cotime.day = time_days_in_month (occ->year, occ->month);
g_array_append_val (new_occs, cotime);
}
-
+
elem = elem->next;
}
}
/* Store the end date in the "X-EVOLUTION-ENDDATE" parameter of the
rule. */
e_cal_recur_set_rule_end_date (prop, cb_data.end_date);
-
+
return TRUE;
}
icaltime = icalvalue_get_datetime (value);
icalvalue_free (value);
- zone = default_timezone ? default_timezone :
+ zone = default_timezone ? default_timezone :
icaltimezone_get_utc_timezone ();
return icaltime_as_timet_with_zone (icaltime,
zone);
* @time: A time value.
* @zone: Desired timezone for destination @date, or NULL if the UTC timezone
* is desired.
- *
+ *
* Converts a time_t value to a #GDate structure using the specified timezone.
* This is analogous to g_date_set_time() but takes the timezone into account.
**/
/**
* isodate_from_time_t:
* @t: A time value.
- *
+ *
* Creates an ISO 8601 UTC representation from a time value.
- *
+ *
* Return value: String with the ISO 8601 representation of the UTC time.
**/
char *
const char *fmt;
gmtime_r (&t, &stm);
- ret = g_malloc (ISODATE_LENGTH);
+ ret = g_malloc (ISODATE_LENGTH);
fmt = "%04d%02d%02dT%02d%02d%02dZ";
g_snprintf (ret, ISODATE_LENGTH, fmt, (stm.tm_year+1900), (stm.tm_mon+1), stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec);
/**
* time_from_isodate:
* @str: Date/time value in ISO 8601 format.
- *
+ *
* Converts an ISO 8601 UTC time string into a time_t value.
- *
+ *
* Return value: Time_t corresponding to the specified ISO string.
* Note that we only allow UTC times at present.
**/
icaltimetype_to_tm (struct icaltimetype *itt)
{
struct tm tm;
-
+
memset (&tm, 0, sizeof (struct tm));
if (!itt->is_date) {
tm.tm_year = itt->year - 1900;
tm.tm_wday = time_day_of_week (itt->day, itt->month - 1, itt->year);
tm.tm_isdst = -1;
-
+
return tm;
}
* @itt: A time value.
* @from_zone: Source timezone.
* @to_zone: Destination timezone.
- *
+ *
* Converts a time value from one timezone to another, and returns a struct tm
* representation of the time.
- *
+ *
* Return value: The converted time as a struct tm. All fields will be
* set properly except for tm.tm_yday.
**/
itt.day = tm->tm_mday;
itt.month = tm->tm_mon + 1;
itt.year = tm->tm_year+ 1900;
-
+
itt.is_utc = 0;
- itt.is_date = is_date;
-
+ itt.is_date = is_date;
+
return itt;
}
void time_to_gdate_with_zone (GDate *date, time_t time, icaltimezone *zone);
/**************************************************************************
- * struct tm manipulation
+ * struct tm manipulation
**************************************************************************/
struct tm icaltimetype_to_tm (struct icaltimetype *itt);
E_CAL_CHANGE_DELETED = 1 << 2
} ECalChangeType;
-typedef struct
+typedef struct
{
ECalComponent *comp;
ECalChangeType type;
icalcomponent_merge_component (icalcomp, tmp);
else
icalcomp = tmp;
- } else
+ } else
g_warning ("Could not merge the components, the component is either invalid or not a toplevel component \n");
g_string_free (comp_str, TRUE);
time_t start;
time_t end;
ECalComponentAlarmAction *omit;
-
+
/* This is what we compute */
GSList *triggers;
int n_triggers;
time_t dur_time;
time_t occur_time, trigger_time;
int i;
-
+
auid = l->data;
alarm = e_cal_component_get_alarm (comp, auid);
g_assert (alarm != NULL);
}
if (aod->omit[i] != -1)
continue;
-
+
if (trigger.type != E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START
&& trigger.type != E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END)
continue;
time_t occur_start, occur_end;
icaltimezone *zone;
int i;
-
+
auid = l->data;
alarm = e_cal_component_get_alarm (comp, auid);
g_assert (alarm != NULL);
* @icalcomp: An #icalcomponent.
*
* Checks if an #icalcomponent has any attendees.
- *
+ *
* Return value: TRUE if there are attendees, FALSE if not.
*/
gboolean
return FALSE;
}
-
+
/* now match the timezones */
if (!(!c1_dtstart.zone && !c2_dtstart.zone) ||
list = NULL;
for (i = 0; i < seq->_length; i++) {
icalcomponent *comp;
-
+
comp = icalcomponent_new_from_string (seq->_buffer[i]);
if (!comp)
continue;
-
+
list = g_list_prepend (list, comp);
}
corba_id = &seq->_buffer[i];
id = g_new (ECalComponentId, 1);
-
+
id->uid = g_strdup (corba_id->uid);
id->rid = g_strdup (corba_id->rid);
ECalViewListener *ql;
ECalViewListenerPrivate *priv;
GList *object_list, *l;
-
+
ql = E_CAL_VIEW_LISTENER (bonobo_object_from_servant (servant));
priv = ql->priv;
object_list = build_object_list (objects);
-
+
g_signal_emit (G_OBJECT (ql), signals[OBJECTS_ADDED], 0, object_list);
for (l = object_list; l; l = l->next)
ECalViewListener *ql;
ECalViewListenerPrivate *priv;
GList *object_list, *l;
-
+
ql = E_CAL_VIEW_LISTENER (bonobo_object_from_servant (servant));
priv = ql->priv;
object_list = build_object_list (objects);
-
+
g_signal_emit (G_OBJECT (ql), signals[OBJECTS_MODIFIED], 0, object_list);
for (l = object_list; l; l = l->next)
ECalViewListener *ql;
ECalViewListenerPrivate *priv;
GList *id_list, *l;
-
+
ql = E_CAL_VIEW_LISTENER (bonobo_object_from_servant (servant));
priv = ql->priv;
id_list = build_id_list (ids);
-
+
g_signal_emit (G_OBJECT (ql), signals[OBJECTS_REMOVED], 0, id_list);
for (l = id_list; l; l = l->next)
ql = E_CAL_VIEW_LISTENER (bonobo_object_from_servant (servant));
priv = ql->priv;
-
+
g_signal_emit (G_OBJECT (ql), signals[VIEW_PROGRESS], 0, message, percent);
}
ql = E_CAL_VIEW_LISTENER (bonobo_object_from_servant (servant));
priv = ql->priv;
-
+
g_signal_emit (G_OBJECT (ql), signals[VIEW_DONE], 0, convert_status (status));
}
{
ECalView *view;
ECalViewPrivate *priv;
-
+
view = E_CAL_VIEW (object);
priv = view->priv;
-
+
switch (property_id) {
case PROP_VIEW:
if (priv->view != CORBA_OBJECT_NIL)
priv->listener = bonobo_object_ref (g_value_get_pointer (value));
- g_signal_connect (G_OBJECT (priv->listener), "objects_added",
+ g_signal_connect (G_OBJECT (priv->listener), "objects_added",
G_CALLBACK (objects_added_cb), view);
- g_signal_connect (G_OBJECT (priv->listener), "objects_modified",
+ g_signal_connect (G_OBJECT (priv->listener), "objects_modified",
G_CALLBACK (objects_modified_cb), view);
- g_signal_connect (G_OBJECT (priv->listener), "objects_removed",
+ g_signal_connect (G_OBJECT (priv->listener), "objects_removed",
G_CALLBACK (objects_removed_cb), view);
- g_signal_connect (G_OBJECT (priv->listener), "view_progress",
+ g_signal_connect (G_OBJECT (priv->listener), "view_progress",
G_CALLBACK (view_progress_cb), view);
- g_signal_connect (G_OBJECT (priv->listener), "view_done",
+ g_signal_connect (G_OBJECT (priv->listener), "view_done",
G_CALLBACK (view_done_cb), view);
- break;
+ break;
case PROP_CLIENT:
priv->client = E_CAL (g_value_dup_object (value));
break;
{
ECalView *view;
ECalViewPrivate *priv;
-
+
view = E_CAL_VIEW (object);
priv = view->priv;
{
GObjectClass *object_class;
GParamSpec *param;
-
+
object_class = (GObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
param = g_param_spec_object ("client", "The e-cal for the view", NULL, E_TYPE_CAL,
G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_CLIENT, param);
-
+
signals[OBJECTS_ADDED] =
g_signal_new ("objects_added",
G_TYPE_FROM_CLASS (klass),
/**
* e_cal_view_get_type:
- *
+ *
* Registers the #ECalView class if necessary, and returns the type ID assigned
* to it.
- *
+ *
* Return value: The type ID of the #ECalView class.
**/
GType
* @corba_view: The CORBA object for the view.
* @listener: An #ECalViewListener.
* @client: An #ECal object.
- *
+ *
* Creates a new view object by issuing the view creation request to the
* calendar server.
- *
+ *
* Return value: A newly-created view object, or NULL if the request failed.
**/
ECalView *
{
ECalView *view;
- view = g_object_new (E_TYPE_CAL_VIEW, "view", corba_view, "listener",
+ view = g_object_new (E_TYPE_CAL_VIEW, "view", corba_view, "listener",
listener, "client", client, NULL);
return view;
g_return_if_fail (view != NULL);
g_return_if_fail (E_IS_CAL_VIEW (view));
-
+
priv = view->priv;
-
+
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_CalView_start (priv->view, &ev);
- if (BONOBO_EX (&ev))
+ if (BONOBO_EX (&ev))
g_warning (G_STRLOC ": Unable to start view");
CORBA_exception_free (&ev);
ESource *source;
char *uri;
ECalSourceType type;
-
+
ECalendarOp *current_op;
GMutex *mutex;
-
+
/* Email address associated with this calendar, or NULL */
char *cal_address;
char *alarm_email_address;
/* Scheduling info */
char *capabilities;
-
+
int mode;
-
+
gboolean read_only;
-
+
/* The calendar factories we are contacting */
GList *factories;
static GNOME_Evolution_Calendar_CalObjType
-convert_type (ECalSourceType type)
+convert_type (ECalSourceType type)
{
switch (type){
case E_CAL_SOURCE_TYPE_EVENT:
default:
return GNOME_Evolution_Calendar_TYPE_ANY;
}
-
+
return GNOME_Evolution_Calendar_TYPE_ANY;
}
g_warning (G_STRLOC ": Unexpected response");
return NULL;
}
-
+
return ecal->priv->current_op;
}
if (result)
return;
- bonobo_object_release_unref (priv->cal, NULL);
+ bonobo_object_release_unref (priv->cal, NULL);
priv->cal = CORBA_OBJECT_NIL;
}
op = e_calendar_get_op (ecal);
if (op == NULL || !op->bool) {
- ecal->priv->read_only = read_only;
+ ecal->priv->read_only = read_only;
return;
}
op->status = status;
op->uid = g_strdup (uid);
-
+
e_flag_set (op->done);
}
op->status = status;
op->string = g_strdup (object);
-
+
e_flag_set (op->done);
}
op->status = status;
op->string = g_strdup (object);
-
+
e_flag_set (op->done);
}
ECal *ecal = data;
ECalendarOp *op;
GList *l;
-
+
op = e_calendar_get_op (ecal);
if (op == NULL) {
op->status = status;
op->list = g_list_copy (objects);
-
+
for (l = op->list; l; l = l->next)
l->data = icalcomponent_new_clone (l->data);
-
+
e_flag_set (op->done);
}
{
ECal *ecal = data;
ECalendarOp *op;
-
+
op = e_calendar_get_op (ecal);
if (op == NULL) {
op->status = status;
op->slist = g_slist_copy (attachments);
-
+
e_flag_set (op->done);
}
ECal *ecal = data;
ECalendarOp *op;
GList *l;
-
+
op = e_calendar_get_op (ecal);
if (op == NULL) {
new_ccc = g_new (ECalChange, 1);
new_ccc->comp = e_cal_component_clone (ccc->comp);
new_ccc->type = ccc->type;
-
+
l->data = new_ccc;
}
-
+
e_flag_set (op->done);
}
ECal *ecal = data;
ECalendarOp *op;
GList *l;
-
+
op = e_calendar_get_op (ecal);
if (op == NULL) {
{
ECal *ecal = data;
ECalendarOp *op;
-
+
op = e_calendar_get_op (ecal);
if (op == NULL) {
op->status = status;
op->query = e_cal_view_new (query, op->listener, ecal);
-
+
e_flag_set (op->done);
}
-static gboolean
+static gboolean
reopen_with_auth (gpointer data)
{
ECalendarStatus status;
-
+
open_calendar (E_CAL (data), TRUE, NULL, &status, TRUE);
return FALSE;
}
static void
auth_required_cb (ECalListener *listener, gpointer data)
{
- g_idle_add (reopen_with_auth, data);
+ g_idle_add (reopen_with_auth, data);
}
switch (status) {
case GNOME_Evolution_Calendar_CalListener_MODE_SET:
ecal_status = E_CAL_SET_MODE_SUCCESS;
- break;
+ break;
case GNOME_Evolution_Calendar_CalListener_MODE_NOT_SET:
ecal_status = E_CAL_SET_MODE_ERROR;
break;
case GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED:
ecal_status = E_CAL_SET_MODE_NOT_SUPPORTED;
- break;
+ break;
default:
g_assert_not_reached ();
}
backend_error_idle_cb (gpointer data)
{
ECalErrorData *error_data = data;
-
+
g_signal_emit (G_OBJECT (error_data->ecal), e_cal_signals[BACKEND_ERROR], 0, error_data->message);
g_object_unref (error_data->ecal);
g_free (error_data->message);
g_free (error_data);
-
+
return FALSE;
}
backend_error_cb (ECalListener *listener, const char *message, gpointer data)
{
ECalErrorData *error_data;
-
+
error_data = g_new0 (ECalErrorData, 1);
error_data->ecal = g_object_ref (data);
\f
-static gboolean
+static gboolean
get_factories (const char *str_uri, GList **factories)
{
GNOME_Evolution_Calendar_CalFactory factory;
uri = e_uri_new (str_uri);
if (!uri) {
g_warning (G_STRLOC ": Invalid uri string");
-
+
return FALSE;
}
query = "repo_ids.has ('IDL:GNOME/Evolution/DataServer/CalFactory:" API_VERSION "')";
-
+
servers = bonobo_activation_query (query, NULL, NULL);
e_uri_free (uri);
if (!servers) {
g_warning (G_STRLOC ": Unable to query for calendar factories");
-
+
return FALSE;
- }
-
+ }
+
/* Try to activate the servers for the protocol */
for (i = 0; i < servers->_length; i++) {
const Bonobo_ServerInfo *info;
g_message (G_STRLOC ": Activating calendar factory (%s)", info->iid);
#endif
factory = bonobo_activation_activate_from_id (info->iid, 0, NULL, NULL);
-
+
if (factory == CORBA_OBJECT_NIL)
g_warning (G_STRLOC ": Could not activate calendar factory (%s)", info->iid);
else
g_mutex_free (priv->mutex);
priv->mutex = NULL;
}
-
+
if (priv->cal_address) {
g_free (priv->cal_address);
priv->cal_address = NULL;
gchar *source_xml;
gchar *str_uri;
gboolean result = FALSE;
-
+
priv = ecal->priv;
g_return_val_if_fail (priv->load_state == E_CAL_LOAD_NOT_LOADED, FALSE);
g_assert (priv->uri == NULL);
BONOBO_OBJREF (priv->listener), &ev);
if (BONOBO_EX (&ev))
continue;
-
+
priv->cal = cal;
result = TRUE;
{
static GStaticMutex e_cal_lock = G_STATIC_MUTEX_INIT;
static gboolean activated = FALSE;
-
+
g_static_mutex_lock (&e_cal_lock);
if (!activated) {
activated = TRUE;
-
+
if (!bonobo_is_initialized ())
bonobo_init (NULL, NULL);
}
".evolution/cache/calendar",
mangled_uri,
NULL);
- priv->local_attachment_store =
+ priv->local_attachment_store =
g_filename_to_uri (filename, NULL, NULL);
g_free (filename);
} else if (g_str_has_prefix (priv->uri, "exchange://")) {
".evolution/cache/calendar",
mangled_uri,
NULL);
- priv->local_attachment_store =
+ priv->local_attachment_store =
g_filename_to_uri (filename, NULL, NULL);
g_free (filename);
}
e_cal_new (ESource *source, ECalSourceType type)
{
ECal *ecal;
-
+
e_cal_activate ();
-
+
ecal = g_object_new (E_TYPE_CAL, NULL);
if (!fetch_corba_cal (ecal, source, type)) {
g_free (filename);
ecal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_EVENT);
g_free (uri);
-
+
return ecal;
}
g_free (filename);
ecal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_TODO);
g_free (uri);
-
+
return ecal;
}
g_free (filename);
ecal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL);
g_free (uri);
-
+
return ecal;
}
ECalendarOp *our_op;
char *username = NULL, *auth_type = NULL, *password = NULL;
gboolean read_only = FALSE;
-
+
e_return_error_if_fail (ecal != NULL, E_CALENDAR_STATUS_INVALID_ARG);
e_return_error_if_fail (E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
priv = ecal->priv;
-
+
g_mutex_lock (ecal->priv->mutex);
if (!needs_auth && priv->load_state == E_CAL_LOAD_LOADED) {
g_mutex_unlock (ecal->priv->mutex);
return TRUE;
}
-
+
if (ecal->priv->current_op != NULL) {
g_mutex_unlock (ecal->priv->mutex);
*status = E_CALENDAR_STATUS_BUSY;
e_source_peek_name (priv->source), username);
auth_type = e_source_get_duped_property (priv->source, "auth-type");
- if (auth_type)
+ if (auth_type)
key = build_pass_key (ecal);
else {
parent_user = e_source_get_duped_property (priv->source, "parent_id_name");
if (parent_user) {
key = build_proxy_pass_key (ecal, parent_user);
- /*
- This password prompt will be prompted rarely. Since the key that is passed to
+ /*
+ This password prompt will be prompted rarely. Since the key that is passed to
the auth_func corresponds to the parent user.
*/
prompt = g_strdup_printf (_("Enter password for %s to enable proxy for user %s"), e_source_peek_name (priv->source), parent_user);
g_free (parent_user);
- } else
+ } else
key = g_strdup (e_cal_get_uri (ecal));
}
g_free (auth_type);
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
priv->load_state = E_CAL_LOAD_NOT_LOADED;
- *status = E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED;
+ *status = E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED;
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED, error);
- }
+ }
g_free (prompt);
g_free (key);
if (BONOBO_EX (&ev)) {
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
-
+
CORBA_exception_free (&ev);
g_warning (G_STRLOC ": Unable to contact backend");
e_flag_wait (our_op->done);
*status = our_op->status;
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
if (*status == E_CALENDAR_STATUS_OK) {
/* free memory */
g_object_unref (ccad->ecal);
g_free (ccad);
-
+
return FALSE;
}
static gpointer
-open_async (gpointer data)
+open_async (gpointer data)
{
ECalAsyncData *ccad = data;
ccad->result = open_calendar (ccad->ecal, ccad->exists, NULL, &ccad->status, FALSE);
g_idle_add ((GSourceFunc) async_signal_idle_cb, ccad);
-
+
return GINT_TO_POINTER (ccad->result);
}
* @only_if_exists: If TRUE, then only open the calendar if it already
* exists. If FALSE, then create a new calendar if it doesn't already
* exist.
- *
+ *
* Open the calendar asynchronously. The calendar will emit the
* "cal_opened" signal when the operation has completed.
- *
+ *
* Because this operation runs in another thread, any authentication
* callback set on the calendar will be called from this other thread.
* See #e_cal_set_auth_func() for details.
*
* Return value: TRUE if the calendar was removed, FALSE if there was an error.
*/
-gboolean
+gboolean
e_cal_remove (ECal *ecal, GError **error)
{
ECalPrivate *priv;
CORBA_Environment ev;
ECalendarStatus status;
ECalendarOp *our_op;
-
+
g_return_val_if_fail (ecal != NULL, FALSE);
g_return_val_if_fail (E_IS_CAL (ecal), FALSE);
priv = ecal->priv;
-
+
g_mutex_lock (ecal->priv->mutex);
if (ecal->priv->current_op != NULL) {
e_flag_wait (our_op->done);
status = our_op->status;
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
#if 0
ECalPrivate *priv;
GNOME_Evolution_Calendar_StringSeq *uri_seq;
- GList *uris = NULL;
+ GList *uris = NULL;
CORBA_Environment ev;
GList *f;
uris = g_list_concat (uris, build_uri_list (uri_seq));
CORBA_free (uri_seq);
}
-
+
CORBA_exception_free (&ev);
}
-
- return uris;
+
+ return uris;
#endif
return NULL;
/**
* e_cal_get_load_state:
* @ecal: A calendar client.
- *
+ *
* Queries the state of loading of a calendar client.
- *
+ *
* Return value: A #ECalLoadState value indicating whether the client has
* not been loaded with #e_cal_open yet, whether it is being
* loaded, or whether it is already loaded.
/**
* e_cal_get_source:
* @ecal: A calendar client.
- *
+ *
* Queries the source that is open in a calendar client.
- *
+ *
* Return value: The source of the calendar that is already loaded or is being
* loaded, or NULL if the ecal has not started a load request yet.
**/
/**
* e_cal_get_uri:
* @ecal: A calendar client.
- *
+ *
* Queries the URI that is open in a calendar client.
- *
+ *
* Return value: The URI of the calendar that is already loaded or is being
* loaded, or NULL if the client has not started a load request yet.
**/
/**
* e_cal_get_local_attachment_store
* @ecal: A calendar client.
- *
+ *
* Queries the URL where the calendar attachments are
* serialized in the local filesystem. This enable clients
* to operate with the reference to attachments rather than the data itself
e_cal_is_read_only (ECal *ecal, gboolean *read_only, GError **error)
{
ECalPrivate *priv;
-
+
if (!(ecal && E_IS_CAL (ecal)))
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
-
+
priv = ecal->priv;
*read_only = priv->read_only;
-
+
return TRUE;
}
CORBA_Environment ev;
ECalendarStatus status;
ECalendarOp *our_op;
-
+
priv = ecal->priv;
g_mutex_lock (ecal->priv->mutex);
/* set it to true so that op does not emit cond signals for all notifications
from the backend */
our_op->bool = TRUE;
-
+
g_mutex_unlock (ecal->priv->mutex);
e_flag_wait (our_op->done);
status = our_op->status;
-
+
if (status == E_CALENDAR_STATUS_OK)
*read_only = our_op->bool;
* @error: Placeholder for error information.
*
* Queries the calendar address associated with a calendar client.
- *
+ *
* Return value: TRUE if the operation was successful, FALSE if there
* was an error.
**/
if (!(ecal && E_IS_CAL (ecal)))
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
priv = ecal->priv;
- if (priv->cal_address == NULL) {
+ if (priv->cal_address == NULL) {
g_mutex_lock (ecal->priv->mutex);
if (ecal->priv->load_state != E_CAL_LOAD_LOADED) {
e_calendar_free_op (our_op);
E_CALENDAR_CHECK_STATUS (status, error);
- } else {
+ } else {
*cal_address = g_strdup (priv->cal_address);
return TRUE;
- }
+ }
}
/**
ECalendarStatus status;
ECalendarOp *our_op;
- e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
priv = ecal->priv;
status = our_op->status;
*alarm_address = our_op->string;
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
ECalendarStatus status;
ECalendarOp *our_op;
- e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
priv = ecal->priv;
status = our_op->status;
*ldap_attribute = our_op->string;
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
}
static gboolean
-load_static_capabilities (ECal *ecal, GError **error)
+load_static_capabilities (ECal *ecal, GError **error)
{
ECalPrivate *priv;
CORBA_Environment ev;
ECalendarStatus status;
ECalendarOp *our_op;
-
+
priv = ecal->priv;
if (priv->capabilities)
status = our_op->status;
priv->capabilities = our_op->string;
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
}
static gboolean
-check_capability (ECal *ecal, const char *cap)
+check_capability (ECal *ecal, const char *cap)
{
ECalPrivate *priv;
load_static_capabilities (ecal, NULL);
if (priv->capabilities && strstr (priv->capabilities, cap))
return TRUE;
-
+
return FALSE;
}
* Return value: TRUE if the calendar forces organizers to attend meetings,
* FALSE otherwise.
*/
-gboolean
+gboolean
e_cal_get_organizer_must_attend (ECal *ecal)
{
g_return_val_if_fail (ecal != NULL, FALSE);
* Return value: TRUE if the calendar has a master object for recurrences,
* FALSE otherwise.
*/
-gboolean
+gboolean
e_cal_get_recurrences_no_master (ECal *ecal)
{
g_return_val_if_fail (ecal != NULL, FALSE);
*
* Return value: TRUE if it saves schedules, FALSE otherwise.
*/
-gboolean
+gboolean
e_cal_get_save_schedules (ECal *ecal)
{
g_return_val_if_fail (ecal != NULL, FALSE);
* Return value: TRUE if the calendar requires organizers to accept, FALSE
* otherwise.
*/
-gboolean
+gboolean
e_cal_get_organizer_must_accept (ECal *ecal)
{
g_return_val_if_fail (ecal != NULL, FALSE);
e_cal_set_mode (ECal *ecal, CalMode mode)
{
ECalPrivate *priv;
- gboolean retval = TRUE;
+ gboolean retval = TRUE;
CORBA_Environment ev;
g_return_val_if_fail (ecal != NULL, -1);
if (BONOBO_EX (&ev))
retval = FALSE;
-
+
CORBA_exception_free (&ev);
return retval;
ECalendarStatus status;
ECalendarOp *our_op;
- e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
priv = ecal->priv;
ECalendarStatus status;
ECalendarOp *our_op;
- e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
priv = ecal->priv;
e_flag_wait (our_op->done);
status = our_op->status;
- if (status != E_CALENDAR_STATUS_OK){
+ if (status != E_CALENDAR_STATUS_OK){
*list = NULL;
} else {
*list = our_op->slist;
ECalendarStatus status;
ECalendarOp *our_op;
- e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
priv = ecal->priv;
e_flag_wait (our_op->done);
status = our_op->status;
- if (status != E_CALENDAR_STATUS_OK){
+ if (status != E_CALENDAR_STATUS_OK){
*icalcomp = NULL;
} else {
icalcomponent *tmp_icalcomp;
e_flag_wait (our_op->done);
status = our_op->status;
- if (status != E_CALENDAR_STATUS_OK){
+ if (status != E_CALENDAR_STATUS_OK){
*objects = NULL;
} else {
icalcomponent *icalcomp;
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (E_IS_CAL (data), NULL);
-
+
ecal = E_CAL (data);
/* FIXME: Handle errors. */
ECalendarOp *our_op;
ECalendarStatus status;
- e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
e_return_error_if_fail (change_id, E_CALENDAR_STATUS_INVALID_ARG);
g_mutex_lock (ecal->priv->mutex);
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
}
-
+
CORBA_exception_free (&ev);
e_flag_wait (our_op->done);
* @query: Query string.
* @objects: Return value for list of objects.
* @error: Placeholder for error information.
- *
+ *
* Gets a list of objects from the calendar that match the query specified
* by the @query argument. The objects will be returned in the @objects
* argument, which is a list of #icalcomponent. When done, this list
* should be freed by using the #e_cal_free_object_list function.
- *
+ *
* Return value: TRUE if the operation was successful, FALSE otherwise.
**/
gboolean
ECalendarStatus status;
- e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
e_return_error_if_fail (query, E_CALENDAR_STATUS_INVALID_ARG);
g_mutex_lock (ecal->priv->mutex);
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
}
-
+
CORBA_exception_free (&ev);
e_flag_wait (our_op->done);
* @query: Query string.
* @objects: Return value for list of objects.
* @error: Placeholder for error information.
- *
+ *
* Gets a list of objects from the calendar that match the query specified
* by the @query argument. The objects will be returned in the @objects
* argument, which is a list of #ECalComponent.
- *
+ *
* Return value: TRUE if the operation was successful, FALSE otherwise.
*/
gboolean
GList *ical_objects = NULL;
GList *l;
- e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
- e_return_error_if_fail (query, E_CALENDAR_STATUS_INVALID_ARG);
- e_return_error_if_fail (objects, E_CALENDAR_STATUS_INVALID_ARG);
-
+ e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (query, E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (objects, E_CALENDAR_STATUS_INVALID_ARG);
+
if (!e_cal_get_object_list (ecal, query, &ical_objects, error))
return FALSE;
-
+
*objects = NULL;
for (l = ical_objects; l; l = l->next) {
ECalComponent *comp;
-
+
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, l->data);
*objects = g_list_prepend (*objects, comp);
}
-
+
g_list_free (ical_objects);
return TRUE;
*
* Frees a list of objects as returned by #e_cal_get_object_list.
*/
-void
+void
e_cal_free_object_list (GList *objects)
{
GList *l;
-
+
for (l = objects; l; l = l->next)
icalcomponent_free (l->data);
GNOME_Evolution_Calendar_Cal_getFreeBusy (ecal->priv->cal, &corba_users, start, end, &ev);
CORBA_free (corba_users._buffer);
-
+
if (BONOBO_EX (&ev)) {
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
}
-
+
CORBA_exception_free (&ev);
e_flag_wait (our_op->done);
icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp));
e_cal_component_get_dtstart (comp, &datetime);
-
+
/* add the instance to the list */
ci->comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (ci->comp, icalcomp);
if (!(icalcomponent_get_first_property (icalcomp, ICAL_RECURRENCEID_PROPERTY))) {
ECalComponentRange *range;
- if (instances_hold->start_zone)
+ if (instances_hold->start_zone)
itt = icaltime_from_timet_with_zone (start, datetime.value->is_date, instances_hold->start_zone);
else {
itt = icaltime_from_timet (start, datetime.value->is_date);
e_cal_component_get_dtstart (comp, &dtstart);
e_cal_component_get_dtend (comp, &dtend);
- /* For DATE-TIME values with a TZID, we use
- e_cal_resolve_tzid_cb to resolve the TZID.
+ /* For DATE-TIME values with a TZID, we use
+ e_cal_resolve_tzid_cb to resolve the TZID.
For DATE values and DATE-TIME values without a
- TZID (i.e. floating times) we use the default
+ TZID (i.e. floating times) we use the default
timezone. */
if (dtstart.tzid && !dtstart.value->is_date) {
start_zone = e_cal_resolve_tzid_cb (dtstart.tzid, ecal);
ci->end = icaltime_as_timet_with_zone (*dtend.value, end_zone);
else if (icaltime_is_date (*dtstart.value))
ci->end = time_day_end (ci->start);
- else
+ else
ci->end = ci->start;
e_cal_component_free_datetime (&dtstart);
e_cal_component_free_datetime (&dtend);
-
+
detached_instances = g_list_prepend (detached_instances, ci);
} else {
ECalComponentDateTime datetime;
icaltimezone *start_zone;
struct instances_info *instances_hold;
-
+
/* Get the start timezone */
e_cal_component_get_dtstart (comp, &datetime);
e_cal_get_timezone (ecal, datetime.tzid, &start_zone, NULL);
e_cal_recur_generate_instances (comp, start, end, add_instance, instances_hold,
e_cal_resolve_tzid_cb, ecal,
default_zone);
-
+
g_free (instances_hold);
g_object_unref (comp);
}
for (l = instances; l; l = l->next) {
struct comp_instance *ci;
gboolean result;
-
+
ci = l->data;
-
+
result = (* cb) (ci->comp, ci->start, ci->end, cb_data);
if (!result)
* @end: End time for query.
* @cb: Callback for each generated instance.
* @cb_data: Closure data for the callback.
- *
+ *
* Does a combination of #e_cal_get_object_list () and
- * #e_cal_recur_generate_instances().
+ * #e_cal_recur_generate_instances().
*
* The callback function should do a g_object_ref() of the calendar component
* it gets passed if it intends to keep it around, since it will be unref'ed
ECalRecurInstanceFn cb, gpointer cb_data)
{
ECalPrivate *priv;
-
+
g_return_if_fail (ecal != NULL);
g_return_if_fail (E_IS_CAL (ecal));
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
- /*If the backend stores it as individual instances and does not
+ /*If the backend stores it as individual instances and does not
* have a master object - do not expand*/
if (e_cal_get_static_capability (ecal, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) {
g_object_unref (comp);
return;
}
-
+
e_cal_component_get_uid (comp, &uid);
/* string might be freed at any time, keep a copy */
rid = g_strdup (e_cal_component_get_recurid_as_string (comp));
instances_hold = g_new0 (struct instances_info, 1);
instances_hold->instances = &instances;
instances_hold->start_zone = start_zone;
-
+
/* generate all instances in the given time range */
generate_instances (ecal, start, end, uid, add_instance, instances_hold);
/**
* e_cal_free_alarms:
* @comp_alarms: A list of #ECalComponentAlarms structures.
- *
+ *
* Frees a list of #ECalComponentAlarms structures as returned by
* e_cal_get_alarms_in_range().
**/
ECalendarStatus status;
ECalendarOp *our_op;
const char *uid;
-
+
g_return_val_if_fail (ecal != NULL, FALSE);
g_return_val_if_fail (E_IS_CAL (ecal), FALSE);
e_flag_wait (our_op->done);
status = our_op->status;
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
*uid = our_op->uid;
icalcomponent_set_uid (icalcomp, *uid);
}
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
e_flag_wait (our_op->done);
status = our_op->status;
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
e_flag_wait (our_op->done);
status = our_op->status;
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
* @ecal: A calendar client.
* @uid: Unique identifier of the calendar component to remove.
* @error: Placeholder for error information.
- *
+ *
* Asks a calendar to remove a component. If the server is able to remove the
* component, all clients will be notified and they will emit the "obj_removed"
* signal.
- *
+ *
* Return value: %TRUE if successful, %FALSE otherwise.
**/
gboolean
e_flag_wait (our_op->done);
status = our_op->status;
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
g_list_foreach (*users, (GFunc) g_free, NULL);
g_list_free (*users);
*users = NULL;
- }
+ }
}
g_free (our_op->string);
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
/* Check for well known zones and in the cache */
*zone = NULL;
-
+
/* If tzid is NULL or "" we return NULL, since it is a 'local time'. */
if (!tzid || !tzid[0]) {
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
*zone = NULL;
-
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error);
+
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error);
}
/* If it is UTC, we return the special UTC timezone. */
/* See if we already have it in the cache. */
*zone = g_hash_table_lookup (priv->timezones, tzid);
}
-
+
if (*zone) {
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
- E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error);
}
-
+
/* call the backend */
CORBA_exception_init (&ev);
e_flag_wait (our_op->done);
status = our_op->status;
- if (status != E_CALENDAR_STATUS_OK){
+ if (status != E_CALENDAR_STATUS_OK){
icalcomp = NULL;
} else {
icalcomp = icalparser_parse_string (our_op->string);
status = E_CALENDAR_STATUS_INVALID_OBJECT;
}
g_free (our_op->string);
-
+
if (!icalcomp) {
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
E_CALENDAR_CHECK_STATUS (status, error);
}
-
- *zone = icaltimezone_new ();
+
+ *zone = icaltimezone_new ();
if (!icaltimezone_set_component (*zone, icalcomp)) {
icaltimezone_free (*zone, 1);
e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
e_return_error_if_fail (izone, E_CALENDAR_STATUS_INVALID_ARG);
-
+
priv = ecal->priv;
g_mutex_lock (priv->mutex);
if (izone == icaltimezone_get_utc_timezone ()) {
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
-
+
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error);
}
-
+
icalcomp = icaltimezone_get_component (izone);
if (!icalcomp) {
e_calendar_remove_op (ecal, our_op);
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
}
- /* convert icaltimezone into a string */
+ /* convert icaltimezone into a string */
tzobj = icalcomponent_as_ical_string (icalcomp);
/* call the backend */
e_flag_wait (our_op->done);
status = our_op->status;
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
* @sexp: S-expression representing the query.
* @query: Return value for the new query.
* @error: Placeholder for error information.
- *
+ *
* Creates a live query object from a loaded calendar.
- *
+ *
* Return value: A query object that will emit notification signals as calendar
* components are added and removed from the query in the server.
**/
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
}
-
+
CORBA_exception_free (&ev);
e_flag_wait (our_op->done);
*query = our_op->query;
bonobo_object_unref (BONOBO_OBJECT (our_op->listener));
-
+
e_calendar_remove_op (ecal, our_op);
e_calendar_free_op (our_op);
icalcomponent *icalcomp = NULL;
char *tzobj;
- e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
- e_return_error_if_fail (zone, E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (zone, E_CALENDAR_STATUS_INVALID_ARG);
priv = ecal->priv;
/* Don't set the same timezone multiple times */
if (priv->default_zone == zone)
return FALSE;
-
+
g_mutex_lock (priv->mutex);
if (ecal->priv->current_op != NULL) {
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
}
- /* convert icaltimezone into a string */
+ /* convert icaltimezone into a string */
tzobj = icalcomponent_as_ical_string (icalcomp);
/* call the backend */
if (default_source) {
*ecal = e_cal_new (default_source, type);
- if (!*ecal) {
+ if (!*ecal) {
g_propagate_error (error, err);
rv = FALSE;
goto done;
if (!e_cal_open (*ecal, TRUE, &err)) {
g_propagate_error (error, err);
rv = FALSE;
- goto done;
+ goto done;
}
} else {
switch (type) {
default:
break;
}
-
- if (!*ecal) {
+
+ if (!*ecal) {
g_propagate_error (error, err);
rv = FALSE;
goto done;
if (!e_cal_open (*ecal, TRUE, &err)) {
g_propagate_error (error, err);
rv = FALSE;
- goto done;
+ goto done;
}
}
{
ESource *source;
- e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
+ e_return_error_if_fail (ecal && E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
source = e_cal_get_source (ecal);
if (!source) {
{
switch (type) {
case E_CAL_SOURCE_TYPE_EVENT:
- return get_sources (sources, "/apps/evolution/calendar/sources", error);
+ return get_sources (sources, "/apps/evolution/calendar/sources", error);
break;
case E_CAL_SOURCE_TYPE_TODO:
return get_sources (sources, "/apps/evolution/tasks/sources", error);
/* FIXME Fill in error */
return FALSE;
}
-
+
/* FIXME Fill in error */
- return FALSE;
+ return FALSE;
}
/* Notification signals */
void (* cal_opened) (ECal *ecal, ECalendarStatus status);
- void (* cal_set_mode) (ECal *ecal, ECalSetModeStatus status, CalMode mode);
+ void (* cal_set_mode) (ECal *ecal, ECalSetModeStatus status, CalMode mode);
void (* backend_error) (ECal *ecal, const char *message);
void (* backend_died) (ECal *ecal);
gboolean e_cal_get_object_list_as_comp (ECal *ecal, const char *query, GList **objects, GError **error);
void e_cal_free_object_list (GList *objects);
-gboolean e_cal_get_free_busy (ECal *ecal, GList *users, time_t start, time_t end,
+gboolean e_cal_get_free_busy (ECal *ecal, GList *users, time_t start, time_t end,
GList **freebusy, GError **error);
void e_cal_generate_instances (ECal *ecal, time_t start, time_t end,
case E_CAL_SOURCE_TYPE_LAST :
default :
break;
- }
+ }
/* mangle the URI to not contain invalid characters */
mangled_uri = g_strdup (uri);
switch (property_id) {
case PROP_SOURCE_TYPE:
- g_value_set_enum (value, priv->source_type);
+ g_value_set_enum (value, priv->source_type);
case PROP_URI :
g_value_set_string (value, priv->uri);
break;
n_construct_properties,
construct_properties);
- if (!g_ascii_strcasecmp ( g_param_spec_get_name (construct_properties->pspec), "source_type"))
+ if (!g_ascii_strcasecmp ( g_param_spec_get_name (construct_properties->pspec), "source_type"))
source_type = g_value_get_enum (construct_properties->value);
/* extract uid */
if (!g_ascii_strcasecmp ( g_param_spec_get_name (construct_properties->pspec), "uri")) {
object_class->constructor = e_cal_backend_cache_constructor;
g_object_class_install_property (object_class, PROP_SOURCE_TYPE,
- g_param_spec_enum ("source_type", NULL, NULL,
+ g_param_spec_enum ("source_type", NULL, NULL,
e_cal_source_type_enum_get_type (),
- E_CAL_SOURCE_TYPE_EVENT,
+ E_CAL_SOURCE_TYPE_EVENT,
G_PARAM_READABLE | G_PARAM_WRITABLE
| G_PARAM_CONSTRUCT_ONLY));
e_cal_backend_cache_get_type (void)
{
static GType type = 0;
- static GStaticMutex registering = G_STATIC_MUTEX_INIT;
+ static GStaticMutex registering = G_STATIC_MUTEX_INIT;
g_static_mutex_lock (®istering);
if (!type) {
e_cal_backend_cache_new (const char *uri, ECalSourceType source_type)
{
ECalBackendCache *cache;
-
+
cache = g_object_new (E_TYPE_CAL_BACKEND_CACHE, "source_type", source_type, "uri", uri, NULL);
return cache;
GList *list = NULL;
icalcomponent *icalcomp;
ECalComponent *comp = NULL;
-
+
/* return null if cache is not a valid Backend Cache. */
g_return_val_if_fail (E_IS_CAL_BACKEND_CACHE (cache), NULL);
l = e_file_cache_get_objects (E_FILE_CACHE (cache));
icalcomponent_free (icalcomp);
}
}
-
+
}
return list;
GSList *list = NULL;
icalcomponent *icalcomp;
ECalComponent *comp = NULL;
-
+
/* return null if cache is not a valid Backend Cache. */
g_return_val_if_fail (E_IS_CAL_BACKEND_CACHE (cache), NULL);
l = e_file_cache_get_objects (E_FILE_CACHE (cache));
if (kind == ICAL_VEVENT_COMPONENT || kind == ICAL_VTODO_COMPONENT) {
comp = e_cal_component_new ();
if ((e_cal_component_set_icalcomponent (comp, icalcomp)) &&
- !strcmp (icalcomponent_get_uid (icalcomp), uid))
+ !strcmp (icalcomponent_get_uid (icalcomp), uid))
list = g_slist_prepend (list, comp);
else {
g_object_unref (comp);
icalcomponent_free (icalcomp);
}
}
-
+
}
return list;
e_cal_backend_cache_put_server_utc_time (ECalBackendCache *cache, const char *utc_str)
{
gboolean ret_val = FALSE;
-
+
g_return_val_if_fail (E_IS_CAL_BACKEND_CACHE (cache), FALSE);
if (!(ret_val = e_file_cache_add_object (E_FILE_CACHE (cache), "server_utc_time", utc_str)))
{
g_return_val_if_fail (E_IS_CAL_BACKEND_CACHE (cache), NULL);
-
+
return e_file_cache_get_object (E_FILE_CACHE (cache), "server_utc_time");
}
e_cal_backend_cache_put_key_value (ECalBackendCache *cache, const char *key, const char *value)
{
gboolean ret_val = FALSE;
-
+
g_return_val_if_fail (E_IS_CAL_BACKEND_CACHE (cache), FALSE);
if (value) {
e_file_cache_remove_object (E_FILE_CACHE (cache), key);
return TRUE;
}
-
+
if (!(ret_val = e_file_cache_add_object (E_FILE_CACHE (cache), key, value)))
ret_val = e_file_cache_replace_object (E_FILE_CACHE (cache), key, value);
{
g_return_val_if_fail (E_IS_CAL_BACKEND_CACHE (cache), NULL);
-
+
return e_file_cache_get_object (E_FILE_CACHE (cache), key);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* cal-backend-card-sexp.c
* Copyright 1999, 2000, 2001, Ximian, Inc.
*
return NULL;
}
n = argv[1]->value.number;
-
+
result = e_sexp_result_new (esexp, ESEXP_RES_TIME);
result->value.time = time_add_day (t, n);
return NULL;
}
- arg_uid = argv[0]->value.string;
+ arg_uid = argv[0]->value.string;
e_cal_component_get_uid (ctx->comp, &uid);
if (!arg_uid && !uid)
equal = TRUE;
else
equal = FALSE;
-
+
result = e_sexp_result_new (esexp, ESEXP_RES_BOOL);
result->value.bool = equal;
resolve_tzid (const char *tzid, gpointer user_data)
{
SearchContext *ctx = user_data;
-
+
if (!tzid || !tzid[0])
return NULL;
else if (!strcmp (tzid, "UTC"))
return icaltimezone_get_utc_timezone ();
-
+
return e_cal_backend_internal_get_timezone (ctx->backend, tzid);
}
due_t = icaltime_as_timet_with_zone(*dt.value,zone);
else
due_t = icaltime_as_timet(*dt.value);
- }
+ }
if(dt.value != NULL && (due_t <= end && due_t >= start))
retval = TRUE;
- else
- retval = FALSE;
+ else
+ retval = FALSE;
result = e_sexp_result_new (esexp, ESEXP_RES_BOOL);
result->value.bool = retval;
e_cal_component_free_datetime (&dt);
-
+
return result;
}
if (str && !*str)
return TRUE;
- if ((org.value && e_util_strstrcase (org.value, str)) ||
+ if ((org.value && e_util_strstrcase (org.value, str)) ||
(org.cn && e_util_strstrcase (org.cn, str)))
return TRUE;
if (!*str)
return FALSE;
-
+
if(g_str_equal (str, "Public"))
classification1 = E_CAL_COMPONENT_CLASS_PUBLIC;
else if(g_str_equal (str, "Private"))
classification1 = E_CAL_COMPONENT_CLASS_PRIVATE;
else if(g_str_equal (str, "Confidential"))
classification1 = E_CAL_COMPONENT_CLASS_CONFIDENTIAL;
- else
+ else
classification1 = E_CAL_COMPONENT_CLASS_UNKNOWN;
e_cal_component_get_classification(comp, &classification);
if (!priority || !*priority)
return FALSE;
- if (g_str_equal (pr, "HIGH") && *priority <= 4)
+ if (g_str_equal (pr, "HIGH") && *priority <= 4)
return TRUE;
else if (g_str_equal (pr, "NORMAL") && *priority == 5)
return TRUE;
if (g_str_equal (str, "NOT STARTED") && status == ICAL_STATUS_NONE)
return TRUE;
- else if (g_str_equal (str, "COMPLETED") && status == ICAL_STATUS_COMPLETED)
+ else if (g_str_equal (str, "COMPLETED") && status == ICAL_STATUS_COMPLETED)
return TRUE;
- else if(g_str_equal (str, "CANCELLED") && status == ICAL_STATUS_CANCELLED)
+ else if(g_str_equal (str, "CANCELLED") && status == ICAL_STATUS_CANCELLED)
return TRUE;
else if(g_str_equal (str, "IN PROGRESS") && status == ICAL_STATUS_INPROCESS)
return TRUE;
e_cal_component_get_percent (ctx->comp, &percent);
- if (percent && *percent) {
+ if (percent && *percent) {
result = e_sexp_result_new (esexp, ESEXP_RES_INT);
result->value.number = *percent;
- }
+ }
return result;
}
if (any_field
|| !strcmp (prop_info_table[i].query_prop, propname)) {
info = &prop_info_table[i];
-
+
if (info->prop_type == PROP_TYPE_NORMAL) {
char *prop = NULL;
/* searches where the query's property
maps directly to an ecard property */
-
+
prop = e_card_simple_get (ctx->card, info->field_id);
if (prop && compare(prop, argv[1]->value.string)) {
const char *prop = NULL;
/* searches where the query's property
maps directly to an ecard property */
-
+
prop = e_card_get_id (ctx->card->card);
if (prop && compare(prop, argv[1]->value.string)) {
break;
}
}
-
+
}
r = e_sexp_result_new(f, ESEXP_RES_BOOL);
r->value.bool = truth;
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomp);
-
+
retval = e_cal_backend_sexp_match_comp (sexp, comp, backend);
g_object_unref (comp);
e_cal_backend_sexp_text (ECalBackendSExp *sexp)
{
ECalBackendSExpPrivate *priv;
-
+
g_return_val_if_fail (sexp != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND_SEXP (sexp), NULL);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* cal-backend-card-sexp.h
* Copyright 2000, 2001, Ximian, Inc.
*
const char *username, const char *password)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
LOCK_WRAPPER (open_sync, (backend, cal, only_if_exists, username, password));
e_cal_backend_sync_remove (ECalBackendSync *backend, EDataCal *cal)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
-
+
LOCK_WRAPPER (remove_sync, (backend, cal));
-
+
return status;
}
e_cal_backend_sync_create_object (ECalBackendSync *backend, EDataCal *cal, char **calobj, char **uid)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->create_object_sync != NULL,
GNOME_Evolution_Calendar_UnsupportedMethod);
-
+
LOCK_WRAPPER (create_object_sync, (backend, cal, calobj, uid));
-
+
return status;
}
* Return value: Status code.
*/
ECalBackendSyncStatus
-e_cal_backend_sync_modify_object (ECalBackendSync *backend, EDataCal *cal, const char *calobj,
+e_cal_backend_sync_modify_object (ECalBackendSync *backend, EDataCal *cal, const char *calobj,
CalObjModType mod, char **old_object, char **new_object)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->modify_object_sync != NULL,
GNOME_Evolution_Calendar_UnsupportedMethod);
-
+
LOCK_WRAPPER (modify_object_sync, (backend, cal, calobj, mod, old_object, new_object));
-
+
return status;
}
CalObjModType mod, char **old_object, char **object)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_object_sync != NULL,
GNOME_Evolution_Calendar_UnsupportedMethod);
-
+
LOCK_WRAPPER (remove_object_sync, (backend, cal, uid, rid, mod, old_object, object));
-
+
return status;
}
e_cal_backend_sync_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *auid)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->discard_alarm_sync != NULL,
GNOME_Evolution_Calendar_UnsupportedMethod);
-
+
LOCK_WRAPPER (discard_alarm_sync, (backend, cal, uid, auid));
-
+
return status;
}
e_cal_backend_sync_receive_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->receive_objects_sync != NULL,
GNOME_Evolution_Calendar_UnsupportedMethod);
-
+
LOCK_WRAPPER (receive_objects_sync, (backend, cal, calobj));
-
+
return status;
}
char **modified_calobj)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->send_objects_sync != NULL,
GNOME_Evolution_Calendar_UnsupportedMethod);
-
+
LOCK_WRAPPER (send_objects_sync, (backend, cal, calobj, users, modified_calobj));
-
+
return status;
}
e_cal_backend_sync_get_default_object (ECalBackendSync *backend, EDataCal *cal, char **object)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
g_return_val_if_fail (object, GNOME_Evolution_Calendar_OtherError);
-
+
LOCK_WRAPPER (get_default_object_sync, (backend, cal, object));
-
+
return status;
}
e_cal_backend_sync_get_object (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, char **object)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
g_return_val_if_fail (object, GNOME_Evolution_Calendar_OtherError);
-
+
LOCK_WRAPPER (get_object_sync, (backend, cal, uid, rid, object));
-
+
return status;
}
e_cal_backend_sync_get_object_list (ECalBackendSync *backend, EDataCal *cal, const char *sexp, GList **objects)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
g_return_val_if_fail (objects, GNOME_Evolution_Calendar_OtherError);
-
+
LOCK_WRAPPER (get_object_list_sync, (backend, cal, sexp, objects));
-
+
return status;
}
e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, GSList **attachments)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
g_return_val_if_fail (attachments, GNOME_Evolution_Calendar_OtherError);
-
+
LOCK_WRAPPER (get_attachment_list_sync, (backend, cal, uid, rid, attachments));
-
+
return status;
}
e_cal_backend_sync_get_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid, char **object)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
-
+
LOCK_WRAPPER (get_timezone_sync, (backend, cal, tzid, object));
-
+
return status;
}
e_cal_backend_sync_add_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzobj)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
-
+
LOCK_WRAPPER (add_timezone_sync, (backend, cal, tzobj));
-
+
return status;
}
e_cal_backend_sync_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const char *tz)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
-
+
/* Old backends might be using the set_default_timezone */
if (!E_CAL_BACKEND_SYNC_GET_CLASS (backend)->set_default_zone_sync) {
icalcomponent *icalcomp = icalparser_parse_string (tz);
}
LOCK_WRAPPER (set_default_zone_sync, (backend, cal, tz));
-
+
return status;
}
e_cal_backend_sync_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid)
{
ECalBackendSyncStatus status;
-
+
g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
-
+
LOCK_WRAPPER (set_default_timezone_sync, (backend, cal, tzid));
-
+
return status;
}
* Return value: Status code.
*/
ECalBackendSyncStatus
-e_cal_backend_sync_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users,
+e_cal_backend_sync_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users,
time_t start, time_t end, GList **freebusy)
{
ECalBackendSyncStatus status;
{
ECalBackendSyncStatus status;
char *uid = NULL, *modified_calobj = (char *) calobj;
-
+
status = e_cal_backend_sync_create_object (E_CAL_BACKEND_SYNC (backend), cal, &modified_calobj, &uid);
e_data_cal_notify_object_created (cal, status, uid, modified_calobj);
ECalBackendSyncStatus status;
char *old_object = NULL;
char *new_object = NULL;
-
- status = e_cal_backend_sync_modify_object (E_CAL_BACKEND_SYNC (backend), cal,
+
+ status = e_cal_backend_sync_modify_object (E_CAL_BACKEND_SYNC (backend), cal,
calobj, mod, &old_object, &new_object);
if (new_object)
{
ECalBackendSyncStatus status;
char *object = NULL, *old_object = NULL;
-
+
status = e_cal_backend_sync_remove_object (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, mod, &old_object, &object);
if (status == GNOME_Evolution_Calendar_Success) {
if (!object)
e_data_cal_notify_object_removed (cal, status, id, old_object, object);
- else
+ else
e_data_cal_notify_object_modified (cal, status, old_object, object);
e_cal_component_free_id (id);
_e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, const char *uid, const char *auid)
{
ECalBackendSyncStatus status;
-
+
status = e_cal_backend_sync_discard_alarm (E_CAL_BACKEND_SYNC (backend), cal, uid, auid);
e_data_cal_notify_alarm_discarded (cal, status);
_e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, const char *calobj)
{
ECalBackendSyncStatus status;
-
+
status = e_cal_backend_sync_receive_objects (E_CAL_BACKEND_SYNC (backend), cal, calobj);
e_data_cal_notify_objects_received (cal, status);
status = e_cal_backend_sync_get_object (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, &object);
e_data_cal_notify_object (cal, status, object);
-
+
g_free (object);
}
status = e_cal_backend_sync_get_attachment_list (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, &list);
e_data_cal_notify_attachment_list (cal, status, list);
-
+
g_slist_foreach (list, (GFunc) g_free, NULL);
g_free (list);
}
{
ECalBackendSyncStatus status;
char *object = NULL;
-
+
status = e_cal_backend_sync_get_timezone (E_CAL_BACKEND_SYNC (backend), cal, tzid, &object);
e_data_cal_notify_timezone_requested (cal, status, object);
{
ECalBackendSyncStatus status;
GList *adds = NULL, *modifies = NULL, *deletes = NULL, *l;
-
- status = e_cal_backend_sync_get_changes (E_CAL_BACKEND_SYNC (backend), cal, change_id,
+
+ status = e_cal_backend_sync_get_changes (E_CAL_BACKEND_SYNC (backend), cal, change_id,
&adds, &modifies, &deletes);
e_data_cal_notify_changes (cal, status, adds, modifies, deletes);
{
ECalBackendSyncStatus status;
GList *freebusy = NULL, *l;
-
+
status = e_cal_backend_sync_get_free_busy (E_CAL_BACKEND_SYNC (backend), cal, users, start, end, &freebusy);
e_data_cal_notify_free_busy (cal, status, freebusy);
CalObjModType mod,
char **old_object,
char **object);
-ECalBackendSyncStatus e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend,
- EDataCal *cal,
- const char *uid,
- const char *rid,
+ECalBackendSyncStatus e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend,
+ EDataCal *cal,
+ const char *uid,
+ const char *rid,
GSList **attachments);
ECalBackendSyncStatus e_cal_backend_sync_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *auid);
* Copyright (C) 2000 Ximian, Inc.
* Copyright (C) 2001 Ximian, Inc.
*
- * Authors: Rodrigo Moya <rodrigo@ximian.com>
+ * Authors: Rodrigo Moya <rodrigo@ximian.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
* Copyright (C) 2000 Ximian, Inc.
* Copyright (C) 2001 Ximian, Inc.
*
- * Authors: Rodrigo Moya <rodrigo@ximian.com>
+ * Authors: Rodrigo Moya <rodrigo@ximian.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
*
* Authors: Federico Mena-Quintero <federico@ximian.com>
* JP Rosevear <jpr@ximian.com>
- * Rodrigo Moya <rodrigo@ximian.com>
+ * Rodrigo Moya <rodrigo@ximian.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
/* The kind of components for this backend */
icalcomponent_kind kind;
-
+
/* List of Cal objects */
GMutex *clients_mutex;
GList *clients;
{
ECalBackend *backend;
ECalBackendPrivate *priv;
-
+
backend = E_CAL_BACKEND (object);
priv = backend->priv;
-
+
switch (property_id) {
case PROP_SOURCE:
{
{
ECalBackend *backend;
ECalBackendPrivate *priv;
-
+
backend = E_CAL_BACKEND (object);
priv = backend->priv;
object_class->get_property = e_cal_backend_get_property;
object_class->finalize = e_cal_backend_finalize;
- g_object_class_install_property (object_class, PROP_SOURCE,
+ g_object_class_install_property (object_class, PROP_SOURCE,
g_param_spec_object ("source", NULL, NULL, E_TYPE_SOURCE,
G_PARAM_READABLE | G_PARAM_WRITABLE
| G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class, PROP_URI,
+ g_object_class_install_property (object_class, PROP_URI,
g_param_spec_string ("uri", NULL, NULL, "",
G_PARAM_READABLE | G_PARAM_WRITABLE
| G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class, PROP_KIND,
- g_param_spec_ulong ("kind", NULL, NULL,
- ICAL_NO_COMPONENT, ICAL_XLICMIMEPART_COMPONENT,
+ g_object_class_install_property (object_class, PROP_KIND,
+ g_param_spec_ulong ("kind", NULL, NULL,
+ ICAL_NO_COMPONENT, ICAL_XLICMIMEPART_COMPONENT,
ICAL_NO_COMPONENT,
G_PARAM_READABLE | G_PARAM_WRITABLE
- | G_PARAM_CONSTRUCT_ONLY));
+ | G_PARAM_CONSTRUCT_ONLY));
e_cal_backend_signals[LAST_CLIENT_GONE] =
g_signal_new ("last_client_gone",
G_TYPE_FROM_CLASS (class),
class->is_read_only = NULL;
class->start_query = NULL;
class->get_mode = NULL;
- class->set_mode = NULL;
+ class->set_mode = NULL;
class->get_object = NULL;
class->get_default_object = NULL;
class->get_object_list = NULL;
g_mutex_free (priv->clients_mutex);
g_mutex_free (priv->queries_mutex);
-
+
g_free (priv->uri);
g_object_unref (priv->source);
g_free (priv);
e_cal_backend_get_source (ECalBackend *backend)
{
ECalBackendPrivate *priv;
-
+
g_return_val_if_fail (backend != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
priv = backend->priv;
-
+
return priv->source;
}
e_cal_backend_get_uri (ECalBackend *backend)
{
ECalBackendPrivate *priv;
-
+
g_return_val_if_fail (backend != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
priv = backend->priv;
-
+
return priv->uri;
}
e_cal_backend_get_kind (ECalBackend *backend)
{
ECalBackendPrivate *priv;
-
+
g_return_val_if_fail (backend != NULL, ICAL_NO_COMPONENT);
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), ICAL_NO_COMPONENT);
priv = backend->priv;
-
+
return priv->kind;
}
e_cal_backend_add_client (ECalBackend *backend, EDataCal *cal)
{
ECalBackendPrivate *priv;
-
+
g_return_if_fail (backend != NULL);
g_return_if_fail (E_IS_CAL_BACKEND (backend));
g_return_if_fail (cal != NULL);
g_return_if_fail (E_IS_DATA_CAL (cal));
priv = backend->priv;
-
+
bonobo_object_set_immortal (BONOBO_OBJECT (cal), TRUE);
g_object_weak_ref (G_OBJECT (cal), cal_destroy_cb, backend);
e_cal_backend_remove_client (ECalBackend *backend, EDataCal *cal)
{
ECalBackendPrivate *priv;
-
+
/* XXX this needs a bit more thinking wrt the mutex - we
should be holding it when we check to see if clients is
NULL */
g_mutex_lock (backend->priv->queries_mutex);
e_list_append (backend->priv->queries, query);
-
+
g_mutex_unlock (backend->priv->queries_mutex);
}
/**
* e_cal_backend_is_loaded:
* @backend: A calendar backend.
- *
+ *
* Queries whether a calendar backend has been loaded yet.
- *
+ *
* Return value: TRUE if the backend has been loaded with data, FALSE
* otherwise.
*/
*
* Starts a new live query on the given backend.
*/
-void
+void
e_cal_backend_start_query (ECalBackend *backend, EDataCalView *query)
{
g_return_if_fail (backend != NULL);
/**
* e_cal_backend_get_mode:
- * @backend: A calendar backend.
- *
+ * @backend: A calendar backend.
+ *
* Queries whether a calendar backend is connected remotely.
- *
+ *
* Return value: The current mode the calendar is in
**/
CalMode
* e_cal_backend_set_mode:
* @backend: A calendar backend
* @mode: Mode to change to
- *
- * Sets the mode of the calendar
+ *
+ * Sets the mode of the calendar
*/
void
e_cal_backend_set_mode (ECalBackend *backend, CalMode mode)
* @backend: A calendar backend.
* @cal: An #EDataCal object.
* @sexp: Expression to search for.
- *
+ *
* Calls the get_object_list method on the given backend.
*/
void
* @uid: Unique identifier for a calendar object.
* @rid: ID for the object's recurrence to get.
*
- * Queries a calendar backend for attachments present in a calendar object based
+ * Queries a calendar backend for attachments present in a calendar object based
* on its unique identifier and its recurrence ID (if a recurrent appointment).
*/
void
* @users: List of users to get free/busy information for.
* @start: Start time for query.
* @end: End time for query.
- *
+ *
* Gets a free/busy object for the given time interval
*/
void
* @backend: A calendar backend.
* @cal: An #EDataCal object.
* @change_id: A unique uid for the callers change list
- *
+ *
* Builds a sequence of objects and the type of change that occurred on them since
* the last time the give change_id was seen
*/
void
-e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, const char *change_id)
+e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, const char *change_id)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (E_IS_CAL_BACKEND (backend));
* @uid: Unique identifier of the object to remove.
* @rid: A recurrence ID.
* @mod: Type of removal.
- *
+ *
* Removes an object in a calendar backend. The backend will notify all of its
* clients about the change.
*/
* @cal: An #EDataCal object.
* @tzid: Unique identifier of a VTIMEZONE object. Note that this must not be
* NULL.
- *
+ *
* Returns the icaltimezone* corresponding to the TZID, or NULL if the TZID
* can't be found.
*/
* @backend: A calendar backend.
* @cal: An #EDataCal object.
* @tzobj: The timezone object, in a string.
- *
+ *
* Sets the default timezone for the calendar, which is used to resolve
- * DATE and floating DATE-TIME values.
+ * DATE and floating DATE-TIME values.
*/
void
e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, const char *tzobj)
* @backend: A calendar backend.
* @cal: An #EDataCal object.
* @tzid: The TZID identifying the timezone.
- *
+ *
* Sets the default timezone for the calendar, which is used to resolve
- * DATE and floating DATE-TIME values.
- *
+ * DATE and floating DATE-TIME values.
+ *
*/
void
e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, const char *tzid)
query = QUERY (e_iterator_get (iter));
bonobo_object_ref (query);
- if (e_data_cal_view_object_matches (query, calobj))
+ if (e_data_cal_view_object_matches (query, calobj))
e_data_cal_view_notify_objects_added_1 (query, calobj);
bonobo_object_unref (query);
e_data_cal_view_notify_objects_added_1 (query, object);
else if (old_match) {
ECalComponent *comp = NULL;
-
+
comp = e_cal_component_new_from_string (old_object);
if (comp) {
ECalComponentId *id = e_cal_component_get_id (comp);
e_data_cal_view_notify_objects_removed_1 (query, id);
-
+
e_cal_component_free_id (id);
g_object_unref (comp);
}
* modified by non-EDS clients.
**/
void
-e_cal_backend_notify_object_modified (ECalBackend *backend,
+e_cal_backend_notify_object_modified (ECalBackend *backend,
const char *old_object, const char *object)
{
ECalBackendPrivate *priv;
**/
void
e_cal_backend_notify_mode (ECalBackend *backend,
- GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
+ GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
GNOME_Evolution_Calendar_CalMode mode)
{
ECalBackendPrivate *priv = backend->priv;
{
ECalBackendPrivate *priv = backend->priv;
GList *l;
-
+
for (l = priv->clients; l; l = l->next)
e_data_cal_notify_auth_required (l->data);
}
void (* get_alarm_email_address) (ECalBackend *backend, EDataCal *cal);
void (* get_ldap_attribute) (ECalBackend *backend, EDataCal *cal);
void (* get_static_capabilities) (ECalBackend *backend, EDataCal *cal);
-
+
void (* open) (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists, const char *username, const char *password);
void (* remove) (ECalBackend *backend, EDataCal *cal);
void (* send_objects) (ECalBackend *backend, EDataCal *cal, const char *calobj);
void (* get_default_object) (ECalBackend *backend, EDataCal *cal);
- void (* get_object) (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid);
+ void (* get_object) (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid);
void (* get_object_list) (ECalBackend *backend, EDataCal *cal, const char *sexp);
- void (* get_attachment_list) (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid);
-
+ void (* get_attachment_list) (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid);
+
/* Timezone related virtual methods */
void (* get_timezone) (ECalBackend *backend, EDataCal *cal, const char *tzid);
void (* add_timezone) (ECalBackend *backend, EDataCal *cal, const char *object);
void e_cal_backend_notify_object_removed (ECalBackend *backend, const ECalComponentId *id, const char *old_object, const char *object);
void e_cal_backend_notify_mode (ECalBackend *backend,
- GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
+ GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
GNOME_Evolution_Calendar_CalMode mode);
void e_cal_backend_notify_auth_required (ECalBackend *backend);
void e_cal_backend_notify_error (ECalBackend *backend, const char *message);
*
* Copyright (C) 2000-2003 Ximian, Inc.
*
- * Authors:
+ * Authors:
* Federico Mena-Quintero <federico@ximian.com>
* JP Rosevear <jpr@ximian.com>
*
/* Whether we have been registered with OAF yet */
guint registered : 1;
-
+
int mode;
-
+
};
/* Signal IDs */
case GNOME_Evolution_Calendar_TYPE_JOURNAL:
return ICAL_VJOURNAL_COMPONENT;
}
-
+
return ICAL_NO_COMPONENT;
}
{
GHashTable *kinds;
ECalBackendFactory *factory;
-
+
kinds = g_hash_table_lookup (methods, method);
if (!kinds)
return NULL;
char *str_uri;
EUri *uri;
char *uri_type_string;
-
+
factory = E_DATA_CAL_FACTORY (bonobo_object_from_servant (servant));
priv = factory->priv;
bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod);
goto cleanup;
}
-
+
/* Duplicate the listener object */
CORBA_exception_init (&ev2);
listener_copy = CORBA_Object_duplicate (listener, &ev2);
G_CALLBACK (backend_last_client_gone_cb),
factory);
}
-
+
/* Create the corba calendar */
cal = e_data_cal_new (backend, listener);
printf ("cal = %p\n", cal);
/* Let the backend know about its clients corba clients */
e_cal_backend_add_client (backend, cal);
e_cal_backend_set_mode (backend, priv->mode);
-
+
ret_cal = CORBA_Object_duplicate (BONOBO_OBJREF (cal), ev);
cleanup:
e_uri_free (uri);
{
EDataCalFactory *factory;
- factory = g_object_new (E_TYPE_DATA_CAL_FACTORY,
- "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
+ factory = g_object_new (E_TYPE_DATA_CAL_FACTORY,
+ "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
NULL);
return factory;
epv->getCal = impl_CalFactory_getCal;
}
-static void
+static void
set_backend_online_status (gpointer key, gpointer value, gpointer data)
{
ECalBackend *backend = E_CAL_BACKEND (value);
*
* Sets the online mode for all backends created by the given factory.
*/
-void
+void
e_data_cal_factory_set_backend_mode (EDataCalFactory *factory, int mode)
{
EDataCalFactoryPrivate *priv = factory->priv;
-
-
+
+
priv->mode = mode;
g_hash_table_foreach (priv->backends, set_backend_online_status, GINT_TO_POINTER (priv->mode));
}
priv = g_new0 (EDataCalFactoryPrivate, 1);
factory->priv = priv;
- priv->methods = g_hash_table_new_full (g_str_hash, g_str_equal,
+ priv->methods = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free, (GDestroyNotify) g_hash_table_destroy);
- priv->backends = g_hash_table_new_full (g_str_hash, g_str_equal,
+ priv->backends = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free, (GDestroyNotify) g_object_unref);
priv->registered = FALSE;
}
* e_data_cal_factory_register_storage:
* @factory: A calendar factory.
* @iid: OAFIID for the factory to be registered.
- *
+ *
* Registers a calendar factory with the OAF object activation daemon. This
* function must be called before any clients can activate the factory.
- *
+ *
* Return value: TRUE on success, FALSE otherwise.
**/
gboolean
* e_data_cal_factory_register_backend:
* @factory: A calendar factory.
* @backend_factory: The object responsible for creating backends.
- *
+ *
* Registers an #ECalBackend subclass that will be used to handle URIs
* with a particular method. When the factory is asked to open a
* particular URI, it will look in its list of registered methods and
kinds = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
g_hash_table_insert (priv->methods, method_str, kinds);
}
-
+
g_hash_table_insert (kinds, GINT_TO_POINTER (kind), backend_factory);
}
struct _EDataCalFactoryClass {
BonoboObjectClass parent_class;
-
+
POA_GNOME_Evolution_Calendar_CalFactory__epv epv;
/* Notification signals */
e_cal_component_get_uid (comp, &this_uid);
if (this_uid && !strcmp (id->uid, this_uid)) {
if (id->rid && *id->rid) {
- const char *rid = e_cal_component_get_recurid_as_string (comp);
+ const char *rid = e_cal_component_get_recurid_as_string (comp);
if (rid && !strcmp (id->rid, rid))
remove = TRUE;
if (ld->component_listener == cl) {
g_object_unref (ld->component_listener);
ld->component_listener = NULL;
-
+
bonobo_object_release_unref (ld->listener, NULL);
ld->listener = NULL;
query = QUERY (object);
priv = query->priv;
-
+
switch (property_id) {
case PROP_BACKEND:
priv->backend = E_CAL_BACKEND (g_value_get_object (value));
{
EDataCalView *query;
EDataCalViewPrivate *priv;
-
+
query = QUERY (object);
priv = query->priv;
GObjectClass *object_class;
POA_GNOME_Evolution_Calendar_CalView__epv *epv = &klass->epv;
GParamSpec *param;
-
+
object_class = (GObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
* @backend: Calendar backend that the query object will monitor.
* @ql: Listener for query results.
* @sexp: Sexp that defines the query.
- *
+ *
* Creates a new query engine object that monitors a calendar backend.
- *
+ *
* Return value: A newly-created query object, or NULL on failure.
**/
EDataCalView *
e_data_cal_view_object_matches (EDataCalView *query, const char *object)
{
EDataCalViewPrivate *priv;
-
+
g_return_val_if_fail (query != NULL, FALSE);
g_return_val_if_fail (IS_QUERY (query), FALSE);
g_return_val_if_fail (object != NULL, FALSE);
priv = query->priv;
-
+
return e_cal_backend_sexp_match_object (priv->sexp, object, priv->backend);
}
CORBA_Environment ev;
const GList *l;
int num_objs, i;
-
+
g_return_if_fail (query != NULL);
g_return_if_fail (IS_QUERY (query));
{
EDataCalViewPrivate *priv;
GList objects;
-
+
g_return_if_fail (query != NULL);
g_return_if_fail (IS_QUERY (query));
g_return_if_fail (object != NULL);
CORBA_Environment ev;
const GList *l;
int num_objs, i;
-
+
g_return_if_fail (query != NULL);
g_return_if_fail (IS_QUERY (query));
{
EDataCalViewPrivate *priv;
GList objects;
-
+
g_return_if_fail (query != NULL);
g_return_if_fail (IS_QUERY (query));
g_return_if_fail (object != NULL);
objects.next = objects.prev = NULL;
objects.data = (gpointer)object;
-
+
e_data_cal_view_notify_objects_modified (query, &objects);
}
CORBA_Environment ev;
const GList *l;
int num_ids, i;
-
+
g_return_if_fail (query != NULL);
g_return_if_fail (IS_QUERY (query));
num_ids = g_list_length ((GList*)ids);
if (num_ids <= 0)
return;
-
+
id_list._buffer = GNOME_Evolution_Calendar_CalObjIDSeq_allocbuf (num_ids);
id_list._maximum = num_ids;
id_list._length = num_ids;
-
+
i = 0;
for (l = ids; l; l = l->next, i++) {
ECalComponentId *id = l->data;
GNOME_Evolution_Calendar_CalObjID *c_id = &id_list._buffer[i];
c_id->uid = CORBA_string_dup (id->uid);
-
+
if (id->rid)
c_id->rid = CORBA_string_dup (id->rid);
else
- c_id->rid = CORBA_string_dup ("");
+ c_id->rid = CORBA_string_dup ("");
/* update our cache */
remove_object_from_cache (query, l->data);
}
-
+
for (l = priv->listeners; l != NULL; l = l->next) {
ListenerData *ld = l->data;
{
EDataCalViewPrivate *priv;
GList ids;
-
+
g_return_if_fail (query != NULL);
g_return_if_fail (IS_QUERY (query));
g_return_if_fail (id != NULL);
ids.next = ids.prev = NULL;
ids.data = (gpointer)id;
-
+
e_data_cal_view_notify_objects_removed (query, &ids);
}
void
e_data_cal_view_notify_progress (EDataCalView *query, const char *message, int percent)
{
- EDataCalViewPrivate *priv;
+ EDataCalViewPrivate *priv;
CORBA_Environment ev;
GList *l;
void
e_data_cal_view_notify_done (EDataCalView *query, GNOME_Evolution_Calendar_CallStatus status)
{
- EDataCalViewPrivate *priv;
+ EDataCalViewPrivate *priv;
CORBA_Environment ev;
GList *l;
{
EDataCal *cal;
EDataCalPrivate *priv;
-
+
cal = E_DATA_CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
{
EDataCal *cal;
EDataCalPrivate *priv;
-
+
cal = E_DATA_CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
e_cal_backend_is_read_only (priv->backend, cal);
}
-
+
/* Cal::getEmailAddress method */
static void
impl_Cal_getCalAddress (PortableServer_Servant servant,
e_cal_backend_get_cal_address (priv->backend, cal);
}
-
+
/* Cal::get_alarm_email_address method */
static void
impl_Cal_getAlarmEmailAddress (PortableServer_Servant servant,
e_cal_backend_get_alarm_email_address (priv->backend, cal);
}
-
+
/* Cal::get_ldap_attribute method */
static void
impl_Cal_getLdapAttribute (PortableServer_Servant servant,
{
EDataCal *cal;
EDataCalPrivate *priv;
-
+
cal = E_DATA_CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
{
EDataCal *cal;
EDataCalPrivate *priv;
-
+
cal = E_DATA_CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
-
+
e_cal_backend_get_default_object (priv->backend, cal);
}
EDataCal *cal;
EDataCalPrivate *priv;
EDataCalView *query;
-
+
cal = E_DATA_CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
EDataCalPrivate *priv;
EDataCalView *query;
ECalBackendSExp *obj_sexp;
-
+
cal = E_DATA_CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
CORBA_exception_free (&ev);
priv->backend = backend;
-
+
return cal;
}
g_return_val_if_fail (backend != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
- cal = E_DATA_CAL (g_object_new (E_TYPE_DATA_CAL,
+ cal = E_DATA_CAL (g_object_new (E_TYPE_DATA_CAL,
"poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
NULL));
priv = cal->priv;
priv->backend = NULL;
-
+
CORBA_exception_init (&ev);
bonobo_object_release_unref (priv->listener, &ev);
if (BONOBO_EX (&ev))
*
* Notifies listeners of the completion of the is_read_only method call.
*/
-void
+void
e_data_cal_notify_read_only (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, gboolean read_only)
{
EDataCalPrivate *priv;
if (BONOBO_EX (&ev))
g_message (G_STRLOC ": could not notify the listener of read only");
- CORBA_exception_free (&ev);
+ CORBA_exception_free (&ev);
}
/**
*
* Notifies listeners of the completion of the get_cal_address method call.
*/
-void
+void
e_data_cal_notify_cal_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address)
{
EDataCalPrivate *priv;
if (BONOBO_EX (&ev))
g_message (G_STRLOC ": could not notify the listener of cal address");
- CORBA_exception_free (&ev);
+ CORBA_exception_free (&ev);
}
/**
*
* Notifies listeners of the completion of the open method call.
*/
-void
+void
e_data_cal_notify_open (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
{
EDataCalPrivate *priv;
* Notifies listeners of the completion of the modify_object method call.
*/
void
-e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
const char *old_object, const char *object)
{
EDataCalPrivate *priv;
* Notifies listeners of the completion of the remove_object method call.
*/
void
-e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
const ECalComponentId *id, const char *old_object, const char *object)
{
EDataCalPrivate *priv;
if (BONOBO_EX (&ev))
g_message (G_STRLOC ": could not notify the listener of alarm discarded");
- CORBA_exception_free (&ev);
+ CORBA_exception_free (&ev);
}
/**
{
EDataCalPrivate *priv;
CORBA_Environment ev;
-
+
g_return_if_fail (cal != NULL);
g_return_if_fail (E_IS_DATA_CAL (cal));
CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_CalListener_notifyDefaultObjectRequested (priv->listener, status,
+ GNOME_Evolution_Calendar_CalListener_notifyDefaultObjectRequested (priv->listener, status,
object ? object : "", &ev);
if (BONOBO_EX (&ev))
{
EDataCalPrivate *priv;
CORBA_Environment ev;
-
+
g_return_if_fail (cal != NULL);
g_return_if_fail (E_IS_DATA_CAL (cal));
GNOME_Evolution_Calendar_stringlist seq;
GList *l;
int i;
-
+
g_return_if_fail (cal != NULL);
g_return_if_fail (E_IS_DATA_CAL (cal));
GNOME_Evolution_Calendar_stringlist seq;
GSList *l;
int i;
-
+
g_return_if_fail (cal != NULL);
g_return_if_fail (E_IS_DATA_CAL (cal));
if (BONOBO_EX (&ev))
g_message (G_STRLOC ": could not notify the listener of query");
- CORBA_exception_free (&ev);
+ CORBA_exception_free (&ev);
}
/**
* Notifies listeners of the completion of the get_changes method call.
*/
void
-e_data_cal_notify_changes (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+e_data_cal_notify_changes (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
GList *adds, GList *modifies, GList *deletes)
{
EDataCalPrivate *priv;
CORBA_Environment ev;
GNOME_Evolution_Calendar_CalObjChangeSeq seq;
- GList *l;
+ GList *l;
int n, i;
g_return_if_fail (E_IS_DATA_CAL (cal));
i = 0;
for (l = adds; l; i++, l = l->next) {
GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
-
+
change->calobj = CORBA_string_dup (l->data);
change->type = GNOME_Evolution_Calendar_ADDED;
}
change->calobj = CORBA_string_dup (l->data);
change->type = GNOME_Evolution_Calendar_DELETED;
}
-
+
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_CalListener_notifyChanges (priv->listener, status, &seq, &ev);
GNOME_Evolution_Calendar_CalObjSeq seq;
GList *l;
int n, i;
-
+
g_return_if_fail (E_IS_DATA_CAL (cal));
priv = cal->priv;
for (i = 0, l = freebusy; l; i++, l = l->next)
seq._buffer[i] = CORBA_string_dup (l->data);
-
+
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_CalListener_notifyFreeBusy (priv->listener, status, &seq, &ev);
* @cal: A calendar client interface.
* @status: Status of the mode set.
* @mode: The current mode.
- *
+ *
* Notifies the listener of the results of a set_mode call.
**/
void
g_message ("e_data_cal_notify_mode(): could not notify the listener "
"about a mode change");
- CORBA_exception_free (&ev);
+ CORBA_exception_free (&ev);
}
/**
*
* Notifies listeners that authorization is required to open the calendar.
*/
-void
+void
e_data_cal_notify_auth_required (EDataCal *cal)
{
EDataCalPrivate *priv;
CORBA_Environment ev;
-
+
g_return_if_fail (cal != NULL);
g_return_if_fail (E_IS_DATA_CAL (cal));
-
+
priv = cal->priv;
g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
+
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_CalListener_notifyAuthRequired (priv->listener, &ev);
if (BONOBO_EX (&ev))
void e_data_cal_notify_object_created (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
const char *uid, const char *object);
-void e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
const char *old_object, const char *object);
-void e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
const ECalComponentId *id, const char *old_object, const char *object);
void e_data_cal_notify_alarm_discarded (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status);
void e_data_cal_notify_free_busy (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
GList *freebusy);
-void e_data_cal_notify_mode (EDataCal *cal,
- GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
+void e_data_cal_notify_mode (EDataCal *cal,
+ GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
GNOME_Evolution_Calendar_CalMode mode);
void e_data_cal_notify_auth_required (EDataCal *cal);
objects_added_cb (GObject *object, GList *objects, gpointer data)
{
GList *l;
-
+
for (l = objects; l; l = l->next)
cl_printf (data, "Object added %s\n", icalcomponent_get_uid (l->data));
}
objects_modified_cb (GObject *object, GList *objects, gpointer data)
{
GList *l;
-
+
for (l = objects; l; l = l->next)
cl_printf (data, "Object modified %s\n", icalcomponent_get_uid (l->data));
}
objects_removed_cb (GObject *object, GList *objects, gpointer data)
{
GList *l;
-
+
for (l = objects; l; l = l->next)
cl_printf (data, "Object removed %s\n", icalcomponent_get_uid (l->data));
}
{
GList *objects = NULL;
GList *l;
-
+
if (!e_cal_get_object_list (client, "(contains? \"any\" \"test\")", &objects, NULL))
return FALSE;
-
+
cl_printf (client, "UIDS: ");
cl_printf (client, "\nGot %d objects\n", g_list_length (objects));
g_main_loop_quit (loop);
}
-static char *
+static char *
test_object_creation (ECal *client, char **uid)
{
ECalComponent *comp, *comp_retrieved;
ECalComponentTransparency transp;
gboolean compare;
GError *error = NULL;
-
+
comp = e_cal_component_new ();
/* set fields */
e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
dt.tzid ="UTC";
e_cal_component_set_dtend (comp, &dt);
e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_OPAQUE);
-
+
e_cal_component_commit_sequence (comp);
- icalcomp = e_cal_component_get_icalcomponent (comp);
+ icalcomp = e_cal_component_get_icalcomponent (comp);
if (!e_cal_create_object (client, icalcomp, uid, &error)) {
cl_printf (client, "Object creation: %s\n", error->message);
g_free (comp);
g_free (icalcomp_retrieved);
return "Test Object Creation failed";
- }
+ }
/* Dumping icalcomp into a string is not useful as the retrieved object
- * has some generated information like timestamps. We compare
+ * has some generated information like timestamps. We compare
* member values we set during creation*/
compare = e_cal_component_event_dates_match (comp, comp_retrieved);
-
+
if (compare) {
e_cal_component_get_transparency (comp_retrieved, &transp);
- compare = (transp == E_CAL_COMPONENT_TRANSP_OPAQUE);
+ compare = (transp == E_CAL_COMPONENT_TRANSP_OPAQUE);
}
-
+
g_free (comp_retrieved);
g_free (comp);
g_free (icalcomp);
g_free (icalcomp_retrieved);
-
+
mu_assert ("Test Object creation : Created object does not match retrieved data\n", compare);
return NULL;
}
-
+
static char *
test_object_modification (ECal *client, char *uid)
{
icalcomponent *icalcomp, *icalcomp_modified;
gboolean compare;
GError *error = NULL;
-
+
if (!e_cal_get_object (client, uid, NULL, &icalcomp, &error)) {
cl_printf (client, "Test Modify object : Could not get the object: %s\n", error->message);
g_free (uid);
static char *
test_object_removal (ECal *client)
{
-
+
char *uid;
ECalComponent *comp;
icalcomponent *icalcomp;
gboolean compare = 1;
GError *error = NULL;
-
+
comp = e_cal_component_new ();
e_cal_component_commit_sequence (comp);
- icalcomp = e_cal_component_get_icalcomponent (comp);
+ icalcomp = e_cal_component_get_icalcomponent (comp);
if (!e_cal_create_object (client, icalcomp, &uid, &error)) {
cl_printf (client, "Test object removal - Object creation: %s\n", error->message);
g_object_unref (comp);
g_object_unref(icalcomp);
return "Test Object Removal failed\n";
}
-
+
if (!e_cal_remove_object (client, uid, &error)) {
cl_printf (client, "Test object removal - Could not remove the object\n");
g_free (uid);
g_object_unref (comp);
g_object_unref (icalcomp);
return "Test Object Removal failed\n";
-
- }
+
+ }
compare = e_cal_get_object (client, uid, NULL, &icalcomp, &error);
g_free (uid);
g_object_unref (comp);
g_object_unref (icalcomp);
-
- mu_assert ("Test object removal - Failed\n", compare);
+
+ mu_assert ("Test object removal - Failed\n", compare);
return NULL;
}
#endif
icaltimezone *utc;
time_t start = time (NULL), end;
gboolean compare;
-
+
utc = icaltimezone_get_utc_timezone ();
start = time_from_isodate ("20040212T000000Z");
end = time_add_day_with_zone (start, 2, utc);
alarms = e_cal_get_alarms_in_range (client, start, end);
- compare = (g_slist_length (alarms) == 3);
-
+ compare = (g_slist_length (alarms) == 3);
+
e_cal_free_alarms (alarms);
mu_assert ("Test getting alarms in range\n", compare);
-
+
return NULL;
}
static char *
-test_set_uri (ECal *client, const gchar *uri)
+test_set_uri (ECal *client, const gchar *uri)
{
/* The uri is set as part of create_client call. This method merely
* verifies it was done correctly.
gboolean compare = 0;
cal_uri = g_strconcat ("file://", uri, NULL);
compare = !strcmp (e_cal_get_uri (client), cal_uri);
-
+
g_free (cal_uri);
- mu_assert ("Test set_uri : uri was not set correctly\n", compare);
-
+ mu_assert ("Test set_uri : uri was not set correctly\n", compare);
+
return NULL;
}
{
/* Test one loaded calendar and another that is not loaded. */
mu_assert ("Test get_cal_load_state : Failed \n",
- (E_CAL_LOAD_LOADED == e_cal_get_load_state (client)) &&
+ (E_CAL_LOAD_LOADED == e_cal_get_load_state (client)) &&
(E_CAL_LOAD_NOT_LOADED == e_cal_get_load_state (NULL)));
return NULL;
char *uri;
char *cal_uri;
gboolean compare = 0;
-
+
source = e_cal_get_source (client);
uri = e_source_get_uri (source);
cal_uri = g_strconcat ("file://", expected, NULL);
g_free (cal_uri);
mu_assert ("Test get_source : Failed\n", compare);
-
+
return NULL;
}
{
/* This uses pre-loaded data. Hence its results are valid only
* when called before any write operation is performed.
- */
+ */
int i = 0;
GList *objects = NULL;
return "Could not get the list of objects";
i = g_list_length (objects);
e_cal_free_object_list (objects);
-
+
mu_assert ("Test get_object_list : Expected number of objects not found", i == expected);
return NULL;
GError *error = NULL;
char *cal_uri, *cal_file;
gboolean created = 0;
-
+
cal_uri = g_strconcat ("file://", uri, NULL);
*cal = e_cal_new_from_uri (cal_uri, E_CAL_SOURCE_TYPE_EVENT);
if (!*cal) {
g_free (cal_file);
mu_assert ("Test creation of new calendar : Failed", created);
-
+
return NULL;
}
char *cal_uri;
GError *error = NULL;
gboolean removed = 0;
-
+
cal_uri = g_strconcat (uri, "/calendar.ics", NULL);
if (!e_cal_remove (ecal, &error)) {
cl_printf (ecal, "Test Calendar removal : Could not remove the Calendar : %s\n", error->message);
}
-
+
removed = !g_file_test (uri, G_FILE_TEST_EXISTS);
g_free (cal_uri);
-
+
mu_assert ("Test Remove calendar : Failed ", removed);
-
+
return NULL;
-}
+}
#endif
static char *
ECal *cal;
char *uri;
gboolean created;
-
+
cal = e_cal_new_system_calendar ();
uri = g_build_filename (g_get_home_dir (), ".evolution", "calendar", "local", "system", "calendar.ics", NULL);
created = g_file_test (uri, G_FILE_TEST_EXISTS);
g_free (uri);
-
+
mu_assert ("Test creation of default system calendar : Failed", created);
-
+
return NULL;
}
ECal *cal;
char *uri;
gboolean created;
-
+
cal = e_cal_new_system_tasks ();
uri = g_build_filename (g_get_home_dir (), ".evolution", "tasks", "local", "system", "tasks.ics", NULL);
created = g_file_test (uri, G_FILE_TEST_EXISTS);
g_free (uri);
-
+
mu_assert ("Test creation of default system tasks : Failed", created);
-
+
return NULL;
}
ECal *cal;
char *uri;
gboolean created;
-
+
cal = e_cal_new_system_memos ();
uri = g_build_filename (g_get_home_dir (), ".evolution", "memos", "local", "system", "journal.ics", NULL);
created = g_file_test (uri, G_FILE_TEST_EXISTS);
g_free (uri);
-
+
mu_assert ("Test creation of default system memos : Failed", created);
-
+
return NULL;
}
GError *error = NULL;
icaltimezone *utc;
time_t start = time (NULL), end;
-
+
utc = icaltimezone_get_utc_timezone ();
start = time_from_isodate ("20040212T000000Z");
end = time_add_day_with_zone (start, 2, utc);
for (l = freebusy; l; l = l->next) {
char *comp_string;
ECalComponent *comp = E_CAL_COMPONENT (l->data);
-
+
comp_string = e_cal_component_get_as_string (comp);
cl_printf (client, "%s\n\n", comp_string);
g_object_unref (comp);
g_free (comp_string);
- }
- }
+ }
+ }
else {
cl_printf (client, "free_busy was returned but NULL");
- }
- return NULL;
+ }
+ return NULL;
}
g_free (ical_string);
tests_passed++;
return NULL;
-
- } else
- cl_printf (client, "Test Get default object : Could not get the default object: %s\n", error->message);
+
+ } else
+ cl_printf (client, "Test Get default object : Could not get the default object: %s\n", error->message);
return error->message;
}
/* XXX The string pasted below is *really* ugly. Alternatively, it could be
* read from a file at run-time. Not sure if it is an elegant solution when
- * multiple clients try to load the same file during stress testing.
+ * multiple clients try to load the same file during stress testing.
* how can this be done better ?
*/
#define EXPECTED \
END:VEVENT"
static char *
-test_get_object (ECal *client)
+test_get_object (ECal *client)
{
const char *uid = "20040213T055519Z-15802-500-1-3@testcal";
char *actual;
icalcomponent *icalcomp;
gboolean compare;
GError *error = NULL;
-
+
if (!e_cal_get_object (client, uid, NULL, &icalcomp, &error)) {
cl_printf (client, "Test Get object : Could not get the object: %s\n", error->message);
return error->message;
actual = icalcomponent_as_ical_string (icalcomp);
compare = !strcmp (actual, EXPECTED);
-
+
g_free (actual);
mu_assert ("Test : get_object does not match the expected output", compare);
return NULL;
-}
+}
static char *
test_timezones (ECal *client)
printf ("\n\nTime Zones : \n%s *** %s", icaltimezone_get_display_name (zone), icaltimezone_get_tzid (zone));
printf ("\n\nTime Zones : \n%s", icaltimezone_get_location (zone));
-
-
+
+
return NULL;
}
static char *
-all_tests(ECal *client, const gchar *uri)
+all_tests(ECal *client, const gchar *uri)
{
char *uid;
-
+
mu_run_test (test_new_system_calendar ());
mu_run_test (test_new_system_tasks ());
mu_run_test (test_new_system_memos ());
mu_run_test (test_set_uri (client, uri));
mu_run_test (test_get_source (client, uri));
mu_run_test (test_cal_loaded (client));
-
+
/* test_query acts on pre-loaded data. Hence it must executed before
* any writes are made */
mu_run_test (test_query (client, "(contains? \"any\" \"test\")", 2));
mu_run_test (test_query (client, "(contains? \"summary\" \"Kansas\")", 1));
mu_run_test (test_query (client, "(contains? \"any\" \"gibberish\")", 0));
-
+
mu_run_test (test_get_default_object (client));
mu_run_test (test_get_object (client));
mu_run_test (test_get_free_busy (client));
// mu_run_test (test_e_cal_new (&ecal, tmp));
// mu_run_test (test_e_cal_remove (ecal, tmp));
// g_free (tmp);
-
+
test_timezones (client);
-
+
return NULL;
}
ECalView *query;
char *cal_uri;
GError *error = NULL;
-
+
cal_uri = g_strconcat ("file://", uri, NULL);
*client = e_cal_new_from_uri (cal_uri, type);
if (!*client) {
exit (1);
}
g_clear_error (&error);
-
+
if (!e_cal_get_query (*client, "(contains? \"any\" \"Event\")", &query, NULL)) {
cl_printf (*client, G_STRLOC ": Unable to obtain query");
- exit (1);
+ exit (1);
}
- g_signal_connect (G_OBJECT (query), "objects_added",
+ g_signal_connect (G_OBJECT (query), "objects_added",
G_CALLBACK (objects_added_cb), client);
- g_signal_connect (G_OBJECT (query), "objects_modified",
+ g_signal_connect (G_OBJECT (query), "objects_modified",
G_CALLBACK (objects_modified_cb), client);
- g_signal_connect (G_OBJECT (query), "objects_removed",
+ g_signal_connect (G_OBJECT (query), "objects_removed",
G_CALLBACK (objects_removed_cb), client);
g_signal_connect (G_OBJECT (query), "view_done",
G_CALLBACK (view_done_cb), client);
-
+
e_cal_view_start (query);
-
+
results = all_tests (*client, uri);
- cl_printf (*client, "\n\n\n*************Tests run: %d****************\n\n", tests_run);
+ cl_printf (*client, "\n\n\n*************Tests run: %d****************\n\n", tests_run);
cl_printf (*client, "*************Tests passed: %d*************\n\n\n", tests_passed);
- if (results != 0)
+ if (results != 0)
cl_printf (*client, "***Failures********%s\n", results);
-
+
cl_printf (*client, "dump of the test calendar data");
list_uids (*client);
g_free (cal_uri);
/* arg1- file name; arg2- client suffix */
uri = g_strconcat (argv[1], argv[2], NULL);
create_client (&client1, uri, E_CAL_SOURCE_TYPE_EVENT, FALSE);
-
- g_free (uri);
+
+ g_free (uri);
g_main_loop_run (loop);
return 0;
}
for (l = objects; l; l = l->next) {
ECalComponent *comp = E_CAL_COMPONENT (l->data);
char *str;
-
+
str = e_cal_component_get_as_string (comp);
printf ("%s\n", str);
struct _date_token *tokens = NULL, *token, *tail = (struct _date_token *) &tokens;
const unsigned char *start, *end;
unsigned int mask;
-
+
start = date;
while (*start) {
/* kill leading whitespace */
while (*start && isspace ((int) *start))
start++;
-
+
if (*start == '\0')
break;
-
+
mask = datetok_table[*start];
-
+
/* find the end of this token */
end = start + 1;
while (*end && !strchr ("-/,\t\r\n ", *end))
mask |= datetok_table[*end++];
-
+
if (end != start) {
token = g_malloc (sizeof (struct _date_token));
token->next = NULL;
token->start = start;
token->len = end - start;
token->mask = mask;
-
+
tail->next = token;
tail = token;
}
-
+
if (*end)
start = end + 1;
else
break;
}
-
+
return tokens;
}
register const unsigned char *inptr;
const unsigned char *inend;
int sign = 1, val = 0;
-
+
inptr = in;
inend = in + inlen;
-
+
if (*inptr == '-') {
sign = -1;
inptr++;
} else if (*inptr == '+')
inptr++;
-
+
for ( ; inptr < inend; inptr++) {
if (!isdigit ((int) *inptr))
return -1;
else
val = (val * 10) + (*inptr - '0');
}
-
+
val *= sign;
-
+
return val;
}
get_wday (const unsigned char *in, unsigned int inlen)
{
int wday;
-
+
if (inlen < 3)
return -1;
-
+
for (wday = 0; wday < 7; wday++)
if (!g_ascii_strncasecmp (in, tm_days[wday], 3))
return wday;
-
+
return -1; /* unknown week day */
}
get_mday (const unsigned char *in, unsigned int inlen)
{
int mday;
-
+
mday = decode_int (in, inlen);
-
+
if (mday < 0 || mday > 31)
mday = -1;
-
+
return mday;
}
get_month (const unsigned char *in, unsigned int inlen)
{
int i;
-
+
if (inlen < 3)
return -1;
-
+
for (i = 0; i < 12; i++)
if (!g_ascii_strncasecmp (in, tm_months[i], 3))
return i;
-
+
return -1; /* unknown month */
}
get_year (const unsigned char *in, unsigned int inlen)
{
int year;
-
+
year = decode_int (in, inlen);
if (year == -1)
return -1;
-
+
if (year < 100)
year += (year < 70) ? 2000 : 1900;
-
+
if (year < 1969)
return -1;
-
+
return year;
}
register const unsigned char *inptr;
const unsigned char *inend;
int *val, colons = 0;
-
+
*hour = *min = *sec = 0;
-
+
inend = in + inlen;
val = hour;
for (inptr = in; inptr < inend; inptr++) {
else
*val = (*val * 10) + (*inptr - '0');
}
-
+
return TRUE;
}
const unsigned char *inptr, *inend;
unsigned int inlen;
int i, t;
-
+
for (i = 0; *token && i < 2; *token = (*token)->next, i++) {
inptr = (*token)->start;
inlen = (*token)->len;
inend = inptr + inlen;
-
+
if (*inptr == '+' || *inptr == '-') {
t = decode_int (inptr, inlen);
if (t < -1200 || t > 1400)
return -1;
-
+
return t;
} else {
if (*inptr == '(') {
else
inlen--;
}
-
+
for (t = 0; t < 15; t++) {
unsigned int len = strlen (tz_offsets[t].name);
-
+
if (len != inlen)
continue;
-
+
if (!strncmp (inptr, tz_offsets[t].name, len))
return tz_offsets[t].offset;
}
}
}
-
+
return -1;
}
struct _date_token *token;
struct tm tm;
time_t time;
-
+
memset ((void *) &tm, 0, sizeof (struct tm));
got_wday = got_month = got_tzone = FALSE;
offset = 0;
-
+
token = tokens;
while (token) {
if (is_weekday (token) && !got_wday) {
goto next_token;
}
}
-
+
if (is_month (token) && !got_month) {
if ((n = get_month (token->start, token->len)) != -1) {
d(printf ("month; "));
goto next_token;
}
}
-
+
if (is_time (token) && !tm.tm_hour && !tm.tm_min && !tm.tm_sec) {
if (get_time (token->start, token->len, &hour, &min, &sec)) {
d(printf ("time; "));
goto next_token;
}
}
-
+
if (is_tzone (token) && !got_tzone) {
struct _date_token *t = token;
-
+
if ((n = get_tzone (&t)) != -1) {
d(printf ("tzone; "));
got_tzone = TRUE;
goto next_token;
}
}
-
+
if (is_numeric (token)) {
if (token->len == 4 && !tm.tm_year) {
if ((n = get_year (token->start, token->len)) != -1) {
}
}
}
-
+
d(printf ("???; "));
-
+
next_token:
-
+
token = token->next;
}
-
+
d(printf ("\n"));
-
+
time = e_mktime_utc (&tm);
-
+
/* time is now GMT of the time we want, but not offset by the timezone ... */
-
+
/* this should convert the time to the GMT equiv time */
time -= ((offset / 100) * 60 * 60) + (offset % 100) * 60;
-
+
if (tzone)
*tzone = offset;
-
+
return time;
}
{
struct _date_token *token, *tokens;
time_t date;
-
+
tokens = datetok (datestr);
-
+
date = decode_broken_date (tokens, saveoffset);
-
+
/* cleanup */
while (tokens) {
token = tokens;
tokens = tokens->next;
g_free (token);
}
-
+
return date;
}
table_init ()
{
int i;
-
+
memset (datetok_table, 0, sizeof (datetok_table));
-
+
for (i = 0; i < 256; i++) {
if (!strchr (NUMERIC_CHARS, i))
datetok_table[i] |= DATE_TOKEN_NON_NUMERIC;
-
+
if (!strchr (WEEKDAY_CHARS, i))
datetok_table[i] |= DATE_TOKEN_NON_WEEKDAY;
-
+
if (!strchr (MONTH_CHARS, i))
datetok_table[i] |= DATE_TOKEN_NON_MONTH;
-
+
if (!strchr (TIME_CHARS, i))
datetok_table[i] |= DATE_TOKEN_NON_TIME;
-
+
if (!strchr (TIMEZONE_ALPHA_CHARS, i))
datetok_table[i] |= DATE_TOKEN_NON_TIMEZONE_ALPHA;
-
+
if (!strchr (TIMEZONE_NUMERIC_CHARS, i))
datetok_table[i] |= DATE_TOKEN_NON_TIMEZONE_NUMERIC;
-
+
if (((char) i) == ':')
datetok_table[i] |= DATE_TOKEN_HAS_COLON;
-
+
if (strchr ("+-", i))
datetok_table[i] |= DATE_TOKEN_HAS_SIGN;
}
-
+
printf ("static const unsigned int datetok_table[256] = {");
for (i = 0; i < 256; i++) {
if (i % 16 == 0)
{
time_t date;
int offset;
-
+
/*table_init ();*/
-
+
date = parse_broken_date (argv[1], &offset);
printf ("%d; %d\n", date, offset);
-
+
return 0;
}
camel_address_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_object_get_type (), "CamelAddress",
sizeof (CamelAddress),
(CamelObjectInitFunc) camel_address_init,
(CamelObjectFinalizeFunc) camel_address_finalize);
}
-
+
return type;
}
* camel_address_new:
*
* Create a new #CamelAddress object.
- *
+ *
* Returns a new #CamelAddress object
**/
CamelAddress *
/**
* camel_address_new_clone:
* @addr: a #CamelAddress object
- *
+ *
* Clone an existing address type.
- *
+ *
* Returns the cloned address
**/
CamelAddress *
/**
* camel_address_length:
* @addr: a #CamelAddress object
- *
+ *
* Get the number of addresses stored in the address @addr.
- *
+ *
* Returns the number of addresses contained in @addr
**/
int
/**
* camel_address_encode:
* @addr: a #CamelAddress object
- *
+ *
* Encode an address in a format suitable for a raw header.
- *
+ *
* Returns the encoded address
**/
char *
* camel_address_unformat:
* @addr: a #CamelAddress object
* @raw: raw address description
- *
+ *
* Attempt to convert a previously formatted and/or edited
* address back into internal form.
- *
+ *
* Returns the number of addresses parsed or %-1 on fail
**/
int
/**
* camel_address_format:
* @addr: a #CamelAddress object
- *
+ *
* Format an address in a format suitable for display.
- *
+ *
* Returns a newly allocated string containing the formatted addresses
**/
char *
* camel_address_cat:
* @dest: destination #CamelAddress object
* @source: source #CamelAddress object
- *
+ *
* Concatenate one address onto another. The addresses must
* be of the same type.
- *
+ *
* Returns the number of addresses concatenated
**/
int
* camel_address_copy:
* @dest: destination #CamelAddress object
* @source: source #CamelAddress object
- *
+ *
* Copy the contents of one address into another.
- *
+ *
* Returns the number of addresses copied
**/
int
* camel_address_remove:
* @addr: a #CamelAddress object
* @index: The address to remove, use %-1 to remove all address.
- *
+ *
* Remove an address by index, or all addresses.
**/
void
struct _CamelBlockFilePrivate *prev;
struct _CamelBlockFile *base;
-
+
pthread_mutex_t root_lock; /* for modifying the root block */
pthread_mutex_t cache_lock; /* for refcounting, flag manip, cache manip */
pthread_mutex_t io_lock; /* for all io ops */
-
+
unsigned int deleted:1;
};
CamelBlockRoot *br;
struct stat st;
int retval;
-
+
br = bs->root;
-
+
retval = fstat (bs->fd, &st);
-
+
d(printf("Validate root: '%s'\n", bs->path));
d(printf("version: %.8s (%.8s)\n", bs->root->version, bs->version));
d(printf("block size: %d (%d)%s\n", br->block_size, bs->block_size,
p = bs->priv = g_malloc0(sizeof(*bs->priv));
p->base = bs;
-
+
pthread_mutex_init(&p->root_lock, NULL);
pthread_mutex_init(&p->cache_lock, NULL);
pthread_mutex_init(&p->io_lock, NULL);
-
+
/* link into lru list */
LOCK(block_file_lock);
e_dlist_addhead(&block_file_list, (EDListNode *)p);
bl = bn;
bn = bn->next;
}
-
+
g_hash_table_destroy (bs->blocks);
-
+
if (bs->root_block)
camel_block_file_unref_block(bs, bs->root_block);
g_free(bs->path);
if (bs->fd != -1)
close(bs->fd);
-
+
pthread_mutex_destroy(&p->io_lock);
pthread_mutex_destroy(&p->cache_lock);
pthread_mutex_destroy(&p->root_lock);
-
+
g_free(p);
}
camel_block_file_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_object_get_type(), "CamelBlockFile",
sizeof (CamelBlockFile),
(CamelObjectInitFunc) camel_block_file_init,
(CamelObjectFinalizeFunc) camel_block_file_finalise);
}
-
+
return type;
}
/**
* camel_block_file_new:
- * @path:
- * @:
- * @block_size:
- *
+ * @path:
+ * @:
+ * @block_size:
+ *
* Allocate a new block file, stored at @path. @version contains an 8 character
* version string which must match the head of the file, or the file will be
* intitialised.
- *
+ *
* @block_size is currently ignored and is set to CAMEL_BLOCK_SIZE.
*
* Return value: The new block file, or NULL if it could not be created.
CAMEL_BLOCK_FILE_UNLOCK(bs, io_lock);
return ret;
-
+
}
/**
* camel_block_file_new_block:
- * @bs:
- *
+ * @bs:
+ *
* Allocate a new block, return a pointer to it. Old blocks
* may be flushed to disk during this call.
- *
+ *
* Return value: The block, or NULL if an error occured.
**/
CamelBlock *camel_block_file_new_block(CamelBlockFile *bs)
/**
* camel_block_file_free_block:
- * @bs:
- * @id:
- *
- *
+ * @bs:
+ * @id:
+ *
+ *
**/
int camel_block_file_free_block(CamelBlockFile *bs, camel_block_t id)
{
/**
* camel_block_file_get_block:
- * @bs:
- * @id:
- *
+ * @bs:
+ * @id:
+ *
* Retreive a block @id.
- *
+ *
* Return value: The block, or NULL if blockid is invalid or a file error
* occured.
**/
/**
* camel_block_file_detach_block:
- * @bs:
- * @bl:
- *
+ * @bs:
+ * @bl:
+ *
* Detatch a block from the block file's cache. The block should
* be unref'd or attached when finished with. The block file will
* perform no writes of this block or flushing of it if the cache
/**
* camel_block_file_attach_block:
- * @bs:
- * @bl:
- *
+ * @bs:
+ * @bl:
+ *
* Reattach a block that has been detached.
**/
void camel_block_file_attach_block(CamelBlockFile *bs, CamelBlock *bl)
/**
* camel_block_file_touch_block:
- * @bs:
- * @bl:
- *
+ * @bs:
+ * @bl:
+ *
* Mark a block as dirty. The block will be written to disk if
* it ever expires from the cache.
**/
/**
* camel_block_file_unref_block:
- * @bs:
- * @bl:
- *
+ * @bs:
+ * @bl:
+ *
* Mark a block as unused. If a block is used it will not be
* written to disk, or flushed from memory.
*
/**
* camel_block_file_sync_block:
- * @bs:
- * @bl:
- *
+ * @bs:
+ * @bl:
+ *
* Flush a block to disk immediately. The block will only
* be flushed to disk if it is marked as dirty (touched).
- *
+ *
* Return value: -1 on io error.
**/
int camel_block_file_sync_block(CamelBlockFile *bs, CamelBlock *bl)
/**
* camel_block_file_sync:
- * @bs:
- *
+ * @bs:
+ *
* Sync all dirty blocks to disk, including the root block.
- *
+ *
* Return value: -1 on io error.
**/
int camel_block_file_sync(CamelBlockFile *bs)
p = bs->priv = g_malloc0(sizeof(*bs->priv));
p->base = bs;
-
+
pthread_mutex_init(&p->lock, NULL);
-
+
LOCK(key_file_lock);
e_dlist_addhead(&key_file_list, (EDListNode *)p);
UNLOCK(key_file_lock);
UNLOCK(key_file_lock);
g_free(bs->path);
-
+
pthread_mutex_destroy(&p->lock);
-
+
g_free(p);
}
camel_key_file_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_object_get_type(), "CamelKeyFile",
sizeof (CamelKeyFile),
(CamelObjectInitFunc) camel_key_file_init,
(CamelObjectFinalizeFunc) camel_key_file_finalise);
}
-
+
return type;
}
/**
* camel_key_file_new:
- * @path:
+ * @path:
* @flags: open flags
* @version: Version string (header) of file. Currently
* written but not checked.
- *
+ *
* Create a new key file. A linked list of record blocks.
- *
+ *
* Return value: A new key file, or NULL if the file could not
* be opened/created/initialised.
**/
CAMEL_KEY_FILE_UNLOCK(kf, lock);
return ret;
-
+
}
/**
* camel_key_file_write:
- * @kf:
- * @parent:
- * @len:
- * @records:
- *
+ * @kf:
+ * @parent:
+ * @len:
+ * @records:
+ *
* Write a new list of records to the key file.
- *
+ *
* Return value: -1 on io error. The key file will remain unchanged.
**/
int
/**
* camel_key_file_read:
- * @kf:
+ * @kf:
* @start: The record pointer. This will be set to the next record pointer on success.
* @len: Number of records read, if != NULL.
* @records: Records, allocated, must be freed with g_free, if != NULL.
- *
+ *
* Read the next block of data from the key file. Returns the number of
* records.
- *
+ *
* Return value: -1 on io error.
**/
int
camel_certdb_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_object_get_type (),
"CamelCertDB",
(CamelObjectInitFunc) camel_certdb_init,
(CamelObjectFinalizeFunc) camel_certdb_finalize);
}
-
+
return type;
}
camel_certdb_class_init (CamelCertDBClass *klass)
{
parent_class = camel_type_get_global_classfuncs (camel_object_get_type ());
-
+
klass->header_load = certdb_header_load;
klass->header_save = certdb_header_save;
-
+
klass->cert_new = certdb_cert_new;
klass->cert_load = certdb_cert_load;
klass->cert_save = certdb_cert_save;
camel_certdb_init (CamelCertDB *certdb)
{
certdb->priv = g_malloc (sizeof (struct _CamelCertDBPrivate));
-
+
certdb->filename = NULL;
certdb->version = CAMEL_CERTDB_VERSION;
certdb->saved_certs = 0;
-
+
certdb->cert_size = sizeof (CamelCert);
-
+
certdb->cert_chunks = NULL;
-
+
certdb->certs = g_ptr_array_new ();
certdb->cert_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
+
certdb->priv->db_lock = g_mutex_new ();
certdb->priv->io_lock = g_mutex_new ();
certdb->priv->alloc_lock = g_mutex_new ();
{
CamelCertDB *certdb = (CamelCertDB *) obj;
struct _CamelCertDBPrivate *p;
-
+
p = certdb->priv;
-
+
if (certdb->flags & CAMEL_CERTDB_DIRTY)
camel_certdb_save (certdb);
-
+
camel_certdb_clear (certdb);
g_ptr_array_free (certdb->certs, TRUE);
g_hash_table_destroy (certdb->cert_hash);
-
+
g_free (certdb->filename);
-
+
if (certdb->cert_chunks)
e_memchunk_destroy (certdb->cert_chunks);
-
+
g_mutex_free (p->db_lock);
g_mutex_free (p->io_lock);
g_mutex_free (p->alloc_lock);
g_mutex_free (p->ref_lock);
-
+
g_free (p);
}
camel_certdb_set_default (CamelCertDB *certdb)
{
pthread_mutex_lock (&default_certdb_lock);
-
+
if (default_certdb)
camel_object_unref (default_certdb);
-
+
if (certdb)
camel_object_ref (certdb);
-
+
default_certdb = certdb;
-
+
pthread_mutex_unlock (&default_certdb_lock);
}
camel_certdb_get_default (void)
{
CamelCertDB *certdb;
-
+
pthread_mutex_lock (&default_certdb_lock);
-
+
if (default_certdb)
camel_object_ref (default_certdb);
-
+
certdb = default_certdb;
-
+
pthread_mutex_unlock (&default_certdb_lock);
-
+
return certdb;
}
{
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
g_return_if_fail (filename != NULL);
-
+
CAMEL_CERTDB_LOCK (certdb, db_lock);
-
+
g_free (certdb->filename);
certdb->filename = g_strdup (filename);
-
+
CAMEL_CERTDB_UNLOCK (certdb, db_lock);
}
return -1;
if (camel_file_util_decode_uint32 (istream, &certdb->saved_certs) == -1)
return -1;
-
+
return 0;
}
certdb_cert_load (CamelCertDB *certdb, FILE *istream)
{
CamelCert *cert;
-
+
cert = camel_certdb_cert_new (certdb);
if (camel_file_util_decode_string (istream, &cert->issuer) == -1)
goto error;
if (camel_file_util_decode_uint32 (istream, &cert->trust) == -1)
goto error;
-
+
return cert;
-
+
error:
-
+
camel_certdb_cert_unref (certdb, cert);
-
+
return NULL;
}
CamelCert *cert;
FILE *in;
int i;
-
+
g_return_val_if_fail (CAMEL_IS_CERTDB (certdb), -1);
g_return_val_if_fail (certdb->filename, -1);
in = g_fopen (certdb->filename, "rb");
if (in == NULL)
return -1;
-
+
CAMEL_CERTDB_LOCK (certdb, io_lock);
if (CAMEL_CERTDB_GET_CLASS (certdb)->header_load (certdb, in) == -1)
goto error;
-
+
for (i = 0; i < certdb->saved_certs; i++) {
cert = CAMEL_CERTDB_GET_CLASS (certdb)->cert_load (certdb, in);
-
+
if (cert == NULL)
goto error;
-
+
camel_certdb_add (certdb, cert);
}
-
+
CAMEL_CERTDB_UNLOCK (certdb, io_lock);
-
+
if (fclose (in) != 0)
return -1;
-
+
certdb->flags &= ~CAMEL_CERTDB_DIRTY;
-
+
return 0;
-
+
error:
-
+
g_warning ("Cannot load certificate database: %s", strerror (ferror (in)));
-
+
CAMEL_CERTDB_UNLOCK (certdb, io_lock);
-
+
fclose (in);
-
+
return -1;
}
return -1;
if (camel_file_util_encode_uint32 (ostream, certdb->saved_certs) == -1)
return -1;
-
+
return 0;
}
return -1;
if (camel_file_util_encode_uint32 (ostream, cert->trust) == -1)
return -1;
-
+
return 0;
}
char *filename;
int fd, i;
FILE *out;
-
+
g_return_val_if_fail (CAMEL_IS_CERTDB (certdb), -1);
g_return_val_if_fail (certdb->filename, -1);
-
+
filename = alloca (strlen (certdb->filename) + 4);
sprintf (filename, "%s~", certdb->filename);
-
+
fd = g_open (filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0600);
if (fd == -1)
return -1;
-
+
out = fdopen (fd, "wb");
if (out == NULL) {
i = errno;
errno = i;
return -1;
}
-
+
CAMEL_CERTDB_LOCK (certdb, io_lock);
-
+
certdb->saved_certs = certdb->certs->len;
if (CAMEL_CERTDB_GET_CLASS (certdb)->header_save (certdb, out) == -1)
goto error;
-
+
for (i = 0; i < certdb->saved_certs; i++) {
cert = (CamelCert *) certdb->certs->pdata[i];
-
+
if (CAMEL_CERTDB_GET_CLASS (certdb)->cert_save (certdb, cert, out) == -1)
goto error;
}
-
+
CAMEL_CERTDB_UNLOCK (certdb, io_lock);
-
+
if (fflush (out) != 0 || fsync (fileno (out)) == -1) {
i = errno;
fclose (out);
errno = i;
return -1;
}
-
+
if (fclose (out) != 0) {
i = errno;
g_unlink (filename);
errno = i;
return -1;
}
-
+
if (g_rename (filename, certdb->filename) == -1) {
i = errno;
g_unlink (filename);
errno = i;
return -1;
}
-
+
certdb->flags &= ~CAMEL_CERTDB_DIRTY;
-
+
return 0;
-
+
error:
-
+
g_warning ("Cannot save certificate database: %s", strerror (ferror (out)));
-
+
CAMEL_CERTDB_UNLOCK (certdb, io_lock);
-
+
i = errno;
fclose (out);
g_unlink (filename);
errno = i;
-
+
return -1;
}
camel_certdb_touch (CamelCertDB *certdb)
{
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
-
+
certdb->flags |= CAMEL_CERTDB_DIRTY;
}
camel_certdb_get_cert (CamelCertDB *certdb, const char *fingerprint)
{
CamelCert *cert;
-
+
g_return_val_if_fail (CAMEL_IS_CERTDB (certdb), NULL);
-
+
CAMEL_CERTDB_LOCK (certdb, db_lock);
-
+
cert = g_hash_table_lookup (certdb->cert_hash, fingerprint);
if (cert)
camel_certdb_cert_ref (certdb, cert);
-
+
CAMEL_CERTDB_UNLOCK (certdb, db_lock);
-
+
return cert;
}
camel_certdb_add (CamelCertDB *certdb, CamelCert *cert)
{
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
-
+
CAMEL_CERTDB_LOCK (certdb, db_lock);
-
+
if (g_hash_table_lookup (certdb->cert_hash, cert->fingerprint)) {
CAMEL_CERTDB_UNLOCK (certdb, db_lock);
return;
}
-
+
camel_certdb_cert_ref (certdb, cert);
g_ptr_array_add (certdb->certs, cert);
g_hash_table_insert (certdb->cert_hash, cert->fingerprint, cert);
-
+
certdb->flags |= CAMEL_CERTDB_DIRTY;
-
+
CAMEL_CERTDB_UNLOCK (certdb, db_lock);
}
camel_certdb_remove (CamelCertDB *certdb, CamelCert *cert)
{
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
-
+
CAMEL_CERTDB_LOCK (certdb, db_lock);
-
+
if (g_hash_table_lookup (certdb->cert_hash, cert->fingerprint)) {
g_hash_table_remove (certdb->cert_hash, cert->fingerprint);
g_ptr_array_remove (certdb->certs, cert);
camel_certdb_cert_unref (certdb, cert);
-
+
certdb->flags |= CAMEL_CERTDB_DIRTY;
}
-
+
CAMEL_CERTDB_UNLOCK (certdb, db_lock);
}
certdb_cert_new (CamelCertDB *certdb)
{
CamelCert *cert;
-
+
if (certdb->cert_chunks)
cert = e_memchunk_alloc0 (certdb->cert_chunks);
else
cert = g_malloc0 (certdb->cert_size);
-
+
cert->refcount = 1;
-
+
return cert;
}
camel_certdb_cert_new (CamelCertDB *certdb)
{
CamelCert *cert;
-
+
g_return_val_if_fail (CAMEL_IS_CERTDB (certdb), NULL);
-
+
CAMEL_CERTDB_LOCK (certdb, alloc_lock);
-
+
cert = CAMEL_CERTDB_GET_CLASS (certdb)->cert_new (certdb);
-
+
CAMEL_CERTDB_UNLOCK (certdb, alloc_lock);
-
+
return cert;
}
{
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
g_return_if_fail (cert != NULL);
-
+
CAMEL_CERTDB_LOCK (certdb, ref_lock);
cert->refcount++;
CAMEL_CERTDB_UNLOCK (certdb, ref_lock);
{
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
g_return_if_fail (cert != NULL);
-
+
CAMEL_CERTDB_LOCK (certdb, ref_lock);
-
+
if (cert->refcount <= 1) {
CAMEL_CERTDB_GET_CLASS (certdb)->cert_free (certdb, cert);
if (certdb->cert_chunks)
} else {
cert->refcount--;
}
-
+
CAMEL_CERTDB_UNLOCK (certdb, ref_lock);
}
{
CamelCert *cert;
int i;
-
+
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
-
+
CAMEL_CERTDB_LOCK (certdb, db_lock);
-
+
g_hash_table_foreach_remove (certdb->cert_hash, cert_remove, NULL);
for (i = 0; i < certdb->certs->len; i++) {
cert = (CamelCert *) certdb->certs->pdata[i];
camel_certdb_cert_unref (certdb, cert);
}
-
+
certdb->saved_certs = 0;
g_ptr_array_set_size (certdb->certs, 0);
certdb->flags |= CAMEL_CERTDB_DIRTY;
-
+
CAMEL_CERTDB_UNLOCK (certdb, db_lock);
}
{
g_return_val_if_fail (CAMEL_IS_CERTDB (certdb), NULL);
g_return_val_if_fail (cert != NULL, NULL);
-
+
/* FIXME: do locking? */
-
+
return CAMEL_CERTDB_GET_CLASS (certdb)->cert_get_string (certdb, cert, string);
}
{
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
g_return_if_fail (cert != NULL);
-
+
/* FIXME: do locking? */
-
+
CAMEL_CERTDB_GET_CLASS (certdb)->cert_set_string (certdb, cert, string, value);
}
{
g_return_val_if_fail (CAMEL_IS_CERTDB (certdb), CAMEL_CERT_TRUST_UNKNOWN);
g_return_val_if_fail (cert != NULL, CAMEL_CERT_TRUST_UNKNOWN);
-
+
return cert->trust;
}
{
g_return_if_fail (CAMEL_IS_CERTDB (certdb));
g_return_if_fail (cert != NULL);
-
+
cert->trust = trust;
}
typedef struct {
guint32 refcount;
-
+
char *issuer;
char *subject;
char *hostname;
char *fingerprint;
-
+
CamelCertTrust trust;
GByteArray *rawcert;
} CamelCert;
struct _CamelCertDB {
CamelObject parent_object;
struct _CamelCertDBPrivate *priv;
-
+
char *filename;
guint32 version;
guint32 saved_certs;
guint32 flags;
-
+
guint32 cert_size;
-
+
struct _EMemChunk *cert_chunks;
-
+
GPtrArray *certs;
GHashTable *cert_hash;
};
struct _CamelCertDBClass {
CamelObjectClass parent_class;
-
+
int (*header_load) (CamelCertDB *certdb, FILE *istream);
int (*header_save) (CamelCertDB *certdb, FILE *ostream);
-
+
CamelCert * (*cert_load) (CamelCertDB *certdb, FILE *istream);
int (*cert_save) (CamelCertDB *certdb, CamelCert *cert, FILE *ostream);
-
+
CamelCert * (*cert_new) (CamelCertDB *certdb);
void (*cert_free) (CamelCertDB *certdb, CamelCert *cert);
-
+
const char * (*cert_get_string) (CamelCertDB *certdb, CamelCert *cert, int string);
void (*cert_set_string) (CamelCertDB *certdb, CamelCert *cert, int string, const char *value);
};
/* This file is automatically generated: DO NOT EDIT */
static const unsigned char m000[256] = {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xbf, 0xbf, 0xbf, 0xbf,
- 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf,
- 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf,
- 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf,
- 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0x9f, 0x9f, 0x9f,
- 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3,
- 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3,
- 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3,
- 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3,
- 0xff, 0x80, 0xc0, 0xe0, 0xc3, 0xc0, 0xe0, 0xf3,
- 0xe3, 0xec, 0x80, 0xe0, 0xe0, 0xf3, 0xc0, 0xc2,
- 0xef, 0xe0, 0xec, 0xe0, 0xc3, 0xc0, 0xc0, 0xec,
- 0xc3, 0xc0, 0x80, 0xe0, 0xc0, 0xe0, 0xc0, 0x80,
- 0x80, 0x83, 0x83, 0x82, 0x83, 0x82, 0x82, 0x81,
- 0x80, 0x83, 0x80, 0x83, 0x80, 0x83, 0x83, 0x80,
- 0x00, 0x80, 0x80, 0x81, 0x83, 0x82, 0x83, 0xc3,
- 0x82, 0x80, 0x83, 0x82, 0x83, 0x01, 0x00, 0x83,
- 0x80, 0x83, 0x83, 0x82, 0x83, 0x82, 0x82, 0x81,
- 0x80, 0x83, 0x80, 0x83, 0x80, 0x83, 0x83, 0x80,
- 0x00, 0x80, 0x80, 0x81, 0x83, 0x82, 0x83, 0xcf,
- 0x82, 0x80, 0x83, 0x82, 0x83, 0x01, 0x00, 0x80,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xbf, 0xbf, 0xbf, 0xbf,
+ 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf,
+ 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf,
+ 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf,
+ 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0x9f, 0x9f, 0x9f,
+ 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3,
+ 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3,
+ 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3,
+ 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3,
+ 0xff, 0x80, 0xc0, 0xe0, 0xc3, 0xc0, 0xe0, 0xf3,
+ 0xe3, 0xec, 0x80, 0xe0, 0xe0, 0xf3, 0xc0, 0xc2,
+ 0xef, 0xe0, 0xec, 0xe0, 0xc3, 0xc0, 0xc0, 0xec,
+ 0xc3, 0xc0, 0x80, 0xe0, 0xc0, 0xe0, 0xc0, 0x80,
+ 0x80, 0x83, 0x83, 0x82, 0x83, 0x82, 0x82, 0x81,
+ 0x80, 0x83, 0x80, 0x83, 0x80, 0x83, 0x83, 0x80,
+ 0x00, 0x80, 0x80, 0x81, 0x83, 0x82, 0x83, 0xc3,
+ 0x82, 0x80, 0x83, 0x82, 0x83, 0x01, 0x00, 0x83,
+ 0x80, 0x83, 0x83, 0x82, 0x83, 0x82, 0x82, 0x81,
+ 0x80, 0x83, 0x80, 0x83, 0x80, 0x83, 0x83, 0x80,
+ 0x00, 0x80, 0x80, 0x81, 0x83, 0x82, 0x83, 0xcf,
+ 0x82, 0x80, 0x83, 0x82, 0x83, 0x01, 0x00, 0x80,
};
static const unsigned char m001[256] = {
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x07, 0x02, 0x03, 0x03, 0x05, 0x02, 0x05, 0x07,
- 0x00, 0x07, 0x02, 0x07, 0x07, 0x07, 0x07, 0x02,
- 0x07, 0x07, 0x03, 0x03, 0x00, 0x07, 0x07, 0x07,
- 0x00, 0x03, 0x02, 0x07, 0x01, 0x01, 0x01, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x02,
- 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x03,
- 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03,
- 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x02,
- 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x03,
- 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x07, 0x02, 0x03, 0x03, 0x05, 0x02, 0x05, 0x07,
+ 0x00, 0x07, 0x02, 0x07, 0x07, 0x07, 0x07, 0x02,
+ 0x07, 0x07, 0x03, 0x03, 0x00, 0x07, 0x07, 0x07,
+ 0x00, 0x03, 0x02, 0x07, 0x01, 0x01, 0x01, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x02,
+ 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x03,
+ 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03,
+ 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x02,
+ 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x03,
+ 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02,
};
static const unsigned char m010[256] = {
- 0x02, 0x02, 0x01, 0x01, 0x03, 0x03, 0x01, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x01, 0x01,
- 0x03, 0x03, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02,
- 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x80, 0x80,
- 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02,
- 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x00,
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01,
- 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00,
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02,
- 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x81, 0x81,
- 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01,
- 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x01, 0x01, 0x03, 0x03, 0x01, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x01, 0x01,
+ 0x03, 0x03, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02,
+ 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x80, 0x80,
+ 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02,
+ 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x00,
+ 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01,
+ 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00,
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02,
+ 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x81, 0x81,
+ 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01,
+ 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m011[256] = {
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01,
- 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
- 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01,
- 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01,
+ 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
+ 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01,
+ 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m020[256] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x03, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x03, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m030[256] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x00,
- 0x20, 0x20, 0x20, 0x00, 0x20, 0x00, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x00,
+ 0x20, 0x20, 0x20, 0x00, 0x20, 0x00, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m040[256] = {
- 0x00, 0x1c, 0x10, 0x10, 0x18, 0x10, 0x18, 0x18,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10,
- 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
- 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
- 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
- 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
- 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
- 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
- 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
- 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
- 0x00, 0x1c, 0x10, 0x10, 0x18, 0x10, 0x18, 0x18,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x1c, 0x10, 0x10, 0x18, 0x10, 0x18, 0x18,
+ 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10,
+ 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
+ 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
+ 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
+ 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
+ 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
+ 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
+ 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
+ 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
+ 0x00, 0x1c, 0x10, 0x10, 0x18, 0x10, 0x18, 0x18,
+ 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m041[256] = {
- 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04, 0x04,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04, 0x04,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m050[256] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
- 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
+ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
+ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
+ 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m200[256] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x40,
- 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x40,
+ 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m201[256] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x00,
- 0x04, 0x05, 0x04, 0x00, 0x05, 0x05, 0x05, 0x00,
- 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x00,
+ 0x04, 0x05, 0x04, 0x00, 0x05, 0x05, 0x05, 0x00,
+ 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m210[256] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m211[256] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m220[256] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m230[256] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char m250[256] = {
- 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0c, 0x0c, 0x0c, 0x04, 0x0c, 0x04, 0x04, 0x0c,
- 0x0c, 0x0c, 0x0c, 0x0c, 0x04, 0x0c, 0x0c, 0x0c,
- 0x0c, 0x0c, 0x04, 0x0c, 0x04, 0x04, 0x0c, 0x0c,
- 0x0c, 0x0c, 0x0c, 0x04, 0x0c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
- 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x0c, 0x0c, 0x04, 0x0c, 0x04, 0x04, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x04, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x04, 0x0c, 0x04, 0x04, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x04, 0x0c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const struct {
const unsigned char *bits0;
const unsigned char *bits1;
} camel_charmap[256] = {
- { m000, m001, }, { m010, m011, }, { m020, NULL, }, { m030, NULL, }, { m040, m041, }, { m050, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { m200, m201, }, { m210, m211, }, { m220, NULL, }, { m230, NULL, }, { NULL, NULL, }, { m250, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
- { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { m000, m001, }, { m010, m011, }, { m020, NULL, }, { m030, NULL, }, { m040, m041, }, { m050, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { m200, m201, }, { m210, m211, }, { m220, NULL, }, { m230, NULL, }, { NULL, NULL, }, { m250, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
+ { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, }, { NULL, NULL, },
};
static const struct {
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; -*- */
-/*
+/*
* Authors:
* Michael Zucchi <notzed@ximian.com>
* Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright 2000-2003 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/*
if you want to build the charset map, compile this with something like:
gcc -DBUILD_MAP camel-charset-map.c `glib-config --cflags`
- (plus any -I/-L/-l flags you need for iconv), then run it as
+ (plus any -I/-L/-l flags you need for iconv), then run it as
./a.out > camel-charset-map-private.h
Note that the big-endian variant isn't tested...
printf("\t\\\n");
}
printf("\n\n");
-
+
return 0;
}
register unsigned int mask;
register int level;
register guint32 c;
-
+
mask = cc->mask;
level = cc->level;
-
+
/* check what charset a given string will fit in */
while ((c = camel_utf8_getc_limit(&inptr, inend)) != 0xffff) {
if (c < 0xffff) {
mask &= charset_mask(c);
-
+
if (c>=128 && c<256)
level = MAX(level, 1);
else if (c>=256)
break;
}
}
-
+
cc->mask = mask;
cc->level = level;
}
{
const char *locale_lang, *lang;
int i;
-
+
locale_lang = e_iconv_locale_language ();
for (i = 0; i < G_N_ELEMENTS (camel_charinfo); i++) {
if (camel_charinfo[i].bit & mask) {
lang = e_iconv_charset_language (camel_charinfo[i].name);
-
+
if (!locale_lang || (lang && !strncmp (locale_lang, lang, 2)))
return camel_charinfo[i].name;
}
}
-
+
return "UTF-8";
}
* iso-8859-13 are Baltic that it also maps to
* windows-cp1257.
*/
-
+
if (!g_ascii_strcasecmp (isocharset, "iso-8859-1") || !g_ascii_strcasecmp (isocharset, "us-ascii"))
return "windows-cp1252";
else if (!g_ascii_strcasecmp (isocharset, "iso-8859-2"))
return "windows-cp1254";
else if (!g_ascii_strcasecmp (isocharset, "iso-8859-13"))
return "windows-cp1257";
-
+
return isocharset;
}
camel_cipher_context_new (CamelSession *session)
{
CamelCipherContext *context;
-
+
g_return_val_if_fail (session != NULL, NULL);
-
+
context = CAMEL_CIPHER_CONTEXT (camel_object_new (CAMEL_CIPHER_CONTEXT_TYPE));
-
+
camel_object_ref (session);
context->session = session;
-
+
return context;
}
{
g_return_if_fail (CAMEL_IS_CIPHER_CONTEXT (context));
g_return_if_fail (CAMEL_IS_SESSION (session));
-
+
camel_object_ref (session);
context->session = session;
}
struct _CamelMimePart *ipart, struct _CamelMimePart *opart, CamelException *ex)
{
int retval;
-
+
g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), -1);
camel_operation_start(NULL, _("Signing message"));
CIPHER_LOCK(context);
-
+
retval = CCC_CLASS (context)->sign (context, userid, hash, ipart, opart, ex);
-
+
CIPHER_UNLOCK(context);
camel_operation_end(NULL);
camel_cipher_verify (CamelCipherContext *context, struct _CamelMimePart *ipart, CamelException *ex)
{
CamelCipherValidity *valid;
-
+
g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), NULL);
-
+
camel_operation_start(NULL, _("Verifying message"));
CIPHER_LOCK(context);
-
+
valid = CCC_CLASS (context)->verify (context, ipart, ex);
-
+
CIPHER_UNLOCK(context);
camel_operation_end(NULL);
-
+
return valid;
}
struct _CamelMimePart *ipart, struct _CamelMimePart *opart, CamelException *ex)
{
int retval;
-
+
g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), -1);
camel_operation_start(NULL, _("Encrypting message"));
-
+
CIPHER_LOCK(context);
-
+
retval = CCC_CLASS (context)->encrypt (context, userid, recipients, ipart, opart, ex);
-
+
CIPHER_UNLOCK(context);
camel_operation_end(NULL);
-
+
return retval;
}
/**
* camel_cipher_decrypt:
- * @context:
- * @ipart:
- * @opart:
- * @ex:
- *
+ * @context:
+ * @ipart:
+ * @opart:
+ * @ex:
+ *
* Decrypts @ipart into @opart.
- *
+ *
* Return value: A validity/encryption status.
**/
CamelCipherValidity *
g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), NULL);
camel_operation_start(NULL, _("Decrypting message"));
-
+
CIPHER_LOCK(context);
-
+
valid = CCC_CLASS (context)->decrypt (context, ipart, opart, ex);
-
+
CIPHER_UNLOCK(context);
camel_operation_end(NULL);
-
+
return valid;
}
{
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("You may not import keys with this cipher"));
-
+
return -1;
}
{
g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), -1);
g_return_val_if_fail (CAMEL_IS_STREAM (istream), -1);
-
+
return CCC_CLASS (context)->import_keys (context, istream, ex);
}
{
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("You may not export keys with this cipher"));
-
+
return -1;
}
g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), -1);
g_return_val_if_fail (CAMEL_IS_STREAM (ostream), -1);
g_return_val_if_fail (keys != NULL, -1);
-
+
return CCC_CLASS (context)->export_keys (context, keys, ostream, ex);
}
camel_cipher_id_to_hash(CamelCipherContext *context, const char *id)
{
g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), CAMEL_CIPHER_HASH_DEFAULT);
-
+
return CCC_CLASS (context)->id_to_hash (context, id);
}
camel_cipher_hash_to_id(CamelCipherContext *context, CamelCipherHash hash)
{
g_return_val_if_fail (CAMEL_IS_CIPHER_CONTEXT (context), NULL);
-
+
return CCC_CLASS (context)->hash_to_id (context, hash);
}
camel_cipher_validity_new (void)
{
CamelCipherValidity *validity;
-
+
validity = g_malloc(sizeof(*validity));
camel_cipher_validity_init(validity);
camel_cipher_validity_set_valid (CamelCipherValidity *validity, gboolean valid)
{
g_assert (validity != NULL);
-
+
validity->sign.status = valid?CAMEL_CIPHER_VALIDITY_SIGN_GOOD:CAMEL_CIPHER_VALIDITY_SIGN_BAD;
}
{
if (validity == NULL)
return NULL;
-
+
return validity->sign.description;
}
camel_cipher_validity_set_description (CamelCipherValidity *validity, const gchar *description)
{
g_assert (validity != NULL);
-
+
g_free(validity->sign.description);
validity->sign.description = g_strdup(description);
}
/**
* camel_cipher_validity_add_certinfo:
- * @vin:
- * @mode:
- * @name:
- * @email:
- *
+ * @vin:
+ * @mode:
+ * @name:
+ * @email:
+ *
* Add a cert info to the signer or encrypter info.
**/
void
* camel_cipher_validity_envelope:
* @parent:
* @valid:
- *
+ *
* Calculate a conglomerate validity based on wrapping one secure part inside
* another one.
**/
camel_cipher_context_finalise (CamelObject *o)
{
CamelCipherContext *context = (CamelCipherContext *)o;
-
+
camel_object_unref (CAMEL_OBJECT (context->session));
-
+
g_mutex_free (context->priv->lock);
-
+
g_free (context->priv);
}
camel_cipher_context_class_init (CamelCipherContextClass *camel_cipher_context_class)
{
parent_class = camel_type_get_global_classfuncs (camel_object_get_type ());
-
+
camel_cipher_context_class->hash_to_id = cipher_hash_to_id;
camel_cipher_context_class->id_to_hash = cipher_id_to_hash;
camel_cipher_context_class->sign = cipher_sign;
camel_cipher_context_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_object_get_type (),
"CamelCipherContext",
(CamelObjectInitFunc) camel_cipher_context_init,
(CamelObjectFinalizeFunc) camel_cipher_context_finalise);
}
-
+
return type;
}
CamelDataWrapper *dw;
CamelTransferEncoding encoding;
int parts, i;
-
+
dw = camel_medium_get_content_object((CamelMedium *)part);
if (!dw)
return;
-
+
if (CAMEL_IS_MULTIPART (dw)) {
parts = camel_multipart_get_number((CamelMultipart *)dw);
for (i = 0; i < parts; i++)
* @part: Part to write.
* @flags: flags for the canonicalisation filter (CamelMimeFilterCanon)
* @ostream: stream to write canonicalised output to.
- *
+ *
* Writes a part to a stream in a canonicalised format, suitable for signing/encrypting.
*
* The transfer encoding paramaters for the part may be changed by this function.
- *
+ *
* Return value: -1 on error;
**/
int
typedef struct _CamelCipherContext {
CamelObject parent_object;
-
+
struct _CamelCipherContextPrivate *priv;
-
+
CamelSession *session;
-
+
/* these MUST be set by implementors */
const char *sign_protocol;
const char *encrypt_protocol;
typedef struct _CamelCipherContextClass {
CamelObjectClass parent_class;
-
+
CamelCipherHash (*id_to_hash)(CamelCipherContext *context, const char *id);
const char * (*hash_to_id)(CamelCipherContext *context, CamelCipherHash hash);
-
+
int (*sign) (CamelCipherContext *context, const char *userid, CamelCipherHash hash,
struct _CamelMimePart *ipart, struct _CamelMimePart *opart, CamelException *ex);
-
+
CamelCipherValidity * (*verify) (CamelCipherContext *context, struct _CamelMimePart *ipart, CamelException *ex);
-
+
int (*encrypt) (CamelCipherContext *context, const char *userid,
GPtrArray *recipients, struct _CamelMimePart *ipart, struct _CamelMimePart *opart,
CamelException *ex);
-
+
CamelCipherValidity *(*decrypt) (CamelCipherContext *context, struct _CamelMimePart *ipart, struct _CamelMimePart *opart,
CamelException *ex);
-
+
int (*import_keys) (CamelCipherContext *context, struct _CamelStream *istream,
CamelException *ex);
-
+
int (*export_keys) (CamelCipherContext *context, GPtrArray *keys,
struct _CamelStream *ostream, CamelException *ex);
} CamelCipherContextClass;
*
* Copyright (C) 2001 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
p = cdc->priv;
camel_object_bag_destroy(p->busy_bag);
g_free(p);
-
+
g_free (cdc->path);
}
camel_data_cache_get_type(void)
{
static CamelType camel_data_cache_type = CAMEL_INVALID_TYPE;
-
+
if (camel_data_cache_type == CAMEL_INVALID_TYPE) {
camel_data_cache_type = camel_type_register(
CAMEL_OBJECT_TYPE, "CamelDataCache",
* camel_data_cache_new:
* @path: Base path of cache, subdirectories will be created here.
* @flags: Open flags, none defined.
- * @ex:
- *
+ * @ex:
+ *
* Create a new data cache.
- *
+ *
* Return value: A new cache object, or NULL if the base path cannot
* be written to.
**/
* camel_data_cache_set_expire_age:
* @cdc: A #CamelDataCache
* @when: Timeout for age expiry, or -1 to disable.
- *
+ *
* Set the cache expiration policy for aged entries.
- *
+ *
* Items in the cache older than @when seconds may be
* flushed at any time. Items are expired in a lazy
* manner, so it is indeterminate when the items will
* camel_data_cache_set_expire_access:
* @cdc: A #CamelDataCache
* @when: Timeout for access, or -1 to disable access expiry.
- *
+ *
* Set the cache expiration policy for access times.
*
* Items in the cache which haven't been accessed for @when
while ( (dname = g_dir_read_name(dir)) ) {
if (strcmp(dname, keep) == 0)
continue;
-
+
g_string_printf (s, "%s/%s", path, dname);
dd(printf("Checking '%s' for expiry\n", s->str));
if (g_stat(s->str, &st) == 0
hash = (hash>>5)&CAMEL_DATA_CACHE_MASK;
dir = alloca(strlen(cdc->path) + strlen(path) + 8);
sprintf(dir, "%s/%s/%02x", cdc->path, path, hash);
-
-#ifdef G_OS_WIN32
+
+#ifdef G_OS_WIN32
if (g_access(dir, F_OK) == -1) {
#else
if (access (dir, F_OK) == -1) {
* @cdc: A #CamelDataCache
* @path: Relative path of item to add.
* @key: Key of item to add.
- * @ex:
- *
+ * @ex:
+ *
* Add a new item to the cache.
*
* The key and the path combine to form a unique key used to store
* the item.
- *
+ *
* Potentially, expiry processing will be performed while this call
* is executing.
*
* @cdc: A #CamelDataCache
* @path: Path to the (sub) cache the item exists in.
* @key: Key for the cache item.
- * @ex:
- *
+ * @ex:
+ *
* Lookup an item in the cache. If the item exists, a stream
* is returned for the item. The stream may be shared by
* multiple callers, so ensure the stream is in a valid state
* through external locking.
- *
+ *
* Return value: A cache item, or NULL if the cache item does not exist.
**/
CamelStream *
/**
* camel_data_cache_remove:
* @cdc: A #CamelDataCache
- * @path:
- * @key:
- * @ex:
- *
+ * @path:
+ * @key:
+ * @ex:
+ *
* Remove/expire a cache item.
- *
- * Return value:
+ *
+ * Return value:
**/
int
camel_data_cache_remove(CamelDataCache *cdc, const char *path, const char *key, CamelException *ex)
/**
* camel_data_cache_rename:
- * @cache:
- * @old:
- * @new:
- * @ex:
- *
+ * @cache:
+ * @old:
+ * @new:
+ * @ex:
+ *
* Rename a cache path. All cache items accessed from the old path
* are accessible using the new path.
*
* CURRENTLY UNIMPLEMENTED
- *
+ *
* Return value: -1 on error.
**/
int camel_data_cache_rename(CamelDataCache *cache,
/**
* camel_data_cache_clear:
- * @cache:
+ * @cache:
* @path: Path to clear, or NULL to clear all items in
* all paths.
- * @ex:
- *
+ * @ex:
+ *
* Clear all items in a given cache path or all items in the cache.
- *
+ *
* CURRENTLY_UNIMPLEMENTED
*
* Return value: -1 on error.
*
* Copyright (C) 2001 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
camel_data_wrapper_init (gpointer object, gpointer klass)
{
CamelDataWrapper *camel_data_wrapper = CAMEL_DATA_WRAPPER (object);
-
+
camel_data_wrapper->priv = g_malloc (sizeof (struct _CamelDataWrapperPrivate));
pthread_mutex_init (&camel_data_wrapper->priv->stream_lock, NULL);
-
+
camel_data_wrapper->mime_type = camel_content_type_new ("application", "octet-stream");
camel_data_wrapper->encoding = CAMEL_TRANSFER_ENCODING_DEFAULT;
camel_data_wrapper->offline = FALSE;
camel_data_wrapper_finalize (CamelObject *object)
{
CamelDataWrapper *camel_data_wrapper = CAMEL_DATA_WRAPPER (object);
-
+
pthread_mutex_destroy (&camel_data_wrapper->priv->stream_lock);
-
+
g_free (camel_data_wrapper->priv);
-
+
if (camel_data_wrapper->mime_type)
camel_content_type_unref (camel_data_wrapper->mime_type);
-
+
if (camel_data_wrapper->stream)
camel_object_unref (camel_data_wrapper->stream);
}
camel_data_wrapper_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (CAMEL_OBJECT_TYPE,
"CamelDataWrapper",
(CamelObjectInitFunc) camel_data_wrapper_init,
(CamelObjectFinalizeFunc) camel_data_wrapper_finalize);
}
-
+
return type;
}
write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
ssize_t ret;
-
+
if (data_wrapper->stream == NULL) {
return -1;
}
-
+
CAMEL_DATA_WRAPPER_LOCK (data_wrapper, stream_lock);
if (camel_stream_reset (data_wrapper->stream) == -1) {
CAMEL_DATA_WRAPPER_UNLOCK (data_wrapper, stream_lock);
return -1;
}
-
+
ret = camel_stream_write_to_stream (data_wrapper->stream, stream);
-
+
CAMEL_DATA_WRAPPER_UNLOCK (data_wrapper, stream_lock);
-
+
return ret;
}
CamelMimeFilter *filter;
CamelStream *fstream;
ssize_t ret;
-
+
fstream = (CamelStream *) camel_stream_filter_new_with_stream (stream);
-
+
switch (data_wrapper->encoding) {
case CAMEL_TRANSFER_ENCODING_BASE64:
filter = (CamelMimeFilter *) camel_mime_filter_basic_new_type (CAMEL_MIME_FILTER_BASIC_BASE64_DEC);
default:
break;
}
-
+
if (camel_content_type_is (data_wrapper->mime_type, "text", "*")) {
filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_DECODE,
CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
camel_stream_filter_add (CAMEL_STREAM_FILTER (fstream), filter);
camel_object_unref (filter);
}
-
+
ret = camel_data_wrapper_write_to_stream (data_wrapper, fstream);
camel_stream_flush (fstream);
camel_object_unref (fstream);
-
+
return ret;
}
{
g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), -1);
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
-
+
return CDW_CLASS (data_wrapper)->decode_to_stream (data_wrapper, stream);
}
{
if (data_wrapper->stream)
camel_object_unref (data_wrapper->stream);
-
+
data_wrapper->stream = stream;
camel_object_ref (stream);
return 0;
{
g_return_val_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper), -1);
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
-
+
return CDW_CLASS (data_wrapper)->construct_from_stream (data_wrapper, stream);
}
struct _CamelDataWrapper {
CamelObject parent_object;
struct _CamelDataWrapperPrivate *priv;
-
+
CamelTransferEncoding encoding;
-
+
CamelContentType *mime_type;
CamelStream *stream;
-
+
unsigned int offline:1;
};
typedef struct {
CamelObjectClass parent_class;
-
+
/* Virtual methods */
void (*set_mime_type) (CamelDataWrapper *data_wrapper,
const char *mime_type);
CamelContentType * (*get_mime_type_field) (CamelDataWrapper *data_wrapper);
void (*set_mime_type_field) (CamelDataWrapper *data_wrapper,
CamelContentType *mime_type_field);
-
+
ssize_t (*write_to_stream) (CamelDataWrapper *data_wrapper,
CamelStream *stream);
-
+
ssize_t (*decode_to_stream) (CamelDataWrapper *data_wrapper,
CamelStream *stream);
-
+
int (*construct_from_stream) (CamelDataWrapper *data_wrapper,
CamelStream *);
-
+
gboolean (*is_offline) (CamelDataWrapper *data_wrapper);
} CamelDataWrapperClass;
*
* Copyright 2004 Novell Inc. (www.novell.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/**
* camel_debug_init:
- * @void:
- *
+ * @void:
+ *
* Init camel debug. Maintain legacy CAMEL_VERBOSE_DEBUG as well as the
* new CAMEL_DEBUG based environment variable interfaces.
*
/**
* camel_debug:
- * @mode:
- *
+ * @mode:
+ *
* Check to see if a debug mode is activated. @mode takes one of two forms,
* a fully qualified 'module:target', or a wildcard 'module' name. It
* returns a boolean to indicate if the module or module and target is
* currently activated for debug output.
- *
- * Return value:
+ *
+ * Return value:
**/
gboolean camel_debug(const char *mode)
{
/* Now check ':subsystem' */
*colon = ':';
if (g_hash_table_lookup(debug_table, colon))
- return TRUE;
+ return TRUE;
}
}
/**
* camel_debug_start:
* @mode:
- *
+ *
* Start debug output for a given mode, used to make sure debug output
* is output atomically and not interspersed with unrelated stuff.
*
/**
* camel_debug_end:
- *
+ *
* Call this when you're done with your debug output. If and only if
* you called camel_debug_start, and if it returns TRUE.
**/
*
* Copyright 2004 Novell Inc. (www.novell.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
camel_digest_folder_class_init (CamelDigestFolderClass *camel_digest_folder_class)
{
CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_digest_folder_class);
-
+
parent_class = CAMEL_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_folder_get_type ()));
-
+
/* virtual method definition */
-
+
/* virtual method overload */
camel_folder_class->refresh_info = digest_refresh_info;
camel_folder_class->sync = digest_sync;
camel_folder_class->expunge = digest_expunge;
camel_folder_class->get_full_name = digest_get_full_name;
-
+
camel_folder_class->get_message = digest_get_message;
camel_folder_class->append_message = digest_append_message;
camel_folder_class->transfer_messages_to = digest_transfer_messages_to;
-
+
camel_folder_class->search_by_expression = digest_search_by_expression;
camel_folder_class->search_by_uids = digest_search_by_uids;
camel_folder_class->search_free = digest_search_free;
{
CamelDigestFolder *digest_folder = CAMEL_DIGEST_FOLDER (object);
CamelFolder *folder = CAMEL_FOLDER (object);
-
+
folder->folder_flags |= CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY | CAMEL_FOLDER_HAS_SEARCH_CAPABILITY;
-
+
folder->summary = camel_digest_summary_new ();
-
+
digest_folder->priv = g_new (struct _CamelDigestFolderPrivate, 1);
digest_folder->priv->message = NULL;
digest_folder->priv->search = NULL;
{
CamelDigestFolder *digest_folder = CAMEL_DIGEST_FOLDER (object);
CamelFolder *folder = CAMEL_FOLDER (object);
-
+
if (folder->summary) {
camel_object_unref (folder->summary);
folder->summary = NULL;
}
-
+
camel_object_unref (digest_folder->priv->message);
-
+
if (digest_folder->priv->search)
camel_object_unref (digest_folder->priv->search);
-
+
g_mutex_free (digest_folder->priv->search_lock);
-
+
g_free (digest_folder->priv);
}
camel_digest_folder_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (CAMEL_FOLDER_TYPE,
"CamelDigestFolder",
(CamelObjectInitFunc) camel_digest_folder_init,
(CamelObjectFinalizeFunc) digest_finalize);
}
-
+
return type;
}
CamelDataWrapper *wrapper;
CamelMimePart *part;
int i, parts;
-
+
parts = camel_multipart_get_number (multipart);
for (i = 0; i < parts && !has_message_parts; i++) {
part = camel_multipart_get_part (multipart, i);
has_message_parts = TRUE;
}
}
-
+
return has_message_parts;
}
CamelMimePart *part;
int parts, i;
char *uid;
-
+
parts = camel_multipart_get_number (multipart);
for (i = 0; i < parts; i++) {
part = camel_multipart_get_part (multipart, i);
-
+
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
-
+
if (CAMEL_IS_MULTIPART (wrapper)) {
uid = g_strdup_printf ("%s%d.", preuid, i);
digest_add_multipart (folder, CAMEL_MULTIPART (wrapper), uid);
} else if (!CAMEL_IS_MIME_MESSAGE (wrapper)) {
continue;
}
-
+
info = camel_folder_summary_info_new_from_message (folder->summary, CAMEL_MIME_MESSAGE (wrapper));
g_free(info->uid);
info->uid = g_strdup_printf ("%s%d", preuid, i);
CamelDigestFolder *digest_folder;
CamelDataWrapper *wrapper;
CamelFolder *folder;
-
+
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (message));
if (!wrapper || !CAMEL_IS_MULTIPART (wrapper))
return NULL;
-
+
/* Make sure we have a multipart/digest subpart or at least some message/rfc822 attachments... */
if (!camel_content_type_is (CAMEL_DATA_WRAPPER (message)->mime_type, "multipart", "digest")) {
if (!multipart_contains_message_parts (CAMEL_MULTIPART (wrapper)))
return NULL;
}
-
+
folder = CAMEL_FOLDER (camel_object_new (camel_digest_folder_get_type ()));
digest_folder = CAMEL_DIGEST_FOLDER (folder);
-
+
camel_folder_construct (folder, parent_store, "folder_name", "short_name");
-
+
camel_object_ref (message);
digest_folder->priv->message = message;
-
+
construct_summary (folder, CAMEL_MULTIPART (wrapper));
-
+
return folder;
}
static void
digest_refresh_info (CamelFolder *folder, CamelException *ex)
{
-
+
}
static void
CamelMimePart *part;
char *subuid;
int id;
-
+
part = CAMEL_MIME_PART (digest->priv->message);
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
-
+
do {
id = strtoul (uid, &subuid, 10);
if (!CAMEL_IS_MULTIPART (wrapper))
return NULL;
-
+
part = camel_multipart_get_part (CAMEL_MULTIPART (wrapper), id);
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
uid = subuid + 1;
} while (*subuid == '.');
-
+
if (!CAMEL_IS_MIME_MESSAGE (wrapper))
return NULL;
-
+
message = CAMEL_MIME_MESSAGE (wrapper);
camel_object_ref (message);
-
+
return message;
}
{
CamelDigestFolder *df = (CamelDigestFolder *) folder;
GPtrArray *matches;
-
+
CAMEL_DIGEST_FOLDER_LOCK (folder, search_lock);
-
+
if (!df->priv->search)
df->priv->search = camel_folder_search_new ();
-
+
camel_folder_search_set_folder (df->priv->search, folder);
matches = camel_folder_search_search(df->priv->search, expression, NULL, ex);
-
+
CAMEL_DIGEST_FOLDER_UNLOCK (folder, search_lock);
-
+
return matches;
}
return g_ptr_array_new();
CAMEL_DIGEST_FOLDER_LOCK (folder, search_lock);
-
+
if (!df->priv->search)
df->priv->search = camel_folder_search_new ();
-
+
camel_folder_search_set_folder (df->priv->search, folder);
matches = camel_folder_search_search(df->priv->search, expression, NULL, ex);
-
+
CAMEL_DIGEST_FOLDER_UNLOCK (folder, search_lock);
-
+
return matches;
}
digest_search_free (CamelFolder *folder, GPtrArray *result)
{
CamelDigestFolder *digest_folder = CAMEL_DIGEST_FOLDER (folder);
-
+
CAMEL_DIGEST_FOLDER_LOCK (folder, search_lock);
-
+
camel_folder_search_free_result (digest_folder->priv->search, result);
-
+
CAMEL_DIGEST_FOLDER_UNLOCK (folder, search_lock);
}
struct _CamelDigestFolder {
CamelFolder parent;
-
+
struct _CamelDigestFolderPrivate *priv;
};
struct _CamelDigestFolderClass {
CamelFolderClass parent_class;
-
+
};
CamelType camel_digest_folder_get_type (void);
camel_digest_store_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_store_get_type (),
"CamelDigestStore",
(CamelObjectInitFunc) camel_digest_store_init,
(CamelObjectFinalizeFunc) camel_digest_store_finalise);
}
-
+
return type;
}
{
CamelObjectClass *object_class = (CamelObjectClass *) klass;
CamelStoreClass *store_class = (CamelStoreClass *) klass;
-
+
parent_class = CAMEL_STORE_CLASS(camel_type_get_global_classfuncs (camel_store_get_type ()));
-
+
/* virtual method overload */
object_class->setv = digest_setv;
object_class->getv = digest_getv;
-
+
store_class->get_folder = digest_get_folder;
store_class->rename_folder = digest_rename_folder;
store_class->delete_folder = digest_delete_folder;
store_class->get_folder_info = digest_get_folder_info;
store_class->free_folder_info = camel_store_free_folder_info_full;
-
+
store_class->get_trash = digest_get_trash;
store_class->get_junk = digest_get_junk;
}
camel_digest_store_init (CamelDigestStore *obj)
{
CamelStore *store = (CamelStore *) obj;
-
+
/* we dont want a vtrash and vjunk on this one */
- store->flags &= ~(CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK);
+ store->flags &= ~(CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK);
}
static void
camel_digest_store_finalise (CamelObject *obj)
{
-
+
}
static int
* @url:
*
* Create a new CamelDigestStore object.
- *
+ *
* Return value: A new CamelDigestStore widget.
**/
CamelStore *
{
CamelStore *store;
CamelURL *uri;
-
+
uri = camel_url_new (url, NULL);
if (!uri)
return NULL;
-
+
store = CAMEL_STORE (camel_object_new (camel_digest_store_get_type ()));
CAMEL_SERVICE (store)->url = uri;
-
+
return store;
}
static void
digest_delete_folder (CamelStore *store, const char *folder_name, CamelException *ex)
{
-
+
}
static void
digest_rename_folder (CamelStore *store, const char *old, const char *new, CamelException *ex)
{
-
+
}
struct _CamelDigestStore {
CamelStore parent;
-
+
};
struct _CamelDigestStoreClass {
CamelStoreClass parent_class;
-
+
};
CamelType camel_digest_store_get_type (void);
camel_digest_summary_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (
camel_folder_summary_get_type (),
(CamelObjectInitFunc) camel_digest_summary_init,
(CamelObjectFinalizeFunc) camel_digest_summary_finalise);
}
-
+
return type;
}
camel_digest_summary_init (CamelDigestSummary *summary)
{
CamelFolderSummary *s = (CamelFolderSummary *) summary;
-
+
/* subclasses need to set the right instance data sizes */
s->message_info_size = sizeof (CamelMessageInfo);
s->content_info_size = sizeof (CamelMessageContentInfo);
-
+
/* and a unique file version */
s->version += CAMEL_DIGEST_SUMMARY_VERSION;
}
static void
camel_digest_summary_finalise (CamelObject *object)
{
-
+
}
struct _CamelDigestSummary {
CamelFolderSummary parent_object;
-
+
};
struct _CamelDigestSummaryClass {
CamelFolderSummaryClass parent_class;
-
+
};
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-disco-diary.c: class for a disconnected operation log */
-/*
+/*
* Authors: Dan Winship <danw@ximian.com>
*
* Copyright (C) 2001 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#include "camel-session.h"
#include "camel-store.h"
-#define d(x)
+#define d(x)
static void
camel_disco_diary_class_init (CamelDiscoDiaryClass *camel_disco_diary_class)
*
* Copyright 2001 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-disco-folder.c: abstract class for a disconnectable folder */
-/*
+/*
* Authors: Dan Winship <danw@ximian.com>
*
* Copyright (C) 2001 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* the bodies of all messages described by @expression (using the
* same syntax as camel_folder_search_by_expression() ).
**/
-void
+void
camel_disco_folder_prepare_for_offline (CamelDiscoFolder *disco_folder,
const char *expression,
CamelException *ex)
*
* Copyright 2001 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#include "camel-exception.h"
#include "camel-session.h"
-#define d(x)
+#define d(x)
#define CDS_CLASS(o) (CAMEL_DISCO_STORE_CLASS (CAMEL_OBJECT_GET_CLASS (o)))
CAMEL_SERVICE_CLASS (camel_disco_store_class);
CamelStoreClass *camel_store_class =
CAMEL_STORE_CLASS (camel_disco_store_class);
-
+
parent_class = CAMEL_STORE_CLASS (camel_type_get_global_classfuncs (camel_store_get_type ()));
-
+
/* virtual method definition */
camel_disco_store_class->set_status = set_status;
camel_disco_store_class->can_work_offline = can_work_offline;
-
+
/* virtual method overload */
camel_object_class->setv = disco_setv;
camel_object_class->getv = disco_getv;
-
+
camel_service_class->construct = disco_construct;
camel_service_class->connect = disco_connect;
camel_service_class->disconnect = disco_disconnect;
camel_service_class->cancel_connect = disco_cancel_connect;
-
+
camel_store_class->get_folder = disco_get_folder;
camel_store_class->get_folder_info = disco_get_folder_info;
}
camel_disco_store_get_type (void)
{
static CamelType camel_disco_store_type = CAMEL_INVALID_TYPE;
-
+
if (camel_disco_store_type == CAMEL_INVALID_TYPE) {
camel_disco_store_type = camel_type_register (
CAMEL_STORE_TYPE,
NULL,
NULL);
}
-
+
return camel_disco_store_type;
}
guint32 flags, CamelException *ex)
{
CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (store);
-
+
switch (camel_disco_store_status (disco_store)) {
case CAMEL_DISCO_STORE_ONLINE:
return CDS_CLASS (store)->get_folder_online (store, name, flags, ex);
-
+
case CAMEL_DISCO_STORE_OFFLINE:
return CDS_CLASS (store)->get_folder_offline (store, name, flags, ex);
-
+
case CAMEL_DISCO_STORE_RESYNCING:
- return CDS_CLASS (store)->get_folder_resyncing (store, name, flags, ex);
+ return CDS_CLASS (store)->get_folder_resyncing (store, name, flags, ex);
}
-
+
g_assert_not_reached ();
return NULL;
}
switch (camel_disco_store_status (disco_store)) {
case CAMEL_DISCO_STORE_ONLINE:
return CDS_CLASS (store)->get_folder_info_online (store, top, flags, ex);
-
+
case CAMEL_DISCO_STORE_OFFLINE:
/* Can't edit subscriptions while offline */
if ((store->flags & CAMEL_STORE_SUBSCRIPTIONS) &&
camel_disco_store_check_online (disco_store, ex);
return NULL;
}
-
+
return CDS_CLASS (store)->get_folder_info_offline (store, top, flags, ex);
-
+
case CAMEL_DISCO_STORE_RESYNCING:
return CDS_CLASS (store)->get_folder_info_resyncing (store, top, flags, ex);
}
-
+
g_assert_not_reached ();
return NULL;
}
GPtrArray *folders;
CamelFolder *folder;
int i, sync;
-
+
sync = camel_url_get_param(((CamelService *)disco_store)->url, "offline_sync") != NULL;
-
+
folders = camel_object_bag_list(((CamelStore *)disco_store)->folders);
for (i=0;i<folders->len;i++) {
folder = folders->pdata[i];
g_ptr_array_free(folders, TRUE);
}
}
-
+
camel_store_sync(CAMEL_STORE (disco_store), FALSE, &x);
camel_exception_clear(&x);
}
-
+
if (!camel_service_disconnect (CAMEL_SERVICE (disco_store), network_state, ex))
return;
GPtrArray *folders;
CamelFolder *folder;
int i, sync;
-
+
sync = camel_url_get_param(((CamelService *)disco_store)->url, "offline_sync") != NULL;
-
+
folders = camel_object_bag_list(((CamelStore *)disco_store)->folders);
for (i=0;i<folders->len;i++) {
folder = folders->pdata[i];
g_ptr_array_free(folders, TRUE);
}
}
-
+
camel_store_sync(CAMEL_STORE (disco_store), FALSE, &x);
camel_exception_clear(&x);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-disco-store.h: abstruct class for a disconnectable store */
-/*
+/*
* Authors: Dan Winship <danw@ximian.com>
*
* Copyright (C) 2001 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
} CamelDiscoStoreStatus;
struct _CamelDiscoStore {
- CamelStore parent_object;
+ CamelStore parent_object;
CamelDiscoStoreStatus status;
CamelDiscoDiary *diary;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
*
- * Author :
+ * Author :
* Bertrand Guiheneuf <bertrand@helixcode.com>
*
* Copyright 1999-2003 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
static EMemChunk *exception_chunks = NULL;
/**
- * camel_exception_new: allocate a new exception object.
- *
+ * camel_exception_new: allocate a new exception object.
+ *
* Create and returns a new exception object.
- *
+ *
* Returns the newly allocated exception object
**/
CamelException *
/**
* camel_exception_init:
* @ex: a #CamelException
- *
+ *
* Init an exception. This routine is mainly useful when using a
* statically allocated exception.
**/
/**
* camel_exception_clear:
* @ex: a #CamelException
- *
+ *
* Clear an exception, that is, set the exception ID to
* #CAMEL_EXCEPTION_NONE and free the description text. If the
* exception is %NULL, this funtion just returns.
**/
-void
+void
camel_exception_clear (CamelException *exception)
{
if (!exception)
/**
* camel_exception_free:
* @ex: a #CamelException
- *
+ *
* Free an exception object. If the exception is %NULL, nothing is
* done, the routine simply returns.
**/
-void
+void
camel_exception_free (CamelException *exception)
{
if (!exception)
return;
-
+
if (exception->desc)
g_free (exception->desc);
}
/**
- * camel_exception_set: set an exception
+ * camel_exception_set: set an exception
* @ex: a #CamelException
- * @id: exception id
+ * @id: exception id
* @desc: textual description of the exception
- *
- * Set the value of an exception. The exception id is
- * a unique number representing the exception. The
- * textual description is a small text explaining
+ *
+ * Set the value of an exception. The exception id is
+ * a unique number representing the exception. The
+ * textual description is a small text explaining
* what happened and provoked the exception.
*
* When @ex is %NULL, nothing is done, this routine
}
/**
- * camel_exception_setv: set an exception
+ * camel_exception_setv: set an exception
* @ex: a #CamelException
- * @id: exception id
+ * @id: exception id
* @format: format of the description string. The format string is
* used as in printf().
- *
- * Set the value of an exception. The exception id is
- * a unique number representing the exception. The
- * textual description is a small text explaining
- * what happened and provoked the exception.
- * In this version, the string is created from the format
+ *
+ * Set the value of an exception. The exception id is
+ * a unique number representing the exception. The
+ * textual description is a small text explaining
+ * what happened and provoked the exception.
+ * In this version, the string is created from the format
* string and the variable argument list.
*
* It is safe to say:
if (camel_debug("exception"))
printf("CamelException.setv(%p, %u, '%s')\n", ex, id, desc);
-
+
if (!ex) {
g_free(desc);
return;
/**
* camel_exception_xfer:
- * @ex_dst: Destination exception object
+ * @ex_dst: Destination exception object
* @ex_src: Source exception object
- *
+ *
* Transfer the content of an exception from an exception object to
* another. The destination exception receives the id and the
* description text of the source exception.
**/
-void
+void
camel_exception_xfer (CamelException *ex_dst,
CamelException *ex_src)
{
/**
* camel_exception_get_id:
* @ex: a #CamelException
- *
+ *
* Get the id of an exception.
- *
+ *
* Returns the exception id (#CAMEL_EXCEPTION_NONE will be returned if
* @ex is %NULL or unset)
**/
{
if (ex)
return ex->id;
-
+
w(g_warning ("camel_exception_get_id called with NULL parameter."));
-
+
return CAMEL_EXCEPTION_NONE;
}
/**
* camel_exception_get_description:
* @ex: a #CamelException
- *
+ *
* Get the exception description text.
- *
+ *
* Returns the exception description text (%NULL will be returned if
* @ex is %NULL or unset)
**/
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-execpetion.h : exception utils */
-/*
+/*
*
- * Author :
+ * Author :
* Bertrand Guiheneuf <bertrand@helixcode.com>
*
* Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
const char *desc);
void camel_exception_setv (CamelException *ex,
ExceptionId id,
- const char *format,
+ const char *format,
...);
/* exception content transfer */
*
* Copyright (C) 2000, 2003 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* camel_file_util_encode_uint32:
* @out: file to output to
* @value: value to output
- *
+ *
* Utility function to save an uint32 to a file.
- *
+ *
* Return value: 0 on success, -1 on error.
**/
int
* camel_file_util_decode_uint32:
* @in: file to read from
* @dest: pointer to a variable to store the value in
- *
+ *
* Retrieve an encoded uint32 from a file.
- *
+ *
* Return value: 0 on success, -1 on error. @*dest will contain the
* decoded value.
**/
* camel_file_util_encode_fixed_int32:
* @out: file to output to
* @value: value to output
- *
+ *
* Encode a gint32, performing no compression, but converting
* to network order.
- *
+ *
* Return value: 0 on success, -1 on error.
**/
int
* camel_file_util_decode_fixed_int32:
* @in: file to read from
* @dest: pointer to a variable to store the value in
- *
+ *
* Retrieve a gint32.
- *
+ *
* Return value: 0 on success, -1 on error.
**/
int
* camel_file_util_encode_time_t:
* @out: file to output to
* @value: value to output
- *
+ *
* Encode a time_t value to the file.
- *
+ *
* Return value: 0 on success, -1 on error.
**/
CFU_ENCODE_T(time_t)
* camel_file_util_decode_time_t:
* @in: file to read from
* @dest: pointer to a variable to store the value in
- *
+ *
* Decode a time_t value.
- *
+ *
* Return value: 0 on success, -1 on error.
**/
CFU_DECODE_T(time_t)
* camel_file_util_encode_off_t:
* @out: file to output to
* @value: value to output
- *
+ *
* Encode an off_t type.
- *
+ *
* Return value: 0 on success, -1 on error.
**/
CFU_ENCODE_T(off_t)
* camel_file_util_decode_off_t:
* @in: file to read from
* @dest: pointer to a variable to put the value in
- *
+ *
* Decode an off_t type.
- *
+ *
* Return value: 0 on success, -1 on failure.
**/
CFU_DECODE_T(off_t)
* camel_file_util_encode_size_t:
* @out: file to output to
* @value: value to output
- *
+ *
* Encode an size_t type.
- *
+ *
* Return value: 0 on success, -1 on error.
**/
CFU_ENCODE_T(size_t)
* camel_file_util_decode_size_t:
* @in: file to read from
* @dest: pointer to a variable to put the value in
- *
+ *
* Decode an size_t type.
- *
+ *
* Return value: 0 on success, -1 on failure.
**/
CFU_DECODE_T(size_t)
* camel_file_util_encode_string:
* @out: file to output to
* @str: value to output
- *
+ *
* Encode a normal string and save it in the output file.
- *
+ *
* Return value: 0 on success, -1 on error.
**/
int
if (str == NULL)
return camel_file_util_encode_uint32 (out, 1);
-
+
if ((len = strlen (str)) > 65536)
len = 65536;
-
+
if (camel_file_util_encode_uint32 (out, len+1) == -1)
return -1;
if (len == 0 || fwrite (str, len, 1, out) == 1)
* camel_file_util_decode_string:
* @in: file to read from
* @str: pointer to a variable to store the value in
- *
+ *
* Decode a normal string from the input file.
- *
+ *
* Return value: 0 on success, -1 on error.
**/
int
* @out: file to output to
* @str: value to output
* @len: total-len of str to store
- *
+ *
* Encode a normal string and save it in the output file.
* Unlike @camel_file_util_encode_string, it pads the
* @str with "NULL" bytes, if @len is > strlen(str)
- *
+ *
* Return value: 0 on success, -1 on error.
**/
int
/* Max size is 64K */
if (len > 65536)
len = 65536;
-
+
memset(buf, 0x00, len);
g_strlcpy(buf, str, len);
* camel_file_util_decode_fixed_string:
* @in: file to read from
* @str: pointer to a variable to store the value in
- * @len: total-len to decode.
- *
+ * @len: total-len to decode.
+ *
* Decode a normal string from the input file.
- *
+ *
* Return value: 0 on success, -1 on error.
**/
int
if (name == NULL)
return NULL;
-
+
return camel_url_encode(name, unsafe_chars);
}
{
ssize_t nread;
int cancel_fd;
-
+
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
return -1;
#ifndef G_OS_WIN32
int errnosav, flags, fdmax;
fd_set rdset;
-
+
flags = fcntl (fd, F_GETFL);
fcntl (fd, F_SETFL, flags | O_NONBLOCK);
-
+
do {
struct timeval tv;
int res;
else if (FD_ISSET (cancel_fd, &rdset)) {
errno = EINTR;
goto failed;
- } else {
+ } else {
do {
nread = read (fd, buf, n);
} while (nread == -1 && errno == EINTR);
errno = errnosav;
#endif
}
-
+
return nread;
}
{
ssize_t w, written = 0;
int cancel_fd;
-
+
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
return -1;
#ifndef G_OS_WIN32
int errnosav, flags, fdmax;
fd_set rdset, wrset;
-
+
flags = fcntl (fd, F_GETFL);
fcntl (fd, F_SETFL, flags | O_NONBLOCK);
-
+
fdmax = MAX (fd, cancel_fd) + 1;
do {
struct timeval tv;
FD_SET (fd, &wrset);
FD_SET (cancel_fd, &rdset);
tv.tv_sec = IO_TIMEOUT;
- tv.tv_usec = 0;
+ tv.tv_usec = 0;
w = -1;
res = select (fdmax, &rdset, &wrset, 0, &tv);
do {
w = write (fd, buf + written, n - written);
} while (w == -1 && errno == EINTR);
-
+
if (w == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK)
w = 0;
written += w;
}
} while (w != -1 && written < n);
-
+
errnosav = errno;
fcntl (fd, F_SETFL, flags);
errno = errnosav;
#endif
}
-
+
if (w == -1)
return -1;
-
+
return written;
}
#else
ssize_t nread;
int cancel_fd;
-
+
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
return -1;
else if (FD_ISSET (cancel_fd, &rdset)) {
errno = EINTR;
goto failed;
- } else {
+ } else {
nread = recv (fd, buf, n, 0);
}
} while (nread == -1 && WSAGetLastError () == WSAEWOULDBLOCK);
failed:
;
}
-
+
return nread;
#endif
}
#else
ssize_t w, written = 0;
int cancel_fd;
-
+
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
return -1;
FD_SET (fd, &wrset);
FD_SET (cancel_fd, &rdset);
tv.tv_sec = IO_TIMEOUT;
- tv.tv_usec = 0;
+ tv.tv_usec = 0;
w = -1;
res = select (fdmax, &rdset, &wrset, 0, &tv);
arg = 0;
ioctlsocket (fd, FIONBIO, &arg);
}
-
+
if (w == -1)
return -1;
-
+
return written;
#endif
}
/**
* camel_file_util_savename:
* @filename: a pathname
- *
+ *
* Builds a pathname where the basename is of the form ".#" + the
* basename of @filename, for instance used in a two-stage commit file
* write.
- *
+ *
* Return value: The new pathname. It must be free'd with g_free().
**/
char *
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Authors:
* Michael Zucchi <notzed@ximian.com>
* Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright (C) 2000, 2003 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
CamelSession *session;
CamelFolder *defaultfolder; /* defualt folder */
-
+
CamelFilterStatusFunc *statusfunc; /* status callback */
void *statusdata; /* status callback data */
-
+
CamelFilterShellFunc *shellfunc; /* execute shell command callback */
void *shelldata; /* execute shell command callback data */
-
+
CamelFilterPlaySoundFunc *playfunc; /* play-sound command callback */
void *playdata; /* play-sound command callback data */
-
+
CamelFilterSystemBeepFunc *beep; /* system beep callback */
void *beepdata; /* system beep callback data */
-
+
/* for callback */
CamelFilterGetFolderFunc get_folder;
void *data;
-
+
/* run-time data */
GHashTable *folders; /* folders that message has been copied to */
int closed; /* close count */
GHashTable *forwards; /* addresses that have been forwarded the message */
GHashTable *only_once; /* actions to run only-once */
-
+
gboolean terminated; /* message processing was terminated */
gboolean deleted; /* message was marked for deletion */
gboolean copied; /* message was copied to some folder or another */
gboolean moved; /* message was moved to some folder or another */
-
+
CamelMimeMessage *message; /* input message */
CamelMessageInfo *info; /* message summary info */
const char *uid; /* message uid */
CamelFolder *source; /* message source folder */
gboolean modified; /* has the input message been modified? */
-
+
FILE *logfile; /* log file */
-
+
EDList rules; /* list of _filter_rule structs */
-
+
CamelException *ex;
-
+
/* evaluator */
ESExp *eval;
};
(CamelObjectInitFunc) camel_filter_driver_init,
(CamelObjectFinalizeFunc) camel_filter_driver_finalise);
}
-
+
return type;
}
{
struct _CamelFilterDriverPrivate *p;
int i;
-
+
p = _PRIVATE (obj) = g_malloc0 (sizeof (*p));
e_dlist_init(&p->rules);
e_sexp_add_function (p->eval, 0, symbols[i].name, symbols[i].func, obj);
}
}
-
+
p->globals = g_hash_table_new (g_str_hash, g_str_equal);
-
+
p->folders = g_hash_table_new (g_str_hash, g_str_equal);
-
+
p->only_once = g_hash_table_new (g_str_hash, g_str_equal);
}
camel_filter_driver_finalise (CamelObject *obj)
{
CamelFilterDriver *driver = (CamelFilterDriver *) obj;
- struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+ struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
struct _filter_rule *node;
/* close all folders that were opened for appending */
close_folders (driver);
g_hash_table_destroy (p->folders);
-
+
g_hash_table_foreach (p->globals, free_hash_strings, driver);
g_hash_table_destroy (p->globals);
-
+
g_hash_table_foreach (p->only_once, free_hash_strings, driver);
g_hash_table_destroy (p->only_once);
-
+
e_sexp_unref(p->eval);
-
+
if (p->defaultfolder) {
camel_folder_thaw (p->defaultfolder);
camel_object_unref (p->defaultfolder);
camel_filter_driver_set_logfile (CamelFilterDriver *d, FILE *logfile)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
-
+
p->logfile = logfile;
}
camel_filter_driver_set_status_func (CamelFilterDriver *d, CamelFilterStatusFunc *func, void *data)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
-
+
p->statusfunc = func;
p->statusdata = data;
}
camel_filter_driver_set_shell_func (CamelFilterDriver *d, CamelFilterShellFunc *func, void *data)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
-
+
p->shellfunc = func;
p->shelldata = data;
}
camel_filter_driver_set_play_sound_func (CamelFilterDriver *d, CamelFilterPlaySoundFunc *func, void *data)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
-
+
p->playfunc = func;
p->playdata = data;
}
camel_filter_driver_set_system_beep_func (CamelFilterDriver *d, CamelFilterSystemBeepFunc *func, void *data)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
-
+
p->beep = func;
p->beepdata = data;
}
camel_filter_driver_set_default_folder (CamelFilterDriver *d, CamelFolder *def)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
-
+
if (p->defaultfolder) {
camel_folder_thaw (p->defaultfolder);
camel_object_unref (p->defaultfolder);
}
-
+
p->defaultfolder = def;
-
+
if (p->defaultfolder) {
camel_folder_freeze (p->defaultfolder);
camel_object_ref (p->defaultfolder);
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
struct _filter_rule *node;
-
+
node = (struct _filter_rule *) p->rules.head;
while (node->next) {
if (!strcmp (node->name, name)) {
g_free (node->action);
g_free (node->name);
g_free (node);
-
+
return 0;
}
-
+
node = node->next;
}
-
+
return -1;
}
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
va_list ap;
char *str;
-
+
if (p->statusfunc) {
va_start (ap, desc);
str = g_strdup_vprintf (desc, ap);
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
char *oldkey, *oldvalue;
-
+
if (g_hash_table_lookup_extended (p->globals, name, (void *)&oldkey, (void *)&oldvalue)) {
g_free (oldvalue);
g_hash_table_insert (p->globals, oldkey, g_strdup (value));
do_delete (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
-
+
d(fprintf (stderr, "doing delete\n"));
p->deleted = TRUE;
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Delete");
-
+
return NULL;
}
mark_forward (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
{
/*struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);*/
-
+
d(fprintf (stderr, "marking message for forwarding\n"));
/* FIXME: do stuff here */
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Forward");
-
+
return NULL;
}
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
int i;
-
+
d(fprintf (stderr, "copying message...\n"));
-
+
for (i = 0; i < argc; i++) {
if (argv[i]->type == ESEXP_RES_STRING) {
/* open folders we intent to copy to */
char *folder = argv[i]->value.string;
CamelFolder *outbox;
-
+
outbox = open_folder (driver, folder);
if (!outbox)
break;
-
+
if (outbox == p->source)
break;
-
+
if (!p->modified && p->uid && p->source && camel_folder_has_summary_capability (p->source)) {
GPtrArray *uids;
-
+
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (char *) p->uid);
camel_folder_transfer_messages_to (p->source, uids, outbox, NULL, FALSE, p->ex);
} else {
if (p->message == NULL)
p->message = camel_folder_get_message (p->source, p->uid, p->ex);
-
+
if (!p->message)
continue;
-
+
camel_folder_append_message (outbox, p->message, p->info, NULL, p->ex);
}
-
+
if (!camel_exception_is_set (p->ex))
p->copied = TRUE;
-
+
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Copy to folder %s",
folder);
}
}
-
+
return NULL;
}
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
int i;
-
+
d(fprintf (stderr, "moving message...\n"));
-
+
for (i = 0; i < argc; i++) {
if (argv[i]->type == ESEXP_RES_STRING) {
/* open folders we intent to move to */
char *folder = argv[i]->value.string;
CamelFolder *outbox;
int last;
-
+
outbox = open_folder (driver, folder);
if (!outbox)
break;
-
+
if (outbox == p->source)
break;
} else {
if (p->message == NULL)
p->message = camel_folder_get_message (p->source, p->uid, p->ex);
-
+
if (!p->message)
continue;
-
+
camel_folder_append_message (outbox, p->message, p->info, NULL, p->ex);
if (!camel_exception_is_set(p->ex) && last) {
camel_message_info_set_flags(p->info, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_FOLDER_FLAGGED, ~0);
}
}
-
+
if (!camel_exception_is_set (p->ex)) {
p->moved = TRUE;
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Move to folder %s", folder);
do_stop (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
-
+
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Stopped processing");
d(fprintf (stderr, "terminating message processing\n"));
p->terminated = TRUE;
-
+
return NULL;
}
do_label (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
-
+
d(fprintf (stderr, "setting label tag\n"));
if (argc > 0 && argv[0]->type == ESEXP_RES_STRING) {
if (p->source && p->uid && camel_folder_has_summary_capability (p->source))
camel_message_info_set_user_tag(p->info, "label", argv[0]->value.string);
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Set label to %s", argv[0]->value.string);
}
-
+
return NULL;
}
do_colour (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
-
+
d(fprintf (stderr, "setting colour tag\n"));
if (argc > 0 && argv[0]->type == ESEXP_RES_STRING) {
if (p->source && p->uid && camel_folder_has_summary_capability (p->source))
camel_message_info_set_user_tag(p->info, "colour", argv[0]->value.string);
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Set colour to %s", argv[0]->value.string);
}
-
+
return NULL;
}
do_score (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
-
+
d(fprintf (stderr, "setting score tag\n"));
if (argc > 0 && argv[0]->type == ESEXP_RES_INT) {
char *value;
-
+
value = g_strdup_printf ("%d", argv[0]->value.number);
camel_message_info_set_user_tag(p->info, "score", value);
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Set score to %d", argv[0]->value.number);
g_free (value);
}
-
+
return NULL;
}
do_adjust_score(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE(driver);
-
+
d(fprintf (stderr, "adjusting score tag\n"));
if (argc > 0 && argv[0]->type == ESEXP_RES_INT) {
char *value;
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Adjust score (%d) to %s", argv[0]->value.number, value);
g_free (value);
}
-
+
return NULL;
}
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
guint32 flags;
-
+
d(fprintf (stderr, "setting flag\n"));
if (argc == 1 && argv[0]->type == ESEXP_RES_STRING) {
flags = camel_system_flag (argv[0]->value.string);
camel_message_info_set_flags(p->info, flags | CAMEL_MESSAGE_FOLDER_FLAGGED, ~0);
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Set %s flag", argv[0]->value.string);
}
-
+
return NULL;
}
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
guint32 flags;
-
+
d(fprintf (stderr, "unsetting flag\n"));
if (argc == 1 && argv[0]->type == ESEXP_RES_STRING) {
flags = camel_system_flag (argv[0]->value.string);
camel_message_info_set_flags(p->info, flags | CAMEL_MESSAGE_FOLDER_FLAGGED, 0);
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Unset %s flag", argv[0]->value.string);
}
-
+
return NULL;
}
child_watch_data_t child_watch_data;
GSource *source;
GMainContext *context;
-
+
if (argc < 1 || argv[0]->value.string[0] == '\0')
return 0;
-
+
/* make sure we have the message... */
if (p->message == NULL) {
if (!(p->message = camel_folder_get_message (p->source, p->uid, p->ex)))
return -1;
}
-
+
args = g_ptr_array_new ();
for (i = 0; i < argc; i++)
g_ptr_array_add (args, argv[i]->value.string);
g_error_free (error);
return -1;
}
-
+
g_ptr_array_free (args, TRUE);
-
+
stream = camel_stream_fs_new_with_fd (pipe_to_child);
if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (p->message), stream) == -1) {
camel_object_unref (stream);
close (pipe_from_child);
goto wait;
}
-
+
if (camel_stream_flush (stream) == -1) {
camel_object_unref (stream);
close (pipe_from_child);
goto wait;
}
-
+
camel_object_unref (stream);
-
+
stream = camel_stream_fs_new_with_fd (pipe_from_child);
mem = camel_stream_mem_new ();
if (camel_stream_write_to_stream (stream, mem) == -1) {
camel_object_unref (mem);
goto wait;
}
-
+
camel_object_unref (stream);
camel_stream_reset (mem);
-
+
parser = camel_mime_parser_new ();
camel_mime_parser_init_with_stream (parser, mem);
camel_mime_parser_scan_from (parser, FALSE);
camel_object_unref (mem);
-
+
message = camel_mime_message_new ();
if (camel_mime_part_construct_from_parser ((CamelMimePart *) message, parser) == -1) {
camel_exception_setv (p->ex, CAMEL_EXCEPTION_SYSTEM,
p->message = message;
p->modified = TRUE;
}
-
+
camel_object_unref (parser);
-
+
wait:
context = g_main_context_new ();
child_watch_data.loop = g_main_loop_new (context, FALSE);
pipe_message (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
{
int i;
-
+
/* make sure all args are strings */
for (i = 0; i < argc; i++) {
if (argv[i]->type != ESEXP_RES_STRING)
return NULL;
}
-
+
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Piping message to %s", argv[0]->value.string);
pipe_to_system (f, argc, argv, driver);
-
+
return NULL;
}
GString *command;
GPtrArray *args;
int i;
-
+
d(fprintf (stderr, "executing shell command\n"));
-
+
command = g_string_new ("");
-
+
args = g_ptr_array_new ();
-
+
/* make sure all args are strings */
for (i = 0; i < argc; i++) {
if (argv[i]->type != ESEXP_RES_STRING)
goto done;
-
+
g_ptr_array_add (args, argv[i]->value.string);
-
+
g_string_append (command, argv[i]->value.string);
g_string_append_c (command, ' ');
}
-
+
g_string_truncate (command, command->len - 1);
-
+
if (p->shellfunc && argc >= 1) {
p->shellfunc (driver, argc, (char **) args->pdata, p->shelldata);
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Executing shell command: [%s]",
command->str);
}
-
+
done:
-
+
g_ptr_array_free (args, TRUE);
g_string_free (command, TRUE);
-
+
return NULL;
}
do_beep (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
-
+
d(fprintf (stderr, "beep\n"));
-
+
if (p->beep) {
p->beep (driver, p->beepdata);
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Beep");
}
-
+
return NULL;
}
play_sound (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
-
+
d(fprintf (stderr, "play sound\n"));
-
+
if (p->playfunc && argc == 1 && argv[0]->type == ESEXP_RES_STRING) {
p->playfunc (driver, argv[0]->value.string, p->playdata);
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Play sound");
}
-
+
return NULL;
}
do_only_once (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
-
+
d(fprintf (stderr, "only once\n"));
-
+
if (argc == 2 && !g_hash_table_lookup (p->only_once, argv[0]->value.string))
g_hash_table_insert (p->only_once, g_strdup (argv[0]->value.string),
g_strdup (argv[1]->value.string));
-
+
return NULL;
}
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
CamelFolder *camelfolder;
-
+
/* we have a lookup table of currently open folders */
camelfolder = g_hash_table_lookup (p->folders, folder_url);
if (camelfolder)
} else {
camelfolder = p->get_folder (driver, folder_url, p->data, p->ex);
}
-
+
if (camelfolder) {
g_hash_table_insert (p->folders, g_strdup (folder_url), camelfolder);
camel_folder_freeze (camelfolder);
} else {
g_hash_table_insert (p->folders, g_strdup (folder_url), FOLDER_INVALID);
}
-
+
return camelfolder;
}
static void
close_folder (void *key, void *value, void *data)
-{
+{
CamelFolder *folder = value;
CamelFilterDriver *driver = data;
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
g_hash_table_foreach (p->folders, close_folder, driver);
g_hash_table_destroy (p->folders);
p->folders = g_hash_table_new (g_str_hash, g_str_equal);
-
+
/* FIXME: status from driver */
return 0;
}
camel_filter_driver_log (CamelFilterDriver *driver, enum filter_log_t status, const char *desc, ...)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
-
+
if (p->logfile) {
char *str = NULL;
-
+
if (desc) {
va_list ap;
-
+
va_start (ap, desc);
str = g_strdup_vprintf (desc, ap);
}
-
+
switch (status) {
case FILTER_LOG_START: {
/* write log header */
const char *from = NULL;
char date[50];
time_t t;
-
+
/* FIXME: does this need locking? Probably */
-
+
from = camel_message_info_from (p->info);
subject = camel_message_info_subject (p->info);
-
+
time (&t);
strftime (date, 49, "%a, %d %b %Y %H:%M:%S", localtime (&t));
fprintf (p->logfile, "Applied filter \"%s\" to message from %s - \"%s\" at %s\n",
str, from ? from : "unknown", subject ? subject : "", date);
-
+
break;
}
case FILTER_LOG_ACTION:
/* nothing else is loggable */
break;
}
-
+
g_free (str);
}
}
struct _CamelFilterDriverPrivate *p = _PRIVATE (data->driver);
CamelException *ex = data->ex;
ESExpResult *r;
-
+
d(printf ("evaluating: %s\n\n", action));
-
+
e_sexp_input_text (p->eval, action, strlen (action));
if (e_sexp_parse (p->eval) == -1) {
if (!camel_exception_is_set (ex))
e_sexp_error (p->eval), action);
goto done;
}
-
+
r = e_sexp_eval (p->eval);
if (r == NULL) {
if (!camel_exception_is_set (ex))
e_sexp_error (p->eval), action);
goto done;
}
-
+
e_sexp_result_free (p->eval, r);
-
+
done:
-
+
g_free (key);
g_free (action);
-
+
return TRUE;
}
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
struct _run_only_once data;
-
+
if (!p->only_once)
return;
-
+
data.driver = driver;
data.ex = ex;
-
+
g_hash_table_foreach_remove (p->only_once, (GHRFunc) run_only_once, &data);
}
int status;
off_t last = 0;
int ret = -1;
-
+
fd = g_open (mbox, O_RDONLY|O_BINARY, 0);
if (fd == -1) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Unable to open spool folder"));
}
/* to get the filesize */
fstat (fd, &st);
-
+
mp = camel_mime_parser_new ();
camel_mime_parser_scan_from (mp, TRUE);
if (camel_mime_parser_init_with_fd (mp, fd) == -1) {
goto fail;
}
fd = -1;
-
+
source_url = g_filename_to_uri (mbox, NULL, NULL);
-
+
while (camel_mime_parser_step (mp, 0, 0) == CAMEL_MIME_PARSER_STATE_FROM) {
CamelMessageInfo *info;
CamelMimeMessage *msg;
int pc = 0;
-
+
if (st.st_size > 0)
pc = (int)(100.0 * ((double)camel_mime_parser_tell (mp) / (double)st.st_size));
-
+
report_status (driver, CAMEL_FILTER_STATUS_START, pc, _("Getting message %d (%d%%)"), i, pc);
-
+
msg = camel_mime_message_new ();
if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg), mp) == -1) {
camel_exception_set (ex, (errno==EINTR)?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_SYSTEM, _("Cannot open message"));
camel_object_unref (msg);
goto fail;
}
-
+
info = camel_message_info_new_from_header(NULL, ((CamelMimePart *)msg)->headers);
((CamelMessageInfoBase *)info)->size = camel_mime_parser_tell(mp) - last;
last = camel_mime_parser_tell(mp);
- status = camel_filter_driver_filter_message (driver, msg, info, NULL, NULL, source_url,
+ status = camel_filter_driver_filter_message (driver, msg, info, NULL, NULL, source_url,
original_source_url ? original_source_url : source_url, ex);
camel_object_unref (msg);
if (camel_exception_is_set (ex) || status == -1) {
camel_message_info_free (info);
goto fail;
}
-
+
i++;
-
+
/* skip over the FROM_END state */
camel_mime_parser_step (mp, 0, 0);
camel_message_info_free (info);
}
-
+
if (p->defaultfolder) {
report_status(driver, CAMEL_FILTER_STATUS_PROGRESS, 100, _("Syncing folder"));
camel_folder_sync(p->defaultfolder, FALSE, camel_exception_is_set (ex) ? NULL : ex);
}
-
+
report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Complete"));
-
+
ret = 0;
fail:
g_free (source_url);
close (fd);
if (mp)
camel_object_unref (mp);
-
+
return ret;
}
int status = 0;
CamelURL *url;
int i;
-
+
service_url = camel_service_get_url (CAMEL_SERVICE (camel_folder_get_parent_store (folder)));
url = camel_url_new (service_url, NULL);
g_free (service_url);
-
+
source_url = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
camel_url_free (url);
-
+
if (uids == NULL) {
uids = camel_folder_get_uids (folder);
freeuids = TRUE;
}
-
+
for (i = 0; i < uids->len; i++) {
int pc = (100 * i)/uids->len;
-
+
report_status (driver, CAMEL_FILTER_STATUS_START, pc, _("Getting message %d of %d"), i+1,
uids->len);
-
+
if (camel_folder_has_summary_capability (folder))
info = camel_folder_get_message_info (folder, uids->pdata[i]);
else
info = NULL;
-
+
status = camel_filter_driver_filter_message (driver, NULL, info, uids->pdata[i],
folder, source_url, source_url, ex);
-
+
if (camel_folder_has_summary_capability (folder))
camel_folder_free_message_info (folder, info);
-
+
if (camel_exception_is_set (ex) || status == -1) {
report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Failed at message %d of %d"),
i+1, uids->len);
status = -1;
break;
}
-
+
if (remove)
camel_folder_set_message_flags (folder, uids->pdata[i],
CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN, ~0);
-
+
if (cache)
camel_uid_cache_save_uid (cache, uids->pdata[i]);
}
-
+
if (p->defaultfolder) {
report_status (driver, CAMEL_FILTER_STATUS_PROGRESS, 100, _("Syncing folder"));
camel_folder_sync (p->defaultfolder, FALSE, camel_exception_is_set (ex) ? NULL : ex);
}
-
+
if (i == uids->len)
report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Complete"));
-
+
if (freeuids)
camel_folder_free_uids (folder, uids);
-
+
g_free (source_url);
-
+
return status;
}
struct _CamelFilterDriverPrivate *p = msgdata->p;
const char *source_url = msgdata->source_url;
CamelMimeMessage *message;
-
+
if (p->message) {
message = p->message;
camel_object_ref (message);
} else {
const char *uid;
-
+
if (p->uid)
uid = p->uid;
else
uid = camel_message_info_uid (p->info);
-
+
message = camel_folder_get_message (p->source, uid, ex);
}
-
+
if (source_url && message && camel_mime_message_get_source (message) == NULL)
camel_mime_message_set_source (message, source_url);
-
+
return message;
}
gboolean filtered = FALSE;
ESExpResult *r;
int result;
-
+
/* FIXME: make me into a g_return_if_fail/g_assert or whatever... */
if (message == NULL && (source == NULL || uid == NULL)) {
g_warning ("there is no way to fetch the message using the information provided...");
return -1;
}
-
+
if (info == NULL) {
struct _camel_header_raw *h;
-
+
if (message) {
camel_object_ref (message);
} else {
if (!message)
return -1;
}
-
+
h = CAMEL_MIME_PART (message)->headers;
info = camel_message_info_new_from_header (NULL, h);
freeinfo = TRUE;
} else {
if (camel_message_info_flags(info) & CAMEL_MESSAGE_DELETED)
return 0;
-
+
uid = camel_message_info_uid (info);
-
+
if (message)
camel_object_ref (message);
}
-
+
p->ex = ex;
p->terminated = FALSE;
p->deleted = FALSE;
p->info = info;
p->uid = uid;
p->source = source;
-
+
if (message && original_source_url && camel_mime_message_get_source (message) == NULL)
camel_mime_message_set_source (message, original_source_url);
-
+
node = (struct _filter_rule *) p->rules.head;
result = CAMEL_SEARCH_NOMATCH;
while (node->next && !p->terminated) {
struct _get_message data;
-
+
d(printf("applying rule %s\naction %s\n", node->match, node->action));
-
+
data.p = p;
data.source_url = original_source_url;
-
- result = camel_filter_search_match (p->session, get_message_cb, &data, p->info,
+
+ result = camel_filter_search_match (p->session, get_message_cb, &data, p->info,
original_source_url ? original_source_url : source_url,
node->match, p->ex);
-
+
switch (result) {
case CAMEL_SEARCH_ERROR:
goto error;
default:
break;
}
-
+
node = node->next;
}
-
+
/* *Now* we can set the DELETED flag... */
if (p->deleted) {
if (p->source && p->uid && camel_folder_has_summary_capability (p->source))
else
camel_message_info_set_flags(info, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_FOLDER_FLAGGED, ~0);
}
-
+
/* Logic: if !Moved and there exists a default folder... */
if (!(p->copied && p->deleted) && !p->moved && p->defaultfolder) {
/* copy it to the default inbox */
if (!p->modified && p->uid && p->source && camel_folder_has_summary_capability (p->source)) {
GPtrArray *uids;
-
+
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (char *) p->uid);
camel_folder_transfer_messages_to (p->source, uids, p->defaultfolder, NULL, FALSE, p->ex);
camel_folder_append_message (p->defaultfolder, p->message, p->info, NULL, p->ex);
}
}
-
+
if (p->message)
camel_object_unref (p->message);
-
+
if (freeinfo)
camel_message_info_free (info);
-
+
return 0;
-
+
error:
if (filtered)
camel_filter_driver_log (driver, FILTER_LOG_END, NULL);
-
+
if (p->message)
camel_object_unref (p->message);
-
+
if (freeinfo)
camel_message_info_free (info);
-
+
return -1;
}
struct _CamelFilterDriver {
CamelObject parent;
-
+
struct _CamelFilterDriverPrivate *priv;
};
{
if (fms->message)
return fms->message;
-
+
fms->message = fms->get_message (fms->get_message_data, fms->ex);
-
+
if (fms->message == NULL)
e_sexp_fatal_error (sexp, _("Failed to retrieve message"));
-
+
return fms->message;
}
gboolean matched = FALSE;
ESExpResult *r;
int i;
-
+
if (argc > 1 && argv[0]->type == ESEXP_RES_STRING) {
char *name = argv[0]->value.string;
}
}
}
-
+
r = e_sexp_result_new (f, ESEXP_RES_BOOL);
r->value.bool = matched;
-
+
return r;
}
gboolean matched = FALSE;
ESExpResult *r;
int i;
-
+
message = camel_filter_search_get_message (fms, f);
-
+
for (i = 0; i < argc && !matched; i++) {
if (argv[i]->type == ESEXP_RES_STRING)
matched = camel_medium_get_header (CAMEL_MEDIUM (message), argv[i]->value.string) != NULL;
}
-
+
r = e_sexp_result_new (f, ESEXP_RES_BOOL);
r->value.bool = matched;
-
+
return r;
}
CamelMimeMessage *message;
regex_t pattern;
const char *contents;
-
+
message = camel_filter_search_get_message (fms, f);
-
+
if (argc > 1 && argv[0]->type == ESEXP_RES_STRING
&& (contents = camel_medium_get_header (CAMEL_MEDIUM (message), argv[0]->value.string))
&& camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE, argc-1, argv+1, fms->ex) == 0) {
regfree (&pattern);
} else
r->value.bool = FALSE;
-
+
return r;
}
GString *str = g_string_new ("");
char *ret;
struct _camel_header_raw *h;
-
+
for (h = mp->headers; h; h = h->next) {
if (h->value != NULL) {
g_string_append (str, h->name);
g_string_append_c(str, '\n');
}
}
-
+
ret = str->str;
g_string_free (str, FALSE);
-
+
return ret;
}
CamelMimeMessage *message;
regex_t pattern;
char *contents;
-
+
if (camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE|CAMEL_SEARCH_MATCH_NEWLINE,
argc, argv, fms->ex) == 0) {
message = camel_filter_search_get_message (fms, f);
regfree (&pattern);
} else
r->value.bool = FALSE;
-
+
return r;
}
{
/* match-all: when dealing with single messages is a no-op */
ESExpResult *r;
-
+
if (argc > 0)
return e_sexp_term_eval (f, argv[0]);
-
+
r = e_sexp_result_new (f, ESEXP_RES_BOOL);
r->value.bool = TRUE;
-
+
return r;
}
ESExpResult *r = e_sexp_result_new (f, ESEXP_RES_BOOL);
CamelMimeMessage *message;
regex_t pattern;
-
+
if (camel_search_build_match_regex (&pattern, CAMEL_SEARCH_MATCH_ICASE, argc, argv, fms->ex) == 0) {
message = camel_filter_search_get_message (fms, f);
r->value.bool = camel_search_message_body_contains ((CamelDataWrapper *) message, &pattern);
regfree (&pattern);
} else
r->value.bool = FALSE;
-
+
return r;
}
ESExpResult *r = e_sexp_result_new(f, ESEXP_RES_BOOL);
CamelMimeMessage *message;
regex_t pattern;
-
+
if (camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_ICASE|CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_NEWLINE,
argc, argv, fms->ex) == 0) {
message = camel_filter_search_get_message (fms, f);
regfree (&pattern);
} else
r->value.bool = FALSE;
-
+
return r;
}
ESExpResult *r;
gboolean truth = FALSE;
int i;
-
+
/* performs an OR of all words */
for (i = 0; i < argc && !truth; i++) {
if (argv[i]->type == ESEXP_RES_STRING
break;
}
}
-
+
r = e_sexp_result_new (f, ESEXP_RES_BOOL);
r->value.bool = truth;
-
+
return r;
}
system_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms)
{
ESExpResult *r;
-
+
if (argc != 1 || argv[0]->type != ESEXP_RES_STRING)
e_sexp_fatal_error(f, _("Invalid arguments to (system-flag)"));
-
+
r = e_sexp_result_new (f, ESEXP_RES_BOOL);
r->value.bool = camel_system_flag_get (camel_message_info_flags(fms->info), argv[0]->value.string);
-
+
return r;
}
if (argc != 1 || argv[0]->type != ESEXP_RES_STRING)
e_sexp_fatal_error(f, _("Invalid arguments to (user-tag)"));
-
+
tag = camel_message_info_user_tag(fms->info, argv[0]->value.string);
-
+
r = e_sexp_result_new (f, ESEXP_RES_STRING);
r->value.string = g_strdup (tag ? tag : "");
-
+
return r;
}
{
CamelMimeMessage *message;
ESExpResult *r;
-
+
message = camel_filter_search_get_message (fms, f);
r = e_sexp_result_new (f, ESEXP_RES_INT);
r->value.number = camel_mime_message_get_date (message, NULL);
-
+
return r;
}
{
CamelMimeMessage *message;
ESExpResult *r;
-
+
message = camel_filter_search_get_message (fms, f);
r = e_sexp_result_new (f, ESEXP_RES_INT);
r->value.number = camel_mime_message_get_date_received (message, NULL);
-
+
return r;
}
get_current_date (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms)
{
ESExpResult *r;
-
+
r = e_sexp_result_new (f, ESEXP_RES_INT);
r->value.number = time (NULL);
-
+
return r;
}
r = e_sexp_result_new(f, ESEXP_RES_BOOL);
r->value.bool = truth;
-
+
return r;
}
get_size (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms)
{
ESExpResult *r;
-
+
r = e_sexp_result_new(f, ESEXP_RES_INT);
r->value.number = camel_message_info_size(fms->info) / 1024;
child_watch_data_t child_watch_data;
GSource *source;
GMainContext *context;
-
+
if (argc < 1 || argv[0]->value.string[0] == '\0')
return 0;
-
+
args = g_ptr_array_new ();
for (i = 0; i < argc; i++)
g_ptr_array_add (args, argv[i]->value.string);
g_ptr_array_add (args, NULL);
-
+
if (!g_spawn_async_with_pipes (NULL,
(gchar **) args->pdata,
NULL,
g_error_free (error);
return -1;
}
-
+
g_ptr_array_free (args, TRUE);
-
+
message = camel_filter_search_get_message (fms, f);
-
+
stream = camel_stream_fs_new_with_fd (pipe_to_child);
camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream);
camel_stream_flush (stream);
camel_object_unref (stream);
-
+
context = g_main_context_new ();
child_watch_data.loop = g_main_loop_new (context, FALSE);
g_main_context_unref (context);
{
ESExpResult *r;
int retval, i;
-
+
/* make sure all args are strings */
for (i = 0; i < argc; i++) {
if (argv[i]->type != ESEXP_RES_STRING) {
goto done;
}
}
-
+
retval = run_command (f, argc, argv, fms);
-
+
done:
r = e_sexp_result_new (f, ESEXP_RES_INT);
r->value.number = retval;
-
+
return r;
}
if (fms->session->junk_plugin != NULL) {
retval = camel_junk_plugin_check_junk (fms->session->junk_plugin, camel_filter_search_get_message (fms, f));
-
+
if (camel_debug ("junk"))
printf("junk filter => %s\n", retval ? "*JUNK*" : "clean");
}
fms.info = info;
fms.source = source;
fms.ex = ex;
-
+
sexp = e_sexp_new ();
-
+
for (i = 0; i < sizeof (symbols) / sizeof (symbols[0]); i++) {
if (symbols[i].type == 1)
e_sexp_add_ifunction (sexp, 0, symbols[i].name, (ESExpIFunc *)symbols[i].func, &fms);
else
e_sexp_add_function (sexp, 0, symbols[i].name, symbols[i].func, &fms);
}
-
+
e_sexp_input_text (sexp, expression, strlen (expression));
if (e_sexp_parse (sexp) == -1) {
if (!camel_exception_is_set (ex))
e_sexp_error (sexp), expression);
goto error;
}
-
+
result = e_sexp_eval (sexp);
if (result == NULL) {
if (!camel_exception_is_set (ex))
e_sexp_error (sexp), expression);
goto error;
}
-
+
if (result->type == ESEXP_RES_BOOL)
retval = result->value.bool ? CAMEL_SEARCH_MATCHED : CAMEL_SEARCH_NOMATCH;
else
retval = CAMEL_SEARCH_NOMATCH;
-
+
e_sexp_result_free (sexp, result);
e_sexp_unref (sexp);
-
+
if (fms.message)
camel_object_unref (fms.message);
-
+
return retval;
-
+
error:
if (fms.message)
camel_object_unref (fms.message);
-
+
e_sexp_unref (sexp);
-
+
return CAMEL_SEARCH_ERROR;
}
#include "camel-search-private.h"
#include "camel-stream-mem.h"
-#define d(x)
-#define r(x)
+#define d(x)
+#define r(x)
struct _CamelFolderSearchPrivate {
GHashTable *mempool_hash;
camel_folder_search_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_object_get_type (), "CamelFolderSearch",
sizeof (CamelFolderSearch),
(CamelObjectInitFunc) camel_folder_search_init,
(CamelObjectFinalizeFunc) camel_folder_search_finalize);
}
-
+
return type;
}
* camel_folder_search_new:
*
* Create a new CamelFolderSearch object.
- *
+ *
* A CamelFolderSearch is a subclassable, extensible s-exp
* evaluator which enforces a particular set of s-expressions.
* Particular methods may be overriden by an implementation to
* camel_folder_search_set_folder:
* @search:
* @folder: A folder.
- *
+ *
* Set the folder attribute of the search. This is currently unused, but
* could be used to perform a slow-search when indexes and so forth are not
* available. Or for use by subclasses.
/**
* camel_folder_search_set_summary:
- * @search:
+ * @search:
* @summary: An array of CamelMessageInfo pointers.
- *
+ *
* Set the array of summary objects representing the span of the search.
*
* If this is not set, then a subclass must provide the functions
/**
* camel_folder_search_set_body_index:
- * @search:
- * @index:
- *
+ * @search:
+ * @index:
+ *
* Set the index representing the contents of all messages
* in this folder. If this is not set, then the folder implementation
* should sub-class the CamelFolderSearch and provide its own
/**
* camel_folder_search_execute_expression:
- * @search:
- * @expr:
- * @ex:
- *
+ * @search:
+ * @expr:
+ * @ex:
+ *
* Execute the search expression @expr, returning an array of
* all matches as a GPtrArray of uid's of matching messages.
*
*
* TODO: The interface should probably return summary items instead
* (since they are much more useful to any client).
- *
+ *
* Return value: A GPtrArray of strings of all matching messages.
* This must only be freed by camel_folder_search_free_result.
**/
/**
* camel_folder_search_search:
- * @search:
- * @expr:
+ * @search:
+ * @expr:
* @uids: to search against, NULL for all uid's.
- * @ex:
- *
+ * @ex:
+ *
* Run a search. Search must have had Folder already set on it, and
* it must implement summaries.
- *
- * Return value:
+ *
+ * Return value:
**/
GPtrArray *
camel_folder_search_search(CamelFolderSearch *search, const char *expr, GPtrArray *uids, CamelException *ex)
search_header_exists (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search)
{
ESExpResult *r;
-
+
r(printf ("executing header-exists\n"));
-
+
if (search->current) {
r = e_sexp_result_new(f, ESEXP_RES_BOOL);
if (argc == 1 && argv[0]->type == ESEXP_RES_STRING)
r->value.bool = camel_medium_get_header(CAMEL_MEDIUM(search->current), argv[0]->value.string) != NULL;
-
+
} else {
r = e_sexp_result_new(f, ESEXP_RES_ARRAY_PTR);
r->value.ptrarray = g_ptr_array_new();
}
-
+
return r;
}
int i;
/* we can have a maximum of 32 words, as we use it as the AND mask */
-
+
wc = camel_index_words(search->body_index);
if (wc) {
while ((word = camel_index_cursor_next(wc))) {
CamelDataWrapper *containee;
int truth = FALSE;
int parts, i;
-
+
containee = camel_medium_get_content_object (CAMEL_MEDIUM (object));
-
+
if (containee == NULL)
return FALSE;
-
+
/* using the object types is more accurate than using the mime/types */
if (CAMEL_IS_MULTIPART (containee)) {
parts = camel_multipart_get_number (CAMEL_MULTIPART (containee));
return TRUE;
}
}
-
+
camel_object_unref (mem);
}
-
+
return truth;
}
for (i=0;i<indexed->len;i++) {
const char *uid = g_ptr_array_index(indexed, i);
-
+
if (match_words_message(search->folder, uid, words, ex))
g_ptr_array_add(matches, (char *)uid);
}
-
+
g_ptr_array_free(indexed, TRUE);
} else {
GPtrArray *v = search->summary_set?search->summary_set:search->summary;
for (i=0;i<v->len;i++) {
CamelMessageInfo *info = g_ptr_array_index(v, i);
const char *uid = camel_message_info_uid(info);
-
+
if (match_words_message(search->folder, uid, words, ex))
g_ptr_array_add(matches, (char *)uid);
}
ESExpResult *r;
struct _glib_sux_donkeys lambdafoo;
- if (search->current) {
+ if (search->current) {
int truth = FALSE;
if (argc == 1 && argv[0]->value.string[0] == 0) {
search_system_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search)
{
ESExpResult *r;
-
+
r(printf ("executing system-flag\n"));
-
+
if (search->current) {
gboolean truth = FALSE;
-
+
if (argc == 1)
truth = camel_system_flag_get (camel_message_info_flags(search->current), argv[0]->value.string);
-
+
r = e_sexp_result_new(f, ESEXP_RES_BOOL);
r->value.bool = truth;
} else {
r = e_sexp_result_new(f, ESEXP_RES_ARRAY_PTR);
r->value.ptrarray = g_ptr_array_new ();
}
-
+
return r;
}
{
const char *value = NULL;
ESExpResult *r;
-
+
r(printf("executing user-tag\n"));
-
+
if (argc == 1)
value = camel_message_info_user_tag(search->current, argv[0]->value.string);
-
+
r = e_sexp_result_new(f, ESEXP_RES_STRING);
r->value.string = g_strdup (value ? value : "");
-
+
return r;
}
search_get_size (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s)
{
ESExpResult *r;
-
+
r(printf("executing get-size\n"));
-
+
/* are we inside a match-all? */
if (s->current) {
r = e_sexp_result_new (f, ESEXP_RES_INT);
r = e_sexp_result_new (f, ESEXP_RES_ARRAY_PTR);
r->value.ptrarray = g_ptr_array_new ();
}
-
+
return r;
}
/* (header-contains "headername" "string1" ...) List of matches, or true if in single-message mode */
ESExpResult * (*header_contains)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
-
+
/* (header-matches "headername" "string") */
ESExpResult * (*header_matches)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
-
+
/* (header-starts-with "headername" "string") */
ESExpResult * (*header_starts_with)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
-
+
/* (header-ends-with "headername" "string") */
ESExpResult * (*header_ends_with)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
-
+
/* (header-exists "headername") */
ESExpResult * (*header_exists)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
-
+
/* (user-flag "flagname" "flagname" ...) If one of user-flag set */
ESExpResult * (*user_flag)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
/* (user-tag "flagname") Returns the value of a user tag. Can only be used in match-all */
ESExpResult * (*user_tag)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
-
+
/* (system-flag "flagname") Returns the value of a system flag. Can only be used in match-all */
ESExpResult * (*system_flag)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
-
+
/* (get-sent-date) Retrieve the date that the message was sent on as a time_t */
ESExpResult * (*get_sent_date)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
s->messages = g_ptr_array_new();
s->messages_uid = g_hash_table_new(g_str_hash, g_str_equal);
-
+
p->summary_lock = g_mutex_new();
p->io_lock = g_mutex_new();
p->filter_lock = g_mutex_new();
s->meta_summary = g_malloc0(sizeof(CamelFolderMetaSummary));
/* Default is 20, any implementor having UIDs that has length
- exceeding 20, has to override this value
+ exceeding 20, has to override this value
*/
s->meta_summary->uid_len = 20;
}
/* Freeing memory occupied by meta-summary-header */
g_free(s->meta_summary->path);
g_free(s->meta_summary);
-
+
g_mutex_free(p->summary_lock);
g_mutex_free(p->io_lock);
g_mutex_free(p->filter_lock);
g_mutex_free(p->alloc_lock);
g_mutex_free(p->ref_lock);
-
+
g_free(p);
}
camel_folder_summary_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_object_get_type (), "CamelFolderSummary",
sizeof (CamelFolderSummary),
(CamelObjectInitFunc) camel_folder_summary_init,
(CamelObjectFinalizeFunc) camel_folder_summary_finalize);
}
-
+
return type;
}
* @folder: parent #CamelFolder object
*
* Create a new #CamelFolderSummary object.
- *
+ *
* Returns a new #CamelFolderSummary object
**/
CamelFolderSummary *
* camel_folder_summary_set_filename:
* @summary: a #CamelFolderSummary object
* @filename: a filename
- *
+ *
* Set the filename where the summary will be loaded to/saved from.
**/
void
* camel_folder_summary_set_index:
* @summary: a #CamelFolderSummary object
* @index: a #CamelIndex
- *
+ *
* Set the index used to index body content. If the index is %NULL, or
* not set (the default), no indexing of body content will take place.
*
* camel_folder_summary_set_build_content:
* @summary: a #CamelFolderSummary object
* @state: to build or not to build the content
- *
+ *
* Set a flag to tell the summary to build the content info summary
* (#CamelMessageInfo.content). The default is not to build content
* info summaries.
/**
* camel_folder_summary_count:
* @summary: a #CamelFolderSummary object
- *
+ *
* Get the number of summary items stored in this summary.
- *
+ *
* Returns the number of items in the summary
**/
int
* camel_folder_summary_index:
* @summary: a #CamelFolderSummary object
* @index: item index
- *
+ *
* Retrieve a summary item by index number.
*
* A referenced to the summary item is returned, which may be
* ref'd or free'd as appropriate.
- *
+ *
* Returns the summary item, or %NULL if @index is out of range
**/
CamelMessageInfo *
/**
* camel_folder_summary_array:
* @summary: a #CamelFolderSummary object
- *
+ *
* Obtain a copy of the summary array. This is done atomically,
* so cannot contain empty entries.
*
CamelMessageInfo *info;
GPtrArray *res = g_ptr_array_new();
int i;
-
+
CAMEL_SUMMARY_LOCK(s, summary_lock);
CAMEL_SUMMARY_LOCK(s, ref_lock);
* camel_folder_summary_array_free:
* @summary: a #CamelFolderSummary object
* @array: array of #CamelMessageInfo items as returned from #camel_folder_summary_array
- *
+ *
* Free the folder summary array.
**/
void
* camel_folder_summary_uid:
* @summary: a #CamelFolderSummary object
* @uid: a uid
- *
+ *
* Retrieve a summary item by uid.
*
* A referenced to the summary item is returned, which may be
* ref'd or free'd as appropriate.
- *
+ *
* Returns the summary item, or %NULL if the uid @uid is not available
**/
CamelMessageInfo *
/**
* camel_folder_summary_next_uid:
* @summary: a #CamelFolderSummary object
- *
+ *
* Generate a new unique uid value as an integer. This
* may be used to create a unique sequence of numbers.
- *
+ *
* Returns the next unique uid value
**/
guint32
* @summary: a #CamelFolderSummary object
* @uid: The next minimum uid to assign. To avoid clashing
* uid's, set this to the uid of a given messages + 1.
- *
+ *
* Set the next minimum uid available. This can be used to
* ensure new uid's do not clash with existing uid's.
**/
}
CAMEL_SUMMARY_UNLOCK(s, io_lock);
-
+
if (fclose (in) != 0)
return -1;
error:
if (errno != EINVAL)
g_warning ("Cannot load summary file: `%s': %s", s->summary_path, g_strerror (errno));
-
+
CAMEL_SUMMARY_UNLOCK(s, io_lock);
fclose (in);
s->flags |= ~CAMEL_SUMMARY_DIRTY;
if (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->content_info_save (s, out, ci) == -1)
return -1;
-
+
if (camel_file_util_encode_uint32 (out, my_list_size ((struct _node **)&ci->childs)) == -1)
return -1;
-
+
part = ci->childs;
while (part) {
if (perform_content_info_save (s, out, part) == -1)
return -1;
part = part->next;
}
-
+
return 0;
}
/**
* camel_folder_summary_save:
* @summary: a #CamelFolderSummary object
- *
+ *
* Writes the summary to disk. The summary is only written if changes
* have occured.
- *
+ *
* Returns %0 on success or %-1 on fail
**/
int
g_assert(s->message_info_size >= sizeof(CamelMessageInfoBase));
- if (s->summary_path == NULL
+ if (s->summary_path == NULL
|| s->meta_summary->path == NULL
|| (s->flags & CAMEL_SUMMARY_DIRTY) == 0)
return 0;
}
/* Meta summary code */
- /* This meta summary will be used by beagle in order to
- quickly pass through the actual summary file, which
+ /* This meta summary will be used by beagle in order to
+ quickly pass through the actual summary file, which
is quite time consuming otherwise.
*/
/* FIXME: Merge meta-summary and summary */
if (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_save(s, out) == -1)
goto exception;
-
+
if (summary_meta_header_save(s, out_meta) == -1)
goto exception;
mi = s->messages->pdata[i];
if (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->meta_message_info_save (s, out_meta, out, mi) == -1)
goto exception;
-
+
if (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->message_info_save (s, out, mi) == -1)
goto exception;
goto exception;
}
}
-
+
/* FIXME: Can't we use the above "fd" variables, instead of fileno()? */
if (fflush (out) != 0 || fsync (fileno (out)) == -1)
goto exception;
-
+
if (fflush (out_meta) != 0 || fsync (fileno (out_meta)) == -1)
goto exception;
fclose (out_meta);
CAMEL_SUMMARY_UNLOCK(s, io_lock);
-
+
#ifdef G_OS_WIN32
g_unlink(s->summary_path);
#endif
errno = i;
return -1;
}
-
+
s->flags &= ~CAMEL_SUMMARY_DIRTY;
return 0;
-
+
exception:
-
+
i = errno;
-
+
fclose (out);
fclose (out_meta);
-
+
CAMEL_SUMMARY_UNLOCK(s, io_lock);
-
+
g_unlink (path);
g_unlink (path_meta);
errno = i;
-
+
return -1;
}
/**
* camel_folder_summary_header_load:
* @summary: a #CamelFolderSummary object
- *
+ *
* Only load the header information from the summary,
* keep the rest on disk. This should only be done on
* a fresh summary object.
- *
+ *
* Returns %0 on success or %-1 on fail
**/
int
ret = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_load(s, in);
ret = summary_meta_header_load(s, in_meta);
CAMEL_SUMMARY_UNLOCK(s, io_lock);
-
+
fclose(in);
fclose(in_meta);
s->flags &= ~CAMEL_SUMMARY_DIRTY;
* camel_folder_summary_add:
* @summary: a #CamelFolderSummary object
* @info: a #CamelMessageInfo
- *
+ *
* Adds a new @info record to the summary. If @info->uid is %NULL,
* then a new uid is automatically re-assigned by calling
* #camel_folder_summary_next_uid_string.
* camel_folder_summary_add_from_header:
* @summary: a #CamelFolderSummary object
* @headers: rfc822 headers
- *
+ *
* Build a new info record based on a set of headers, and add it to
* the summary.
*
* Note that this function should not be used if build_content_info
* has been specified for this summary.
- *
+ *
* Returns the newly added record
**/
CamelMessageInfo *
* camel_folder_summary_add_from_parser:
* @summary: a #CamelFolderSummary object
* @parser: a #CamelMimeParser object
- *
+ *
* Build a new info record based on the current position of a #CamelMimeParser.
*
* The parser should be positioned before the start of the message to summarise.
* This function may be used if build_contnet_info or an index has been
* specified for the summary.
- *
+ *
* Returns the newly added record
**/
CamelMessageInfo *
* camel_folder_summary_add_from_message:
* @summary: a #CamelFolderSummary object
* @message: a #CamelMimeMessage object
- *
+ *
* Add a summary item from an existing message.
- *
+ *
* Returns the newly added record
**/
CamelMessageInfo *
* camel_folder_summary_info_new_from_header:
* @summary: a #CamelFolderSummary object
* @headers: rfc822 headers
- *
+ *
* Create a new info record from a header.
*
* Returns the newly allocated record which must be freed with
* camel_folder_summary_info_new_from_parser:
* @summary: a #CamelFolderSummary object
* @parser: a #CamelMimeParser object
- *
+ *
* Create a new info record from a parser. If the parser cannot
* determine a uid, then none will be assigned.
*
* camel_folder_summary_info_new_from_message:
* @summary: a #CamelFodlerSummary object
* @message: a #CamelMimeMessage object
- *
+ *
* Create a summary item from a message.
- *
+ *
* Returns the newly allocated record which must be freed using
* #camel_message_info_free
**/
* camel_folder_summary_content_info_free:
* @summary: a #CamelFolderSummary object
* @ci: a #CamelMessageContentInfo
- *
+ *
* Free the content info @ci, and all associated memory.
**/
void
/**
* camel_folder_summary_touch:
* @summary: a #CamelFolderSummary object
- *
+ *
* Mark the summary as changed, so that a save will force it to be
* written back to disk.
**/
/**
* camel_folder_summary_clear:
* @summary: a #CamelFolderSummary object
- *
+ *
* Empty the summary contents.
**/
void
* camel_folder_summary_remove:
* @summary: a #CamelFolderSummary object
* @info: a #CamelMessageInfo
- *
+ *
* Remove a specific @info record from the summary.
**/
void
s->flags |= CAMEL_SUMMARY_DIRTY;
s->meta_summary->msg_expunged = TRUE;
CAMEL_SUMMARY_UNLOCK(s, summary_lock);
-
+
camel_message_info_free(info);
}
* camel_folder_summary_remove_uid:
* @summary: a #CamelFolderSummary object
* @uid: a uid
- *
+ *
* Remove a specific info record from the summary, by @uid.
**/
void
* camel_folder_summary_remove_index:
* @summary: a #CamelFolderSummary object
* @index: record index
- *
+ *
* Remove a specific info record from the summary, by index.
**/
void
* @summary: a #CamelFolderSummary object
* @start: initial index
* @end: last index to remove
- *
+ *
* Removes an indexed range of info records.
**/
void
* camel_folder_summary_encode_token:
* @out: output FILE pointer
* @str: string token to encode
- *
+ *
* Encode a string value, but use tokenisation and compression
* to reduce the size taken for common mailer words. This
* can still be used to encode normal strings as well.
- *
+ *
* Returns %0 on success or %-1 on fail
**/
int
* camel_folder_summary_decode_token:
* @in: input FILE pointer
* @str: string pointer to hold the decoded result
- *
+ *
* Decode a token value.
- *
+ *
* Returns %0 on success or %-1 on fail
**/
int
guint32 len;
io(printf("Decode token ...\n"));
-
+
if (camel_file_util_decode_uint32(in, &len) == -1) {
io(printf ("Could not decode token from file"));
*str = NULL;
|| camel_file_util_decode_uint32(in, &s->meta_summary->uid_len) == -1) {
return -1;
}
-
+
return 0;
}
} else {
ret = g_strdup (text);
}
-
+
return ret;
}
summary_format_string (struct _camel_header_raw *h, const char *name, const char *charset)
{
const char *text;
-
+
text = camel_header_raw_find (&h, name, NULL);
if (text) {
while (isspace ((unsigned) *text))
/**
* camel_folder_summary_content_info_new:
* @summary: a #CamelFolderSummary object
- *
+ *
* Allocate a new #CamelMessageContentInfo, suitable for adding
* to this summary.
- *
+ *
* Returns a newly allocated #CamelMessageContentInfo
**/
CamelMessageContentInfo *
&& (charset = camel_content_type_param(ct, "charset"))
&& (g_ascii_strcasecmp(charset, "us-ascii") == 0))
charset = NULL;
-
+
charset = charset ? e_iconv_charset_name (charset) : NULL;
-
+
subject = summary_format_string(h, "subject", charset);
from = summary_format_address(h, "from", charset);
to = summary_format_address(h, "to", charset);
if (ct)
camel_content_type_unref(ct);
-
+
mi->subject = camel_pstring_add (subject, TRUE);
mi->from = camel_pstring_add (from, TRUE);
mi->to = camel_pstring_add (to, TRUE);
mi->cc = camel_pstring_add (cc, TRUE);
mi->mlist = camel_pstring_add (mlist, TRUE);
-
+
mi->user_flags = NULL;
mi->user_tags = NULL;
mi->date_sent = camel_header_decode_date(camel_header_raw_find(&h, "date", NULL), NULL);
memcpy(mi->message_id.id.hash, digest, sizeof(mi->message_id.id.hash));
g_free(msgid);
}
-
+
/* decode our references and in-reply-to headers */
refs = camel_header_references_decode (camel_header_raw_find (&h, "references", NULL));
irt = camel_header_references_inreplyto_decode (camel_header_raw_find (&h, "in-reply-to", NULL));
/* The References field is populated from the ``References'' and/or ``In-Reply-To''
headers. If both headers exist, take the first thing in the In-Reply-To header
that looks like a Message-ID, and append it to the References header. */
-
+
if (refs)
irt->next = refs;
-
+
refs = irt;
}
-
+
count = camel_header_references_list_size(&refs);
mi->references = g_malloc(sizeof(*mi->references) + ((count-1) * sizeof(mi->references->references[0])));
count = 0;
camel_file_util_decode_string(in, &to);
camel_file_util_decode_string(in, &cc);
camel_file_util_decode_string(in, &mlist);
-
+
mi->uid = uid;
mi->subject = camel_pstring_add (subject, TRUE);
mi->from = camel_pstring_add (from, TRUE);
mi->to = camel_pstring_add (to, TRUE);
mi->cc = camel_pstring_add (cc, TRUE);
mi->mlist = camel_pstring_add (mlist, TRUE);
-
+
mi->content = NULL;
camel_file_util_decode_fixed_int32(in, &mi->message_id.id.part.hi);
time (×tamp);
offset = ftell (out);
/* FIXME: errno check after ftell */
-
+
camel_file_util_encode_time_t(out_meta, timestamp);
camel_file_util_encode_fixed_string(out_meta, camel_message_info_uid(mi), s->meta_summary->uid_len);
camel_file_util_encode_uint32(out_meta, mi->flags);
- camel_file_util_encode_off_t(out_meta, offset);
+ camel_file_util_encode_off_t(out_meta, offset);
return ferror(out);
}
{
CamelMessageContentInfo *ci;
const char *charset;
-
+
ci = camel_folder_summary_content_info_new (s);
-
+
charset = e_iconv_locale_charset ();
ci->id = camel_header_msgid_decode (camel_header_raw_find (&h, "content-id", NULL));
ci->description = camel_header_decode_string (camel_header_raw_find (&h, "content-description", NULL), charset);
io(printf("Loading content info\n"));
ci = camel_folder_summary_content_info_new(s);
-
+
camel_folder_summary_decode_token(in, &type);
camel_folder_summary_decode_token(in, &subtype);
ct = camel_content_type_new(type, subtype);
g_free(subtype);
if (camel_file_util_decode_uint32(in, &count) == -1 || count > 500)
goto error;
-
+
for (i=0;i<count;i++) {
char *name, *value;
camel_folder_summary_decode_token(in, &name);
camel_folder_summary_decode_token(in, &value);
if (!(name && value))
goto error;
-
+
camel_content_type_set_param(ct, name, value);
/* TODO: do this so we dont have to double alloc/free */
g_free(name);
/* start of this part */
state = camel_mime_parser_step(mp, &buffer, &len);
-
+
if (s->build_content)
info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_new_from_parser(s, mp);
const char *charset;
d(printf("generating index:\n"));
-
+
encoding = camel_content_transfer_encoding_decode(camel_mime_parser_header(mp, "content-transfer-encoding", NULL));
if (encoding) {
if (!g_ascii_strcasecmp(encoding, "base64")) {
camel_mime_filter_reset((CamelMimeFilter *)p->filter_html);
html_id = camel_mime_parser_filter_add(mp, (CamelMimeFilter *)p->filter_html);
}
-
+
/* and this filter actually does the indexing */
idx_id = camel_mime_parser_filter_add(mp, (CamelMimeFilter *)p->filter_index);
}
if (s->build_content)
info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_new_from_message(s, object);
-
+
containee = camel_medium_get_content_object(CAMEL_MEDIUM(object));
if (containee == NULL)
* camel_flag_get:
* @list: the address of a #CamelFlag list
* @name: name of the flag to get
- *
+ *
* Find the state of the flag @name in @list.
- *
+ *
* Returns the state of the flag (%TRUE or %FALSE)
**/
gboolean
* @list: the address of a #CamelFlag list
* @name: name of the flag to set or change
* @value: the value to set on the flag
- *
+ *
* Set the state of a flag @name in the list @list to @value.
*
* Returns %TRUE if the value of the flag has been changed or %FALSE
/**
* camel_flag_list_size:
* @list: the address of a #CamelFlag list
- *
+ *
* Get the length of the flag list.
- *
+ *
* Returns the number of flags in the list
**/
int
/**
* camel_flag_list_free:
* @list: the address of a #CamelFlag list
- *
+ *
* Free the memory associated with the flag list @list.
**/
void
* camel_flag_list_copy:
* @to: the address of the #CamelFlag list to copy to
* @from: the address of the #CamelFlag list to copy from
- *
+ *
* Copy a flag list.
- *
+ *
* Returns %TRUE if @to is changed or %FALSE otherwise
**/
gboolean
* @name: name of the tag to get
*
* Find the flag @name in @list and get the value.
- *
+ *
* Returns the value of the flag or %NULL if unset
**/
const char *
* @list: the address of a #CamelTag list
* @name: name of the tag to set
* @value: value to set on the tag
- *
+ *
* Set the tag @name in the tag list @list to @value.
*
* Returns %TRUE if the value on the tag changed or %FALSE otherwise
/**
* camel_tag_list_size:
* @list: the address of a #CamelTag list
- *
+ *
* Get the number of tags present in the tag list @list.
- *
+ *
* Returns the number of tags
**/
int
* camel_tag_list_copy:
* @to: the address of the #CamelTag list to copy to
* @from: the address of the #CamelTag list to copy from
- *
+ *
* Copy a tag list.
- *
+ *
* Returns %TRUE if @to is changed or %FALSE otherwise
**/
gboolean
/**
* camel_tag_list_free:
* @list: the address of a #CamelTag list
- *
+ *
* Free the tag list @list.
**/
void
/**
* camel_system_flag:
* @name: name of a system flag
- *
+ *
* Returns the integer value of the system flag string
**/
guint32
camel_system_flag (const char *name)
{
struct flag_names_t *flag;
-
+
g_return_val_if_fail (name != NULL, 0);
-
+
for (flag = flag_names; *flag->name; flag++)
if (!g_ascii_strcasecmp (name, flag->name))
return flag->value;
-
+
return 0;
}
* camel_system_flag_get:
* @flags: bitwise system flags
* @name: name of the flag to check for
- *
+ *
* Find the state of the flag @name in @flags.
- *
+ *
* Returns %TRUE if the named flag is set or %FALSE otherwise
**/
gboolean
camel_system_flag_get (guint32 flags, const char *name)
{
g_return_val_if_fail (name != NULL, FALSE);
-
+
return flags & camel_system_flag (name);
}
/**
* camel_message_info_ref:
* @info: a #CamelMessageInfo
- *
+ *
* Reference an info.
**/
void
camel_content_info_dump (CamelMessageContentInfo *ci, int depth)
{
char *p;
-
+
p = alloca (depth * 4 + 1);
memset (p, ' ', depth * 4);
p[depth * 4] = 0;
-
+
if (ci == NULL) {
printf ("%s<empty>\n", p);
return;
}
-
+
if (ci->type)
printf ("%scontent-type: %s/%s\n", p, ci->type->type ? ci->type->type : "(null)",
ci->type->subtype ? ci->type->subtype : "(null)");
describe the content structure of the message (if it has any) */
struct _CamelMessageContentInfo {
struct _CamelMessageContentInfo *next;
-
+
struct _CamelMessageContentInfo *childs;
struct _CamelMessageContentInfo *parent;
-
+
CamelContentType *type;
char *id;
char *description;
CAMEL_MESSAGE_DRAFT = 1<<2,
CAMEL_MESSAGE_FLAGGED = 1<<3,
CAMEL_MESSAGE_SEEN = 1<<4,
-
+
/* these aren't really system flag bits, but are convenience flags */
CAMEL_MESSAGE_ATTACHMENTS = 1<<5,
CAMEL_MESSAGE_ANSWERED_ALL = 1<<6,
CAMEL_MESSAGE_SECURE = 1<<8,
CAMEL_MESSAGE_USER_NOT_DELETABLE = 1<<9,
CAMEL_MESSAGE_HIDDEN = 1<<10,
-
+
/* following flags are for the folder, and are not really permanent flags */
CAMEL_MESSAGE_FOLDER_FLAGGED = 1<<16, /* for use by the folder implementation */
CamelMessageContentInfo *content;
};
-/* probably do this as well, removing CamelFolderChangeInfo and interfaces
+/* probably do this as well, removing CamelFolderChangeInfo and interfaces
typedef struct _CamelChangeInfo CamelChangeInfo;
struct _CamelChangeInfo {
GPtrArray *added;
#include "camel-folder-thread.h"
-#define d(x)
-#define m(x)
+#define d(x)
+#define m(x)
/*#define TIMEIT*/
{
char *s, *p;
CamelFolderThreadNode *scan;
-
+
s = NULL;
c->re = FALSE;
if (c->message)
GHashTable *subject_table = g_hash_table_new(g_str_hash, g_str_equal);
CamelFolderThreadNode *c, *clast, *scan, *container;
- /* gather subject lines */
+ /* gather subject lines */
d(printf("gathering subject lines\n"));
clast = (CamelFolderThreadNode *)cp;
c = clast->next;
const CamelFolderThreadNode *a1 = ((CamelFolderThreadNode **)a)[0];
const CamelFolderThreadNode *b1 = ((CamelFolderThreadNode **)b)[0];
- /* if we have no message, it must be a dummy node, which
+ /* if we have no message, it must be a dummy node, which
also means it must have a child, just use that as the
sort data (close enough?) */
if (a1->message == NULL)
/* remove empty parent nodes */
prune_empty(thread, &head);
-
+
/* find any siblings which missed out - but only if we are allowing threading by subject */
if (thread->subject)
group_root_set (thread, &head);
/**
* camel_folder_thread_messages_new:
- * @folder:
+ * @folder:
* @uids: The subset of uid's to thread. If NULL. then thread all
* uid's in @folder.
* @thread_subject: thread based on subject also
- *
+ *
* Thread a (subset) of the messages in a folder. And sort the result
* in summary order.
*
* If @thread_subject is %TRUE, messages with
* related subjects will also be threaded. The default behaviour is to
* only thread based on message-id.
- *
+ *
* This function is probably to be removed soon.
*
* Return value: A CamelFolderThread contianing a tree of CamelFolderThreadNode's
/**
* camel_folder_thread_messages_unref:
- * @thread:
- *
+ * @thread:
+ *
* Free all memory associated with the thread descriptor @thread.
**/
void
/**
* camel_folder_thread_messages_new_summary:
* @summary: Array of CamelMessageInfo's to thread.
- *
+ *
* Thread a list of MessageInfo's. The summary must remain valid for the
* life of the CamelFolderThread created by this function, and it is upto the
* caller to ensure this.
- *
+ *
* Return value: A CamelFolderThread contianing a tree of CamelFolderThreadNode's
* which represent the threaded structure of the messages.
**/
typedef struct _CamelFolderThread {
guint32 refcount : 31;
guint32 subject : 1;
-
+
struct _CamelFolderThreadNode *tree;
struct _EMemChunk *node_chunks;
CamelFolder *folder;
camel_object_unref (camel_folder->summary);
camel_folder_change_info_free(p->changed_frozen);
-
+
g_static_rec_mutex_free(&p->lock);
g_static_mutex_free(&p->change_lock);
-
+
g_free(p);
}
g_return_if_fail (CAMEL_IS_FOLDER (folder));
CAMEL_FOLDER_REC_LOCK(folder, lock);
-
+
if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
CF_CLASS (folder)->sync (folder, expunge, ex);
-
+
CAMEL_FOLDER_REC_UNLOCK(folder, lock);
}
camel_folder_expunge (CamelFolder *folder, CamelException *ex)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
-
+
CAMEL_FOLDER_REC_LOCK(folder, lock);
-
+
if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
CF_CLASS (folder)->expunge (folder, ex);
-
+
CAMEL_FOLDER_REC_UNLOCK(folder, lock);
}
int count = -1;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
-
+
camel_object_get(folder, NULL, CAMEL_FOLDER_UNREAD, &count, 0);
return count;
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
_("Unsupported operation: append message: for %s"),
camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder)));
-
+
w(g_warning ("CamelFolder::append_message not implemented for `%s'",
camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
-
+
return;
}
* camel_folder_free_message_info:
* @folder: a #CamelFolder object
* @info: a #CamelMessageInfo
- *
+ *
* Free (unref) a #CamelMessageInfo, previously obtained with
* #camel_folder_get_message_info.
**/
* camel_folder_ref_message_info:
* @folder: a #CamelFolder object
* @info: a #CamelMessageInfo
- *
+ *
* DEPRECATED: Use #camel_message_info_ref directly.
*
* Ref a #CamelMessageInfo, previously obtained with
{
w(g_warning ("CamelFolder::get_message not implemented for `%s'",
camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
-
+
return NULL;
}
g_ptr_array_set_size(array, count);
for (i = 0, j = 0; i < count; i++) {
CamelMessageInfo *info = camel_folder_summary_index(folder->summary, i);
-
+
if (info) {
array->pdata[j++] = g_strdup (camel_message_info_uid (info));
camel_message_info_free(info);
}
}
-
+
g_ptr_array_set_size (array, j);
-
+
return array;
}
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
_("Unsupported operation: search by expression: for %s"),
camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder)));
-
+
w(g_warning ("CamelFolder::search_by_expression not implemented for "
"`%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
-
+
return NULL;
}
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
_("Unsupported operation: search by UIDs: for %s"),
camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder)));
-
+
w(g_warning ("CamelFolder::search_by_expression not implemented for "
"`%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
-
+
return NULL;
}
* camel_folder_search_free:
* @folder: a #CamelFolder object
* @result: search results to free
- *
+ *
* Free the result of a search as gotten by #camel_folder_search or
* #camel_folder_search_by_uids.
**/
-void
+void
camel_folder_search_free (CamelFolder *folder, GPtrArray *result)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
{
CamelMimeMessage *msg;
CamelMessageInfo *minfo, *info;
-
+
/* Default implementation. */
-
+
msg = camel_folder_get_message(source, uid, ex);
if (!msg)
return;
camel_folder_free_message_info(source, minfo);
} else
info = camel_message_info_new_from_header(NULL, ((CamelMimePart *)msg)->headers);
-
+
/* we don't want to retain the deleted flag */
camel_message_info_set_flags(info, CAMEL_MESSAGE_DELETED, 0);
-
+
camel_folder_append_message (dest, msg, info, transferred_uid, ex);
camel_object_unref (msg);
-
+
if (delete_original && !camel_exception_is_set (ex))
camel_folder_set_message_flags (source, uid, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN, ~0);
-
+
camel_message_info_free (info);
}
g_return_if_fail (CAMEL_IS_FOLDER (source));
g_return_if_fail (CAMEL_IS_FOLDER (dest));
g_return_if_fail (uids != NULL);
-
+
if (source == dest || uids->len == 0) {
/* source and destination folders are the same, or no work to do, do nothing. */
return;
}
-
+
if (source->parent_store == dest->parent_store) {
/* If either folder is a vtrash, we need to use the
* vtrash transfer method.
camel_folder_delete (CamelFolder *folder)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
-
+
CAMEL_FOLDER_REC_LOCK (folder, lock);
if (folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED) {
CAMEL_FOLDER_REC_UNLOCK (folder, lock);
return;
}
-
+
folder->folder_flags |= CAMEL_FOLDER_HAS_BEEN_DELETED;
-
+
CF_CLASS (folder)->delete (folder);
CAMEL_FOLDER_REC_UNLOCK (folder, lock);
* camel_folder_rename:
* @folder: a #CamelFolder object
* @new: new name for the folder
- *
+ *
* Mark an active folder object as renamed.
*
* NOTE: This is an internal function used by camel stores, no locking
info = folder->priv->changed_frozen;
folder->priv->changed_frozen = camel_folder_change_info_new();
}
-
+
CAMEL_FOLDER_UNLOCK(folder, change_lock);
if (info) {
for (i = 0; i < m->junk->len; i ++) {
CamelMimeMessage *msg = camel_folder_get_message(m->folder, m->junk->pdata[i], NULL);
int pc = 100 * i / m->junk->len;
-
+
camel_operation_progress(NULL, pc);
if (msg) {
notjunk = g_ptr_array_new();
g_ptr_array_add (notjunk, g_strdup (changed->uid_changed->pdata [i]));
}
- /* reset junk learn flag so that we don't process it again*/
+ /* reset junk learn flag so that we don't process it again*/
camel_folder_set_message_flags (folder, changed->uid_changed->pdata [i], CAMEL_MESSAGE_JUNK_LEARN, 0);
}
}
if ((folder->folder_flags & (CAMEL_FOLDER_FILTER_RECENT|CAMEL_FOLDER_FILTER_JUNK))
&& p->uid_filter->len > 0)
driver = camel_session_get_filter_driver(session,
- (folder->folder_flags & CAMEL_FOLDER_FILTER_RECENT)
+ (folder->folder_flags & CAMEL_FOLDER_FILTER_RECENT)
? "incoming":"junktest", NULL);
-
+
if (driver) {
recents = g_ptr_array_new();
for (i = 0; i < p->uid_filter->len; i++)
g_ptr_array_add (recents, g_strdup (p->uid_filter->pdata[i]));
-
+
g_ptr_array_set_size (p->uid_filter, 0);
}
-
+
if (driver || junk || notjunk) {
struct _folder_filter_msg *msg;
/**
* camel_folder_change_info_new:
- *
+ *
* Create a new folder change info structure.
*
* Change info structures are not MT-SAFE and must be
* camel_folder_change_info_add_source:
* @info: a #CamelFolderChangeInfo
* @uid: a uid
- *
+ *
* Add a source uid for generating a changeset.
**/
void
camel_folder_change_info_add_source(CamelFolderChangeInfo *info, const char *uid)
{
struct _CamelFolderChangeInfoPrivate *p;
-
+
g_assert(info != NULL);
-
+
p = info->priv;
-
+
if (p->uid_source == NULL)
p->uid_source = g_hash_table_new(g_str_hash, g_str_equal);
* camel_folder_change_info_add_source_list:
* @info: a #CamelFolderChangeInfo
* @list: a list of uids
- *
+ *
* Add a list of source uid's for generating a changeset.
**/
void
{
struct _CamelFolderChangeInfoPrivate *p;
int i;
-
+
g_assert(info != NULL);
g_assert(list != NULL);
-
+
p = info->priv;
if (p->uid_source == NULL)
* camel_folder_change_info_add_update:
* @info: a #CamelFolderChangeInfo
* @uid: a uid
- *
+ *
* Add a uid from the updated list, used to generate a changeset diff.
**/
void
struct _CamelFolderChangeInfoPrivate *p;
char *key;
int value;
-
+
g_assert(info != NULL);
-
+
p = info->priv;
-
+
if (p->uid_source == NULL) {
camel_folder_change_info_add_uid(info, uid);
return;
* camel_folder_change_info_add_update_list:
* @info: a #CamelFolderChangeInfo
* @list: a list of uids
- *
+ *
* Add a list of uid's from the updated list.
**/
void
camel_folder_change_info_add_update_list(CamelFolderChangeInfo *info, const GPtrArray *list)
{
int i;
-
+
g_assert(info != NULL);
g_assert(list != NULL);
-
+
for (i=0;i<list->len;i++)
camel_folder_change_info_add_update(info, list->pdata[i]);
}
/**
* camel_folder_change_info_build_diff:
* @info: a #CamelFolderChangeInfo
- *
+ *
* Compare the source uid set to the updated uid set and generate the
* differences into the added and removed lists.
**/
camel_folder_change_info_build_diff(CamelFolderChangeInfo *info)
{
struct _CamelFolderChangeInfoPrivate *p;
-
+
g_assert(info != NULL);
-
+
p = info->priv;
-
+
if (p->uid_source) {
g_hash_table_foreach(p->uid_source, (GHFunc)change_info_remove, info);
g_hash_table_destroy(p->uid_source);
struct _CamelFolderChangeInfoPrivate *p;
GPtrArray *olduids;
char *olduid;
-
+
p = info->priv;
- /* always add to recent, but dont let anyone else know */
+ /* always add to recent, but dont let anyone else know */
if (!g_hash_table_lookup_extended(p->uid_stored, uid, (void **)&olduid, (void **)&olduids)) {
olduid = e_mempool_strdup(p->uid_pool, uid);
}
struct _CamelFolderChangeInfoPrivate *p;
GPtrArray *olduids;
char *olduid;
-
+
p = info->priv;
- /* always add to filter, but dont let anyone else know */
+ /* always add to filter, but dont let anyone else know */
if (!g_hash_table_lookup_extended(p->uid_stored, uid, (void **)&olduid, (void **)&olduids)) {
olduid = e_mempool_strdup(p->uid_pool, uid);
}
* camel_folder_change_info_cat:
* @info: a #CamelFolderChangeInfo to append to
* @src: a #CamelFolderChangeInfo to append from
- *
+ *
* Concatenate one change info onto antoher. Can be used to copy them
* too.
**/
{
g_assert(info != NULL);
g_assert(source != NULL);
-
+
change_info_cat(info, source->uid_added, camel_folder_change_info_add_uid);
change_info_cat(info, source->uid_removed, camel_folder_change_info_remove_uid);
change_info_cat(info, source->uid_changed, camel_folder_change_info_change_uid);
* camel_folder_change_info_add_uid:
* @info: a #CamelFolderChangeInfo
* @uid: a uid
- *
+ *
* Add a new uid to the changeinfo.
**/
void
struct _CamelFolderChangeInfoPrivate *p;
GPtrArray *olduids;
char *olduid;
-
+
g_assert(info != NULL);
-
+
p = info->priv;
-
+
if (g_hash_table_lookup_extended(p->uid_stored, uid, (gpointer) &olduid, (gpointer) &olduids)) {
/* if it was removed then added, promote it to a changed */
/* if it was changed then added, leave as changed */
* camel_folder_change_info_remove_uid:
* @info: a #CamelFolderChangeInfo
* @uid: a uid
- *
+ *
* Add a uid to the removed uid list.
**/
void
struct _CamelFolderChangeInfoPrivate *p;
GPtrArray *olduids;
char *olduid;
-
+
g_assert(info != NULL);
-
+
p = info->priv;
-
+
if (g_hash_table_lookup_extended(p->uid_stored, uid, (gpointer) &olduid, (gpointer) &olduids)) {
/* if it was added/changed them removed, then remove it */
if (olduids != info->uid_removed) {
* camel_folder_change_info_change_uid:
* @info: a #CamelFolderChangeInfo
* @uid: a uid
- *
+ *
* Add a uid to the changed uid list.
**/
void
struct _CamelFolderChangeInfoPrivate *p;
GPtrArray *olduids;
char *olduid;
-
+
g_assert(info != NULL);
-
+
p = info->priv;
-
+
if (g_hash_table_lookup_extended(p->uid_stored, uid, (gpointer) &olduid, (gpointer) &olduids)) {
/* if we have it already, leave it as that */
return;
camel_folder_change_info_recent_uid(CamelFolderChangeInfo *info, const char *uid)
{
g_assert(info != NULL);
-
+
change_info_recent_uid(info, uid);
change_info_filter_uid(info, uid);
}
camel_folder_change_info_changed(CamelFolderChangeInfo *info)
{
g_assert(info != NULL);
-
+
return (info->uid_added->len || info->uid_removed->len || info->uid_changed->len || info->uid_recent->len);
}
/**
* camel_folder_change_info_clear:
* @info: a #CamelFolderChangeInfo
- *
+ *
* Empty out the change info; called after changes have been
* processed.
**/
camel_folder_change_info_clear(CamelFolderChangeInfo *info)
{
struct _CamelFolderChangeInfoPrivate *p;
-
+
g_assert(info != NULL);
-
+
p = info->priv;
-
+
g_ptr_array_set_size(info->uid_added, 0);
g_ptr_array_set_size(info->uid_removed, 0);
g_ptr_array_set_size(info->uid_changed, 0);
/**
* camel_folder_change_info_free:
* @info: a #CamelFolderChangeInfo
- *
+ *
* Free memory associated with the folder change info lists.
**/
void
struct _CamelFolderChangeInfoPrivate *p;
g_assert(info != NULL);
-
+
p = info->priv;
-
+
if (p->uid_source)
g_hash_table_destroy(p->uid_source);
*
* Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct {
CamelObjectClass parent_class;
- /* Virtual methods */
+ /* Virtual methods */
void (*refresh_info) (CamelFolder *folder, CamelException *ex);
- void (*sync) (CamelFolder *folder, gboolean expunge,
+ void (*sync) (CamelFolder *folder, gboolean expunge,
CamelException *ex);
const char * (*get_name) (CamelFolder *folder);
CamelStore * (*get_parent_store) (CamelFolder *folder);
- void (*expunge) (CamelFolder *folder,
+ void (*expunge) (CamelFolder *folder,
CamelException *ex);
int (*get_message_count) (CamelFolder *folder);
- void (*append_message) (CamelFolder *folder,
+ void (*append_message) (CamelFolder *folder,
CamelMimeMessage *message,
const CamelMessageInfo *info,
char **appended_uid,
CamelException *ex);
-
+
guint32 (*get_permanent_flags) (CamelFolder *folder);
guint32 (*get_message_flags) (CamelFolder *folder,
const char *uid);
const char *name,
const char *value);
- CamelMimeMessage * (*get_message) (CamelFolder *folder,
- const char *uid,
+ CamelMimeMessage * (*get_message) (CamelFolder *folder,
+ const char *uid,
CamelException *ex);
GPtrArray * (*get_uids) (CamelFolder *folder);
GPtrArray **transferred_uids,
gboolean delete_originals,
CamelException *ex);
-
+
void (*delete) (CamelFolder *folder);
void (*rename) (CamelFolder *folder, const char *newname);
-
+
void (*freeze) (CamelFolder *folder);
void (*thaw) (CamelFolder *folder);
gboolean (*is_frozen) (CamelFolder *folder);
const char *full_name,
const char *name);
-void camel_folder_refresh_info (CamelFolder *folder,
+void camel_folder_refresh_info (CamelFolder *folder,
CamelException *ex);
-void camel_folder_sync (CamelFolder *folder,
- gboolean expunge,
+void camel_folder_sync (CamelFolder *folder,
+ gboolean expunge,
CamelException *ex);
CamelStore * camel_folder_get_parent_store (CamelFolder *folder);
/* delete operations */
-void camel_folder_expunge (CamelFolder *folder,
+void camel_folder_expunge (CamelFolder *folder,
CamelException *ex);
/* message manipulation */
-void camel_folder_append_message (CamelFolder *folder,
+void camel_folder_append_message (CamelFolder *folder,
CamelMimeMessage *message,
const CamelMessageInfo *info,
char **appended_uid,
GPtrArray *array);
/* uid based access operations */
-CamelMimeMessage * camel_folder_get_message (CamelFolder *folder,
- const char *uid,
+CamelMimeMessage * camel_folder_get_message (CamelFolder *folder,
+ const char *uid,
CamelException *ex);
#define camel_folder_delete_message(folder, uid) \
camel_folder_set_message_flags (folder, uid, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN)
#include "camel-stream-fs.h"
#include "camel-stream-mem.h"
-#define d(x)
+#define d(x)
#ifdef GPG_LOG
static int logid;
{
CamelCipherContext *cipher;
CamelGpgContext *ctx;
-
+
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
-
+
ctx = (CamelGpgContext *) camel_object_new (camel_gpg_context_get_type ());
-
+
cipher = (CamelCipherContext *) ctx;
cipher->session = session;
camel_object_ref (session);
-
+
return cipher;
}
camel_gpg_context_set_always_trust (CamelGpgContext *ctx, gboolean always_trust)
{
g_return_if_fail (CAMEL_IS_GPG_CONTEXT (ctx));
-
+
ctx->always_trust = always_trust;
}
case CAMEL_CIPHER_HASH_HAVAL5160:
return "pgp-haval-5-160";
}
-
+
return NULL;
}
else if (!strcmp (id, "haval-5-160"))
return CAMEL_CIPHER_HASH_HAVAL5160;
}
-
+
return CAMEL_CIPHER_HASH_DEFAULT;
}
CamelSession *session;
GHashTable *userid_hint;
pid_t pid;
-
+
char *userid;
char *sigfile;
GPtrArray *recipients;
CamelCipherHash hash;
-
+
int stdin_fd;
int stdout_fd;
int stderr_fd;
int status_fd;
int passwd_fd; /* only needed for sign/decrypt */
-
+
/* status-fd buffer */
unsigned char *statusbuf;
unsigned char *statusptr;
unsigned int statusleft;
-
+
char *need_id;
char *passwd;
-
+
CamelStream *istream;
CamelStream *ostream;
-
+
GByteArray *diagbuf;
CamelStream *diagnostics;
-
+
int exit_status;
-
+
unsigned int exited:1;
unsigned int complete:1;
unsigned int seen_eof1:1;
unsigned int armor:1;
unsigned int need_passwd:1;
unsigned int send_passwd:1;
-
+
unsigned int bad_passwds:2;
-
+
unsigned int hadsig:1;
unsigned int badsig:1;
unsigned int errsig:1;
unsigned int nopubkey:1;
unsigned int nodata:1;
unsigned int trust:3;
-
+
unsigned int diagflushed:1;
-
+
unsigned int utf8:1;
-
+
unsigned int padding:10;
};
struct _GpgCtx *gpg;
const char *charset;
CamelStream *stream;
-
+
gpg = g_new (struct _GpgCtx, 1);
gpg->mode = GPG_CTX_MODE_SIGN;
gpg->session = session;
gpg->pid = (pid_t) -1;
gpg->exit_status = 0;
gpg->exited = FALSE;
-
+
gpg->userid = NULL;
gpg->sigfile = NULL;
gpg->recipients = NULL;
gpg->hash = CAMEL_CIPHER_HASH_DEFAULT;
gpg->always_trust = FALSE;
gpg->armor = FALSE;
-
+
gpg->stdin_fd = -1;
gpg->stdout_fd = -1;
gpg->stderr_fd = -1;
gpg->status_fd = -1;
gpg->passwd_fd = -1;
-
+
gpg->statusbuf = g_malloc (128);
gpg->statusptr = gpg->statusbuf;
gpg->statusleft = 128;
-
+
gpg->bad_passwds = 0;
gpg->need_passwd = FALSE;
gpg->send_passwd = FALSE;
gpg->need_id = NULL;
gpg->passwd = NULL;
-
+
gpg->nodata = FALSE;
gpg->hadsig = FALSE;
gpg->badsig = FALSE;
gpg->validsig = FALSE;
gpg->nopubkey = FALSE;
gpg->trust = GPG_TRUST_NONE;
-
+
gpg->istream = NULL;
gpg->ostream = NULL;
-
+
stream = camel_stream_mem_new ();
gpg->diagbuf = CAMEL_STREAM_MEM (stream)->buffer;
gpg->diagflushed = FALSE;
-
+
if ((charset = e_iconv_locale_charset ()) && g_ascii_strcasecmp (charset, "UTF-8") != 0) {
CamelMimeFilterCharset *filter;
CamelStreamFilter *fstream;
-
+
gpg->utf8 = FALSE;
-
+
if ((filter = camel_mime_filter_charset_new_convert (charset, "UTF-8"))) {
fstream = camel_stream_filter_new_with_stream (stream);
camel_stream_filter_add (fstream, (CamelMimeFilter *) filter);
camel_object_unref (filter);
camel_object_unref (stream);
-
+
stream = (CamelStream *) fstream;
}
} else {
gpg->utf8 = TRUE;
}
-
+
gpg->diagnostics = stream;
-
+
return gpg;
}
{
if (gpg->mode != GPG_CTX_MODE_ENCRYPT && gpg->mode != GPG_CTX_MODE_EXPORT)
return;
-
+
if (!gpg->recipients)
gpg->recipients = g_ptr_array_new ();
-
+
g_ptr_array_add (gpg->recipients, g_strdup (keyid));
}
camel_stream_flush (gpg->diagnostics);
if (gpg->diagbuf->len == 0)
return NULL;
-
+
g_byte_array_append (gpg->diagbuf, (guchar *) "", 1);
}
-
+
return (const char *) gpg->diagbuf->data;
}
if (gpg->session)
camel_object_unref (gpg->session);
-
+
g_hash_table_foreach (gpg->userid_hint, userid_hint_free, NULL);
g_hash_table_destroy (gpg->userid_hint);
-
+
g_free (gpg->userid);
-
+
g_free (gpg->sigfile);
-
+
if (gpg->recipients) {
for (i = 0; i < gpg->recipients->len; i++)
g_free (gpg->recipients->pdata[i]);
-
+
g_ptr_array_free (gpg->recipients, TRUE);
}
-
+
if (gpg->stdin_fd != -1)
close (gpg->stdin_fd);
if (gpg->stdout_fd != -1)
close (gpg->status_fd);
if (gpg->passwd_fd != -1)
close (gpg->passwd_fd);
-
+
g_free (gpg->statusbuf);
-
+
g_free (gpg->need_id);
-
+
if (gpg->passwd) {
memset (gpg->passwd, 0, strlen (gpg->passwd));
g_free (gpg->passwd);
}
-
+
if (gpg->istream)
camel_object_unref (gpg->istream);
-
+
if (gpg->ostream)
camel_object_unref (gpg->ostream);
-
+
camel_object_unref (gpg->diagnostics);
-
+
g_free (gpg);
}
GPtrArray *argv;
char *buf;
int i;
-
+
argv = g_ptr_array_new ();
g_ptr_array_add (argv, "gpg");
-
+
g_ptr_array_add (argv, "--verbose");
g_ptr_array_add (argv, "--no-secmem-warning");
g_ptr_array_add (argv, "--no-greeting");
g_ptr_array_add (argv, "--batch");
g_ptr_array_add (argv, "--yes");
}
-
+
*sfd = buf = g_strdup_printf ("--status-fd=%d", status_fd);
g_ptr_array_add (argv, buf);
-
+
if (passwd_fd != -1) {
*pfd = buf = g_strdup_printf ("--command-fd=%d", passwd_fd);
g_ptr_array_add (argv, buf);
}
-
+
switch (gpg->mode) {
case GPG_CTX_MODE_SIGN:
g_ptr_array_add (argv, "--sign");
g_ptr_array_add (argv, gpg->recipients->pdata[i]);
break;
}
-
+
g_ptr_array_add (argv, NULL);
-
+
return argv;
}
int i, maxfd, errnosave, fds[10];
GPtrArray *argv;
int flags;
-
+
for (i = 0; i < 10; i++)
fds[i] = -1;
-
+
maxfd = gpg->need_passwd ? 10 : 8;
for (i = 0; i < maxfd; i += 2) {
if (pipe (fds + i) == -1)
goto exception;
}
-
+
argv = gpg_ctx_get_argv (gpg, fds[7], &status_fd, fds[8], &passwd_fd);
-
+
if (!(gpg->pid = fork ())) {
/* child process */
-
+
if ((dup2 (fds[0], STDIN_FILENO) < 0 ) ||
(dup2 (fds[3], STDOUT_FILENO) < 0 ) ||
(dup2 (fds[5], STDERR_FILENO) < 0 )) {
_exit (255);
}
-
+
/* Dissociate from camel's controlling terminal so
* that gpg won't be able to read from it.
*/
setsid ();
-
+
maxfd = sysconf (_SC_OPEN_MAX);
/* Loop over all fds. */
for (i = 3; i < maxfd; i++) {
if (i != fds[7] && i != fds[8])
fcntl (i, F_SETFD, FD_CLOEXEC);
}
-
+
/* run gpg */
execvp ("gpg", (char **) argv->pdata);
_exit (255);
g_free (passwd_fd);
goto exception;
}
-
+
g_ptr_array_free (argv, TRUE);
g_free (status_fd);
g_free (passwd_fd);
-
+
/* Parent */
close (fds[0]);
gpg->stdin_fd = fds[1];
flags = fcntl (gpg->passwd_fd, F_GETFL);
fcntl (gpg->passwd_fd, F_SETFL, flags | O_NONBLOCK);
}
-
+
flags = fcntl (gpg->stdin_fd, F_GETFL);
fcntl (gpg->stdin_fd, F_SETFL, flags | O_NONBLOCK);
-
+
flags = fcntl (gpg->stdout_fd, F_GETFL);
fcntl (gpg->stdout_fd, F_SETFL, flags | O_NONBLOCK);
-
+
flags = fcntl (gpg->stderr_fd, F_GETFL);
fcntl (gpg->stderr_fd, F_SETFL, flags | O_NONBLOCK);
-
+
flags = fcntl (gpg->status_fd, F_GETFL);
fcntl (gpg->status_fd, F_SETFL, flags | O_NONBLOCK);
-
+
return 0;
-
+
exception:
-
+
errnosave = errno;
-
+
for (i = 0; i < 10; i++) {
if (fds[i] != -1)
close (fds[i]);
}
-
+
errno = errnosave;
#else
/* FIXME: Port me */
errno = EINVAL;
#endif
-
+
return -1;
}
next_token (const char *in, char **token)
{
const char *start, *inptr = in;
-
+
while (*inptr == ' ')
inptr++;
-
+
if (*inptr == '\0' || *inptr == '\n') {
if (token)
*token = NULL;
return inptr;
}
-
+
start = inptr;
while (*inptr && *inptr != ' ' && *inptr != '\n')
inptr++;
-
+
if (token)
*token = g_strndup (start, inptr - start);
-
+
return inptr;
}
const unsigned char *status;
size_t nread, nwritten;
int len;
-
+
parse:
-
+
inptr = gpg->statusbuf;
while (inptr < gpg->statusptr && *inptr != '\n')
inptr++;
-
+
if (*inptr != '\n') {
/* we don't have enough data buffered to parse this status line */
return 0;
}
-
+
*inptr++ = '\0';
status = gpg->statusbuf;
if (camel_debug("gpg:status"))
printf ("status: %s\n", status);
-
+
if (strncmp (status, "[GNUPG:] ", 9) != 0) {
char *message;
message = g_locale_to_utf8(status, -1, NULL, NULL, NULL);
g_free(message);
return -1;
}
-
+
status += 9;
-
+
if (!strncmp ((char *) status, "USERID_HINT ", 12)) {
char *hint, *user;
-
+
status += 12;
status = (const unsigned char *) next_token ((char *) status, &hint);
if (!hint) {
_("Failed to parse gpg userid hint."));
return -1;
}
-
+
if (g_hash_table_lookup (gpg->userid_hint, hint)) {
/* we already have this userid hint... */
g_free (hint);
goto recycle;
}
-
+
if (gpg->utf8 || !(user = g_locale_to_utf8 ((gchar *) status, -1, &nread, &nwritten, NULL)))
user = g_strdup ((gchar *) status);
-
+
g_strstrip (user);
-
+
g_hash_table_insert (gpg->userid_hint, hint, user);
} else if (!strncmp ((char *) status, "NEED_PASSPHRASE ", 16)) {
char *userid;
-
+
status += 16;
-
+
status = (const unsigned char *) next_token ((char *) status, &userid);
if (!userid) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to parse gpg passphrase request."));
return -1;
}
-
+
g_free (gpg->need_id);
gpg->need_id = userid;
} else if (!strncmp ((char *) status, "NEED_PASSPHRASE_PIN ", 20)) {
char *userid;
-
+
status += 20;
-
+
status = (const unsigned char *) next_token ((char *) status, &userid);
if (!userid) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to parse gpg passphrase request."));
return -1;
}
-
+
g_free (gpg->need_id);
gpg->need_id = userid;
} else if (!strncmp ((char *) status, "GET_HIDDEN ", 11)) {
const char *name = NULL;
char *prompt, *passwd;
guint32 flags;
-
+
status += 11;
-
+
if (gpg->need_id && !(name = g_hash_table_lookup (gpg->userid_hint, gpg->need_id)))
name = gpg->need_id;
else if (!name)
name = "";
-
+
if (!strncmp ((char *) status, "passphrase.pin.ask", 18)) {
prompt = g_strdup_printf (_("You need a PIN to unlock the key for your\n"
"SmartCard: \"%s\""), name);
g_free (prompt);
return -1;
}
-
+
flags = CAMEL_SESSION_PASSWORD_SECRET | CAMEL_SESSION_PASSPHRASE;
if ((passwd = camel_session_get_password (gpg->session, NULL, NULL, prompt, gpg->need_id, flags, ex))) {
if (!gpg->utf8) {
char *opasswd = passwd;
-
+
if ((passwd = g_locale_to_utf8 (passwd, -1, &nread, &nwritten, NULL))) {
memset (opasswd, 0, strlen (opasswd));
g_free (opasswd);
passwd = opasswd;
}
}
-
+
gpg->passwd = g_strdup_printf ("%s\n", passwd);
memset (passwd, 0, strlen (passwd));
g_free (passwd);
-
+
gpg->send_passwd = TRUE;
} else {
if (!camel_exception_is_set (ex))
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled."));
return -1;
}
-
+
g_free (prompt);
} else if (!strncmp ((char *) status, "GOOD_PASSPHRASE", 15)) {
gpg->bad_passwds = 0;
} else if (!strncmp ((char *) status, "BAD_PASSPHRASE", 14)) {
gpg->bad_passwds++;
-
+
camel_session_forget_password (gpg->session, NULL, NULL, gpg->need_id, ex);
-
+
if (gpg->bad_passwds == 3) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("Failed to unlock secret key: 3 bad passphrases given."));
break;
}
}
-
+
recycle:
-
+
/* recycle our statusbuf by moving inptr to the beginning of statusbuf */
len = gpg->statusptr - inptr;
memmove (gpg->statusbuf, inptr, len);
-
+
len = inptr - gpg->statusbuf;
gpg->statusleft += len;
gpg->statusptr -= len;
-
+
/* if we have more data, try parsing the next line? */
if (gpg->statusptr > gpg->statusbuf)
goto parse;
-
+
return 0;
}
{
pid_t retval;
int status;
-
+
if (gpg->exited)
return;
-
+
kill (gpg->pid, SIGTERM);
sleep (1);
retval = waitpid (gpg->pid, &status, WNOHANG);
the next file descriptor and so on until we've done what we
can to all of them. If one fails along the way, return
-1. */
-
+
if (polls[2].revents & (POLLIN|POLLHUP)) {
/* read the status message and decide what to do... */
char buffer[4096];
ssize_t nread;
-
+
d(printf ("reading from gpg's status-fd...\n"));
-
+
do {
nread = read (gpg->status_fd, buffer, sizeof (buffer));
} while (nread == -1 && (errno == EINTR || errno == EAGAIN));
if (nread == -1)
goto exception;
-
+
if (nread > 0) {
status_backup (gpg, buffer, nread);
-
+
if (gpg_ctx_parse_status (gpg, ex) == -1)
return -1;
} else {
gpg->complete = TRUE;
}
}
-
+
if ((polls[0].revents & (POLLIN|POLLHUP)) && gpg->ostream) {
char buffer[4096];
ssize_t nread;
-
+
d(printf ("reading gpg's stdout...\n"));
-
+
do {
nread = read (gpg->stdout_fd, buffer, sizeof (buffer));
} while (nread == -1 && (errno == EINTR || errno == EAGAIN));
if (nread == -1)
goto exception;
-
+
if (nread > 0) {
if (camel_stream_write (gpg->ostream, buffer, (size_t) nread) == -1)
goto exception;
gpg->seen_eof1 = TRUE;
}
}
-
+
if (polls[1].revents & (POLLIN|POLLHUP)) {
char buffer[4096];
ssize_t nread;
-
+
d(printf ("reading gpg's stderr...\n"));
-
+
do {
nread = read (gpg->stderr_fd, buffer, sizeof (buffer));
} while (nread == -1 && (errno == EINTR || errno == EAGAIN));
if (nread == -1)
goto exception;
-
+
if (nread > 0) {
camel_stream_write (gpg->diagnostics, buffer, nread);
} else {
gpg->seen_eof2 = TRUE;
}
}
-
+
if ((polls[4].revents & (POLLOUT|POLLHUP)) && gpg->need_passwd && gpg->send_passwd) {
ssize_t w, nwritten = 0;
size_t n;
-
+
d(printf ("sending gpg our passphrase...\n"));
-
+
/* send the passphrase to gpg */
n = strlen (gpg->passwd);
do {
do {
w = write (gpg->passwd_fd, gpg->passwd + nwritten, n - nwritten);
} while (w == -1 && (errno == EINTR || errno == EAGAIN));
-
+
if (w > 0)
nwritten += w;
} while (nwritten < n && w != -1);
-
+
/* zero and free our passwd buffer */
memset (gpg->passwd, 0, n);
g_free (gpg->passwd);
gpg->passwd = NULL;
-
+
if (w == -1)
goto exception;
-
+
gpg->send_passwd = FALSE;
}
-
+
if ((polls[3].revents & (POLLOUT|POLLHUP)) && gpg->istream) {
char buffer[4096];
ssize_t nread;
-
+
d(printf ("writing to gpg's stdin...\n"));
-
+
/* write our stream to gpg's stdin */
nread = camel_stream_read (gpg->istream, buffer, sizeof (buffer));
if (nread > 0) {
ssize_t w, nwritten = 0;
-
+
do {
do {
w = write (gpg->stdin_fd, buffer + nwritten, nread - nwritten);
} while (w == -1 && (errno == EINTR || errno == EAGAIN));
-
+
if (w > 0)
nwritten += w;
} while (nwritten < nread && w != -1);
-
+
if (w == -1)
goto exception;
-
+
d(printf ("wrote %d (out of %d) bytes to gpg's stdin\n", nwritten, nread));
}
-
+
if (camel_stream_eos (gpg->istream)) {
d(printf ("closing gpg's stdin\n"));
close (gpg->stdin_fd);
gpg->stdin_fd = -1;
}
}
-
+
return 0;
-
+
exception:
/* always called on an i/o error */
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Failed to execute gpg: %s"), g_strerror(errno));
{
pid_t retval;
int status;
-
+
if (gpg->exited)
return TRUE;
-
+
retval = waitpid (gpg->pid, &status, WNOHANG);
if (retval == gpg->pid) {
gpg->exit_status = status;
gpg->exited = TRUE;
return TRUE;
}
-
+
return FALSE;
}
#endif
sigset_t mask, omask;
pid_t retval;
int status;
-
+
if (!gpg->exited) {
sigemptyset (&mask);
sigaddset (&mask, SIGALRM);
retval = waitpid (gpg->pid, &status, 0);
alarm (0);
sigprocmask (SIG_SETMASK, &omask, NULL);
-
+
if (retval == (pid_t) -1 && errno == EINTR) {
/* The child is hanging: send a friendly reminder. */
kill (gpg->pid, SIGTERM);
status = gpg->exit_status;
retval = gpg->pid;
}
-
+
if (retval != (pid_t) -1 && WIFEXITED (status))
return WEXITSTATUS (status);
else
int res = -1;
CamelMimePart *sigpart;
CamelMultipartSigned *mps;
-
+
/* Note: see rfc2015 or rfc3156, section 5 */
-
+
/* FIXME: stream this, we stream output at least */
istream = camel_stream_mem_new();
if (camel_cipher_canonical_to_stream(ipart, CAMEL_MIME_FILTER_CANON_STRIP|CAMEL_MIME_FILTER_CANON_CRLF|CAMEL_MIME_FILTER_CANON_FROM,
gpg_ctx_set_userid (gpg, userid);
gpg_ctx_set_istream (gpg, istream);
gpg_ctx_set_ostream (gpg, ostream);
-
+
if (gpg_ctx_op_start (gpg) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to execute gpg: %s"), g_strerror (errno));
goto fail;
}
-
+
while (!gpg_ctx_op_complete (gpg)) {
if (gpg_ctx_op_step (gpg, ex) == -1)
goto fail;
}
-
+
if (gpg_ctx_op_wait (gpg) != 0) {
const char *diagnostics;
-
+
diagnostics = gpg_ctx_get_diagnostics (gpg);
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
diagnostics && *diagnostics ? diagnostics :
camel_medium_set_content_object((CamelMedium *)opart, (CamelDataWrapper *)mps);
fail:
camel_object_unref(ostream);
-
+
if (gpg)
gpg_ctx_free (gpg);
-
+
return res;
}
CamelStream *ostream;
char *template;
int fd, ret;
-
+
template = g_build_filename (g_get_tmp_dir (), "evolution-pgp.XXXXXX", NULL);
if ((fd = g_mkstemp (template)) == -1) {
g_free (template);
return NULL;
}
-
+
/* TODO: This should probably just write the decoded message content out, not the part + headers */
-
+
ostream = camel_stream_fs_new_with_fd (fd);
ret = camel_data_wrapper_write_to_stream((CamelDataWrapper *)sigpart, ostream);
if (ret != -1) {
if (ret != -1)
ret = camel_stream_close (ostream);
}
-
+
camel_object_unref(ostream);
-
+
if (ret == -1) {
g_unlink (template);
g_free (template);
return NULL;
}
-
+
return template;
}
mps = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)ipart);
ct = ((CamelDataWrapper *)mps)->mime_type;
-
+
/* Inline signature (using our fake mime type) or PGP/Mime signature */
if (camel_content_type_is(ct, "multipart", "signed")) {
/* PGP/Mime Signature */
tmp = camel_content_type_param(ct, "protocol");
if (!CAMEL_IS_MULTIPART_SIGNED(mps)
- || tmp == NULL
+ || tmp == NULL
|| g_ascii_strcasecmp(tmp, context->sign_protocol) != 0) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot verify message signature: Incorrect message format"));
return NULL;
}
-
+
if (!(istream = camel_multipart_signed_get_content_stream ((CamelMultipartSigned *) mps, NULL))) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot verify message signature: Incorrect message format"));
return NULL;
}
-
+
if (!(sigpart = camel_multipart_get_part (mps, CAMEL_MULTIPART_SIGNED_SIGNATURE))) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot verify message signature: Incorrect message format"));
_("Cannot verify message signature: Incorrect message format"));
return NULL;
}
-
+
/* Now start the real work of verifying the message */
#ifdef GPG_LOG
if (camel_debug_start("gpg:sign")) {
goto exception;
}
}
-
+
camel_stream_reset(istream);
gpg = gpg_ctx_new (context->session);
gpg_ctx_set_mode (gpg, GPG_CTX_MODE_VERIFY);
if (sigfile)
gpg_ctx_set_sigfile (gpg, sigfile);
gpg_ctx_set_istream (gpg, istream);
-
+
if (gpg_ctx_op_start (gpg) == -1) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to execute gpg."));
goto exception;
}
-
+
while (!gpg_ctx_op_complete (gpg)) {
if (gpg_ctx_op_step (gpg, ex) == -1)
goto exception;
}
-
+
gpg_ctx_op_wait (gpg);
validity = camel_cipher_validity_new ();
diagnostics = gpg_ctx_get_diagnostics (gpg);
} else {
validity->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_BAD;
}
-
+
gpg_ctx_free (gpg);
-
+
if (sigfile) {
g_unlink (sigfile);
g_free (sigfile);
}
camel_object_unref(istream);
-
+
return validity;
-
+
exception:
-
+
if (gpg != NULL)
gpg_ctx_free (gpg);
-
+
if (istream)
camel_object_unref(istream);
g_unlink (sigfile);
g_free (sigfile);
}
-
+
return NULL;
}
for (i = 0; i < recipients->len; i++) {
gpg_ctx_add_recipient (gpg, recipients->pdata[i]);
}
-
+
if (gpg_ctx_op_start (gpg) == -1) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Failed to execute gpg."));
goto fail;
if (gpg_ctx_op_step (gpg, ex) == -1)
goto fail;
}
-
+
if (gpg_ctx_op_wait (gpg) != 0) {
const char *diagnostics;
-
+
diagnostics = gpg_ctx_get_diagnostics (gpg);
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
diagnostics && *diagnostics ? diagnostics : _("Failed to execute gpg."));
fail1:
camel_object_unref(istream);
camel_object_unref(ostream);
-
+
return res;
}
ct = camel_mime_part_get_content_type((CamelMimePart *)content);
/* Encrypted part (using our fake mime type) or PGP/Mime multipart */
- if (camel_content_type_is(ct, "multipart", "encrypted")) {
+ if (camel_content_type_is(ct, "multipart", "encrypted")) {
mp = (CamelMultipart *) camel_medium_get_content_object ((CamelMedium *) ipart);
if (!(encrypted = camel_multipart_get_part (mp, CAMEL_MULTIPART_ENCRYPTED_CONTENT))) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Failed to decrypt MIME part: protocol error"));
_("Cannot decrypt message: Incorrect message format"));
return NULL;
}
-
+
istream = camel_stream_mem_new();
camel_data_wrapper_decode_to_stream (content, istream);
camel_stream_reset(istream);
-
+
ostream = camel_stream_mem_new();
camel_stream_mem_set_secure((CamelStreamMem *)ostream);
gpg_ctx_set_mode (gpg, GPG_CTX_MODE_DECRYPT);
gpg_ctx_set_istream (gpg, istream);
gpg_ctx_set_ostream (gpg, ostream);
-
+
if (gpg_ctx_op_start (gpg) == -1) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to execute gpg."));
goto fail;
}
-
+
while (!gpg_ctx_op_complete (gpg)) {
if (gpg_ctx_op_step (gpg, ex) == -1)
goto fail;
}
-
+
if (gpg_ctx_op_wait (gpg) != 0) {
const char *diagnostics;
-
+
diagnostics = gpg_ctx_get_diagnostics (gpg);
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
diagnostics && *diagnostics ? diagnostics :
/* Set mime/type of this new part to application/octet-stream to force type snooping */
camel_mime_part_set_content_type(opart, "application/octet-stream");
}
- if (rv != -1) {
+ if (rv != -1) {
valid = camel_cipher_validity_new();
valid->encrypt.description = g_strdup(_("Encrypted content"));
valid->encrypt.status = CAMEL_CIPHER_VALIDITY_ENCRYPT_ENCRYPTED;
-
+
if (gpg->hadsig) {
if (gpg->validsig) {
if (gpg->trust == GPG_TRUST_UNDEFINED || gpg->trust == GPG_TRUST_NONE)
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Unable to parse message content"));
}
-
+
fail:
camel_object_unref(ostream);
camel_object_unref(istream);
gpg = gpg_ctx_new (context->session);
gpg_ctx_set_mode (gpg, GPG_CTX_MODE_IMPORT);
gpg_ctx_set_istream (gpg, istream);
-
+
if (gpg_ctx_op_start (gpg) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to execute gpg: %s"),
errno ? g_strerror (errno) : _("Unknown"));
goto fail;
}
-
+
while (!gpg_ctx_op_complete (gpg)) {
if (gpg_ctx_op_step (gpg, ex) == -1)
goto fail;
}
-
+
if (gpg_ctx_op_wait (gpg) != 0) {
const char *diagnostics;
-
+
diagnostics = gpg_ctx_get_diagnostics (gpg);
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
diagnostics && *diagnostics ? diagnostics :
res = 0;
fail:
gpg_ctx_free (gpg);
-
+
return res;
}
gpg_ctx_set_mode (gpg, GPG_CTX_MODE_EXPORT);
gpg_ctx_set_armor (gpg, TRUE);
gpg_ctx_set_ostream (gpg, ostream);
-
+
for (i = 0; i < keys->len; i++) {
gpg_ctx_add_recipient (gpg, keys->pdata[i]);
}
-
+
if (gpg_ctx_op_start (gpg) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to execute gpg: %s"),
errno ? g_strerror (errno) : _("Unknown"));
goto fail;
}
-
+
while (!gpg_ctx_op_complete (gpg)) {
if (gpg_ctx_op_step (gpg, ex) == -1)
goto fail;
}
-
+
if (gpg_ctx_op_wait (gpg) != 0) {
const char *diagnostics;
-
+
diagnostics = gpg_ctx_get_diagnostics (gpg);
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
diagnostics && *diagnostics ? diagnostics :
res = 0;
fail:
gpg_ctx_free (gpg);
-
+
return res;
}
camel_gpg_context_class_init (CamelGpgContextClass *klass)
{
CamelCipherContextClass *cipher_class = CAMEL_CIPHER_CONTEXT_CLASS (klass);
-
+
parent_class = CAMEL_CIPHER_CONTEXT_CLASS (camel_type_get_global_classfuncs (camel_cipher_context_get_type ()));
-
+
cipher_class->hash_to_id = gpg_hash_to_id;
cipher_class->id_to_hash = gpg_id_to_hash;
cipher_class->sign = gpg_sign;
camel_gpg_context_init (CamelGpgContext *context)
{
CamelCipherContext *cipher = (CamelCipherContext *) context;
-
+
context->always_trust = FALSE;
-
+
cipher->sign_protocol = "application/pgp-signature";
cipher->encrypt_protocol = "application/pgp-encrypted";
cipher->key_protocol = "application/pgp-keys";
camel_gpg_context_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_cipher_context_get_type (),
"CamelGpgContext",
(CamelObjectInitFunc) camel_gpg_context_init,
(CamelObjectFinalizeFunc) camel_gpg_context_finalise);
}
-
+
return type;
}
struct _CamelGpgContext {
CamelCipherContext parent_object;
-
+
gboolean always_trust;
};
struct _CamelGpgContextClass {
CamelCipherContextClass parent_class;
-
+
};
camel_html_parser_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_object_get_type (), "CamelHTMLParser",
sizeof (CamelHTMLParser),
(CamelObjectInitFunc) camel_html_parser_init,
(CamelObjectFinalizeFunc) camel_html_parser_finalize);
}
-
+
return type;
}
* camel_html_parser_new:
*
* Create a new CamelHTMLParser object.
- *
+ *
* Return value: A new CamelHTMLParser widget.
**/
CamelHTMLParser *
p->tag = g_string_new("");
p->ent = g_string_new("");
p->charset = NULL;
-
+
if (entities == NULL)
tokenise_setup();
#include "camel-tcp-stream-ssl.h"
#endif
-#define d(x)
+#define d(x)
static CamelStreamClass *parent_class = NULL;
{
CamelStreamClass *camel_stream_class =
CAMEL_STREAM_CLASS (camel_http_stream_class);
-
+
parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ()));
-
+
/* virtual method overload */
camel_stream_class->read = stream_read;
camel_stream_class->write = stream_write;
camel_http_stream_init (gpointer object, gpointer klass)
{
CamelHttpStream *http = CAMEL_HTTP_STREAM (object);
-
+
http->parser = NULL;
http->content_type = NULL;
http->headers = NULL;
camel_http_stream_finalize (CamelObject *object)
{
CamelHttpStream *http = CAMEL_HTTP_STREAM (object);
-
+
if (http->parser)
camel_object_unref(http->parser);
-
+
if (http->content_type)
camel_content_type_unref (http->content_type);
-
+
if (http->headers)
camel_header_raw_clear (&http->headers);
-
+
if (http->session)
camel_object_unref(http->session);
-
+
if (http->url)
camel_url_free (http->url);
-
+
if (http->proxy)
camel_url_free (http->proxy);
-
+
g_free (http->authrealm);
g_free (http->authpass);
-
+
if (http->raw)
camel_object_unref(http->raw);
if (http->read)
camel_http_stream_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_stream_get_type (),
"CamelHttpStream",
(CamelObjectInitFunc) camel_http_stream_init,
(CamelObjectFinalizeFunc) camel_http_stream_finalize);
}
-
+
return type;
}
{
CamelHttpStream *stream;
char *str;
-
+
g_return_val_if_fail(CAMEL_IS_SESSION(session), NULL);
g_return_val_if_fail(url != NULL, NULL);
-
+
stream = CAMEL_HTTP_STREAM (camel_object_new (camel_http_stream_get_type ()));
-
+
stream->method = method;
stream->session = session;
camel_object_ref(session);
-
+
str = camel_url_to_string (url, 0);
stream->url = camel_url_new (str, NULL);
g_free (str);
-
+
return (CamelStream *)stream;
}
} else {
stream = camel_tcp_stream_raw_new ();
}
-
+
if (stream == NULL) {
errno = EINVAL;
return NULL;
camel_object_unref (stream);
return NULL;
}
-
+
if (camel_tcp_stream_connect (CAMEL_TCP_STREAM (stream), ai) == -1) {
errsave = errno;
camel_object_unref (stream);
errno = errsave;
return NULL;
}
-
+
camel_freeaddrinfo(ai);
http->raw = stream;
http->read = camel_stream_buffer_new (stream, CAMEL_STREAM_BUFFER_READ);
-
+
return stream;
}
camel_object_unref(http->raw);
http->raw = NULL;
}
-
+
if (http->read) {
camel_object_unref(http->read);
http->read = NULL;
http_next_token (const unsigned char *in)
{
const unsigned char *inptr = in;
-
+
while (*inptr && !isspace ((int) *inptr))
inptr++;
-
+
while (*inptr && isspace ((int) *inptr))
inptr++;
-
+
return (const char *) inptr;
}
{
const char *token;
char buffer[4096];
-
+
if (camel_stream_buffer_gets ((CamelStreamBuffer *)http->read, buffer, sizeof (buffer)) <= 0)
return -1;
}
http_disconnect(http);
-
+
return -1;
}
char *buf;
size_t len;
int err;
-
+
if (http->parser)
camel_object_unref (http->parser);
-
+
http->parser = camel_mime_parser_new ();
camel_mime_parser_init_with_stream (http->parser, http->read);
-
+
switch (camel_mime_parser_step (http->parser, &buf, &len)) {
case CAMEL_MIME_PARSER_STATE_MESSAGE:
case CAMEL_MIME_PARSER_STATE_HEADER:
http->content_type = camel_content_type_decode (type);
else
http->content_type = NULL;
-
+
if (http->headers)
camel_header_raw_clear (&http->headers);
-
+
http->headers = NULL;
tail = (struct _camel_header_raw *) &http->headers;
-
+
d(printf("HTTP Headers:\n"));
while (headers) {
d(printf(" %s:%s\n", headers->name, headers->value));
tail = node;
headers = headers->next;
}
-
+
break;
default:
g_warning ("Invalid state encountered???: %u", camel_mime_parser_state (http->parser));
}
-
+
err = camel_mime_parser_errno (http->parser);
-
+
if (err != 0) {
camel_object_unref (http->parser);
http->parser = NULL;
goto exception;
}
-
+
camel_mime_parser_drop_step (http->parser);
-
+
return 0;
-
+
exception:
http_disconnect(http);
-
+
return -1;
}
{
const char *method = NULL;
char *url;
-
+
switch (http->method) {
case CAMEL_HTTP_METHOD_GET:
method = "GET";
default:
g_assert_not_reached ();
}
-
+
url = camel_url_to_string (http->url, 0);
d(printf("HTTP Stream Sending: %s %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\n",
method,
if (http->authrealm)
d(printf("HTTP Stream Sending: WWW-Authenticate: %s\n", http->authrealm));
-
+
if (http->authrealm && camel_stream_printf (http->raw, "WWW-Authenticate: %s\r\n", http->authrealm) == -1) {
http_disconnect(http);
return -1;
if (http->authpass && http->proxy)
d(printf("HTTP Stream Sending: Proxy-Aurhorization: Basic %s\n", http->authpass));
-
+
if (http->authpass && http->proxy && camel_stream_printf (http->raw, "Proxy-Authorization: Basic %s\r\n",
http->authpass) == -1) {
http_disconnect(http);
return -1;
}
-
+
/* end the headers */
if (camel_stream_write (http->raw, "\r\n", 2) == -1 || camel_stream_flush (http->raw) == -1) {
http_disconnect(http);
return -1;
}
-
+
return 0;
}
CamelHttpStream *http = CAMEL_HTTP_STREAM (stream);
const char *parser_buf;
ssize_t nread;
-
+
if (http->method != CAMEL_HTTP_METHOD_GET && http->method != CAMEL_HTTP_METHOD_HEAD) {
errno = EIO;
return -1;
}
-
+
redirect:
-
+
if (!http->raw) {
if (http_connect (http, http->proxy ? http->proxy : http->url) == NULL)
return -1;
-
+
if (http_method_invoke (http) == -1)
return -1;
-
+
if (http_get_statuscode (http) == -1)
return -1;
-
+
if (http_get_headers (http) == -1)
return -1;
-
+
switch (http->statuscode) {
case 200:
case 206:
return -1;
}
}
-
+
nread = camel_mime_parser_read (http->parser, &parser_buf, n);
-
+
if (nread > 0)
memcpy (buffer, parser_buf, nread);
else if (nread == 0)
stream->eos = TRUE;
-
+
return nread;
}
stream_flush (CamelStream *stream)
{
CamelHttpStream *http = (CamelHttpStream *) stream;
-
+
if (http->raw)
return camel_stream_flush (http->raw);
else
stream_close (CamelStream *stream)
{
CamelHttpStream *http = (CamelHttpStream *) stream;
-
+
if (http->raw) {
if (camel_stream_close (http->raw) == -1)
return -1;
http_disconnect(http);
}
-
+
return 0;
}
stream_reset (CamelStream *stream)
{
CamelHttpStream *http = CAMEL_HTTP_STREAM (stream);
-
+
if (http->raw)
http_disconnect(http);
camel_http_stream_get_content_type (CamelHttpStream *http_stream)
{
g_return_val_if_fail (CAMEL_IS_HTTP_STREAM (http_stream), NULL);
-
+
if (!http_stream->content_type && !http_stream->raw) {
if (http_connect (http_stream, http_stream->url) == NULL)
return NULL;
-
+
if (http_method_invoke (http_stream) == -1)
return NULL;
-
+
if (http_get_headers (http_stream) == -1)
return NULL;
}
-
+
if (http_stream->content_type)
camel_content_type_ref (http_stream->content_type);
-
+
return http_stream->content_type;
}
camel_http_stream_set_user_agent (CamelHttpStream *http_stream, const char *user_agent)
{
g_return_if_fail (CAMEL_IS_HTTP_STREAM (http_stream));
-
+
g_free (http_stream->user_agent);
http_stream->user_agent = g_strdup (user_agent);
}
camel_http_stream_set_proxy (CamelHttpStream *http_stream, const char *proxy_url)
{
g_return_if_fail (CAMEL_IS_HTTP_STREAM (http_stream));
-
+
if (http_stream->proxy)
camel_url_free (http_stream->proxy);
camel_http_stream_set_proxy_authrealm (CamelHttpStream *http_stream, const char *proxy_authrealm)
{
g_return_if_fail (CAMEL_IS_HTTP_STREAM (http_stream));
-
+
g_free (http_stream->authrealm);
http_stream->authrealm = g_strdup (proxy_authrealm);
}
camel_http_stream_set_proxy_authpass (CamelHttpStream *http_stream, const char *proxy_authpass)
{
g_return_if_fail (CAMEL_IS_HTTP_STREAM (http_stream));
-
+
g_free (http_stream->authpass);
http_stream->authpass = g_strdup (proxy_authpass);
}
struct _CamelHttpStream {
CamelStream parent_object;
-
+
CamelMimeParser *parser;
-
+
CamelContentType *content_type;
struct _camel_header_raw *headers;
-
+
CamelHttpMethod method;
struct _CamelSession *session;
CamelURL *url;
-
+
char *user_agent;
-
+
/* proxy info */
CamelURL *proxy;
char *authrealm;
char *authpass;
-
+
int statuscode;
-
+
CamelStream *raw;
CamelStream *read;
};
struct _CamelHttpStreamClass {
CamelStreamClass parent_class;
-
+
/* Virtual methods */
};
# ifdef CAMEL_EXPLICIT_TRANSLATION_DOMAIN
# undef _
# define _(String) dgettext (CAMEL_EXPLICIT_TRANSLATION_DOMAIN, String)
-# else
+# else
# define _(String) gettext (String)
# endif
# ifdef gettext_noop
camel_index_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_object_get_type(), "CamelIndex",
sizeof (CamelIndex),
(CamelObjectInitFunc) camel_index_init,
(CamelObjectFinalizeFunc) camel_index_finalise);
}
-
+
return type;
}
camel_index_rename(CamelIndex *idx, const char *path)
{
g_return_val_if_fail (CAMEL_IS_INDEX (idx), -1);
-
+
if ((idx->state & CAMEL_INDEX_DELETED) == 0)
return CI_CLASS(idx)->rename(idx, path);
else {
camel_index_set_normalise(CamelIndex *idx, CamelIndexNorm func, void *data)
{
g_return_if_fail (CAMEL_IS_INDEX (idx));
-
+
idx->normalise = func;
idx->normalise_data = data;
}
camel_index_sync(CamelIndex *idx)
{
g_return_val_if_fail (CAMEL_IS_INDEX (idx), -1);
-
+
if ((idx->state & CAMEL_INDEX_DELETED) == 0)
return CI_CLASS(idx)->sync(idx);
else {
camel_index_compress(CamelIndex *idx)
{
g_return_val_if_fail (CAMEL_IS_INDEX (idx), -1);
-
+
if ((idx->state & CAMEL_INDEX_DELETED) == 0)
return CI_CLASS(idx)->compress(idx);
else {
int ret;
g_return_val_if_fail (CAMEL_IS_INDEX (idx), -1);
-
+
if ((idx->state & CAMEL_INDEX_DELETED) == 0) {
ret = CI_CLASS(idx)->delete(idx);
idx->state |= CAMEL_INDEX_DELETED;
camel_index_has_name(CamelIndex *idx, const char *name)
{
g_return_val_if_fail (CAMEL_IS_INDEX (idx), FALSE);
-
+
if ((idx->state & CAMEL_INDEX_DELETED) == 0)
return CI_CLASS(idx)->has_name(idx, name);
else
camel_index_add_name(CamelIndex *idx, const char *name)
{
g_return_val_if_fail (CAMEL_IS_INDEX (idx), NULL);
-
+
if ((idx->state & CAMEL_INDEX_DELETED) == 0)
return CI_CLASS(idx)->add_name(idx, name);
else
camel_index_write_name(CamelIndex *idx, CamelIndexName *idn)
{
g_return_val_if_fail (CAMEL_IS_INDEX (idx), -1);
-
+
if ((idx->state & CAMEL_INDEX_DELETED) == 0)
return CI_CLASS(idx)->write_name(idx, idn);
else {
camel_index_find_name(CamelIndex *idx, const char *name)
{
g_return_val_if_fail (CAMEL_IS_INDEX (idx), NULL);
-
+
if ((idx->state & CAMEL_INDEX_DELETED) == 0)
return CI_CLASS(idx)->find_name(idx, name);
else
camel_index_delete_name(CamelIndex *idx, const char *name)
{
g_return_if_fail (CAMEL_IS_INDEX (idx));
-
+
if ((idx->state & CAMEL_INDEX_DELETED) == 0)
CI_CLASS(idx)->delete_name(idx, name);
}
CamelIndexCursor *ret;
g_return_val_if_fail (CAMEL_IS_INDEX (idx), NULL);
-
+
if ((idx->state & CAMEL_INDEX_DELETED) != 0)
return NULL;
camel_index_words(CamelIndex *idx)
{
g_return_val_if_fail (CAMEL_IS_INDEX (idx), NULL);
-
+
if ((idx->state & CAMEL_INDEX_DELETED) == 0)
return CI_CLASS(idx)->words(idx);
else
camel_index_names(CamelIndex *idx)
{
g_return_val_if_fail (CAMEL_IS_INDEX (idx), NULL);
-
+
if ((idx->state & CAMEL_INDEX_DELETED) == 0)
return CI_CLASS(idx)->names(idx);
else
camel_index_name_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_object_get_type(), "CamelIndexName",
sizeof (CamelIndexName),
(CamelObjectInitFunc) camel_index_name_init,
(CamelObjectFinalizeFunc) camel_index_name_finalise);
}
-
+
return type;
}
camel_index_cursor_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_object_get_type(), "CamelIndexCursor",
sizeof (CamelIndexCursor),
(CamelObjectInitFunc) camel_index_cursor_init,
(CamelObjectFinalizeFunc) camel_index_cursor_finalise);
}
-
+
return type;
}
camel_internet_address_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_address_get_type(), "CamelInternetAddress",
sizeof (CamelInternetAddress),
(CamelObjectInitFunc) camel_internet_address_init,
NULL);
}
-
+
return type;
}
}
camel_header_address_list_clear(&ha);
}
-
+
return a->addresses->len - count;
}
if (a->addresses->len == 0)
return NULL;
-
+
out = g_string_new("");
-
+
for (i = 0;i < a->addresses->len; i++) {
struct _address *addr = g_ptr_array_index(a->addresses, i);
char *enc;
g_string_append(out, enc);
g_free(enc);
}
-
+
ret = out->str;
g_string_free(out, FALSE);
-
+
return ret;
}
int i;
GString *out;
char *ret;
-
+
if (a->addresses->len == 0)
return NULL;
-
+
out = g_string_new("");
-
+
for (i = 0;i < a->addresses->len; i++) {
struct _address *addr = g_ptr_array_index(a->addresses, i);
char *enc;
g_string_append(out, enc);
g_free(enc);
}
-
+
ret = out->str;
g_string_free(out, FALSE);
-
+
return ret;
}
internet_remove (CamelAddress *a, int index)
{
struct _address *addr;
-
+
if (index < 0 || index >= a->addresses->len)
return;
-
+
addr = g_ptr_array_index(a->addresses, index);
g_free(addr->name);
g_free(addr->address);
* camel_internet_address_new:
*
* Create a new #CamelInternetAddress object.
- *
+ *
* Returns a new #CamelInternetAddress object
**/
CamelInternetAddress *
* @addr: a #CamelInternetAddress object
* @name: name associated with the new address
* @address: routing address associated with the new address
- *
+ *
* Add a new internet address to @addr.
- *
+ *
* Returns the index of added entry
**/
int
* @index: address's array index
* @namep: holder for the returned name, or %NULL, if not required.
* @addressp: holder for the returned address, or %NULL, if not required.
- *
+ *
* Get the address at @index.
- *
+ *
* Returns %TRUE if such an address exists, or %FALSE otherwise
**/
gboolean
* @addr: a #CamelInternetAddress object
* @name: name to lookup
* @addressp: holder for address part, or %NULL, if not required.
- *
+ *
* Find address by real name.
- *
+ *
* Returns the index of the address matching the name, or %-1 if no
* match was found
**/
* @addr: a #CamelInternetAddress object
* @address: address to lookup
* @namep: holder for the matching name, or %NULL, if not required.
- *
+ *
* Find an address by address.
- *
+ *
* Returns the index of the address, or %-1 if not found
**/
int
* @len: the length of the line the address is being appended to
* @name: the unencoded real name associated with the address
* @addr: the routing address
- *
+ *
* Encode a single address ready for internet usage. Header folding
* as per rfc822 is also performed, based on the length *@len. If @len
* is %NULL, then no folding will occur.
*
* Note: The value at *@in will be updated based on any linewrapping done
- *
+ *
* Returns the encoded address
**/
char *
g_string_append_printf(out, ">");
len += out->len;
-
+
if (inlen != NULL)
*inlen = len;
g_free(name);
-
+
ret = out->str;
g_string_free(out, FALSE);
* camel_internet_address_format_address:
* @name: a name, quotes may be stripped from it
* @addr: an rfc822 routing address
- *
+ *
* Function to format a single address, suitable for display.
- *
+ *
* Returns a nicely formatted string containing the rfc822 address
**/
char *
/**
* camel_dlist_init:
- * @v:
- *
+ * @v:
+ *
* Initialise a double-linked list header. All list headers must be
* initialised before use.
**/
* camel_dlist_addhead:
* @l: An initialised list header.
* @n: A node, the next and prev pointers will be overwritten.
- *
+ *
* Add the list node @n to the head (start) of the list @l.
- *
+ *
* Return value: @n.
**/
CamelDListNode *camel_dlist_addhead(CamelDList *l, CamelDListNode *n)
* camel_dlist_addtail:
* @l: An intialised list header.
* @n: A node, the next and prev pointers will be overwritten.
- *
+ *
* Add the list onde @n to the tail (end) of the list @l.
- *
+ *
* Return value: @n.
**/
CamelDListNode *camel_dlist_addtail(CamelDList *l, CamelDListNode *n)
/**
* camel_dlist_remove:
* @n: A node which is part of a list.
- *
+ *
* Remove @n from the list it's in. @n must belong to a list.
- *
+ *
* Return value: @n.
**/
CamelDListNode *camel_dlist_remove(CamelDListNode *n)
/**
* camel_dlist_remhead:
* @l: An initialised list, maybe containing items.
- *
+ *
* Remove the head node (start) of the list.
- *
+ *
* xReturn value: The previously first-node in the list, or NULLif @l
* is an empty list.
**/
/**
* camel_dlist_remtail:
* @l: An initialised list, maybe containing items.
- *
+ *
* Remove the last node in the list.
- *
+ *
* Return value: The previously last-node in the list, or NULL if @l
* is an empty list.
**/
/**
* camel_dlist_empty:
* @l: An initialised list header.
- *
+ *
* Returns %TRUE if @l is an empty list.
- *
+ *
* Return value: %TRUE if @l is an empty list, %FALSE otherwise.
**/
int camel_dlist_empty(CamelDList *l)
/**
* camel_dlist_length:
* @l: An initialised list header.
- *
+ *
* Returns the number of nodes in the list @l.
- *
+ *
* Return value: The number of nodes.
**/
int camel_dlist_length(CamelDList *l)
/**
* struct _CamelDListNode - A double-linked list node.
- *
+ *
* @next: The next node link.
* @prev: The previous node link.
- *
+ *
* A double-linked list node header. Put this at the start of the
* list node structure. Data is stored in the list by subclassing the
* node header rather than using a pointer. Or more normally by just
/**
* struct _CamelDList - A double-linked list header.
- *
+ *
* @head: The head node's next pointer.
* @tail: The tail node's next pointer.
* @tailpred: The previous node to the tail node.
- *
+ *
* This is the merging of two separate head and tail nodes into a
* single structure. i.e. if you ahve a NULL terminated head and tail
* node such as head = { first, NULL } and tail = { NULL, last } then
/**
* struct _CamelSListNode - A single-linked list node.
- *
+ *
* @next: The next node in the list.
*
* A single-linked list node header. Put this at hte start of the
/**
* struct _CamelSList - A single-linked list header.
- *
+ *
* @head: The head of the list.
- *
+ *
* This is the header of a single-linked list.
**/
struct _CamelSList {
*
* Authors: Michael Zucchi <notzed@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* Copyright (C) 2001 Ximian Inc (www.ximian.com/)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* Authors: Michael Zucchi <notzed@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
{
struct sigaction sa;
sigset_t sigset;
-
+
/* ignore sigint/sigio */
sa.sa_handler = SIG_IGN;
sigemptyset (&sa.sa_mask);
sa.sa_flags = 0;
-
+
sigemptyset(&sigset);
sigaddset(&sigset, SIGIO);
sigaddset(&sigset, SIGINT);
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
-
+
sigaction (SIGIO, &sa, NULL);
sigaction (SIGINT, &sa, NULL);
-
+
/* FIXME: add more sanity checks/setup here */
#ifdef SETEUID_SAVES
tv.tv_sec = delay;
tv.tv_usec = 0;
}
-
+
d(fprintf(stderr, "lock helper waiting for input\n"));
if (select(STDIN_FILENO+1, &rset, NULL, NULL, lock_info_list?&tv:NULL) == -1) {
if (errno == EINTR)
}
info = info->next;
}
-
+
continue;
}
*
* Copyright (C) 1999 Ximian (www.ximian.com/).
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* Copyright (C) 1999 Ximian (www.ximian.com/).
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/**
* camel_lock_dot:
- * @path:
- * @ex:
- *
+ * @path:
+ * @ex:
+ *
* Create an exclusive lock using .lock semantics.
* All locks are equivalent to write locks (exclusive).
- *
+ *
* Return value: -1 on error, sets @ex appropriately.
**/
int
/**
* camel_unlock_dot:
- * @path:
- *
+ * @path:
+ *
* Attempt to unlock a .lock lock.
**/
void
/**
* camel_lock_fcntl:
- * @fd:
- * @type:
- * @ex:
- *
+ * @fd:
+ * @type:
+ * @ex:
+ *
* Create a lock using fcntl(2).
*
* @type is CAMEL_LOCK_WRITE or CAMEL_LOCK_READ,
* to create exclusive or shared read locks
- *
+ *
* Return value: -1 on error.
**/
int
/**
* camel_unlock_fcntl:
- * @fd:
- *
+ * @fd:
+ *
* Unlock an fcntl lock.
**/
void
/**
* camel_lock_flock:
- * @fd:
- * @type:
- * @ex:
- *
+ * @fd:
+ * @type:
+ * @ex:
+ *
* Create a lock using flock(2).
- *
+ *
* @type is CAMEL_LOCK_WRITE or CAMEL_LOCK_READ,
* to create exclusive or shared read locks
*
/**
* camel_unlock_flock:
- * @fd:
- *
+ * @fd:
+ *
* Unlock an flock lock.
**/
void
* @path: Path to the file to lock (used for .locking only).
* @fd: Open file descriptor of the right type to lock.
* @type: Type of lock, CAMEL_LOCK_READ or CAMEL_LOCK_WRITE.
- * @ex:
- *
+ * @ex:
+ *
* Attempt to lock a folder, multiple attempts will be made using all
* locking strategies available.
- *
+ *
* Return value: -1 on error, @ex will describe the locking system that failed.
**/
int
* camel_unlock_folder:
* @path: Filename of folder.
* @fd: Open descrptor on which locks were placed.
- *
+ *
* Free a lock on a folder.
**/
void
return 1;
}
fd2 = open("mylock", O_RDWR);
- if (fd2 == -1) {
+ if (fd2 == -1) {
printf("Could not open lock file (mylock): %s", g_strerror (errno));
close (fd1);
return 1;
*
* Copyright (C) 1999 Ximian (www.ximian.com/).
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#include "camel-mime-utils.h"
static void reset(CamelMimeFilter *mf);
-static void complete(CamelMimeFilter *mf, char *in, size_t len,
- size_t prespace, char **out,
+static void complete(CamelMimeFilter *mf, char *in, size_t len,
+ size_t prespace, char **out,
size_t *outlen, size_t *outprespace);
-static void filter(CamelMimeFilter *mf, char *in, size_t len,
- size_t prespace, char **out,
+static void filter(CamelMimeFilter *mf, char *in, size_t len,
+ size_t prespace, char **out,
size_t *outlen, size_t *outprespace);
static void camel_mime_filter_basic_class_init (CamelMimeFilterBasicClass *klass);
camel_mime_filter_basic_class_init (CamelMimeFilterBasicClass *klass)
{
CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
-
+
camel_mime_filter_basic_parent = CAMEL_MIME_FILTER_CLASS(camel_type_get_global_classfuncs (camel_mime_filter_get_type ()));
filter_class->reset = reset;
camel_mime_filter_basic_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (), "CamelMimeFilterBasic",
sizeof (CamelMimeFilterBasic),
(CamelObjectInitFunc) camel_mime_filter_basic_init,
NULL);
}
-
+
return type;
}
reset(CamelMimeFilter *mf)
{
CamelMimeFilterBasic *f = (CamelMimeFilterBasic *)mf;
-
+
switch(f->type) {
case CAMEL_MIME_FILTER_BASIC_QP_ENC:
f->state = -1;
{
CamelMimeFilterBasic *f = (CamelMimeFilterBasic *)mf;
size_t newlen = 0;
-
+
switch(f->type) {
case CAMEL_MIME_FILTER_BASIC_BASE64_ENC:
/* wont go to more than 2x size (overly conservative) */
{
CamelMimeFilterBasic *f = (CamelMimeFilterBasic *)mf;
size_t newlen;
-
+
switch(f->type) {
case CAMEL_MIME_FILTER_BASIC_BASE64_ENC:
/* wont go to more than 2x size (overly conservative) */
if (!(f->state & CAMEL_UUDECODE_STATE_BEGIN)) {
register char *inptr, *inend;
size_t left;
-
+
inptr = in;
inend = inptr + len;
-
+
while (inptr < inend) {
left = inend - inptr;
if (left < 6) {
}
break;
}
-
+
/* go to the next line */
for ( ; inptr < inend && *inptr != '\n'; inptr++);
-
+
if (inptr < inend)
inptr++;
}
}
-
+
if ((f->state & CAMEL_UUDECODE_STATE_BEGIN) && !(f->state & CAMEL_UUDECODE_STATE_END)) {
/* "begin <mode> <filename>\n" has been found, so we can now start decoding */
camel_mime_filter_set_size (mf, len + 3, FALSE);
* camel_mime_filter_basic_new:
*
* Create a new #CamelMimeFilterBasic object.
- *
+ *
* Returns a new #CamelMimeFilterBasic object
**/
CamelMimeFilterBasic *
* @type: a #CamelMimeFilterBasicType type
*
* Create a new #CamelMimeFilterBasic object of type @type.
- *
+ *
* Returns a new #CamelMimeFilterBasic object
**/
CamelMimeFilterBasic *
struct _CamelMimeFilterBasicPrivate *priv;
CamelMimeFilterBasicType type;
-
+
unsigned char uubuf[60];
int state;
int save;
camel_mime_filter_bestenc_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (), "CamelMimeFilterBestenc",
sizeof (CamelMimeFilterBestenc),
(CamelObjectInitFunc) camel_mime_filter_bestenc_init,
NULL);
}
-
+
return type;
}
if (f->flags & CAMEL_BESTENC_GET_ENCODING) {
register unsigned int /* hopefully reg's are assinged in the order they appear? */
c,
- lastc=f->lastc,
+ lastc=f->lastc,
countline=f->countline,
count0=f->count0,
count8 = f->count8;
* camel_mime_filter_bestenc_new:
* @flags: a bitmask of data required.
*
- * Create a new #CamelMimeFilterBestenc object.
- *
+ * Create a new #CamelMimeFilterBestenc object.
+ *
* Returns a new #CamelMimeFilterBestenc object
**/
CamelMimeFilterBestenc *
* camel_mime_filter_bestenc_get_best_encoding:
* @filter: a #CamelMimeFilterBestenc object
* @required: maximum level of output encoding allowed.
- *
+ *
* Get the best encoding, given specific constraints, that can be used to
* encode a stream of bytes.
- *
+ *
* Returns the best encoding to use
**/
CamelTransferEncoding
{
CamelTransferEncoding bestenc;
int istext;
-
+
istext = (required & CAMEL_BESTENC_TEXT) ? 1 : 0;
required = required & ~CAMEL_BESTENC_TEXT;
-
+
#if 0
printf("count0 = %d, count8 = %d, total = %d\n", filter->count0, filter->count8, filter->total);
printf("maxline = %d, crlfnoorder = %s\n", filter->maxline, filter->crlfnoorder?"TRUE":"FALSE");
bestenc = CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE;
else
bestenc = CAMEL_TRANSFER_ENCODING_BASE64;
-
+
/* if we have nocrlf order, or long lines, we need to encode always */
if (filter->crlfnoorder || filter->maxline >= 998)
return bestenc;
/**
* camel_mime_filter_bestenc_get_best_charset:
* @filter: a #CamelMimeFilterBestenc object
- *
+ *
* Gets the best charset that can be used to contain this content.
- *
+ *
* Returns the name of the best charset to use to encode the input
* text filtered by @filter
**/
* camel_mime_filter_bestenc_set_flags:
* @filter: a #CamelMimeFilterBestenc object
* @flags: bestenc filter flags
- *
+ *
* Set the flags for subsequent operations.
**/
void
CAMEL_BESTENC_7BIT,
CAMEL_BESTENC_8BIT,
CAMEL_BESTENC_BINARY,
-
+
/* is the content stream to be treated as text? */
CAMEL_BESTENC_TEXT = 1<<8,
} CamelBestencEncoding;
camel_mime_filter_canon_class_init (CamelMimeFilterCanonClass *klass)
{
CamelMimeFilterClass *mime_filter_class = (CamelMimeFilterClass *) klass;
-
+
mime_filter_class->filter = filter;
mime_filter_class->complete = complete;
mime_filter_class->reset = reset;
camel_mime_filter_canon_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type(), "CamelMimeFilterCanon",
sizeof (CamelMimeFilterCanon),
NULL,
NULL);
}
-
+
return type;
}
/* empty line */
*o++ = '\r';
}
-
+
*o++ = c;
start = inptr;
starto = o;
filter_run(f, in, len, prespace, out, outlen, outprespace, FALSE);
}
-static void
+static void
complete(CamelMimeFilter *f, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace)
{
filter_run(f, in, len, prespace, out, outlen, outprespace, TRUE);
camel_mime_filter_charset_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (), "CamelMimeFilterCharset",
sizeof (CamelMimeFilterCharset),
(CamelObjectInitFunc) camel_mime_filter_charset_init,
(CamelObjectFinalizeFunc) camel_mime_filter_charset_finalize);
}
-
+
return type;
}
char buf[16];
char *buffer;
size_t outlen = 16;
-
+
/* what happens with the output bytes if this resets the state? */
if (f->ic != (iconv_t) -1) {
buffer = buf;
size_t inleft, outleft, converted = 0;
const char *inbuf;
char *outbuf;
-
+
if (charset->ic == (iconv_t) -1)
goto noop;
-
+
camel_mime_filter_set_size (mf, len * 5 + 16, FALSE);
outbuf = mf->outbuf;
outleft = mf->outsize;
-
+
inbuf = in;
inleft = len;
-
+
if (inleft > 0) {
do {
converted = e_iconv (charset->ic, &inbuf, &inleft, &outbuf, &outleft);
*
* We just need to grow our outbuffer and try again.
*/
-
+
converted = outbuf - mf->outbuf;
camel_mime_filter_set_size (mf, inleft * 5 + mf->outsize + 16, TRUE);
outbuf = mf->outbuf + converted;
*
* What we do here is eat the invalid bytes in the sequence and continue
*/
-
+
inbuf++;
inleft--;
} else if (errno == EINVAL) {
* We assume that this can only happen if we've run out of
* bytes for a multibyte sequence, if not we're in trouble.
*/
-
+
break;
} else
goto noop;
}
} while (((int) inleft) > 0);
}
-
+
/* flush the iconv conversion */
e_iconv (charset->ic, NULL, NULL, &outbuf, &outleft);
-
+
*out = mf->outbuf;
*outlen = mf->outsize - outleft;
*outprespace = mf->outpre;
-
+
return;
-
+
noop:
-
+
*out = in;
*outlen = len;
*outprespace = prespace;
size_t inleft, outleft, converted = 0;
const char *inbuf;
char *outbuf;
-
+
if (charset->ic == (iconv_t) -1)
goto noop;
-
+
camel_mime_filter_set_size (mf, len * 5 + 16, FALSE);
outbuf = mf->outbuf + converted;
outleft = mf->outsize - converted;
-
+
inbuf = in;
inleft = len;
-
+
do {
converted = e_iconv (charset->ic, &inbuf, &inleft, &outbuf, &outleft);
if (converted == (size_t) -1) {
if (errno == E2BIG || errno == EINVAL)
break;
-
+
if (errno == EILSEQ) {
/*
* EILSEQ An invalid multibyte sequence has been encountered
*
* What we do here is eat the invalid bytes in the sequence and continue
*/
-
+
inbuf++;
inleft--;
} else {
}
}
} while (((int) inleft) > 0);
-
+
if (((int) inleft) > 0) {
/* We've either got an E2BIG or EINVAL. Save the
remainder of the buffer as we'll process this next
time through */
camel_mime_filter_backup (mf, inbuf, inleft);
}
-
+
*out = mf->outbuf;
*outlen = outbuf - mf->outbuf;
*outprespace = mf->outpre;
-
+
return;
-
+
noop:
-
+
*out = in;
*outlen = len;
*outprespace = prespace;
camel_mime_filter_charset_class_init (CamelMimeFilterCharsetClass *klass)
{
CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
-
+
camel_mime_filter_charset_parent = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ()));
filter_class->reset = reset;
* camel_mime_filter_charset_new:
*
* Create a new #CamelMimeFilterCharset object.
- *
+ *
* Returns a new #CamelMimeFilterCharset object
**/
CamelMimeFilterCharset *
camel_mime_filter_charset_new_convert (const char *from_charset, const char *to_charset)
{
CamelMimeFilterCharset *new;
-
+
new = CAMEL_MIME_FILTER_CHARSET (camel_object_new (camel_mime_filter_charset_get_type ()));
-
+
new->ic = e_iconv_open (to_charset, from_charset);
if (new->ic == (iconv_t) -1) {
w(g_warning ("Cannot create charset conversion from %s to %s: %s",
new->from = g_strdup (from_charset);
new->to = g_strdup (to_charset);
}
-
+
return new;
}
{
CamelMimeFilterClass *mime_filter_class =
(CamelMimeFilterClass *) klass;
-
+
mime_filter_class->filter = filter;
mime_filter_class->complete = complete;
mime_filter_class->reset = reset;
camel_mime_filter_crlf_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type(), "CamelMimeFilterCRLF",
sizeof (CamelMimeFilterCRLF),
const char *inend;
gboolean do_dots;
char *outptr;
-
+
do_dots = crlf->mode == CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS;
-
+
inptr = in;
inend = in + len;
-
+
if (crlf->direction == CAMEL_MIME_FILTER_CRLF_ENCODE) {
camel_mime_filter_set_size (f, 3 * len, FALSE);
-
+
outptr = f->outbuf;
while (inptr < inend) {
if (*inptr == '\r') {
} else {
if (do_dots && *inptr == '.' && crlf->saw_lf)
*outptr++ = '.';
-
+
crlf->saw_cr = FALSE;
crlf->saw_lf = FALSE;
}
-
+
*outptr++ = *inptr++;
}
} else {
* in practice, as the input is processed in arbitrarily-sized
* blocks. */
camel_mime_filter_set_size (f, len + 1, FALSE);
-
+
outptr = f->outbuf;
while (inptr < inend) {
if (*inptr == '\r') {
} else {
if (crlf->saw_cr) {
crlf->saw_cr = FALSE;
-
+
if (*inptr == '\n') {
crlf->saw_lf = TRUE;
*outptr++ = *inptr++;
} else
*outptr++ = '\r';
}
-
+
*outptr++ = *inptr;
}
-
+
if (do_dots && *inptr == '.') {
if (crlf->saw_lf) {
crlf->saw_dot = TRUE;
crlf->saw_dot = FALSE;
}
}
-
+
crlf->saw_lf = FALSE;
-
+
inptr++;
}
}
-
+
*out = f->outbuf;
*outlen = outptr - f->outbuf;
*outprespace = f->outpre;
}
-static void
+static void
complete (CamelMimeFilter *f, char *in, size_t len, size_t prespace,
char **out, size_t *outlen, size_t *outprespace)
{
reset (CamelMimeFilter *f)
{
CamelMimeFilterCRLF *crlf = (CamelMimeFilterCRLF *)f;
-
+
crlf->saw_cr = FALSE;
crlf->saw_lf = TRUE;
crlf->saw_dot = FALSE;
camel_mime_filter_crlf_new (CamelMimeFilterCRLFDirection direction, CamelMimeFilterCRLFMode mode)
{
CamelMimeFilterCRLF *crlf = CAMEL_MIME_FILTER_CRLF(camel_object_new (CAMEL_MIME_FILTER_CRLF_TYPE));
-
+
crlf->direction = direction;
crlf->mode = mode;
crlf->saw_cr = FALSE;
crlf->saw_lf = TRUE;
crlf->saw_dot = FALSE;
-
+
return (CamelMimeFilter *)crlf;
}
{ "/color", "</font>", FALSE, NULL },
{ "lang", "<span lang=\"%s\">", TRUE, param_parse_lang },
{ "/lang", "</span>", FALSE, NULL },
-
+
/* don't handle this tag yet... */
{ "paraindent", "<!-- ", /* TRUE */ FALSE, NULL },
{ "/paraindent", " -->", FALSE, NULL },
-
+
/* as soon as we support all the tags that can have a param
* tag argument, these should be unnecessary, but we'll keep
* them anyway just in case? */
camel_mime_filter_enriched_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (),
"CamelMimeFilterEnriched",
(CamelObjectInitFunc) camel_mime_filter_enriched_init,
(CamelObjectFinalizeFunc) camel_mime_filter_enriched_finalize);
}
-
+
return type;
}
{
CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
int i;
-
+
parent_class = CAMEL_MIME_FILTER_CLASS (camel_mime_filter_get_type ());
-
+
filter_class->reset = filter_reset;
filter_class->filter = filter_filter;
filter_class->complete = filter_complete;
-
+
if (!enriched_hash) {
enriched_hash = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
for (i = 0; i < NUM_ENRICHED_TAGS; i++)
enriched_tag_needs_param (const char *tag)
{
int i;
-
+
for (i = 0; i < NUM_ENRICHED_TAGS; i++)
if (!g_ascii_strcasecmp (tag, enriched_tags[i].enriched))
return enriched_tags[i].needs_param;
-
+
return FALSE;
}
#endif
guint32 rgb = 0;
guint v;
int i;
-
+
for (i = 0; i < NUM_VALID_COLOURS; i++) {
if (!g_ascii_strncasecmp (inptr, valid_colours[i], inlen))
return g_strdup (valid_colours[i]);
}
-
+
/* check for numeric r/g/b in the format: ####,####,#### */
if (inptr[4] != ',' || inptr[9] != ',') {
/* okay, mailer must have used a string name that
inend = inptr + inlen;
while (end < inend && ((*end >= 'a' && *end <= 'z') || (*end >= 'A' && *end <= 'Z')))
end++;
-
+
return g_strndup (inptr, end - inptr);
}
-
+
for (i = 0; i < 3; i++) {
v = strtoul (inptr, (char **) &end, 16);
if (end != inptr + 4)
goto invalid_format;
-
+
v >>= 8;
rgb = (rgb << 8) | (v & 0xff);
-
+
inptr += 5;
}
-
+
return g_strdup_printf ("#%.6X", rgb);
-
+
invalid_format:
-
+
/* default colour? */
return g_strdup ("black");
}
{
register const char *inptr = fontfamily;
const char *inend = inptr + inlen;
-
+
/* don't allow any of '"', '<', nor '>' */
while (inptr < inend && *inptr != '"' && *inptr != '<' && *inptr != '>')
inptr++;
-
+
return g_strndup (fontfamily, inptr - fontfamily);
}
{
register const char *inptr = lang;
const char *inend = inptr + inlen;
-
+
/* don't allow any of '"', '<', nor '>' */
while (inptr < inend && *inptr != '"' && *inptr != '<' && *inptr != '>')
inptr++;
-
+
return g_strndup (lang, inptr - lang);
}
param_parse (const char *enriched, const char *inptr, int inlen)
{
int i;
-
+
for (i = 0; i < NUM_ENRICHED_TAGS; i++) {
if (!g_ascii_strcasecmp (enriched, enriched_tags[i].enriched))
return enriched_tags[i].parse_param (inptr, inlen);
}
-
+
g_assert_not_reached ();
-
+
return NULL;
}
const char *tag, *inend, *outend;
register const char *inptr;
register char *outptr;
-
+
camel_mime_filter_set_size (filter, inlen * 2 + 6, FALSE);
-
+
inptr = in;
inend = in + inlen;
outptr = filter->outbuf;
outend = filter->outbuf + filter->outsize;
-
+
retry:
do {
while (inptr < inend && outptr < outend && !strchr (" <>&\n", *inptr))
*outptr++ = *inptr++;
-
+
if (outptr == outend)
goto backup;
-
+
if ((inptr + 1) >= inend)
break;
-
+
switch (*inptr++) {
case ' ':
while (inptr < inend && (outptr + 7) < outend && *inptr == ' ') {
outptr += 6;
inptr++;
}
-
+
if (outptr < outend)
*outptr++ = ' ';
-
+
break;
case '\n':
if (!(enriched->flags & IS_RICHTEXT)) {
inptr--;
goto backup;
}
-
+
while (inptr < inend && (outptr + 4) < outend && *inptr == '\n') {
memcpy (outptr, "<br>", 4);
outptr += 4;
goto backup;
}
}
-
+
tag = inptr;
while (inptr < inend && *inptr != '>')
inptr++;
-
+
if (inptr == inend) {
inptr = tag - 1;
goto need_input;
}
-
+
if (!g_ascii_strncasecmp (tag, "nofill>", 7)) {
if ((outptr + 5) < outend) {
enriched->nofill++;
const char *html_tag;
char *enriched_tag;
int len;
-
+
len = inptr - tag;
enriched_tag = g_alloca (len + 1);
memcpy (enriched_tag, tag, len);
enriched_tag[len] = '\0';
-
+
html_tag = g_hash_table_lookup (enriched_hash, enriched_tag);
-
+
if (html_tag) {
if (html_tag_needs_param (html_tag)) {
const char *start;
char *param;
-
+
while (inptr < inend && *inptr != '<')
inptr++;
-
+
if (inptr == inend || (inend - inptr) <= 15) {
inptr = tag - 1;
goto need_input;
}
-
+
if (g_ascii_strncasecmp (inptr, "<param>", 7) != 0) {
/* ignore the enriched command tag... */
inptr -= 1;
goto loop;
}
-
+
inptr += 7;
start = inptr;
-
+
while (inptr < inend && *inptr != '<')
inptr++;
-
+
if (inptr == inend || (inend - inptr) <= 8) {
inptr = tag - 1;
goto need_input;
}
-
+
if (g_ascii_strncasecmp (inptr, "</param>", 8) != 0) {
/* ignore the enriched command tag... */
inptr += 7;
goto loop;
}
-
+
len = inptr - start;
param = param_parse (enriched_tag, start, len);
len = strlen (param);
-
+
inptr += 7;
-
+
len += strlen (html_tag);
-
+
if ((outptr + len) < outend) {
outptr += snprintf (outptr, len, html_tag, param);
g_free (param);
}
}
}
-
+
loop:
inptr++;
break;
break;
}
} while (inptr < inend);
-
+
need_input:
-
+
/* the reason we ignore @flush here is because if there isn't
enough input to parse a tag, then there's nothing we can
do. */
-
+
if (inptr < inend)
camel_mime_filter_backup (filter, inptr, (unsigned) (inend - inptr));
-
+
*out = filter->outbuf;
*outlen = outptr - filter->outbuf;
*outprespace = filter->outpre;
-
+
return;
-
+
backup:
-
+
if (flush) {
size_t offset, grow;
-
+
grow = (inend - inptr) * 2 + 20;
offset = outptr - filter->outbuf;
camel_mime_filter_set_size (filter, filter->outsize + grow, TRUE);
outend = filter->outbuf + filter->outsize;
outptr = filter->outbuf + offset;
-
+
goto retry;
} else {
camel_mime_filter_backup (filter, inptr, (unsigned) (inend - inptr));
}
-
+
*out = filter->outbuf;
*outlen = outptr - filter->outbuf;
*outprespace = filter->outpre;
enriched_to_html (filter, in, len, prespace, out, outlen, outprespace, FALSE);
}
-static void
+static void
filter_complete (CamelMimeFilter *filter, char *in, size_t len, size_t prespace,
char **out, size_t *outlen, size_t *outprespace)
{
filter_reset (CamelMimeFilter *filter)
{
CamelMimeFilterEnriched *enriched = (CamelMimeFilterEnriched *) filter;
-
+
enriched->nofill = 0;
}
camel_mime_filter_enriched_new (guint32 flags)
{
CamelMimeFilterEnriched *new;
-
+
new = (CamelMimeFilterEnriched *) camel_object_new (CAMEL_TYPE_MIME_FILTER_ENRICHED);
new->flags = flags;
-
+
return CAMEL_MIME_FILTER (new);
}
if (in == NULL)
return NULL;
-
+
filter = camel_mime_filter_enriched_new(flags);
-
+
camel_mime_filter_complete(filter, (char *)in, strlen(in), 0, &outbuf, &outlen, &outpre);
outbuf = g_strndup (outbuf, outlen);
camel_object_unref (filter);
-
+
return outbuf;
}
struct _CamelMimeFilterEnriched {
CamelMimeFilter parent_object;
-
+
guint32 flags;
int nofill;
};
struct _CamelMimeFilterEnrichedClass {
CamelMimeFilterClass parent_class;
-
+
};
CamelType camel_mime_filter_enriched_get_type (void);
camel_mime_filter_from_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (), "CamelMimeFilterFrom",
sizeof (CamelMimeFilterFrom),
(CamelObjectInitFunc) camel_mime_filter_from_init,
NULL);
}
-
+
return type;
}
*out = in;
*outlen = inend - in;
*outprespace = prespace;
-
+
d(printf("Filtered '%.*s'\n", *outlen, *out));
}
}
camel_mime_filter_from_class_init (CamelMimeFilterFromClass *klass)
{
CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
-
+
camel_mime_filter_from_parent = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ()));
filter_class->filter = filter;
* camel_mime_filter_from_new:
*
* Create a new #CamelMimeFilterFrom object.
- *
+ *
* Returns a new #CamelMimeFilterFrom object
**/
CamelMimeFilterFrom *
prespace = 0;
camel_mime_filter_complete(f, buffer, len, prespace, &buffer, &len, &prespace);
printf("complete = '%.*s'\n", len, buffer);
-
+
return 0;
}
struct _CamelMimeFilterFrom {
CamelMimeFilter parent;
-
+
int midline; /* are we between lines? */
};
guint16 xlen;
guint16 xlen_nread;
guint16 crc16;
-
+
guint8 got_hdr:1;
guint8 is_valid:1;
guint8 got_xlen:1;
struct _CamelMimeFilterGZipPrivate {
z_stream *stream;
-
+
gzip_state_t state;
gzip_hdr_t hdr;
-
+
guint32 crc32;
guint32 isize;
};
camel_mime_filter_gzip_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (),
"CamelMimeFilterGZip",
(CamelObjectInitFunc) camel_mime_filter_gzip_init,
(CamelObjectFinalizeFunc) camel_mime_filter_gzip_finalize);
}
-
+
return type;
}
camel_mime_filter_gzip_class_init (CamelMimeFilterGZipClass *klass)
{
CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
-
+
parent_class = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ()));
-
+
filter_class->reset = filter_reset;
filter_class->filter = filter_filter;
filter_class->complete = filter_complete;
{
CamelMimeFilterGZip *gzip = (CamelMimeFilterGZip *) object;
struct _CamelMimeFilterGZipPrivate *priv = gzip->priv;
-
+
if (gzip->mode == CAMEL_MIME_FILTER_GZIP_MODE_ZIP)
deflateEnd (priv->stream);
else
inflateEnd (priv->stream);
-
+
g_free (priv->stream);
g_free (priv);
}
CamelMimeFilterGZip *gzip = (CamelMimeFilterGZip *) filter;
struct _CamelMimeFilterGZipPrivate *priv = gzip->priv;
int retval;
-
+
if (!priv->state.zip.wrote_hdr) {
priv->hdr.v.id1 = 31;
priv->hdr.v.id2 = 139;
else
priv->hdr.v.xfl = 0;
priv->hdr.v.os = 255;
-
+
camel_mime_filter_set_size (filter, (len * 2) + 22, FALSE);
-
+
memcpy (filter->outbuf, priv->hdr.buf, 10);
-
+
priv->stream->next_out = filter->outbuf + 10;
priv->stream->avail_out = filter->outsize - 10;
-
+
priv->state.zip.wrote_hdr = TRUE;
} else {
camel_mime_filter_set_size (filter, (len * 2) + 12, FALSE);
-
+
priv->stream->next_out = filter->outbuf;
priv->stream->avail_out = filter->outsize;
}
-
+
priv->stream->next_in = in;
priv->stream->avail_in = len;
-
+
do {
/* FIXME: handle error cases? */
if ((retval = deflate (priv->stream, flush)) != Z_OK)
fprintf (stderr, "gzip: %d: %s\n", retval, priv->stream->msg);
-
+
if (flush == Z_FULL_FLUSH) {
size_t n;
-
+
n = filter->outsize - priv->stream->avail_out;
camel_mime_filter_set_size (filter, n + (priv->stream->avail_in * 2) + 12, TRUE);
priv->stream->avail_out = filter->outsize - n;
priv->stream->next_out = filter->outbuf + n;
-
+
if (priv->stream->avail_in == 0) {
guint32 val;
-
+
val = GUINT32_TO_LE (priv->crc32);
memcpy (priv->stream->next_out, &val, 4);
priv->stream->avail_out -= 4;
priv->stream->next_out += 4;
-
+
val = GUINT32_TO_LE (priv->isize);
memcpy (priv->stream->next_out, &val, 4);
priv->stream->avail_out -= 4;
priv->stream->next_out += 4;
-
+
break;
}
} else {
if (priv->stream->avail_in > 0)
camel_mime_filter_backup (filter, priv->stream->next_in, priv->stream->avail_in);
-
+
break;
}
} while (1);
-
+
priv->crc32 = crc32 (priv->crc32, in, len - priv->stream->avail_in);
priv->isize += len - priv->stream->avail_in;
-
+
*out = filter->outbuf;
*outlen = filter->outsize - priv->stream->avail_out;
*outprespace = filter->outpre;
struct _CamelMimeFilterGZipPrivate *priv = gzip->priv;
guint16 need, val;
int retval;
-
+
if (!priv->state.unzip.got_hdr) {
if (len < 10) {
camel_mime_filter_backup (filter, in, len);
return;
}
-
+
memcpy (priv->hdr.buf, in, 10);
priv->state.unzip.got_hdr = TRUE;
len -= 10;
in += 10;
-
+
priv->state.unzip.is_valid = (priv->hdr.v.id1 == 31 &&
priv->hdr.v.id2 == 139 &&
priv->hdr.v.cm == Z_DEFLATED);
}
-
+
if (!priv->state.unzip.is_valid)
return;
-
+
if (priv->hdr.v.flg & GZIP_FLAG_FEXTRA) {
if (!priv->state.unzip.got_xlen) {
if (len < 2) {
camel_mime_filter_backup (filter, in, len);
return;
}
-
+
memcpy (&val, in, 2);
priv->state.unzip.xlen = GUINT16_FROM_LE (val);
priv->state.unzip.got_xlen = TRUE;
len -= 2;
in += 2;
}
-
+
if (priv->state.unzip.xlen_nread < priv->state.unzip.xlen) {
need = priv->state.unzip.xlen - priv->state.unzip.xlen_nread;
-
+
if (need < len) {
priv->state.unzip.xlen_nread += need;
len -= need;
}
}
}
-
+
if ((priv->hdr.v.flg & GZIP_FLAG_FNAME) && !priv->state.unzip.got_fname) {
while (*in && len > 0) {
len--;
in++;
}
-
+
if (*in == '\0' && len > 0) {
priv->state.unzip.got_fname = TRUE;
len--;
return;
}
}
-
+
if ((priv->hdr.v.flg & GZIP_FLAG_FCOMMENT) && !priv->state.unzip.got_fcomment) {
while (*in && len > 0) {
len--;
in++;
}
-
+
if (*in == '\0' && len > 0) {
priv->state.unzip.got_fcomment = TRUE;
len--;
return;
}
}
-
+
if ((priv->hdr.v.flg & GZIP_FLAG_FHCRC) && !priv->state.unzip.got_crc16) {
if (len < 2) {
camel_mime_filter_backup (filter, in, len);
return;
}
-
+
memcpy (&val, in, 2);
priv->state.unzip.crc16 = GUINT16_FROM_LE (val);
len -= 2;
in += 2;
}
-
+
if (len == 0)
return;
-
+
camel_mime_filter_set_size (filter, (len * 2) + 12, FALSE);
-
+
priv->stream->next_in = in;
priv->stream->avail_in = len - 8;
-
+
priv->stream->next_out = filter->outbuf;
priv->stream->avail_out = filter->outsize;
-
+
do {
/* FIXME: handle error cases? */
if ((retval = inflate (priv->stream, flush)) != Z_OK)
fprintf (stderr, "gunzip: %d: %s\n", retval, priv->stream->msg);
-
+
if (flush == Z_FULL_FLUSH) {
size_t n;
-
+
if (priv->stream->avail_in == 0) {
/* FIXME: extract & compare calculated crc32 and isize values? */
break;
}
-
+
n = filter->outsize - priv->stream->avail_out;
camel_mime_filter_set_size (filter, n + (priv->stream->avail_in * 2) + 12, TRUE);
priv->stream->avail_out = filter->outsize - n;
priv->stream->next_out = filter->outbuf + n;
} else {
priv->stream->avail_in += 8;
-
+
if (priv->stream->avail_in > 0)
camel_mime_filter_backup (filter, priv->stream->next_in, priv->stream->avail_in);
-
+
break;
}
} while (1);
-
+
/* FIXME: if we keep this, we could check that the gzip'd
* stream is sane, but how would we tell our consumer if it
* was/wasn't? */
/*priv->crc32 = crc32 (priv->crc32, in, len - priv->stream->avail_in - 8);
priv->isize += len - priv->stream->avail_in - 8;*/
-
+
*out = filter->outbuf;
*outlen = filter->outsize - priv->stream->avail_out;
*outprespace = filter->outpre;
char **out, size_t *outlen, size_t *outprespace)
{
CamelMimeFilterGZip *gzip = (CamelMimeFilterGZip *) filter;
-
+
if (gzip->mode == CAMEL_MIME_FILTER_GZIP_MODE_ZIP)
gzip_filter (filter, in, len, prespace, out, outlen, outprespace, Z_SYNC_FLUSH);
else
char **out, size_t *outlen, size_t *outprespace)
{
CamelMimeFilterGZip *gzip = (CamelMimeFilterGZip *) filter;
-
+
if (gzip->mode == CAMEL_MIME_FILTER_GZIP_MODE_ZIP)
gzip_filter (filter, in, len, prespace, out, outlen, outprespace, Z_FULL_FLUSH);
else
{
CamelMimeFilterGZip *gzip = (CamelMimeFilterGZip *) filter;
struct _CamelMimeFilterGZipPrivate *priv = gzip->priv;
-
+
memset (&priv->state, 0, sizeof (priv->state));
-
+
if (gzip->mode == CAMEL_MIME_FILTER_GZIP_MODE_ZIP)
deflateReset (priv->stream);
else
inflateReset (priv->stream);
-
+
priv->crc32 = crc32 (0, Z_NULL, 0);
priv->isize = 0;
}
{
CamelMimeFilterGZip *new;
int retval;
-
+
new = (CamelMimeFilterGZip *) camel_object_new (CAMEL_TYPE_MIME_FILTER_GZIP);
new->mode = mode;
new->level = level;
-
+
if (mode == CAMEL_MIME_FILTER_GZIP_MODE_ZIP)
retval = deflateInit2 (new->priv->stream, level, Z_DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
else
retval = inflateInit2 (new->priv->stream, -MAX_WBITS);
-
+
if (retval != Z_OK) {
camel_object_unref (new);
return NULL;
}
-
+
return (CamelMimeFilter *) new;
}
struct _CamelMimeFilterGZip {
CamelMimeFilter parent_object;
-
+
struct _CamelMimeFilterGZipPrivate *priv;
-
+
CamelMimeFilterGZipMode mode;
int level;
};
struct _CamelMimeFilterGZipClass {
CamelMimeFilterClass parent_class;
-
+
};
camel_mime_filter_html_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (), "CamelMimeFilterHTML",
sizeof (CamelMimeFilterHTML),
(CamelObjectInitFunc) camel_mime_filter_html_init,
(CamelObjectFinalizeFunc) camel_mime_filter_html_finalize);
}
-
+
return type;
}
CamelMimeFilterHTML *f = (CamelMimeFilterHTML *) mf;
camel_html_parser_t state;
char *outp;
-
+
d(printf("converting html:\n%.*s\n", (int)inlen, in));
-
+
/* We should generally shrink the data, but this'll do */
camel_mime_filter_set_size (mf, inlen * 2 + 256, FALSE);
outp = mf->outbuf;
-
+
camel_html_parser_set_data (f->priv->ctxt, in, inlen, last);
do {
const char *data;
int len;
-
+
state = camel_html_parser_step(f->priv->ctxt, &data, &len);
-
+
switch(state) {
case CAMEL_HTML_PARSER_DATA:
case CAMEL_HTML_PARSER_ENT:
camel_mime_filter_html_class_init (CamelMimeFilterHTMLClass *klass)
{
CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
-
+
camel_mime_filter_html_parent = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ()));
filter_class->reset = reset;
* camel_mime_filter_html_new:
*
* Create a new #CamelMimeFilterHTML object.
- *
+ *
* Returns a new #CamelMimeFilterHTML object
**/
CamelMimeFilterHTML *
camel_mime_filter_index_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (), "CamelMimeFilterIndex",
sizeof (CamelMimeFilterIndex),
NULL,
(CamelObjectFinalizeFunc) camel_mime_filter_index_finalize);
}
-
+
return type;
}
camel_mime_filter_index_class_init (CamelMimeFilterIndexClass *klass)
{
CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
-
+
camel_mime_filter_index_parent = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ()));
/*filter_class->reset = reset;*/
* camel_mime_filter_index_new:
*
* Create a new #CamelMimeFilterIndex object
- *
+ *
* Returns a new #CamelMimeFilterIndex object
**/
CamelMimeFilterIndex *
{
CamelMimeFilterClass *mime_filter_class =
(CamelMimeFilterClass *) klass;
-
+
mime_filter_class->filter = filter;
mime_filter_class->complete = complete;
mime_filter_class->reset = reset;
camel_mime_filter_linewrap_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type(), "CamelMimeFilterLinewrap",
sizeof (CamelMimeFilterLinewrap),
NULL,
NULL);
}
-
+
return type;
}
CamelMimeFilterLinewrap *linewrap = (CamelMimeFilterLinewrap *)f;
char *inend, *p, *q;
int nchars = linewrap->nchars;
-
+
/* we'll be adding chars here so we need a bigger buffer */
camel_mime_filter_set_size (f, 3 * len, FALSE);
-
+
p = in;
q = f->outbuf;
inend = in + len;
-
+
while (p < inend) {
if (*p == '\n') {
*q++ = *p++;
*q++ = *p++;
nchars++;
}
-
+
/* line is getting way too long, we must force a wrap here */
if (nchars >= (linewrap->max_len - 1) && *p != '\n') {
*q++ = '\n';
nchars = 0;
}
}
-
+
linewrap->nchars = nchars;
-
+
*out = f->outbuf;
*outlen = q - f->outbuf;
*outprespace = f->outpre;
}
-static void
+static void
complete (CamelMimeFilter *f, char *in, size_t len, size_t prespace,
char **out, size_t *outlen, size_t *outprespace)
{
reset (CamelMimeFilter *f)
{
CamelMimeFilterLinewrap *linewrap = (CamelMimeFilterLinewrap *)f;
-
+
linewrap->nchars = 0;
}
{
CamelMimeFilterLinewrap *linewrap =
CAMEL_MIME_FILTER_LINEWRAP (camel_object_new (CAMEL_MIME_FILTER_LINEWRAP_TYPE));
-
+
linewrap->indent = indent_char;
linewrap->wrap_len = preferred_len;
linewrap->max_len = max_len;
linewrap->nchars = 0;
-
+
return (CamelMimeFilter *) linewrap;
}
struct _CamelMimeFilterLinewrap {
CamelMimeFilter parent;
-
+
guint wrap_len;
guint max_len;
char indent;
camel_mime_filter_pgp_class_init (CamelMimeFilterPgpClass *klass)
{
CamelMimeFilterClass *mime_filter_class = (CamelMimeFilterClass *) klass;
-
+
mime_filter_class->filter = filter;
mime_filter_class->complete = complete;
mime_filter_class->reset = reset;
camel_mime_filter_pgp_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (),
"CamelMimeFilterPgp",
NULL,
NULL);
}
-
+
return type;
}
const char *start, *inend = in + len;
register const char *inptr = in;
register char *o;
-
+
/* only need as much space as the input, we're stripping chars */
camel_mime_filter_set_size (f, len, FALSE);
-
+
o = f->outbuf;
-
+
while (inptr < inend) {
start = inptr;
-
+
while (inptr < inend && *inptr != '\n')
inptr++;
-
+
if (inptr == inend) {
if (!last) {
camel_mime_filter_backup (f, start, inend - start);
}
break;
}
-
+
inptr++;
-
+
switch (pgp->state) {
case PGP_PREFACE:
/* check for the beginning of the pgp block */
pgp->state++;
break;
}
-
+
memcpy (o, start, inptr - start);
o += (inptr - start);
break;
pgp->state++;
break;
}
-
+
/* do dash decoding */
if (!strncmp (start, "- ", 2)) {
/* Dash encoded line found, skip encoding */
start += 2;
}
-
+
memcpy (o, start, inptr - start);
o += (inptr - start);
break;
break;
}
}
-
+
*out = f->outbuf;
*outlen = o - f->outbuf;
*outprespace = f->outpre;
filter_run (f, in, len, prespace, out, outlen, outprespace, FALSE);
}
-static void
+static void
complete (CamelMimeFilter *f, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace)
{
filter_run (f, in, len, prespace, out, outlen, outprespace, TRUE);
{
CamelMimeFilterClass *mime_filter_class =
(CamelMimeFilterClass *) klass;
-
+
mime_filter_class->filter = filter;
mime_filter_class->complete = complete;
mime_filter_class->reset = reset;
camel_mime_filter_save_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type(), "CamelMimeFilterSave",
sizeof (CamelMimeFilterSave),
NULL,
NULL);
}
-
+
return type;
}
char **out, size_t *outlen, size_t *outprespace)
{
CamelMimeFilterSave *save = (CamelMimeFilterSave *) f;
-
+
if (save->stream)
camel_stream_write (save->stream, in, len);
-
+
*out = in;
*outlen = len;
*outprespace = f->outpre;
}
-static void
+static void
complete (CamelMimeFilter *f, char *in, size_t len, size_t prespace,
char **out, size_t *outlen, size_t *outprespace)
{
camel_mime_filter_save_new (void)
{
CamelMimeFilterSave *save = CAMEL_MIME_FILTER_SAVE (camel_object_new (CAMEL_MIME_FILTER_SAVE_TYPE));
-
+
save->stream = camel_stream_mem_new ();
-
+
return (CamelMimeFilter *) save;
}
camel_mime_filter_save_new_with_stream (CamelStream *stream)
{
CamelMimeFilterSave *save = CAMEL_MIME_FILTER_SAVE (camel_object_new (CAMEL_MIME_FILTER_SAVE_TYPE));
-
+
save->stream = stream;
camel_object_ref (stream);
-
+
return (CamelMimeFilter *) save;
}
struct _CamelMimeFilterSave {
CamelMimeFilter parent;
-
+
CamelStream *stream;
};
camel_mime_filter_tohtml_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (),
"CamelMimeFilterToHTML",
(CamelObjectInitFunc) camel_mime_filter_tohtml_init,
(CamelObjectFinalizeFunc) camel_mime_filter_tohtml_finalize);
}
-
+
return type;
}
camel_mime_filter_tohtml_finalize (CamelObject *obj)
{
CamelMimeFilterToHTML *filter = (CamelMimeFilterToHTML *) obj;
-
+
camel_url_scanner_free (filter->scanner);
}
camel_mime_filter_tohtml_init (CamelMimeFilterToHTML *filter)
{
filter->scanner = camel_url_scanner_new ();
-
+
filter->flags = 0;
filter->colour = 0;
filter->column = 0;
check_size (CamelMimeFilter *filter, char *outptr, char **outend, size_t len)
{
size_t offset;
-
+
if (*outend - outptr >= len)
return outptr;
-
+
offset = outptr - filter->outbuf;
-
+
camel_mime_filter_set_size (filter, filter->outsize + len, TRUE);
-
+
*outend = filter->outbuf + filter->outsize;
-
+
return filter->outbuf + offset;
}
{
register const char *inptr = in;
int depth = 1;
-
+
if (*inptr++ != '>')
return 0;
-
+
#if FOOLISHLY_UNMUNGE_FROM
/* check that it isn't an escaped From line */
if (!strncmp (inptr, "From", 4))
return 0;
#endif
-
+
while (*inptr != '\n') {
if (*inptr == ' ')
inptr++;
-
+
if (*inptr++ != '>')
break;
-
+
depth++;
}
-
+
return depth;
}
{
CamelMimeFilterToHTML *html = (CamelMimeFilterToHTML *) filter;
const unsigned char *inptr = in;
-
+
while (inptr < inend) {
guint32 u;
-
+
outptr = check_size (filter, outptr, outend, 16);
u = camel_utf8_getc_limit (&inptr, inend);
break;
}
}
-
+
return outptr;
}
return;
}
-
+
camel_mime_filter_set_size (filter, inlen * 2 + 6, FALSE);
-
+
inptr = in;
inend = in + inlen;
outptr = filter->outbuf;
outend = filter->outbuf + filter->outsize;
-
+
if (html->flags & CAMEL_MIME_FILTER_TOHTML_PRE && !html->pre_open) {
outptr = g_stpcpy (outptr, "<pre>");
html->pre_open = TRUE;
html->column = 0;
depth = 0;
-
+
if (html->flags & CAMEL_MIME_FILTER_TOHTML_MARK_CITATION) {
if ((depth = citation_depth (start)) > 0) {
/* FIXME: we could easily support multiple colour depths here */
-
+
outptr = check_size (filter, outptr, &outend, 25);
outptr += sprintf(outptr, "<font color=\"#%06x\">", (html->colour & 0xffffff));
}
outptr = g_stpcpy (outptr, "> ");
html->column += 2;
}
-
+
#define CONVERT_URLS (CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES)
if (html->flags & CONVERT_URLS) {
size_t matchlen, buflen, len;
urlmatch_t match;
-
+
len = inptr - start;
-
+
do {
if (camel_url_scanner_scan (html->scanner, start, len, &match)) {
/* write out anything before the first regex match */
outptr = writeln (filter, (const unsigned char *)start, (const unsigned char *)start + match.um_so,
outptr, &outend);
-
+
start += match.um_so;
len -= match.um_so;
-
+
matchlen = match.um_eo - match.um_so;
-
+
buflen = 20 + strlen (match.prefix) + matchlen + matchlen;
outptr = check_size (filter, outptr, &outend, buflen);
-
+
/* write out the href tag */
outptr = g_stpcpy (outptr, "<a href=\"");
outptr = g_stpcpy (outptr, match.prefix);
memcpy (outptr, start, matchlen);
outptr += matchlen;
outptr = g_stpcpy (outptr, "\">");
-
+
/* now write the matched string */
memcpy (outptr, start, matchlen);
html->column += matchlen;
outptr += matchlen;
start += matchlen;
len -= matchlen;
-
+
/* close the href tag */
outptr = g_stpcpy (outptr, "</a>");
} else {
} else {
outptr = writeln (filter, (const unsigned char *)start, (const unsigned char *)inptr, outptr, &outend);
}
-
+
if ((html->flags & CAMEL_MIME_FILTER_TOHTML_MARK_CITATION) && depth > 0) {
outptr = check_size (filter, outptr, &outend, 8);
outptr = g_stpcpy (outptr, "</font>");
}
-
+
if (inptr < inend) {
if (html->flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_NL) {
outptr = check_size (filter, outptr, &outend, 5);
outptr = g_stpcpy (outptr, "<br>");
}
-
+
*outptr++ = '\n';
}
-
+
start = ++inptr;
} while (inptr < inend);
-
+
if (flush) {
/* flush the rest of our input buffer */
if (start < inend)
outptr = writeln (filter, (const unsigned char *)start, (const unsigned char *)inend, outptr, &outend);
-
+
if (html->pre_open) {
/* close the pre-tag */
outptr = check_size (filter, outptr, &outend, 10);
/* backup */
camel_mime_filter_backup (filter, start, (unsigned) (inend - start));
}
-
+
*out = filter->outbuf;
*outlen = outptr - filter->outbuf;
*outprespace = filter->outpre;
html_convert (filter, in, len, prespace, out, outlen, outprespace, FALSE);
}
-static void
+static void
filter_complete (CamelMimeFilter *filter, char *in, size_t len, size_t prespace,
char **out, size_t *outlen, size_t *outprespace)
{
filter_reset (CamelMimeFilter *filter)
{
CamelMimeFilterToHTML *html = (CamelMimeFilterToHTML *) filter;
-
+
html->column = 0;
html->pre_open = FALSE;
}
camel_mime_filter_tohtml_class_init (CamelMimeFilterToHTMLClass *klass)
{
CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
-
+
camel_mime_filter_tohtml_parent = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ()));
-
+
filter_class->reset = filter_reset;
filter_class->filter = filter_filter;
filter_class->complete = filter_complete;
{
CamelMimeFilterToHTML *new;
int i;
-
+
new = CAMEL_MIME_FILTER_TOHTML (camel_object_new (camel_mime_filter_tohtml_get_type ()));
-
+
new->flags = flags;
new->colour = colour;
-
+
for (i = 0; i < NUM_URL_PATTERNS; i++) {
if (patterns[i].mask & flags)
camel_url_scanner_add (new->scanner, &patterns[i].pattern);
}
-
+
return CAMEL_MIME_FILTER (new);
}
CamelMimeFilter *filter;
size_t outlen, outpre;
char *outbuf;
-
+
g_return_val_if_fail (in != NULL, NULL);
-
+
filter = camel_mime_filter_tohtml_new (flags, colour);
-
+
camel_mime_filter_complete (filter, (char *) in, strlen (in), 0,
&outbuf, &outlen, &outpre);
-
+
outbuf = g_strndup (outbuf, outlen);
-
+
camel_object_unref (filter);
-
+
return outbuf;
}
struct _CamelMimeFilterToHTML {
CamelMimeFilter parent;
-
+
struct _CamelUrlScanner *scanner;
-
+
guint32 flags;
guint32 colour;
-
+
guint32 column : 31;
guint32 pre_open : 1;
};
camel_mime_filter_windows_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (),
"CamelMimeFilterWindows",
(CamelObjectInitFunc) camel_mime_filter_windows_init,
(CamelObjectFinalizeFunc) camel_mime_filter_windows_finalize);
}
-
+
return type;
}
camel_mime_filter_windows_finalize (CamelObject *o)
{
CamelMimeFilterWindows *windows = (CamelMimeFilterWindows *) o;
-
+
g_free (windows->claimed_charset);
}
camel_mime_filter_windows_init (CamelObject *o)
{
CamelMimeFilterWindows *windows = (CamelMimeFilterWindows *) o;
-
+
windows->is_windows = FALSE;
windows->claimed_charset = NULL;
}
CamelMimeFilterWindows *windows = (CamelMimeFilterWindows *) filter;
register unsigned char *inptr;
unsigned char *inend;
-
+
if (!windows->is_windows) {
inptr = (unsigned char *) in;
inend = inptr + len;
-
+
while (inptr < inend) {
register unsigned char c = *inptr++;
-
+
if (c >= 128 && c <= 159) {
w(g_warning ("Encountered Windows charset masquerading as %s",
windows->claimed_charset));
}
}
}
-
+
*out = in;
*outlen = len;
*outprespace = prespace;
}
-static void
+static void
filter_complete (CamelMimeFilter *filter, char *in, size_t len, size_t prespace,
char **out, size_t *outlen, size_t *outprespace)
{
filter_reset (CamelMimeFilter *filter)
{
CamelMimeFilterWindows *windows = (CamelMimeFilterWindows *) filter;
-
+
windows->is_windows = FALSE;
}
camel_mime_filter_windows_class_init (CamelMimeFilterWindowsClass *klass)
{
CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
-
+
parent_class = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ()));
-
+
filter_class->reset = filter_reset;
filter_class->filter = filter_filter;
filter_class->complete = filter_complete;
camel_mime_filter_windows_new (const char *claimed_charset)
{
CamelMimeFilterWindows *new;
-
+
g_return_val_if_fail (claimed_charset != NULL, NULL);
-
+
new = CAMEL_MIME_FILTER_WINDOWS (camel_object_new (camel_mime_filter_windows_get_type ()));
-
+
new->claimed_charset = g_strdup (claimed_charset);
-
+
return CAMEL_MIME_FILTER (new);
}
camel_mime_filter_windows_is_windows_charset (CamelMimeFilterWindows *filter)
{
g_return_val_if_fail (CAMEL_IS_MIME_FILTER_WINDOWS (filter), FALSE);
-
+
return filter->is_windows;
}
camel_mime_filter_windows_real_charset (CamelMimeFilterWindows *filter)
{
g_return_val_if_fail (CAMEL_IS_MIME_FILTER_WINDOWS (filter), NULL);
-
+
if (filter->is_windows)
return camel_charset_iso_to_windows (filter->claimed_charset);
else
struct _CamelMimeFilterWindows {
CamelMimeFilter parent;
-
+
gboolean is_windows;
char *claimed_charset;
};
struct _CamelMimeFilterWindowsClass {
CamelMimeFilterClass parent_class;
-
+
};
camel_mime_filter_yenc_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_mime_filter_get_type (),
"CamelMimeFilterYenc",
(CamelObjectInitFunc) camel_mime_filter_yenc_init,
NULL);
}
-
+
return type;
}
camel_mime_filter_yenc_class_init (CamelMimeFilterYencClass *klass)
{
CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
-
+
parent_class = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ()));
-
+
filter_class->reset = filter_reset;
filter_class->filter = filter_filter;
filter_class->complete = filter_complete;
{
CamelMimeFilterYenc *yenc = (CamelMimeFilterYenc *) filter;
size_t newlen = 0;
-
+
switch (yenc->direction) {
case CAMEL_MIME_FILTER_YENC_DIRECTION_ENCODE:
/* won't go to more than 2 * (x + 2) + 62 */
if (!(yenc->state & CAMEL_MIME_YDECODE_STATE_DECODE)) {
register char *inptr, *inend;
size_t left;
-
+
inptr = in;
inend = inptr + len;
-
+
/* we cannot start decoding until we have found an =ybegin line */
if (!(yenc->state & CAMEL_MIME_YDECODE_STATE_BEGIN)) {
while (inptr < inend) {
}
break;
}
-
+
/* go to the next line */
while (inptr < inend && *inptr != '\n')
inptr++;
-
+
if (inptr < inend)
inptr++;
}
}
-
+
left = inend - inptr;
if ((yenc->state & CAMEL_MIME_YDECODE_STATE_BEGIN) && left > 0) {
/* we have found an '=ybegin' line but we may yet have an "=ypart" line to
}
}
}
-
+
if ((yenc->state & CAMEL_MIME_YDECODE_STATE_DECODE) && !(yenc->state & CAMEL_MIME_YDECODE_STATE_END)) {
/* all yEnc headers have been found so we can now start decoding */
camel_mime_filter_set_size (filter, len + 3, FALSE);
}
break;
}
-
+
*out = filter->outbuf;
*outlen = newlen;
*outprespace = filter->outpre;
{
CamelMimeFilterYenc *yenc = (CamelMimeFilterYenc *) filter;
size_t newlen = 0;
-
+
switch (yenc->direction) {
case CAMEL_MIME_FILTER_YENC_DIRECTION_ENCODE:
/* won't go to more than 2 * (x + 2) + 62 */
}
break;
}
-
+
*out = filter->outbuf;
*outlen = newlen;
*outprespace = filter->outpre;
filter_reset (CamelMimeFilter *filter)
{
CamelMimeFilterYenc *yenc = (CamelMimeFilterYenc *) filter;
-
+
switch (yenc->direction) {
case CAMEL_MIME_FILTER_YENC_DIRECTION_ENCODE:
yenc->state = CAMEL_MIME_YENCODE_STATE_INIT;
camel_mime_filter_yenc_new (CamelMimeFilterYencDirection direction)
{
CamelMimeFilterYenc *new;
-
+
new = (CamelMimeFilterYenc *) camel_object_new (CAMEL_TYPE_MIME_FILTER_YENC);
new->direction = direction;
-
+
switch (direction) {
case CAMEL_MIME_FILTER_YENC_DIRECTION_ENCODE:
new->state = CAMEL_MIME_YENCODE_STATE_INIT;
default:
g_assert_not_reached ();
}
-
+
return (CamelMimeFilter *) new;
}
camel_mime_filter_yenc_set_state (CamelMimeFilterYenc *yenc, int state)
{
g_return_if_fail (CAMEL_IS_MIME_FILTER_YENC (yenc));
-
+
yenc->state = state;
}
camel_mime_filter_yenc_set_crc (CamelMimeFilterYenc *yenc, guint32 crc)
{
g_return_if_fail (CAMEL_IS_MIME_FILTER_YENC (yenc));
-
+
yenc->crc = crc;
}
camel_mime_filter_yenc_get_part (CamelMimeFilterYenc *yenc)
{
g_return_val_if_fail (CAMEL_IS_MIME_FILTER_YENC (yenc), -1);
-
+
if (yenc->state & CAMEL_MIME_YDECODE_STATE_PART)
return yenc->part;
-
+
return -1;
}
#endif
camel_mime_filter_yenc_get_pcrc (CamelMimeFilterYenc *yenc)
{
g_return_val_if_fail (CAMEL_IS_MIME_FILTER_YENC (yenc), -1);
-
+
return CAMEL_MIME_YENCODE_CRC_FINAL (yenc->pcrc);
}
camel_mime_filter_yenc_get_crc (CamelMimeFilterYenc *yenc)
{
g_return_val_if_fail (CAMEL_IS_MIME_FILTER_YENC (yenc), -1);
-
+
return CAMEL_MIME_YENCODE_CRC_FINAL (yenc->crc);
}
const unsigned char *inend;
unsigned char ch;
int ystate;
-
+
if (*state & CAMEL_MIME_YDECODE_STATE_END)
return 0;
-
+
ystate = *state;
-
+
inend = in + inlen;
outptr = out;
-
+
inptr = in;
while (inptr < inend) {
ch = *inptr++;
-
+
if ((ystate & YENC_NEWLINE_ESCAPE) == YENC_NEWLINE_ESCAPE) {
ystate &= ~CAMEL_MIME_YDECODE_STATE_EOLN;
-
+
if (ch == 'y') {
/* we probably have a =yend here */
ystate |= CAMEL_MIME_YDECODE_STATE_END;
break;
}
}
-
+
if (ch == '\n') {
ystate |= CAMEL_MIME_YDECODE_STATE_EOLN;
continue;
}
-
+
if (ystate & CAMEL_MIME_YDECODE_STATE_ESCAPE) {
ystate &= ~CAMEL_MIME_YDECODE_STATE_ESCAPE;
ch -= 64;
ystate |= CAMEL_MIME_YDECODE_STATE_ESCAPE;
continue;
}
-
+
ystate &= ~CAMEL_MIME_YDECODE_STATE_EOLN;
-
+
*outptr++ = ch -= 42;
-
+
*pcrc = yenc_crc_add (*pcrc, ch);
*crc = yenc_crc_add (*crc, ch);
}
-
+
*state = ystate;
-
+
return outptr - out;
}
const unsigned char *inend;
register int already;
unsigned char ch;
-
+
inend = in + inlen;
outptr = out;
-
+
already = *state;
-
+
inptr = in;
while (inptr < inend) {
ch = (*inptr++);
-
+
*pcrc = yenc_crc_add (*pcrc, ch);
*crc = yenc_crc_add (*crc, ch);
-
+
ch += 42;
-
+
if (ch == '\0' || ch == '\t' || ch == '\r' || ch == '\n' || ch == '=') {
*outptr++ = '=';
*outptr++ = ch + 64;
*outptr++ = ch;
already++;
}
-
+
if (already >= 128) {
*outptr++ = '\n';
already = 0;
}
}
-
+
*state = already;
-
+
return outptr - out;
}
int *state, guint32 *pcrc, guint32 *crc)
{
register unsigned char *outptr;
-
+
outptr = out;
-
+
if (inlen)
outptr += camel_yencode_step (in, inlen, out, state, pcrc, crc);
-
+
if (*state)
*outptr++ = '\n';
-
+
*state = CAMEL_MIME_YENCODE_STATE_INIT;
-
+
return outptr - out;
}
struct _CamelMimeFilterYenc {
CamelMimeFilter parent_object;
-
+
CamelMimeFilterYencDirection direction;
-
+
int part;
-
+
int state;
guint32 pcrc;
guint32 crc;
struct _CamelMimeFilterYencClass {
CamelMimeFilterClass parent_class;
-
+
};
static CamelObjectClass *camel_mime_filter_parent;
-static void complete (CamelMimeFilter *mf, char *in, size_t len,
- size_t prespace, char **out, size_t *outlen,
+static void complete (CamelMimeFilter *mf, char *in, size_t len,
+ size_t prespace, char **out, size_t *outlen,
size_t *outprespace);
static void
camel_mime_filter_get_type (void)
{
static CamelType camel_mime_filter_type = CAMEL_INVALID_TYPE;
-
+
if (camel_mime_filter_type == CAMEL_INVALID_TYPE) {
camel_mime_filter_type = camel_type_register (CAMEL_OBJECT_TYPE, "CamelMimeFilter",
sizeof (CamelMimeFilter),
(CamelObjectInitFunc) camel_mime_filter_init,
(CamelObjectFinalizeFunc) camel_mime_filter_finalize);
}
-
+
return camel_mime_filter_type;
}
* camel_mime_filter_new:
*
* Create a new #CamelMimeFilter object.
- *
+ *
* Returns a new #CamelMimeFilter
**/
CamelMimeFilter *
prespace -= f->backlen;
f->backlen = 0;
}
-
+
filterfunc(f, in, len, prespace, out, outlen, outprespace);
#ifdef MALLOC_CHECK
filter->outptr = filter->outreal + offset;
filter->outbuf = filter->outreal + PRE_HEAD*4;
filter->outsize = size;
- /* this could be offset from the end of the structure, but
+ /* this could be offset from the end of the structure, but
this should be good enough */
filter->outpre = PRE_HEAD*4;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */
/* camel-mime-message.c : class for a mime_message */
-/*
+/*
* Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
* Michael Zucchi <notzed@ximian.com>
* Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright 1999-2003 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
CamelMimePartClass *camel_mime_part_class = CAMEL_MIME_PART_CLASS (camel_mime_message_class);
CamelMediumClass *camel_medium_class = CAMEL_MEDIUM_CLASS (camel_mime_message_class);
int i;
-
+
parent_class = CAMEL_MIME_PART_CLASS (camel_type_get_global_classfuncs (camel_mime_part_get_type ()));
-
+
header_name_table = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
for (i = 0;header_names[i]; i++)
g_hash_table_insert (header_name_table, header_names[i], GINT_TO_POINTER(i+1));
{
CamelMimeMessage *mime_message = (CamelMimeMessage *)object;
int i;
-
+
mime_message->recipients = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
for (i=0;recipient_names[i];i++) {
g_hash_table_insert(mime_message->recipients, recipient_names[i], camel_internet_address_new());
mime_message->message_id = NULL;
}
-static void
+static void
camel_mime_message_finalize (CamelObject *object)
{
CamelMimeMessage *message = CAMEL_MIME_MESSAGE (object);
-
+
g_free (message->subject);
-
+
g_free (message->message_id);
-
+
if (message->reply_to)
camel_object_unref ((CamelObject *)message->reply_to);
-
+
if (message->from)
camel_object_unref ((CamelObject *)message->from);
-
+
g_hash_table_foreach (message->recipients, unref_recipient, NULL);
g_hash_table_destroy (message->recipients);
}
camel_mime_message_get_type (void)
{
static CamelType camel_mime_message_type = CAMEL_INVALID_TYPE;
-
+
if (camel_mime_message_type == CAMEL_INVALID_TYPE) {
camel_mime_message_type = camel_type_register (camel_mime_part_get_type(), "CamelMimeMessage",
sizeof (CamelMimeMessage),
(CamelObjectInitFunc) camel_mime_message_init,
(CamelObjectFinalizeFunc) camel_mime_message_finalize);
}
-
+
return camel_mime_message_type;
}
* Returns a new #CamelMimeMessage object
**/
CamelMimeMessage *
-camel_mime_message_new (void)
+camel_mime_message_new (void)
{
CamelMimeMessage *mime_message;
mime_message = CAMEL_MIME_MESSAGE (camel_object_new (CAMEL_MIME_MESSAGE_TYPE));
-
+
return mime_message;
}
camel_mime_message_set_date (CamelMimeMessage *message, time_t date, int offset)
{
char *datestr;
-
+
g_assert(message);
-
+
if (date == CAMEL_MESSAGE_DATE_CURRENT) {
struct tm local;
int tz;
-
+
date = time(NULL);
e_localtime_with_offset(date, &local, &tz);
offset = (((tz/60/60) * 100) + (tz/60 % 60));
}
message->date = date;
message->date_offset = offset;
-
+
datestr = camel_header_format_date (date, offset);
CAMEL_MEDIUM_CLASS (parent_class)->set_header ((CamelMedium *)message, "Date", datestr);
g_free (datestr);
{
if (offset)
*offset = msg->date_offset;
-
+
return msg->date;
}
{
if (msg->date_received == CAMEL_MESSAGE_DATE_CURRENT) {
const char *received;
-
+
received = camel_medium_get_header ((CamelMedium *)msg, "received");
if (received)
received = strrchr (received, ';');
if (received)
msg->date_received = camel_header_decode_date (received + 1, &msg->date_received_offset);
}
-
+
if (offset)
*offset = msg->date_received_offset;
-
+
return msg->date_received;
}
camel_mime_message_set_message_id (CamelMimeMessage *mime_message, const char *message_id)
{
char *id;
-
+
g_assert (mime_message);
-
+
g_free (mime_message->message_id);
-
+
if (message_id) {
id = g_strstrip (g_strdup (message_id));
} else {
id = camel_header_msgid_generate ();
}
-
+
mime_message->message_id = id;
id = g_strdup_printf ("<%s>", mime_message->message_id);
CAMEL_MEDIUM_CLASS (parent_class)->set_header (CAMEL_MEDIUM (mime_message), "Message-Id", id);
camel_mime_message_get_message_id (CamelMimeMessage *mime_message)
{
g_assert (mime_message);
-
+
return mime_message->message_id;
}
camel_mime_message_set_reply_to (CamelMimeMessage *msg, const CamelInternetAddress *reply_to)
{
char *addr;
-
+
g_assert(msg);
-
+
if (msg->reply_to) {
camel_object_unref ((CamelObject *)msg->reply_to);
msg->reply_to = NULL;
}
-
+
if (reply_to == NULL) {
CAMEL_MEDIUM_CLASS (parent_class)->remove_header (CAMEL_MEDIUM (msg), "Reply-To");
return;
}
-
+
msg->reply_to = (CamelInternetAddress *)camel_address_new_clone ((CamelAddress *)reply_to);
addr = camel_address_encode ((CamelAddress *)msg->reply_to);
CAMEL_MEDIUM_CLASS (parent_class)->set_header (CAMEL_MEDIUM (msg), "Reply-To", addr);
camel_mime_message_get_reply_to (CamelMimeMessage *mime_message)
{
g_assert (mime_message);
-
+
/* TODO: ref for threading? */
-
+
return mime_message->reply_to;
}
camel_mime_message_set_subject (CamelMimeMessage *message, const char *subject)
{
char *text;
-
+
g_assert(message);
-
+
g_free (message->subject);
-
+
if (subject) {
message->subject = g_strstrip (g_strdup (subject));
text = camel_header_encode_string ((unsigned char *) message->subject);
message->subject = NULL;
text = NULL;
}
-
+
CAMEL_MEDIUM_CLASS (parent_class)->set_header (CAMEL_MEDIUM (message), "Subject", text);
g_free (text);
}
camel_mime_message_get_subject (CamelMimeMessage *mime_message)
{
g_assert(mime_message);
-
+
return mime_message->subject;
}
camel_mime_message_set_from (CamelMimeMessage *msg, const CamelInternetAddress *from)
{
char *addr;
-
+
g_assert(msg);
-
+
if (msg->from) {
camel_object_unref((CamelObject *)msg->from);
msg->from = NULL;
}
-
+
if (from == NULL || camel_address_length((CamelAddress *)from) == 0) {
CAMEL_MEDIUM_CLASS(parent_class)->remove_header(CAMEL_MEDIUM(msg), "From");
return;
}
-
+
msg->from = (CamelInternetAddress *)camel_address_new_clone((CamelAddress *)from);
addr = camel_address_encode((CamelAddress *)msg->from);
CAMEL_MEDIUM_CLASS (parent_class)->set_header(CAMEL_MEDIUM(msg), "From", addr);
camel_mime_message_get_from (CamelMimeMessage *mime_message)
{
g_assert (mime_message);
-
+
/* TODO: we should really ref this for multi-threading to work */
-
+
return mime_message->from;
}
{
char *text;
CamelInternetAddress *addr;
-
+
g_assert(mime_message);
-
+
addr = g_hash_table_lookup (mime_message->recipients, type);
if (addr == NULL) {
g_warning ("trying to set a non-valid receipient type: %s", type);
return;
}
-
+
if (r == NULL || camel_address_length ((CamelAddress *)r) == 0) {
camel_address_remove ((CamelAddress *)addr, -1);
CAMEL_MEDIUM_CLASS (parent_class)->remove_header (CAMEL_MEDIUM (mime_message), type);
return;
}
-
+
/* note this does copy, and not append (cat) */
camel_address_copy ((CamelAddress *)addr, (const CamelAddress *)r);
-
+
/* and sync our headers */
text = camel_address_encode (CAMEL_ADDRESS (addr));
CAMEL_MEDIUM_CLASS (parent_class)->set_header (CAMEL_MEDIUM (mime_message), type, text);
camel_mime_message_get_recipients (CamelMimeMessage *mime_message, const char *type)
{
g_assert(mime_message);
-
+
return g_hash_table_lookup (mime_message->recipients, type);
}
{
CamelURL *url;
char *uri;
-
+
g_assert (mime_message);
-
+
url = camel_url_new (src, NULL);
if (url) {
uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
camel_mime_message_get_source (CamelMimeMessage *mime_message)
{
const char *src;
-
+
g_assert(mime_message);
-
+
src = camel_medium_get_header (CAMEL_MEDIUM (mime_message), "X-Evolution-Source");
if (src) {
while (*src && isspace ((unsigned) *src))
write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
CamelMimeMessage *mm = CAMEL_MIME_MESSAGE (data_wrapper);
-
+
/* force mandatory headers ... */
if (mm->from == NULL) {
/* FIXME: should we just abort? Should we make one up? */
}
if (!camel_medium_get_header ((CamelMedium *)mm, "Date"))
camel_mime_message_set_date (mm, CAMEL_MESSAGE_DATE_CURRENT, 0);
-
+
if (mm->subject == NULL)
camel_mime_message_set_subject (mm, "No Subject");
-
+
if (mm->message_id == NULL)
camel_mime_message_set_message_id (mm, NULL);
-
+
/* FIXME: "To" header needs to be set explicitly as well ... */
-
+
if (!camel_medium_get_header ((CamelMedium *)mm, "Mime-Version"))
camel_medium_set_header ((CamelMedium *)mm, "Mime-Version", "1.0");
-
+
return CAMEL_DATA_WRAPPER_CLASS (parent_class)->write_to_stream (data_wrapper, stream);
}
CamelMimeMessage *message = CAMEL_MIME_MESSAGE (medium);
CamelInternetAddress *addr;
const char *charset;
-
+
header_type = (CamelHeaderType) g_hash_table_lookup (header_name_table, name);
switch (header_type) {
case HEADER_FROM:
default:
return FALSE;
}
-
+
return TRUE;
}
CamelDataWrapper *containee;
int parts, i;
int go = TRUE;
-
+
if (callback (msg, part, data) == FALSE)
return FALSE;
-
+
containee = camel_medium_get_content_object (CAMEL_MEDIUM (part));
-
+
if (containee == NULL)
return go;
-
+
/* using the object types is more accurate than using the mime/types */
if (CAMEL_IS_MULTIPART (containee)) {
parts = camel_multipart_get_number (CAMEL_MULTIPART (containee));
for (i = 0; go && i < parts; i++) {
CamelMimePart *mpart = camel_multipart_get_part (CAMEL_MULTIPART (containee), i);
-
+
go = message_foreach_part_rec (msg, mpart, callback, data);
}
} else if (CAMEL_IS_MIME_MESSAGE (containee)) {
go = message_foreach_part_rec (msg, (CamelMimePart *)containee, callback, data);
}
-
+
return go;
}
{
CamelTransferEncoding encoding;
int *has8bit = data;
-
+
/* check this part, and stop as soon as we are done */
encoding = camel_mime_part_get_encoding (part);
-
+
*has8bit = encoding == CAMEL_TRANSFER_ENCODING_8BIT || encoding == CAMEL_TRANSFER_ENCODING_BINARY;
-
+
return !(*has8bit);
}
camel_mime_message_has_8bit_parts (CamelMimeMessage *msg)
{
int has8bit = FALSE;
-
+
camel_mime_message_foreach_part (msg, check_8bit, &has8bit);
-
+
return has8bit;
}
CamelStream *null;
int idb, idc = -1;
gboolean istext;
-
+
/* we use all these weird stream things so we can do it with streams, and
not have to read the whole lot into memory - although i have a feeling
it would make things a fair bit simpler to do so ... */
-
+
d(printf("starting to check part\n"));
-
+
content = camel_medium_get_content_object ((CamelMedium *)part);
if (content == NULL) {
/* charset might not be right here, but it'll get the right stuff
*charsetp = NULL;
return CAMEL_TRANSFER_ENCODING_DEFAULT;
}
-
+
istext = camel_content_type_is (((CamelDataWrapper *) part)->mime_type, "text", "*");
if (istext) {
flags = CAMEL_BESTENC_GET_CHARSET | CAMEL_BESTENC_GET_ENCODING;
} else {
flags = CAMEL_BESTENC_GET_ENCODING;
}
-
+
/* when building the message, any encoded parts are translated already */
flags |= CAMEL_BESTENC_LF_IS_CRLF;
/* and get any flags the caller passed in */
callerflags = (required & CAMEL_BESTENC_NO_FROM);
flags |= callerflags;
-
+
/* first a null stream, so any filtering is thrown away; we only want the sideeffects */
null = (CamelStream *)camel_stream_null_new ();
filter = camel_stream_filter_new_with_stream (null);
-
+
/* if we're looking for the best charset, then we need to convert to UTF-8 */
if (istext && (required & CAMEL_BESTENC_GET_CHARSET) != 0
&& (charsetin = camel_content_type_param (content->mime_type, "charset"))) {
idc = camel_stream_filter_add (filter, (CamelMimeFilter *)charenc);
charsetin = NULL;
}
-
+
bestenc = camel_mime_filter_bestenc_new (flags);
idb = camel_stream_filter_add (filter, (CamelMimeFilter *)bestenc);
d(printf("writing to checking stream\n"));
camel_object_unref (charenc);
charenc = NULL;
}
-
+
if (istext && (required & CAMEL_BESTENC_GET_CHARSET) != 0) {
charsetin = camel_mime_filter_bestenc_get_best_charset (bestenc);
d(printf("best charset = %s\n", charsetin ? charsetin : "(null)"));
charset = g_strdup (charsetin);
-
+
charsetin = camel_content_type_param (content->mime_type, "charset");
} else {
charset = NULL;
}
-
+
/* if we have US-ASCII, or we're not doing text, we dont need to bother with the rest */
if (istext && charsetin && charset && (required & CAMEL_BESTENC_GET_CHARSET) != 0) {
d(printf("have charset, trying conversion/etc\n"));
-
+
/* now that 'bestenc' has told us what the best encoding is, we can use that to create
a charset conversion filter as well, and then re-add the bestenc to filter the
result to find the best encoding to use as well */
-
+
charenc = camel_mime_filter_charset_new_convert (charsetin, charset);
if (charenc != NULL) {
/* otherwise, try another pass, converting to the real charset */
-
+
camel_mime_filter_reset ((CamelMimeFilter *)bestenc);
camel_mime_filter_bestenc_set_flags (bestenc, CAMEL_BESTENC_GET_ENCODING |
CAMEL_BESTENC_LF_IS_CRLF | callerflags);
-
+
camel_stream_filter_add (filter, (CamelMimeFilter *)charenc);
camel_stream_filter_add (filter, (CamelMimeFilter *)bestenc);
-
+
/* and write it to the new stream */
camel_data_wrapper_write_to_stream (content, (CamelStream *)filter);
-
+
camel_object_unref (charenc);
}
}
-
+
encoding = camel_mime_filter_bestenc_get_best_encoding (bestenc, enctype);
-
+
camel_object_unref (filter);
camel_object_unref (bestenc);
camel_object_unref (null);
-
+
d(printf("done, best encoding = %d\n", encoding));
-
+
if (charsetp)
*charsetp = charset;
else
g_free (charset);
-
+
return encoding;
}
CamelTransferEncoding encoding;
CamelDataWrapper *wrapper;
char *charset;
-
+
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
if (!wrapper)
return FALSE;
-
+
/* we only care about actual content objects */
if (!CAMEL_IS_MULTIPART (wrapper) && !CAMEL_IS_MIME_MESSAGE (wrapper)) {
encoding = find_best_encoding (part, data->required, data->enctype, &charset);
/* we always set the encoding, if we got this far. GET_CHARSET implies
also GET_ENCODING */
camel_mime_part_set_encoding (part, encoding);
-
+
if ((data->required & CAMEL_BESTENC_GET_CHARSET) != 0) {
if (camel_content_type_is (((CamelDataWrapper *) part)->mime_type, "text", "*")) {
char *newct;
-
+
/* FIXME: ick, the part content_type interface needs fixing bigtime */
camel_content_type_set_param (((CamelDataWrapper *) part)->mime_type, "charset",
charset ? charset : "us-ascii");
newct = camel_content_type_format (((CamelDataWrapper *) part)->mime_type);
if (newct) {
d(printf("Setting content-type to %s\n", newct));
-
+
camel_mime_part_set_content_type (part, newct);
g_free (newct);
}
}
}
-
+
g_free (charset);
}
-
+
return TRUE;
}
camel_mime_message_set_best_encoding (CamelMimeMessage *msg, CamelBestencRequired required, CamelBestencEncoding enctype)
{
struct _enc_data data;
-
+
if ((required & (CAMEL_BESTENC_GET_ENCODING|CAMEL_BESTENC_GET_CHARSET)) == 0)
return;
-
+
data.required = required;
data.enctype = enctype;
-
+
camel_mime_message_foreach_part (msg, best_encoding, &data);
}
struct _check_content_id *check = (struct _check_content_id *) data;
const char *content_id;
gboolean found;
-
+
content_id = camel_mime_part_get_content_id (part);
-
+
found = content_id && !strcmp (content_id, check->content_id) ? TRUE : FALSE;
if (found) {
check->part = part;
camel_object_ref (part);
}
-
+
return !found;
}
camel_mime_message_get_part_by_content_id (CamelMimeMessage *message, const char *id)
{
struct _check_content_id check;
-
+
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
-
+
if (id == NULL)
return NULL;
-
+
check.content_id = id;
check.part = NULL;
-
+
camel_mime_message_foreach_part (message, check_content_id, &check);
-
+
return check.part;
}
time_t thetime;
int offset;
struct tm tm;
-
+
tmp = camel_header_raw_find (&header, "Sender", NULL);
if (tmp == NULL)
tmp = camel_header_raw_find (&header, "From", NULL);
if (tmp != NULL) {
struct _camel_header_address *addr = camel_header_address_decode (tmp, NULL);
-
+
tmp = NULL;
if (addr) {
if (addr->type == CAMEL_HEADER_ADDRESS_NAME) {
camel_header_address_unref (addr);
}
}
-
+
if (tmp == NULL)
g_string_append (out, "unknown@nodomain.now.au");
-
+
/* try use the received header to get the date */
tmp = camel_header_raw_find (&header, "Received", NULL);
if (tmp) {
if (tmp)
tmp++;
}
-
+
/* if there isn't one, try the Date field */
if (tmp == NULL)
tmp = camel_header_raw_find (&header, "Date", NULL);
-
+
thetime = camel_header_decode_date (tmp, &offset);
thetime += ((offset / 100) * (60 * 60)) + (offset % 100) * 60;
gmtime_r (&thetime, &tm);
tz_days[tm.tm_wday], tz_months[tm.tm_mon],
tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
tm.tm_year + 1900);
-
+
ret = out->str;
g_string_free (out, FALSE);
-
+
return ret;
}
printf("%smime-type: %s\n", s, camel_content_type_format(((CamelDataWrapper *)part)->mime_type));
containee = camel_medium_get_content_object((CamelMedium *)part);
-
+
if (containee == NULL)
return;
printf("%scontent class: %s\n", s, ((CamelObject *)containee)->klass->name);
printf("%scontent mime-type: %s\n", s, camel_content_type_format(((CamelDataWrapper *)containee)->mime_type));
-
+
/* using the object types is more accurate than using the mime/types */
if (CAMEL_IS_MULTIPART(containee)) {
parts = camel_multipart_get_number((CamelMultipart *)containee);
for (i = 0; go && i < parts; i++) {
CamelMimePart *mpart = camel_multipart_get_part((CamelMultipart *)containee, i);
-
+
cmm_dump_rec(msg, mpart, body, depth+2);
}
} else if (CAMEL_IS_MIME_MESSAGE(containee)) {
/**
* camel_mime_message_dump:
- * @msg:
- * @body:
- *
+ * @msg:
+ * @body:
+ *
* Dump information about the mime message to stdout.
*
* If body is TRUE, then dump body content of the message as well (currently unimplemented).
*
* Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct {
CamelMimePartClass parent_class;
- /* Virtual methods */
+ /* Virtual methods */
} CamelMimeMessageClass;
void camel_mime_message_set_source (CamelMimeMessage *message,
const char *identity);
const char *camel_mime_message_get_source (CamelMimeMessage *message);
-
+
/* utility functions */
gboolean camel_mime_message_has_8bit_parts (CamelMimeMessage *message);
#include "camel-seekable-stream.h"
#include "camel-stream.h"
-#define r(x)
-#define h(x)
-#define c(x)
-#define d(x)
+#define r(x)
+#define h(x)
+#define c(x)
+#define d(x)
/*#define PRESERVE_HEADERS*/
camel_mime_parser_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_object_get_type (), "CamelMimeParser",
sizeof (CamelMimeParser),
(CamelObjectInitFunc) camel_mime_parser_init,
(CamelObjectFinalizeFunc) camel_mime_parser_finalise);
}
-
+
return type;
}
* camel_mime_parser_new:
*
* Create a new CamelMimeParser object.
- *
+ *
* Return value: A new CamelMimeParser widget.
**/
CamelMimeParser *
/**
* camel_mime_parser_filter_add:
- * @m:
- * @mf:
- *
+ * @m:
+ * @mf:
+ *
* Add a filter that will be applied to any body content before it is passed
* to the caller. Filters may be pipelined to perform multi-pass operations
* on the content, and are applied in the order they were added.
* Note that filters are only applied to the body content of messages, and once
* a filter has been set, all content returned by a filter_step() with a state
* of CAMEL_MIME_PARSER_STATE_BODY will have passed through the filter.
- *
+ *
* Return value: An id that may be passed to filter_remove() to remove
* the filter, or -1 if the operation failed.
**/
/**
* camel_mime_parser_filter_remove:
- * @m:
- * @id:
- *
+ * @m:
+ * @id:
+ *
* Remove a processing filter from the pipeline. There is no
* restriction on the order the filters can be removed.
**/
{
struct _header_scan_state *s = _PRIVATE(m);
struct _header_scan_filter *f, *old;
-
+
f = (struct _header_scan_filter *)&s->filters;
while (f && f->next) {
old = f->next;
/**
* camel_mime_parser_header:
- * @m:
+ * @m:
* @name: Name of header.
* @offset: Pointer that can receive the offset of the header in
* the stream from the start of parsing.
- *
+ *
* Lookup a header by name.
- *
+ *
* Return value: The header value, or NULL if the header is not
* defined.
**/
/**
* camel_mime_parser_headers_raw:
- * @m:
- *
+ * @m:
+ *
* Get the list of the raw headers which are defined for the
* current state of the parser. These headers are valid
* until the next call to parser_step(), or parser_drop_step().
- *
+ *
* Return value: The raw headers, or NULL if there are no headers
* defined for the current part or state. These are READ ONLY.
**/
/**
* camel_mime_parser_preface:
- * @m:
- *
+ * @m:
+ *
* Retrieve the preface text for the current multipart.
* Can only be used when the state is CAMEL_MIME_PARSER_STATE_MULTIPART_END.
- *
+ *
* Return value: The preface text, or NULL if there wasn't any.
**/
const char *
/**
* camel_mime_parser_postface:
- * @m:
- *
+ * @m:
+ *
* Retrieve the postface text for the current multipart.
* Only returns valid data when the current state if
* CAMEL_MIME_PARSER_STATE_MULTIPART_END.
- *
+ *
* Return value: The postface text, or NULL if there wasn't any.
**/
const char *
/**
* camel_mime_parser_from_line:
- * @m:
- *
+ * @m:
+ *
* Get the last scanned "From " line, from a recently scanned from.
* This should only be called in the CAMEL_MIME_PARSER_STATE_FROM state. The
* from line will include the closing \n found (if there was one).
*
* The return value will remain valid while in the CAMEL_MIME_PARSER_STATE_FROM
* state, or any deeper state.
- *
+ *
* Return value: The From line, or NULL if called out of context.
**/
const char *
/**
* camel_mime_parser_init_with_fd:
- * @m:
+ * @m:
* @fd: A valid file descriptor.
- *
+ *
* Initialise the scanner with an fd. The scanner's offsets
* will be relative to the current file position of the file
* descriptor. As a result, seekable descritors should
/**
* camel_mime_parser_init_with_stream:
- * @m:
- * @stream:
- *
+ * @m:
+ * @stream:
+ *
* Initialise the scanner with a source stream. The scanner's
* offsets will be relative to the current file position of
* the stream. As a result, seekable streams should only
* be seeked using the parser seek function.
- *
+ *
* Return value: -1 on error.
**/
int
* camel_mime_parser_scan_from:
* @parser: MIME parser object
* @scan_from: #TRUE if the scanner should scan From lines.
- *
+ *
* Tell the scanner if it should scan "^From " lines or not.
*
* If the scanner is scanning from lines, two additional
camel_mime_parser_scan_from (CamelMimeParser *parser, gboolean scan_from)
{
struct _header_scan_state *s = _PRIVATE (parser);
-
+
s->scan_from = scan_from;
}
* camel_mime_parser_scan_pre_from:
* @parser: MIME parser object
* @scan_pre_from: #TRUE if we want to get pre-from data.
- *
+ *
* Tell the scanner whether we want to know abou the pre-from
* data during a scan. If we do, then we may get an additional
* state CAMEL_MIME_PARSER_STATE_PRE_FROM which returns the specified data.
camel_mime_parser_scan_pre_from (CamelMimeParser *parser, gboolean scan_pre_from)
{
struct _header_scan_state *s = _PRIVATE (parser);
-
+
s->scan_pre_from = scan_pre_from;
}
/**
* camel_mime_parser_content_type:
* @parser: MIME parser object
- *
+ *
* Get the content type defined in the current part.
- *
+ *
* Return value: A content_type structure, or NULL if there
* is no content-type defined for this part of state of the
* parser.
camel_mime_parser_content_type (CamelMimeParser *parser)
{
struct _header_scan_state *s = _PRIVATE (parser);
-
+
/* FIXME: should this search up until it's found the 'right'
content-type? can it? */
if (s->parts)
return s->parts->content_type;
-
+
return NULL;
}
/**
* camel_mime_parser_unstep:
* @parser: MIME parser object
- *
- * Cause the last step operation to repeat itself. If this is
+ *
+ * Cause the last step operation to repeat itself. If this is
* called repeated times, then the same step will be repeated
* that many times.
*
camel_mime_parser_unstep (CamelMimeParser *parser)
{
struct _header_scan_state *s = _PRIVATE (parser);
-
+
s->unstep++;
}
/**
* camel_mime_parser_drop_step:
* @parser: MIME parser object
- *
+ *
* Drop the last step call. This should only be used
* in conjunction with seeking of the stream as the
* stream may be in an undefined state relative to the
camel_mime_parser_drop_step (CamelMimeParser *parser)
{
struct _header_scan_state *s = _PRIVATE (parser);
-
+
s->unstep = 0;
folder_scan_drop_step(s);
}
/**
* camel_mime_parser_step:
- * @parser: MIME parser object
+ * @parser: MIME parser object
* @databuffer: Pointer to accept a pointer to the data
* associated with this step (if any). May be #NULL,
* in which case datalength is also ingored.
* @datalength: Pointer to accept a pointer to the data
* length associated with this step (if any).
- *
+ *
* Parse the next part of the MIME message. If _unstep()
* has been called, then continue to return the same state
* for that many calls.
databuffer = &dummy;
datalength = &dummylength;
}
-
+
folder_scan_step(s, databuffer, datalength);
} else
s->unstep--;
/**
* camel_mime_parser_read:
* @parser: MIME parser object
- * @databuffer:
- * @len:
- *
+ * @databuffer:
+ * @len:
+ *
* Read at most @len bytes from the internal mime parser buffer.
*
* Returns the address of the internal buffer in @databuffer,
/**
* camel_mime_parser_tell:
* @parser: MIME parser object
- *
+ *
* Return the current scanning offset. The meaning of this
* value will depend on the current state of the parser.
*
* CAMEL_MIME_PARSER_STATE_*_END, The position of the character starting
* the next section of the scan (the last position + 1 of
* the respective current state).
- *
+ *
* Return value: See above.
**/
off_t
/**
* camel_mime_parser_tell_start_headers:
* @parser: MIME parser object
- *
+ *
* Find out the position within the file of where the
* headers started, this is cached by the parser
* at the time.
- *
+ *
* Return value: The header start position, or -1 if
* no headers were scanned in the current state.
**/
/**
* camel_mime_parser_tell_start_from:
* @parser: MIME parser object
- *
+ *
* If the parser is scanning From lines, then this returns
* the position of the start of the From line.
- *
+ *
* Return value: The start of the from line, or -1 if there
* was no From line, or From lines are not being scanned.
**/
/**
* camel_mime_parser_tell_start_boundary:
* @parser: MIME parser object
- *
+ *
* When parsing a multipart, this returns the start of the last
* boundary.
- *
+ *
* Return value: The start of the boundary, or -1 if there
* was no boundary encountered yet.
**/
* @parser: MIME parser object
* @offset: Number of bytes to offset the seek by.
* @whence: SEEK_SET, SEEK_CUR, SEEK_END
- *
+ *
* Reset the source position to a known value.
*
* Note that if the source stream/descriptor was not
* positioned at 0 to begin with, and an absolute seek
* is specified (whence != SEEK_CUR), then the seek
* position may not match the desired seek position.
- *
+ *
* Return value: The new seek offset, or -1 on
* an error (for example, trying to seek on a non-seekable
* stream or file descriptor).
camel_mime_parser_seek(CamelMimeParser *parser, off_t offset, int whence)
{
struct _header_scan_state *s = _PRIVATE (parser);
-
+
return folder_seek(s, offset, whence);
}
/**
* camel_mime_parser_state:
* @parser: MIME parser object
- *
+ *
* Get the current parser state.
- *
+ *
* Return value: The current parser state.
**/
camel_mime_parser_state_t
camel_mime_parser_state (CamelMimeParser *parser)
{
struct _header_scan_state *s = _PRIVATE (parser);
-
+
return s->state;
}
* @mp: MIME parser object
* @newstate: New state
* @boundary: Boundary marker for state.
- *
+ *
* Pre-load a new parser state. Used to post-parse multipart content
* without headers.
**/
/**
* camel_mime_parser_stream:
* @parser: MIME parser object
- *
+ *
* Get the stream, if any, the parser has been initialised
* with. May be used to setup sub-streams, but should not
* be read from directly (without saving and restoring
* the seek position in between).
- *
+ *
* Return value: The stream from _init_with_stream(), or NULL
* if the parser is reading from a file descriptor or is
* uninitialised.
camel_mime_parser_stream (CamelMimeParser *parser)
{
struct _header_scan_state *s = _PRIVATE (parser);
-
+
return s->stream;
}
/**
* camel_mime_parser_fd:
* @parser: MIME parser object
- *
+ *
* Return the file descriptor, if any, the parser has been
* initialised with.
*
* Should not be read from unless the parser it to terminate,
* or the seek offset can be reset before the next parse
* step.
- *
+ *
* Return value: The file descriptor or -1 if the parser
* is reading from a stream or has not been initialised.
**/
camel_mime_parser_fd (CamelMimeParser *parser)
{
struct _header_scan_state *s = _PRIVATE (parser);
-
+
return s->fd;
}
camel_mime_parser_errno (CamelMimeParser *parser)
{
struct _header_scan_state *s = _PRIVATE (parser);
-
+
return s->ioerrno;
}
}
/*
- need some way to prime the parser state, so this actually works for
+ need some way to prime the parser state, so this actually works for
other than top-level messages
*/
static off_t
/* again, make sure we're in range */
if (part->boundarylenfinal <= len) {
int extra = part->boundarylenfinal - part->boundarylen;
-
+
/* check the extra stuff on an final boundary, normally -- for mime parts */
if (extra>0) {
*lastone = memcmp(&boundary[part->boundarylen],
{
struct _camel_header_raw *l, *n;
char *content;
-
+
content = strchr(header, ':');
if (content) {
register int len;
n = e_mempool_alloc(h->pool, sizeof(*n));
n->next = NULL;
-
+
len = content-header;
n->name = e_mempool_alloc(h->pool, len+1);
memcpy(n->name, header, len);
n->name[len] = 0;
-
+
content++;
-
+
len = s->outptr - content;
n->value = e_mempool_alloc(h->pool, len+1);
memcpy(n->value, content, len);
n->value[len] = 0;
-
+
n->offset = offset;
-
+
l = (struct _camel_header_raw *)&h->headers;
while (l->next) {
l = l->next;
}
l->next = n;
}
-
+
}
#define header_raw_append_parse(a, b, c) (header_append_mempool(s, h, b, c))
while ((len = folder_read(s))>0 && len >= s->atleast) { /* ensure we have at least enough room here */
inptr = s->inptr;
inend = s->inend-s->atleast+1;
-
+
while (inptr<inend) {
if (!s->midline) {
if (folder_boundary_check(s, inptr, lastone)) {
if ((s->outptr>s->outbuf))
goto header_truncated; /* may not actually be truncated */
-
+
goto header_done;
}
}
-
+
start = inptr;
/* goto next line/sentinal */
while ((*inptr++)!='\n')
;
-
+
g_assert(inptr<=s->inend+1);
-
+
/* check for sentinal or real end of line */
if (inptr > inend) {
h(printf("not at end of line yet, going further\n"));
s->outptr--;
#endif
s->outptr[0] = 0;
-
+
h(printf("header '%s' at %d\n", s->outbuf, (int)s->header_start));
-
+
header_raw_append_parse(&h->headers, s->outbuf, s->header_start);
s->outptr = s->outbuf;
s->header_start = -1;
}
goto header_truncated;
}
-
+
s->atleast = atleast;
-
+
return h;
-
+
header_truncated:
header_append(s, start, inptr);
-
+
s->outptr[0] = 0;
if (s->outbuf == s->outptr)
goto header_done;
-
+
header_raw_append_parse(&h->headers, s->outbuf, s->header_start);
-
+
s->outptr = s->outbuf;
header_done:
s->inptr = inptr;
/* otherwise, jump to the state of the boundary we actually found */
goto normal_exit;
}
-
+
/* goto the next line */
while ((*inptr++)!='\n')
;
folder_push_part(s, h);
s->state = type;
return;
-
+
case CAMEL_MIME_PARSER_STATE_HEADER:
s->state = CAMEL_MIME_PARSER_STATE_BODY;
-
+
case CAMEL_MIME_PARSER_STATE_BODY:
h = s->parts;
*datalength = 0;
presize = SCAN_HEAD;
f = s->filters;
-
+
do {
hb = folder_scan_content (s, &state, databuffer, datalength);
return;
}
} while (hb == h && *datalength > 0);
-
+
/* check for any filter completion data */
while (f) {
camel_mime_filter_complete(f->filter, *databuffer, *datalength, presize,
if (*datalength > 0)
return;
-
+
s->state = CAMEL_MIME_PARSER_STATE_BODY_END;
break;
-
+
case CAMEL_MIME_PARSER_STATE_MULTIPART:
h = s->parts;
/* This mess looks for the next boundary on this
name = argv[i];
printf("opening: %s", name);
-
+
fd = g_open(name, O_RDONLY|O_BINARY, 0);
if (fd==-1) {
perror("Cannot open mailbox");
h = g_malloc0(sizeof(*h));
h->savestate = CAMEL_MIME_PARSER_STATE_EOF;
folder_push_part(s, h);
-#endif
+#endif
while (s->state != CAMEL_MIME_PARSER_STATE_EOF) {
folder_scan_step(s, &data, &len);
printf("\n -- PARSER STEP RETURN -- %d '%s'\n\n", s->state, states[s->state]);
CAMEL_MIME_PARSER_STATE_BODY, /* scanning body of message */
CAMEL_MIME_PARSER_STATE_MULTIPART, /* got multipart header */
CAMEL_MIME_PARSER_STATE_MESSAGE, /* rfc822 message */
-
+
CAMEL_MIME_PARSER_STATE_PART, /* part of a multipart */
-
+
CAMEL_MIME_PARSER_STATE_END = 8, /* bit mask for 'end' flags */
-
+
CAMEL_MIME_PARSER_STATE_EOF = 8, /* end of file */
CAMEL_MIME_PARSER_STATE_PRE_FROM_END, /* pre from end */
CAMEL_MIME_PARSER_STATE_FROM_END, /* end of whole from bracket */
*
* Copyright 1999-2003 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
GByteArray *buffer;
CamelStream *mem;
size_t len;
-
+
d(printf ("simple_data_wrapper_construct_from_parser()\n"));
-
+
/* read in the entire content */
buffer = g_byte_array_new ();
while (camel_mime_parser_step (mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_BODY_END) {
d(printf("appending o/p data: %d: %.*s\n", len, len, buf));
g_byte_array_append (buffer, buf, len);
}
-
+
d(printf("message part kept in memory!\n"));
-
+
mem = camel_stream_mem_new_with_byte_array (buffer);
camel_data_wrapper_construct_from_stream (dw, mem);
camel_object_unref (mem);
ct = camel_mime_parser_content_type (mp);
encoding = camel_content_transfer_encoding_decode (camel_mime_parser_header (mp, "Content-Transfer-Encoding", NULL));
-
+
switch (camel_mime_parser_state (mp)) {
case CAMEL_MIME_PARSER_STATE_HEADER:
d(printf("Creating body part\n"));
content = (CamelDataWrapper *) camel_multipart_signed_new ();
else
content = (CamelDataWrapper *) camel_multipart_new ();
-
+
camel_multipart_construct_from_parser((CamelMultipart *)content, mp);
d(printf("Created multi-part\n"));
break;
default:
g_warning("Invalid state encountered???: %u", camel_mime_parser_state (mp));
}
-
+
if (content) {
if (encoding)
content->encoding = camel_transfer_encoding_from_string (encoding);
/* camel-mime-part-utils : Utility for mime parsing and so on */
-/*
+/*
*
- * Author :
+ * Author :
* Bertrand Guiheneuf <bertrand@helixcode.com>
*
* Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */
/* camelMimePart.c : Abstract class for a mime_part */
-/*
+/*
* Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
* Michael Zucchi <notzed@ximian.com>
* Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright 1999-2003 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
static ssize_t write_to_stream (CamelDataWrapper *dw, CamelStream *stream);
static int construct_from_stream (CamelDataWrapper *dw, CamelStream *stream);
-/* from CamelMedium */
+/* from CamelMedium */
static void add_header (CamelMedium *medium, const char *name, const void *value);
static void set_header (CamelMedium *medium, const char *name, const void *value);
static void remove_header (CamelMedium *medium, const char *name);
init_header_name_table();
camel_mime_part_class->construct_from_parser = construct_from_parser;
-
- /* virtual method overload */
+
+ /* virtual method overload */
camel_medium_class->add_header = add_header;
camel_medium_class->set_header = set_header;
camel_medium_class->get_header = get_header;
camel_medium_class->get_headers = get_headers;
camel_medium_class->free_headers = free_headers;
camel_medium_class->set_content_object = set_content_object;
-
+
camel_data_wrapper_class->write_to_stream = write_to_stream;
camel_data_wrapper_class->construct_from_stream= construct_from_stream;
}
camel_mime_part_init (gpointer object, gpointer klass)
{
CamelMimePart *mime_part = CAMEL_MIME_PART (object);
-
+
if (((CamelDataWrapper *) mime_part)->mime_type)
camel_content_type_unref (((CamelDataWrapper *) mime_part)->mime_type);
((CamelDataWrapper *) mime_part)->mime_type = camel_content_type_new ("text", "plain");
-
+
mime_part->description = NULL;
mime_part->disposition = NULL;
mime_part->content_id = NULL;
}
-static void
+static void
camel_mime_part_finalize (CamelObject *object)
{
CamelMimePart *mime_part = CAMEL_MIME_PART (object);
-
+
g_free (mime_part->description);
g_free (mime_part->content_id);
g_free (mime_part->content_MD5);
g_free (mime_part->content_location);
camel_string_list_free (mime_part->content_languages);
camel_content_disposition_unref(mime_part->disposition);
-
+
camel_header_raw_clear(&mime_part->headers);
}
camel_mime_part_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (CAMEL_MEDIUM_TYPE,
"CamelMimePart",
(CamelObjectInitFunc) camel_mime_part_init,
(CamelObjectFinalizeFunc) camel_mime_part_finalize);
}
-
+
return type;
}
set_header (CamelMedium *medium, const char *name, const void *value)
{
CamelMimePart *part = CAMEL_MIME_PART (medium);
-
+
process_header(medium, name, value);
camel_header_raw_replace(&part->headers, name, value, -1);
}
add_header (CamelMedium *medium, const char *name, const void *value)
{
CamelMimePart *part = CAMEL_MIME_PART (medium);
-
+
/* Try to parse the header pair. If it corresponds to something */
/* known, the job is done in the parsing routine. If not, */
/* we simply add the header in a raw fashion */
remove_header (CamelMedium *medium, const char *name)
{
CamelMimePart *part = (CamelMimePart *)medium;
-
+
process_header(medium, name, NULL);
camel_header_raw_remove(&part->headers, name);
}
camel_mime_part_set_description (CamelMimePart *mime_part, const char *description)
{
char *text = camel_header_encode_string (description);
-
+
camel_medium_set_header (CAMEL_MEDIUM (mime_part),
"Content-Description", text);
g_free (text);
camel_mime_part_set_filename (CamelMimePart *mime_part, const char *filename)
{
char *str;
-
+
if (mime_part->disposition == NULL)
mime_part->disposition = camel_content_disposition_decode("attachment");
camel_medium_set_header (CAMEL_MEDIUM (mime_part),
"Content-Disposition", str);
g_free(str);
-
+
camel_content_type_set_param (((CamelDataWrapper *) mime_part)->mime_type, "name", filename);
str = camel_content_type_format (((CamelDataWrapper *) mime_part)->mime_type);
camel_medium_set_header (CAMEL_MEDIUM (mime_part), "Content-Type", str);
if (name)
return name;
}
-
+
return camel_content_type_param (((CamelDataWrapper *) mime_part)->mime_type, "name");
}
camel_mime_part_set_content_id (CamelMimePart *mime_part, const char *contentid)
{
char *cid, *id;
-
+
if (contentid)
id = g_strstrip (g_strdup (contentid));
else
id = camel_header_msgid_generate ();
-
+
cid = g_strdup_printf ("<%s>", id);
g_free (id);
camel_medium_set_header (CAMEL_MEDIUM (mime_part), "Content-ID", cid);
{
if (mime_part->content_languages)
camel_string_list_free (mime_part->content_languages);
-
+
mime_part->content_languages = content_languages;
/* FIXME: translate to a header and set it */
{
CamelDataWrapper *mime_part = CAMEL_DATA_WRAPPER (medium);
CamelContentType *content_type;
-
+
parent_class->set_content_object (medium, content);
-
+
content_type = camel_data_wrapper_get_mime_type_field (content);
if (mime_part->mime_type != content_type) {
char *txt;
-
+
txt = camel_content_type_format (content_type);
camel_medium_set_header (CAMEL_MEDIUM (mime_part), "Content-Type", txt);
g_free (txt);
{
ssize_t len, out, total;
char *v, *ids, *ide;
-
+
/* this is only approximate, based on the next >, this way it retains any content
from the original which may not be properly formatted, etc. It also doesn't handle
the case where an individual messageid is too long, however thats a bad mail to
ssize_t total = 0;
ssize_t count;
int errnosav;
-
+
d(printf("mime_part::write_to_stream\n"));
-
+
/* FIXME: something needs to be done about this ... */
/* TODO: content-languages header? */
-
+
if (mp->headers) {
struct _camel_header_raw *h = mp->headers;
char *val;
ssize_t (*writefn)(CamelStream *stream, struct _camel_header_raw *);
-
+
/* fold/write the headers. But dont fold headers that are already formatted
(e.g. ones with parameter-lists, that we know about, and have created) */
while (h) {
h = h->next;
}
}
-
+
count = camel_stream_write(stream, "\n", 1);
if (count == -1)
return -1;
total += count;
-
+
content = camel_medium_get_content_object(medium);
if (content) {
CamelMimeFilter *filter = NULL;
const char *part_charset = NULL;
gboolean reencode = FALSE;
const char *filename;
-
+
if (camel_content_type_is (dw->mime_type, "text", "*")) {
content_charset = camel_content_type_param (content->mime_type, "charset");
part_charset = camel_content_type_param (dw->mime_type, "charset");
-
+
if (content_charset && part_charset) {
content_charset = e_iconv_charset_name (content_charset);
part_charset = e_iconv_charset_name (part_charset);
}
}
-
+
if (mp->encoding != content->encoding) {
switch (mp->encoding) {
case CAMEL_TRANSFER_ENCODING_BASE64:
break;
}
}
-
+
if (content_charset && part_charset && part_charset != content_charset)
charenc = (CamelMimeFilter *) camel_mime_filter_charset_new_convert (content_charset, part_charset);
-
+
if (filter || charenc) {
filter_stream = camel_stream_filter_new_with_stream(stream);
-
+
/* if we have a character encoder, add that always */
if (charenc) {
camel_stream_filter_add(filter_stream, charenc);
camel_object_unref (charenc);
}
-
+
/* we only re-do crlf on encoded blocks */
if (filter && camel_content_type_is (dw->mime_type, "text", "*")) {
CamelMimeFilter *crlf = camel_mime_filter_crlf_new(CAMEL_MIME_FILTER_CRLF_ENCODE,
CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
-
+
camel_stream_filter_add(filter_stream, crlf);
camel_object_unref (crlf);
}
-
+
if (filter) {
camel_stream_filter_add(filter_stream, filter);
camel_object_unref (filter);
}
-
+
stream = (CamelStream *)filter_stream;
-
+
reencode = TRUE;
}
-
+
if (reencode)
count = camel_data_wrapper_decode_to_stream (content, stream);
else
count = camel_data_wrapper_write_to_stream (content, stream);
-
+
if (filter_stream) {
errnosav = errno;
camel_stream_flush (stream);
camel_object_unref (filter_stream);
errno = errnosav;
}
-
+
if (count == -1)
return -1;
-
+
total += count;
-
+
if (reencode && mp->encoding == CAMEL_TRANSFER_ENCODING_UUENCODE) {
count = camel_stream_write (ostream, "end\n", 4);
if (count == -1)
} else {
g_warning("No content for medium, nothing to write");
}
-
+
return total;
}
char *buf;
size_t len;
int err;
-
+
d(printf("mime_part::construct_from_parser()\n"));
-
+
switch (camel_mime_parser_step(mp, &buf, &len)) {
case CAMEL_MIME_PARSER_STATE_MESSAGE:
/* set the default type of a message always */
* @parser: a #CamelMimeParser object
*
* Constructs a MIME part from a parser.
- *
+ *
* Returns %0 on success or %-1 on fail
**/
int
* @data: data to put into the part
* @length: length of @data
* @type: Content-Type of the data
- *
- * Utility function used to set the content of a mime part object to
+ *
+ * Utility function used to set the content of a mime part object to
* be the provided data. If @length is 0, this routine can be used as
* a way to remove old content (in which case @data and @type are
* ignored and may be %NULL).
**/
-void
+void
camel_mime_part_set_content (CamelMimePart *mime_part,
const char *data, int length,
const char *type) /* why on earth is the type last? */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */
/* camel-mime-part.h : class for a mime part */
-/*
+/*
*
* Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
* Michael Zucchi <notzed@ximian.com>
*
* Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* Do not change these values directly, you would regret it one day */
struct _CamelMimePart {
CamelMedium parent_object;
-
+
struct _camel_header_raw *headers; /* mime headers */
-
+
/* All fields here are -** PRIVATE **- */
/* TODO: these should be in a camelcontentinfo */
char *description;
typedef struct _CamelMimePartClass {
CamelMediumClass parent_class;
-
+
/* Virtual methods */
int (*construct_from_parser) (CamelMimePart *, CamelMimeParser *);
} CamelMimePartClass;
register unsigned char *outptr, *bufptr;
register guint32 saved;
int uulen, uufill, i;
-
+
outptr = out;
-
+
if (len > 0)
outptr += camel_uuencode_step (in, len, out, uubuf, state, save);
-
+
uufill = 0;
-
+
saved = *save;
i = *state & 0xff;
uulen = (*state >> 8) & 0xff;
-
+
bufptr = uubuf + ((uulen / 3) * 4);
-
+
if (i > 0) {
while (i < 3) {
saved <<= 8 | 0;
uufill++;
i++;
}
-
+
if (i == 3) {
/* convert 3 normal bytes into 4 uuencoded bytes */
unsigned char b0, b1, b2;
-
+
b0 = saved >> 16;
b1 = saved >> 8 & 0xff;
b2 = saved & 0xff;
-
+
*bufptr++ = CAMEL_UUENCODE_CHAR ((b0 >> 2) & 0x3f);
*bufptr++ = CAMEL_UUENCODE_CHAR (((b0 << 4) | ((b1 >> 4) & 0xf)) & 0x3f);
*bufptr++ = CAMEL_UUENCODE_CHAR (((b1 << 2) | ((b2 >> 6) & 0x3)) & 0x3f);
*bufptr++ = CAMEL_UUENCODE_CHAR (b2 & 0x3f);
-
+
i = 0;
saved = 0;
uulen += 3;
}
}
-
+
if (uulen > 0) {
int cplen = ((uulen / 3) * 4);
-
+
*outptr++ = CAMEL_UUENCODE_CHAR ((uulen - uufill) & 0xff);
memcpy (outptr, uubuf, cplen);
outptr += cplen;
*outptr++ = '\n';
uulen = 0;
}
-
+
*outptr++ = CAMEL_UUENCODE_CHAR (uulen & 0xff);
*outptr++ = '\n';
-
+
*save = 0;
*state = 0;
-
+
return outptr - out;
}
unsigned char *inend;
register guint32 saved;
int uulen, i;
-
+
saved = *save;
i = *state & 0xff;
uulen = (*state >> 8) & 0xff;
-
+
inptr = in;
inend = in + len;
-
+
outptr = out;
-
+
bufptr = uubuf + ((uulen / 3) * 4);
-
+
while (inptr < inend) {
while (uulen < 45 && inptr < inend) {
while (i < 3 && inptr < inend) {
saved = (saved << 8) | *inptr++;
i++;
}
-
+
if (i == 3) {
/* convert 3 normal bytes into 4 uuencoded bytes */
unsigned char b0, b1, b2;
-
+
b0 = saved >> 16;
b1 = saved >> 8 & 0xff;
b2 = saved & 0xff;
-
+
*bufptr++ = CAMEL_UUENCODE_CHAR ((b0 >> 2) & 0x3f);
*bufptr++ = CAMEL_UUENCODE_CHAR (((b0 << 4) | ((b1 >> 4) & 0xf)) & 0x3f);
*bufptr++ = CAMEL_UUENCODE_CHAR (((b1 << 2) | ((b2 >> 6) & 0x3)) & 0x3f);
*bufptr++ = CAMEL_UUENCODE_CHAR (b2 & 0x3f);
-
+
i = 0;
saved = 0;
uulen += 3;
}
}
-
+
if (uulen >= 45) {
*outptr++ = CAMEL_UUENCODE_CHAR (uulen & 0xff);
memcpy (outptr, uubuf, ((uulen / 3) * 4));
bufptr = uubuf;
}
}
-
+
*save = saved;
*state = ((uulen & 0xff) << 8) | (i & 0xff);
-
+
return outptr - out;
}
register guint32 saved;
gboolean last_was_eoln;
int uulen, i;
-
+
if (*state & CAMEL_UUDECODE_STATE_END)
return 0;
-
+
saved = *save;
i = *state & 0xff;
uulen = (*state >> 8) & 0xff;
last_was_eoln = TRUE;
else
last_was_eoln = FALSE;
-
+
inend = in + len;
outptr = out;
-
+
inptr = in;
while (inptr < inend) {
if (*inptr == '\n' || last_was_eoln) {
} else {
last_was_eoln = TRUE;
}
-
+
inptr++;
continue;
}
-
+
ch = *inptr++;
-
+
if (uulen > 0) {
/* save the byte */
saved = (saved << 8) | ch;
if (i == 4) {
/* convert 4 uuencoded bytes to 3 normal bytes */
unsigned char b0, b1, b2, b3;
-
+
b0 = saved >> 24;
b1 = saved >> 16 & 0xff;
b2 = saved >> 8 & 0xff;
b3 = saved & 0xff;
-
+
if (uulen >= 3) {
*outptr++ = CAMEL_UUDECODE_CHAR (b0) << 2 | CAMEL_UUDECODE_CHAR (b1) >> 4;
*outptr++ = CAMEL_UUDECODE_CHAR (b1) << 4 | CAMEL_UUDECODE_CHAR (b2) >> 2;
*outptr++ = CAMEL_UUDECODE_CHAR (b1) << 4 | CAMEL_UUDECODE_CHAR (b2) >> 2;
}
}
-
+
i = 0;
saved = 0;
uulen -= 3;
break;
}
}
-
+
*save = saved;
*state = (*state & CAMEL_UUDECODE_STATE_MASK) | ((uulen & 0xff) << 8) | (i & 0xff);
-
+
return outptr - out;
}
unsigned char c;
register int sofar = *save; /* keeps track of how many chars on a line */
register int last = *statep; /* keeps track if last char to end was a space cr etc */
-
+
inptr = in;
inend = in + len;
outptr = out;
sofar += 3;
}
}
-
+
if (camel_mime_is_qpsafe(c)) {
if (sofar > 74) {
*outptr++ = '=';
*outptr++ = '\n';
sofar = 0;
}
-
+
/* delay output of space char */
if (c==' ' || c=='\t') {
last = c;
sofar = 3;
} else
sofar += 3;
-
+
*outptr++ = '=';
*outptr++ = tohex[(c >> 4) & 0xf];
*outptr++ = tohex[c & 0xf];
}
*save = sofar;
*statep = last;
-
+
return (outptr - out);
}
Should it also canonicalise the end of line to CR LF??
Note: Trailing rubbish (at the end of input), like = or =x or =\r will be lost.
-*/
+*/
/**
* camel_quoted_decode_step:
case 0:
while (inptr<inend) {
c = *inptr++;
- if (c=='=') {
+ if (c=='=') {
state = 1;
break;
}
size_t inlen, outlen;
gboolean retried = FALSE;
iconv_t ic;
-
+
d(printf("rfc2047: decoding '%.*s'\n", len, in));
/* quick check to see if this could possibly be a real encoded word */
d(printf("invalid\n"));
return NULL;
}
-
+
/* skip past the charset to the encoding type */
inptr = memchr (inptr, '?', inend-inptr);
if (inptr != NULL && inptr < inend + 2 && inptr[2] == '?') {
case 'B': {
int state = 0;
unsigned int save = 0;
-
+
inlen = camel_base64_decode_step((char *)inptr+2, tmplen, decword, &state, &save);
/* if state != 0 then error? */
break;
encname = g_alloca (tmplen + 1);
memcpy (encname, in + 2, tmplen);
encname[tmplen] = '\0';
-
+
/* rfc2231 updates rfc2047 encoded words...
* The ABNF given in RFC 2047 for encoded-words is:
* encoded-word := "=?" charset "?" encoding "?" encoded-text "?="
* This specification changes this ABNF to:
* encoded-word := "=?" charset ["*" language] "?" encoding "?" encoded-text "?="
*/
-
+
/* trim off the 'language' part if it's there... */
p = strchr (encname, '*');
if (p)
*p = '\0';
-
+
charset = e_iconv_charset_name (encname);
-
+
inbuf = decword;
-
+
outlen = inlen * 6 + 16;
outbase = g_alloca (outlen);
outbuf = outbase;
-
+
retry:
ic = e_iconv_open ("UTF-8", charset);
if (ic != (iconv_t) -1) {
} else {
w(g_warning ("Cannot decode charset, header display may be corrupt: %s: %s",
charset, strerror (errno)));
-
+
if (!retried) {
charset = e_iconv_locale_charset ();
if (!charset)
charset = "iso-8859-1";
-
+
retried = TRUE;
goto retry;
}
-
+
/* we return the encoded word here because we've got to return valid utf8 */
decoded = g_strndup (in, inlen);
}
}
}
-
+
d(printf("decoded '%s'\n", decoded));
-
+
return decoded;
}
append_latin1 (GString *out, const char *in, size_t len)
{
unsigned int c;
-
+
while (len) {
c = (unsigned int)*in++;
len--;
char *outbase, *outbuf;
size_t outlen;
iconv_t ic;
-
+
ic = e_iconv_open ("UTF-8", charset);
if (ic == (iconv_t) -1)
return FALSE;
outlen = inlen * 6 + 16;
outbuf = outbase = g_malloc(outlen);
-
+
if (e_iconv (ic, &inbuf, &inlen, &outbuf, &outlen) == (size_t) -1) {
w(g_warning("Conversion to '%s' failed: %s", charset, strerror (errno)));
g_free(outbase);
e_iconv_close (ic);
return FALSE;
}
-
+
e_iconv (ic, NULL, NULL, &outbuf, &outlen);
-
+
*outbuf = 0;
g_string_append(out, outbase);
g_free(outbase);
e_iconv_close (ic);
return TRUE;
-
+
}
static GString *
register const char *inptr = in;
const char *inend = in + inlen;
char c;
-
+
while (inptr < inend) {
c = *inptr++;
if (c == '\\' && inptr < inend)
GString *(* append) (GString *, const char *, gssize);
char *dword = NULL;
guint32 mask;
-
+
locale_charset = e_iconv_locale_charset ();
-
+
if (ctext) {
mask = (CAMEL_MIME_IS_SPECIAL | CAMEL_MIME_IS_SPACE | CAMEL_MIME_IS_CTRL);
append = append_quoted_pair;
mask = (CAMEL_MIME_IS_LWSP);
append = g_string_append_len;
}
-
+
out = g_string_new ("");
inptr = in;
inend = inptr + inlen;
} else {
if (!chunk)
chunk = start;
-
+
if ((default_charset == NULL || !append_8bit (out, chunk, inptr-chunk, default_charset))
&& (locale_charset == NULL || !append_8bit(out, chunk, inptr-chunk, locale_charset)))
append_latin1(out, chunk, inptr-chunk);
}
-
+
chunk = NULL;
}
dword = out->str;
g_string_free (out, FALSE);
-
+
return dword;
}
return header_decode_text (in, strlen (in), TRUE, default_charset);
}
-/* how long a sequence of pre-encoded words should be less than, to attempt to
+/* how long a sequence of pre-encoded words should be less than, to attempt to
fit into a properly folded word. Only a guide. */
#define CAMEL_FOLD_PREENCODED (24)
buffer = g_alloca (bufflen);
inlen = len;
inptr = in;
-
+
ascii = g_alloca (bufflen);
-
+
if (g_ascii_strcasecmp (type, "UTF-8") != 0)
ic = e_iconv_open (type, "UTF-8");
-
+
while (inlen) {
size_t convlen, proclen;
int i;
-
+
/* break up words into smaller bits, what we really want is encoded + overhead < 75,
but we'll just guess what that means in terms of input chars, and assume its good enough */
}
inlen -= (inptr - p);
}
-
+
enclen = out-buffer;
-
+
if (enclen) {
/* create token */
out = ascii;
out += sprintf (out, "=?%s?Q?", type);
out += quoted_encode (buffer, enclen, out, safemask);
sprintf (out, "?=");
-
+
d(printf("converted part = %s\n", ascii));
-
+
g_string_append (outstring, ascii);
}
}
-
+
if (ic != (iconv_t) -1)
e_iconv_close (ic);
}
char *outstr;
g_return_val_if_fail (g_utf8_validate (in, -1, NULL), NULL);
-
+
if (in == NULL)
return NULL;
-
+
/* do a quick us-ascii check (the common case?) */
while (*inptr) {
if (*inptr > 127)
}
if (*inptr == '\0')
return g_strdup (in);
-
+
/* This gets each word out of the input, and checks to see what charset
can be used to encode it. */
/* TODO: Work out when to merge subsequent words, or across word-parts */
while (inptr && *inptr) {
gunichar c;
const char *newinptr;
-
+
newinptr = g_utf8_next_char (inptr);
c = g_utf8_get_char (inptr);
if (newinptr == NULL || !g_unichar_validate (c)) {
inptr++;
continue;
}
-
+
if (c < 256 && camel_mime_is_lwsp (c) && !last_was_space) {
/* we've reached the end of a 'word' */
if (word && !(last_was_encoded && encoding)) {
g_string_append_len (out, start, word - start);
start = word;
}
-
+
switch (encoding) {
case 0:
g_string_append_len (out, start, inptr - start);
case 1:
if (last_was_encoded)
g_string_append_c (out, ' ');
-
+
rfc2047_encode_word (out, start, inptr - start, "ISO-8859-1", CAMEL_MIME_IS_ESAFE);
last_was_encoded = TRUE;
break;
case 2:
if (last_was_encoded)
g_string_append_c (out, ' ');
-
+
if (!(charset = camel_charset_best (start, inptr - start)))
charset = "UTF-8";
rfc2047_encode_word (out, start, inptr - start, charset, CAMEL_MIME_IS_ESAFE);
last_was_encoded = TRUE;
break;
}
-
+
last_was_space = TRUE;
start = inptr;
word = NULL;
} else if (!camel_mime_is_lwsp (c)) {
last_was_space = FALSE;
}
-
+
if (!(c < 256 && camel_mime_is_lwsp (c)) && !word)
word = inptr;
-
+
inptr = newinptr;
}
-
+
if (inptr - start) {
if (word && !(last_was_encoded && encoding)) {
g_string_append_len (out, start, word - start);
start = word;
}
-
+
switch (encoding) {
case 0:
g_string_append_len (out, start, inptr - start);
case 1:
if (last_was_encoded)
g_string_append_c (out, ' ');
-
+
rfc2047_encode_word (out, start, inptr - start, "ISO-8859-1", CAMEL_MIME_IS_ESAFE);
break;
case 2:
if (last_was_encoded)
g_string_append_c (out, ' ');
-
+
if (!(charset = camel_charset_best (start, inptr - start)))
charset = "UTF-8";
rfc2047_encode_word (out, start, inptr - start, charset, CAMEL_MIME_IS_ESAFE);
break;
}
}
-
+
outstr = out->str;
g_string_free (out, FALSE);
-
+
return outstr;
}
enum _phrase_word_t type;
int encoding, count = 0;
GList *words = NULL;
-
+
/* break the input into words */
type = WORD_ATOM;
last = inptr;
while (inptr && *inptr) {
gunichar c;
const char *newinptr;
-
+
newinptr = g_utf8_next_char (inptr);
c = g_utf8_get_char (inptr);
-
+
if (!g_unichar_validate (c)) {
w(g_warning ("Invalid UTF-8 sequence encountered (pos %d, char '%c'): %s",
(inptr - in), inptr[0], in));
inptr++;
continue;
}
-
+
inptr = newinptr;
if (g_unichar_isspace (c)) {
if (count > 0) {
words = g_list_append (words, word);
count = 0;
}
-
+
start = inptr;
type = WORD_ATOM;
encoding = 0;
encoding = MAX (encoding, 2);
}
}
-
+
last = inptr;
}
-
+
if (count > 0) {
word = g_new0 (struct _phrase_word, 1);
word->start = start;
word->encoding = encoding;
words = g_list_append (words, word);
}
-
+
return words;
}
GList *wordl, *nextl, *words = *wordsp;
struct _phrase_word *word, *next;
gboolean merged = FALSE;
-
+
/* scan the list, checking for words of similar types that can be merged */
wordl = words;
while (wordl) {
word = wordl->data;
nextl = g_list_next (wordl);
-
+
while (nextl) {
next = nextl->data;
/* merge nodes of the same type AND we are not creating too long a string */
words = g_list_remove_link (words, nextl);
g_list_free_1 (nextl);
g_free (next);
-
+
nextl = g_list_next (wordl);
-
+
merged = TRUE;
} else {
/* if it is going to be too long, make sure we include the
break;
}
}
-
+
wordl = g_list_next (wordl);
}
-
+
*wordsp = words;
-
+
return merged;
}
const char *charset;
GString *out;
char *outstr;
-
+
if (in == NULL)
return NULL;
-
+
words = header_encode_phrase_get_words (in);
if (!words)
return NULL;
-
+
while (header_encode_phrase_merge_words (&words))
;
-
+
out = g_string_new ("");
-
+
/* output words now with spaces between them */
wordl = words;
while (wordl) {
const char *start;
size_t len;
-
+
word = wordl->data;
-
+
/* append correct number of spaces between words */
if (last_word && !(last_word->type == WORD_2047 && word->type == WORD_2047)) {
/* one or both of the words are not encoded so we write the spaces out untouched */
len = word->start - last_word->end;
out = g_string_append_len (out, last_word->end, len);
}
-
+
switch (word->type) {
case WORD_ATOM:
out = g_string_append_len (out, word->start, word->end - word->start);
resulting rfc2047 encoded word. */
len = word->end - last_word->end;
start = last_word->end;
-
+
/* encoded words need to be separated by linear whitespace */
g_string_append_c (out, ' ');
} else {
len = word->end - word->start;
start = word->start;
}
-
+
if (word->encoding == 1) {
rfc2047_encode_word (out, start, len, "ISO-8859-1", CAMEL_MIME_IS_PSAFE);
} else {
}
break;
}
-
+
g_free (last_word);
wordl = g_list_next (wordl);
-
+
last_word = word;
}
-
+
/* and we no longer need the list */
g_free (word);
g_list_free (words);
-
+
outstr = out->str;
g_string_free (out, FALSE);
-
+
return outstr;
}
{
const char *inptr = *in;
const char *start;
-
+
header_decode_lwsp (&inptr);
start = inptr;
while (camel_mime_is_ttoken (*inptr))
header_decode_word (const char **in)
{
const char *inptr = *in;
-
+
header_decode_lwsp (&inptr);
if (*inptr == '"') {
*in = inptr;
const unsigned char *inend = in + len;
unsigned char *inptr, *outptr;
char *outbuf;
-
+
outptr = outbuf = g_malloc (len + 1);
-
+
inptr = (unsigned char *) in;
while (inptr < inend) {
if (*inptr == '%') {
} else
*outptr++ = *inptr++;
}
-
+
*outptr = '\0';
-
+
return outbuf;
}
outlen = inlen * 6 + 16;
outbuf = outbase = g_malloc(outlen);
-
+
ret = e_iconv(ic, &in, &inlen, &outbuf, &outlen);
if (ret != (size_t) -1) {
e_iconv(ic, NULL, 0, &outbuf, &outlen);
const char *inend = in + len;
const char *charset;
char *decoded, *decword, *encoding;
-
+
inptr = memchr (inptr, '\'', len);
if (!inptr)
return NULL;
memcpy(encoding, in, inptr-in);
encoding[inptr-in] = 0;
charset = e_iconv_charset_name (encoding);
-
+
inptr = memchr (inptr + 1, '\'', inend - inptr - 1);
if (!inptr)
return NULL;
camel_header_set_param (struct _camel_header_param **l, const char *name, const char *value)
{
struct _camel_header_param *p = (struct _camel_header_param *)l, *pn;
-
+
if (name == NULL)
return NULL;
-
+
while (p->next) {
pn = p->next;
if (!g_ascii_strcasecmp (pn->name, name)) {
if (pre) {
size_t l = strlen (last);
size_t p = strlen (pre);
-
+
/* dont append ' ' between sucsessive encoded words */
if ((l>6 && last[l-2] == '?' && last[l-1] == '=')
&& (p>6 && pre[0] == '=' && pre[1] == '?')) {
inptr++;
} else {
w(g_warning("invalid route address, no closing '>': %s", *in));
- }
+ }
} else if (name == NULL && comment != NULL && inptr>comment) { /* check for comment after address */
char *text, *tmp;
const char *comstart, *comend;
comend = inptr-1;
while (comend > comstart && comend[0] != ')')
comend--;
-
+
if (comend > comstart) {
d(printf(" looking at subset '%.*s'\n", comend-comstart, comstart));
tmp = g_strndup (comstart, comend-comstart);
}
}
}
-
+
*in = inptr;
-
+
if (addr->len > 0) {
if (!g_utf8_validate (addr->str, addr->len, NULL)) {
/* workaround for invalid addr-specs containing 8bit chars (see bug #42170 for details) */
const char *locale_charset;
GString *out;
-
+
locale_charset = e_iconv_locale_charset ();
-
+
out = g_string_new ("");
-
+
if ((charset == NULL || !append_8bit (out, addr->str, addr->len, charset))
&& (locale_charset == NULL || !append_8bit (out, addr->str, addr->len, locale_charset)))
append_latin1 (out, addr->str, addr->len);
-
+
g_string_free (addr, TRUE);
addr = out;
}
-
+
address = camel_header_address_new_name(name ? name->str : "", addr->str);
}
-
+
d(printf("got mailbox: %s\n", addr->str));
-
+
g_string_free(addr, TRUE);
if (name)
g_string_free(name, TRUE);
-
+
return address;
}
gboolean at = FALSE;
GString *addr;
char *buf;
-
+
d(printf("decoding Content-ID: '%s'\n", in));
-
+
header_decode_lwsp (&inptr);
-
+
/* some lame mailers quote the Content-Id */
if (*inptr == '"')
inptr++;
-
+
/* make sure the content-id is not "" which can happen if we get a
* content-id such as <.@> (which Eudora likes to use...) */
if ((buf = camel_header_msgid_decode (inptr)) != NULL && *buf)
return buf;
-
+
g_free (buf);
-
+
/* ugh, not a valid msg-id - try to get something useful out of it then? */
inptr = in;
header_decode_lwsp (&inptr);
inptr++;
header_decode_lwsp (&inptr);
}
-
+
/* Eudora has been known to use <.@> as a content-id */
if (!(buf = header_decode_word (&inptr)) && !strchr (".@", *inptr))
return NULL;
-
+
addr = g_string_new ("");
header_decode_lwsp (&inptr);
while (buf != NULL || *inptr == '.' || (*inptr == '@' && !at)) {
g_free (buf);
buf = NULL;
}
-
+
if (!at) {
if (*inptr == '.') {
g_string_append_c (addr, *inptr++);
g_string_append_c (addr, *inptr++);
buf = header_decode_atom (&inptr);
}
-
+
header_decode_lwsp (&inptr);
}
-
+
buf = addr->str;
g_string_free (addr, FALSE);
-
+
return buf;
}
struct _camel_header_references *ref;
const char *inptr = *in;
char *id, *word;
-
+
while (*inptr) {
header_decode_lwsp (&inptr);
if (*inptr == '<') {
inptr++; /* Stupid mailer tricks */
}
}
-
+
*in = inptr;
}
camel_header_references_inreplyto_decode (const char *in)
{
struct _camel_header_references *ref = NULL;
-
+
if (in == NULL || in[0] == '\0')
return NULL;
-
+
header_references_decode_single (&in, &ref);
-
+
return ref;
}
camel_header_references_decode (const char *in)
{
struct _camel_header_references *refs = NULL;
-
+
if (in == NULL || in[0] == '\0')
return NULL;
-
+
while (*in)
header_references_decode_single (&in, &refs);
-
+
return refs;
}
{
if (encoding >= sizeof (encodings) / sizeof (encodings[0]))
encoding = 0;
-
+
return encodings[encoding];
}
camel_transfer_encoding_from_string (const char *string)
{
int i;
-
+
if (string != NULL) {
for (i = 0; i < sizeof (encodings) / sizeof (encodings[0]); i++)
if (!g_ascii_strcasecmp (string, encodings[i]))
return i;
}
-
+
return CAMEL_TRANSFER_ENCODING_DEFAULT;
}
else if (a->index < b->index)
res = -1;
}
-
+
return res;
}
g_free(value);
} else if (g_ascii_strcasecmp (name, "boundary") != 0 && !g_utf8_validate(value, -1, NULL)) {
const char *charset = e_iconv_locale_charset();
-
+
if ((node->value = header_convert("UTF-8", charset?charset:"ISO-8859-1", value, strlen(value)))) {
g_free(value);
} else {
GString *out;
guint32 c;
char *str;
-
+
*encoded = FALSE;
-
+
g_return_val_if_fail (in != NULL, NULL);
/* if we have really broken utf8 passed in, we just treat it as binary data */
charset = camel_charset_best(in, strlen(in));
if (charset == NULL)
return g_strdup(in);
-
+
if (g_ascii_strcasecmp(charset, "UTF-8") != 0) {
if ((outbuf = header_convert(charset, "UTF-8", in, strlen(in))))
inptr = outbuf;
else
return g_strdup(in);
}
-
+
/* FIXME: set the 'language' as well, assuming we can get that info...? */
out = g_string_new (charset);
g_string_append(out, "''");
g_string_append_printf (out, "%%%c%c", tohex[(c >> 4) & 0xf], tohex[c & 0xf]);
}
g_free (outbuf);
-
+
str = out->str;
g_string_free (out, FALSE);
*encoded = TRUE;
-
+
return str;
}
camel_header_param_list_format_append (GString *out, struct _camel_header_param *p)
{
int used = out->len;
-
+
while (p) {
gboolean encoded = FALSE;
gboolean quote = FALSE;
int here = out->len;
size_t nlen, vlen;
char *value;
-
+
if (!p->value) {
p = p->next;
continue;
}
-
+
value = header_encode_param (p->value, &encoded);
if (!value) {
w(g_warning ("appending parameter %s=%s violates rfc2184", p->name, p->value));
value = g_strdup (p->value);
}
-
+
if (!encoded) {
char *ch;
-
+
for (ch = value; *ch; ch++) {
if (camel_mime_is_tspecial (*ch) || camel_mime_is_lwsp (*ch))
break;
}
-
+
quote = ch && *ch;
}
-
+
nlen = strlen (p->name);
vlen = strlen (value);
-
+
if (used + nlen + vlen > CAMEL_FOLD_SIZE - 8) {
out = g_string_append (out, ";\n\t");
here = out->len;
used = 0;
} else
out = g_string_append (out, "; ");
-
+
if (nlen + vlen > CAMEL_FOLD_SIZE - 8) {
/* we need to do special rfc2184 parameter wrapping */
int maxlen = CAMEL_FOLD_SIZE - (nlen + 8);
char *inptr, *inend;
int i = 0;
-
+
inptr = value;
inend = value + vlen;
-
+
while (inptr < inend) {
char *ptr = inptr + MIN (inend - inptr, maxlen);
-
+
if (encoded && ptr < inend) {
/* be careful not to break an encoded char (ie %20) */
char *q = ptr;
int j = 2;
-
+
for ( ; j > 0 && q > inptr && *q != '%'; j--, q--);
if (*q == '%')
ptr = q;
}
-
+
if (i != 0) {
g_string_append (out, ";\n\t");
here = out->len;
used = 0;
}
-
+
g_string_append_printf (out, "%s*%d%s=", p->name, i++, encoded ? "*" : "");
if (encoded || !quote)
g_string_append_len (out, inptr, ptr - inptr);
else
quote_word (out, TRUE, inptr, ptr - inptr);
-
+
d(printf ("wrote: %s\n", out->str + here));
-
+
used += (out->len - here);
-
+
inptr = ptr;
}
} else {
g_string_append_printf (out, "%s%s=", p->name, encoded ? "*" : "");
-
+
if (encoded || !quote)
g_string_append (out, value);
else
quote_word (out, TRUE, value, vlen);
-
+
used += (out->len - here);
}
-
+
g_free (value);
-
+
p = p->next;
}
}
{
GString *out;
char *ret;
-
+
if (ct == NULL)
return NULL;
-
+
out = g_string_new ("");
if (ct->type == NULL) {
g_string_append_printf (out, "text/plain");
g_string_append_printf (out, "%s/%s", ct->type, ct->subtype);
}
camel_header_param_list_format_append (out, ct->params);
-
+
ret = out->str;
g_string_free (out, FALSE);
-
+
return ret;
}
{
if (in)
return decode_token (&in);
-
+
return NULL;
}
time += ((offset / 100) * (60*60)) + (offset % 100)*60;
d(printf("converting date %s", ctime(&time)));
-
+
gmtime_r (&time, &tm);
-
+
return g_strdup_printf("%s, %02d %s %04d %02d:%02d:%02d %+05d",
tz_days[tm.tm_wday],
tm.tm_mday, tz_months[tm.tm_mon],
camel_header_to_decode(value);
} else if (!g_ascii_strcasecmp(name, "Content-type")) {
printf("- Decoding content-type\n");
- camel_content_type_dump(camel_content_type_decode(value));
+ camel_content_type_dump(camel_content_type_decode(value));
} else if (!g_ascii_strcasecmp(name, "MIME-Version")) {
printf("- Decoding mime version\n");
camel_header_mime_decode(value);
name = host;
} else
name = "localhost.localdomain";
-
+
COUNT_LOCK ();
msgid = g_strdup_printf ("%d.%d.%d.camel@%s", (int) time (NULL), getpid (), count++, name);
COUNT_UNLOCK ();
-
+
if (ai)
camel_freeaddrinfo(ai);
-
+
return msgid;
}
{ "X-Loop", "[ \t]*([^@]+)@?([^ \n\t\r>]*)" },
/* X-List: gnome-hackers */
/* X-List: gnome-hackers@gnome.org */
- { "X-List", "[ \t]*([^@]+)@?([^ \n\t\r>]*)" },
+ { "X-List", "[ \t]*([^@]+)@?([^ \n\t\r>]*)" },
/* Sender: owner-gnome-hackers@gnome.org */
/* Sender: owner-gnome-hacekrs */
{ "Sender", "[ \t]*owner-([^@]+)@?([^ @\n\t\r>]*)" },
if (errcode != 0) {
char *errstr;
size_t len;
-
+
len = regerror(errcode, &mail_list_magic[i].regex, NULL, 0);
errstr = g_malloc0(len + 1);
regerror(errcode, &mail_list_magic[i].regex, errstr, len);
-
+
g_warning("Internal error, compiling regex failed: %s: %s", mail_list_magic[i].pattern, errstr);
g_free(errstr);
failed++;
if (v != NULL && regexec (&mail_list_magic[i].regex, v, 3, match, 0) == 0 && match[1].rm_so != -1) {
int len1, len2;
char *mlist;
-
+
len1 = match[1].rm_eo - match[1].rm_so;
len2 = match[2].rm_eo - match[2].rm_so;
-
+
mlist = g_malloc (len1 + len2 + 2);
memcpy (mlist, v + match[1].rm_so, len1);
if (len2) {
} else {
mlist[len1] = '\0';
}
-
+
return mlist;
}
}
|| h->type == CAMEL_HEADER_ADDRESS_NONE) {
h->type = CAMEL_HEADER_ADDRESS_GROUP;
camel_header_address_list_append(&h->v.members, member);
- }
+ }
}
}
header_address_list_encode_append (GString *out, int encode, struct _camel_header_address *a)
{
char *text;
-
+
while (a) {
switch (a->type) {
case CAMEL_HEADER_ADDRESS_NAME:
{
GString *out;
char *ret;
-
+
if (a == NULL)
return NULL;
-
+
out = g_string_new ("");
header_address_list_encode_append (out, TRUE, a);
ret = out->str;
g_string_free (out, FALSE);
-
+
return ret;
}
{
GString *out;
char *ret;
-
+
if (a == NULL)
return NULL;
-
+
out = g_string_new ("");
-
+
header_address_list_encode_append (out, FALSE, a);
ret = out->str;
g_string_free (out, FALSE);
-
+
return ret;
}
GString *out;
char *ret;
int i, needunfold = FALSE;
-
+
if (in == NULL)
return NULL;
-
+
/* first, check to see if we even need to fold */
len = headerlen + 2;
p = in;
len += strlen (p);
break;
}
-
+
needunfold = TRUE;
len += n-p;
-
+
if (len >= CAMEL_FOLD_SIZE)
break;
len = 0;
}
if (len < CAMEL_FOLD_SIZE)
return g_strdup (in);
-
+
/* we need to fold, so first unfold (if we need to), then process */
if (needunfold)
inptr = in = camel_header_unfold (in);
-
+
out = g_string_new ("");
outlen = headerlen + 2;
while (*inptr) {
} else {
len = strlen (inptr);
}
-
+
d(printf("next word '%.*s'\n", len, inptr));
-
+
if (outlen + len > CAMEL_FOLD_SIZE) {
d(printf("outlen = %d wordlen = %d\n", outlen, len));
/* strip trailing space */
g_string_append (out, "\n\t");
outlen = 1;
}
-
+
outlen += len;
for (i = 0; i < len; i++) {
g_string_append_c (out, inptr[i]);
}
-
+
inptr += len;
}
ret = out->str;
g_string_free (out, FALSE);
-
+
if (needunfold)
g_free ((char *)in);
-
- return ret;
+
+ return ret;
}
/* simple header folding */
needunfold = TRUE;
len += n-p;
-
+
if (len >= CAMEL_FOLD_SIZE)
break;
len = 0;
if (needunfold)
g_free((char *)in);
- return ret;
+ return ret;
}
char *
iv[0].iov_len = strlen(header->name);
iv[2].iov_base = header->value;
iv[2].iov_len = strlen(header->value);
-
+
do {
len = writev(fd, iv, 4);
} while (len == -1 && errno == EINTR);
-
+
if (len == -1)
return -1;
outlen += len;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-movemail.h: mbox copy function */
-/*
- * Author:
+/*
+ * Author:
* Dan Winship <danw@ximian.com>
*
* Copyright 2000 Ximian, Inc. (www.ximian.com)
camel_multipart_encrypted_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_multipart_get_type (),
"CamelMultipartEncrypted",
(CamelObjectInitFunc) camel_multipart_encrypted_init,
(CamelObjectFinalizeFunc) camel_multipart_encrypted_finalize);
}
-
+
return type;
}
camel_multipart_encrypted_class_init (CamelMultipartEncryptedClass *klass)
{
CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (klass);
-
+
parent_class = (CamelMultipartClass *) camel_multipart_get_type ();
-
+
/* virtual method overload */
camel_data_wrapper_class->set_mime_type_field = set_mime_type_field;
}
camel_multipart_encrypted_init (gpointer object, gpointer klass)
{
CamelMultipartEncrypted *multipart = (CamelMultipartEncrypted *) object;
-
+
camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart), "multipart/encrypted");
-
+
multipart->decrypted = NULL;
}
camel_multipart_encrypted_finalize (CamelObject *object)
{
CamelMultipartEncrypted *mpe = (CamelMultipartEncrypted *) object;
-
+
g_free (mpe->protocol);
-
+
if (mpe->decrypted)
camel_object_unref (mpe->decrypted);
}
set_mime_type_field (CamelDataWrapper *data_wrapper, CamelContentType *mime_type)
{
CamelMultipartEncrypted *mpe = (CamelMultipartEncrypted *) data_wrapper;
-
+
if (mime_type) {
const char *protocol;
-
+
protocol = camel_content_type_param (mime_type, "protocol");
g_free (mpe->protocol);
mpe->protocol = g_strdup (protocol);
}
-
+
((CamelDataWrapperClass *) parent_class)->set_mime_type_field (data_wrapper, mime_type);
}
camel_multipart_encrypted_new (void)
{
CamelMultipartEncrypted *multipart;
-
+
multipart = (CamelMultipartEncrypted *) camel_object_new (CAMEL_MULTIPART_ENCRYPTED_TYPE);
-
+
return multipart;
}
struct _CamelMultipartEncrypted {
CamelMultipart parent_object;
-
+
CamelMimePart *version;
CamelMimePart *content;
CamelMimePart *decrypted;
-
+
char *protocol;
};
struct _CamelMultipartEncryptedClass {
CamelMultipartClass parent_class;
-
+
};
CamelType camel_multipart_encrypted_get_type (void);
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- * camel-multipart.c : Abstract class for a multipart
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * camel-multipart.c : Abstract class for a multipart
*
* Authors: Michael Zucchi <notzed@ximian.com>
*
if (state == CAMEL_MIME_PARSER_STATE_MULTIPART_END) {
mps->end2 = camel_mime_parser_tell_start_boundary(cmp);
-
+
camel_multipart_set_preface(mp, camel_mime_parser_preface(cmp));
camel_multipart_set_postface(mp, camel_mime_parser_postface(cmp));
}
const char *boundary;
ssize_t total = 0;
ssize_t count;
-
+
/* we have 3 basic cases:
1. constructed, we write out the data wrapper stream we got
2. signed content, we create and write out a new stream
if (count == -1)
return -1;
total += count;
-
+
/* boundary */
count = camel_stream_printf(stream, "\n--%s\n", boundary);
if (count == -1)
total += count;
}
- return total;
+ return total;
}
sub = camel_seekable_substream_new((CamelSeekableStream *)((CamelDataWrapper *)mps)->stream, mps->start1, mps->end1);
constream = (CamelStream *)camel_stream_filter_new_with_stream(sub);
camel_object_unref((CamelObject *)sub);
-
+
/* Note: see rfc2015 or rfc3156, section 5 */
canon_filter = camel_mime_filter_canon_new (CAMEL_MIME_FILTER_CANON_CRLF);
camel_stream_filter_add((CamelStreamFilter *)constream, (CamelMimeFilter *)canon_filter);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- * camel-signed--multipart.h : class for a signed-multipart
+ * camel-signed--multipart.h : class for a signed-multipart
*
* Authors: Michael Zucchi <notzed@ximian.com>
*
/* get the bundary text */
boundary = camel_multipart_get_boundary (multipart);
-
+
/* we cannot write a multipart without a boundary string */
g_return_val_if_fail (boundary, -1);
-
+
/*
* write the preface text (usually something like
* "This is a mime message, if you see this, then
* camel_multipart_set_preface:
* @multipart: a #CamelMultipart object
* @preface: the multipart preface
- *
+ *
* Set the preface text for this multipart. Will be written out infront
* of the multipart. This text should only include US-ASCII strings, and
* be relatively short, and will be ignored by any MIME mail client.
* camel_multipart_set_postface:
* @multipart: a #CamelMultipart object
* @postface: multipat postface
- *
+ *
* Set the postfix text for this multipart. Will be written out after
* the last boundary of the multipart, and ignored by any MIME mail
* client.
CamelMimePart *bodypart;
char *buf;
size_t len;
-
+
g_assert(camel_mime_parser_state(mp) == CAMEL_MIME_PARSER_STATE_MULTIPART);
-
+
/* FIXME: we should use a came-mime-mutlipart, not jsut a camel-multipart, but who cares */
d(printf("Creating multi-part\n"));
-
+
content_type = camel_mime_parser_content_type(mp);
camel_multipart_set_boundary(multipart,
camel_content_type_param(content_type, "boundary"));
-
+
while (camel_mime_parser_step(mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_MULTIPART_END) {
camel_mime_parser_unstep(mp);
bodypart = camel_mime_part_new();
camel_multipart_add_part(multipart, bodypart);
camel_object_unref((CamelObject *)bodypart);
}
-
+
/* these are only return valid data in the MULTIPART_END state */
camel_multipart_set_preface(multipart, camel_mime_parser_preface (mp));
camel_multipart_set_postface(multipart, camel_mime_parser_postface (mp));
-
+
err = camel_mime_parser_errno(mp);
if (err != 0) {
errno = err;
*
* Copyright (C) 2004 Ximian Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
struct addrinfo hints, *res;
int retval, len;
char *addr;
-
+
memset (&hints, 0, sizeof (struct addrinfo));
#ifdef HAVE_AI_ADDRCONFIG
hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
-
+
if ((retval = getaddrinfo (name, NULL, &hints, &res)) != 0) {
*herr = ai_to_herr (retval);
return -1;
}
-
+
len = ALIGN (strlen (res->ai_canonname) + 1);
if (buflen < IPv6_BUFLEN_MIN + len + res->ai_addrlen + sizeof (char *))
return ERANGE;
-
+
/* h_name */
strcpy (buf, res->ai_canonname);
host->h_name = buf;
buf += len;
-
+
/* h_aliases */
((char **) buf)[0] = NULL;
host->h_aliases = (char **) buf;
buf += sizeof (char *);
-
+
/* h_addrtype and h_length */
host->h_length = res->ai_addrlen;
if (res->ai_family == PF_INET6) {
host->h_addrtype = AF_INET6;
-
+
addr = (char *) &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
} else {
host->h_addrtype = AF_INET;
-
+
addr = (char *) &((struct sockaddr_in *) res->ai_addr)->sin_addr;
}
-
+
memcpy (buf, addr, host->h_length);
addr = buf;
buf += ALIGN (host->h_length);
-
+
/* h_addr_list */
((char **) buf)[0] = addr;
((char **) buf)[1] = NULL;
host->h_addr_list = (char **) buf;
-
+
freeaddrinfo (res);
-
+
return 0;
#else /* No support for IPv6 addresses */
#ifdef HAVE_GETHOSTBYNAME_R
#else
struct hostent *hp;
int retval;
-
+
retval = gethostbyname_r (name, host, buf, buflen, &hp, herr);
if (hp != NULL) {
*herr = 0;
*/
retval = -1;
}
-
+
return retval;
#endif
#else /* No support for gethostbyname_r */
struct hostent *h;
-
+
G_LOCK (gethost_mutex);
-
+
h = gethostbyname (name);
-
+
if (!h) {
*herr = h_errno;
G_UNLOCK (gethost_mutex);
return -1;
}
-
+
GETHOST_PROCESS (h, host, buf, buflen, herr);
-
+
G_UNLOCK (gethost_mutex);
-
+
return 0;
#endif /* HAVE_GETHOSTBYNAME_R */
#endif /* ENABLE_IPv6 */
{
#ifdef ENABLE_IPv6
int retval, len;
-
+
if ((retval = getnameinfo (addr, addrlen, buf, buflen, NULL, 0, NI_NAMEREQD)) != 0) {
*herr = ai_to_herr (retval);
return -1;
}
-
+
len = ALIGN (strlen (buf) + 1);
if (buflen < IPv6_BUFLEN_MIN + len + addrlen + sizeof (char *))
return ERANGE;
-
+
/* h_name */
host->h_name = buf;
buf += len;
-
+
/* h_aliases */
((char **) buf)[0] = NULL;
host->h_aliases = (char **) buf;
buf += sizeof (char *);
-
+
/* h_addrtype and h_length */
host->h_length = addrlen;
host->h_addrtype = type;
-
+
memcpy (buf, addr, host->h_length);
addr = buf;
buf += ALIGN (host->h_length);
-
+
/* h_addr_list */
((char **) buf)[0] = addr;
((char **) buf)[1] = NULL;
host->h_addr_list = (char **) buf;
-
+
return 0;
#else /* No support for IPv6 addresses */
#ifdef HAVE_GETHOSTBYADDR_R
#else
struct hostent *hp;
int retval;
-
+
retval = gethostbyaddr_r (addr, addrlen, type, host, buf, buflen, &hp, herr);
if (hp != NULL) {
*herr = 0;
*/
retval = -1;
}
-
+
return retval;
#endif
#else /* No support for gethostbyaddr_r */
struct hostent *h;
-
+
G_LOCK (gethost_mutex);
-
+
h = gethostbyaddr (addr, addrlen, type);
-
+
if (!h) {
*herr = h_errno;
G_UNLOCK (gethost_mutex);
return -1;
}
-
+
GETHOST_PROCESS (h, host, buf, buflen, herr);
-
+
G_UNLOCK (gethost_mutex);
-
+
return 0;
#endif /* HAVE_GETHOSTBYADDR_R */
#endif /* ENABLE_IPv6 */
worker(msg);
return 0;
}
-
+
reply_port = msg->msg.reply_port = e_msgport_new();
fd = e_msgport_fd(msg->msg.reply_port);
if ((err = pthread_create(&id, NULL, worker, msg)) == 0) {
);
else
camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
-
+
/* We cancel so if the thread impl is decent it causes immediate exit.
We detach so we dont need to wait for it to exit if it isn't.
We check the reply port incase we had a reply in the mean time, which we free later */
msg->hostbuflen *= 2;
msg->hostbufmem = g_realloc(msg->hostbufmem, msg->hostbuflen);
}
-
+
/* If we got cancelled, dont reply, just free it */
if (msg->cancelled)
goto cancel;
struct _addrinfo_msg *info = data;
info->result = getaddrinfo(info->name, info->service, info->hints, info->res);
-
+
if (info->cancelled) {
cs_freeinfo(info);
} else {
e_msgport_reply((EMsg *)info);
}
-
+
return NULL;
}
#endif /* NEED_ADDRINFO */
struct addrinfo myhints;
#endif
g_return_val_if_fail(name != NULL, NULL);
-
+
if (camel_operation_cancel_check(NULL)) {
camel_exception_set(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
return NULL;
memset(&myhints, 0, sizeof(myhints));
else
memcpy (&myhints, hints, sizeof (myhints));
-
+
myhints.ai_family = AF_INET;
hints = &myhints;
#endif
#ifdef NEED_ADDRINFO
msg->hostbuflen = 1024;
msg->hostbufmem = g_malloc(msg->hostbuflen);
-#endif
+#endif
if (cs_waitinfo(cs_getaddrinfo, msg, _("Host lookup failed"), ex) == 0) {
if (msg->result != 0)
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Host lookup failed: %s: %s"),
name, gai_strerror (msg->result));
-
+
cs_freeinfo(msg);
} else
res = NULL;
-
+
camel_operation_end(NULL);
return res;
msg->hostbuflen *= 2;
msg->hostbufmem = g_realloc(msg->hostbufmem, msg->hostbuflen);
}
-
+
if (msg->cancelled)
goto cancel;
msg->host = g_strdup(h.h_name);
} else {
unsigned char *in = (unsigned char *)&sin->sin_addr;
-
+
/* sin_addr is always network order which is big-endian */
msg->host = g_strdup_printf("%u.%u.%u.%u", in[0], in[1], in[2], in[3]);
}
/* there doens't appear to be a return code which says host or serv buffers are too short, lengthen them */
msg->result = getnameinfo(msg->addr, msg->addrlen, msg->host, msg->hostlen, msg->serv, msg->servlen, msg->flags);
-
+
if (msg->cancelled)
cs_freeinfo(msg);
else
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
+ *
* Authors: Michael Zucchi <notzed@ximian.com>
* Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright (C) 2004 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
camel_news_address_get_type (void)
{
static guint type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_address_get_type (), "CamelNewsAddress",
sizeof (CamelNewsAddress),
NULL,
NULL);
}
-
+
return type;
}
* camel_news_address_new:
*
* Create a new CamelNewsAddress object.
- *
+ *
* Return value: A new CamelNewsAddress widget.
**/
CamelNewsAddress *
camel_nntp_address_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_address_get_type(), "CamelNNTPAddress",
sizeof (CamelNNTPAddress),
(CamelObjectInitFunc) camel_nntp_address_init,
NULL);
}
-
+
return type;
}
camel_nntp_address_add((CamelNNTPAddress *)a, n->newsgroup);
camel_header_newsgroups_free(ha);
}
-
+
return a->addresses->len - count;
}
int i;
GString *out;
char *ret;
-
+
if (a->addresses->len == 0)
return NULL;
-
+
out = g_string_new("");
-
+
for (i = 0;i < a->addresses->len; i++) {
if (i != 0)
g_string_append(out, ", ");
g_string_append(out, g_ptr_array_index(a->addresses, i));
}
-
+
ret = out->str;
g_string_free(out, FALSE);
-
+
return ret;
}
{
if (index < 0 || index >= a->addresses->len)
return;
-
+
g_free(g_ptr_array_index(a->addresses, index));
g_ptr_array_remove_index(a->addresses, index);
}
* camel_nntp_address_new:
*
* Create a new CamelNNTPAddress object.
- *
+ *
* Return value: A new CamelNNTPAddress object.
**/
CamelNNTPAddress *
/**
* camel_nntp_address_add:
* @a: nntp address object
- * @name:
- *
+ * @name:
+ *
* Add a new nntp address to the address object. Duplicates are not added twice.
- *
+ *
* Return value: Index of added entry, or existing matching entry.
**/
int
* @a: nntp address object
* @index: address's array index
* @addressp: Holder for the returned address, or NULL, if not required.
- *
+ *
* Get the address at @index.
- *
+ *
* Return value: TRUE if such an address exists, or FALSE otherwise.
**/
gboolean
}
camel_object_unget_hooks(obj);
}
-
+
return res;
}
for (i=0;i<count;i++) {
char *name = NULL, *value = NULL;
-
+
if (camel_file_util_decode_string(fp, &name) == 0
&& camel_file_util_decode_string(fp, &value) == 0) {
camel_object_meta_set(obj, name, value);
}
count = MIN(count, CAMEL_ARGV_MAX);
-
+
/* we batch up the properties and set them in one go */
argv = g_try_malloc(sizeof(CamelArgV) -
((CAMEL_ARGV_MAX - count) * sizeof(CamelArg)));
if (argv == NULL)
return -1;
-
+
argv->argc = 0;
for (i=0;i<count;i++) {
if (camel_file_util_decode_uint32(fp, &argv->argv[argv->argc].tag) == -1)
0, sizeof(CamelInterface),
cinterface_class_init, cinterface_class_finalise,
cinterface_init, NULL);
-
+
}
return camel_object_type;
klass->object_size = object_size;
klass->lock = g_mutex_new();
klass->instance_chunks = e_memchunk_new(8, object_size);
-
+
klass->parent = parent;
if (parent) {
klass->next = parent->child;
CamelHookList *hooks = NULL;
g_return_if_fail(CAMEL_IS_OBJECT(o));
-
+
klass = o->klass;
if (o->hooks)
what = g_strdup_printf("finalised CLASS");
else if (o->magic == CAMEL_INTERFACE_FINALISED_MAGIC)
what = g_strdup_printf("finalised INTERFACE");
- else
+ else
what = g_strdup_printf("junk data");
return what;
what = g_strdup_printf("OBJECT '%s'", ((CamelObject *)o)->klass->name);
else
what = g_strdup_printf("OBJECT '%s'", ((CamelObjectClass *)o)->name);
- }
+ }
if (to == NULL)
to = g_strdup_printf("OBJECT '%s'", ctype->name);
g_warning("Trying to check %s is %s", what, to);
}
pthread_mutex_unlock(&lock);
}
-
+
g_static_rec_mutex_lock(&o->hooks->lock);
-
- return o->hooks;
+
+ return o->hooks;
}
unsigned int
pair = co_find_pair_ptr(obj->klass, interface_name);
if (pair) {
GPtrArray *interfaces = pair->data;
-
+
for (i=0;i<interfaces->len;i++) {
hook = co_find_pair(interfaces->pdata[i], name);
if (hook)
/* lock the object for hook emission */
camel_object_ref(obj);
hooks = camel_object_get_hooks(obj);
-
+
if (hooks->list) {
/* first, copy the items in the list, and say we're in an event */
hooks->depth++;
/**
* camel_object_meta_get:
- * @vo:
- * @name:
- *
+ * @vo:
+ * @name:
+ *
* Get a meta-data on an object.
- *
+ *
* Return value: NULL if the meta-data is not set.
**/
char *
/**
* camel_object_meta_set:
- * @vo:
+ * @vo:
* @name: Name of meta-data. Should be prefixed with class of setter.
* @value: Value to set. If NULL, then the meta-data is removed.
- *
+ *
* Set a meta-data item on an object. If the object supports persistent
* data, then the meta-data will be persistent across sessions.
*
/**
* camel_object_state_read:
- * @vo:
- *
+ * @vo:
+ *
* Read persistent object state from object_set(CAMEL_OBJECT_STATE_FILE).
- *
+ *
* Return value: -1 on error.
**/
int camel_object_state_read(void *vo)
/**
* camel_object_state_write:
- * @vo:
- *
+ * @vo:
+ *
* Write persistent state to the file as set by object_set(CAMEL_OBJECT_STATE_FILE).
- *
+ *
* Return value: -1 on error.
**/
int camel_object_state_write(void *vo)
Add a 'const' bit to the arg type field,
specifying that the object should not be freed.
-
+
And, add free handlers for any pointer objects which are
not const. The free handlers would be hookpairs off of the
class.
/**
* camel_object_bag_new:
- * @hash:
- * @equal:
- * @keycopy:
- * @keyfree:
- *
+ * @hash:
+ * @equal:
+ * @keycopy:
+ * @keyfree:
+ *
* Allocate a new object bag. Object bag's are key'd hash tables of
* camel-objects which can be updated atomically using transaction
* semantics.
- *
- * Return value:
+ *
+ * Return value:
**/
CamelObjectBag *
camel_object_bag_new(GHashFunc hash, GEqualFunc equal, CamelCopyFunc keycopy, GFreeFunc keyfree)
g_hash_table_foreach(bag->object_table, (GHFunc)save_object, objects);
for (i=0;i<objects->len;i++)
camel_object_bag_remove(bag, objects->pdata[i]);
-
+
g_ptr_array_free(objects, TRUE);
g_hash_table_destroy(bag->object_table);
g_hash_table_destroy(bag->key_table);
/**
* camel_object_bag_add:
- * @bag:
- * @key:
- * @vo:
- *
+ * @bag:
+ * @key:
+ * @vo:
+ *
* Add an object @vo to the object bag @bag. The @key MUST have
* previously been reserved using camel_object_bag_reserve().
**/
g_hash_table_insert(bag->key_table, vo, k);
co_bag_unreserve(bag, key);
-
+
REF_UNLOCK();
camel_object_unget_hooks(o);
}
/**
* camel_object_bag_get:
- * @bag:
- * @key:
- *
+ * @bag:
+ * @key:
+ *
* Lookup an object by @key. If the key is currently reserved, then
* wait until the key has been committed before continuing.
- *
+ *
* Return value: NULL if the object corresponding to @key is not
* in the bag. Otherwise a ref'd object pointer which the caller owns
* the ref to.
co_bag_unreserve(bag, key);
}
}
-
+
REF_UNLOCK();
-
+
return o;
}
/**
* camel_object_bag_peek:
- * @bag:
- * @key:
- *
+ * @bag:
+ * @key:
+ *
* Lookup the object @key in @bag, ignoring any reservations. If it
* isn't committed, then it isn't considered. This should only be
* used where reliable transactional-based state is not required.
- *
+ *
* Unlike other 'peek' operations, the object is still reffed if
* found.
*
/**
* camel_object_bag_reserve:
- * @bag:
- * @key:
- *
+ * @bag:
+ * @key:
+ *
* Reserve a key in the object bag. If the key is already reserved in
* another thread, then wait until the reservation has been committed.
*
*
* You may reserve multiple keys from the same thread, but they should
* always be reserved in the same order, to avoid deadlocks.
- *
- * Return value:
+ *
+ * Return value:
**/
void *
camel_object_bag_reserve(CamelObjectBag *bag, const void *key)
bag->reserved = res;
}
}
-
+
REF_UNLOCK();
return o;
/**
* camel_object_bag_abort:
- * @bag:
- * @key:
- *
+ * @bag:
+ * @key:
+ *
* Abort a key reservation.
**/
void
/**
* camel_object_bag_rekey:
- * @bag:
- * @o:
- * @newkey:
- *
+ * @bag:
+ * @o:
+ * @newkey:
+ *
* Re-key an object, atomically. The key for object @o is set to
* @newkey, in an atomic manner.
*
REF_LOCK();
camel_object_bag_remove_unlocked(inbag, o, hooks);
-
+
REF_UNLOCK();
camel_object_unget_hooks(o);
}
{
g_assert(it);
g_return_val_if_fail(((CamelIterator *)it)->klass->length != NULL, 0);
-
+
return ((CamelIterator *)it)->klass->length(it);
}
camel_offline_folder_get_type (void)
{
static CamelType type = NULL;
-
+
if (!type) {
type = camel_type_register (CAMEL_FOLDER_TYPE,
"CamelOfflineFolder",
(CamelObjectInitFunc) camel_offline_folder_init,
(CamelObjectFinalizeFunc) camel_offline_folder_finalize);
}
-
+
return type;
}
camel_offline_folder_class_init (CamelOfflineFolderClass *klass)
{
int i;
-
+
parent_class = (CamelFolderClass *) camel_type_get_global_classfuncs (CAMEL_FOLDER_TYPE);
-
+
if (offline_folder_props == NULL) {
for (i = 0; i < G_N_ELEMENTS (offline_prop_list); i++) {
offline_prop_list[i].description = _(offline_prop_list[i].description);
offline_folder_props = g_slist_prepend (offline_folder_props, &offline_prop_list[i]);
}
}
-
+
((CamelObjectClass *) klass)->getv = offline_folder_getv;
((CamelObjectClass *) klass)->setv = offline_folder_setv;
-
+
klass->downsync = offline_folder_downsync;
}
struct _offline_downsync_msg {
CamelSessionThreadMsg msg;
-
+
CamelFolder *folder;
CamelFolderChangeInfo *changes;
};
struct _offline_downsync_msg *m = (struct _offline_downsync_msg *) mm;
CamelMimeMessage *message;
int i;
-
+
camel_operation_start (NULL, _("Downloading new messages for offline mode"));
-
+
if (m->changes) {
for (i = 0; i < m->changes->uid_added->len; i++) {
int pc = i * 100 / m->changes->uid_added->len;
-
+
camel_operation_progress (NULL, pc);
if ((message = camel_folder_get_message (m->folder, m->changes->uid_added->pdata[i], &mm->ex)))
camel_object_unref (message);
} else {
camel_offline_folder_downsync ((CamelOfflineFolder *) m->folder, "(match-all)", &mm->ex);
}
-
+
camel_operation_end (NULL);
}
offline_downsync_free (CamelSession *session, CamelSessionThreadMsg *mm)
{
struct _offline_downsync_msg *m = (struct _offline_downsync_msg *) mm;
-
+
if (m->changes)
camel_folder_change_info_free (m->changes);
-
+
camel_object_unref (m->folder);
}
{
CamelOfflineFolder *offline = (CamelOfflineFolder *) folder;
CamelService *service = (CamelService *) folder->parent_store;
-
+
if (changes->uid_added->len > 0 && (offline->sync_offline || camel_url_get_param (service->url, "sync_offline"))) {
CamelSession *session = service->session;
struct _offline_downsync_msg *m;
-
+
m = camel_session_thread_msg_new (session, &offline_downsync_ops, sizeof (*m));
m->changes = camel_folder_change_info_new ();
camel_folder_change_info_cat (m->changes, changes);
camel_object_ref (folder);
m->folder = folder;
-
+
camel_session_thread_queue (session, &m->msg, 0);
}
}
static void
camel_offline_folder_init (CamelOfflineFolder *folder, CamelOfflineFolderClass *klass)
-{
+{
camel_object_hook_event (folder, "folder_changed", (CamelObjectEventHookFunc) offline_folder_changed, NULL);
}
CamelArgGetV props;
int i, count = 0;
guint32 tag;
-
+
for (i = 0; i < args->argc; i++) {
CamelArgGet *arg = &args->argv[i];
-
+
tag = arg->tag;
-
+
switch (tag & CAMEL_ARG_TAG) {
case CAMEL_OBJECT_ARG_PERSISTENT_PROPERTIES:
case CAMEL_FOLDER_ARG_PROPERTIES:
count++;
continue;
}
-
+
arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
}
-
+
if (count)
return ((CamelObjectClass *) parent_class)->getv (object, ex, args);
-
+
return 0;
}
gboolean save = FALSE;
guint32 tag;
int i;
-
+
for (i = 0; i < args->argc; i++) {
CamelArg *arg = &args->argv[i];
-
+
tag = arg->tag;
-
+
switch (tag & CAMEL_ARG_TAG) {
case CAMEL_OFFLINE_FOLDER_ARG_SYNC_OFFLINE:
if (folder->sync_offline != arg->ca_int) {
default:
continue;
}
-
+
arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
}
-
+
if (save)
camel_object_state_write (object);
-
+
return ((CamelObjectClass *) parent_class)->setv (object, ex, args);
}
CamelMimeMessage *message;
GPtrArray *uids;
int i;
-
+
camel_operation_start (NULL, _("Syncing messages in folder '%s' to disk"), folder->full_name);
-
+
if (expression)
uids = camel_folder_search_by_expression (folder, expression, ex);
else
uids = camel_folder_get_uids (folder);
-
+
if (!uids) {
camel_operation_end (NULL);
return;
}
-
+
for (i = 0; i < uids->len; i++) {
int pc = i * 100 / uids->len;
-
+
message = camel_folder_get_message (folder, uids->pdata[i], ex);
camel_operation_progress (NULL, pc);
if (message == NULL)
break;
-
+
camel_object_unref (message);
}
-
+
if (expression)
camel_folder_search_free (folder, uids);
else
camel_folder_free_uids (folder, uids);
-
+
camel_operation_end (NULL);
}
camel_offline_folder_downsync (CamelOfflineFolder *offline, const char *expression, CamelException *ex)
{
g_return_if_fail (CAMEL_IS_OFFLINE_FOLDER (offline));
-
+
CAMEL_OFFLINE_FOLDER_GET_CLASS (offline)->downsync (offline, expression, ex);
}
struct _CamelOfflineFolder {
CamelFolder parent_object;
-
+
unsigned int sync_offline:1;
};
struct _CamelOfflineFolderClass {
CamelFolderClass parent_class;
-
+
void (* downsync) (CamelOfflineFolder *folder, const char *expression, CamelException *ex);
};
camel_offline_journal_get_type (void)
{
static CamelType type = NULL;
-
+
if (!type) {
type = camel_type_register (camel_object_get_type (),
"CamelOfflineJournal",
(CamelObjectInitFunc) camel_offline_journal_init,
(CamelObjectFinalizeFunc) camel_offline_journal_finalize);
}
-
+
return type;
}
{
CamelOfflineJournal *journal = (CamelOfflineJournal *) object;
EDListNode *entry;
-
+
g_free (journal->filename);
-
+
while ((entry = e_dlist_remhead (&journal->queue)))
CAMEL_OFFLINE_JOURNAL_GET_CLASS (journal)->entry_free (journal, entry);
}
{
EDListNode *entry;
FILE *fp;
-
+
journal->filename = g_strdup (filename);
journal->folder = folder;
-
+
if ((fp = g_fopen (filename, "rb"))) {
while ((entry = CAMEL_OFFLINE_JOURNAL_GET_CLASS (journal)->entry_load (journal, fp)))
e_dlist_addtail (&journal->queue, entry);
-
+
fclose (fp);
}
}
camel_offline_journal_set_filename (CamelOfflineJournal *journal, const char *filename)
{
g_return_if_fail (CAMEL_IS_OFFLINE_JOURNAL (journal));
-
+
g_free (journal->filename);
journal->filename = g_strdup (filename);
}
EDListNode *entry;
FILE *fp;
int fd;
-
+
if ((fd = g_open (journal->filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666)) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot write offline journal for folder `%s': %s"),
journal->folder->full_name, g_strerror (errno));
return -1;
}
-
+
fp = fdopen (fd, "w");
entry = journal->queue.head;
while (entry->next) {
goto exception;
entry = entry->next;
}
-
+
if (fsync (fd) == -1)
goto exception;
-
+
fclose (fp);
-
+
return 0;
-
+
exception:
-
+
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot write offline journal for folder `%s': %s"),
journal->folder->full_name, g_strerror (errno));
-
+
fclose (fp);
-
+
return -1;
}
EDListNode *entry, *next;
CamelException lex;
int failed = 0;
-
+
camel_exception_init (&lex);
-
+
entry = journal->queue.head;
while (entry->next) {
next = entry->next;
}
entry = next;
}
-
+
if (failed > 0)
return -1;
-
+
return 0;
}
struct _CamelOfflineJournal {
CamelObject parent_object;
-
+
struct _CamelFolder *folder;
char *filename;
EDList queue;
struct _CamelOfflineJournalClass {
CamelObjectClass parent_class;
-
+
/* entry methods */
void (* entry_free) (CamelOfflineJournal *journal, EDListNode *entry);
-
+
EDListNode * (* entry_load) (CamelOfflineJournal *journal, FILE *in);
int (* entry_write) (CamelOfflineJournal *journal, EDListNode *entry, FILE *out);
int (* entry_play) (CamelOfflineJournal *journal, EDListNode *entry, CamelException *ex);
camel_offline_store_get_type (void)
{
static CamelType type = NULL;
-
+
if (!type) {
type = camel_type_register (CAMEL_STORE_TYPE,
"CamelOfflineStore",
(CamelObjectInitFunc) camel_offline_store_init,
(CamelObjectFinalizeFunc) camel_offline_store_finalize);
}
-
+
return type;
}
camel_offline_store_class_init (CamelOfflineStoreClass *klass)
{
parent_class = (CamelStoreClass *) camel_type_get_global_classfuncs (CAMEL_STORE_TYPE);
-
+
((CamelServiceClass *) klass)->construct = offline_store_construct;
}
CamelException *ex)
{
CamelOfflineStore *store = CAMEL_OFFLINE_STORE (service);
-
+
CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
if (camel_exception_is_set (ex))
return;
-
+
store->state = camel_session_is_online (session) ?
CAMEL_OFFLINE_STORE_NETWORK_AVAIL : CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL;
}
if (store->state == state)
return;
-
+
camel_exception_init (&lex);
if (store->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
/* network available -> network unavailable */
GPtrArray *folders;
CamelFolder *folder;
int i, sync;
-
+
sync = camel_url_get_param (((CamelService *) store)->url, "sync_offline") != NULL;
-
+
folders = camel_object_bag_list (((CamelStore *) store)->folders);
for (i = 0; i < folders->len; i++) {
folder = folders->pdata[i];
-
+
if (CAMEL_CHECK_TYPE (folder, CAMEL_OFFLINE_FOLDER_TYPE)
&& (sync || ((CamelOfflineFolder *) folder)->sync_offline)) {
camel_offline_folder_downsync ((CamelOfflineFolder *) folder, NULL, &lex);
camel_exception_clear (&lex);
}
-
+
camel_object_unref (folder);
}
-
+
g_ptr_array_free (folders, TRUE);
}
-
+
camel_store_sync (CAMEL_STORE (store), FALSE, &lex);
camel_exception_clear (&lex);
}
if (!camel_service_connect (CAMEL_SERVICE (store), ex))
return;
}
-
+
store->state = state;
}
struct _CamelOfflineStore {
CamelStore parent_object;
-
+
int state;
};
struct _CamelOfflineStoreClass {
CamelStoreClass parent_class;
-
+
void (* set_network_state) (CamelOfflineStore *store, int state, CamelException *ex);
};
* @status: Callback for receiving status messages. This will always
* be called with an internal lock held.
* @status_data: User data.
- *
+ *
* Create a new camel operation handle. Camel operation handles can
* be used in a multithreaded application (or a single operation
* handle can be used in a non threaded appliation) to cancel running
* operations and to obtain notification messages of the internal
* status of messages.
- *
+ *
* Return value: A new operation handle.
**/
CamelOperation *
LOCK();
e_dlist_addtail(&operation_list, (EDListNode *)cc);
UNLOCK();
-
+
return cc;
}
/**
* camel_operation_mute:
- * @cc:
- *
+ * @cc:
+ *
* mutes a camel operation permanently. from this point on you will never
* receive operation updates, even if more are sent.
**/
/**
* camel_operation_ref:
* @cc: operation context
- *
+ *
* Add a reference to the CamelOperation @cc.
**/
void
/**
* camel_operation_unref:
* @cc: operation context
- *
+ *
* Unref and potentially free @cc.
**/
void
LOCK();
if (cc->refcount == 1) {
CamelOperationMsg *msg;
-
+
e_dlist_remove((EDListNode *)cc);
while ((msg = (CamelOperationMsg *)e_msgport_get(cc->cancel_port)))
g_free(msg);
e_msgport_destroy(cc->cancel_port);
-
+
n = cc->status_stack;
while (n) {
g_warning("Camel operation status stack non empty: %s", (char *)n->data);
/**
* camel_operation_cancel_block:
* @cc: operation context
- *
+ *
* Block cancellation for this operation. If @cc is NULL, then the
* current thread is blocked.
**/
/**
* camel_operation_cancel_unblock:
* @cc: operation context
- *
+ *
* Unblock cancellation, when the unblock count reaches the block
* count, then this operation can be cancelled. If @cc is NULL, then
* the current thread is unblocked.
/**
* camel_operation_cancel:
* @cc: operation context
- *
+ *
* Cancel a given operation. If @cc is NULL then all outstanding
* operations are cancelled.
**/
camel_operation_cancel (CamelOperation *cc)
{
CamelOperationMsg *msg;
-
+
LOCK();
if (cc == NULL) {
/**
* camel_operation_uncancel:
* @cc: operation context
- *
+ *
* Uncancel a cancelled operation. If @cc is NULL then the current
* operation is uncancelled.
*
/**
* camel_operation_register:
* @cc: operation context
- *
+ *
* Register a thread or the main thread for cancellation through @cc.
* If @cc is NULL, then a new cancellation is created for this thread.
*
/**
* camel_operation_unregister:
* @cc: operation context
- *
+ *
* Unregister the current thread for all cancellations.
**/
void
/**
* camel_operation_cancel_check:
* @cc: operation context
- *
+ *
* Check if cancellation has been applied to @cc. If @cc is NULL,
* then the CamelOperation registered for the current thread is used.
- *
+ *
* Return value: TRUE if the operation has been cancelled.
**/
gboolean
/**
* camel_operation_cancel_fd:
* @cc: operation context
- *
+ *
* Retrieve a file descriptor that can be waited on (select, or poll)
* for read, to asynchronously detect cancellation.
- *
+ *
* Return value: The fd, or -1 if cancellation is not available
* (blocked, or has not been registered for this thread).
**/
/**
* camel_operation_cancel_prfd:
* @cc: operation context
- *
+ *
* Retrieve a file descriptor that can be waited on (select, or poll)
* for read, to asynchronously detect cancellation.
- *
+ *
* Return value: The fd, or NULL if cancellation is not available
* (blocked, or has not been registered for this thread).
**/
* @cc: operation context
* @what: action being performed (printf-style format string)
* @Varargs: varargs
- *
+ *
* Report the start of an operation. All start operations should have
* similar end operations.
**/
* @cc: operation context
* @what: printf-style format string describing the action being performed
* @Varargs: varargs
- *
+ *
* Start a transient event. We only update this to the display if it
* takes very long to process, and if we do, we then go back to the
* previous state when finished.
* camel_operation_progress:
* @cc: Operation to report to.
* @pc: Percent complete, 0 to 100.
- *
+ *
* Report progress on the current operation. If @cc is NULL, then the
* currently registered operation is used. @pc reports the current
* percentage of completion, which should be in the range of 0 to 100.
* camel_operation_end:
* @cc: operation context
* @what: Format string.
- * @Varargs: varargs
- *
+ * @Varargs: varargs
+ *
* Report the end of an operation. If @cc is NULL, then the currently
* registered operation is notified.
**/
camel_object_unref((CamelObject *)cpi->blocks);
}
-
+
pthread_mutex_destroy(&p->lock);
-
+
g_free(p);
}
camel_partition_table_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_object_get_type(), "CamelPartitionTable",
sizeof (CamelPartitionTable),
(CamelObjectInitFunc) camel_partition_table_init,
(CamelObjectFinalizeFunc) camel_partition_table_finalise);
}
-
+
return type;
}
{
CamelBlock *bl, *bn;
int ret = 0;
-
+
CAMEL_PARTITION_TABLE_LOCK(cpi, lock);
-
+
if (cpi->blocks) {
bl = (CamelBlock *)cpi->partition.head;
bn = bl->next;
}
CAMEL_PARTITION_TABLE_UNLOCK(cpi, lock);
-
+
camel_block_file_unref_block(cpi->blocks, block);
return keyid;
hashid = hash_key(key);
CAMEL_PARTITION_TABLE_LOCK(cpi, lock);
-
+
ptblock = find_partition(cpi, hashid, &index);
if (ptblock == NULL) {
CAMEL_PARTITION_TABLE_UNLOCK(cpi, lock);
if (pkb->keys[i].hashid == hashid) {
/* !! need to: lookup and compare string value */
/* get_key() if key == key ... */
-
+
/* remove this key */
pkb->used--;
for (;i<pkb->used;i++) {
}
CAMEL_PARTITION_TABLE_UNLOCK(cpi, lock);
-
+
camel_block_file_unref_block(cpi->blocks, block);
}
camel_block_file_sync(ki->blocks);
camel_object_unref((CamelObject *)ki->blocks);
}
-
+
pthread_mutex_destroy(&p->lock);
-
+
g_free(p);
}
camel_key_table_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_object_get_type(), "CamelKeyTable",
sizeof (CamelKeyTable),
(CamelObjectInitFunc) camel_key_table_init,
(CamelObjectFinalizeFunc) camel_key_table_finalise);
}
-
+
return type;
}
do {
blockid = next & (~(CAMEL_BLOCK_SIZE-1));
index = next & (CAMEL_BLOCK_SIZE-1);
-
+
bl = camel_block_file_get_block(ki->blocks, blockid);
if (bl == NULL) {
CAMEL_KEY_TABLE_UNLOCK(ki, lock);
*
* Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
struct _CamelStreamFilter *filter_stream;
struct _CamelIndex *index;
-
+
GMutex *summary_lock; /* for the summary hashtable/array */
GMutex *io_lock; /* load/save lock, for access to saved_count, etc */
GMutex *filter_lock; /* for accessing any of the filtering/indexing stuff, since we share them */
struct _CamelVeeFolderPrivate {
GList *folders; /* lock using subfolder_lock before changing/accessing */
GList *folders_changed; /* for list of folders that have changed between updates */
-
+
GMutex *summary_lock; /* for locking vfolder summary */
GMutex *subfolder_lock; /* for locking the subfolder list */
GMutex *changed_lock; /* for locking the folders-changed list */
{
int errnosav, fd[6], i;
pid_t pid;
-
+
for (i = 0; i < 6; i++)
fds[i] = -1;
-
+
for (i = 0; i < 6; i += 2) {
if (pipe (fd + i) == -1) {
errnosav = errno;
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to create pipe to '%s': %s"),
argv[0], strerror (errno));
-
+
for (i = 0; i < 6; i++) {
if (fd[i] == -1)
break;
close (fd[i]);
}
-
+
errno = errnosav;
-
+
return -1;
}
}
-
+
if (!(pid = fork ())) {
/* child process */
int maxfd, nullfd = -1;
-
+
if (!outfd || !errfd)
nullfd = open ("/dev/null", O_WRONLY);
-
+
if (dup2 (fd[0], STDIN_FILENO) == -1)
_exit (255);
-
+
if (dup2 (outfd ? fd[3] : nullfd, STDOUT_FILENO) == -1)
_exit (255);
-
+
if (dup2 (errfd ? fd[5] : nullfd, STDERR_FILENO) == -1)
_exit (255);
-
+
setsid ();
-
+
if ((maxfd = sysconf (_SC_OPEN_MAX)) > 0) {
for (i = 3; i < maxfd; i++)
fcntl (i, F_SETFD, FD_CLOEXEC);
}
-
+
execv (path, argv);
_exit (255);
} else if (pid == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to create child process '%s': %s"),
argv[0], strerror (errno));
- for (i = 0; i < 6; i++)
+ for (i = 0; i < 6; i++)
close (fd[i]);
return -1;
}
-
+
/* parent process */
close (fd[0]);
close (fd[3]);
close (fd[5]);
-
+
if (infd)
*infd = fd[1];
else
close (fd[1]);
-
+
if (outfd)
*outfd = fd[2];
else
close (fd[2]);
-
+
if (errfd)
*errfd = fd[4];
else
close (fd[4]);
-
+
return pid;
}
sigset_t mask, omask;
int status;
pid_t r;
-
+
sigemptyset (&mask);
sigaddset (&mask, SIGALRM);
sigprocmask (SIG_BLOCK, &mask, &omask);
alarm (1);
-
+
r = waitpid (pid, &status, 0);
-
+
alarm (0);
sigprocmask (SIG_SETMASK, &omask, NULL);
-
+
if (r == (pid_t) -1 && errno == EINTR) {
kill (pid, SIGTERM);
sleep (1);
r = waitpid (pid, &status, WNOHANG);
}
}
-
+
if (r != (pid_t) -1 && WIFEXITED (status))
return WEXITSTATUS (status);
else
static CamelProvider vee_provider = {
"vfolder",
N_("Virtual folder email provider"),
-
+
N_("For reading mail as a query of another set of folders"),
-
+
"vfolder",
-
+
CAMEL_PROVIDER_IS_STORAGE,
CAMEL_URL_NEED_PATH | CAMEL_URL_PATH_IS_ABSOLUTE | CAMEL_URL_FRAGMENT_IS_PATH,
-
+
/* ... */
};
CAMEL_PROVIDERDIR, g_strerror (errno));
return;
}
-
+
while ((entry = g_dir_read_name (dir))) {
FILE *fp;
-
+
p = strrchr (entry, '.');
if (!p || strcmp (p, ".urls") != 0)
continue;
-
+
name = g_strdup_printf ("%s/%s", CAMEL_PROVIDERDIR, entry);
fp = g_fopen (name, "r");
if (!fp) {
g_free (name);
continue;
}
-
+
p = strrchr (name, '.');
strcpy (p, "." G_MODULE_SUFFIX);
p = strchr (buf, '\n');
if (p)
*p = '\0';
-
+
if (*buf) {
char *protocol = g_strdup(buf);
* Loads the provider at @path, and calls its initialization function,
* passing @session as an argument. The provider should then register
* itself with @session.
- **/
+ **/
void
camel_provider_load(const char *path, CamelException *ex)
{
UNLOCK();
return;
}
-
+
for (i = 0; i < CAMEL_NUM_PROVIDER_TYPES; i++) {
if (provider->object_types[i])
provider->service_cache[i] = camel_object_bag_new (provider->url_hash, provider->url_equal,
typedef struct {
/* Provider name used in CamelURLs. */
char *protocol;
-
+
/* Provider name as used by people. (May be the same as protocol) */
char *name;
-
+
/* Description of the provider. A novice user should be able
* to read this description, and the information provided by
* an ISP, IS department, etc, and determine whether or not
* information goes with it.
*/
char *description;
-
+
/* The category of message that this provider works with.
* (evolution-mail will only list a provider in the store/transport
* config dialogs if its domain is "mail".)
*/
char *domain;
-
+
/* Flags describing the provider, flags describing its URLs */
int flags, url_flags;
/* The ConfEntry and AutoDetect functions will probably be
* DEPRECATED in a future release */
-
+
/* Extra configuration information */
CamelProviderConfEntry *extra_conf;
* uses the store type (eg, Exchange or NNTP).
*/
CamelType object_types[CAMEL_NUM_PROVIDER_TYPES];
-
+
/* GList of CamelServiceAuthTypes the provider supports */
GList *authtypes;
-
+
CamelObjectBag *service_cache[CAMEL_NUM_PROVIDER_TYPES];
-
+
GHashFunc url_hash;
GCompareFunc url_equal;
/* This string points to the provider's gconf key value
*/
const char *license;
-
+
/* This holds the license file name [ ascii text format ] containing
- * the license agreement. This should be the absolute file path. This
+ * the license agreement. This should be the absolute file path. This
* is read only when the HAS_LICENSE flag is set
*/
const char *license_file;
- /* Private to the provider */
+ /* Private to the provider */
void *priv;
} CamelProvider;
CamelServiceAuthType camel_sasl_anonymous_authtype = {
N_("Anonymous"),
-
+
N_("This option will connect to the server using an anonymous login."),
-
+
"ANONYMOUS",
FALSE
};
camel_sasl_anonymous_class_init (CamelSaslAnonymousClass *camel_sasl_anonymous_class)
{
CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (camel_sasl_anonymous_class);
-
+
parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ()));
-
+
/* virtual method overload */
camel_sasl_class->challenge = anon_challenge;
}
camel_sasl_anonymous_finalize (CamelObject *object)
{
CamelSaslAnonymous *sasl = CAMEL_SASL_ANONYMOUS (object);
-
+
g_free (sasl->trace_info);
}
camel_sasl_anonymous_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_sasl_get_type (),
"CamelSaslAnonymous",
NULL,
(CamelObjectFinalizeFunc) camel_sasl_anonymous_finalize);
}
-
+
return type;
}
camel_sasl_anonymous_new (CamelSaslAnonTraceType type, const char *trace_info)
{
CamelSaslAnonymous *sasl_anon;
-
+
if (!trace_info && type != CAMEL_SASL_ANON_TRACE_EMPTY) return NULL;
-
+
sasl_anon = CAMEL_SASL_ANONYMOUS (camel_object_new (camel_sasl_anonymous_get_type ()));
sasl_anon->trace_info = g_strdup (trace_info);
sasl_anon->type = type;
-
+
return CAMEL_SASL (sasl_anon);
}
typedef struct _CamelSaslAnonymous {
CamelSasl parent_object;
-
+
char *trace_info;
CamelSaslAnonTraceType type;
} CamelSaslAnonymous;
typedef struct _CamelSaslAnonymousClass {
CamelSaslClass parent_class;
-
+
} CamelSaslAnonymousClass;
camel_sasl_cram_md5_class_init (CamelSaslCramMd5Class *camel_sasl_cram_md5_class)
{
CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (camel_sasl_cram_md5_class);
-
+
parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ()));
-
+
/* virtual method overload */
camel_sasl_class->challenge = cram_md5_challenge;
}
camel_sasl_cram_md5_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_sasl_get_type (),
"CamelSaslCramMd5",
NULL,
NULL);
}
-
+
return type;
}
guchar opad[64];
MD5Context ctx;
int i, pw_len;
-
+
/* Need to wait for the server */
if (!token)
return NULL;
-
+
g_return_val_if_fail (sasl->service->url->passwd != NULL, NULL);
-
+
memset (ipad, 0, sizeof (ipad));
memset (opad, 0, sizeof (opad));
-
+
passwd = sasl->service->url->passwd;
pw_len = strlen (passwd);
if (pw_len <= 64) {
md5_get_digest (passwd, pw_len, ipad);
memcpy (opad, ipad, 16);
}
-
+
for (i = 0; i < 64; i++) {
ipad[i] ^= 0x36;
opad[i] ^= 0x5c;
}
-
+
md5_init (&ctx);
md5_update (&ctx, ipad, 64);
md5_update (&ctx, token->data, token->len);
md5_final (&ctx, digest);
-
+
md5_init (&ctx);
md5_update (&ctx, opad, 64);
md5_update (&ctx, digest, 16);
md5_final (&ctx, digest);
-
+
/* lowercase hexify that bad-boy... */
for (s = digest, p = md5asc; p < md5asc + 32; s++, p += 2)
sprintf (p, "%.2x", *s);
-
+
ret = g_byte_array_new ();
g_byte_array_append (ret, sasl->service->url->user, strlen (sasl->service->url->user));
g_byte_array_append (ret, " ", 1);
g_byte_array_append (ret, md5asc, 32);
-
+
sasl->authenticated = TRUE;
-
+
return ret;
}
typedef struct _CamelSaslCramMd5Class {
CamelSaslClass parent_class;
-
+
} CamelSaslCramMd5Class;
camel_sasl_digest_md5_class_init (CamelSaslDigestMd5Class *camel_sasl_digest_md5_class)
{
CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (camel_sasl_digest_md5_class);
-
+
parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ()));
-
+
/* virtual method overload */
camel_sasl_class->challenge = digest_md5_challenge;
}
camel_sasl_digest_md5_init (gpointer object, gpointer klass)
{
CamelSaslDigestMd5 *sasl_digest = CAMEL_SASL_DIGEST_MD5 (object);
-
+
sasl_digest->priv = g_new0 (struct _CamelSaslDigestMd5Private, 1);
}
struct _DigestResponse *r = sasl->priv->response;
GList *p;
int i;
-
+
if (c != NULL) {
for (i = 0; i < c->realms->len; i++)
g_free (c->realms->pdata[i]);
g_ptr_array_free (c->realms, TRUE);
-
+
g_free (c->nonce);
g_free (c->charset);
g_free (c->algorithm);
for (p = c->params; p; p = p->next) {
struct _param *param = p->data;
-
+
g_free (param->name);
g_free (param->value);
g_free (param);
g_list_free (c->params);
g_free (c);
}
-
+
if (r != NULL) {
g_free (r->username);
g_free (r->realm);
g_free (r->param);
g_free (r);
}
-
+
g_free (sasl->priv);
}
camel_sasl_digest_md5_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_sasl_get_type (),
"CamelSaslDigestMd5",
(CamelObjectInitFunc) camel_sasl_digest_md5_init,
(CamelObjectFinalizeFunc) camel_sasl_digest_md5_finalize);
}
-
+
return type;
}
decode_lwsp (const char **in)
{
const char *inptr = *in;
-
+
while (isspace (*inptr))
inptr++;
-
+
*in = inptr;
}
char *out = NULL, *outptr;
int outlen;
int c;
-
+
decode_lwsp (&inptr);
if (*inptr == '"') {
const char *intmp;
int skip = 0;
-
+
/* first, calc length */
inptr++;
intmp = inptr;
skip++;
}
}
-
+
outlen = intmp - inptr - skip;
out = outptr = g_malloc (outlen + 1);
-
+
while ((c = *inptr++) && c != '"') {
if (c == '\\' && *inptr) {
c = *inptr++;
}
*outptr = '\0';
}
-
+
*in = inptr;
-
+
return out;
}
{
const char *inptr = *in;
const char *start;
-
+
decode_lwsp (&inptr);
start = inptr;
-
+
while (*inptr && *inptr != '=' && *inptr != ',')
inptr++;
-
+
if (inptr > start) {
*in = inptr;
return g_strndup (start, inptr - start);
decode_value (const char **in)
{
const char *inptr = *in;
-
+
decode_lwsp (&inptr);
if (*inptr == '"') {
d(printf ("decoding quoted string token\n"));
GList *params = NULL;
struct _param *param;
const char *ptr;
-
+
for (ptr = tokens; ptr && *ptr; ) {
param = g_new0 (struct _param, 1);
param->name = decode_token (&ptr);
ptr++;
param->value = decode_value (&ptr);
}
-
+
params = g_list_prepend (params, param);
-
+
if (*ptr == ',')
ptr++;
}
-
+
return params;
}
decode_data_type (DataType *dtype, const char *name)
{
int i;
-
+
for (i = 0; dtype[i].name; i++) {
if (!g_ascii_strcasecmp (dtype[i].name, name))
break;
}
-
+
return dtype[i].type;
}
type_to_string (DataType *dtype, guint type)
{
int i;
-
+
for (i = 0; dtype[i].name; i++) {
if (dtype[i].type == type)
break;
}
-
+
return dtype[i].name;
}
gboolean got_maxbuf = FALSE;
gboolean got_charset = FALSE;
#endif /* PARANOID */
-
+
params = parse_param_list (tokens);
if (!params) {
*abort = TRUE;
return NULL;
}
-
+
*abort = FALSE;
-
+
challenge = g_new0 (struct _DigestChallenge, 1);
challenge->realms = g_ptr_array_new ();
challenge->maxbuf = 65536;
-
+
for (p = params; p; p = p->next) {
struct _param *param = p->data;
int type;
-
+
type = get_digest_arg (param->name);
switch (type) {
case DIGEST_REALM:
for (ptr = param->value; ptr && *ptr; ) {
char *token;
-
+
token = decode_token (&ptr);
if (token)
g_ptr_array_add (challenge->realms, token);
-
+
if (*ptr == ',')
ptr++;
}
case DIGEST_QOP:
for (ptr = param->value; ptr && *ptr; ) {
char *token;
-
+
token = decode_token (&ptr);
if (token)
challenge->qop |= decode_qop (token);
-
+
if (*ptr == ',')
ptr++;
}
-
+
if (challenge->qop & QOP_INVALID)
challenge->qop = QOP_INVALID;
g_free (param->value);
case DIGEST_CIPHER:
for (ptr = param->value; ptr && *ptr; ) {
char *token;
-
+
token = decode_token (&ptr);
if (token)
challenge->cipher |= decode_cipher (token);
-
+
if (*ptr == ',')
ptr++;
}
break;
}
}
-
+
g_list_free (params);
-
+
return challenge;
}
digest_hex (guchar *digest, guchar hex[33])
{
guchar *s, *p;
-
+
/* lowercase hexify that bad-boy... */
for (s = digest, p = hex; p < hex + 32; s++, p += 2)
sprintf (p, "%.2x", *s);
guchar digest[16];
MD5Context ctx;
char *buf;
-
+
/* compute A1 */
md5_init (&ctx);
md5_update (&ctx, resp->username, strlen (resp->username));
md5_update (&ctx, ":", 1);
md5_update (&ctx, passwd, strlen (passwd));
md5_final (&ctx, digest);
-
+
md5_init (&ctx);
md5_update (&ctx, digest, 16);
md5_update (&ctx, ":", 1);
md5_update (&ctx, ":", 1);
md5_update (&ctx, resp->authzid, strlen (resp->authzid));
}
-
+
/* hexify A1 */
md5_final (&ctx, digest);
digest_hex (digest, hex_a1);
-
+
/* compute A2 */
md5_init (&ctx);
if (client) {
/* we are calculating the server rspauth */
md5_update (&ctx, ":", 1);
}
-
+
buf = digest_uri_to_string (resp->uri);
md5_update (&ctx, buf, strlen (buf));
g_free (buf);
-
+
if (resp->qop == QOP_AUTH_INT || resp->qop == QOP_AUTH_CONF)
md5_update (&ctx, ":00000000000000000000000000000000", 33);
-
+
/* now hexify A2 */
md5_final (&ctx, digest);
digest_hex (digest, hex_a2);
-
+
/* compute KD */
md5_init (&ctx);
md5_update (&ctx, hex_a1, 32);
md5_update (&ctx, ":", 1);
md5_update (&ctx, hex_a2, 32);
md5_final (&ctx, digest);
-
+
digest_hex (digest, out);
}
struct _DigestResponse *resp;
struct _DigestURI *uri;
char *bgen, digest[16];
-
+
resp = g_new0 (struct _DigestResponse, 1);
resp->username = g_strdup (user);
/* FIXME: we should use the preferred realm */
resp->realm = g_strdup (challenge->realms->pdata[0]);
else
resp->realm = g_strdup ("");
-
+
resp->nonce = g_strdup (challenge->nonce);
-
+
/* generate the cnonce */
bgen = g_strdup_printf ("%p:%lu:%lu", resp,
(unsigned long) getpid (),
g_free (bgen);
/* take our recommended 64 bits of entropy */
resp->cnonce = g_base64_encode (digest, 8);
-
+
/* we don't support re-auth so the nonce count is always 1 */
strcpy (resp->nc, "00000001");
-
+
/* choose the QOP */
/* FIXME: choose - probably choose "auth" ??? */
resp->qop = QOP_AUTH;
-
+
/* create the URI */
uri = g_new0 (struct _DigestURI, 1);
uri->type = g_strdup (protocol);
uri->host = g_strdup (host);
uri->name = NULL;
resp->uri = uri;
-
+
/* charsets... yay */
if (challenge->charset) {
/* I believe that this is only ever allowed to be
*/
resp->charset = g_strdup (challenge->charset);
}
-
+
resp->cipher = CIPHER_INVALID;
if (resp->qop == QOP_AUTH_CONF) {
/* FIXME: choose a cipher? */
resp->cipher = CIPHER_INVALID;
}
-
+
/* we don't really care about this... */
resp->authzid = NULL;
-
+
compute_response (resp, passwd, TRUE, resp->resp);
-
+
return resp;
}
GByteArray *buffer;
const char *str;
char *buf;
-
+
buffer = g_byte_array_new ();
g_byte_array_append (buffer, "username=\"", 10);
if (resp->charset) {
size_t len, outlen;
const char *inbuf;
iconv_t cd;
-
+
charset = e_iconv_locale_charset ();
if (!charset)
charset = "iso-8859-1";
-
+
cd = e_iconv_open (resp->charset, charset);
-
+
len = strlen (resp->username);
outlen = 2 * len; /* plenty of space */
-
+
outbuf = username = g_malloc0 (outlen + 1);
inbuf = resp->username;
if (cd == (iconv_t) -1 || e_iconv (cd, &inbuf, &len, &outbuf, &outlen) == (size_t) -1) {
/* We can't convert to UTF-8 - pretend we never got a charset param? */
g_free (resp->charset);
resp->charset = NULL;
-
+
/* Set the username to the non-UTF-8 version */
g_free (username);
username = g_strdup (resp->username);
}
-
+
if (cd != (iconv_t) -1)
e_iconv_close (cd);
-
+
g_byte_array_append (buffer, username, strlen (username));
g_free (username);
} else {
g_byte_array_append (buffer, resp->username, strlen (resp->username));
}
-
+
g_byte_array_append (buffer, "\",realm=\"", 9);
g_byte_array_append (buffer, resp->realm, strlen (resp->realm));
-
+
g_byte_array_append (buffer, "\",nonce=\"", 9);
g_byte_array_append (buffer, resp->nonce, strlen (resp->nonce));
-
+
g_byte_array_append (buffer, "\",cnonce=\"", 10);
g_byte_array_append (buffer, resp->cnonce, strlen (resp->cnonce));
-
+
g_byte_array_append (buffer, "\",nc=", 5);
g_byte_array_append (buffer, resp->nc, 8);
-
+
g_byte_array_append (buffer, ",qop=", 5);
str = qop_to_string (resp->qop);
g_byte_array_append (buffer, str, strlen (str));
-
+
g_byte_array_append (buffer, ",digest-uri=\"", 13);
buf = digest_uri_to_string (resp->uri);
g_byte_array_append (buffer, buf, strlen (buf));
g_free (buf);
-
+
g_byte_array_append (buffer, "\",response=", 11);
g_byte_array_append (buffer, resp->resp, 32);
-
+
if (resp->maxbuf > 0) {
g_byte_array_append (buffer, ",maxbuf=", 8);
buf = g_strdup_printf ("%u", resp->maxbuf);
g_byte_array_append (buffer, buf, strlen (buf));
g_free (buf);
}
-
+
if (resp->charset) {
g_byte_array_append (buffer, ",charset=", 9);
g_byte_array_append (buffer, resp->charset, strlen (resp->charset));
}
-
+
if (resp->cipher != CIPHER_INVALID) {
str = cipher_to_string (resp->cipher);
if (str) {
g_byte_array_append (buffer, "\"", 1);
}
}
-
+
if (resp->authzid) {
g_byte_array_append (buffer, ",authzid=\"", 10);
g_byte_array_append (buffer, resp->authzid, strlen (resp->authzid));
g_byte_array_append (buffer, "\"", 1);
}
-
+
return buffer;
}
guchar out[33];
char *tokens;
struct addrinfo *ai, hints;
-
+
/* Need to wait for the server */
if (!token)
return NULL;
-
+
g_return_val_if_fail (sasl->service->url->passwd != NULL, NULL);
-
+
switch (priv->state) {
case STATE_AUTH:
if (token->len > 2048) {
_("Server challenge too long (>2048 octets)"));
return NULL;
}
-
+
tokens = g_strndup (token->data, token->len);
priv->challenge = parse_server_challenge (tokens, &abort);
g_free (tokens);
_("Server challenge invalid\n"));
return NULL;
}
-
+
if (priv->challenge->qop == QOP_INVALID) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("Server challenge contained invalid "
if (ai)
camel_freeaddrinfo(ai);
ret = digest_response (priv->response);
-
+
break;
case STATE_FINAL:
if (token->len)
tokens = g_strndup (token->data, token->len);
else
tokens = NULL;
-
+
if (!tokens || !*tokens) {
g_free (tokens);
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("Server response did not contain authorization data"));
return NULL;
}
-
+
rspauth = g_new0 (struct _param, 1);
-
+
ptr = tokens;
rspauth->name = decode_token (&ptr);
if (*ptr == '=') {
rspauth->value = decode_value (&ptr);
}
g_free (tokens);
-
+
if (!rspauth->value) {
g_free (rspauth->name);
g_free (rspauth);
_("Server response contained incomplete authorization data"));
return NULL;
}
-
+
compute_response (priv->response, sasl->service->url->passwd, FALSE, out);
if (memcmp (out, rspauth->value, 32) != 0) {
g_free (rspauth->name);
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("Server response does not match"));
sasl->authenticated = TRUE;
-
+
return NULL;
}
-
+
g_free (rspauth->name);
g_free (rspauth->value);
g_free (rspauth);
-
+
ret = g_byte_array_new ();
-
+
sasl->authenticated = TRUE;
default:
break;
}
-
+
priv->state++;
-
+
return ret;
}
typedef struct _CamelSaslDigestMd5 {
CamelSasl parent_object;
struct _CamelSaslDigestMd5Private *priv;
-
+
} CamelSaslDigestMd5;
typedef struct _CamelSaslDigestMd5Class {
CamelSaslClass parent_class;
-
+
} CamelSaslDigestMd5Class;
#ifdef HAVE_HEIMDAL_KRB5
#include <gssapi.h>
#else
-#ifdef HAVE_SUN_KRB5
+#ifdef HAVE_SUN_KRB5
#include <gssapi/gssapi.h>
#include <gssapi/gssapi_ext.h>
extern gss_OID gss_nt_service_name;
CamelServiceAuthType camel_sasl_gssapi_authtype = {
N_("GSSAPI"),
-
+
N_("This option will connect to the server using "
"Kerberos 5 authentication."),
-
+
"GSSAPI",
FALSE
};
camel_sasl_gssapi_class_init (CamelSaslGssapiClass *klass)
{
CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (klass);
-
+
parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ()));
-
+
/* virtual method overload */
camel_sasl_class->challenge = gssapi_challenge;
}
camel_sasl_gssapi_init (gpointer object, gpointer klass)
{
CamelSaslGssapi *gssapi = CAMEL_SASL_GSSAPI (object);
-
+
gssapi->priv = g_new (struct _CamelSaslGssapiPrivate, 1);
gssapi->priv->state = GSSAPI_STATE_INIT;
gssapi->priv->ctx = GSS_C_NO_CONTEXT;
{
CamelSaslGssapi *gssapi = CAMEL_SASL_GSSAPI (object);
guint32 status;
-
+
if (gssapi->priv->ctx != GSS_C_NO_CONTEXT)
gss_delete_sec_context (&status, &gssapi->priv->ctx, GSS_C_NO_BUFFER);
-
+
if (gssapi->priv->target != GSS_C_NO_NAME)
gss_release_name (&status, &gssapi->priv->target);
-
+
g_free (gssapi->priv);
}
camel_sasl_gssapi_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (
camel_sasl_get_type (),
(CamelObjectInitFunc) camel_sasl_gssapi_init,
(CamelObjectFinalizeFunc) camel_sasl_gssapi_finalize);
}
-
+
return type;
}
gssapi_set_exception (OM_uint32 major, OM_uint32 minor, CamelException *ex)
{
const char *str;
-
+
switch (major) {
case GSS_S_BAD_MECH:
str = _("The specified mechanism is not supported by the "
default:
str = _("Bad authentication response from server.");
}
-
+
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, str);
}
gss_OID mech;
char *str;
struct addrinfo *ai, hints;
-
+
switch (priv->state) {
case GSSAPI_STATE_INIT:
memset(&hints, 0, sizeof(hints));
ai = camel_getaddrinfo(sasl->service->url->host?sasl->service->url->host:"localhost", NULL, &hints, ex);
if (ai == NULL)
return NULL;
-
+
str = g_strdup_printf("%s@%s", sasl->service_name, ai->ai_canonname);
camel_freeaddrinfo(ai);
-
+
inbuf.value = str;
inbuf.length = strlen (str);
major = gss_import_name (&minor, &inbuf, GSS_C_NT_HOSTBASED_SERVICE, &priv->target);
g_free (str);
-
+
if (major != GSS_S_COMPLETE) {
gssapi_set_exception (major, minor, ex);
return NULL;
}
-
+
input_token = GSS_C_NO_BUFFER;
-
+
goto challenge;
break;
case GSSAPI_STATE_CONTINUE_NEEDED:
_("Bad authentication response from server."));
return NULL;
}
-
+
inbuf.value = token->data;
inbuf.length = token->len;
input_token = &inbuf;
-
+
challenge:
major = gss_init_sec_context (&minor, GSS_C_NO_CREDENTIAL, &priv->ctx, priv->target,
GSS_C_OID_KRBV5_DES, GSS_C_MUTUAL_FLAG |
GSS_C_REPLAY_FLAG | GSS_C_SEQUENCE_FLAG,
0, GSS_C_NO_CHANNEL_BINDINGS,
input_token, &mech, &outbuf, &flags, &time);
-
+
switch (major) {
case GSS_S_COMPLETE:
priv->state = GSSAPI_STATE_COMPLETE;
gssapi_set_exception (major, minor, ex);
return NULL;
}
-
+
challenge = g_byte_array_new ();
g_byte_array_append (challenge, outbuf.value, outbuf.length);
#ifndef HAVE_HEIMDAL_KRB5
_("Bad authentication response from server."));
return NULL;
}
-
+
inbuf.value = token->data;
inbuf.length = token->len;
-
+
major = gss_unwrap (&minor, priv->ctx, &inbuf, &outbuf, &conf_state, &qop);
if (major != GSS_S_COMPLETE) {
gssapi_set_exception (major, minor, ex);
return NULL;
}
-
+
if (outbuf.length < 4) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("Bad authentication response from server."));
#endif
return NULL;
}
-
+
/* check that our desired security layer is supported */
if ((((unsigned char *) outbuf.value)[0] & DESIRED_SECURITY_LAYER) != DESIRED_SECURITY_LAYER) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
#endif
return NULL;
}
-
+
inbuf.length = 4 + strlen (sasl->service->url->user);
inbuf.value = str = g_malloc (inbuf.length);
memcpy (inbuf.value, outbuf.value, 4);
str[0] = DESIRED_SECURITY_LAYER;
memcpy (str + 4, sasl->service->url->user, inbuf.length - 4);
-
+
#ifndef HAVE_HEIMDAL_KRB5
gss_release_buffer (&minor, &outbuf);
#endif
-
+
major = gss_wrap (&minor, priv->ctx, FALSE, qop, &inbuf, &conf_state, &outbuf);
if (major != GSS_S_COMPLETE) {
gssapi_set_exception (major, minor, ex);
g_free (str);
return NULL;
}
-
+
g_free (str);
challenge = g_byte_array_new ();
g_byte_array_append (challenge, outbuf.value, outbuf.length);
-
+
#ifndef HAVE_HEIMDAL_KRB5
gss_release_buffer (&minor, &outbuf);
#endif
-
+
priv->state = GSSAPI_STATE_AUTHENTICATED;
-
+
sasl->authenticated = TRUE;
break;
default:
return NULL;
}
-
+
return challenge;
}
struct _CamelSaslGssapi {
CamelSasl parent_object;
-
+
struct _CamelSaslGssapiPrivate *priv;
-
+
};
struct _CamelSaslGssapiClass {
CamelSaslClass parent_class;
-
+
};
/* Standard Camel function */
struct _CamelSaslKerberos4Private {
int state;
-
+
guint32 nonce_n;
guint32 nonce_h;
-
+
des_cblock session;
des_key_schedule schedule;
};
camel_sasl_kerberos4_class_init (CamelSaslKerberos4Class *camel_sasl_kerberos4_class)
{
CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (camel_sasl_kerberos4_class);
-
+
parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ()));
-
+
/* virtual method overload */
camel_sasl_class->challenge = krb4_challenge;
}
camel_sasl_kerberos4_init (gpointer object, gpointer klass)
{
CamelSaslKerberos4 *sasl_krb4 = CAMEL_SASL_KERBEROS4 (object);
-
+
sasl_krb4->priv = g_new0 (struct _CamelSaslKerberos4Private, 1);
}
camel_sasl_kerberos4_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_sasl_get_type (),
"CamelSaslKerberos4",
(CamelObjectInitFunc) camel_sasl_kerberos4_init,
(CamelObjectFinalizeFunc) camel_sasl_kerberos4_finalize);
}
-
+
return type;
}
typedef struct _CamelSaslKerberos4Class {
CamelSaslClass parent_class;
-
+
} CamelSaslKerberos4Class;
CamelServiceAuthType camel_sasl_login_authtype = {
N_("Login"),
-
+
N_("This option will connect to the server using a "
"simple password."),
-
+
"LOGIN",
TRUE
};
camel_sasl_login_class_init (CamelSaslLoginClass *camel_sasl_login_class)
{
CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (camel_sasl_login_class);
-
+
parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ()));
-
+
/* virtual method overload */
camel_sasl_class->challenge = login_challenge;
}
camel_sasl_login_init (gpointer object, gpointer klass)
{
CamelSaslLogin *sasl_login = CAMEL_SASL_LOGIN (object);
-
+
sasl_login->priv = g_new0 (struct _CamelSaslLoginPrivate, 1);
}
camel_sasl_login_finalize (CamelObject *object)
{
CamelSaslLogin *sasl = CAMEL_SASL_LOGIN (object);
-
+
g_free (sasl->priv);
}
camel_sasl_login_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_sasl_get_type (),
"CamelSaslLogin",
(CamelObjectInitFunc) camel_sasl_login_init,
(CamelObjectFinalizeFunc) camel_sasl_login_finalize);
}
-
+
return type;
}
struct _CamelSaslLoginPrivate *priv = CAMEL_SASL_LOGIN (sasl)->priv;
GByteArray *buf = NULL;
CamelURL *url = sasl->service->url;
-
+
g_return_val_if_fail (url->passwd != NULL, NULL);
/* Need to wait for the server */
if (!token)
return NULL;
-
+
switch (priv->state) {
case LOGIN_USER:
buf = g_byte_array_new ();
case LOGIN_PASSWD:
buf = g_byte_array_new ();
g_byte_array_append (buf, url->passwd, strlen (url->passwd));
-
+
sasl->authenticated = TRUE;
break;
default:
_("Unknown authentication state."));
}
}
-
+
priv->state++;
-
+
return buf;
}
typedef struct _CamelSaslLogin {
CamelSasl parent_object;
-
+
struct _CamelSaslLoginPrivate *priv;
-
+
} CamelSaslLogin;
typedef struct _CamelSaslLoginClass {
CamelSaslClass parent_class;
-
+
} CamelSaslLoginClass;
camel_sasl_ntlm_class_init (CamelSaslNTLMClass *camel_sasl_ntlm_class)
{
CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (camel_sasl_ntlm_class);
-
+
parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ()));
-
+
/* virtual method overload */
camel_sasl_class->challenge = ntlm_challenge;
}
}
/* MD4 */
-static void md4sum (const unsigned char *in,
- int nbytes,
+static void md4sum (const unsigned char *in,
+ int nbytes,
unsigned char digest[16]);
/* DES */
}
-/*
+/*
* MD4 encoder. (The one everyone else uses is not GPL-compatible;
* this is a reimplementation from spec.) This doesn't need to be
* efficient for our purposes, although it would be nice to fix
des (guint32 ks[16][2], unsigned char block[8])
{
guint32 left, right, work;
-
+
/* Read input block and place in left/right in big-endian order */
left = ((guint32)block[0] << 24)
| ((guint32)block[1] << 16)
| (guint32)block[7];
/* Hoey's clever initial permutation algorithm, from Outerbridge
- * (see Schneier p 478)
+ * (see Schneier p 478)
*
* The convention here is the same as Outerbridge: rotate each
* register left by 1 bit, i.e., so that "left" contains permuted
- * input bits 2, 3, 4, ... 1 and "right" contains 33, 34, 35, ... 32
+ * input bits 2, 3, 4, ... 1 and "right" contains 33, 34, 35, ... 32
* (using origin-1 numbering as in the FIPS). This allows us to avoid
* one of the two rotates that would otherwise be required in each of
* the 16 rounds.
typedef struct _CamelSaslNTLMClass {
CamelSaslClass parent_class;
-
+
} CamelSaslNTLMClass;
camel_sasl_plain_class_init (CamelSaslPlainClass *camel_sasl_plain_class)
{
CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (camel_sasl_plain_class);
-
+
parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ()));
-
+
/* virtual method overload */
camel_sasl_class->challenge = plain_challenge;
}
camel_sasl_plain_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_sasl_get_type (),
"CamelSaslPlain",
NULL,
NULL);
}
-
+
return type;
}
return NULL;
}
#endif
-
+
g_return_val_if_fail (url->passwd != NULL, NULL);
-
+
/* FIXME: make sure these are "UTF8-SAFE" */
buf = g_byte_array_new ();
g_byte_array_append (buf, "", 1);
g_byte_array_append (buf, url->user, strlen (url->user));
g_byte_array_append (buf, "", 1);
g_byte_array_append (buf, url->passwd, strlen (url->passwd));
-
+
sasl->authenticated = TRUE;
-
+
return buf;
}
typedef struct _CamelSaslPlainClass {
CamelSaslClass parent_class;
-
+
} CamelSaslPlainClass;
camel_sasl_popb4smtp_class_init (CamelSaslPOPB4SMTPClass *camel_sasl_popb4smtp_class)
{
CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (camel_sasl_popb4smtp_class);
-
+
parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ()));
-
+
/* virtual method overload */
camel_sasl_class->challenge = popb4smtp_challenge;
camel_sasl_popb4smtp_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_sasl_get_type (),
"CamelSaslPOPB4SMTP",
NULL,
NULL);
}
-
+
return type;
}
POPB4SMTP_UNLOCK(lock);
g_free(popuri);
-
+
return NULL;
}
typedef struct _CamelSaslPOPB4SMTPClass {
CamelSaslClass parent_class;
-
+
} CamelSaslPOPB4SMTPClass;
camel_sasl_class_init (CamelSaslClass *camel_sasl_class)
{
parent_class = camel_type_get_global_classfuncs (CAMEL_OBJECT_TYPE);
-
+
/* virtual method definition */
camel_sasl_class->challenge = sasl_challenge;
}
camel_sasl_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (CAMEL_OBJECT_TYPE,
"CamelSasl",
NULL,
(CamelObjectFinalizeFunc) camel_sasl_finalize);
}
-
+
return type;
}
camel_sasl_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex)
{
g_return_val_if_fail (CAMEL_IS_SASL (sasl), NULL);
-
+
return CS_CLASS (sasl)->challenge (sasl, token, ex);
}
{
GByteArray *token_binary, *ret_binary;
char *ret;
-
+
g_return_val_if_fail (CAMEL_IS_SASL (sasl), NULL);
-
+
if (token) {
guchar *data;
gsize length;
g_free (data);
} else
token_binary = NULL;
-
+
ret_binary = camel_sasl_challenge (sasl, token_binary, ex);
if (token_binary)
g_byte_array_free (token_binary, TRUE);
if (!ret_binary)
return NULL;
-
+
ret = g_base64_encode (ret_binary->data, ret_binary->len);
g_byte_array_free (ret_binary, TRUE);
camel_sasl_new (const char *service_name, const char *mechanism, CamelService *service)
{
CamelSasl *sasl;
-
+
g_return_val_if_fail (service_name != NULL, NULL);
g_return_val_if_fail (mechanism != NULL, NULL);
g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
-
+
/* We don't do ANONYMOUS here, because it's a little bit weird. */
-
+
if (!strcmp (mechanism, "CRAM-MD5"))
sasl = (CamelSasl *) camel_object_new (CAMEL_SASL_CRAM_MD5_TYPE);
else if (!strcmp (mechanism, "DIGEST-MD5"))
sasl->service_name = g_strdup (service_name);
sasl->service = service;
camel_object_ref (service);
-
+
return sasl;
}
camel_sasl_authtype_list (gboolean include_plain)
{
GList *types = NULL;
-
+
types = g_list_prepend (types, &camel_sasl_cram_md5_authtype);
types = g_list_prepend (types, &camel_sasl_digest_md5_authtype);
#ifdef HAVE_KRB5
types = g_list_prepend (types, &camel_sasl_ntlm_authtype);
if (include_plain)
types = g_list_prepend (types, &camel_sasl_plain_authtype);
-
+
return types;
}
typedef struct _CamelSasl {
CamelObject parent_object;
-
+
char *service_name;
char *mech; /* mechanism */
CamelService *service;
typedef struct _CamelSaslClass {
CamelObjectClass parent_class;
-
+
GByteArray * (*challenge) (CamelSasl *sasl, GByteArray *token, CamelException *ex);
} CamelSaslClass;
r<<=1;
m<<=5;
} while (r & 0x40);
-
+
*ptr = p;
v &= ~m;
int c, i, count=0, err;
char *word;
int flags;
-
+
/* build a regex pattern we can use to match the words, we OR them together */
if (argc>1)
g_string_append_c (match, '(');
if (argv[i]->type == ESEXP_RES_STRING) {
if (count > 0)
g_string_append_c (match, '|');
-
+
word = argv[i]->value.string;
if (type & CAMEL_SEARCH_MATCH_REGEX) {
/* no need to escape because this should already be a valid regex */
flags |= REG_NEWLINE;
err = regcomp (pattern, match->str, flags);
if (err != 0) {
- /* regerror gets called twice to get the full error string
+ /* regerror gets called twice to get the full error string
length to do proper posix error reporting */
int len = regerror (err, pattern, 0, 0);
char *buffer = g_malloc0 (len + 1);
-
+
regerror (err, pattern, buffer, len);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Regular expression compilation failed: %s: %s"),
match->str, buffer);
-
+
regfree (pattern);
}
d(printf("Built regex: '%s'\n", match->str));
g_string_free (match, TRUE);
-
+
return err;
}
{
guchar *c, last = '\0';
gint n;
-
+
for (c = (guchar *) sound; *c && !isalpha (*c); c++);
code[0] = toupper (*c);
memset (code + 1, '0', 3);
for (n = 1; *c && n < 5; c++) {
guchar ch = soundex_table[*c];
-
+
if (ch && ch != last) {
code[n++] = ch;
last = ch;
char c;
GString *word;
int truth = FALSE;
-
+
soundexify (match, mcode);
-
+
/* split the header into words, and soundexify and compare each one */
/* FIXME: Should this convert to utf8, and split based on that, and what not?
soundex only makes sense for us-ascii though ... */
-
+
word = g_string_new("");
p = header;
do {
g_string_append_c (word, c);
} while (c && !truth);
g_string_free (word, TRUE);
-
+
return truth;
}
gunichar *nuni, *puni;
gunichar u;
const unsigned char *p;
-
+
g_return_val_if_fail (haystack != NULL, NULL);
g_return_val_if_fail (needle != NULL, NULL);
-
+
if (strlen (needle) == 0)
return haystack;
if (strlen (haystack) == 0)
return NULL;
-
+
puni = nuni = g_alloca (sizeof (gunichar) * strlen (needle));
-
+
p = (const unsigned char *) needle;
while ((u = camel_utf8_getc(&p)))
*puni++ = g_unichar_tolower (u);
-
+
/* NULL means there was illegal utf-8 sequence */
if (!p)
return NULL;
-
+
p = (const unsigned char *)haystack;
while ((u = camel_utf8_getc(&p))) {
gunichar c;
-
+
c = g_unichar_tolower (u);
/* We have valid stripped char */
if (c == nuni[0]) {
const unsigned char *q = p;
gint npos = 1;
-
+
while (nuni + npos < puni) {
u = camel_utf8_getc(&q);
if (!q || !u)
return NULL;
-
- c = g_unichar_tolower (u);
+
+ c = g_unichar_tolower (u);
if (c != nuni[npos])
break;
-
+
npos++;
}
-
+
if (nuni + npos == puni)
return (const char *) p;
}
}
-
+
return NULL;
}
gunichar u1, u2 = 0;
const unsigned char *s1 = (const unsigned char *)ps1;
const unsigned char *s2 = (const unsigned char *)ps2;
-
+
CAMEL_SEARCH_COMPARE (s1, s2, NULL);
-
+
u1 = camel_utf8_getc(&s1);
u2 = camel_utf8_getc(&s2);
while (u1 && u2) {
return -1;
else if (u1 > u2)
return 1;
-
+
u1 = camel_utf8_getc(&s1);
u2 = camel_utf8_getc(&s2);
}
-
+
/* end of one of the strings ? */
CAMEL_SEARCH_COMPARE (u1, u2, 0);
-
+
/* if we have invalid utf8 sequence ? */
CAMEL_SEARCH_COMPARE (s1, s2, NULL);
-
+
return 0;
}
gunichar u1, u2 = 0;
const unsigned char *s1 = (const unsigned char *)ps1;
const unsigned char *s2 = (const unsigned char *)ps2;
-
+
CAMEL_SEARCH_COMPARE (s1, s2, NULL);
-
+
u1 = camel_utf8_getc(&s1);
u2 = camel_utf8_getc(&s2);
while (len > 0 && u1 && u2) {
return -1;
else if (u1 > u2)
return 1;
-
+
len--;
u1 = camel_utf8_getc(&s1);
u2 = camel_utf8_getc(&s2);
}
-
+
if (len == 0)
return 0;
-
+
/* end of one of the strings ? */
CAMEL_SEARCH_COMPARE (u1, u2, 0);
-
+
/* if we have invalid utf8 sequence ? */
CAMEL_SEARCH_COMPARE (s1, s2, NULL);
-
+
return 0;
}
const unsigned char *p;
int vlen, mlen;
gunichar c;
-
+
if (how == CAMEL_SEARCH_MATCH_SOUNDEX)
return header_soundex (value, match);
mlen = strlen(match);
if (vlen < mlen)
return FALSE;
-
+
/* from dan the man, if we have mixed case, perform a case-sensitive match,
otherwise not */
p = (const unsigned char *)match;
return FALSE;
}
}
-
+
switch (how) {
case CAMEL_SEARCH_MATCH_EXACT:
return camel_ustrcasecmp(value, match) == 0;
default:
break;
}
-
+
return FALSE;
}
for (i=0; !truth && camel_internet_address_get(cia, i, &name, &addr);i++)
truth = (name && header_match(name, match, how)) || (addr && header_match(addr, match, how));
-
+
camel_object_unref (cia);
break;
}
CamelDataWrapper *containee;
int truth = FALSE;
int parts, i;
-
+
containee = camel_medium_get_content_object (CAMEL_MEDIUM (object));
-
+
if (containee == NULL)
return FALSE;
-
+
/* using the object types is more accurate than using the mime/types */
if (CAMEL_IS_MULTIPART (containee)) {
parts = camel_multipart_get_number (CAMEL_MULTIPART (containee));
} else if (camel_content_type_is(CAMEL_DATA_WRAPPER (containee)->mime_type, "text", "*")) {
/* for all other text parts, we look inside, otherwise we dont care */
CamelStreamMem *mem = (CamelStreamMem *)camel_stream_mem_new ();
-
+
camel_data_wrapper_write_to_stream (containee, CAMEL_STREAM (mem));
camel_stream_write (CAMEL_STREAM (mem), "", 1);
truth = regexec (pattern, (char *) mem->buffer->data, 0, NULL, 0) == 0;
camel_object_unref (mem);
}
-
+
return truth;
}
guint32 c;
int inquote = 0;
- words = g_malloc0(sizeof(*words));
+ words = g_malloc0(sizeof(*words));
w = g_string_new("");
do {
struct _camel_search_words *words;
guint32 c;
- words = g_malloc0(sizeof(*words));
+ words = g_malloc0(sizeof(*words));
for (i=0;i<wordin->len;i++) {
if ((wordin->words[i]->type & CAMEL_SEARCH_WORD_COMPLEX) == 0) {
camel_service_class_init (CamelServiceClass *camel_service_class)
{
CamelObjectClass *object_class = CAMEL_OBJECT_CLASS (camel_service_class);
-
+
parent_class = camel_type_get_global_classfuncs (CAMEL_OBJECT_TYPE);
-
+
/* virtual method overloading */
object_class->setv = service_setv;
object_class->getv = service_getv;
-
+
/* virtual method definition */
camel_service_class->construct = construct;
camel_service_class->connect = service_connect;
camel_service_init (void *o, void *k)
{
CamelService *service = o;
-
+
service->priv = g_malloc0(sizeof(*service->priv));
g_static_rec_mutex_init(&service->priv->connect_lock);
g_static_mutex_init(&service->priv->connect_op_lock);
if (service->status == CAMEL_SERVICE_CONNECTED) {
CamelException ex;
-
+
camel_exception_init (&ex);
CSERV_CLASS (service)->disconnect (service, TRUE, &ex);
if (camel_exception_is_set (&ex)) {
}
camel_exception_clear (&ex);
}
-
+
if (service->url)
camel_url_free (service->url);
if (service->session)
camel_object_unref (service->session);
-
+
g_static_rec_mutex_free (&service->priv->connect_lock);
g_static_mutex_free (&service->priv->connect_op_lock);
-
+
g_free (service->priv);
}
camel_service_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type =
camel_type_register (CAMEL_OBJECT_TYPE,
(CamelObjectInitFunc) camel_service_init,
camel_service_finalize );
}
-
+
return type;
}
gboolean reconnect = FALSE;
guint32 tag;
int i;
-
+
for (i = 0; i < args->argc; i++) {
tag = args->argv[i].tag;
-
+
/* make sure this is an arg we're supposed to handle */
if ((tag & CAMEL_ARG_TAG) <= CAMEL_SERVICE_ARG_FIRST ||
(tag & CAMEL_ARG_TAG) >= CAMEL_SERVICE_ARG_FIRST + 100)
continue;
-
+
if (tag == CAMEL_SERVICE_USERNAME) {
/* set the username */
if (strcmp (url->user, args->argv[i].ca_str) != 0) {
/* error? */
continue;
}
-
+
/* let our parent know that we've handled this arg */
camel_argv_ignore (args, i);
}
-
+
/* FIXME: what if we are in the process of connecting? */
if (reconnect && service->status == CAMEL_SERVICE_CONNECTED) {
/* reconnect the service using the new URL */
if (camel_service_disconnect (service, TRUE, ex))
camel_service_connect (service, ex);
}
-
+
return CAMEL_OBJECT_CLASS (parent_class)->setv (object, ex, args);
}
CamelURL *url = service->url;
guint32 tag;
int i;
-
+
for (i = 0; i < args->argc; i++) {
tag = args->argv[i].tag;
-
+
/* make sure this is an arg we're supposed to handle */
if ((tag & CAMEL_ARG_TAG) <= CAMEL_SERVICE_ARG_FIRST ||
(tag & CAMEL_ARG_TAG) >= CAMEL_SERVICE_ARG_FIRST + 100)
continue;
-
+
switch (tag) {
case CAMEL_SERVICE_USERNAME:
/* get the username */
break;
}
}
-
+
return CAMEL_OBJECT_CLASS (parent_class)->getv (object, ex, args);
}
construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
{
char *err, *url_string;
-
+
if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_USER) &&
(url->user == NULL || url->user[0] == '\0')) {
err = _("URL '%s' needs a username component");
err = _("URL '%s' needs a path component");
goto fail;
}
-
+
service->provider = provider;
service->url = camel_url_copy(url);
service->session = session;
camel_object_ref (session);
-
+
service->status = CAMEL_SERVICE_DISCONNECTED;
return;
{
g_return_if_fail (CAMEL_IS_SERVICE (service));
g_return_if_fail (CAMEL_IS_SESSION (session));
-
+
CSERV_CLASS (service)->construct (service, session, provider, url, ex);
}
{
gboolean ret = FALSE;
gboolean unreg = FALSE;
-
+
g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE);
g_return_val_if_fail (service->session != NULL, FALSE);
g_return_val_if_fail (service->url != NULL, FALSE);
-
+
CAMEL_SERVICE_REC_LOCK (service, connect_lock);
-
+
if (service->status == CAMEL_SERVICE_CONNECTED) {
CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
return TRUE;
if (service->connect_op) {
if (unreg)
camel_operation_unregister (service->connect_op);
-
+
camel_operation_unref (service->connect_op);
service->connect_op = NULL;
}
CAMEL_SERVICE_UNLOCK (service, connect_op_lock);
CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
-
+
return ret;
}
/*service->connect_level--;*/
/* We let people get away with not having a disconnect
- * function -- CamelMboxStore, for example.
+ * function -- CamelMboxStore, for example.
*/
-
+
return TRUE;
}
int unreg = FALSE;
CAMEL_SERVICE_REC_LOCK (service, connect_lock);
-
+
if (service->status != CAMEL_SERVICE_DISCONNECTED
&& service->status != CAMEL_SERVICE_DISCONNECTING) {
CAMEL_SERVICE_LOCK (service, connect_op_lock);
service->connect_op = NULL;
CAMEL_SERVICE_UNLOCK (service, connect_op_lock);
}
-
+
CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
-
+
service->status = CAMEL_SERVICE_DISCONNECTED;
return res;
}
w(g_warning ("CamelService::get_name not implemented for `%s'",
camel_type_to_name (CAMEL_OBJECT_GET_TYPE (service))));
return g_strdup ("???");
-}
+}
/**
{
g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
g_return_val_if_fail (service->url, NULL);
-
+
return CSERV_CLASS (service)->get_name (service, brief);
}
CamelURL *url = service->url;
GString *gpath;
char *path;
-
+
/* A sort of ad-hoc default implementation that works for our
* current set of services.
*/
-
+
gpath = g_string_new (service->provider->protocol);
if (CAMEL_PROVIDER_ALLOWS (prov, CAMEL_URL_PART_USER)) {
if (CAMEL_PROVIDER_ALLOWS (prov, CAMEL_URL_PART_HOST)) {
g_string_append_printf (gpath, "/%s@%s",
url->user ? url->user : "",
url->host ? url->host : "");
-
+
if (url->port)
g_string_append_printf (gpath, ":%d", url->port);
} else {
g_string_append_printf (gpath, "/%s%s",
CAMEL_PROVIDER_NEEDS (prov, CAMEL_URL_PART_HOST) ? "" : "@",
url->host ? url->host : "");
-
+
if (url->port)
g_string_append_printf (gpath, ":%d", url->port);
}
-
+
if (CAMEL_PROVIDER_NEEDS (prov, CAMEL_URL_PART_PATH))
g_string_append_printf (gpath, "%s%s", *url->path == '/' ? "" : "/", url->path);
-
+
path = gpath->str;
g_string_free (gpath, FALSE);
-
+
return path;
-}
+}
/**
* camel_service_get_path:
{
g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
g_return_val_if_fail (service->url, NULL);
-
+
return CSERV_CLASS (service)->get_path (service);
}
camel_service_query_auth_types (CamelService *service, CamelException *ex)
{
GList *ret;
-
+
/* note that we get the connect lock here, which means the callee
must not call the connect functions itself */
CAMEL_SERVICE_REC_LOCK (service, connect_lock);
ret = CSERV_CLASS (service)->query_auth_types (service, ex);
CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
-
+
return ret;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-service.h : Abstract class for an email service */
-/*
+/*
*
* Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
* Michael Zucchi <notzed@ximian.com>
*
* Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
CamelURL *url,
CamelException *ex);
- gboolean (*connect) (CamelService *service,
+ gboolean (*connect) (CamelService *service,
CamelException *ex);
gboolean (*disconnect) (CamelService *service,
gboolean clean,
char *name; /* user-friendly name */
char *description;
char *authproto;
-
+
gboolean need_password; /* needs a password to authenticate */
} CamelServiceAuthType;
void camel_service_construct (CamelService *service,
CamelSession *session,
CamelProvider *provider,
- CamelURL *url,
+ CamelURL *url,
CamelException *ex);
-gboolean camel_service_connect (CamelService *service,
+gboolean camel_service_connect (CamelService *service,
CamelException *ex);
gboolean camel_service_disconnect (CamelService *service,
gboolean clean,
session->online = TRUE;
session->network_state = TRUE;
session->priv = g_malloc0(sizeof(*session->priv));
-
+
session->priv->lock = g_mutex_new();
session->priv->thread_lock = g_mutex_new();
session->priv->thread_id = 1;
{
CamelSession *session = (CamelSession *)o;
GThreadPool *thread_pool = session->priv->thread_pool;
-
+
g_hash_table_destroy(session->priv->thread_active);
if (thread_pool != NULL) {
}
g_free(session->storage_path);
-
+
g_mutex_free(session->priv->lock);
g_mutex_free(session->priv->thread_lock);
-
+
g_free(session->priv);
}
/* virtual method definition */
camel_session_class->get_service = get_service;
camel_session_class->get_storage_path = get_storage_path;
-
+
camel_session_class->thread_msg_new = session_thread_msg_new;
camel_session_class->thread_msg_free = session_thread_msg_free;
camel_session_class->thread_queue = session_thread_queue;
CamelProvider *provider;
CamelService *service;
CamelException internal_ex;
-
+
url = camel_url_new (url_string, ex);
if (!url)
return NULL;
url->protocol);
provider = NULL;
}
-
+
if (!provider) {
camel_url_free (url);
return NULL;
*/
if (url->path && !CAMEL_PROVIDER_ALLOWS (provider, CAMEL_URL_PART_PATH))
camel_url_set_path (url, NULL);
-
+
/* Now look up the service in the provider's cache */
service = camel_object_bag_reserve(provider->service_cache[type], url);
if (service == NULL) {
path = g_strdup_printf ("%s/%s", session->storage_path, p);
g_free (p);
-#ifdef G_OS_WIN32
+#ifdef G_OS_WIN32
if (g_access (path, F_OK) == 0)
#else
if (access (path, F_OK) == 0)
* If #CAMEL_SESSION_PASSWORD_STATIC is set, it means the password returned
* will be stored statically by the caller automatically, for the current
* session.
- *
+ *
* The authenticator should set @ex to #CAMEL_EXCEPTION_USER_CANCEL if
* the user did not provide the information. The caller must #g_free
* the information returned when it is done with it.
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
g_return_val_if_fail (prompt != NULL, NULL);
g_return_val_if_fail (item != NULL, NULL);
-
+
return CS_CLASS (session)->get_password (session, service, domain, prompt, item, flags, ex);
}
CAMEL_SESSION_UNLOCK(session, thread_lock);
d(printf("free msg, ops->free = %p\n", msg->ops->free));
-
+
if (msg->ops->free)
msg->ops->free(session, msg);
if (msg->op)
* @session: a #CamelSession object
* @ops: thread operations
* @size: number of bytes
- *
+ *
* Create a new thread message, using ops as the receive/reply/free
* ops, of @size bytes.
*
g_assert(CAMEL_IS_SESSION(session));
g_assert(ops != NULL);
g_assert(size >= sizeof(CamelSessionThreadMsg));
-
+
return CS_CLASS (session)->thread_msg_new(session, ops, size);
}
* camel_session_thread_msg_free:
* @session: a #CamelSession object
* @msg: a #CamelSessionThreadMsg
- *
+ *
* Free a @msg. Note that the message must have been allocated using
* msg_new, and must nto have been submitted to any queue function.
**/
* @session: a #CamelSession object
* @msg: a #CamelSessionThreadMsg
* @flags: queue type flags, currently 0.
- *
+ *
* Queue a thread message in another thread for processing.
* The operation should be (but needn't) run in a queued manner
* with other operations queued in this manner.
- *
+ *
* Returns the id of the operation queued
**/
int
* camel_session_thread_wait:
* @session: a #CamelSession object
* @id: id of the operation to wait on
- *
+ *
* Wait on an operation to complete (by id).
**/
void
camel_session_thread_wait(CamelSession *session, int id)
{
g_assert(CAMEL_IS_SESSION(session));
-
+
if (id == -1)
return;
/**
* camel_session_check_junk:
* @session: a #CamelSession object
- *
+ *
* Do we have to check incoming messages to be junk?
*
* Returns whether or not we are checking incoming messages for junk
* camel_session_set_check_junk:
* @session: a #CamelSession object
* @check_junk: state
- *
+ *
* Set check_junk flag, if set, incoming mail will be checked for being junk.
**/
void
camel_session_get_network_state (CamelSession *session)
{
g_return_val_if_fail (CAMEL_IS_SESSION(session), FALSE);
-
+
return session->network_state;
}
camel_session_set_network_state (CamelSession *session, gboolean network_state)
{
g_return_if_fail (CAMEL_IS_SESSION(session));
-
+
session->network_state = network_state;
}
CamelFilterDriver * (*get_filter_driver) (CamelSession *session,
const char *type,
CamelException *ex);
-
+
/* mechanism for creating and maintaining multiple threads of control */
void *(*thread_msg_new)(CamelSession *session, CamelSessionThreadOps *ops, unsigned int size);
void (*thread_msg_free)(CamelSession *session, CamelSessionThreadMsg *msg);
const char *url_string,
CamelProviderType type,
CamelException *ex);
-CamelService * camel_session_get_service_connected (CamelSession *session,
+CamelService * camel_session_get_service_connected (CamelSession *session,
const char *url_string,
- CamelProviderType type,
+ CamelProviderType type,
CamelException *ex);
#define camel_session_get_store(session, url_string, ex) \
* Michael Zucchi <notzed@ximian.com>
*
* The Initial Developer of the Original Code is Netscape
- * Communications Corporation. Portions created by Netscape are
+ * Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
{
CamelCipherContext *cipher;
CamelSMIMEContext *ctx;
-
+
g_return_val_if_fail(CAMEL_IS_SESSION(session), NULL);
-
+
ctx =(CamelSMIMEContext *) camel_object_new(camel_smime_context_get_type());
-
+
cipher =(CamelCipherContext *) ctx;
cipher->session = session;
camel_object_ref(session);
-
+
return cipher;
}
camel_data_wrapper_decode_to_stream(camel_medium_get_content_object((CamelMedium *)part), (CamelStream *)istream);
camel_stream_reset((CamelStream *)istream);
- dec = NSS_CMSDecoder_Start(NULL,
+ dec = NSS_CMSDecoder_Start(NULL,
NULL, NULL,
NULL, NULL, /* password callback */
NULL, NULL); /* decrypt key callback */
-
+
NSS_CMSDecoder_Update(dec, istream->buffer->data, istream->buffer->len);
camel_object_unref(istream);
-
+
cmsg = NSS_CMSDecoder_Finish(dec);
if (cmsg) {
if (NSS_CMSMessage_IsSigned(cmsg)) {
printf("message is signed\n");
flags |= CAMEL_SMIME_SIGNED;
}
-
+
if (NSS_CMSMessage_IsEncrypted(cmsg)) {
printf("message is encrypted\n");
flags |= CAMEL_SMIME_ENCRYPTED;
else if (!strcmp(id, "sha1"))
return CAMEL_CIPHER_HASH_SHA1;
}
-
+
return CAMEL_CIPHER_HASH_DEFAULT;
}
goto fail;
}
- enc = NSS_CMSEncoder_Start(cmsg,
+ enc = NSS_CMSEncoder_Start(cmsg,
sm_write_stream, ostream, /* DER output callback */
NULL, NULL, /* destination storage */
NULL, NULL, /* password callback */
mps->contentraw = istream;
camel_stream_reset(istream);
camel_object_ref(istream);
-
+
camel_medium_set_content_object((CamelMedium *)opart, (CamelDataWrapper *)mps);
} else {
ct = camel_content_type_new("application", "x-pkcs7-mime");
camel_content_type_set_param(ct, "smime-type", "signed-data");
camel_data_wrapper_set_mime_type_field(dw, ct);
camel_content_type_unref(ct);
-
+
camel_medium_set_content_object((CamelMedium *)opart, dw);
camel_mime_part_set_filename(opart, "smime.p7m");
camel_mime_part_set_disposition(opart, "attachment");
camel_mime_part_set_encoding(opart, CAMEL_TRANSFER_ENCODING_BASE64);
}
-
+
camel_object_unref(dw);
-fail:
+fail:
camel_object_unref(ostream);
camel_object_unref(istream);
}
digestalgs = NSS_CMSSignedData_GetDigestAlgs(sigd);
-
+
digcx = NSS_CMSDigestContext_StartMultiple(digestalgs);
if (digcx == NULL) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot calculate digests"));
/* check for certs-only message */
nsigners = NSS_CMSSignedData_SignerInfoCount(sigd);
if (nsigners == 0) {
-
+
/* already imported certs above, not sure what usage we should use here or if this isn't handled above */
if (NSS_CMSSignedData_VerifyCertsOnly(sigd, p->certdb, certUsageEmailSigner) != SECSuccess) {
g_string_printf(description, _("Certificate is the only message, cannot verify certificates"));
for (j = 0; j < nsigners; j++) {
NSSCMSSignerInfo *si;
char *cn, *em;
-
+
si = NSS_CMSSignedData_GetSignerInfo(sigd, j);
NSS_CMSSignedData_VerifySignerInfo(sigd, j, p->certdb, certUsageEmailSigner);
-
+
status = NSS_CMSSignerInfo_GetVerificationStatus(si);
-
+
cn = NSS_CMSSignerInfo_GetSignerCommonName(si);
em = NSS_CMSSignerInfo_GetSignerEmailAddress(si);
-
+
g_string_append_printf(description, _("Signer: %s <%s>: %s\n"),
cn?cn:"<unknown>", em?em:"<unknown>",
sm_status_description(status));
-
+
camel_cipher_validity_add_certinfo(valid, CAMEL_CIPHER_VALIDITY_SIGN, cn, em);
if (cn)
PORT_Free(cn);
if (em)
PORT_Free(em);
-
+
if (status != NSSCMSVS_GoodSignature)
camel_cipher_validity_set_valid(valid, FALSE);
}
/* FIXME: we should stream this to the decoder */
mem = (CamelStreamMem *)camel_stream_mem_new();
-
+
if (camel_content_type_is(ct, "multipart", "signed")) {
CamelMultipart *mps = (CamelMultipart *)dw;
goto fail;
}
- dec = NSS_CMSDecoder_Start(NULL,
+ dec = NSS_CMSDecoder_Start(NULL,
NULL, NULL, /* content callback */
NULL, NULL, /* password callback */
NULL, NULL); /* decrypt key callback */
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Decoder failed"));
goto fail;
}
-
+
valid = sm_verify_cmsg(context, cmsg, constream, ex);
-
+
NSS_CMSMessage_Destroy(cmsg);
fail:
camel_object_unref(mem);
for (i=0;recipient_certs[i];i++)
CERT_DestroyCertificate(recipient_certs[i]);
PORT_FreeArena(poolp, PR_FALSE);
-
+
dw = camel_data_wrapper_new();
camel_data_wrapper_construct_from_stream(dw, ostream);
camel_object_unref(ostream);
camel_data_wrapper_decode_to_stream(camel_medium_get_content_object((CamelMedium *)ipart), (CamelStream *)istream);
camel_stream_reset((CamelStream *)istream);
- dec = NSS_CMSDecoder_Start(NULL,
+ dec = NSS_CMSDecoder_Start(NULL,
sm_write_stream, ostream, /* content callback */
NULL, NULL,
NULL, NULL); /* decrypt key callback */
sm_import_keys(CamelCipherContext *context, CamelStream *istream, CamelException *ex)
{
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("import keys: unimplemented"));
-
+
return -1;
}
sm_export_keys(CamelCipherContext *context, GPtrArray *keys, CamelStream *ostream, CamelException *ex)
{
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("export keys: unimplemented"));
-
+
return -1;
}
camel_smime_context_class_init(CamelSMIMEContextClass *klass)
{
CamelCipherContextClass *cipher_class = CAMEL_CIPHER_CONTEXT_CLASS(klass);
-
+
parent_class = CAMEL_CIPHER_CONTEXT_CLASS(camel_type_get_global_classfuncs(camel_cipher_context_get_type()));
-
+
cipher_class->hash_to_id = sm_hash_to_id;
cipher_class->id_to_hash = sm_id_to_hash;
cipher_class->sign = sm_sign;
camel_smime_context_init(CamelSMIMEContext *context)
{
CamelCipherContext *cipher =(CamelCipherContext *) context;
-
+
cipher->sign_protocol = "application/x-pkcs7-signature";
cipher->encrypt_protocol = "application/x-pkcs7-mime";
cipher->key_protocol = "application/x-pkcs7-signature";
camel_smime_context_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_cipher_context_get_type(),
"CamelSMIMEContext",
(CamelObjectInitFunc) camel_smime_context_init,
(CamelObjectFinalizeFunc) camel_smime_context_finalise);
}
-
+
return type;
}
s->folders = g_ptr_array_new();
s->folders_path = g_hash_table_new(g_str_hash, g_str_equal);
-
+
p->summary_lock = g_mutex_new();
p->io_lock = g_mutex_new();
p->alloc_lock = g_mutex_new();
if (s->store_info_chunks)
e_memchunk_destroy(s->store_info_chunks);
-
+
g_mutex_free(p->summary_lock);
g_mutex_free(p->io_lock);
g_mutex_free(p->alloc_lock);
g_mutex_free(p->ref_lock);
-
+
g_free(p);
}
camel_store_summary_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_object_get_type (), "CamelStoreSummary",
sizeof (CamelStoreSummary),
(CamelObjectInitFunc) camel_store_summary_init,
(CamelObjectFinalizeFunc) camel_store_summary_finalise);
}
-
+
return type;
}
* camel_store_summary_new:
*
* Create a new #CamelStoreSummary object.
- *
+ *
* Returns a new #CamelStoreSummary object
**/
CamelStoreSummary *
* camel_store_summary_set_filename:
* @summary: a #CamelStoreSummary
* @filename: a filename
- *
+ *
* Set the filename where the summary will be loaded to/saved from.
**/
void
/**
* camel_store_summary_count:
* @summary: a #CamelStoreSummary object
- *
+ *
* Get the number of summary items stored in this summary.
- *
+ *
* Returns the number of items int he summary.
**/
int
* camel_store_summary_index:
* @summary: a #CamelStoreSummary object
* @index: record index
- *
+ *
* Retrieve a summary item by index number.
*
* A referenced to the summary item is returned, which may be ref'd or
* free'd as appropriate.
*
* It must be freed using #camel_store_summary_info_free.
- *
+ *
* Returns the summary item, or %NULL if @index is out of range
**/
CamelStoreInfo *
/**
* camel_store_summary_array:
* @summary: a #CamelStoreSummary object
- *
+ *
* Obtain a copy of the summary array. This is done atomically,
* so cannot contain empty entries.
*
CamelStoreInfo *info;
GPtrArray *res = g_ptr_array_new();
int i;
-
+
CAMEL_STORE_SUMMARY_LOCK(s, ref_lock);
CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
* camel_store_summary_array_free:
* @summary: a #CamelStoreSummary object
* @array: the summary array as gotten from #camel_store_summary_array
- *
+ *
* Free the folder summary array.
**/
void
* camel_store_summary_path:
* @summary: a #CamelStoreSummary object
* @path: path to the item
- *
+ *
* Retrieve a summary item by path name.
*
* A referenced to the summary item is returned, which may be ref'd or
}
CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
-
+
if (fclose (in) != 0)
return -1;
fclose (in);
s->flags |= ~CAMEL_STORE_SUMMARY_DIRTY;
errno = i;
-
+
return -1;
}
/**
* camel_store_summary_save:
* @summary: a #CamelStoreSummary object
- *
+ *
* Writes the summary to disk. The summary is only written if changes
* have occured.
- *
+ *
* Returns %0 on succes or %-1 on fail
**/
int
}
CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
-
+
if (fflush (out) != 0 || fsync (fileno (out)) == -1) {
i = errno;
fclose (out);
errno = i;
return -1;
}
-
+
if (fclose (out) != 0)
return -1;
/**
* camel_store_summary_header_load:
* @summary: a #CamelStoreSummary object
- *
+ *
* Only load the header information from the summary,
* keep the rest on disk. This should only be done on
* a fresh summary object.
- *
+ *
* Returns %0 on success or %-1 on fail
**/
int
CAMEL_STORE_SUMMARY_LOCK(s, io_lock);
ret = ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_load(s, in);
CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
-
+
fclose(in);
s->flags &= ~CAMEL_STORE_SUMMARY_DIRTY;
return ret;
* camel_store_summary_add:
* @summary: a #CamelStoreSummary object
* @info: a #CamelStoreInfo
- *
+ *
* Adds a new @info record to the summary. If @info->uid is %NULL,
* then a new uid is automatically re-assigned by calling
* #camel_store_summary_next_uid_string.
* camel_store_summary_add_from_path:
* @summary: a #CamelStoreSummary object
* @path: item path
- *
+ *
* Build a new info record based on the name, and add it to the summary.
*
* Returns the newly added record
* camel_store_summary_info_new_from_path:
* @summary: a #CamelStoreSummary object
* @path: item path
- *
+ *
* Create a new info record from a name.
*
* This info record MUST be freed using
* camel_store_summary_info_free:
* @summary: a #CamelStoreSummary object
* @info: a #CamelStoreInfo
- *
+ *
* Unref and potentially free @info, and all associated memory.
**/
void
CAMEL_STORE_SUMMARY_UNLOCK(s, ref_lock);
- ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->store_info_free(s, info);
+ ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->store_info_free(s, info);
}
* camel_store_summary_info_ref:
* @summary: a #CamelStoreSummary object
* @info: a #CamelStoreInfo
- *
+ *
* Add an extra reference to @info.
**/
void
/**
* camel_store_summary_touch:
* @summary: a #CamelStoreSummary object
- *
+ *
* Mark the summary as changed, so that a save will force it to be
* written back to disk.
**/
/**
* camel_store_summary_clear:
* @summary: a #CamelStoreSummary object
- *
+ *
* Empty the summary contents.
**/
void
* camel_store_summary_remove:
* @summary: a #CamelStoreSummary object
* @info: a #CamelStoreInfo
- *
+ *
* Remove a specific @info record from the summary.
**/
void
* camel_store_summary_remove_path:
* @summary: a #CamelStoreSummary object
* @path: item path
- *
+ *
* Remove a specific info record from the summary, by @path.
**/
void
* camel_store_summary_remove_index:
* @summary: a #CamelStoreSummary object
* @index: item index
- *
+ *
* Remove a specific info record from the summary, by index.
**/
void
/**
* camel_store_summary_info_new:
* @summary: a #CamelStoreSummary object
- *
+ *
* Allocate a new #CamelStoreInfo, suitable for adding to this
* summary.
- *
+ *
* Returns the newly allocated #CamelStoreInfo
**/
CamelStoreInfo *
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-store.c : Abstract class for an email store */
-/*
+/*
* Authors:
* Bertrand Guiheneuf <bertrand@helixcode.com>
* Dan Winship <danw@ximian.com>
*
* Copyright 1999-2003 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
{
CamelObjectClass *camel_object_class = CAMEL_OBJECT_CLASS (camel_store_class);
CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS(camel_store_class);
-
+
parent_class = CAMEL_SERVICE_CLASS (camel_type_get_global_classfuncs (camel_service_get_type ()));
-
+
/* virtual method definition */
camel_store_class->hash_folder_name = g_str_hash;
camel_store_class->compare_folder_name = g_str_equal;
camel_store_class->subscribe_folder = subscribe_folder;
camel_store_class->unsubscribe_folder = unsubscribe_folder;
camel_store_class->noop = noop;
-
+
/* virtual method overload */
camel_service_class->construct = construct;
-
+
camel_object_class->setv = store_setv;
camel_object_class->getv = store_getv;
-
+
camel_object_class_add_event(camel_object_class, "folder_opened", NULL);
camel_object_class_add_event(camel_object_class, "folder_created", NULL);
camel_object_class_add_event(camel_object_class, "folder_deleted", NULL);
(CamelCopyFunc)g_strdup, g_free);
} else
store->folders = NULL;
-
+
/* set vtrash and vjunk on by default */
store->flags = CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK;
store->mode = CAMEL_STORE_READ|CAMEL_STORE_WRITE;
if (store->folders)
camel_object_bag_destroy(store->folders);
-
+
g_static_rec_mutex_free (&store->priv->folder_lock);
-
+
g_free (store->priv);
}
{
w(g_warning ("CamelStore::get_folder not implemented for `%s'",
camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store))));
-
+
camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_INVALID,
_("Cannot get folder: Invalid operation on this store"));
-
+
return NULL;
}
-/**
+/**
* camel_store_get_folder:
* @store: a #CamelStore object
* @folder_name: name of the folder to get
* @ex: a #CamelException
*
* Get a specific folder object from the store by name.
- *
+ *
* Returns the folder corresponding to the path @folder_name.
**/
CamelFolder *
camel_store_get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex)
{
CamelFolder *folder = NULL;
-
+
g_return_val_if_fail (folder_name != NULL, NULL);
-
+
/* O_EXCL doesn't make sense if we aren't requesting to also create the folder if it doesn't exist */
if (!(flags & CAMEL_STORE_FOLDER_CREATE))
flags &= ~CAMEL_STORE_FOLDER_EXCL;
-
+
if (store->folders) {
/* Try cache first. */
folder = camel_object_bag_reserve(store->folders, folder_name);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot create folder `%s': folder exists"),
folder_name);
-
+
camel_object_unref (folder);
return NULL;
}
}
-
+
if (!folder) {
if ((store->flags & CAMEL_STORE_VTRASH) && strcmp(folder_name, CAMEL_VTRASH_NAME) == 0) {
folder = CS_CLASS(store)->get_trash(store, ex);
folder = CS_CLASS (store)->get_folder(store, folder_name, flags, ex);
if (folder) {
CamelVeeFolder *vfolder;
-
+
if ((store->flags & CAMEL_STORE_VTRASH)
&& (vfolder = camel_object_bag_get(store->folders, CAMEL_VTRASH_NAME))) {
camel_vee_folder_add_folder(vfolder, folder);
{
w(g_warning ("CamelStore::create_folder not implemented for `%s'",
camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store))));
-
+
camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_INVALID,
_("Cannot create folder: Invalid operation on this store"));
-
+
return NULL;
}
-/**
+/**
* camel_store_create_folder:
* @store: a #CamelStore object
* @parent_name: name of the new folder's parent, or %NULL
* @folder_name: name of the folder to create
* @ex: a #CamelException
- *
+ *
* Creates a new folder as a child of an existing folder.
* @parent_name can be %NULL to create a new top-level folder.
*
if (store->folders
&& (folder = camel_object_bag_get(store->folders, folder_name))) {
CamelVeeFolder *vfolder;
-
+
if ((store->flags & CAMEL_STORE_VTRASH)
&& (vfolder = camel_object_bag_get(store->folders, CAMEL_VTRASH_NAME))) {
camel_vee_folder_remove_folder(vfolder, folder);
camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store))));
}
-/**
+/**
* camel_store_delete_folder:
* @store: a #CamelStore object
* @folder_name: name of the folder to delete
* @ex: a #CamelException
- *
+ *
* Deletes the named folder. The folder must be empty.
**/
void
cs_delete_cached_folder(store, folder_name);
else
camel_exception_xfer(ex, &local);
-
+
CAMEL_STORE_UNLOCK(store, folder_lock);
}
* @old_namein: the current name of the folder
* @new_name: the new name of the folder
* @ex: a #CamelException
- *
+ *
* Rename a named folder to a new name.
**/
void
/* Emit renamed signal */
if (store->flags & CAMEL_STORE_SUBSCRIPTIONS)
flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
-
+
reninfo.old_base = (char *)old_name;
reninfo.new = ((CamelStoreClass *)((CamelObject *)store)->klass)->get_folder_info(store, new_name, flags, ex);
if (reninfo.new != NULL) {
return CS_CLASS (store)->get_folder (store, "inbox", 0, ex);
}
-/**
+/**
* camel_store_get_inbox:
* @store: a #CamelStore object
* @ex: a #CamelException
return get_special(store, CAMEL_VTRASH_FOLDER_JUNK);
}
-/**
+/**
* camel_store_get_trash:
* @store: a #CamelStore object
* @ex: a #CamelException
return camel_store_get_folder(store, CAMEL_VTRASH_NAME, 0, ex);
}
-/**
+/**
* camel_store_get_junk:
* @store: a #CamelStore object
* @ex: a #CamelException
{
w(g_warning ("CamelStore::get_folder_info not implemented for `%s'",
camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store))));
-
+
return NULL;
}
CamelFolderInfo *fi, *vinfo, *parent;
char *uri, *path;
CamelURL *url;
-
+
g_return_if_fail (info != NULL);
-
+
parent = NULL;
for (fi = info; fi; fi = fi->next) {
if (!strcmp (fi->full_name, name))
break;
parent = fi;
}
-
+
/* create our vTrash/vJunk URL */
url = camel_url_new (info->uri, NULL);
if (((CamelService *) store)->provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) {
camel_url_set_path (url, path);
g_free (path);
}
-
+
uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
camel_url_free (url);
-
+
if (fi) {
/* We're going to replace the physical Trash/Junk folder with our vTrash/vJunk folder */
vinfo = fi;
} else {
/* There wasn't a Trash/Junk folder so create a new folder entry */
vinfo = g_new0 (CamelFolderInfo, 1);
-
+
g_assert(parent != NULL);
-
+
vinfo->flags |= CAMEL_FOLDER_NOINFERIORS | CAMEL_FOLDER_SUBSCRIBED;
-
+
/* link it into the right spot */
vinfo->next = parent->next;
parent->next = vinfo;
}
-
+
/* Fill in the new fields */
vinfo->flags |= flags;
vinfo->full_name = g_strdup (name);
* determine that information quickly. If @flags includes
* #CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL, don't include special virtual
* folders (such as vTrash or vJunk).
- *
+ *
* The CAMEL_STORE_FOLDER_INFO_FAST flag should be considered
* deprecated; most backends will behave the same whether it is
* supplied or not. The only guaranteed way to get updated folder
camel_store_get_folder_info(CamelStore *store, const char *top, guint32 flags, CamelException *ex)
{
CamelFolderInfo *info;
-
+
g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
info = CS_CLASS (store)->get_folder_info (store, top, flags, ex);
-
+
if (info && (top == NULL || *top == '\0') && (flags & CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL) == 0) {
if (info->uri && (store->flags & CAMEL_STORE_VTRASH))
/* the name of the Trash folder, used for deleted messages */
dump_fi(info, 2);
camel_debug_end();
}
-
+
return info;
}
{
const CamelFolderInfo *a = ((CamelFolderInfo **)ap)[0];
const CamelFolderInfo *b = ((CamelFolderInfo **)bp)[0];
-
+
return strcmp (a->full_name, b->full_name);
}
nlen = strlen (namespace);
qsort (folders->pdata, folders->len, sizeof (folders->pdata[0]), folder_info_cmp);
-
+
/* Hash the folders. */
hash = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < folders->len; i++) {
fi = folders->pdata[i];
g_hash_table_insert (hash, fi->full_name, fi);
}
-
+
/* Now find parents. */
for (i = 0; i < folders->len; i++) {
fi = folders->pdata[i];
pfi->name = g_strdup (pname);
} else
pfi->name = g_strdup (pname);
-
+
url = camel_url_new (fi->uri, NULL);
if (url->fragment)
path = url->fragment;
else
path = url->path + 1;
-
+
sep = strrchr (path, separator);
if (sep)
*sep = '\0';
else
d(g_warning ("huh, no \"%c\" in \"%s\"?", separator, fi->uri));
-
+
pfi->full_name = g_strdup (path);
-
+
/* since this is a "fake" folder node, it is not selectable */
camel_url_set_param (url, "noselect", "yes");
pfi->uri = camel_url_to_string (url, 0);
tail = fi;
}
}
-
+
return top;
}
info->full_name = g_strdup(fi->full_name);
info->unread = fi->unread;
info->flags = fi->flags;
-
+
if (fi->next)
info->next = folder_info_clone_rec(fi->next, parent);
else
{
w(g_warning ("CamelStore::folder_subscribed not implemented for `%s'",
camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store))));
-
+
return FALSE;
}
CamelProvider *provider;
CamelURL *url0, *url1;
int equal;
-
+
g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
g_return_val_if_fail (uri0 && uri1, FALSE);
-
+
provider = ((CamelService *) store)->provider;
-
+
if (!(url0 = camel_url_new (uri0, NULL)))
return FALSE;
-
+
if (!(url1 = camel_url_new (uri1, NULL))) {
camel_url_free (url0);
return FALSE;
}
-
+
if ((equal = provider->url_equal (url0, url1))) {
const char *name0, *name1;
-
+
if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) {
name0 = url0->fragment;
name1 = url1->fragment;
if (name1 == NULL)
g_warning("URI is badly formed, missing folder name: %s", uri1);
-
+
equal = name0 && name1 && CS_CLASS (store)->compare_folder_name (name0, name1);
}
-
+
camel_url_free (url0);
camel_url_free (url1);
-
+
return equal;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-store.h : Abstract class for an email store */
-/*
+/*
*
* Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
* Michael Zucchi <NotZed@ximian.com>
*
* Copyright 1999, 2003 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
struct _CamelStore {
CamelService parent_object;
struct _CamelStorePrivate *priv;
-
+
CamelObjectBag *folders;
guint32 flags;
guint32 flags,
CamelException *ex);
- CamelFolder * (*get_inbox) (CamelStore *store, CamelException *ex);
+ CamelFolder * (*get_inbox) (CamelStore *store, CamelException *ex);
CamelFolder * (*get_trash) (CamelStore *store, CamelException *ex);
CamelFolder * (*get_junk) (CamelStore *store, CamelException *ex);
-
+
CamelFolderInfo *(*create_folder) (CamelStore *store,
const char *parent_name,
const char *folder_name,
const char *old_name,
const char *new_name,
CamelException *ex);
-
+
void (*sync) (CamelStore *store, int expunge, CamelException *ex);
-
+
CamelFolderInfo *(*get_folder_info) (CamelStore *store,
const char *top,
guint32 flags,
CamelException *ex);
void (*free_folder_info) (CamelStore *store,
CamelFolderInfo *fi);
-
+
gboolean (*folder_subscribed) (CamelStore *store,
const char *folder_name);
void (*subscribe_folder) (CamelStore *store,
sbf->buf = g_malloc(size);
sbf->flags &= ~BUF_USER;
}
-
+
sbf->ptr = sbf->buf;
sbf->end = sbf->buf;
sbf->size = size;
if ((sbf->mode & CAMEL_STREAM_BUFFER_MODE) == CAMEL_STREAM_BUFFER_WRITE) {
size_t len = sbf->ptr - sbf->buf;
-
+
if (camel_stream_write (sbf->stream, sbf->buf, len) == -1)
return -1;
-
+
sbf->ptr = sbf->buf;
} else {
/* nothing to do for read mode 'flush' */
#include "camel-stream-filter.h"
-#define d(x)
+#define d(x)
/* use my malloc debugger? */
/*extern void g_check(void *mp);*/
struct _CamelStreamFilterPrivate {
struct _filter *filters;
int filterid; /* next filter id */
-
+
char *realbuffer; /* buffer - READ_PAD */
char *buffer; /* READ_SIZE bytes */
camel_stream_class->write = do_write;
camel_stream_class->flush = do_flush;
camel_stream_class->close = do_close;
- camel_stream_class->eos = do_eos;
+ camel_stream_class->eos = do_eos;
camel_stream_class->reset = do_reset;
}
camel_stream_filter_init (CamelStreamFilter *obj)
{
struct _CamelStreamFilterPrivate *p;
-
+
_PRIVATE(obj) = p = g_malloc0(sizeof(*p));
p->realbuffer = g_malloc(READ_SIZE + READ_PAD);
p->buffer = p->realbuffer + READ_PAD;
camel_stream_filter_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (CAMEL_STREAM_TYPE, "CamelStreamFilter",
sizeof (CamelStreamFilter),
(CamelObjectInitFunc) camel_stream_filter_init,
(CamelObjectFinalizeFunc) camel_stream_filter_finalize);
}
-
+
return type;
}
* camel_stream_filter_new:
*
* Create a new #CamelStreamFilter object.
- *
+ *
* Returns a new #CamelStreamFilter object.
**/
CamelStreamFilter *
* camel_stream_filter_add:
* @stream: a #CamelStreamFilter object
* @filter: a #CamelMimeFilter object
- *
+ *
* Add a new #CamelMimeFilter to execute during the processing of this
* stream. Each filter added is processed after the previous one.
*
* Note that a filter should only be added to a single stream
* at a time, otherwise unpredictable results may occur.
- *
+ *
* Returns a filter id for the added @filter.
**/
int
* camel_stream_filter_remove:
* @stream: a #CamelStreamFilter object
* @id: Filter id, as returned from #camel_stream_filter_add
- *
+ *
* Remove a processing filter from the stream by id.
**/
void
char *buffer;
size_t presize;
size_t len;
-
+
if (p->last_was_read)
return 0;
-
+
buffer = "";
len = 0;
presize = 0;
f = p->filters;
-
+
d(printf ("\n\nFlushing: Original content (%s): '", ((CamelObject *)filter->source)->klass->name));
d(fwrite(buffer, sizeof(char), len, stdout));
d(printf("'\n"));
{
CamelStreamFilter *filter = (CamelStreamFilter *)stream;
struct _CamelStreamFilterPrivate *p = _PRIVATE(filter);
-
+
if (p->filteredlen > 0)
return FALSE;
-
+
if (!p->flushed)
return FALSE;
-
+
return camel_stream_eos(filter->source);
}
p->filteredlen = 0;
p->flushed = FALSE;
-
+
/* and reset filters */
f = p->filters;
while (f) {
CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream);
CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
ssize_t nread;
-
+
if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
n = MIN (seekable->bound_end - seekable->position, n);
-
+
if ((nread = camel_read (stream_fs->fd, buffer, n)) > 0)
seekable->position += nread;
else if (nread == 0)
stream->eos = TRUE;
-
+
return nread;
}
CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream);
CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
ssize_t nwritten;
-
+
if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
n = MIN (seekable->bound_end - seekable->position, n);
-
+
if ((nwritten = camel_write (stream_fs->fd, buffer, n)) > 0)
seekable->position += nwritten;
-
+
return nwritten;
}
{
if (close (((CamelStreamFs *)stream)->fd) == -1)
return -1;
-
+
((CamelStreamFs *)stream)->fd = -1;
return 0;
}
/**
* camel_stream_mem_set_secure:
* @mem: a #CamelStreamMem object
- *
+ *
* Mark the memory stream as secure. At the very least this means the
* data in the buffer will be cleared when the buffer is finalised.
* This only applies to buffers owned by the stream.
CamelStreamMem *stream_mem = CAMEL_STREAM_MEM (stream);
CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
ssize_t nwrite = n;
-
+
if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
nwrite = MIN(seekable->bound_end - seekable->position, n);
struct _CamelStreamNull {
CamelStream parent;
-
+
size_t written;
};
*
* Authors: David Woodhouse <dwmw2@infradead.org>,
* Jeffrey Stedfast <fejj@ximian.com>
- *
+ *
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
camel_stream_process_class_init (CamelStreamProcessClass *camel_stream_process_class)
{
CamelStreamClass *camel_stream_class = (CamelStreamClass *) camel_stream_process_class;
-
+
parent_class = camel_type_get_global_classfuncs (CAMEL_OBJECT_TYPE);
-
+
/* virtual method definition */
camel_stream_class->read = stream_read;
camel_stream_class->write = stream_write;
camel_stream_process_init (gpointer object, gpointer klass)
{
CamelStreamProcess *stream = CAMEL_STREAM_PROCESS (object);
-
+
stream->sockfd = -1;
stream->childpid = 0;
}
camel_stream_process_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_stream_get_type (),
"CamelStreamProcess",
(CamelObjectInitFunc) camel_stream_process_init,
(CamelObjectFinalizeFunc) camel_stream_process_finalise);
}
-
+
return type;
}
stream_read (CamelStream *stream, char *buffer, size_t n)
{
CamelStreamProcess *stream_process = CAMEL_STREAM_PROCESS (stream);
-
+
return camel_read (stream_process->sockfd, buffer, n);
}
stream_write (CamelStream *stream, const char *buffer, size_t n)
{
CamelStreamProcess *stream_process = CAMEL_STREAM_PROCESS (stream);
-
+
return camel_write (stream_process->sockfd, buffer, n);
}
stream_close (CamelStream *object)
{
CamelStreamProcess *stream = CAMEL_STREAM_PROCESS (object);
-
+
if (camel_verbose_debug)
fprintf (stderr, "Process stream close. sockfd %d, childpid %d\n",
stream->sockfd, stream->childpid);
-
+
if (stream->sockfd != -1) {
close (stream->sockfd);
stream->sockfd = -1;
}
-
+
if (stream->childpid) {
int ret, i;
for (i = 0; i < 4; i++) {
break;
}
}
-
+
stream->childpid = 0;
}
-
+
return 0;
}
do_exec_command (int fd, const char *command, char **env)
{
int i, maxopen;
-
+
/* Not a lot we can do if there's an error other than bail. */
if (dup2 (fd, 0) == -1)
exit (1);
if (dup2 (fd, 1) == -1)
exit (1);
-
+
/* What to do with stderr? Possibly put it through a separate pipe
and bring up a dialog box with its output if anything does get
spewed to it? It'd help the user understand what was going wrong
with their command, but it's hard to do cleanly. For now we just
leave it as it is. Perhaps we should close it and reopen /dev/null? */
-
+
maxopen = sysconf (_SC_OPEN_MAX);
for (i = 3; i < maxopen; i++)
fcntl (i, F_SETFD, FD_CLOEXEC);
-
+
setsid ();
#ifdef TIOCNOTTY
- /* Detach from the controlling tty if we have one. Otherwise,
- SSH might do something stupid like trying to use it instead
+ /* Detach from the controlling tty if we have one. Otherwise,
+ SSH might do something stupid like trying to use it instead
of running $SSH_ASKPASS. Doh. */
if ((fd = open ("/dev/tty", O_RDONLY)) != -1) {
ioctl (fd, TIOCNOTTY, NULL);
close (fd);
}
#endif /* TIOCNOTTY */
-
- /* Set up child's environment. We _add_ to it, don't use execle,
+
+ /* Set up child's environment. We _add_ to it, don't use execle,
because otherwise we'd destroy stuff like SSH_AUTH_SOCK etc. */
for ( ; env && *env; env++)
putenv(*env);
-
+
execl ("/bin/sh", "/bin/sh", "-c", command, NULL);
-
+
if (camel_verbose_debug)
fprintf (stderr, "exec failed %d\n", errno);
-
+
exit (1);
}
camel_stream_process_connect (CamelStreamProcess *stream, const char *command, const char **env)
{
int sockfds[2];
-
+
if (stream->sockfd != -1 || stream->childpid)
stream_close (CAMEL_STREAM (stream));
-
+
if (socketpair (AF_UNIX, SOCK_STREAM, 0, sockfds))
return -1;
-
+
stream->childpid = fork ();
if (!stream->childpid) {
do_exec_command (sockfds[1], command, (char **)env);
stream->sockfd = -1;
return -1;
}
-
+
close (sockfds[1]);
stream->sockfd = sockfds[0];
-
+
return 0;
}
struct _CamelStreamProcess {
CamelStream parent;
-
+
int sockfd;
pid_t childpid;
};
{
CamelStreamVFS *stream_vfs;
off_t offset;
-
+
if (!handle)
return NULL;
GnomeVFSResult result;
GnomeVFSHandle *handle;
int vfs_flag = 0;
-
+
if (flags & O_WRONLY)
vfs_flag = vfs_flag | GNOME_VFS_OPEN_WRITE;
if (flags & O_RDONLY)
vfs_flag = vfs_flag | GNOME_VFS_OPEN_READ;
if (flags & O_RDWR)
vfs_flag = vfs_flag | GNOME_VFS_OPEN_READ |GNOME_VFS_OPEN_WRITE;
-
+
if (flags & O_CREAT)
result = gnome_vfs_create (&handle, name, vfs_flag, FALSE, mode);
else
result = gnome_vfs_open (&handle, name, vfs_flag);
-
+
if (result != GNOME_VFS_OK) {
return NULL;
}
CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
GnomeVFSFileSize nread = 0;
GnomeVFSResult result;
-
+
if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
n = MIN (seekable->bound_end - seekable->position, n);
result = gnome_vfs_read (stream_vfs->handle, buffer, n, &nread);
-
+
if (nread > 0 && result == GNOME_VFS_OK)
seekable->position += nread;
else if (nread == 0)
stream->eos = TRUE;
-
+
return nread;
}
CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
GnomeVFSFileSize nwritten = 0;
GnomeVFSResult result;
-
+
if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
n = MIN (seekable->bound_end - seekable->position, n);
result = gnome_vfs_write (stream_vfs->handle, buffer, n, &nwritten);
-
+
if (nwritten > 0 && result == GNOME_VFS_OK)
seekable->position += nwritten;
-
+
return nwritten;
}
GnomeVFSResult result;
result = gnome_vfs_close(((CamelStreamVFS *)stream)->handle);
-
+
if (result != GNOME_VFS_OK)
return -1;
-
+
((CamelStreamVFS *)stream)->handle = NULL;
return 0;
}
GnomeVFSFileSize real = 0;
GnomeVFSResult result;
GnomeVFSHandle *handle = stream_vfs->handle;
-
+
switch (policy) {
case CAMEL_STREAM_SET:
real = offset;
{
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
g_return_val_if_fail (n == 0 || buffer, -1);
-
+
return (CS_CLASS (stream)->read) (stream, buffer, n);
}
/**
* camel_stream_close:
* @stream: a #CamelStream object
- *
+ *
* Closes the stream.
- *
+ *
* Returns %0 on success or %-1 on error.
**/
int
camel_stream_close (CamelStream *stream)
{
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
-
+
return CS_CLASS (stream)->close (stream);
}
camel_stream_eos (CamelStream *stream)
{
g_return_val_if_fail (CAMEL_IS_STREAM (stream), TRUE);
-
+
return CS_CLASS (stream)->eos (stream);
}
camel_stream_reset (CamelStream *stream)
{
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
-
+
return CS_CLASS (stream)->reset (stream);
}
va_list args;
char *string;
ssize_t ret;
-
+
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
-
+
va_start (args, fmt);
string = g_strdup_vprintf (fmt, args);
va_end (args);
-
+
if (!string)
return -1;
-
+
ret = camel_stream_write (stream, string, strlen (string));
g_free (string);
return ret;
{
const char *p = (char *) v;
guint h = 0, g;
-
+
for ( ; *p != '\0'; p++) {
h = (h << 4) + g_ascii_toupper (*p);
if ((g = h & 0xf0000000)) {
h = h ^ g;
}
}
-
+
return h;
}
camel_string_list_free (GList *string_list)
{
if (string_list == NULL)
- return;
-
+ return;
+
g_list_foreach (string_list, free_string, NULL);
g_list_free (string_list);
}
/* find the needle in the haystack neglecting case */
const char *ptr;
guint len;
-
+
g_return_val_if_fail (haystack != NULL, NULL);
g_return_val_if_fail (needle != NULL, NULL);
-
+
len = strlen (needle);
if (len > strlen (haystack))
return NULL;
-
+
if (len == 0)
return (char *) haystack;
-
+
for (ptr = haystack; *(ptr + len - 1) != '\0'; ptr++)
if (!g_ascii_strncasecmp (ptr, needle, len))
return (char *) ptr;
-
+
return NULL;
}
camel_strdown (char *str)
{
register char *s = str;
-
+
while (*s) {
if (*s >= 'A' && *s <= 'Z')
*s += 0x20;
s++;
}
-
+
return str;
}
/**
* camel_tolower:
- * @c:
- *
+ * @c:
+ *
* ASCII to-lower function.
- *
- * Return value:
+ *
+ * Return value:
**/
char camel_tolower(char c)
{
/**
* camel_toupper:
- * @c:
- *
+ * @c:
+ *
* ASCII to-upper function.
- *
- * Return value:
+ *
+ * Return value:
**/
char camel_toupper(char c)
{
void *pcount;
char *pstr;
int count;
-
+
if (str == NULL)
return NULL;
-
+
if (str[0] == '\0') {
if (own)
g_free (str);
return "";
}
-
+
pthread_mutex_lock (&pstring_lock);
if (pstring_table == NULL)
pstring_table = g_hash_table_new (g_str_hash, g_str_equal);
-
+
if (g_hash_table_lookup_extended (pstring_table, str, (void **) &pstr, &pcount)) {
count = GPOINTER_TO_INT (pcount) + 1;
g_hash_table_insert (pstring_table, pstr, GINT_TO_POINTER (count));
pstr = own ? str : g_strdup (str);
g_hash_table_insert (pstring_table, pstr, GINT_TO_POINTER (1));
}
-
+
pthread_mutex_unlock (&pstring_lock);
-
+
return pstr;
}
/**
* camel_pstring_strdup:
* @s: String to copy.
- *
+ *
* Create a new pooled string entry for the string @s. A pooled
* string is a table where common strings are uniquified to the same
* pointer value. They are also refcounted, so freed when no longer
* in use. In a thread-safe manner.
- *
+ *
* The NULL and empty strings are special cased to constant values.
*
* Return value: A pointer to an equivalent string of @s. Use
/**
* camel_pstring_free:
* @s: String to free.
- *
+ *
* De-ref a pooled string. If no more refs exist to this string, it will be deallocated.
*
* NULL and the empty string are special cased.
struct _CamelTcpStreamSSLPrivate {
int sockfd;
SSL *ssl;
-
+
CamelService *service;
char *expected_host;
gboolean ssl_mode;
CAMEL_TCP_STREAM_CLASS (camel_tcp_stream_ssl_class);
CamelStreamClass *camel_stream_class =
CAMEL_STREAM_CLASS (camel_tcp_stream_ssl_class);
-
+
parent_class = CAMEL_TCP_STREAM_CLASS (camel_type_get_global_classfuncs (camel_tcp_stream_get_type ()));
-
+
/* virtual method overload */
camel_stream_class->read = stream_read;
camel_stream_class->write = stream_write;
camel_stream_class->flush = stream_flush;
camel_stream_class->close = stream_close;
-
+
camel_tcp_stream_class->connect = stream_connect;
camel_tcp_stream_class->getsockopt = stream_getsockopt;
camel_tcp_stream_class->setsockopt = stream_setsockopt;
camel_tcp_stream_class->get_local_address = stream_get_local_address;
camel_tcp_stream_class->get_remote_address = stream_get_remote_address;
-
+
/* init OpenSSL stuff */
SSLeay_add_ssl_algorithms ();
SSL_load_error_strings ();
camel_tcp_stream_ssl_init (gpointer object, gpointer klass)
{
CamelTcpStreamSSL *stream = CAMEL_TCP_STREAM_SSL (object);
-
+
stream->priv = g_new0 (struct _CamelTcpStreamSSLPrivate, 1);
stream->priv->sockfd = -1;
}
camel_tcp_stream_ssl_finalize (CamelObject *object)
{
CamelTcpStreamSSL *stream = CAMEL_TCP_STREAM_SSL (object);
-
+
if (stream->priv->ssl) {
SSL_shutdown (stream->priv->ssl);
-
+
if (stream->priv->ssl->ctx) {
SSL_CTX_free (stream->priv->ssl->ctx);
}
-
+
SSL_free (stream->priv->ssl);
}
-
+
if (stream->priv->sockfd != -1)
close (stream->priv->sockfd);
-
+
g_free (stream->priv->expected_host);
-
+
g_free (stream->priv);
}
camel_tcp_stream_ssl_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_tcp_stream_get_type (),
"CamelTcpStreamSSL",
(CamelObjectInitFunc) camel_tcp_stream_ssl_init,
(CamelObjectFinalizeFunc) camel_tcp_stream_ssl_finalize);
}
-
+
return type;
}
camel_tcp_stream_ssl_new (CamelService *service, const char *expected_host, guint32 flags)
{
CamelTcpStreamSSL *stream;
-
+
stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ()));
-
+
stream->priv->service = service;
stream->priv->expected_host = g_strdup (expected_host);
stream->priv->ssl_mode = TRUE;
stream->priv->flags = flags;
-
+
return CAMEL_STREAM (stream);
}
camel_tcp_stream_ssl_new_raw (CamelService *service, const char *expected_host, guint32 flags)
{
CamelTcpStreamSSL *stream;
-
+
stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ()));
-
+
stream->priv->service = service;
stream->priv->expected_host = g_strdup (expected_host);
stream->priv->ssl_mode = FALSE;
stream->priv->flags = flags;
-
+
return CAMEL_STREAM (stream);
}
camel_tcp_stream_ssl_enable_ssl (CamelTcpStreamSSL *stream)
{
SSL *ssl;
-
+
g_return_val_if_fail (CAMEL_IS_TCP_STREAM_SSL (stream), -1);
-
+
if (stream->priv->sockfd != -1 && !stream->priv->ssl_mode) {
ssl = open_ssl_connection (stream->priv->service, stream->priv->sockfd, stream);
if (ssl == NULL) {
stream->priv->sockfd = -1;
return -1;
}
-
+
stream->priv->ssl = ssl;
}
-
+
stream->priv->ssl_mode = TRUE;
-
+
return 0;
}
SSL *ssl = openssl->priv->ssl;
ssize_t nread;
int cancel_fd;
-
+
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
return -1;
}
-
+
cancel_fd = camel_operation_cancel_fd (NULL);
if (cancel_fd == -1) {
do {
int error, flags, fdmax;
struct timeval timeout;
fd_set rdset;
-
+
flags = fcntl (openssl->priv->sockfd, F_GETFL);
fcntl (openssl->priv->sockfd, F_SETFL, flags | O_NONBLOCK);
-
+
fdmax = MAX (openssl->priv->sockfd, cancel_fd) + 1;
-
+
do {
FD_ZERO (&rdset);
FD_SET (openssl->priv->sockfd, &rdset);
FD_SET (cancel_fd, &rdset);
-
+
timeout.tv_sec = 0;
timeout.tv_usec = TIMEOUT_USEC;
select (fdmax, &rdset, 0, 0, &timeout);
errno = EINTR;
return -1;
}
-
+
do {
if (ssl) {
nread = SSL_read (ssl, buffer, n);
}
} while (nread < 0 && errno == EINTR);
} while (nread < 0 && (errno == EAGAIN || errno == EWOULDBLOCK));
-
+
error = errno;
fcntl (openssl->priv->sockfd, F_SETFL, flags);
errno = error;
}
-
+
return nread;
}
SSL *ssl = openssl->priv->ssl;
ssize_t w, written = 0;
int cancel_fd;
-
+
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
return -1;
}
-
+
cancel_fd = camel_operation_cancel_fd (NULL);
if (cancel_fd == -1) {
do {
w = write (openssl->priv->sockfd, buffer + written, n - written);
}
} while (w < 0 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
-
+
if (w > 0)
written += w;
} while (w != -1 && written < n);
int error, flags, fdmax;
struct timeval timeout;
fd_set rdset, wrset;
-
+
flags = fcntl (openssl->priv->sockfd, F_GETFL);
fcntl (openssl->priv->sockfd, F_SETFL, flags | O_NONBLOCK);
-
+
fdmax = MAX (openssl->priv->sockfd, cancel_fd) + 1;
do {
FD_ZERO (&rdset);
FD_ZERO (&wrset);
FD_SET (openssl->priv->sockfd, &wrset);
FD_SET (cancel_fd, &rdset);
-
+
timeout.tv_sec = 0;
timeout.tv_usec = TIMEOUT_USEC;
select (fdmax, &rdset, &wrset, 0, &timeout);
errno = EINTR;
return -1;
}
-
+
do {
if (ssl) {
w = SSL_write (ssl, buffer + written, n - written);
w = write (openssl->priv->sockfd, buffer + written, n - written);
}
} while (w < 0 && errno == EINTR);
-
+
if (w < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
w = 0;
} else
written += w;
} while (w >= 0 && written < n);
-
+
fcntl (openssl->priv->sockfd, F_SETFL, flags);
}
-
+
return written;
}
{
if (ssl) {
SSL_shutdown (ssl);
-
+
if (ssl->ctx)
SSL_CTX_free (ssl->ctx);
-
+
SSL_free (ssl);
}
}
{
close_ssl_connection (((CamelTcpStreamSSL *)stream)->priv->ssl);
((CamelTcpStreamSSL *)stream)->priv->ssl = NULL;
-
+
if (close (((CamelTcpStreamSSL *)stream)->priv->sockfd) == -1)
return -1;
-
+
((CamelTcpStreamSSL *)stream)->priv->sockfd = -1;
return 0;
}
socklen_t len;
int cancel_fd;
int ret, fd;
-
+
/* see if we're cancelled yet */
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
return -1;
}
-
+
/* setup connect, we do it using a nonblocking socket so we can poll it */
#ifdef ENABLE_IPv6
if (h->h_addrtype == AF_INET6) {
#ifdef ENABLE_IPv6
}
#endif
-
+
fd = socket (h->h_addrtype, SOCK_STREAM, 0);
-
+
cancel_fd = camel_operation_cancel_fd (NULL);
if (cancel_fd == -1) {
ret = connect (fd, saddr, len);
close (fd);
return -1;
}
-
+
return fd;
} else {
fd_set rdset, wrset;
int flags, fdmax;
-
+
flags = fcntl (fd, F_GETFL);
fcntl (fd, F_SETFL, flags | O_NONBLOCK);
-
+
ret = connect (fd, saddr, len);
if (ret == 0) {
fcntl (fd, F_SETFL, flags);
return fd;
}
-
+
if (errno != EINPROGRESS) {
close (fd);
return -1;
}
-
+
FD_ZERO (&rdset);
FD_ZERO (&wrset);
FD_SET (fd, &wrset);
fdmax = MAX (fd, cancel_fd) + 1;
tv.tv_usec = 0;
tv.tv_sec = 60 * 4;
-
+
if (select (fdmax, &rdset, &wrset, 0, &tv) == 0) {
close (fd);
errno = ETIMEDOUT;
return -1;
}
-
+
if (cancel_fd != -1 && FD_ISSET (cancel_fd, &rdset)) {
close (fd);
errno = EINTR;
return -1;
} else {
len = sizeof (int);
-
+
if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &len) == -1) {
close (fd);
return -1;
}
-
+
if (ret != 0) {
close (fd);
errno = ret;
return -1;
}
}
-
+
fcntl (fd, F_SETFL, flags);
}
-
+
return fd;
}
char buf[257];
X509 *cert;
SSL *ssl;
-
+
if (ok)
return TRUE;
-
+
ssl = X509_STORE_CTX_get_ex_data (ctx, SSL_get_ex_data_X509_STORE_CTX_idx ());
-
+
stream = SSL_CTX_get_app_data (ssl->ctx);
if (!stream)
return FALSE;
-
+
service = stream->priv->service;
-
+
cert = X509_STORE_CTX_get_current_cert (ctx);
err = X509_STORE_CTX_get_error (ctx);
-
+
/* calculate the MD5 hash of the raw certificate */
md5len = sizeof (md5sum);
X509_digest (cert, EVP_md5 (), md5sum, &md5len);
for (i = 0, f = fingerprint; i < 16; i++, f += 3)
sprintf (f, "%.2x%c", md5sum[i], i != 15 ? ':' : '\0');
-
+
#define GET_STRING(name) X509_NAME_oneline (name, buf, 256)
-
+
certdb = camel_certdb_get_default ();
if (certdb) {
ccert = camel_certdb_get_cert (certdb, fingerprint);
ok = ccert->trust != CAMEL_CERT_TRUST_NEVER;
camel_certdb_cert_unref (certdb, ccert);
camel_object_unref (certdb);
-
+
return ok;
}
} else {
camel_cert_set_hostname (certdb, ccert, stream->priv->expected_host);
camel_cert_set_fingerprint (certdb, ccert, fingerprint);
camel_cert_set_trust (certdb, ccert, CAMEL_CERT_TRUST_UNKNOWN);
-
+
/* Add the certificate to our db */
camel_certdb_add (certdb, ccert);
}
}
-
+
cert_str = g_strdup_printf (_("Issuer: %s\n"
"Subject: %s\n"
"Fingerprint: %s\n"
GET_STRING (X509_get_issuer_name (cert)),
GET_STRING (X509_get_subject_name (cert)),
fingerprint, cert->valid ? _("GOOD") : _("BAD"));
-
+
prompt = g_strdup_printf (_("Bad certificate from %s:\n\n%s\n\n%s\n\n"
"Do you wish to accept anyway?"),
service->url->host, cert_str, x509_strerror (err));
-
+
ok = camel_session_alert_user (service->session, CAMEL_SESSION_ALERT_WARNING, prompt, TRUE);
g_free (prompt);
-
+
if (ok && ccert) {
camel_cert_set_trust (certdb, ccert, CAMEL_CERT_TRUST_FULLY);
camel_certdb_touch (certdb);
}
-
+
if (certdb) {
camel_certdb_cert_unref (certdb, ccert);
camel_object_unref (certdb);
}
-
+
return ok;
}
SSL_CTX *ssl_ctx = NULL;
SSL *ssl = NULL;
int n;
-
+
/* SSLv23_client_method will negotiate with SSL v2, v3, or TLS v1 */
ssl_ctx = SSL_CTX_new (SSLv23_client_method ());
g_return_val_if_fail (ssl_ctx != NULL, NULL);
-
+
SSL_CTX_set_default_verify_paths (ssl_ctx);
SSL_CTX_set_verify (ssl_ctx, SSL_VERIFY_PEER, &ssl_verify);
ssl = SSL_new (ssl_ctx);
SSL_set_fd (ssl, sockfd);
-
+
SSL_CTX_set_app_data (ssl_ctx, openssl);
-
+
n = SSL_connect (ssl);
if (n != 1) {
int errnosave = ssl_errno (ssl, n);
-
+
SSL_shutdown (ssl);
-
+
if (ssl->ctx)
SSL_CTX_free (ssl->ctx);
-
+
SSL_free (ssl);
ssl = NULL;
-
+
close (sockfd);
-
+
errno = errnosave;
}
-
+
return ssl;
}
CamelTcpStreamSSL *openssl = CAMEL_TCP_STREAM_SSL (stream);
SSL *ssl = NULL;
int fd;
-
+
g_return_val_if_fail (host != NULL, -1);
-
+
fd = socket_connect (host, port);
if (fd == -1)
return -1;
-
+
if (openssl->priv->ssl_mode) {
ssl = open_ssl_connection (openssl->priv->service, fd, openssl);
if (!ssl)
return -1;
}
-
+
openssl->priv->sockfd = fd;
openssl->priv->ssl = ssl;
-
+
return 0;
}
stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
{
int optname, optlen;
-
+
if ((optname = get_sockopt_optname (data)) == -1)
return -1;
-
+
if (data->option == CAMEL_SOCKOPT_NONBLOCKING) {
int flags;
-
+
flags = fcntl (((CamelTcpStreamSSL *) stream)->priv->sockfd, F_GETFL);
if (flags == -1)
return -1;
-
+
data->value.non_blocking = flags & O_NONBLOCK ? TRUE : FALSE;
-
+
return 0;
}
-
+
return getsockopt (((CamelTcpStreamSSL *) stream)->priv->sockfd,
get_sockopt_level (data),
optname,
stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
{
int optname;
-
+
if ((optname = get_sockopt_optname (data)) == -1)
return -1;
-
+
if (data->option == CAMEL_SOCKOPT_NONBLOCKING) {
int flags, set;
-
+
flags = fcntl (((CamelTcpStreamSSL *) stream)->priv->sockfd, F_GETFL);
if (flags == -1)
return -1;
-
+
set = data->value.non_blocking ? O_NONBLOCK : 0;
flags = (flags & ~O_NONBLOCK) | set;
-
+
if (fcntl (((CamelTcpStreamSSL *) stream)->priv->sockfd, F_SETFL, flags) == -1)
return -1;
-
+
return 0;
}
-
+
return setsockopt (((CamelTcpStreamSSL *) stream)->priv->sockfd,
get_sockopt_level (data),
optname,
gpointer address;
socklen_t len;
int family;
-
+
len = MIN_SOCKADDR_BUFLEN;
-
+
if (getsockname (CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd, saddr, &len) == -1)
return NULL;
-
+
if (saddr->sa_family == AF_INET) {
family = CAMEL_TCP_ADDRESS_IPv4;
address = &sin->sin_addr;
#endif
} else
return NULL;
-
+
return camel_tcp_address_new (family, sin->sin_port, len, address);
}
gpointer address;
socklen_t len;
int family;
-
+
len = MIN_SOCKADDR_BUFLEN;
-
+
if (getpeername (CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd, saddr, &len) == -1)
return NULL;
-
+
if (saddr->sa_family == AF_INET) {
family = CAMEL_TCP_ADDRESS_IPv4;
address = &sin->sin_addr;
#endif
} else
return NULL;
-
+
return camel_tcp_address_new (family, sin->sin_port, len, address);
}
CAMEL_TCP_STREAM_CLASS (camel_tcp_stream_raw_class);
CamelStreamClass *camel_stream_class =
CAMEL_STREAM_CLASS (camel_tcp_stream_raw_class);
-
+
parent_class = CAMEL_TCP_STREAM_CLASS (camel_type_get_global_classfuncs (camel_tcp_stream_get_type ()));
-
+
/* virtual method overload */
camel_stream_class->read = stream_read;
camel_stream_class->write = stream_write;
camel_stream_class->flush = stream_flush;
camel_stream_class->close = stream_close;
-
+
camel_tcp_stream_class->connect = stream_connect;
camel_tcp_stream_class->getsockopt = stream_getsockopt;
camel_tcp_stream_class->setsockopt = stream_setsockopt;
camel_tcp_stream_raw_init (gpointer object, gpointer klass)
{
CamelTcpStreamRaw *stream = CAMEL_TCP_STREAM_RAW (object);
-
+
stream->sockfd = -1;
}
camel_tcp_stream_raw_finalize (CamelObject *object)
{
CamelTcpStreamRaw *stream = CAMEL_TCP_STREAM_RAW (object);
-
+
if (stream->sockfd != -1)
SOCKET_CLOSE (stream->sockfd);
}
camel_tcp_stream_raw_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_tcp_stream_get_type (),
"CamelTcpStreamRaw",
(CamelObjectInitFunc) camel_tcp_stream_raw_init,
(CamelObjectFinalizeFunc) camel_tcp_stream_raw_finalize);
}
-
+
return type;
}
size_t len = buflen;
ssize_t nwritten;
int val;
-
+
if (buflen == 0)
return 0;
-
+
val = 1 + (int) (10.0 * rand () / (RAND_MAX + 1.0));
-
+
switch (val) {
case 1:
printf ("flaky_tcp_write (%d, ..., %d): (-1) EINTR\n", fd, buflen);
printf (" only wrote %d bytes\n", nwritten);
else
printf ("\n");
-
+
return nwritten;
}
}
size_t len = buflen;
ssize_t nread;
int val;
-
+
if (buflen == 0)
return 0;
-
+
val = 1 + (int) (10.0 * rand () / (RAND_MAX + 1.0));
-
+
switch (val) {
case 1:
printf ("flaky_tcp_read (%d, ..., %d): (-1) EINTR\n", fd, buflen);
printf (" only read %d bytes\n", nread);
else
printf ("\n");
-
+
return nread;
}
}
camel_tcp_stream_raw_new (void)
{
CamelTcpStreamRaw *stream;
-
+
stream = CAMEL_TCP_STREAM_RAW (camel_object_new (camel_tcp_stream_raw_get_type ()));
-
+
return CAMEL_STREAM (stream);
}
stream_read (CamelStream *stream, char *buffer, size_t n)
{
CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
-
+
return camel_read_socket (raw->sockfd, buffer, n);
}
stream_write (CamelStream *stream, const char *buffer, size_t n)
{
CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
-
+
return camel_write_socket (raw->sockfd, buffer, n);
}
{
if (SOCKET_CLOSE (((CamelTcpStreamRaw *)stream)->sockfd) == -1)
return -1;
-
+
((CamelTcpStreamRaw *)stream)->sockfd = -1;
return 0;
}
int cancel_fd;
int errnosav;
int ret, fd;
-
+
/* see if we're cancelled yet */
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
return -1;
}
-
+
if (h->ai_socktype != SOCK_STREAM) {
errno = EINVAL;
return -1;
if ((fd = socket (h->ai_family, SOCK_STREAM, 0)) == -1)
return -1;
-
+
cancel_fd = camel_operation_cancel_fd (NULL);
if (cancel_fd == -1) {
if (connect (fd, h->ai_addr, h->ai_addrlen) == -1) {
errno = errnosav;
return -1;
}
-
+
return fd;
} else {
#ifndef G_OS_WIN32
#endif
int fdmax, status;
fd_set rdset, wrset;
-
+
#ifndef G_OS_WIN32
flags = fcntl (fd, F_GETFL);
fcntl (fd, F_SETFL, flags | O_NONBLOCK);
#endif
return fd;
}
-
+
if (!SOCKET_ERROR_IS_EINPROGRESS ()) {
errnosav = errno;
SOCKET_CLOSE (fd);
errno = errnosav;
return -1;
}
-
+
do {
FD_ZERO (&rdset);
FD_ZERO (&wrset);
fdmax = MAX (fd, cancel_fd) + 1;
tv.tv_sec = 60 * 4;
tv.tv_usec = 0;
-
+
status = select (fdmax, &rdset, &wrset, NULL, &tv);
} while (status == -1 && SOCKET_ERROR_IS_EINTR ());
-
+
if (status <= 0) {
SOCKET_CLOSE (fd);
errno = ETIMEDOUT;
return -1;
}
-
+
if (cancel_fd != -1 && FD_ISSET (cancel_fd, &rdset)) {
SOCKET_CLOSE (fd);
errno = EINTR;
return -1;
} else {
len = sizeof (int);
-
+
if (getsockopt (fd, SOL_SOCKET, SO_ERROR, (char *) &ret, &len) == -1) {
errnosav = errno;
SOCKET_CLOSE (fd);
errno = errnosav;
return -1;
}
-
+
if (ret != 0) {
SOCKET_CLOSE (fd);
errno = ret;
}
#endif
}
-
+
return fd;
}
stream_connect (CamelTcpStream *stream, struct addrinfo *host)
{
CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
-
+
g_return_val_if_fail (host != NULL, -1);
while (host) {
stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
{
int optname, optlen;
-
+
if ((optname = get_sockopt_optname (data)) == -1)
return -1;
-
+
if (data->option == CAMEL_SOCKOPT_NONBLOCKING) {
#ifndef G_OS_WIN32
int flags;
-
+
flags = fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_GETFL);
if (flags == -1)
return -1;
-
+
data->value.non_blocking = flags & O_NONBLOCK ? TRUE : FALSE;
#else
data->value.non_blocking = ((CamelTcpStreamRaw *)stream)->is_nonblocking;
#endif
return 0;
}
-
+
return getsockopt (((CamelTcpStreamRaw *)stream)->sockfd,
get_sockopt_level (data),
optname,
stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
{
int optname;
-
+
if ((optname = get_sockopt_optname (data)) == -1)
return -1;
-
+
if (data->option == CAMEL_SOCKOPT_NONBLOCKING) {
#ifndef G_OS_WIN32
int flags, set;
-
+
flags = fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_GETFL);
if (flags == -1)
return -1;
-
+
set = data->value.non_blocking ? O_NONBLOCK : 0;
flags = (flags & ~O_NONBLOCK) | set;
-
+
if (fcntl (((CamelTcpStreamRaw *)stream)->sockfd, F_SETFL, flags) == -1)
return -1;
#else
#endif
return 0;
}
-
+
return setsockopt (((CamelTcpStreamRaw *)stream)->sockfd,
get_sockopt_level (data),
optname,
struct _CamelTcpStreamRaw
{
CamelTcpStream parent_object;
-
+
int sockfd;
#ifdef G_OS_WIN32
int is_nonblocking;
typedef struct {
CamelTcpStreamClass parent_class;
-
+
/* virtual functions */
-
+
} CamelTcpStreamRawClass;
/* Standard Camel function */
struct _CamelTcpStreamSSLPrivate {
PRFileDesc *sockfd;
-
+
struct _CamelSession *session;
char *expected_host;
gboolean ssl_mode;
CAMEL_TCP_STREAM_CLASS (camel_tcp_stream_ssl_class);
CamelStreamClass *camel_stream_class =
CAMEL_STREAM_CLASS (camel_tcp_stream_ssl_class);
-
+
parent_class = CAMEL_TCP_STREAM_CLASS (camel_type_get_global_classfuncs (camel_tcp_stream_get_type ()));
-
+
/* virtual method overload */
camel_stream_class->read = stream_read;
camel_stream_class->write = stream_write;
camel_stream_class->flush = stream_flush;
camel_stream_class->close = stream_close;
-
+
camel_tcp_stream_class->connect = stream_connect;
camel_tcp_stream_class->getsockopt = stream_getsockopt;
camel_tcp_stream_class->setsockopt = stream_setsockopt;
camel_tcp_stream_ssl_init (gpointer object, gpointer klass)
{
CamelTcpStreamSSL *stream = CAMEL_TCP_STREAM_SSL (object);
-
+
stream->priv = g_new0 (struct _CamelTcpStreamSSLPrivate, 1);
}
camel_tcp_stream_ssl_finalize (CamelObject *object)
{
CamelTcpStreamSSL *stream = CAMEL_TCP_STREAM_SSL (object);
-
+
if (stream->priv->sockfd != NULL)
PR_Close (stream->priv->sockfd);
camel_object_unref(stream->priv->session);
g_free (stream->priv->expected_host);
-
+
g_free (stream->priv);
}
camel_tcp_stream_ssl_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_tcp_stream_get_type (),
"CamelTcpStreamSSL",
(CamelObjectInitFunc) camel_tcp_stream_ssl_init,
(CamelObjectFinalizeFunc) camel_tcp_stream_ssl_finalize);
}
-
+
return type;
}
g_assert(CAMEL_IS_SESSION(session));
stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ()));
-
+
stream->priv->session = session;
camel_object_ref(session);
stream->priv->expected_host = g_strdup (expected_host);
stream->priv->ssl_mode = TRUE;
stream->priv->flags = flags;
-
+
return CAMEL_STREAM (stream);
}
CamelTcpStreamSSL *stream;
g_assert(CAMEL_IS_SESSION(session));
-
+
stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ()));
-
+
stream->priv->session = session;
camel_object_ref(session);
stream->priv->expected_host = g_strdup (expected_host);
stream->priv->ssl_mode = FALSE;
stream->priv->flags = flags;
-
+
return CAMEL_STREAM (stream);
}
camel_tcp_stream_ssl_enable_ssl (CamelTcpStreamSSL *ssl)
{
PRFileDesc *fd;
-
+
g_return_val_if_fail (CAMEL_IS_TCP_STREAM_SSL (ssl), -1);
-
+
if (ssl->priv->sockfd && !ssl->priv->ssl_mode) {
if (!(fd = enable_ssl (ssl, NULL))) {
set_errno (PR_GetError ());
return -1;
}
-
+
ssl->priv->sockfd = fd;
-
+
if (SSL_ResetHandshake (fd, FALSE) == SECFailure) {
set_errno (PR_GetError ());
return -1;
}
-
+
if (SSL_ForceHandshake (fd) == -1) {
set_errno (PR_GetError ());
return -1;
}
}
-
+
ssl->priv->ssl_mode = TRUE;
-
+
return 0;
}
CamelTcpStreamSSL *tcp_stream_ssl = CAMEL_TCP_STREAM_SSL (stream);
PRFileDesc *cancel_fd;
ssize_t nread;
-
+
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
return -1;
}
-
+
cancel_fd = camel_operation_cancel_prfd (NULL);
if (cancel_fd == NULL) {
do {
PRPollDesc pollfds[2];
gboolean nonblock;
int error;
-
+
/* get O_NONBLOCK options */
sockopts.option = PR_SockOpt_Nonblocking;
PR_GetSocketOption (tcp_stream_ssl->priv->sockfd, &sockopts);
pollfds[0].in_flags = PR_POLL_READ;
pollfds[1].fd = cancel_fd;
pollfds[1].in_flags = PR_POLL_READ;
-
+
do {
PRInt32 res;
} while (nread == -1 && (PR_GetError () == PR_PENDING_INTERRUPT_ERROR ||
PR_GetError () == PR_IO_PENDING_ERROR ||
PR_GetError () == PR_WOULD_BLOCK_ERROR));
-
+
/* restore O_NONBLOCK options */
failed:
error = errno;
PR_SetSocketOption (tcp_stream_ssl->priv->sockfd, &sockopts);
errno = error;
}
-
+
return nread;
}
CamelTcpStreamSSL *tcp_stream_ssl = CAMEL_TCP_STREAM_SSL (stream);
ssize_t w, written = 0;
PRFileDesc *cancel_fd;
-
+
if (camel_operation_cancel_check (NULL)) {
errno = EINTR;
return -1;
}
-
+
cancel_fd = camel_operation_cancel_prfd (NULL);
if (cancel_fd == NULL) {
do {
} while (w == -1 && (PR_GetError () == PR_PENDING_INTERRUPT_ERROR ||
PR_GetError () == PR_IO_PENDING_ERROR ||
PR_GetError () == PR_WOULD_BLOCK_ERROR));
-
+
if (w > 0)
written += w;
} while (w != -1 && written < n);
PRPollDesc pollfds[2];
gboolean nonblock;
int error;
-
+
/* get O_NONBLOCK options */
sockopts.option = PR_SockOpt_Nonblocking;
PR_GetSocketOption (tcp_stream_ssl->priv->sockfd, &sockopts);
nonblock = sockopts.value.non_blocking;
sockopts.value.non_blocking = TRUE;
PR_SetSocketOption (tcp_stream_ssl->priv->sockfd, &sockopts);
-
+
pollfds[0].fd = tcp_stream_ssl->priv->sockfd;
pollfds[0].in_flags = PR_POLL_WRITE;
pollfds[1].fd = cancel_fd;
pollfds[1].in_flags = PR_POLL_READ;
-
+
do {
PRInt32 res;
if (w == -1)
set_errno (PR_GetError ());
} while (w == -1 && PR_GetError () == PR_PENDING_INTERRUPT_ERROR);
-
+
if (w == -1) {
if (PR_GetError () == PR_IO_PENDING_ERROR ||
PR_GetError () == PR_WOULD_BLOCK_ERROR)
written += w;
}
} while (w != -1 && written < n);
-
+
/* restore O_NONBLOCK options */
error = errno;
sockopts.option = PR_SockOpt_Nonblocking;
PR_SetSocketOption (tcp_stream_ssl->priv->sockfd, &sockopts);
errno = error;
}
-
+
if (w == -1)
return -1;
-
+
return written;
}
if (PR_Close (((CamelTcpStreamSSL *)stream)->priv->sockfd) == PR_FAILURE)
return -1;
-
+
((CamelTcpStreamSSL *)stream)->priv->sockfd = NULL;
-
+
return 0;
}
ssl_get_client_auth (void *data, PRFileDesc *sockfd,
struct CERTDistNamesStr *caNames,
struct CERTCertificateStr **pRetCert,
- struct SECKEYPrivateKeyStr **pRetKey)
+ struct SECKEYPrivateKeyStr **pRetKey)
{
SECStatus status = SECFailure;
SECKEYPrivateKey *privkey;
CERTCertificate *cert;
void *proto_win;
-
+
proto_win = SSL_RevealPinArg (sockfd);
-
+
if ((char *) data) {
cert = PK11_FindCertFromNickname ((char *) data, proto_win);
if (cert) {
/* no nickname given, automatically find the right cert */
CERTCertNicknames *names;
int i;
-
- names = CERT_GetCertNicknames (CERT_GetDefaultCertDB (),
+
+ names = CERT_GetCertNicknames (CERT_GetDefaultCertDB (),
SEC_CERT_NICKNAMES_USER,
proto_win);
-
+
if (names != NULL) {
for (i = 0; i < names->numnicknames; i++) {
- cert = PK11_FindCertFromNickname (names->nicknames[i],
+ cert = PK11_FindCertFromNickname (names->nicknames[i],
proto_win);
if (!cert)
continue;
-
+
/* Only check unexpired certs */
if (CERT_CheckCertValidTimes (cert, PR_Now (), PR_FALSE) != secCertTimeValid) {
CERT_DestroyCertificate (cert);
continue;
}
-
+
status = NSS_CmpCertChainWCANames (cert, caNames);
if (status == SECSuccess) {
privkey = PK11_FindKeyByAnyCert (cert, proto_win);
if (privkey)
break;
-
+
status = SECFailure;
break;
}
-
+
CERT_FreeNicknames (names);
}
}
}
-
+
if (status == SECSuccess) {
*pRetCert = cert;
*pRetKey = privkey;
}
-
+
return status;
}
#endif
SECStatus status;
void *pinarg;
char *host;
-
+
cert = SSL_PeerCertificate (sockfd);
pinarg = SSL_RevealPinArg (sockfd);
status = CERT_VerifyCertNow ((CERTCertDBHandle *)data, cert,
checksig, certUsageSSLClient, pinarg);
-
+
if (status != SECSuccess)
return SECFailure;
-
+
/* Certificate is OK. Since this is the client side of an SSL
* connection, we need to verify that the name field in the cert
* matches the desired hostname. This is our defense against
* man-in-the-middle attacks.
*/
-
+
/* SSL_RevealURL returns a hostname, not a URL. */
host = SSL_RevealURL (sockfd);
-
+
if (host && *host) {
status = CERT_VerifyCertName (cert, host);
} else {
PR_SetError (SSL_ERROR_BAD_CERT_DOMAIN, 0);
status = SECFailure;
}
-
+
if (host)
PR_Free (host);
-
+
return secStatus;
}
#endif
char *dir, *path, *fingerprint;
CamelStream *stream;
struct stat st;
-
+
fingerprint = ccert->fingerprint;
-
+
if (ccert->rawcert == NULL)
ccert->rawcert = g_byte_array_new ();
-
+
g_byte_array_set_size (ccert->rawcert, cert->derCert.len);
memcpy (ccert->rawcert->data, cert->derCert.data, cert->derCert.len);
-
+
#ifndef G_OS_WIN32
dir = g_strdup_printf ("%s/.camel_certs", getenv ("HOME"));
#else
g_free (dir);
return;
}
-
+
path = g_strdup_printf ("%s/%s", dir, fingerprint);
g_free (dir);
-
+
stream = camel_stream_fs_new_with_name (path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (stream != NULL) {
if (camel_stream_write (stream, ccert->rawcert->data, ccert->rawcert->len) == -1) {
} else {
g_warning ("Could not save cert: %s: %s", path, strerror (errno));
}
-
+
g_free (path);
}
g_return_val_if_fail (CAMEL_IS_TCP_STREAM_SSL (data), SECFailure);
ssl = data;
-
+
cert = SSL_PeerCertificate (sockfd);
if (cert == NULL)
return SECFailure;
prompt = g_strdup_printf (_("SSL Certificate check for %s:\n\n%s\n\nDo you wish to accept?"),
ssl->priv->expected_host, cert_str);
g_free (cert_str);
-
+
/* query the user to find out if we want to accept this certificate */
accept = camel_session_alert_user (ssl->priv->session, CAMEL_SESSION_ALERT_WARNING, prompt, TRUE);
g_free(prompt);
cert->trust = (CERTCertTrust*)PORT_ArenaZAlloc(cert->arena, sizeof(CERTCertTrust));
CERT_DecodeTrustString(cert->trust, "P");
}
-
+
certs[0] = &cert->derCert;
/*CERT_ImportCerts (cert->dbhandle, certUsageSSLServer, 1, certs, NULL, TRUE, FALSE, nick);*/
CERT_ImportCerts(cert->dbhandle, certUsageUserCertImport, 1, certs, NULL, TRUE, FALSE, nick);
}
break;
-
+
case SEC_ERROR_EXPIRED_CERTIFICATE:
printf("expired\n");
enable_ssl (CamelTcpStreamSSL *ssl, PRFileDesc *fd)
{
PRFileDesc *ssl_fd;
-
+
ssl_fd = SSL_ImportFD (NULL, fd ? fd : ssl->priv->sockfd);
if (!ssl_fd)
return NULL;
-
+
SSL_OptionSet (ssl_fd, SSL_SECURITY, PR_TRUE);
if (ssl->priv->flags & CAMEL_TCP_STREAM_SSL_ENABLE_SSL2) {
SSL_OptionSet (ssl_fd, SSL_ENABLE_SSL2, PR_TRUE);
SSL_OptionSet (ssl_fd, SSL_ENABLE_TLS, PR_TRUE);
else
SSL_OptionSet (ssl_fd, SSL_ENABLE_TLS, PR_FALSE);
-
+
SSL_SetURL (ssl_fd, ssl->priv->expected_host);
-
+
/*SSL_GetClientAuthDataHook (sslSocket, ssl_get_client_auth, (void *) certNickname);*/
/*SSL_AuthCertificateHook (ssl_fd, ssl_auth_cert, (void *) CERT_GetDefaultCertDB ());*/
SSL_BadCertHook (ssl_fd, ssl_bad_cert, ssl);
-
+
ssl->priv->ssl_mode = TRUE;
-
+
return ssl_fd;
}
errno = EINVAL;
return -1;
}
-
+
fd = PR_OpenTCPSocket(netaddr.raw.family);
if (fd == NULL) {
set_errno (PR_GetError ());
return -1;
}
-
+
if (ssl->priv->ssl_mode) {
PRFileDesc *ssl_fd;
-
+
ssl_fd = enable_ssl (ssl, fd);
if (ssl_fd == NULL) {
int errnosave;
-
+
set_errno (PR_GetError ());
errnosave = errno;
PR_Close (fd);
errno = errnosave;
-
+
return -1;
}
-
+
fd = ssl_fd;
}
if (PR_Connect (fd, &netaddr, cancel_fd?0:CONNECT_TIMEOUT) == PR_FAILURE) {
int errnosave;
-
+
set_errno (PR_GetError ());
if (PR_GetError () == PR_IN_PROGRESS_ERROR ||
(cancel_fd && (PR_GetError () == PR_CONNECT_TIMEOUT_ERROR ||
poll[0].in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;
poll[1].fd = cancel_fd;
poll[1].in_flags = PR_POLL_READ;
-
+
do {
poll[0].out_flags = 0;
poll[1].out_flags = 0;
set_errno (PR_GetError ());
goto exception;
}
-
+
if (poll[1].out_flags == PR_POLL_READ) {
errno = EINTR;
goto exception;
PR_Close (fd);
ssl->priv->sockfd = NULL;
errno = errnosave;
-
+
return -1;
}
-
+
errno = 0;
}
-
+
ssl->priv->sockfd = fd;
return 0;
stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
{
PRSocketOptionData sodata;
-
+
memset ((void *) &sodata, 0, sizeof (sodata));
memcpy ((void *) &sodata, (void *) data, sizeof (CamelSockOptData));
-
+
if (PR_GetSocketOption (((CamelTcpStreamSSL *)stream)->priv->sockfd, &sodata) == PR_FAILURE)
return -1;
-
+
memcpy ((void *) data, (void *) &sodata, sizeof (CamelSockOptData));
-
+
return 0;
}
stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
{
PRSocketOptionData sodata;
-
+
memset ((void *) &sodata, 0, sizeof (sodata));
memcpy ((void *) &sodata, (void *) data, sizeof (CamelSockOptData));
-
+
if (PR_SetSocketOption (((CamelTcpStreamSSL *)stream)->priv->sockfd, &sodata) == PR_FAILURE)
return -1;
-
+
return 0;
}
sin->sin6_scope_id = addr->ipv6.scope_id;
*len = sizeof(*sin);
- return (struct sockaddr *)sin;
+ return (struct sockaddr *)sin;
}
#endif
{
PRFileDesc *sockfd = CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd;
PRNetAddr addr;
-
+
if (PR_GetSockName(sockfd, &addr) != PR_SUCCESS)
return NULL;
{
PRFileDesc *sockfd = CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd;
PRNetAddr addr;
-
+
if (PR_GetPeerName(sockfd, &addr) != PR_SUCCESS)
return NULL;
struct _CamelTcpStreamSSL {
CamelTcpStream parent_object;
-
+
struct _CamelTcpStreamSSLPrivate *priv;
};
typedef struct {
CamelTcpStreamClass parent_class;
-
+
/* virtual functions */
-
+
} CamelTcpStreamSSLClass;
/* Standard Camel function */
camel_tcp_stream_class_init (CamelTcpStreamClass *camel_tcp_stream_class)
{
/*CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_tcp_stream_class);*/
-
+
parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (CAMEL_STREAM_TYPE));
-
+
/* tcp stream methods */
camel_tcp_stream_class->connect = tcp_connect;
camel_tcp_stream_class->getsockopt = tcp_getsockopt;
camel_tcp_stream_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (CAMEL_STREAM_TYPE,
"CamelTcpStream",
camel_tcp_stream_connect (CamelTcpStream *stream, struct addrinfo *host)
{
g_return_val_if_fail (CAMEL_IS_TCP_STREAM (stream), -1);
-
+
return CTS_CLASS (stream)->connect (stream, host);
}
camel_tcp_stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
{
g_return_val_if_fail (CAMEL_IS_TCP_STREAM (stream), -1);
-
+
return CTS_CLASS (stream)->getsockopt (stream, data);
}
camel_tcp_stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
{
g_return_val_if_fail (CAMEL_IS_TCP_STREAM (stream), -1);
-
+
return CTS_CLASS (stream)->setsockopt (stream, data);
}
{
g_return_val_if_fail (CAMEL_IS_TCP_STREAM (stream), NULL);
g_return_val_if_fail(len != NULL, NULL);
-
+
return CTS_CLASS (stream)->get_local_address (stream, len);
}
CAMEL_SOCKOPT_KEEPALIVE, /* keep connections alive */
CAMEL_SOCKOPT_RECVBUFFERSIZE, /* receive buffer size */
CAMEL_SOCKOPT_SENDBUFFERSIZE, /* send buffer size */
-
+
CAMEL_SOCKOPT_IPTIMETOLIVE, /* time to live */
CAMEL_SOCKOPT_IPTYPEOFSERVICE, /* type of service and precedence */
-
+
CAMEL_SOCKOPT_ADDMEMBER, /* add an IP group membership */
CAMEL_SOCKOPT_DROPMEMBER, /* drop an IP group membership */
CAMEL_SOCKOPT_MCASTINTERFACE, /* multicast interface address */
CAMEL_SOCKOPT_MCASTTIMETOLIVE, /* multicast timetolive */
CAMEL_SOCKOPT_MCASTLOOPBACK, /* multicast loopback */
-
+
CAMEL_SOCKOPT_NODELAY, /* don't delay send to coalesce packets */
CAMEL_SOCKOPT_MAXSEGMENT, /* maximum segment size */
CAMEL_SOCKOPT_BROADCAST, /* enable broadcast */
struct _CamelTcpStream {
CamelStream parent_object;
-
+
};
typedef struct {
int (*connect) (CamelTcpStream *stream, struct addrinfo *host);
int (*getsockopt) (CamelTcpStream *stream, CamelSockOptData *data);
int (*setsockopt) (CamelTcpStream *stream, const CamelSockOptData *data);
-
+
struct sockaddr * (*get_local_address) (CamelTcpStream *stream, socklen_t *len);
struct sockaddr * (*get_remote_address) (CamelTcpStream *stream, socklen_t *len);
} CamelTcpStreamClass;
#define w(x)
-#define io(x)
+#define io(x)
#define d(x) /*(printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__),(x))*/
/* cursor debug */
return;
}
}
-
+
w = g_malloc0(sizeof(*w));
w->word = g_strdup(word);
w->wordid = wordid;
g_hash_table_remove(p->words, ww->word);
g_free(ww->word);
g_free(ww);
- }
+ }
if (camel_key_table_sync(p->word_index) == -1
|| camel_key_table_sync(p->name_index) == -1
}
g_free(records);
}
-
+
if (newcount > 0) {
if (camel_key_file_write(newp->links, &newdata, newcount, newrecords) == -1)
goto fail;
}
camel_block_file_touch_block(newp->blocks, newp->blocks->root_block);
-
+
if (camel_index_sync((CamelIndex *)newidx) == -1)
goto fail;
camel_key_table_set_flags(p->name_index, keyid, 1, 1);
camel_partition_table_remove(p->name_hash, name);
}
-
+
keyid = camel_key_table_add(p->name_index, name, 0, 0);
if (keyid != 0) {
camel_partition_table_add(p->name_hash, name, keyid);
/* see text_index_add_name for when this can be 0 */
if (((CamelTextIndexName *)idn)->priv->nameid != 0) {
CAMEL_TEXT_INDEX_LOCK(idx, lock);
-
+
g_hash_table_foreach(idn->words, (GHFunc)hash_write_word, idn);
-
+
CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
}
/* this cache size and the block cache size have been tuned for about the best
with moderate memory usage. Doubling the memory usage barely affects performance. */
p->word_cache_limit = 4096; /* 1024 = 128K */
-
+
g_static_rec_mutex_init(&p->lock);
}
camel_object_unref((CamelObject *)p->blocks);
if (p->links)
camel_object_unref((CamelObject *)p->links);
-
+
g_static_rec_mutex_free(&p->lock);
-
+
g_free(p);
}
camel_text_index_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_index_get_type(), "CamelTextIndex",
sizeof (CamelTextIndex),
(CamelObjectInitFunc) camel_text_index_init,
(CamelObjectFinalizeFunc) camel_text_index_finalise);
}
-
+
return type;
}
rb->word_index_root = bl->id;
camel_block_file_unref_block(p->blocks, bl);
camel_block_file_touch_block(p->blocks, p->blocks->root_block);
- }
+ }
if (rb->word_hash_root == 0) {
bl = camel_block_file_new_block(p->blocks);
rb->word_hash_root = bl->id;
camel_block_file_unref_block(p->blocks, bl);
camel_block_file_touch_block(p->blocks, p->blocks->root_block);
- }
+ }
if (rb->name_index_root == 0) {
bl = camel_block_file_new_block(p->blocks);
rb->name_index_root = bl->id;
camel_block_file_unref_block(p->blocks, bl);
camel_block_file_touch_block(p->blocks, p->blocks->root_block);
- }
+ }
if (rb->name_hash_root == 0) {
bl = camel_block_file_new_block(p->blocks);
rb->name_hash_root = bl->id;
camel_block_file_unref_block(p->blocks, bl);
camel_block_file_touch_block(p->blocks, p->blocks->root_block);
- }
+ }
p->word_index = camel_key_table_new(p->blocks, rb->word_index_root);
p->word_hash = camel_partition_table_new(p->blocks, rb->word_hash_root);
CamelIndexCursor *idc;
printf("Word: '%s':\n", word);
-
+
idc = camel_index_find((CamelIndex *)idx, word);
while ( (name = camel_index_cursor_next(idc)) ) {
printf(" %s", name);
text_index_name_add_word(idn, p->buffer->str);
/*camel_index_name_add_word(idn, p->buffer->str);*/
}
-
+
g_string_truncate (p->buffer, 0);
}
}
camel_text_index_name_finalise(CamelTextIndexName *idn)
{
CamelTextIndexNamePrivate *p = CIN_PRIVATE(idn);
-
+
g_hash_table_destroy(idn->parent.words);
g_string_free(p->buffer, TRUE);
camel_text_index_name_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_index_name_get_type(), "CamelTextIndexName",
sizeof (CamelTextIndexName),
(CamelObjectInitFunc) camel_text_index_name_init,
(CamelObjectFinalizeFunc) camel_text_index_name_finalise);
}
-
+
return type;
}
if (flags & 1) {
g_free(p->current);
p->current = NULL;
- }
+ }
p->record_index++;
} while (p->current == NULL);
camel_text_index_cursor_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_index_cursor_get_type(), "CamelTextIndexCursor",
sizeof (CamelTextIndexCursor),
(CamelObjectInitFunc) camel_text_index_cursor_init,
(CamelObjectFinalizeFunc) camel_text_index_cursor_finalise);
}
-
+
return type;
}
camel_text_index_key_cursor_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_index_cursor_get_type(), "CamelTextIndexKeyCursor",
sizeof (CamelTextIndexKeyCursor),
(CamelObjectInitFunc) camel_text_index_key_cursor_init,
(CamelObjectFinalizeFunc) camel_text_index_key_cursor_finalise);
}
-
+
return type;
}
line[strlen(line)-1] = 0;
/* see if its already there */
- keyid = camel_partition_table_lookup(cpi, line);
+ keyid = camel_partition_table_lookup(cpi, line);
if (keyid == 0) {
m(printf("Adding word '%s' %d\n", line, index));
camel_partition_table_add(cpi, line, keyid);
m(printf("Lookup word '%s'\n", line));
- keyid = camel_partition_table_lookup(cpi, line);
+ keyid = camel_partition_table_lookup(cpi, line);
m(printf(" key = %08x\n", keyid));
}
while (fgets(line, sizeof(line), fp) != NULL) {
line[strlen(line)-1] = 0;
m(printf("Lookup word '%s' %d\n", line, index));
- keyid = camel_partition_table_lookup(cpi, line);
+ keyid = camel_partition_table_lookup(cpi, line);
m(printf(" key = %08d\n", keyid));
m(printf("Lookup key %08x\n", keyid));
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-transport.c : Abstract class for an email transport */
-/*
+/*
*
- * Author :
+ * Author :
* Dan Winship <danw@ximian.com>
*
* Copyright 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
camel_transport_class_init (CamelTransportClass *camel_transport_class)
{
CamelObjectClass *camel_object_class = CAMEL_OBJECT_CLASS (camel_transport_class);
-
+
parent_class = CAMEL_SERVICE_CLASS (camel_type_get_global_classfuncs (camel_service_get_type ()));
-
+
/* virtual method overload */
camel_object_class->setv = transport_setv;
camel_object_class->getv = transport_getv;
camel_transport_init (gpointer object, gpointer klass)
{
CamelTransport *xport = object;
-
+
xport->priv = g_malloc0 (sizeof (struct _CamelTransportPrivate));
xport->priv->send_lock = g_mutex_new ();
}
camel_transport_finalize (CamelObject *object)
{
CamelTransport *xport = CAMEL_TRANSPORT (object);
-
+
g_mutex_free (xport->priv->send_lock);
g_free (xport->priv);
}
camel_transport_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (CAMEL_SERVICE_TYPE,
"CamelTransport",
(CamelObjectInitFunc) camel_transport_init,
(CamelObjectFinalizeFunc) camel_transport_finalize);
}
-
+
return type;
}
CamelException *ex)
{
gboolean sent;
-
+
g_return_val_if_fail (CAMEL_IS_TRANSPORT (transport), FALSE);
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), FALSE);
g_return_val_if_fail (CAMEL_IS_ADDRESS (from), FALSE);
g_return_val_if_fail (CAMEL_IS_ADDRESS (recipients), FALSE);
-
+
CAMEL_TRANSPORT_LOCK (transport, send_lock);
sent = CT_CLASS (transport)->send_to (transport, message,
from, recipients, ex);
CAMEL_TRANSPORT_UNLOCK (transport, send_lock);
-
+
return sent;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-transport.h : Abstract class for an email transport */
-/*
+/*
*
- * Author :
+ * Author :
* Dan Winship <danw@ximian.com>
*
* Copyright 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
struct _CamelTransport
{
CamelService parent_object;
-
+
struct _CamelTransportPrivate *priv;
};
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-uid-cache.c: UID caching code. */
-/*
+/*
* Authors:
* Dan Winship <danw@ximian.com>
*
* Copyright 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
struct stat st;
char *dirname, *buf, **uids;
int fd, i;
-
+
dirname = g_path_get_dirname (filename);
if (g_mkdir_with_parents (dirname, 0777) == -1) {
g_free (dirname);
return NULL;
}
-
+
g_free (dirname);
-
+
if ((fd = g_open (filename, O_RDONLY | O_CREAT | O_BINARY, 0666)) == -1)
return NULL;
-
+
if (fstat (fd, &st) == -1) {
close (fd);
return NULL;
}
-
+
buf = g_malloc (st.st_size + 1);
-
+
if (st.st_size > 0 && camel_read (fd, buf, st.st_size) == -1) {
close (fd);
g_free (buf);
return NULL;
}
-
+
buf[st.st_size] = '\0';
-
+
close (fd);
-
+
cache = g_new (CamelUIDCache, 1);
cache->uids = g_hash_table_new (g_str_hash, g_str_equal);
cache->filename = g_strdup (filename);
cache->expired = 0;
cache->size = 0;
cache->fd = -1;
-
+
uids = g_strsplit (buf, "\n", 0);
g_free (buf);
for (i = 0; uids[i]; i++) {
struct _uid_state *state;
-
+
state = g_new (struct _uid_state, 1);
state->level = cache->level;
state->save = TRUE;
-
+
g_hash_table_insert (cache->uids, uids[i], state);
}
-
+
g_free (uids);
-
+
return cache;
}
{
CamelUIDCache *cache = data;
struct _uid_state *state = value;
-
+
if (cache->fd == -1)
return;
-
+
if (state && state->level == cache->level && state->save) {
- if (camel_write (cache->fd, key, strlen (key)) == -1 ||
+ if (camel_write (cache->fd, key, strlen (key)) == -1 ||
camel_write (cache->fd, "\n", 1) == -1) {
cache->fd = -1;
} else {
char *filename;
int errnosav;
int fd;
-
+
filename = g_strdup_printf ("%s~", cache->filename);
if ((fd = g_open (filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666)) == -1) {
g_free (filename);
return FALSE;
}
-
+
cache->fd = fd;
cache->size = 0;
cache->expired = 0;
g_hash_table_foreach (cache->uids, maybe_write_uid, cache);
-
+
if (fsync (fd) == -1)
goto exception;
-
+
close (fd);
fd = -1;
cache->fd = -1;
if (g_rename (filename, cache->filename) == -1)
goto exception;
-
+
g_free (filename);
-
+
return TRUE;
-
+
exception:
-
+
errnosav = errno;
-
+
#ifdef ENABLE_SPASMOLYTIC
if (fd != -1) {
/*
* more), then we should replace the old cache with
* the new cache as well.
*/
-
+
if (g_stat (cache->filename, &st) == 0 &&
(cache->size > st.st_size || cache->size + cache->expired > st.st_size)) {
if (ftruncate (fd, (off_t) cache->size) != -1) {
cache->expired = 0;
goto overwrite; /* FIXME: no such label */
}
- }
+ }
}
#endif
if (fd != -1) {
g_unlink (filename);
g_free (filename);
-
+
errno = errnosav;
-
+
return FALSE;
}
gpointer old_uid;
char *uid;
int i;
-
+
new_uids = g_ptr_array_new ();
cache->level++;
for (i = 0; i < uids->len; i++) {
struct _uid_state *state;
-
+
uid = uids->pdata[i];
if (g_hash_table_lookup_extended (cache->uids, uid, (void **)&old_uid, (void **)&state)) {
g_hash_table_remove (cache->uids, uid);
state = g_new (struct _uid_state, 1);
state->save = FALSE;
}
-
+
state->level = cache->level;
g_hash_table_insert (cache->uids, g_strdup (uid), state);
}
-
+
return new_uids;
}
{
struct _uid_state *state;
gpointer old_uid;
-
+
g_return_if_fail (uid != NULL);
if (g_hash_table_lookup_extended (cache->uids, uid, (void **)&old_uid, (void **)&state)) {
camel_uid_cache_free_uids (GPtrArray *uids)
{
int i;
-
+
for (i = 0; i < uids->len; i++)
g_free (uids->pdata[i]);
g_ptr_array_free (uids, TRUE);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-uid-cache.h: UID caching code. */
-/*
+/*
* Authors:
* Bertrand Guiheneuf <bertrand@helixcode.com>
*
* Copyright 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
camel_url_scanner_new (void)
{
CamelUrlScanner *scanner;
-
+
scanner = g_new (CamelUrlScanner, 1);
scanner->patterns = g_ptr_array_new ();
scanner->trie = e_trie_new (TRUE);
-
+
return scanner;
}
camel_url_scanner_free (CamelUrlScanner *scanner)
{
g_return_if_fail (scanner != NULL);
-
+
g_ptr_array_free (scanner->patterns, TRUE);
e_trie_free (scanner->trie);
g_free (scanner);
camel_url_scanner_add (CamelUrlScanner *scanner, urlpattern_t *pattern)
{
g_return_if_fail (scanner != NULL);
-
+
e_trie_add (scanner->trie, pattern->pattern, scanner->patterns->len);
g_ptr_array_add (scanner->patterns, pattern);
}
const unsigned char *inptr, *inend;
urlpattern_t *pat;
int pattern;
-
+
g_return_val_if_fail (scanner != NULL, FALSE);
g_return_val_if_fail (in != NULL, FALSE);
-
+
inptr = (const unsigned char *) in;
inend = inptr + inlen;
-
+
do {
if (!(pos = e_trie_search (scanner->trie, (const char *)inptr, inlen, &pattern)))
return FALSE;
-
+
pat = g_ptr_array_index (scanner->patterns, pattern);
-
+
match->pattern = pat->pattern;
match->prefix = pat->prefix;
-
+
if (pat->start (in, pos, (const char *)inend, match) && pat->end (in, pos, (const char *)inend, match))
return TRUE;
-
+
inptr = (const unsigned char *) pos;
if (camel_utf8_getc_limit (&inptr, inend) == 0xffff)
break;
-
+
inlen = inend - inptr;
} while (inptr < inend);
-
+
return FALSE;
}
is_open_brace (char c)
{
int i;
-
+
for (i = 0; i < G_N_ELEMENTS (url_braces); i++) {
if (c == url_braces[i].open)
return TRUE;
}
-
+
return FALSE;
}
if (so > 0) {
for (i = 0; i < G_N_ELEMENTS (url_braces); i++) {
if (in[so - 1] == url_braces[i].open) {
- if (open_brace != NULL)
+ if (open_brace != NULL)
*open_brace = url_braces[i].open;
return url_braces[i].close;
}
}
}
-
+
return '\0';
}
camel_url_addrspec_start (const char *in, const char *pos, const char *inend, urlmatch_t *match)
{
register const char *inptr = pos;
-
+
g_assert (*inptr == '@');
-
+
if (inptr > in)
inptr--;
-
+
while (inptr > in) {
if (is_atom (*inptr))
inptr--;
else
break;
-
+
while (inptr > in && is_atom (*inptr))
inptr--;
-
+
if (inptr > in && *inptr == '.')
inptr--;
}
-
+
while (!is_atom (*inptr) || is_open_brace (*inptr))
inptr++;
-
+
if (inptr >= pos)
return FALSE;
-
+
match->um_so = (inptr - in);
-
+
return TRUE;
}
const char *inptr = pos;
int parts = 0, digits;
gboolean got_dot = FALSE;
-
+
g_assert (*inptr == '@');
-
+
inptr++;
-
+
if (*inptr == '[') {
/* domain literal */
do {
inptr++;
-
+
digits = 0;
while (inptr < inend && is_digit (*inptr) && digits < 3) {
inptr++;
digits++;
}
-
+
parts++;
-
+
if (*inptr != '.' && parts != 4)
return FALSE;
} while (parts < 4);
-
+
if (*inptr == ']')
inptr++;
else
return FALSE;
-
+
got_dot = TRUE;
} else {
while (inptr < inend) {
inptr++;
else
break;
-
+
while (inptr < inend && is_domain (*inptr))
inptr++;
-
+
if (inptr < inend && *inptr == '.' && is_domain (inptr[1])) {
if (*inptr == '.')
got_dot = TRUE;
}
}
}
-
+
/* don't allow toplevel domains */
if (inptr == pos + 1 || !got_dot)
return FALSE;
-
+
match->um_eo = (inptr - in);
-
+
return TRUE;
}
camel_url_file_start (const char *in, const char *pos, const char *inend, urlmatch_t *match)
{
match->um_so = (pos - in);
-
+
return TRUE;
}
{
register const char *inptr = pos;
char close_brace;
-
+
inptr += strlen (match->pattern);
-
+
if (*inptr == '/')
inptr++;
-
+
close_brace = url_stop_at_brace (in, match->um_so, NULL);
-
+
while (inptr < inend && is_urlsafe (*inptr) && *inptr != close_brace)
inptr++;
-
+
if (inptr == pos)
return FALSE;
-
+
match->um_eo = (inptr - in);
-
+
return TRUE;
}
if (!is_open_brace (pos[-1]) && !isspace (pos[-1]))
return FALSE;
}
-
+
match->um_so = (pos - in);
-
+
return TRUE;
}
int port;
inptr += strlen (match->pattern);
-
+
close_brace = url_stop_at_brace (in, match->um_so, &open_brace);
/* find the end of the domain */
while (inptr < inend) {
if (!is_atom (*inptr))
break;
-
+
inptr++;
-
+
while (inptr < inend && is_atom (*inptr))
inptr++;
-
- if ((inptr + 1) < inend && *inptr == '.' && (is_atom (inptr[1]) || inptr[1] == '/'))
+
+ if ((inptr + 1) < inend && *inptr == '.' && (is_atom (inptr[1]) || inptr[1] == '/'))
inptr++;
}
-
+
if (*inptr != '@')
inptr = save;
else
inptr++;
-
+
goto domain;
} else if (is_domain (*inptr)) {
domain:
while (inptr < inend) {
if (!is_domain (*inptr))
break;
-
+
inptr++;
-
+
while (inptr < inend && is_domain (*inptr))
inptr++;
-
- if ((inptr + 1) < inend && *inptr == '.' && (is_domain (inptr[1]) || inptr[1] == '/'))
+
+ if ((inptr + 1) < inend && *inptr == '.' && (is_domain (inptr[1]) || inptr[1] == '/'))
inptr++;
}
} else {
return FALSE;
}
-
+
if (inptr < inend) {
switch (*inptr) {
case ':': /* we either have a port or a password */
inptr++;
-
+
if (is_digit (*inptr) || passwd) {
port = (*inptr++ - '0');
-
+
while (inptr < inend && is_digit (*inptr) && port < 65536)
port = (port * 10) + (*inptr++ - '0');
-
+
if (!passwd && (port >= 65536 || *inptr == '@')) {
if (inptr < inend) {
/* this must be a password? */
goto passwd;
}
-
+
inptr--;
}
} else {
passwd:
passwd = TRUE;
save = inptr;
-
+
while (inptr < inend && is_atom (*inptr))
inptr++;
-
+
if ((inptr + 2) < inend) {
if (*inptr == '@') {
inptr++;
if (is_domain (*inptr))
goto domain;
}
-
+
return FALSE;
}
}
-
+
if (inptr >= inend || *inptr != '/')
break;
-
+
/* we have a '/' so there could be a path - fall through */
case '/': /* we've detected a path component to our url */
inptr++;
match->um_eo = (inptr - in);
-
+
return TRUE;
}
table_init_bits (unsigned int mask, const unsigned char *vals)
{
int i;
-
+
for (i = 0; vals[i] != '\0'; i++)
url_scanner_table[vals[i]] |= mask;
}
url_scanner_table_init (void)
{
int i;
-
+
for (i = 0; i < 256; i++) {
url_scanner_table[i] = 0;
if (i < 32)
if (i >= 127)
url_scanner_table[i] |= IS_CTRL;
}
-
+
url_scanner_table[' '] |= IS_SPACE;
url_scanner_table['-'] |= IS_DOMAIN;
-
+
/* not defined to be special in rfc0822, but when scanning
backwards to find the beginning of the email address we do
not want to include this char if we come accross it - so
this is kind of a hack */
url_scanner_table['/'] |= IS_SPECIAL;
-
+
table_init_bits (IS_LWSP, CHARS_LWSP);
table_init_bits (IS_SPECIAL, CHARS_SPECIAL);
table_init_bits (IS_URLSAFE, CHARS_URLSAFE);
int main (int argc, char **argv)
{
int i;
-
+
url_scanner_table_init ();
-
+
printf ("static unsigned char url_scanner_table[256] = {");
for (i = 0; i < 256; i++) {
printf ("%s%3d%s", (i % 16) ? "" : "\n\t",
url_scanner_table[i], i != 255 ? "," : "\n");
}
printf ("};\n\n");
-
+
return 0;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-url.c : utility functions to parse URLs */
-/*
+/*
* Authors:
* Dan Winship <danw@ximian.com>
* Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright 1999-2001 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* IF YOU CHANGE ANYTHING IN THIS FUNCTION, RUN
* tests/misc/url AFTERWARD.
*/
-
+
#ifdef G_OS_WIN32
if (url->protocol && !strcmp(url->protocol, "file"))
return g_filename_to_uri(url->path, url->host, NULL);
#endif
-
+
str = g_string_sized_new (20);
-
+
if (url->protocol)
g_string_append_printf (str, "%s:", url->protocol);
-
+
if (url->host) {
g_string_append (str, "//");
if (url->user) {
if (!url->path && (url->params || url->query || url->fragment))
g_string_append_c (str, '/');
}
-
+
if (url->path)
append_url_encoded (str, url->path, ";?");
if (url->params && !(flags & CAMEL_URL_HIDE_PARAMS))
g_string_append_c (str, '#');
append_url_encoded (str, url->fragment, NULL);
}
-
+
return_result = str->str;
g_string_free (str, FALSE);
-
+
return return_result;
}
g_datalist_clear (&url->params);
g_free (url->query);
g_free (url->fragment);
-
+
g_free (url);
}
}
ADD_HASH (u->path);
ADD_HASH (u->query);
hash ^= u->port;
-
+
return hash;
}
else
return FALSE;
}
-
+
if (s2 == NULL)
return FALSE;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-url.h : utility functions to parse URLs */
-/*
+/*
* Authors:
* Bertrand Guiheneuf <bertrand@helixcode.com>
* Dan Winship <danw@ximian.com>
*
* Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/**
* camel_utf8_putc:
- * @ptr:
- * @c:
- *
+ * @ptr:
+ * @c:
+ *
* Output a 32 bit unicode character as utf8 octets. At most 4 octets will
* be written to @ptr. @ptr will be advanced to the next character position.
**/
/**
* camel_utf8_getc:
- * @ptr:
- *
+ * @ptr:
+ *
* Get a Unicode character from a utf8 stream. @ptr will be advanced
* to the next character position. Invalid utf8 characters will be
* silently skipped. @ptr should point to a NUL terminated array.
- *
+ *
* Return value: The next Unicode character. @ptr will be advanced to
* the next character always.
**/
r<<=1;
m<<=5;
} while (r & 0x40);
-
+
*ptr = p;
v &= ~m;
/**
* camel_utf8_getc_limit:
- * @ptr:
+ * @ptr:
* @end: must not be NULL.
- *
+ *
* Get the next utf8 char at @ptr, and return it, advancing @ptr to
* the next character. If @end is reached before a full utf8
* character can be read, then the invalid Unicode char 0xffff is
* returned as a sentinel (Unicode 3.1, section 2.7), and @ptr is not
* advanced.
- *
+ *
* Return value: The next utf8 char, or 0xffff.
**/
guint32
do {
if (p >= end)
return 0xffff;
-
+
c = *p++;
if ((c & 0xc0) != 0x80) {
r = c;
r<<=1;
m<<=5;
} while (r & 0x40);
-
+
*ptr = p;
-
+
v &= ~m;
return v;
} else {
/**
* camel_utf7_utf8:
- * @ptr:
- *
+ * @ptr:
+ *
* Convert a modified utf7 string to utf8. If the utf7 string
* contains 8 bit characters, they are treated as iso-8859-1.
- *
+ *
* The IMAP rules [rfc2060] are used in the utf7 encoding.
*
* Return value: The converted string.
/**
* camel_utf8_utf7:
- * @ptr:
- *
+ * @ptr:
+ *
* Convert a utf8 string to a modified utf7 format.
*
* The IMAP rules [rfc2060] are used in the utf7 encoding.
- *
- * Return value:
+ *
+ * Return value:
**/
char *
camel_utf8_utf7(const char *ptr)
/**
* camel_utf8_ucs2:
- * @ptr:
- *
+ * @ptr:
+ *
* Convert a utf8 string into a ucs2 one. The ucs string will be in
* network byte order, and terminated with a 16 bit NULL.
- *
- * Return value:
+ *
+ * Return value:
**/
char *
camel_utf8_ucs2(const char *pptr)
/**
* camel_ucs2_utf8:
- * @ptr:
- *
+ * @ptr:
+ *
* Convert a ucs2 string into a utf8 one. The ucs2 string is treated
* as network byte ordered, and terminated with a 16 bit NUL.
- *
- * Return value:
+ *
+ * Return value:
**/
char *camel_ucs2_utf8(const char *ptr)
{
#include "camel-vee-store.h" /* for open flags */
#include "camel-vee-summary.h"
-#define d(x)
+#define d(x)
#define dd(x) (camel_debug("vfolder")?(x):0)
#define _PRIVATE(o) (((CamelVeeFolder *)(o))->priv)
camel_vee_folder_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_folder_get_type (), "CamelVeeFolder",
sizeof (CamelVeeFolder),
(CamelObjectInitFunc) camel_vee_folder_init,
(CamelObjectFinalizeFunc) camel_vee_folder_finalise);
}
-
+
return type;
}
{
CamelVeeFolder *vf;
char *tmp;
-
+
if (CAMEL_IS_VEE_STORE(parent_store) && strcmp(full, CAMEL_UNMATCHED_NAME) == 0) {
vf = ((CamelVeeStore *)parent_store)->folder_unmatched;
camel_object_ref(vf);
struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
int i;
CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
-
+
if (vf == (CamelVeeFolder *)sub) {
g_warning("Adding a virtual folder to itself as source, ignored");
return;
if (g_list_find(p->folders, sub) == NULL) {
camel_object_ref((CamelObject *)sub);
p->folders = g_list_append(p->folders, sub);
-
+
CAMEL_FOLDER_LOCK(vf, change_lock);
/* update the freeze state of 'sub' to match our freeze state */
struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
int i;
CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
-
+
CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock);
CAMEL_VEE_FOLDER_LOCK(vf, changed_lock);
CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
return;
}
-
+
camel_object_unhook_event((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf);
camel_object_unhook_event((CamelObject *)sub, "deleted", (CamelObjectEventHookFunc) subfolder_deleted, vf);
camel_object_unhook_event((CamelObject *)sub, "renamed", (CamelObjectEventHookFunc) folder_renamed, vf);
p->folders = g_list_remove(p->folders, sub);
-
+
/* undo the freeze state that we have imposed on this source folder */
CAMEL_FOLDER_LOCK(vf, change_lock);
for (i = 0; i < ((CamelFolder *)vf)->priv->frozen; i++)
camel_folder_thaw(sub);
CAMEL_FOLDER_UNLOCK(vf, change_lock);
-
+
CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
if (folder_unmatched != NULL) {
while (g_list_find(up->folders, sub)) {
up->folders = g_list_remove(up->folders, sub);
camel_object_unref((CamelObject *)sub);
-
+
/* undo the freeze state that Unmatched has imposed on this source folder */
CAMEL_FOLDER_LOCK(folder_unmatched, change_lock);
for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
if (g_list_find(up->folders, sub) != NULL) {
up->folders = g_list_remove(up->folders, sub);
camel_object_unref((CamelObject *)sub);
-
+
/* undo the freeze state that Unmatched has imposed on this source folder */
CAMEL_FOLDER_LOCK(folder_unmatched, change_lock);
for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
if (CAMEL_IS_VEE_FOLDER(sub))
return;
-
+
camel_object_unref((CamelObject *)sub);
}
/**
* camel_vee_folder_set_folders:
- * @vf:
- * @folders:
- *
+ * @vf:
+ * @folders:
+ *
* Set the whole list of folder sources on a vee folder.
**/
void
/**
* camel_vee_folder_hash_folder:
- * @folder:
- * @:
- *
+ * @folder:
+ * @:
+ *
* Create a hash string representing the folder name, which should be
* unique, and remain static for a given folder.
**/
/**
* camel_vee_folder_get_location:
- * @vf:
- * @vinfo:
+ * @vf:
+ * @vinfo:
* @realuid: if not NULL, set to the uid of the real message, must be
* g_free'd by caller.
- *
+ *
* Find the real folder (and uid)
- *
- * Return value:
+ *
+ * Return value:
**/
CamelFolder *
camel_vee_folder_get_location(CamelVeeFolder *vf, const CamelVeeMessageInfo *vinfo, char **realuid)
struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
GHashTable *searched = g_hash_table_new(NULL, NULL);
CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
-
+
CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock);
-
+
if (vf != folder_unmatched)
expr = g_strdup_printf ("(and %s %s)", vf->expression ? vf->expression : "", expression);
else
expr = g_strdup (expression);
-
+
node = p->folders;
while (node) {
CamelFolder *f = node->data;
int i;
char hash[8];
-
+
/* make sure we only search each folder once - for unmatched folder to work right */
if (g_hash_table_lookup(searched, f) == NULL) {
camel_vee_folder_hash_folder(f, hash);
CamelFolder *f = node->data;
int i;
char hash[8];
-
+
/* make sure we only search each folder once - for unmatched folder to work right */
if (g_hash_table_lookup(searched, f) == NULL) {
camel_vee_folder_hash_folder(f, hash);
if (matches) {
for (i = 0; i < matches->len; i++) {
char *uid = matches->pdata[i], *vuid;
-
+
vuid = g_malloc(strlen(uid)+9);
memcpy(vuid, hash, 8);
strcpy(vuid+8, uid);
count = camel_folder_summary_count(((CamelFolder *)folder_unmatched)->summary);
for (i=0;i<count;i++) {
CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index(((CamelFolder *)folder_unmatched)->summary, i);
-
+
if (mi) {
if (mi->real->summary == ssummary) {
camel_folder_change_info_remove_uid(folder_unmatched->changes, camel_message_info_uid(mi));
if (mi->real->summary == ssummary) {
char *uid = (char *)camel_message_info_uid(mi), *oldkey;
void *oldval;
-
+
if (g_hash_table_lookup(matchhash, uid+8) == NULL) {
if (last == -1) {
last = start = i;
vinfo = vee_folder_add_uid(vf, sub, uid, hash);
if (vinfo == NULL)
return;
-
+
vuid = camel_message_info_uid(vinfo);
camel_folder_change_info_add_uid(vf->changes, vuid);
}
memcpy(vuid, hash, 8);
strcpy(vuid+8, uid);
-
+
if (!CAMEL_IS_VEE_FOLDER(sub) && folder_unmatched != NULL && g_hash_table_lookup(unmatched_uids, vuid) == NULL) {
dd(printf(" adding uid '%s' to Unmatched [newly unmatched]\n", (char *)uid));
vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info((CamelFolder *)folder_unmatched, vuid);
unmatched_changes = folder_unmatched->changes;
folder_unmatched->changes = camel_folder_change_info_new();
}
-
+
CAMEL_VEE_FOLDER_UNLOCK(folder_unmatched, summary_lock);
}
g_ptr_array_free(newchanged, TRUE);
g_free(vuid);
-
+
if (unmatched_changes) {
camel_object_trigger_event((CamelObject *)folder_unmatched, "folder_changed", unmatched_changes);
camel_folder_change_info_free(unmatched_changes);
}
-
+
if (vf_changes) {
/* If not auto-updating, keep track of changed folders for later re-sync */
if ((vf->flags & CAMEL_STORE_VEE_FOLDER_AUTO) == 0) {
{
struct _folder_changed_msg *m;
CamelSession *session = ((CamelService *)((CamelFolder *)vf)->parent_store)->session;
-
+
m = camel_session_thread_msg_new(session, &folder_changed_ops, sizeof(*m));
m->changes = camel_folder_change_info_new();
camel_folder_change_info_cat(m->changes, changes);
CamelVeeFolder *vfolder = (CamelVeeFolder *)folder;
struct _CamelVeeFolderPrivate *p = _PRIVATE(vfolder);
GList *node;
-
+
CAMEL_VEE_FOLDER_LOCK(vfolder, subfolder_lock);
-
+
node = p->folders;
while (node) {
CamelFolder *f = node->data;
-
+
camel_folder_freeze(f);
node = node->next;
}
-
+
CAMEL_VEE_FOLDER_UNLOCK(vfolder, subfolder_lock);
-
+
/* call parent implementation */
CAMEL_FOLDER_CLASS (camel_vee_folder_parent)->freeze(folder);
}
CamelVeeFolder *vfolder = (CamelVeeFolder *)folder;
struct _CamelVeeFolderPrivate *p = _PRIVATE(vfolder);
GList *node;
-
+
CAMEL_VEE_FOLDER_LOCK(vfolder, subfolder_lock);
-
+
node = p->folders;
while (node) {
CamelFolder *f = node->data;
-
+
camel_folder_thaw(f);
node = node->next;
}
-
+
CAMEL_VEE_FOLDER_UNLOCK(vfolder, subfolder_lock);
-
+
/* call parent implementation */
CAMEL_FOLDER_CLASS (camel_vee_folder_parent)->thaw(folder);
}
obj->changes = camel_folder_change_info_new();
obj->search = camel_folder_search_new();
-
+
p->summary_lock = g_mutex_new();
p->subfolder_lock = g_mutex_new();
p->changed_lock = g_mutex_new();
}
g_free(vf->expression);
-
+
g_list_free(p->folders);
g_list_free(p->folders_changed);
camel_folder_change_info_free(vf->changes);
camel_object_unref((CamelObject *)vf->search);
-
+
g_mutex_free(p->summary_lock);
g_mutex_free(p->subfolder_lock);
g_mutex_free(p->changed_lock);
-
+
g_free(p);
}
camel_vee_store_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_store_get_type (), "CamelVeeStore",
sizeof (CamelVeeStore),
(CamelObjectInitFunc) camel_vee_store_init,
(CamelObjectFinalizeFunc) camel_vee_store_finalise);
}
-
+
return type;
}
camel_vee_store_class_init (CamelVeeStoreClass *klass)
{
CamelStoreClass *store_class = (CamelStoreClass *) klass;
-
+
camel_vee_store_parent = (CamelStoreClass *)camel_store_get_type();
/* virtual method overload */
CamelStore *store = (CamelStore *)obj;
/* we dont want a vtrash/vjunk on this one */
- store->flags &= ~(CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK);
+ store->flags &= ~(CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK);
/* Set up unmatched folder */
obj->unmatched_uids = g_hash_table_new (g_str_hash, g_str_equal);
* camel_vee_store_new:
*
* Create a new #CamelVeeStore object.
- *
+ *
* Returns new #CamelVeeStore object
**/
CamelVeeStore *
camel_vtrash_folder_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_vee_folder_get_type (),
"CamelVTrashFolder",
(CamelObjectInitFunc) camel_vtrash_folder_init,
NULL);
}
-
+
return type;
}
camel_vtrash_folder_new (CamelStore *parent_store, camel_vtrash_folder_t type)
{
CamelVTrashFolder *vtrash;
-
+
g_assert(type < CAMEL_VTRASH_FOLDER_LAST);
vtrash = (CamelVTrashFolder *)camel_object_new(camel_vtrash_folder_get_type());
const CamelMessageInfo *info, char **appended_uid,
CamelException *ex)
{
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_(vdata[((CamelVTrashFolder *)folder)->type].error_copy));
}
if (CAMEL_IS_VTRASH_FOLDER (dest)) {
/* Copy to trash is meaningless. */
if (!delete_originals) {
- camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_(vdata[((CamelVTrashFolder *)dest)->type].error_copy));
return;
}
g_warning ("Cannot find uid %s in source folder during transfer", (char *) uids->pdata[i]);
continue;
}
-
+
if (dest == mi->real->summary->folder) {
/* Just unset the flag on the original message */
camel_folder_set_message_flags (source, uids->pdata[i], sbit, 0);
GList *node;
GPtrArray *matches, *result = g_ptr_array_new(), *folder_uids = g_ptr_array_new();
struct _CamelVeeFolderPrivate *p = ((CamelVeeFolder *)folder)->priv;
-
+
CAMEL_VEE_FOLDER_LOCK(folder, subfolder_lock);
node = p->folders;
CamelFolder *f = node->data;
int i;
char hash[8];
-
+
camel_vee_folder_hash_folder(f, hash);
/* map the vfolder uid's to the source folder uid's first */
g_ptr_array_set_size(uids, 0);
for (i=0;i<uids->len;i++) {
char *uid = uids->pdata[i];
-
+
if (strlen(uid) >= 8 && strncmp(uid, hash, 8) == 0) {
CamelMessageInfo *mi;
&& (matches = camel_folder_search_by_uids(f, expression, folder_uids, ex))) {
for (i = 0; i < matches->len; i++) {
char *uid = matches->pdata[i], *vuid;
-
+
vuid = g_malloc(strlen(uid)+9);
memcpy(vuid, hash, 8);
strcpy(vuid+8, uid);
}
CAMEL_VEE_FOLDER_UNLOCK(vf, summary_lock);
-
+
if (vf_changes) {
camel_object_trigger_event(vf, "folder_changed", vf_changes);
camel_folder_change_info_free(vf_changes);
camel_vtrash_folder_class_init (CamelVTrashFolderClass *klass)
{
CamelFolderClass *folder_class = (CamelFolderClass *) klass;
-
+
camel_vtrash_folder_parent = CAMEL_VEE_FOLDER_CLASS(camel_vee_folder_get_type());
((CamelObjectClass *)klass)->getv = vtrash_getv;
-
+
folder_class->append_message = vtrash_append_message;
folder_class->transfer_messages_to = vtrash_transfer_messages_to;
folder_class->search_by_expression = vtrash_search_by_expression;
struct _CamelVTrashFolderClass {
CamelVeeFolderClass parent_class;
-
+
};
CamelType camel_vtrash_folder_get_type (void);
camel_shutdown (void)
{
CamelCertDB *certdb;
-
+
if (!initialised)
return;
-
+
#if defined (HAVE_NSS) && !defined (G_OS_WIN32)
/* For some reason we get into trouble on Win32 if we call these.
* But they shouldn't be necessary as the process is exiting anywy?
*/
NSS_Shutdown ();
-
+
PR_Cleanup ();
#endif /* HAVE_NSS */
-
+
certdb = camel_certdb_get_default ();
if (certdb) {
camel_certdb_save (certdb);
camel_object_unref (certdb);
}
-
+
initialised = FALSE;
}
{
CamelCertDB *certdb;
char *path;
-
+
if (initialised)
return 0;
PRUint16 indx;
PR_Init (PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 10);
-
+
#ifndef G_OS_WIN32
nss_configdir = g_strdup (configdir);
#else
for (indx = 0; indx < SSL_NumImplementedCiphers; indx++) {
if (!SSL_IS_SSL2_CIPHER(SSL_ImplementedCiphers[indx]))
SSL_CipherPrefSetDefault (SSL_ImplementedCiphers[indx], PR_TRUE);
- }
-
+ }
+
SSL_OptionSetDefault (SSL_ENABLE_SSL2, PR_TRUE);
SSL_OptionSetDefault (SSL_ENABLE_SSL3, PR_TRUE);
SSL_OptionSetDefault (SSL_ENABLE_TLS, PR_TRUE);
SSL_OptionSetDefault (SSL_V2_COMPATIBLE_HELLO, PR_TRUE /* maybe? */);
}
#endif /* HAVE_NSS */
-
+
path = g_strdup_printf ("%s/camel-cert.db", configdir);
certdb = camel_certdb_new ();
camel_certdb_set_filename (certdb, path);
g_free (path);
-
+
/* if we fail to load, who cares? it'll just be a volatile certdb */
camel_certdb_load (certdb);
-
+
/* set this certdb as the default db */
camel_certdb_set_default (certdb);
-
+
camel_object_unref (certdb);
-
+
g_atexit (camel_shutdown);
-
+
initialised = TRUE;
-
+
return 0;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
*
- * Author :
+ * Author :
* Bertrand Guiheneuf <bertrand@helixcode.com>
*
* Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-groupwise-folder.c: class for an groupwise folder */
-/*
+/*
* Authors:
* Sivaiah Nallagatla <snallagatla@novell.com>
* parthasarathi susarla <sparthasarathi@novell.com>
* Sankar P <psankar@novell.com>
- *
+ *
*
* Copyright (C) 2004, Novell Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include <config.h>
#endif
#include <errno.h>
static CamelMimeMessage *groupwise_folder_item_to_msg ( CamelFolder *folder, EGwItem *item, CamelException *ex );
-#define d(x)
+#define d(x)
static CamelMimeMessage *
groupwise_folder_get_message( CamelFolder *folder, const char *uid, CamelException *ex )
if(!temp_body){
int len = 0;
EGwConnectionStatus status;
- status = e_gw_connection_get_attachment (cnc,
- e_gw_item_get_msg_body_id (item), 0, -1,
+ status = e_gw_connection_get_attachment (cnc,
+ e_gw_item_get_msg_body_id (item), 0, -1,
(const char **)&temp_body, &len);
if (status != E_GW_CONNECTION_STATUS_OK) {
g_warning ("Could not get Messagebody\n");
convert_to_calendar (item, &cal_buffer, &len);
else if (type == E_GW_ITEM_TYPE_TASK)
convert_to_task (item, &cal_buffer, &len);
- else
+ else
convert_to_note (item, &cal_buffer, &len);
camel_mime_part_set_content(part, cal_buffer, len, "text/calendar");
}
case E_GW_ITEM_TYPE_NOTIFICATION:
case E_GW_ITEM_TYPE_MAIL:
- if (body)
+ if (body)
camel_mime_part_set_content(part, body, strlen(body), "text/html");
else if (temp_body)
camel_mime_part_set_content(part, temp_body, strlen(temp_body), e_gw_item_get_msg_content_type (item));
}
if (recp->type == E_GW_ITEM_RECIPIENT_TO) {
- if (recp->status_enabled)
+ if (recp->status_enabled)
status_opt = g_strconcat (status_opt ? status_opt : "" , "TO", ";",NULL);
camel_header_address_list_append(&to_list, ha);
} else if (recp->type == E_GW_ITEM_RECIPIENT_CC) {
- if (recp->status_enabled)
+ if (recp->status_enabled)
status_opt = g_strconcat (status_opt ? status_opt : "", "CC", ";",NULL);
camel_header_address_list_append(&cc_list,ha);
} else if (recp->type == E_GW_ITEM_RECIPIENT_BC) {
- if (recp->status_enabled)
+ if (recp->status_enabled)
status_opt = g_strconcat (status_opt ? status_opt : "", "BCC", ";",NULL);
camel_header_address_list_append(&bcc_list,ha);
} else {
camel_header_address_unref(ha);
}
if (recp->status_enabled) {
- status_opt = g_strconcat (status_opt,
+ status_opt = g_strconcat (status_opt,
recp->display_name,";",
recp->email,";",
recp->delivered_date ? recp->delivered_date : "", ";",
- recp->opened_date ? recp->opened_date : "", ";",
+ recp->opened_date ? recp->opened_date : "", ";",
recp->accepted_date ? recp->accepted_date : "", ";",
- recp->deleted_date ? recp->deleted_date : "", ";",
+ recp->deleted_date ? recp->deleted_date : "", ";",
recp->declined_date ? recp->declined_date : "", ";",
recp->completed_date ? recp->completed_date : "", ";",
- recp->undelivered_date ? recp->undelivered_date : "", ";",
+ recp->undelivered_date ? recp->undelivered_date : "", ";",
"::", NULL);
}
}
}
- if(to_list) {
+ if(to_list) {
subs_email=camel_header_address_list_encode(to_list);
camel_medium_set_header( CAMEL_MEDIUM(msg), "To", subs_email);
g_free(subs_email);
camel_header_address_list_clear(&to_list);
}
- if(cc_list) {
+ if(cc_list) {
subs_email=camel_header_address_list_encode(cc_list);
camel_medium_set_header( CAMEL_MEDIUM(msg), "Cc", subs_email);
g_free(subs_email);
camel_header_address_list_clear(&cc_list);
}
- if(bcc_list) {
+ if(bcc_list) {
subs_email=camel_header_address_list_encode(bcc_list);
camel_medium_set_header( CAMEL_MEDIUM(msg), "Bcc", subs_email);
g_free(subs_email);
if (org) {
if (org->display_name && org->display_name[0] && org->email != NULL && org->email[0] != '\0') {
int i;
- for (i = 0; org->display_name[i] != '<' &&
+ for (i = 0; org->display_name[i] != '<' &&
org->display_name[i] != '\0';
i++);
org->display_name[i] = '\0';
}
- if (org->display_name && org->email)
+ if (org->display_name && org->email)
ha=camel_header_address_new_name(org->display_name, org->email);
else if (org->display_name)
ha=camel_header_address_new_group(org->display_name);
ha = NULL;
if (ha) {
- subs_email = camel_header_address_list_encode (ha);
+ subs_email = camel_header_address_list_encode (ha);
camel_medium_set_header (CAMEL_MEDIUM (msg), "From", subs_email);
camel_header_address_unref (ha);
g_free (subs_email);
}
/******************* functions specific to Junk Mail Handling**************/
-static void
+static void
free_node (EGwJunkEntry *entry)
{
if (entry) {
static void
update_junk_list (CamelStore *store, CamelMessageInfo *info, int flag)
{
- gchar **email = NULL, *from = NULL;
+ gchar **email = NULL, *from = NULL;
CamelGroupwiseStore *gw_store= CAMEL_GROUPWISE_STORE(store);
CamelGroupwiseStorePrivate *priv = gw_store->priv;
EGwConnection *cnc = cnc_lookup (priv);
if (e_gw_connection_get_junk_entries (cnc, &list)== E_GW_CONNECTION_STATUS_OK){
while (list) {
entry = list->data;
- if (!g_ascii_strcasecmp (entry->match, email[1])) {
+ if (!g_ascii_strcasecmp (entry->match, email[1])) {
e_gw_connection_remove_junk_entry (cnc, entry->id);
}
list = list->next;
g_strfreev (email);
}
-static void
+static void
move_to_mailbox (CamelFolder *folder, CamelMessageInfo *info, CamelException *ex)
{
CamelFolder *dest;
update_junk_list (folder->parent_store, info, REMOVE_JUNK_ENTRY);
}
-static void
+static void
move_to_junk (CamelFolder *folder, CamelMessageInfo *info, CamelException *ex)
{
CamelFolder *dest;
g_ptr_array_add (uids, (gpointer) uid);
dest = camel_store_get_folder (folder->parent_store, JUNK_FOLDER, 0, ex);
-
+
if (dest)
groupwise_transfer_messages_to (folder, uids, dest, NULL, TRUE, ex);
else {
/********************* back to folder functions*************************/
-static void
+static void
groupwise_sync_summary (CamelFolder *folder, CamelException *ex)
{
camel_folder_summary_save (folder->summary);
deleted_items = deleted_head = NULL;
- if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
+ if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
((CamelService *)gw_store)->status == CAMEL_SERVICE_DISCONNECTED) {
groupwise_sync_summary (folder, ex);
return;
/**Junk Mail handling**/
if(!info)
continue;
- flags = camel_message_info_flags (info);
+ flags = camel_message_info_flags (info);
- if ((flags & CAMEL_MESSAGE_JUNK) && strcmp(camel_folder_get_name(folder), JUNK_FOLDER)) {
+ if ((flags & CAMEL_MESSAGE_JUNK) && strcmp(camel_folder_get_name(folder), JUNK_FOLDER)) {
/*marked a message junk*/
move_to_junk (folder, info, ex);
camel_folder_summary_remove_uid (folder->summary, camel_message_info_uid(info));
}
if ((flags & CAMEL_GW_MESSAGE_NOJUNK) && !strcmp(camel_folder_get_name(folder), JUNK_FOLDER)) {
- /*message was marked as junk, now unjunk*/
+ /*message was marked as junk, now unjunk*/
move_to_mailbox (folder, info, ex);
camel_folder_summary_remove_uid (folder->summary, camel_message_info_uid(info));
camel_data_cache_remove (gw_folder->cache, "cache", camel_message_info_uid(info), NULL);
if (gw_info && (gw_info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) {
do_flags_diff (&diff, gw_info->server_flags, gw_info->info.flags);
do_flags_diff (&unset_flags, flags, gw_info->server_flags);
-
+
diff.changed &= folder->permanent_flags;
/* weed out flag changes that we can't sync to the server */
if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
- /*
- Sync up the READ changes before deleting the message.
+ /*
+ Sync up the READ changes before deleting the message.
Note that if a message is marked as unread and then deleted,
Evo doesnt not take care of it, as I find that scenario to be impractical.
*/
if (deleted_read_items) {
-
+
/* FIXME: As in many places, we need to handle the return value
and do some error handling. But, we do not have all error codes also
and errors are not returned always either */
}
camel_message_info_free (info);
}
-
+
CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
if (deleted_items) {
}
CamelFolder *
-camel_gw_folder_new(CamelStore *store, const char *folder_name, const char *folder_dir, CamelException *ex)
+camel_gw_folder_new(CamelStore *store, const char *folder_name, const char *folder_dir, CamelException *ex)
{
CamelFolder *folder;
CamelGroupwiseFolder *gw_folder;
else {
/* item_list is prepended to items_full_list and not the other way
- because when we have a large number of items say 50000,
- for each iteration there will be more elements in items_full_list
+ because when we have a large number of items say 50000,
+ for each iteration there will be more elements in items_full_list
and less elements in item_list */
last_element = g_list_last (item_list);
item_list = item_list->next;
}
- i = 0;
+ i = 0;
while (((const char *)item_list->data)[i++]!='@');
((char *)item_list->data)[i-1] = '\0';
}*/
return;
}
- if (!cnc)
+ if (!cnc)
return;
if (camel_folder_is_frozen (folder) ) {
CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
- if (!camel_groupwise_store_connected (gw_store, ex))
+ if (!camel_groupwise_store_connected (gw_store, ex))
goto end1;
if (!strcmp (folder->full_name, "Trash")) {
}
time_string = g_strdup (((CamelGroupwiseSummary *) folder->summary)->time_string);
- t_str = g_strdup (time_string);
+ t_str = g_strdup (time_string);
/*Get the New Items*/
if (!is_proxy) {
}
/*
- * The value in t_str is the one that has to be used for the next set of calls.
+ * The value in t_str is the one that has to be used for the next set of calls.
* so store this value in the summary.
*/
if (summary->time_string)
((CamelGroupwiseSummary *) folder->summary)->time_string = g_strdup (t_str);
camel_folder_summary_touch (folder->summary);
groupwise_sync_summary (folder, ex);
- g_free (t_str);
+ g_free (t_str);
t_str = NULL;
/*
- for ( sl = slist ; sl != NULL; sl = sl->next)
+ for ( sl = slist ; sl != NULL; sl = sl->next)
list = g_list_append (list, sl->data);*/
if (slist && g_slist_length(slist) != 0)
goto end3;
}
- /* The storing of time-stamp to summary code below should be commented if the
+ /* The storing of time-stamp to summary code below should be commented if the
above commented code is uncommented */
/* if (summary->time_string)
g_free (t_str), t_str = NULL;*/
- for ( sl = slist ; sl != NULL; sl = sl->next)
+ for ( sl = slist ; sl != NULL; sl = sl->next)
list = g_list_prepend (list, sl->data);
if (!check_all && slist && g_slist_length(slist) != 0)
is_locked = FALSE;
/*
- * The New and Modified items in the server have been updated in the summary.
+ * The New and Modified items in the server have been updated in the summary.
* Now we have to make sure that all the delted items in the server are deleted
- * from Evolution as well. So we get the id's of all the items on the sever in
+ * from Evolution as well. So we get the id's of all the items on the sever in
* this folder, and update the summary.
*/
/*create a new session thread for the update all operation*/
/*thread creation and queueing done*/
}
-end3:
+end3:
g_list_foreach (list, (GFunc) g_object_unref, NULL);
g_list_free (list);
list = NULL;
}
static void
-gw_update_cache (CamelFolder *folder, GList *list, CamelException *ex, gboolean uid_flag)
+gw_update_cache (CamelFolder *folder, GList *list, CamelException *ex, gboolean uid_flag)
{
CamelGroupwiseMessageInfo *mi = NULL;
CamelMessageInfo *pmi = NULL;
if (uid_flag == FALSE) {
temp_item = (EGwItem *)item_list->data;
id = e_gw_item_get_id (temp_item);
- } else
+ } else
id = (char *) item_list->data;
camel_operation_progress (NULL, (100*i)/total_items);
continue;
}
- mi = (CamelGroupwiseMessageInfo *)camel_message_info_new (folder->summary);
+ mi = (CamelGroupwiseMessageInfo *)camel_message_info_new (folder->summary);
if (mi->info.content == NULL) {
mi->info.content = camel_folder_summary_content_info_new (folder->summary);
- mi->info.content->type = camel_content_type_new ("multipart", "mixed");
+ mi->info.content->type = camel_content_type_new ("multipart", "mixed");
}
}
-
+
rk = e_gw_item_get_recurrence_key (item);
if (rk > 0) {
- recurrence_key = g_strdup_printf("%d", rk);
+ recurrence_key = g_strdup_printf("%d", rk);
camel_message_info_set_user_tag ((CamelMessageInfo*)mi, "recurrence-key", recurrence_key);
- }
+ }
/*all items in the Junk Mail folder should have this flag set*/
if (is_junk)
item_status = e_gw_item_get_item_status (item);
if (item_status & E_GW_ITEM_STAT_READ)
status_flags |= CAMEL_MESSAGE_SEEN;
- else
+ else
mi->info.flags &= ~CAMEL_MESSAGE_SEEN;
if (item_status & E_GW_ITEM_STAT_REPLIED)
status_flags |= CAMEL_MESSAGE_ANSWERED;
- if (exists)
+ if (exists)
mi->info.flags |= status_flags;
- else
+ else
mi->info.flags = status_flags;
priority = e_gw_item_get_priority (item);
mi->info.flags |= CAMEL_MESSAGE_ATTACHMENTS;
if (is_proxy)
mi->info.flags |= CAMEL_MESSAGE_USER_NOT_DELETABLE;
-
+
mi->server_flags = mi->info.flags;
- org = e_gw_item_get_organizer (item);
+ org = e_gw_item_get_organizer (item);
if (org) {
GString *str;
int i;
str = g_string_new ("");
if (org->display_name && org->display_name[0] && org->email != NULL && org->email[0] != '\0') {
- for (i = 0; org->display_name[i] != '<' &&
+ for (i = 0; org->display_name[i] != '<' &&
org->display_name[i] != '\0';
i++);
str = g_string_append (str, " ");
}
- if (org->display_name[0] == '\0') {
+ if (org->display_name[0] == '\0') {
str = g_string_append (str, org->email);
str = g_string_append (str, " ");
}
- if (org->email && org->email[0]) {
+ if (org->email && org->email[0]) {
g_string_append (str, "<");
str = g_string_append (str, org->email);
g_string_append (str, ">");
}
if (type == E_GW_ITEM_TYPE_APPOINTMENT
- || type == E_GW_ITEM_TYPE_NOTE
+ || type == E_GW_ITEM_TYPE_NOTE
|| type == E_GW_ITEM_TYPE_TASK ) {
temp_date = e_gw_item_get_start_date (item);
if (temp_date) {
if (!exists) {
mi->info.uid = g_strdup (e_gw_item_get_id(item));
- mi->info.size = e_gw_item_get_mail_size (item);
+ mi->info.size = e_gw_item_get_mail_size (item);
mi->info.subject = camel_pstring_strdup(e_gw_item_get_subject(item));
}
}
void
-gw_update_summary ( CamelFolder *folder, GList *list,CamelException *ex)
+gw_update_summary ( CamelFolder *folder, GList *list,CamelException *ex)
{
CamelGroupwiseMessageInfo *mi = NULL;
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
id = e_gw_item_get_id (item);
mi = (CamelGroupwiseMessageInfo *)camel_folder_summary_uid (folder->summary, id);
- if (mi)
+ if (mi)
exists = TRUE;
if (!exists) {
continue;
}
- mi = camel_message_info_new (folder->summary);
+ mi = camel_message_info_new (folder->summary);
if (mi->info.content == NULL) {
mi->info.content = camel_folder_summary_content_info_new (folder->summary);
mi->info.content->type = camel_content_type_new ("multipart", "mixed");
}
}
-
+
rk = e_gw_item_get_recurrence_key (item);
if (rk > 0) {
- recurrence_key = g_strdup_printf("%d", rk);
+ recurrence_key = g_strdup_printf("%d", rk);
camel_message_info_set_user_tag ((CamelMessageInfo*)mi, "recurrence-key", recurrence_key);
- }
+ }
/*all items in the Junk Mail folder should have this flag set*/
if (is_junk)
if (priority && !(g_ascii_strcasecmp (priority,"High"))) {
mi->info.flags |= CAMEL_MESSAGE_FLAGGED;
}
-
+
if (e_gw_item_has_attachment (item))
mi->info.flags |= CAMEL_MESSAGE_ATTACHMENTS;
- if (is_proxy)
+ if (is_proxy)
mi->info.flags |= CAMEL_MESSAGE_USER_NOT_DELETABLE;
mi->server_flags = mi->info.flags;
- org = e_gw_item_get_organizer (item);
+ org = e_gw_item_get_organizer (item);
if (org) {
GString *str;
int i;
str = g_string_new ("");
if (org->display_name && org->display_name[0] && org->email != NULL && org->email[0] != '\0') {
- for (i = 0; org->display_name[i] != '<' &&
- org->display_name[i] != '\0';
+ for (i = 0; org->display_name[i] != '<' &&
+ org->display_name[i] != '\0';
i++);
org->display_name[i] = '\0';
str = g_string_append (str, " ");
}
- if (org->display_name[0] == '\0') {
-
+ if (org->display_name[0] == '\0') {
+
str = g_string_append (str, org->email);
str = g_string_append (str, " ");
}
- if (org->email && org->email[0]) {
+ if (org->email && org->email[0]) {
g_string_append (str, "<");
str = g_string_append (str, org->email);
g_string_append (str, ">");
time_t time = e_gw_connection_get_date_from_string (temp_date);
time_t actual_time = camel_header_decode_date (ctime(&time), NULL);
mi->info.date_sent = mi->info.date_received = actual_time;
- }
+ }
} else {
temp_date = e_gw_item_get_delivered_date(item);
if (temp_date) {
mi->info.uid = g_strdup(e_gw_item_get_id(item));
if (!exists)
- mi->info.size = e_gw_item_get_mail_size (item);
+ mi->info.size = e_gw_item_get_mail_size (item);
mi->info.subject = camel_pstring_strdup(e_gw_item_get_subject(item));
if (exists) {
body = g_strdup (attachment);
g_free (attachment);
is_text_html = TRUE;
- }
+ }
}//if attachment and len
} // if Mime.822 or TEXT.htm
int len_iter = 0, t_len , offset = 0, t_offset = 0;
char *t_attach = NULL;
GString *gstr = g_string_new (NULL);
-
+
len = 0;
do {
- status = e_gw_connection_get_attachment_base64 (cnc,
- attach->id, t_offset, MAX_ATTACHMENT_SIZE,
+ status = e_gw_connection_get_attachment_base64 (cnc,
+ attach->id, t_offset, MAX_ATTACHMENT_SIZE,
(const char **)&t_attach, &t_len, &offset);
if (status == E_GW_CONNECTION_STATUS_OK) {
char *temp = NULL;
-
+
temp = g_base64_decode(t_attach, &len_iter);
gstr = g_string_append_len (gstr, temp, len_iter);
g_free (temp);
body_len = len;
g_string_free (gstr, FALSE);
} else {
- status = e_gw_connection_get_attachment (cnc,
- attach->id, 0, -1,
+ status = e_gw_connection_get_attachment (cnc,
+ attach->id, 0, -1,
(const char **)&attachment, &len);
if (status != E_GW_CONNECTION_STATUS_OK) {
g_warning ("Could not get attachment\n");
g_free (attachment);
}
has_mime_822 = TRUE;
- }
+ }
}
}//if attach_list
g_free (value);
}
}
-
+
if (has_mime_822)
goto end;
else
camel_data_wrapper_set_mime_type_field(CAMEL_DATA_WRAPPER (temp_msg), ct);
camel_content_type_unref(ct);
camel_medium_set_content_object ( CAMEL_MEDIUM (part),CAMEL_DATA_WRAPPER(temp_msg));
-
+
camel_multipart_add_part (multipart,part);
camel_object_unref (temp_msg);
camel_object_unref (part);
len = 0;
do {
- status = e_gw_connection_get_attachment_base64 (cnc,
- attach->id, t_offset, MAX_ATTACHMENT_SIZE,
+ status = e_gw_connection_get_attachment_base64 (cnc,
+ attach->id, t_offset, MAX_ATTACHMENT_SIZE,
(const char **)&t_attach, &t_len, &offset);
if (status == E_GW_CONNECTION_STATUS_OK) {
int len_iter = 0;
char *temp = NULL;
-
+
temp = g_base64_decode(t_attach, &len_iter);
gstr = g_string_append_len (gstr, temp, len_iter);
g_free (temp);
g_string_free (gstr, FALSE);
is_base64_encoded = FALSE;
} else {
- status = e_gw_connection_get_attachment (cnc,
- attach->id, 0, -1,
+ status = e_gw_connection_get_attachment (cnc,
+ attach->id, 0, -1,
(const char **)&attachment, &len);
}
if (status != E_GW_CONNECTION_STATUS_OK) {
if (attach->contentid) {
gchar **t;
t= g_strsplit_set (attach->contentid, "<>", -1);
- if (!t[1])
+ if (!t[1])
camel_mime_part_set_content_id (part, attach->contentid);
- else
+ else
camel_mime_part_set_content_id (part, t[1]);
g_strfreev (t);
camel_mime_part_set_content_location (part, attach->name);
}
static void
-gw_update_all_items (CamelFolder *folder, GList *item_list, CamelException *ex)
+gw_update_all_items (CamelFolder *folder, GList *item_list, CamelException *ex)
{
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER (folder);
GPtrArray *summary = NULL;
int index = 0;
GList *temp;
CamelFolderChangeInfo *changes = NULL;
- CamelMessageInfo *info;
+ CamelMessageInfo *info;
changes = camel_folder_change_info_new ();
item_list = g_list_reverse (item_list);
/*item_ids : List of ids from the summary*/
while (index < summary->len) {
info = g_ptr_array_index (summary, index);
- temp = NULL;
+ temp = NULL;
if (item_list) {
temp = g_list_find_custom (item_list, (const char *)info->uid, (GCompareFunc) strcmp);
camel_data_cache_remove (gw_folder->cache, "cache", info->uid, NULL);
camel_folder_change_info_remove_uid (changes, info->uid);
CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
- } else {
+ } else {
item_list = g_list_delete_link (item_list, temp);
}
index ++;
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
- gw_update_cache (folder, item_list, ex, TRUE);
+ gw_update_cache (folder, item_list, ex, TRUE);
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
- g_list_foreach (item_list, (GFunc)g_free, NULL);
+ g_list_foreach (item_list, (GFunc)g_free, NULL);
g_list_free (item_list);
}
CAMEL_SERVICE_REC_LOCK (folder->parent_store, connect_lock);
/*Get the container id*/
container_id = camel_groupwise_store_container_id_lookup (gw_store, folder->full_name) ;
-
+
item = camel_groupwise_util_item_from_message (cnc, message, CAMEL_ADDRESS (message->from));
/*Set the source*/
if (!strcmp (folder->name, RECEIVED))
}
if (appended_uid)
- *appended_uid = g_strdup (id);
+ *appended_uid = g_strdup (id);
g_free (id);
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
}
}
static void
-groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
- CamelFolder *destination, GPtrArray **transferred_uids,
+groupwise_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
+ CamelFolder *destination, GPtrArray **transferred_uids,
gboolean delete_originals, CamelException *ex)
{
int count, index = 0;
if (transferred_uids)
*transferred_uids = NULL;
- if (delete_originals)
+ if (delete_originals)
source_container_id = camel_groupwise_store_container_id_lookup (gw_store, source->full_name) ;
else
source_container_id = NULL;
if (camel_exception_is_set (ex))
break;
- if (delete_originals) {
+ if (delete_originals) {
if ( !strcmp(source->full_name, SENT) ) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("This message is not available in offline mode."));
gw_info->server_flags = gw_info->info.flags;
if (diff.bits & CAMEL_MESSAGE_SEEN) {
-
+
/*
- wrapper is a list wrapper bcos e_gw_connection_mark_read
+ wrapper is a list wrapper bcos e_gw_connection_mark_read
is designed for passing multiple uids. Also, there are is not much
- need/use for a e_gw_connection_mark_ITEM_[un]read
+ need/use for a e_gw_connection_mark_ITEM_[un]read
*/
wrapper = g_list_prepend (wrapper, (char *)uid);
wrapper = NULL;
}
-
+
/* A User may mark a message as Unread and then immediately move it to
some other folder. The following piece of code take care of such scenario.
-
- However, Remember that When a mail is deleted after being marked as unread,
- I am not syncing the read-status.
+
+ However, Remember that When a mail is deleted after being marked as unread,
+ I am not syncing the read-status.
*/
if (unset_flags.bits & CAMEL_MESSAGE_SEEN) {
if (delete_originals) {
if (strcmp(source->full_name, "Sent Items")) {
- status = e_gw_connection_move_item (cnc, (const char *)uids->pdata[index],
+ status = e_gw_connection_move_item (cnc, (const char *)uids->pdata[index],
dest_container_id, source_container_id);
} else {
char *container_id = NULL;
container_id = e_gw_connection_get_container_id (cnc, "Mailbox");
- status = e_gw_connection_move_item (cnc, (const char *)uids->pdata[index],
+ status = e_gw_connection_move_item (cnc, (const char *)uids->pdata[index],
dest_container_id, container_id);
g_free (container_id);
}
} else
- status = e_gw_connection_move_item (cnc, (const char *)uids->pdata[index],
+ status = e_gw_connection_move_item (cnc, (const char *)uids->pdata[index],
dest_container_id, NULL);
if (status == E_GW_CONNECTION_STATUS_OK) {
- if (delete_originals) {
+ if (delete_originals) {
if ( !strcmp(source->full_name, SENT) ) {
camel_folder_delete_message(source, uids->pdata[index]);
} else {
int i, max;
gboolean delete = FALSE;
GList *deleted_items, *deleted_head;
-
+
deleted_items = deleted_head = NULL;
cnc = cnc_lookup (priv);
camel_folder_class->get_message = groupwise_folder_get_message;
camel_folder_class->rename = groupwise_folder_rename;
camel_folder_class->search_by_expression = groupwise_folder_search_by_expression;
- camel_folder_class->search_by_uids = groupwise_folder_search_by_uids;
+ camel_folder_class->search_by_uids = groupwise_folder_search_by_uids;
camel_folder_class->search_free = groupwise_folder_search_free;
camel_folder_class->append_message = groupwise_append_message;
camel_folder_class->refresh_info = groupwise_refresh_info;
#ifdef ENABLE_THREADS
g_static_mutex_init(&gw_folder->priv->search_lock);
g_static_rec_mutex_init(&gw_folder->priv->cache_lock);
-#endif
+#endif
gw_folder->need_rescan = TRUE;
}
}
-void
+void
convert_to_calendar (EGwItem *item, char **str, int *len)
{
EGwItemOrganizer *org = NULL;
gstr = g_string_append (gstr, "BEGIN:VEVENT\n");
if ((recur_key = e_gw_item_get_recurrence_key (item)) != 0) {
- char *recur_k = g_strdup_printf ("%d", recur_key);
+ char *recur_k = g_strdup_printf ("%d", recur_key);
g_string_append_printf (gstr, "UID:%s\n", recur_k);
g_string_append_printf (gstr, "X-GW-RECURRENCE-KEY:%s\n", recur_k);
g_string_append_c(gstr, *temp);
temp++;
}
- g_string_append(gstr, "\n");
+ g_string_append(gstr, "\n");
}
g_string_append_printf (gstr, "DTSTAMP:%s\n", e_gw_item_get_creation_date (item));
org = e_gw_item_get_organizer (item);
if (org)
- g_string_append_printf (gstr, "ORGANIZER;CN= %s;ROLE= CHAIR;\n MAILTO:%s\n",
+ g_string_append_printf (gstr, "ORGANIZER;CN= %s;ROLE= CHAIR;\n MAILTO:%s\n",
org->display_name, org->email);
recp_list = e_gw_item_get_recipient_list (item);
for (rl = recp_list ; rl != NULL ; rl = rl->next) {
EGwItemRecipient *recp = (EGwItemRecipient *) rl->data;
- g_string_append_printf (gstr,
+ g_string_append_printf (gstr,
"ATTENDEE;CN= %s;ROLE= REQ-PARTICIPANT:\nMAILTO:%s\n",
recp->display_name, recp->email);
}
g_strfreev (tmp);
}
-static void
+static void
convert_to_task (EGwItem *item, char **str, int *len)
{
EGwItemOrganizer *org = NULL;
org = e_gw_item_get_organizer (item);
if (org)
- g_string_append_printf (gstr, "ORGANIZER;CN= %s;ROLE= CHAIR;\n MAILTO:%s\n",
+ g_string_append_printf (gstr, "ORGANIZER;CN= %s;ROLE= CHAIR;\n MAILTO:%s\n",
org->display_name, org->email);
recp_list = e_gw_item_get_recipient_list (item);
for (rl = recp_list ; rl != NULL ; rl = rl->next) {
EGwItemRecipient *recp = (EGwItemRecipient *) rl->data;
- g_string_append_printf (gstr,
+ g_string_append_printf (gstr,
"ATTENDEE;CN= %s;ROLE= REQ-PARTICIPANT:\nMAILTO:%s\n",
recp->display_name, recp->email);
}
g_strfreev (tmp);
}
-static void
+static void
convert_to_note (EGwItem *item, char **str, int *len)
{
EGwItemOrganizer *org = NULL;
org = e_gw_item_get_organizer (item);
if (org)
- g_string_append_printf (gstr, "ORGANIZER;CN= %s;ROLE= CHAIR;\n MAILTO:%s\n",
+ g_string_append_printf (gstr, "ORGANIZER;CN= %s;ROLE= CHAIR;\n MAILTO:%s\n",
org->display_name, org->email);
-
+
gstr = g_string_append (gstr, "END:VJOURNAL\n");
gstr = g_string_append (gstr, "END:VCALENDAR\n");
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-groupwise-folder.h: class for an groupwise folder */
-/*
+/*
* Authors:
* Sivaiah Nallagatla <snallagatla@novell.com>
* parthasarathi susarla <sparthasarathi@novell.com>
- *
+ *
*
* Copyright (C) 2004, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
struct _CamelGroupwiseFolderClass {
CamelOfflineFolderClass parent_class;
- /* Virtual methods */
-
+ /* Virtual methods */
+
} ;
camel_groupwise_journal_get_type (void)
{
static CamelType type = NULL;
-
+
if (!type) {
type = camel_type_register (camel_offline_journal_get_type (),
"CamelGroupwiseJournal",
(CamelObjectInitFunc) camel_groupwise_journal_init,
(CamelObjectFinalizeFunc) camel_groupwise_journal_finalize);
}
-
+
return type;
}
camel_groupwise_journal_class_init (CamelGroupwiseJournalClass *klass)
{
CamelOfflineJournalClass *journal_class = (CamelOfflineJournalClass *) klass;
-
+
parent_class = (CamelOfflineJournalClass *) camel_type_get_global_classfuncs (CAMEL_TYPE_OFFLINE_JOURNAL);
-
+
journal_class->entry_free = groupwise_entry_free;
journal_class->entry_load = groupwise_entry_load;
journal_class->entry_write = groupwise_entry_write;
static void
camel_groupwise_journal_init (CamelGroupwiseJournal *journal, CamelGroupwiseJournalClass *klass)
{
-
+
}
static void
camel_groupwise_journal_finalize (CamelObject *object)
{
-
+
}
static void
groupwise_entry_free (CamelOfflineJournal *journal, EDListNode *entry)
{
CamelGroupwiseJournalEntry *groupwise_entry = (CamelGroupwiseJournalEntry *) entry;
-
+
g_free (groupwise_entry->uid);
g_free (groupwise_entry->original_uid);
g_free (groupwise_entry->source_container);
groupwise_entry_load (CamelOfflineJournal *journal, FILE *in)
{
CamelGroupwiseJournalEntry *entry;
-
+
entry = g_malloc0 (sizeof (CamelGroupwiseJournalEntry));
-
+
if (camel_file_util_decode_uint32 (in, &entry->type) == -1)
goto exception;
-
+
switch (entry->type) {
case CAMEL_GROUPWISE_JOURNAL_ENTRY_APPEND:
if (camel_file_util_decode_string (in, &entry->uid) == -1)
default:
goto exception;
}
-
+
return (EDListNode *) entry;
-
+
exception:
-
+
if (entry->type == CAMEL_GROUPWISE_JOURNAL_ENTRY_TRANSFER)
g_free (entry->source_container);
-
+
g_free (entry->uid);
g_free (entry);
-
+
return NULL;
}
groupwise_entry_write (CamelOfflineJournal *journal, EDListNode *entry, FILE *out)
{
CamelGroupwiseJournalEntry *groupwise_entry = (CamelGroupwiseJournalEntry *) entry;
-
+
if (camel_file_util_encode_uint32 (out, groupwise_entry->type) == -1)
return -1;
-
+
switch (groupwise_entry->type) {
case CAMEL_GROUPWISE_JOURNAL_ENTRY_APPEND:
if (camel_file_util_encode_string (out, groupwise_entry->uid))
default:
g_assert_not_reached ();
}
-
+
return 0;
}
CamelMessageInfo *info;
CamelStream *stream;
CamelException lex;
-
+
/* if the message isn't in the cache, the user went behind our backs so "not our problem" */
if (!gw_folder->cache || !(stream = camel_data_cache_get (gw_folder->cache, "cache", entry->uid, ex)))
goto done;
-
+
message = camel_mime_message_new ();
if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream) == -1) {
camel_object_unref (message);
camel_object_unref (stream);
goto done;
}
-
+
camel_object_unref (stream);
-
+
if (!(info = camel_folder_summary_uid (folder->summary, entry->uid))) {
/* Note: this should never happen, but rather than crash lets make a new info */
info = camel_message_info_new (NULL);
}
-
+
camel_exception_init (&lex);
camel_folder_append_message (folder, message, info, NULL, &lex);
camel_message_info_free (info);
camel_object_unref (message);
-
+
if (camel_exception_is_set (&lex)) {
camel_exception_xfer (ex, &lex);
return -1;
}
-
+
done:
-
+
camel_folder_summary_remove_uid (folder->summary, entry->uid);
camel_data_cache_remove (gw_folder->cache, "cache", entry->uid, NULL);
-
+
return 0;
}
CamelException lex;
CamelFolder *src;
const char *name;
-
+
if (!(info = (CamelMessageInfoBase *) camel_folder_summary_uid (folder->summary, entry->uid))) {
/* Note: this should never happen, but rather than crash lets make a new info */
info = camel_message_info_new (NULL);
}
-
+
name = camel_groupwise_store_folder_lookup ((CamelGroupwiseStore *) folder->parent_store, entry->source_container);
if (name && (src = camel_store_get_folder (folder->parent_store, name, 0, ex))) {
uids = g_ptr_array_sized_new (1);
g_ptr_array_add (uids, entry->original_uid);
-
+
camel_exception_init (&lex);
camel_folder_transfer_messages_to (src, uids, folder, &xuids, FALSE, &lex);
if (!camel_exception_is_set (&lex)) {
real = (CamelGroupwiseMessageInfo *) camel_folder_summary_uid (folder->summary, xuids->pdata[0]);
-
+
/* transfer all the system flags, user flags/tags, etc */
gw_message_info_dup_to ((CamelMessageInfoBase *) real, (CamelMessageInfoBase *) info);
camel_message_info_free (real);
camel_exception_xfer (ex, &lex);
goto exception;
}
-
+
g_ptr_array_free (xuids, TRUE);
g_ptr_array_free (uids, TRUE);
camel_object_unref (src);
entry->source_container);
goto exception;
}
-
+
/* message was successfully transferred, remove the fake item from the cache/summary */
camel_folder_summary_remove_uid (folder->summary, entry->uid);
camel_data_cache_remove (gw_folder->cache, "cache", entry->uid, NULL);
camel_message_info_free (info);
-
+
return 0;
-
+
exception:
-
+
camel_message_info_free (info);
-
+
return -1;
}
groupwise_entry_play (CamelOfflineJournal *journal, EDListNode *entry, CamelException *ex)
{
CamelGroupwiseJournalEntry *groupwise_entry = (CamelGroupwiseJournalEntry *) entry;
-
+
switch (groupwise_entry->type) {
case CAMEL_GROUPWISE_JOURNAL_ENTRY_APPEND:
return groupwise_entry_play_append (journal, groupwise_entry, ex);
camel_groupwise_journal_new (CamelGroupwiseFolder *folder, const char *filename)
{
CamelOfflineJournal *journal;
-
+
g_return_val_if_fail (CAMEL_IS_GROUPWISE_FOLDER (folder), NULL);
-
+
journal = (CamelOfflineJournal *) camel_object_new (camel_groupwise_journal_get_type ());
camel_offline_journal_construct (journal, (CamelFolder *) folder, filename);
-
+
return journal;
}
CamelStream *cache;
guint32 nextuid;
char *uid;
-
+
if (groupwise_folder->cache == NULL) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot append message in offline mode: cache unavailable"));
return FALSE;
}
-
+
nextuid = camel_folder_summary_next_uid (folder->summary);
uid = g_strdup_printf ("-%u", nextuid);
-
+
if (!(cache = camel_data_cache_add (groupwise_folder->cache, "cache", uid, ex))) {
folder->summary->nextuid--;
g_free (uid);
return FALSE;
}
-
+
if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) message, cache) == -1
|| camel_stream_flush (cache) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
g_free (uid);
return FALSE;
}
-
+
camel_object_unref (cache);
-
+
info = camel_folder_summary_info_new_from_message (folder->summary, message);
g_free(info->uid);
info->uid = g_strdup (uid);
-
+
gw_message_info_dup_to ((CamelMessageInfoBase *) info, (CamelMessageInfoBase *) mi);
-
+
camel_folder_summary_add (folder->summary, info);
-
+
if (updated_uid)
*updated_uid = g_strdup (uid);
-
+
g_free (uid);
-
+
return TRUE;
}
CamelOfflineJournal *journal = (CamelOfflineJournal *) groupwise_journal;
CamelGroupwiseJournalEntry *entry;
char *uid;
-
+
if (!update_cache (groupwise_journal, message, mi, &uid, ex))
return;
-
+
entry = g_new (CamelGroupwiseJournalEntry, 1);
entry->type = CAMEL_GROUPWISE_JOURNAL_ENTRY_APPEND;
entry->uid = uid;
-
+
e_dlist_addtail (&journal->queue, (EDListNode *) entry);
-
+
if (appended_uid)
*appended_uid = g_strdup (uid);
}
CamelGroupwiseStore *gw_store= CAMEL_GROUPWISE_STORE(journal->folder->parent_store) ;
CamelGroupwiseJournalEntry *entry;
char *uid;
-
+
if (!update_cache (groupwise_journal, message, mi, &uid, ex))
return;
-
+
entry = g_new (CamelGroupwiseJournalEntry, 1);
entry->type = CAMEL_GROUPWISE_JOURNAL_ENTRY_APPEND;
entry->uid = uid;
entry->original_uid = g_strdup (original_uid);
entry->source_container = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, ((CamelFolder *)source_folder)->name));
-
+
e_dlist_addtail (&journal->queue, (EDListNode *) entry);
-
+
if (transferred_uid)
*transferred_uid = g_strdup (uid);
}
struct _CamelGroupwiseJournalEntry {
EDListNode node;
-
+
int type;
char *uid;
struct _CamelGroupwiseJournal {
CamelOfflineJournal parent_object;
-
+
};
struct _CamelGroupwiseJournalClass {
CamelOfflineJournalClass parent_class;
-
+
};
/* interfaces for adding a journal entry */
void camel_groupwise_journal_append (CamelGroupwiseJournal *journal, CamelMimeMessage *message, const CamelMessageInfo *mi,
char **appended_uid, CamelException *ex);
-void camel_groupwise_journal_transfer (CamelGroupwiseJournal *journal, CamelGroupwiseFolder *source_folder, CamelMimeMessage *message,
+void camel_groupwise_journal_transfer (CamelGroupwiseJournal *journal, CamelGroupwiseFolder *source_folder, CamelMimeMessage *message,
const CamelMessageInfo *mi, const char *orginal_uid, char **transferred_uid, CamelException *ex);
G_END_DECLS
*
* Copyright 2004 Novell Inc
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
{ CAMEL_PROVIDER_CONF_HIDDEN, "auth-domain", NULL,
NULL, "Groupwise" },
-
- { CAMEL_PROVIDER_CONF_SECTION_END },
+
+ { CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_END }
};
CamelServiceAuthType camel_groupwise_password_authtype = {
N_("Password"),
-
+
N_("This option will connect to the GroupWise server using a "
"plaintext password."),
-
+
"",
TRUE
};
groupwise_provider.auto_detect = groupwise_auto_detect_cb;
groupwise_provider.authtypes = g_list_prepend (groupwise_provider.authtypes, &camel_groupwise_password_authtype);
groupwise_provider.translation_domain = GETTEXT_PACKAGE;
-
+
if (use_imap)
groupwise_provider.object_types[CAMEL_PROVIDER_STORE] = imap_provider->object_types [CAMEL_PROVIDER_STORE];
else {
groupwise_provider.object_types[CAMEL_PROVIDER_STORE] = camel_groupwise_store_get_type();
groupwise_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = camel_groupwise_transport_get_type();
- }
-
+ }
+
camel_provider_register (&groupwise_provider);
}
add_hash (&hash, u->authmech);
add_hash (&hash, u->host);
hash ^= u->port;
-
+
return hash;
}
else
return FALSE;
}
-
+
if (s2 == NULL)
return FALSE;
groupwise_url_equal (gconstpointer a, gconstpointer b)
{
const CamelURL *u1 = a, *u2 = b;
-
+
return check_equal (u1->protocol, u2->protocol)
&& check_equal (u1->user, u2->user)
&& check_equal (u1->authmech, u2->authmech)
/*
* Copyright (C) 2002 Ximian Inc.
*
- * Authors: Parthasarathi Susarla <sparthasarathi@novell.com>
+ * Authors: Parthasarathi Susarla <sparthasarathi@novell.com>
*
* Description: Based on the imap implementaion of camelstoresummary
*
ssklass->summary_header_load = summary_header_load;
ssklass->summary_header_save = summary_header_save;
-
+
ssklass->store_info_load = store_info_load;
ssklass->store_info_save = store_info_save;
ssklass->store_info_free = store_info_free;
return ns;
}
-void
+void
camel_groupwise_store_summary_namespace_set(CamelGroupwiseStoreSummary *s, CamelGroupwiseStoreNamespace *ns)
{
d(printf("Setting namesapce to '%s' '%c' -> '%s'\n", ns->full_name, ns->sep, ns->path));
gint32 version, capabilities, count ;
namespace_clear (s) ;
-
+
if (camel_groupwise_store_summary_parent->summary_header_load ((CamelStoreSummary *)s, in) == -1
|| camel_file_util_decode_fixed_int32(in, &version) == -1)
return -1 ;
summary->capabilities = capabilities ;
if (count == 1) {
- if ((summary->namespace = namespace_load (s, in)) == NULL)
+ if ((summary->namespace = namespace_load (s, in)) == NULL)
return -1 ;
}
return 0 ;
#include <glib/gstdio.h>
#include "camel-debug.h"
-#include "camel-folder.h"
+#include "camel-folder.h"
#include "camel-net-utils.h"
#include "camel-private.h"
#include "camel-session.h"
#include "camel-groupwise-summary.h"
#include "camel-groupwise-utils.h"
-#define d(x)
+#define d(x)
#define CURSOR_ITEM_LIMIT 100
#define JUNK_ENABLE 1
#define JUNK_PERSISTENCE 14
const char *property_value;
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
char *path = NULL;
-
+
d("in groupwise store constrcut\n");
CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
if (camel_exception_is_set (ex))
return;
-
+
if (!(url->host || url->user)) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID,
_("Host or user not available in url"));
* This is a dirty hack. But it *WORKS*
*/
groupwise_store->list_loaded = 3;
-
+
/*storage path*/
priv->storage_path = camel_session_get_storage_path (session, service, ex);
if (!priv->storage_path)
return;
-
+
/*store summary*/
path = g_alloca (strlen (priv->storage_path) + 32);
sprintf (path, "%s/.summary", priv->storage_path);
camel_store_summary_set_filename ((CamelStoreSummary *)groupwise_store->summary, path);
camel_store_summary_touch ((CamelStoreSummary *)groupwise_store->summary);
camel_store_summary_load ((CamelStoreSummary *) groupwise_store->summary);
-
+
/*host and user*/
priv->server_name = g_strdup (url->host);
priv->user = g_strdup (url->user);
priv->port = g_strdup (property_value);
/*filter*/
- if (camel_url_get_param (url, "filter"))
+ if (camel_url_get_param (url, "filter"))
store->flags |= CAMEL_STORE_FILTER_INBOX;
-
- /*Hash Table*/
+
+ /*Hash Table*/
priv->id_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
priv->name_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
priv->parent_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
gboolean authenticated = FALSE;
char *uri;
- if (priv->use_ssl && !g_str_equal (priv->use_ssl, "never"))
+ if (priv->use_ssl && !g_str_equal (priv->use_ssl, "never"))
uri = g_strconcat ("https://", priv->server_name, ":", priv->port, "/soap", NULL);
- else
+ else
uri = g_strconcat ("http://", priv->server_name, ":", priv->port, "/soap", NULL);
service->url->passwd = NULL;
-
+
while (!authenticated) {
if (errbuf) {
g_free (service->url->passwd);
service->url->passwd = NULL;
}
-
-
+
+
if (!service->url->passwd && !(store->flags & CAMEL_STORE_PROXY)) {
char *prompt;
-
+
prompt = g_strdup_printf (_("%sPlease enter the GroupWise "
"password for %s@%s"),
errbuf ? errbuf : "",
g_free (prompt);
g_free (errbuf);
errbuf = NULL;
-
+
if (!service->url->passwd) {
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
_("You did not enter a password."));
return FALSE;
}
}
-
+
priv->cnc = e_gw_connection_new (uri, priv->user, service->url->passwd);
if (!E_IS_GW_CONNECTION(priv->cnc) && priv->use_ssl && g_str_equal (priv->use_ssl, "when-possible")) {
char *http_uri = g_strconcat ("http://", uri + 8, NULL);
if (!E_IS_GW_CONNECTION(priv->cnc)) {
errbuf = g_strdup_printf (_("Unable to authenticate "
"to GroupWise server. "));
-
+
camel_exception_clear (ex);
- } else
+ } else
authenticated = TRUE;
-
+
}
-
+
return TRUE;
}
CamelSession *session = service->session;
d("in groupwise store connect\n");
-
-/* if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
+
+/* if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
(service->status == CAMEL_SERVICE_DISCONNECTED))
return FALSE; */
if (service->status == CAMEL_SERVICE_DISCONNECTED)
}
CAMEL_SERVICE_REC_LOCK (service, connect_lock);
-
+
if (priv->cnc) {
CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
return TRUE;
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
-
-
+
+
service->status = CAMEL_SERVICE_CONNECTED;
((CamelOfflineStore *) store)->state = CAMEL_OFFLINE_STORE_NETWORK_AVAIL;
if (!e_gw_connection_get_version (priv->cnc)) {
- camel_session_alert_user(session,
- CAMEL_SESSION_ALERT_WARNING,
+ camel_session_alert_user(session,
+ CAMEL_SESSION_ALERT_WARNING,
_("Some features may not work correctly with your current server version"),
FALSE);
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
-
+
g_print ("camel_groupwise_store_finalize\n");
if (groupwise_store->summary) {
camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
camel_object_unref (groupwise_store->summary);
}
-
+
if (priv) {
if (priv->user) {
g_free (priv->user);
g_free (priv->base_url);
priv->base_url = NULL;
}
-
+
if (priv->storage_path)
g_free(priv->storage_path);
if(groupwise_store->root_container)
g_free (groupwise_store->root_container);
-
+
if (priv->id_hash)
g_hash_table_destroy (priv->id_hash);
groupwise_disconnect (CamelService *service, gboolean clean, CamelException *ex)
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
-
+
if (clean) {
CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
if (groupwise_store->priv && groupwise_store->priv->cnc) {
}
CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
}
-
+
//groupwise_disconnect_cleanup (service, clean, ex);
return TRUE;
}
groupwise_store_query_auth_types (CamelService *service, CamelException *ex)
{
GList *auth_types = NULL;
-
+
d("in query auth types\n");
auth_types = g_list_prepend (auth_types, &camel_groupwise_password_authtype);
return auth_types;
CamelGroupwiseStorePrivate *priv = gw_store->priv;
fi = g_malloc0(sizeof(*fi));
-
+
fi->unread = -1;
fi->total = -1;
if (parent_name) {
- if (strlen(parent_name) > 0)
+ if (strlen(parent_name) > 0)
fi->full_name = g_strconcat(parent_name, "/", folder_name, NULL);
else
fi->full_name = g_strdup (folder_name);
- } else
+ } else
fi->full_name = g_strdup(folder_name);
-
+
url = camel_url_new(priv->base_url,NULL);
g_free(url->path);
url->path = g_strdup_printf("/%s", fi->full_name);
fi->flags |= CAMEL_FOLDER_TYPE_TRASH;
else if (!strcmp (folder_name, "Junk Mail"))
fi->flags |= CAMEL_FOLDER_TYPE_JUNK;
-
+
fi->name = g_strdup(name);
return fi;
}
CamelFolderInfo *fi;
const char *name;
-
+
name = folder_name;
storage_path = g_strdup_printf ("%s/folders", priv->storage_path);
return folder;
}
-static CamelFolder *
+static CamelFolder *
groupwise_get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex)
{
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (store);
EGwConnectionStatus status;
GList *list = NULL;
gboolean done = FALSE, all_ok = TRUE;
- const char *position = E_GW_CURSOR_POSITION_END;
+ const char *position = E_GW_CURSOR_POSITION_END;
int count = 0, cursor, summary_count = 0;
CamelStoreInfo *si = NULL;
guint total = 0;
-
+
folder = groupwise_get_folder_from_disk (store, folder_name, flags, ex);
if (folder) {
camel_object_ref (folder);
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
return NULL;
}
-
+
if (gw_store->current_folder) {
camel_object_unref (gw_store->current_folder);
gw_store->current_folder = NULL;
return NULL;
}
g_free (folder_dir);
-
+
si = camel_store_summary_path ((CamelStoreSummary *)gw_store->summary, folder_name);
if (si) {
total = si->total;
if(!summary_count || !summary->time_string) {
d(g_print ("\n\n** %s **: No summary as yet : using get cursor request\n\n", folder->name);)
- status = e_gw_connection_create_cursor (priv->cnc, container_id,
+ status = e_gw_connection_create_cursor (priv->cnc, container_id,
"peek id recipient attachments distribution subject status options priority startDate created delivered size hasAttachment",
NULL,
&cursor);
camel_folder_summary_clear (folder->summary);
while (!done) {
- status = e_gw_connection_read_cursor (priv->cnc, container_id,
- cursor, FALSE,
+ status = e_gw_connection_read_cursor (priv->cnc, container_id,
+ cursor, FALSE,
CURSOR_ITEM_LIMIT, position, &list);
if (status != E_GW_CONNECTION_STATUS_OK) {
all_ok = FALSE;
g_free (container_id);
return NULL;*/
}
-
+
count += g_list_length (list);
-
+
if (total > 0)
camel_operation_progress (NULL, (100*count)/total);
gw_update_summary (folder, list, ex);
-
+
if (!list)
done = TRUE;
g_list_foreach (list, (GFunc)g_object_unref, NULL);
e_gw_connection_destroy_cursor (priv->cnc, container_id, cursor);
camel_operation_end (NULL);
- }
+ }
if (done && all_ok) {
if (summary->time_string)
g_free (summary->time_string);
return folder;
}
-void
+void
gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guint32 flags, CamelException *ex)
{
CamelGroupwiseStorePrivate *priv = gw_store->priv;
EGwConnectionStatus status;
GList *list = NULL;
gboolean done = FALSE;
- const char *position = E_GW_CURSOR_POSITION_END;
+ const char *position = E_GW_CURSOR_POSITION_END;
int count = 0, cursor, summary_count = 0;
CamelStoreInfo *si = NULL;
guint total = 0;
-
+
camel_exception_clear (ex);
CAMEL_SERVICE_REC_LOCK (gw_store, connect_lock);
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
return;
}
-
+
if (!E_IS_GW_CONNECTION( priv->cnc)) {
if (!groupwise_connect (CAMEL_SERVICE((CamelStore*)gw_store), ex)) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Authentication failed"));
return;
}
}
-
+
container_id = g_strdup (g_hash_table_lookup (priv->name_hash, folder->full_name));
si = camel_store_summary_path ((CamelStoreSummary *)gw_store->summary, folder->name);
if(!summary_count || !summary->time_string) {
d(g_print ("\n\n** %s **: Summary missing???? Reloading summary....\n\n", folder->name);)
- status = e_gw_connection_create_cursor (priv->cnc, container_id,
+ status = e_gw_connection_create_cursor (priv->cnc, container_id,
"peek id recipient attachments distribution subject status options priority startDate created delivered size hasAttachment",
NULL,
&cursor);
camel_operation_start (NULL, _("Fetching summary information for new messages in %s"), folder->name);
while (!done) {
- status = e_gw_connection_read_cursor (priv->cnc, container_id,
- cursor, FALSE,
+ status = e_gw_connection_read_cursor (priv->cnc, container_id,
+ cursor, FALSE,
CURSOR_ITEM_LIMIT, position, &list);
if (status != E_GW_CONNECTION_STATUS_OK) {
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
g_free (container_id);
return;
}
-
+
count += g_list_length (list);
-
+
if (total > 0)
camel_operation_progress (NULL, (100*count)/total);
gw_update_summary (folder, list, ex);
-
+
if (!list)
done = TRUE;
g_list_foreach (list, (GFunc)g_object_unref, NULL);
e_gw_connection_destroy_cursor (priv->cnc, container_id, cursor);
camel_operation_end (NULL);
- }
+ }
if (done) {
if (summary->time_string)
camel_folder_summary_save (folder->summary);
gw_store->current_folder = folder;
-
+
g_free (container_id);
CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
return;
name = e_gw_container_get_name (container);
id = e_gw_container_get_id (container);
type = e_gw_container_get_container_type (container);
-
+
fi = g_new0 (CamelFolderInfo, 1);
if (type == E_GW_CONTAINER_TYPE_INBOX)
(type == E_GW_CONTAINER_TYPE_DRAFT) ||
(type == E_GW_CONTAINER_TYPE_CABINET) ||
(type == E_GW_CONTAINER_TYPE_JUNK) ||
- (type == E_GW_CONTAINER_TYPE_TRASH) )
+ (type == E_GW_CONTAINER_TYPE_TRASH) )
fi->flags |= CAMEL_FOLDER_SYSTEM;
/*
parent_hash contains the "parent id <-> container id" combination. So we form
temp = g_hash_table_lookup (priv->id_hash, temp_parent );
if (temp == NULL) {
break;
- }
+ }
str = g_strconcat ( temp, "/", str, NULL);
temp_parent = g_hash_table_lookup (priv->parent_hash, temp_parent);
- }
+ }
fi->full_name = g_strdup (str);
fi->uri = g_strconcat (url, str, NULL);
g_free (str);
si->info.unread = fi->unread;
si->info.flags = fi->flags;
/*refresh info*/
- if (store->current_folder
+ if (store->current_folder
&& !strcmp (store->current_folder->full_name, fi->full_name)
&& type != E_GW_CONTAINER_TYPE_INBOX) {
CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (store->current_folder))->refresh_info(store->current_folder, ex);
g_free ((char *)url);
url = temp_url;
}
-
+
/*populate the hash table for finding the mapping from container id <-> folder name*/
for (;temp_list != NULL ; temp_list = g_list_next (temp_list) ) {
const char *name, *id, *parent;
}
/*id_hash returns the name for a given container id*/
- g_hash_table_insert (priv->id_hash, g_strdup(id), g_strdup(name));
+ g_hash_table_insert (priv->id_hash, g_strdup(id), g_strdup(name));
/*parent_hash returns the parent container id, given an id*/
g_hash_table_insert (priv->parent_hash, g_strdup(id), g_strdup(parent));
}
for (;folder_list != NULL; folder_list = g_list_next (folder_list)) {
EGwContainerType type;
EGwContainer *container = E_GW_CONTAINER (folder_list->data);
-
+
type = e_gw_container_get_container_type (container);
if (e_gw_container_is_root(container))
}
}
}
-
+
g_free ((char *)url);
e_gw_connection_free_container_list (list);
count = camel_store_summary_count ((CamelStoreSummary *)store->summary);
for (i=0;i<camel_store_summary_count((CamelStoreSummary *)groupwise_store->summary);i++) {
CamelStoreInfo *si = camel_store_summary_index((CamelStoreSummary *)groupwise_store->summary, i);
- if (si == NULL)
+ if (si == NULL)
continue;
-
+
if ( !strcmp(name, camel_groupwise_store_info_full_name (groupwise_store->summary, si))
|| match_path (path, camel_groupwise_store_info_full_name (groupwise_store->summary, si))) {
fi = groupwise_build_folder_info(groupwise_store, NULL, camel_store_info_path((CamelStoreSummary *)groupwise_store->summary, si));
{
struct _store_refresh_msg *m = (struct _store_refresh_msg *)msg;
CamelGroupwiseStore *groupwise_store = (CamelGroupwiseStore *)m->store;
-
+
CAMEL_SERVICE_REC_LOCK (m->store, connect_lock);
if (!camel_groupwise_store_connected ((CamelGroupwiseStore *)m->store, &m->ex))
goto done;
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
CamelFolderInfo *info = NULL;
char *top_folder = NULL;
-
+
if (top) {
top_folder = g_hash_table_lookup (priv->name_hash, top);
/* 'top' is a valid path, but doesnt have a container id
}*/
}
- if (top && groupwise_is_system_folder (top))
+ if (top && groupwise_is_system_folder (top))
return groupwise_build_folder_info (groupwise_store, NULL, top );
/*
if (!priv->cnc) {
if (groupwise_connect ((CamelService *)store, ex)) {
g_warning ("Could connect!!!\n");
- } else
+ } else
g_warning ("Could not connect..failure connecting\n");
}
if (camel_groupwise_store_connected ((CamelGroupwiseStore *)store, ex)) {
folder_name = "Junk Mail";
parent_id = "";
/* TODO: check for offlining*/
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
status = e_gw_connection_modify_junk_settings (priv->cnc, JUNK_ENABLE, 0, 0, JUNK_PERSISTENCE);
if (status == E_GW_CONNECTION_STATUS_OK) {
root = groupwise_build_folder_info(groupwise_store, parent_name, folder_name);
camel_store_summary_save((CamelStoreSummary *)groupwise_store->summary);
-
+
child_container_id = e_gw_connection_get_container_id (priv->cnc, "Junk Mail");
if (!child_container_id)
g_warning("failed to retrieve id for junk folder");
-
- g_hash_table_insert (priv->id_hash, g_strdup(child_container_id), g_strdup(folder_name));
+
+ g_hash_table_insert (priv->id_hash, g_strdup(child_container_id), g_strdup(folder_name));
g_hash_table_insert (priv->name_hash, g_strdup(folder_name), g_strdup(child_container_id));
g_hash_table_insert (priv->parent_hash, g_strdup(child_container_id), g_strdup(parent_id));
camel_object_trigger_event (CAMEL_OBJECT (store), "folder_created", root);
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create GroupWise folders in offline mode."));
return NULL;
}
-
+
if(parent_name == NULL) {
parent_name = "";
if (groupwise_is_system_folder (folder_name)) {
root = groupwise_build_folder_info(groupwise_store, parent_name,folder_name);
camel_store_summary_save((CamelStoreSummary *)groupwise_store->summary);
- g_hash_table_insert (priv->id_hash, g_strdup(child_container_id), g_strdup(folder_name));
+ g_hash_table_insert (priv->id_hash, g_strdup(child_container_id), g_strdup(folder_name));
g_hash_table_insert (priv->name_hash, g_strdup(root->full_name), g_strdup(child_container_id));
g_hash_table_insert (priv->parent_hash, g_strdup(child_container_id), g_strdup(parent_id));
return root;
}
-static void
+static void
groupwise_delete_folder(CamelStore *store,
const char *folder_name,
CamelException *ex)
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
EGwConnectionStatus status;
- const char * container;
-
+ const char * container;
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
if (!camel_groupwise_store_connected ((CamelGroupwiseStore *)store, ex)) {
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return;
g_hash_table_remove (priv->id_hash, container);
g_hash_table_remove (priv->name_hash, folder_name);
-
+
g_hash_table_remove (priv->parent_hash, container);
}
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
}
-static void
+static void
groupwise_rename_folder(CamelStore *store,
const char *old_name,
const char *new_name,
char *oldpath, *newpath, *storepath;
const char *container_id;
char *temp_new = NULL;
-
+
if (groupwise_is_system_folder (old_name)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename Groupwise folder `%s' to `%s'"),
old_name, new_name);
}
CAMEL_SERVICE_REC_LOCK (groupwise_store, connect_lock);
-
+
if (!camel_groupwise_store_connected ((CamelGroupwiseStore *)store, ex)) {
CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
return;
}
-
+
container_id = camel_groupwise_store_container_id_lookup (groupwise_store, old_name);
temp_new = strrchr (new_name, '/');
- if (temp_new)
+ if (temp_new)
temp_new++;
else
temp_new = (char *)new_name;
-
+
if (!container_id || e_gw_connection_rename_folder (priv->cnc, container_id , temp_new) != E_GW_CONNECTION_STATUS_OK)
{
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename Groupwise folder `%s' to `%s'"),
CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
}
-char *
-groupwise_get_name(CamelService *service, gboolean brief)
+char *
+groupwise_get_name(CamelService *service, gboolean brief)
{
- if(brief)
+ if(brief)
return g_strdup_printf(_("GroupWise server %s"), service->url->host);
else
- return g_strdup_printf(_("GroupWise service for %s on %s"),
+ return g_strdup_printf(_("GroupWise service for %s on %s"),
service->url->user, service->url->host);
}
camel_object_state_read(folder);
return folder;
- } else
+ } else
return NULL;
}
/*
* Function to check if we are both connected and are _actually_
* online. Based on an equivalient function in IMAP
- */
+ */
gboolean
camel_groupwise_store_connected (CamelGroupwiseStore *store, CamelException *ex)
{
return FALSE;
}
-static int
+static int
match_path(const char *path, const char *name)
{
char p, n;
CAMEL_SERVICE_CLASS (camel_groupwise_store_class);
CamelStoreClass *camel_store_class =
CAMEL_STORE_CLASS (camel_groupwise_store_class);
-
+
parent_class = CAMEL_OFFLINE_STORE_CLASS (camel_type_get_global_classfuncs (camel_offline_store_get_type ()));
-
+
camel_service_class->construct = groupwise_store_construct;
camel_service_class->query_auth_types = groupwise_store_query_auth_types;
camel_service_class->get_name = groupwise_get_name;
camel_service_class->connect = groupwise_connect;
camel_service_class->disconnect = groupwise_disconnect;
-
+
camel_store_class->hash_folder_name = groupwise_hash_folder_name;
camel_store_class->compare_folder_name = groupwise_compare_folder_name;
-
+
camel_store_class->get_folder = groupwise_get_folder;
camel_store_class->create_folder = groupwise_create_folder;
camel_store_class->delete_folder = groupwise_delete_folder;
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (object);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
-
+
g_print ("camel_groupwise_store_finalize\n");
if (groupwise_store->summary) {
camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
camel_object_unref (groupwise_store->summary);
}
-
+
if (priv) {
if (priv->user) {
g_free (priv->user);
g_free (priv->base_url);
priv->base_url = NULL;
}
-
+
if (E_IS_GW_CONNECTION (priv->cnc)) {
g_object_unref (priv->cnc);
priv->cnc = NULL;
if(groupwise_store->root_container)
g_free (groupwise_store->root_container);
-
+
if (priv->id_hash)
g_hash_table_destroy (priv->id_hash);
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (object);
CamelGroupwiseStorePrivate *priv = g_new0 (CamelGroupwiseStorePrivate, 1);
-
+
d("in groupwise store init\n");
priv->server_name = NULL;
priv->port = NULL;
priv->user = NULL;
priv->cnc = NULL;
groupwise_store->priv = priv;
-
+
}
CamelType
camel_groupwise_store_get_type (void)
{
static CamelType camel_groupwise_store_type = CAMEL_INVALID_TYPE;
-
+
if (camel_groupwise_store_type == CAMEL_INVALID_TYPE) {
camel_groupwise_store_type =
camel_type_register (camel_offline_store_get_type (),
(CamelObjectInitFunc) camel_groupwise_store_init,
(CamelObjectFinalizeFunc) camel_groupwise_store_finalize);
}
-
+
return camel_groupwise_store_type;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-groupwise-store.h : class for an groupwise store */
-/*
+/*
* Authors: Sivaiah Nallagatla <snallagatla@novell.com>
*
* Copyright (C) 2004 Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
char *root_container;
CamelGroupwiseStorePrivate *priv;
CamelFolder *current_folder;
-
+
/* the parameters field is not to be included not. probably for 2.6*/
/*guint32 parameters;*/
time_t refresh_stamp;
*
* Authors:
* parthasrathi susarla <sparthasrathi@novell.com>
- * Based on the IMAP summary class implementation by:
+ * Based on the IMAP summary class implementation by:
* Michael Zucchi <notzed@ximian.com>
* Dan Winship <danw@ximian.com>
*
static int gw_message_info_save (CamelFolderSummary *s, FILE *out, CamelMessageInfo *info) ;
static CamelMessageContentInfo * gw_content_info_load (CamelFolderSummary *s, FILE *in) ;
static int gw_content_info_save (CamelFolderSummary *s, FILE *out, CamelMessageContentInfo *info) ;
-static gboolean gw_info_set_flags(CamelMessageInfo *info, guint32 flags, guint32 set);
+static gboolean gw_info_set_flags(CamelMessageInfo *info, guint32 flags, guint32 set);
static void camel_groupwise_summary_class_init (CamelGroupwiseSummaryClass *klass);
static void camel_groupwise_summary_init (CamelGroupwiseSummary *obj);
/* subclasses need to set the right instance data sizes */
s->message_info_size = sizeof(CamelGroupwiseMessageInfo);
s->content_info_size = sizeof(CamelGroupwiseMessageContentInfo);
-
+
/* Meta-summary - Overriding UID len */
s->meta_summary->uid_len = 2048;
}
{
CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (
camel_object_new (camel_groupwise_summary_get_type ()));
-
+
summary->folder = folder ;
camel_folder_summary_set_build_content (summary, TRUE);
camel_folder_summary_set_filename (summary, filename);
if (camel_file_util_decode_fixed_int32(in, &ims->version) == -1
|| camel_file_util_decode_fixed_int32(in, &ims->validity) == -1)
return -1;
-
+
if (camel_file_util_decode_string (in, &ims->time_string) == -1)
return -1;
return 0 ;
static CamelMessageContentInfo *
gw_content_info_load (CamelFolderSummary *s, FILE *in)
-{
+{
if (fgetc (in))
return camel_groupwise_summary_parent->content_info_load (s, in);
else
/* we don't set flags which aren't appropriate for the folder*/
if ((set == (CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_JUNK_LEARN|CAMEL_MESSAGE_SEEN)) && (old & CAMEL_GW_MESSAGE_JUNK))
return FALSE;
-
+
mi->flags = (old & ~flags) | (set & flags);
if (old != mi->flags) {
mi->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED;
}
/* This is a hack, we are using CAMEL_MESSAGE_JUNK justo to hide the item
* we make sure this doesn't have any side effects*/
-
+
if ((set == CAMEL_MESSAGE_JUNK_LEARN) && (old & CAMEL_GW_MESSAGE_JUNK)) {
mi->flags |= CAMEL_GW_MESSAGE_NOJUNK | CAMEL_MESSAGE_JUNK;
- /* This has ugly side-effects. Evo will never learn unjunk.
+ /* This has ugly side-effects. Evo will never learn unjunk.
We need to create one CAMEL_MESSAGE_HIDDEN flag which must be used for all hiding operations. We must also get rid of the seperate file that is maintained somewhere in evolution/mail/em-folder-browser.c for hidden messages
*/
camel_folder_summary_touch(mi->summary);
}
- } else if ((old & ~CAMEL_MESSAGE_SYSTEM_MASK) == (mi->flags & ~CAMEL_MESSAGE_SYSTEM_MASK))
+ } else if ((old & ~CAMEL_MESSAGE_SYSTEM_MASK) == (mi->flags & ~CAMEL_MESSAGE_SYSTEM_MASK))
return FALSE;
if (mi->summary && mi->summary->folder && mi->uid) {
void
camel_gw_summary_add_offline (CamelFolderSummary *summary, const char *uid, CamelMimeMessage *message, const CamelMessageInfo *info)
{
- CamelGroupwiseMessageInfo *mi ;
+ CamelGroupwiseMessageInfo *mi ;
const CamelFlag *flag ;
const CamelTag *tag ;
for (i = 0; i < count; i++) {
if (!(info = camel_folder_summary_index (summary, i)))
continue;
-
+
uid = camel_message_info_uid (info);
camel_folder_change_info_remove_uid (changes, uid);
camel_folder_summary_remove_uid (summary, uid);
struct _CamelGroupwiseMessageContentInfo {
CamelMessageContentInfo info ;
-} ;
+} ;
struct _CamelGroupwiseSummary {
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-groupwise-transport.c : class for an groupwise transport */
-/*
+/*
* Authors: Sivaiah Nallagatla <snallagatla@novell.com>
* Parthasarathi Susarla <sparthasarathi@novell.com>
*
* Copyright (C) 2004 Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#include "camel-mime-message.h"
#include "camel-mime-utils.h"
#include "camel-multipart.h"
-#include "camel-session.h"
+#include "camel-session.h"
#include "camel-stream-mem.h"
#include "camel-stream.h"
CamelServiceClass *camel_service_class =
CAMEL_SERVICE_CLASS (camel_groupwise_transport_class);
-
+
parent_class = CAMEL_TRANSPORT_CLASS (camel_type_get_global_classfuncs (camel_transport_get_type ()));
-
+
camel_service_class->connect = groupwise_transport_connect;
camel_service_class->get_name = groupwise_transport_get_name;
camel_service_class->construct = groupwise_transport_construct;
-
+
/* virtual method overload */
camel_transport_class->send_to = groupwise_send_to;
}
static gboolean
-groupwise_send_to (CamelTransport *transport,
+groupwise_send_to (CamelTransport *transport,
CamelMimeMessage *message,
- CamelAddress *from,
+ CamelAddress *from,
CamelAddress *recipients,
CamelException *ex)
{
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, _("Authentication failed"));
return FALSE;
}
-
+
item = camel_groupwise_util_item_from_message (cnc, message, from);
-
+
reply_request = (char *)camel_medium_get_header (CAMEL_MEDIUM (message), "In-Reply-To");
if (reply_request) {
char *id;
id = (char *)g_malloc0 (len-1);
id = memcpy(id, reply_request+2, len-3);
status = e_gw_connection_reply_item (cnc, id, NULL, &temp_item);
- if (status != E_GW_CONNECTION_STATUS_OK)
+ if (status != E_GW_CONNECTION_STATUS_OK)
g_warning ("Could not send a replyRequest...continuing without!!\n");
else {
info = e_gw_item_get_link_info (temp_item);
g_free (id);
}
-
-
+
+
/*Send item*/
status = e_gw_connection_send_item (cnc, item, &sent_item_list);
if (status != E_GW_CONNECTION_STATUS_OK) {
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-groupwise-transport.h : class for an groupwise transport */
-/*
+/*
* Authors: Sivaiah Nallagatla <snallagatla@novell.com>
*
* Copyright (C) 2004 Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
{
int total_add,i;
EGwItemRecipient *recipient;
-
+
total_add = camel_address_length (recipients);
for (i=0 ; i<total_add ; i++) {
const char *name = NULL, *addr = NULL;
return recipient_list;
}
-static void
+static void
send_as_attachment (EGwConnection *cnc, EGwItem *item, CamelStreamMem *content, CamelContentType *type, CamelDataWrapper *dw, const char *filename, const char *cid, GSList **attach_list)
{
EGwItemLinkInfo *info = NULL;
EGwConnectionStatus status;
EGwItemAttachment *attachment;
EGwItem *temp_item;
-
+
attachment = g_new0 (EGwItemAttachment, 1);
attachment->contentType = camel_content_type_simple (type);
-
+
if (cid)
attachment->contentid = camel_header_contentid_decode (cid);
-
+
if (filename) {
if (camel_content_type_is (type, "application", "pgp-signature")) {
char *temp_str;
temp_len = 0;
}
}
-
+
if (camel_content_type_is (type, "text", "html") || camel_content_type_is (type, "multipart", "alternative")) {
if (!filename)
filename = "text.htm";
const char *message_id;
char *msgid;
int len;
-
+
message_id = camel_medium_get_header (CAMEL_MEDIUM (dw), "Message-Id");
/*
* XXX: The following code piece is a screwed up way of doing stuff.
* since it removes the container id portion from the id and which the
* groupwise server needs.
*/
-
+
len = strlen (message_id);
msgid = (char *)g_malloc0 (len-1);
msgid = memcpy(msgid, message_id+2, len-3);
status = e_gw_connection_forward_item (cnc, msgid, NULL, TRUE, &temp_item);
g_free (msgid);
-
+
if (status != E_GW_CONNECTION_STATUS_OK) {
g_warning ("Could not send a forwardRequest...continuing without!!\n");
} else {
attachment->name = g_strdup (temp_attach->name);
g_free (attachment->contentType);
attachment->contentType = g_strdup ("Mail");
- g_free (attachment->data);
+ g_free (attachment->data);
attachment->data = NULL;
attachment->size = 0;
info = e_gw_item_get_link_info (temp_item);
/*Egroupwise item*/
item = e_gw_item_new_empty ();
-
+
/*populate recipient list*/
recipients = CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO));
recipient_list=add_recipients(recipient_list,recipients,E_GW_ITEM_RECIPIENT_TO);
-
+
recipients = CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC));
recipient_list=add_recipients(recipient_list,recipients,E_GW_ITEM_RECIPIENT_CC);
-
+
recipients = CAMEL_ADDRESS (camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_BCC));
recipient_list=add_recipients(recipient_list,recipients,E_GW_ITEM_RECIPIENT_BC);
recipient_list = g_slist_reverse (recipient_list);
-
+
/** Get the mime parts from CamelMimemessge **/
mp = (CamelMultipart *)camel_medium_get_content_object (CAMEL_MEDIUM (message));
if(!mp) {
CamelStreamMem *content = (CamelStreamMem *)camel_stream_mem_new ();
CamelDataWrapper *dw = NULL;
CamelContentType *type;
-
+
dw = camel_medium_get_content_object (CAMEL_MEDIUM (message));
type = camel_mime_part_get_content_type((CamelMimePart *)message);
-
+
if (camel_content_type_is (type, "text", "plain")) {
CamelStream *filtered_stream;
CamelMimeFilter *filter;
const char *charset;
char *content_type;
-
+
content_type = camel_content_type_simple (type);
e_gw_item_set_content_type (item, content_type);
g_free (content_type);
-
+
charset = camel_content_type_param (type, "charset");
if (charset && g_ascii_strcasecmp (charset, "US-ASCII") && g_ascii_strcasecmp (charset, "UTF-8")) {
filter = (CamelMimeFilter *) camel_mime_filter_charset_new_convert (charset, "UTF-8");
filtered_stream = (CamelStream *) content;
camel_object_ref (content);
}
-
+
camel_data_wrapper_decode_to_stream (dw, filtered_stream);
camel_stream_flush (filtered_stream);
camel_object_unref (filtered_stream);
-
+
camel_stream_write ((CamelStream *) content, "", 1);
e_gw_item_set_message (item, (const char *)content->buffer->data);
} else {
camel_data_wrapper_decode_to_stream (dw, (CamelStream *) content);
- send_as_attachment (cnc, item, content, type, dw, NULL, NULL, &attach_list);
+ send_as_attachment (cnc, item, content, type, dw, NULL, NULL, &attach_list);
}
-
+
camel_object_unref (content);
}
/*Populate EGwItem*/
e_gw_item_set_subject (item, camel_mime_message_get_subject(message));
/*attachmets*/
e_gw_item_set_attach_id_list (item, attach_list);
-
+
/*send options*/
e_gw_item_set_sendoptions (item, TRUE);
- if ((char *)camel_medium_get_header (CAMEL_MEDIUM(message), X_REPLY_CONVENIENT))
+ if ((char *)camel_medium_get_header (CAMEL_MEDIUM(message), X_REPLY_CONVENIENT))
e_gw_item_set_reply_request (item, TRUE);
-
+
send_options = (char *)camel_medium_get_header (CAMEL_MEDIUM(message), X_REPLY_WITHIN);
- if (send_options) {
+ if (send_options) {
e_gw_item_set_reply_request (item, TRUE);
e_gw_item_set_reply_within (item, send_options);
}
send_options = (char *)camel_medium_get_header (CAMEL_MEDIUM(message), X_TRACK_WHEN);
- /*we check if user has modified the status tracking options, if no then we anyway
+ /*we check if user has modified the status tracking options, if no then we anyway
* set status tracking all*/
if (send_options) {
switch (atoi(send_options)) {
break;
case 1: e_gw_item_set_notify_deleted (item, E_GW_ITEM_NOTIFY_MAIL);
}
- }
-
+ }
+
send_options = (char *)camel_medium_get_header (CAMEL_MEDIUM (message), X_SEND_OPT_PRIORITY);
if (send_options) {
switch (atoi(send_options)) {
case E_GW_SECURITY_FOR_YOUR_EYES_ONLY : e_gw_item_set_security(item, "ForYourEyesOnly");
break;
}
- }
+ }
return item;
}
{
char *temp = NULL;
int len;
-
+
temp = g_strdup (*string);
len = strlen (*string);
type = camel_mime_part_get_content_type(part);
dw = camel_medium_get_content_object (CAMEL_MEDIUM (part));
-
+
if (CAMEL_IS_MULTIPART (dw)) {
do_multipart (cnc, item, (CamelMultipart *) camel_medium_get_content_object ((CamelMedium *) part), attach_list);
continue;
}
-
+
if (type->subtype && !strcmp (type->subtype, "alternative")) {
/* eh... I don't think this code will ever get hit? */
CamelMimePart *temp_part;
const char *cid = NULL;
CamelStreamMem *temp_content = (CamelStreamMem *)camel_stream_mem_new ();
CamelDataWrapper *temp_dw = NULL;
-
+
temp_part = camel_multipart_get_part ((CamelMultipart *)dw, 1);
if (temp_part) {
is_alternative = TRUE;
}
camel_object_unref (temp_content);
continue;
- }
-
+ }
+
if (i == 0 && camel_content_type_is (type, "text", "plain")) {
CamelStream *filtered_stream;
CamelMimeFilter *filter;
const char *charset;
char *content_type;
-
+
content_type = camel_content_type_simple (type);
e_gw_item_set_content_type (item, content_type);
g_free (content_type);
-
+
charset = camel_content_type_param (type, "charset");
if (charset && g_ascii_strcasecmp (charset, "US-ASCII") && g_ascii_strcasecmp (charset, "UTF-8")) {
filter = (CamelMimeFilter *) camel_mime_filter_charset_new_convert (charset, "UTF-8");
filtered_stream = (CamelStream *) content;
camel_object_ref (content);
}
-
+
camel_data_wrapper_decode_to_stream (dw, filtered_stream);
camel_stream_flush (filtered_stream);
camel_object_unref (filtered_stream);
-
+
camel_stream_write ((CamelStream *) content, "", 1);
e_gw_item_set_message (item, (const char *)content->buffer->data);
} else {
filename = camel_mime_part_get_filename (part);
disposition = camel_mime_part_get_disposition (part);
content_id = camel_mime_part_get_content_id (part);
-
+
camel_data_wrapper_decode_to_stream (dw, (CamelStream *) content);
send_as_attachment (cnc, item, content, type, dw, filename, content_id, attach_list);
}
-
+
camel_object_unref (content);
} /*end of for*/
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2001 Ximian, Inc.
*
* This library is free software; you can redistribute it and/or
{ CAMEL_PROVIDER_CONF_ENTRY, "namespace", "override_namespace",
N_("Namespace") },
{ CAMEL_PROVIDER_CONF_SECTION_END },
-
+
{ CAMEL_PROVIDER_CONF_END }
/* revisit each options in other providers (incl. authdomain) for
* relevancy - harish*/
static CamelServiceAuthType camel_hula_password_authtype = {
N_("Password"),
-
+
N_("This option will connect to the Hula server using a "
"plaintext password."),
-
+
"",
TRUE
};
hula_provider.auto_detect = hula_auto_detect_cb;
hula_provider.authtypes = g_list_prepend (hula_provider.authtypes, &camel_hula_password_authtype);
hula_provider.translation_domain = GETTEXT_PACKAGE;
-
+
hula_provider.object_types[CAMEL_PROVIDER_STORE] = imap_provider->object_types [CAMEL_PROVIDER_STORE];
-
-
+
+
camel_provider_register (&hula_provider);
}
add_hash (&hash, u->authmech);
add_hash (&hash, u->host);
hash ^= u->port;
-
+
return hash;
}
else
return FALSE;
}
-
+
if (s2 == NULL)
return FALSE;
hula_url_equal (gconstpointer a, gconstpointer b)
{
const CamelURL *u1 = a, *u2 = b;
-
+
return check_equal (u1->protocol, u2->protocol)
&& check_equal (u1->user, u2->user)
&& check_equal (u1->authmech, u2->authmech)
{
va_list ap;
char *cmd;
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
if (fmt) {
va_start (ap, fmt);
cmd = imap_command_strdup_vprintf (store, fmt, ap);
store->current_folder = folder;
cmd = imap_command_strdup_printf (store, "SELECT %F", folder->full_name);
}
-
+
if (!imap_command_start (store, folder, cmd, ex)) {
g_free (cmd);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return NULL;
}
g_free (cmd);
-
+
return imap_read_response (store, ex);
}
va_list ap;
char *cmd;
gboolean ok;
-
+
va_start (ap, fmt);
cmd = imap_command_strdup_vprintf (store, fmt, ap);
va_end (ap);
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
ok = imap_command_start (store, folder, cmd, ex);
g_free (cmd);
-
+
if (!ok)
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return ok;
const char *cmd, CamelException *ex)
{
ssize_t nwritten;
-
+
g_return_val_if_fail(store->ostream!=NULL, FALSE);
g_return_val_if_fail(store->istream!=NULL, FALSE);
-
+
/* Check for current folder */
if (folder && folder != store->current_folder) {
CamelImapResponse *response;
CamelException internal_ex;
-
+
response = camel_imap_command (store, folder, ex, NULL);
if (!response)
return FALSE;
return FALSE;
}
}
-
+
/* Send the command */
if (camel_verbose_debug) {
const char *mask;
-
+
if (!strncmp ("LOGIN \"", cmd, 7))
mask = "LOGIN \"xxx\" xxx";
else if (!strncmp ("LOGIN {", cmd, 7))
mask = "LOGIN xxx xxx";
else
mask = cmd;
-
+
fprintf (stderr, "sending : %c%.5u %s\r\n", store->tag_prefix, store->command, mask);
}
-
+
nwritten = camel_stream_printf (store->ostream, "%c%.5u %s\r\n",
store->tag_prefix, store->command++, cmd);
-
+
if (nwritten == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
else
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
g_strerror (errno));
-
+
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
return FALSE;
}
-
+
return TRUE;
}
* This method is for sending continuing responses to the IMAP server
* after camel_imap_command() or camel_imap_command_response() returns
* a continuation response.
- *
+ *
* This function assumes you have an exclusive lock on the imap stream.
*
* Return value: as for camel_imap_command(). On failure, the store's
g_return_val_if_fail(store->ostream!=NULL, NULL);
g_return_val_if_fail(store->istream!=NULL, NULL);
-
+
if (camel_stream_write (store->ostream, cmd, cmdlen) == -1 ||
camel_stream_write (store->ostream, "\r\n", 2) == -1) {
if (errno == EINTR)
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return NULL;
}
-
+
return imap_read_response (store, ex);
}
{
CamelImapResponseType type;
char *respbuf;
-
+
if (camel_imap_store_readline (store, &respbuf, ex) < 0) {
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return CAMEL_IMAP_RESPONSE_ERROR;
}
-
+
switch (*respbuf) {
case '*':
if (!g_ascii_strncasecmp (respbuf, "* BYE", 5)) {
type = CAMEL_IMAP_RESPONSE_ERROR;
break;
}
-
+
/* Read the rest of the response. */
type = CAMEL_IMAP_RESPONSE_UNTAGGED;
respbuf = imap_read_untagged (store, respbuf, ex);
camel_session_alert_user(((CamelService *)store)->session, CAMEL_SESSION_ALERT_WARNING, msg, FALSE);
g_free(msg);
}
-
+
break;
case '+':
type = CAMEL_IMAP_RESPONSE_CONTINUATION;
break;
}
*response = respbuf;
-
+
if (type == CAMEL_IMAP_RESPONSE_ERROR ||
type == CAMEL_IMAP_RESPONSE_TAGGED)
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
-
+
return type;
}
CamelImapResponse *response;
CamelImapResponseType type;
char *respbuf, *p;
-
+
/* Get another lock so that when we reach the tagged
* response and camel_imap_command_response unlocks,
* we're still locked. This lock is owned by response
* and gets unlocked when response is freed.
*/
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
response = g_new0 (CamelImapResponse, 1);
if (store->current_folder && camel_disco_store_status (CAMEL_DISCO_STORE (store)) != CAMEL_DISCO_STORE_RESYNCING) {
response->folder = store->current_folder;
camel_object_ref (CAMEL_OBJECT (response->folder));
}
-
+
response->untagged = g_ptr_array_new ();
while ((type = camel_imap_command_response (store, &respbuf, ex))
== CAMEL_IMAP_RESPONSE_UNTAGGED)
g_ptr_array_add (response->untagged, respbuf);
-
+
if (type == CAMEL_IMAP_RESPONSE_ERROR) {
camel_imap_response_free_without_processing (store, response);
return NULL;
}
-
+
response->status = respbuf;
-
+
/* Check for OK or continuation response. */
if (*respbuf == '+')
return response;
p = strchr (respbuf, ' ');
if (p && !g_ascii_strncasecmp (p, " OK", 3))
return response;
-
+
/* We should never get BAD, or anything else but +, OK, or NO
* for that matter. Well, we could get BAD, treat as NO.
*/
camel_imap_response_free_without_processing (store, response);
return NULL;
}
-
+
p += 3;
if (!*p++)
p = NULL;
GPtrArray *data;
GString *str;
char *end, *p, *s, *d;
-
+
p = strrchr (line, '{');
if (!p)
return line;
-
+
data = g_ptr_array_new ();
fulllen = 0;
-
+
while (1) {
str = g_string_new (line);
g_free (line);
fulllen += str->len;
g_ptr_array_add (data, str);
-
+
if (!(p = strrchr (str->str, '{')) || p[1] == '-')
break;
-
+
/* HACK ALERT: We scan the non-literal part of the string, looking for possible s expression braces.
This assumes we're getting s-expressions, which we should be.
This is so if we get a blank line after a literal, in an s-expression, we can keep going, since
else if (*s == ')')
sexp--;
}
-
+
length = strtoul (p + 1, &end, 10);
if (*end != '}' || *(end + 1) || end == p + 1 || length >= UINT_MAX - 2)
break;
ldigits = end - (p + 1);
-
+
/* Read the literal */
str = g_string_sized_new (length + 2);
str->str[0] = '\n';
nread = 0;
-
+
do {
if ((n = camel_stream_read (store->istream, str->str + nread + 1, length - nread)) == -1) {
if (errno == EINTR)
g_string_free (str, TRUE);
goto lose;
}
-
+
nread += n;
} while (n > 0 && nread < length);
-
+
if (nread < length) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Server response ended too soon."));
fwrite(str->str+1, 1, length, stdout);
printf("<--\n");
}
-
+
/* Fix up the literal, turning CRLFs into LF. Also, if
* we find any embedded NULs, strip them. This is
* dubious, but:
* - WU-imapd 12.264 (at least) will cheerily pass
* NULs along if they are embedded in the message
*/
-
+
s = d = str->str + 1;
end = str->str + 1 + length;
while (s < end) {
}
*d = '\0';
str->len = length + 1;
-
+
/* p points to the "{" in the line that starts the
* literal. The length of the CR-less response must be
* less than or equal to the length of the response
* GString's length would be off...
*/
sprintf (p, "{%0*u}", ldigits, length);
-
+
fulllen += str->len;
g_ptr_array_add (data, str);
g_warning("Server sent empty line after a literal, assuming in error");
} while (line[0] == 0 && sexp > 0);
}
-
+
/* Now reassemble the data. */
p = line = g_malloc (fulllen + 1);
for (i = 0; i < data->len; i++) {
*p = '\0';
g_ptr_array_free (data, TRUE);
return line;
-
+
lose:
for (i = 0; i < data->len; i++)
g_string_free (data->pdata[i], TRUE);
int i, number, exists = 0;
GArray *expunged = NULL;
char *resp, *p;
-
+
if (!response)
return;
-
+
for (i = 0; i < response->untagged->len; i++) {
resp = response->untagged->pdata[i];
-
+
if (response->folder) {
/* Check if it's something we need to handle. */
number = strtoul (resp + 2, &p, 10);
}
g_free (resp);
}
-
+
g_ptr_array_free (response->untagged, TRUE);
g_free (response->status);
-
+
if (response->folder) {
if (exists > 0 || expunged) {
/* Update the summary */
if (expunged)
g_array_free (expunged, TRUE);
}
-
+
camel_object_unref (CAMEL_OBJECT (response->folder));
}
-
+
g_free (response);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
}
{
if (!response)
return;
-
+
if (response->folder) {
camel_object_unref (CAMEL_OBJECT (response->folder));
response->folder = NULL;
{
int len = strlen (type), i;
char *resp;
-
+
len = strlen (type);
-
+
for (i = 0; i < response->untagged->len; i++) {
resp = response->untagged->pdata[i];
/* Skip "* ", and initial sequence number, if present */
strtoul (resp + 2, &resp, 10);
if (*resp == ' ')
resp = (char *) imap_next_word (resp);
-
+
if (!g_ascii_strncasecmp (resp, type, len))
break;
}
-
+
if (i < response->untagged->len) {
resp = response->untagged->pdata[i];
g_ptr_array_remove_index (response->untagged, i);
_("IMAP server response did not contain "
"%s information"), type);
}
-
+
camel_imap_response_free (store, response);
return resp;
}
CamelException *ex)
{
char *status;
-
+
if (response->status && *response->status == '+') {
status = response->status;
response->status = NULL;
camel_imap_response_free (store, response);
return status;
}
-
+
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Unexpected OK response from IMAP server: %s"),
response->status);
int num, len, i, arglen;
args = g_ptr_array_new ();
-
+
/* Determine the length of the data */
len = strlen (fmt);
p = start = fmt;
p = strchr (start, '%');
if (!p)
break;
-
+
switch (*++p) {
case 'd':
num = va_arg (ap, int);
} else if (*p == 'G') {
string = camel_utf8_utf7(string);
}
-
+
arglen = strlen (string);
g_ptr_array_add (args, string);
if (imap_is_atom (string)) {
break;
}
}
-
+
/* Now write out the string */
outptr = out = g_malloc (len + 1);
p = start = fmt;
strncpy (outptr, start, p - start);
outptr += p - start;
}
-
+
switch (*++p) {
case 'd':
num = GPOINTER_TO_INT (args->pdata[i++]);
outptr += sprintf (outptr, "%d", num);
break;
-
+
case 's':
string = args->pdata[i++];
outptr += sprintf (outptr, "%s", string);
outptr += sprintf (outptr, "{%d+}\r\n%s", len, string);
} else {
char *quoted = imap_quote_string (string);
-
+
outptr += sprintf (outptr, "%s", quoted);
g_free (quoted);
}
}
-
+
if (*p == 'F' || *p == 'G')
g_free (string);
break;
*outptr++ = '%';
*outptr++ = *p;
}
-
+
start = *p ? p + 1 : p;
}
-
+
g_ptr_array_free (args, TRUE);
return out;
{
va_list ap;
char *result;
-
+
va_start (ap, fmt);
result = imap_command_strdup_vprintf (store, fmt, ap);
va_end (ap);
-
+
return result;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-imap-command.h: IMAP command sending/parsing routines */
-/*
+/*
* Authors:
* Dan Winship <danw@ximian.com>
* Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright (C) 2000, 2001 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-imap-folder.c: class for an imap folder */
-/*
+/*
* Authors:
* Dan Winship <danw@ximian.com>
- * Jeffrey Stedfast <fejj@ximian.com>
+ * Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright (C) 2000, 2001 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* USA
*/
-#include <config.h>
+#include <config.h>
#include <ctype.h>
#include <errno.h>
#include "camel-imap-utils.h"
#include "camel-imap-wrapper.h"
-#define d(x)
+#define d(x)
/* set to -1 for infinite size (suggested max command-line length is
* 1000 octets (see rfc2683), so we should keep the uid-set length to
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (object);
CamelFolder *folder = CAMEL_FOLDER (object);
-
+
folder->permanent_flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_DELETED |
CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_SEEN;
-
+
folder->folder_flags |= (CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY |
CAMEL_FOLDER_HAS_SEARCH_CAPABILITY);
-
+
imap_folder->priv = g_malloc0(sizeof(*imap_folder->priv));
#ifdef ENABLE_THREADS
g_static_mutex_init(&imap_folder->priv->search_lock);
camel_imap_folder_get_type (void)
{
static CamelType camel_imap_folder_type = CAMEL_INVALID_TYPE;
-
+
if (camel_imap_folder_type == CAMEL_INVALID_TYPE) {
parent_class = camel_disco_folder_get_type();
camel_imap_folder_type =
(CamelObjectInitFunc) camel_imap_folder_init,
(CamelObjectFinalizeFunc) imap_finalize);
}
-
+
return camel_imap_folder_type;
}
GData *fetch_data;
int i, count;
char *resp;
-
+
count = camel_folder_summary_count (folder->summary);
-
+
for (i = 0; i < response->untagged->len; i++) {
resp = response->untagged->pdata[i] + 2;
if (!g_ascii_strncasecmp (resp, "FLAGS ", 6) && !perm_flags) {
folder->permanent_flags = imap_parse_flag_list (&resp);
} else if (!g_ascii_strncasecmp (resp, "OK [PERMANENTFLAGS ", 19)) {
resp += 19;
-
+
/* workaround for broken IMAP servers that send "* OK [PERMANENTFLAGS ()] Permanent flags"
* even tho they do allow storing flags. *Sigh* So many fucking broken IMAP servers out there. */
if ((perm_flags = imap_parse_flag_list (&resp)) != 0)
validity = strtoul (resp + 16, NULL, 10);
} else if (isdigit ((unsigned char)*resp)) {
unsigned long num = strtoul (resp, &resp, 10);
-
+
if (!g_ascii_strncasecmp (resp, " EXISTS", 7)) {
exists = num;
/* Remove from the response so nothing
_("Folder was destroyed and recreated on server."));
return;
}
-
+
/* FIXME: find missing UIDs ? */
return;
}
-
+
if (!imap_summary->validity)
imap_summary->validity = validity;
else if (validity != imap_summary->validity) {
camel_imap_folder_changed (folder, exists, NULL, ex);
return;
}
-
+
/* If we've lost messages, we have to rescan everything */
if (exists < count)
imap_folder->need_rescan = TRUE;
else if (count != 0 && !imap_folder->need_rescan) {
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
-
+
/* Similarly, if the UID of the highest message we
* know about has changed, then that indicates that
* messages have been both added and removed, so we
}
if (uid != 0 || val != count || g_ascii_strncasecmp (resp, " FETCH (", 8) != 0)
continue;
-
+
fetch_data = parse_fetch_response (imap_folder, resp + 7);
uid = strtoul (g_datalist_get_data (&fetch_data, "UID"), NULL, 10);
g_datalist_clear (&fetch_data);
}
camel_imap_response_free_without_processing (store, response);
-
+
info = camel_folder_summary_index (folder->summary, count - 1);
val = strtoul (camel_message_info_uid (info), NULL, 10);
camel_message_info_free(info);
if (uid == 0 || uid != val)
imap_folder->need_rescan = TRUE;
}
-
+
/* Now rescan if we need to */
if (imap_folder->need_rescan) {
imap_rescan (folder, exists, ex);
return;
}
-
+
/* If we don't need to rescan completely, but new messages
* have been added, find out about them.
*/
if (exists > count)
camel_imap_folder_changed (folder, exists, NULL, ex);
-
+
/* And we're done. */
}
-static void
+static void
imap_finalize (CamelObject *object)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (object);
CamelFolderChangeInfo *changes = NULL;
imap_folder->need_rescan = FALSE;
-
+
summary_len = camel_folder_summary_count (folder->summary);
if (summary_len == 0) {
if (exists)
camel_imap_folder_changed (folder, exists, NULL, ex);
return;
}
-
+
/* Check UIDs and flags of all messages we already know of. */
camel_operation_start (NULL, _("Scanning for changed messages in %s"), folder->name);
info = camel_folder_summary_index (folder->summary, summary_len - 1);
camel_operation_end (NULL);
return;
}
-
+
new = g_malloc0 (summary_len * sizeof (*new));
summary_got = 0;
while ((type = camel_imap_command_response (store, &resp, ex)) == CAMEL_IMAP_RESPONSE_UNTAGGED) {
GData *data;
char *uid;
guint32 flags;
-
+
data = parse_fetch_response (imap_folder, resp);
g_free (resp);
if (!data)
continue;
-
+
seq = GPOINTER_TO_INT (g_datalist_get_data (&data, "SEQUENCE"));
uid = g_datalist_get_data (&data, "UID");
flags = GPOINTER_TO_UINT (g_datalist_get_data (&data, "FLAGS"));
-
+
if (!uid || !seq || seq > summary_len || seq < 0) {
g_datalist_clear (&data);
continue;
}
-
+
camel_operation_progress (NULL, ++summary_got * 100 / summary_len);
new[seq - 1].uid = g_strdup (uid);
new[seq - 1].flags = flags;
g_datalist_clear (&data);
}
-
+
camel_operation_end (NULL);
if (type == CAMEL_IMAP_RESPONSE_ERROR) {
for (i = 0; i < summary_len && new[i].uid; i++)
g_free (new);
return;
}
-
+
/* Free the final tagged response */
g_free (resp);
-
+
/* If we find a UID in the summary that doesn't correspond to
* the UID in the folder, then either: (a) it's a real UID,
* but the message was deleted on the server, or (b) it's a
for (i = 0; i < summary_len && new[i].uid; i++) {
info = camel_folder_summary_index (folder->summary, i);
iinfo = (CamelImapMessageInfo *)info;
-
+
if (strcmp (camel_message_info_uid (info), new[i].uid) != 0) {
camel_message_info_free(info);
seq = i + 1;
summary_len--;
continue;
}
-
+
/* Update summary flags */
if (new[i].flags != iinfo->server_flags) {
guint32 server_set, server_cleared;
-
+
server_set = new[i].flags & ~iinfo->server_flags;
server_cleared = iinfo->server_flags & ~new[i].flags;
camel_object_trigger_event(CAMEL_OBJECT (folder), "folder_changed", changes);
camel_folder_change_info_free(changes);
}
-
+
seq = i + 1;
-
+
/* Free remaining memory. */
while (i < summary_len && new[i].uid)
g_free (new[i++].uid);
g_free (new);
-
+
/* Remove any leftover cached summary messages. (Yes, we
* repeatedly add the same number to the removed array.
* See RFC2060 7.4.1)
CamelImapMessageInfo *info;
int i, max, range;
GString *gset;
-
+
matches = g_ptr_array_new ();
gset = g_string_new ("");
max = camel_folder_summary_count (folder->summary);
}
continue;
}
-
+
g_ptr_array_add (matches, info);
if (range != -1)
continue;
g_string_append_c (gset, ',');
g_string_append_printf (gset, "%s", camel_message_info_uid (info));
}
-
+
if (range != -1 && range != max - 1) {
info = matches->pdata[matches->len - 1];
g_string_append_printf (gset, ":%s", camel_message_info_uid (info));
}
-
+
if (matches->len) {
*set = gset->str;
g_string_free (gset, FALSE);
char *set, *flaglist;
gboolean unset;
int i, j, max;
-
+
if (folder->permanent_flags == 0) {
imap_sync_offline (folder, ex);
return;
}
-
+
camel_exception_init (&local_ex);
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
/* Find a message with changed flags, find all of the other
* messages like it, sync them as a group, mark them as
* updated, and continue.
for (i = 0; i < max; i++) {
if (!(info = (CamelImapMessageInfo *)camel_folder_summary_index (folder->summary, i)))
continue;
-
+
if (!(info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) {
camel_message_info_free((CamelMessageInfo *)info);
continue;
empty-set of flags so... if this is true then we
want to unset the previously set flags.*/
unset = !(info->info.flags & folder->permanent_flags);
-
+
/* Note: get_matching() uses UID_SET_LIMIT to limit
the size of the uid-set string. We don't have to
loop here to flush all the matching uids because
camel_message_info_free(info);
if (matches == NULL)
continue;
-
+
/* Make sure we're connected before issuing commands */
if (!camel_imap_store_connected(store, ex)) {
g_free(set);
/* FIXME: since we don't know the previously set flags,
if unset is TRUE then just unset all the flags? */
flaglist = imap_create_flag_list (unset ? folder->permanent_flags : info->info.flags & folder->permanent_flags);
-
+
/* Note: to `unset' flags, use -FLAGS.SILENT (<flag list>) */
response = camel_imap_command (store, folder, &local_ex,
"UID STORE %s %sFLAGS.SILENT %s",
set, unset ? "-" : "", flaglist);
g_free (set);
g_free (flaglist);
-
+
if (response)
camel_imap_response_free (store, response);
-
+
if (!camel_exception_is_set (&local_ex)) {
for (j = 0; j < matches->len; j++) {
info = matches->pdata[j];
}
camel_folder_summary_touch (folder->summary);
}
-
+
for (j = 0; j < matches->len; j++) {
info = matches->pdata[j];
camel_message_info_free(&info->info);
}
g_ptr_array_free (matches, TRUE);
-
+
/* We unlock here so that other threads can have a chance to grab the connect_lock */
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
-
+
/* check for an exception */
if (camel_exception_is_set (&local_ex)) {
camel_exception_xfer (ex, &local_ex);
return;
}
-
+
/* Re-lock the connect_lock */
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
}
-
+
/* Save the summary */
imap_sync_offline (folder, ex);
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
}
{
CamelFolderChangeInfo *changes;
int i;
-
+
qsort (uids->pdata, uids->len, sizeof (void *), uid_compar);
-
+
changes = camel_folder_change_info_new ();
-
+
for (i = 0; i < uids->len; i++) {
camel_folder_summary_remove_uid (folder->summary, uids->pdata[i]);
camel_folder_change_info_remove_uid (changes, uids->pdata[i]);
CamelImapResponse *response;
int uid = 0;
char *set;
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
if ((store->capabilities & IMAP_CAPABILITY_UIDPLUS) == 0) {
return;
}
}
-
+
qsort (uids->pdata, uids->len, sizeof (void *), uid_compar);
-
+
while (uid < uids->len) {
set = imap_uid_array_to_set (folder->summary, uids, uid, UID_SET_LIMIT, &uid);
response = camel_imap_command (store, folder, ex,
g_free (set);
return;
}
-
+
if (store->capabilities & IMAP_CAPABILITY_UIDPLUS) {
response = camel_imap_command (store, folder, ex,
"UID EXPUNGE %s", set);
} else
response = camel_imap_command (store, folder, ex, "EXPUNGE");
-
+
if (response)
camel_imap_response_free (store, response);
}
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
}
imap_expunge_uids_online (folder, uids, ex);
return;
}
-
+
/* If we don't have UID EXPUNGE we need to avoid expunging any
* of the wrong messages. So we search for deleted messages,
* and any that aren't in our to-expunge list get temporarily
* marked un-deleted.
*/
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
((CamelFolderClass *)CAMEL_OBJECT_GET_CLASS(folder))->sync(folder, 0, ex);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return;
}
-
+
if (result[8] == ' ') {
char *uid, *lasts = NULL;
unsigned long euid, kuid;
int ei, ki;
-
+
keep_uids = g_ptr_array_new ();
mark_uids = g_ptr_array_new ();
-
+
/* Parse SEARCH response */
for (uid = strtok_r (result + 9, " ", &lasts); uid; uid = strtok_r (NULL, " ", &lasts))
g_ptr_array_add (keep_uids, uid);
qsort (keep_uids->pdata, keep_uids->len,
sizeof (void *), uid_compar);
-
+
/* Fill in "mark_uids", empty out "keep_uids" as needed */
for (ei = ki = 0; ei < uids->len; ei++) {
euid = strtoul (uids->pdata[ei], NULL, 10);
-
+
for (kuid = 0; ki < keep_uids->len; ki++) {
kuid = strtoul (keep_uids->pdata[ki], NULL, 10);
-
+
if (kuid >= euid)
break;
}
-
+
if (euid == kuid)
g_ptr_array_remove_index (keep_uids, ki);
else
/* Empty SEARCH result, meaning nothing is marked deleted
* on server.
*/
-
+
keep_uids = NULL;
mark_uids = uids;
}
-
+
/* Unmark messages to be kept */
-
+
if (keep_uids) {
char *uidset;
int uid = 0;
-
+
while (uid < keep_uids->len) {
uidset = imap_uid_array_to_set (folder->summary, keep_uids, uid, UID_SET_LIMIT, &uid);
-
+
response = camel_imap_command (store, folder, ex,
"UID STORE %s -FLAGS.SILENT (\\Deleted)",
uidset);
-
+
g_free (uidset);
-
+
if (!response) {
g_ptr_array_free (keep_uids, TRUE);
g_ptr_array_free (mark_uids, TRUE);
camel_imap_response_free (store, response);
}
}
-
+
/* Mark any messages that still need to be marked */
if (mark_uids) {
char *uidset;
int uid = 0;
-
+
while (uid < mark_uids->len) {
uidset = imap_uid_array_to_set (folder->summary, mark_uids, uid, UID_SET_LIMIT, &uid);
-
+
response = camel_imap_command (store, folder, ex,
"UID STORE %s +FLAGS.SILENT (\\Deleted)",
uidset);
-
+
g_free (uidset);
-
+
if (!response) {
g_ptr_array_free (keep_uids, TRUE);
g_ptr_array_free (mark_uids, TRUE);
if (mark_uids != uids)
g_ptr_array_free (mark_uids, TRUE);
}
-
+
/* Do the actual expunging */
response = camel_imap_command (store, folder, ex, "EXPUNGE");
if (response)
camel_imap_response_free (store, response);
-
+
/* And fix the remaining messages if we mangled them */
if (keep_uids) {
char *uidset;
int uid = 0;
-
+
while (uid < keep_uids->len) {
uidset = imap_uid_array_to_set (folder->summary, keep_uids, uid, UID_SET_LIMIT, &uid);
-
+
/* Don't pass ex if it's already been set */
response = camel_imap_command (store, folder,
camel_exception_is_set (ex) ? NULL : ex,
"UID STORE %s +FLAGS.SILENT (\\Deleted)",
uidset);
-
+
g_free (uidset);
if (response)
camel_imap_response_free (store, response);
}
-
+
g_ptr_array_free (keep_uids, TRUE);
}
/* now we can free this, now that we're done with keep_uids */
g_free (result);
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
}
G_LOCK_DEFINE_STATIC (lock);
G_LOCK (lock);
- res = g_strdup_printf ("tempuid-%lx-%d",
+ res = g_strdup_printf ("tempuid-%lx-%d",
(unsigned long) time (NULL),
counter++);
G_UNLOCK (lock);
GByteArray *ba;
char *flagstr, *end;
guint32 flags = 0;
-
+
/* encode any 8bit parts so we avoid sending embedded nul-chars and such */
camel_mime_message_encode_8bit_parts (message);
-
+
/* FIXME: We could avoid this if we knew how big the message was. */
memstream = camel_stream_mem_new ();
ba = g_byte_array_new ();
camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (memstream), ba);
-
+
streamfilter = camel_stream_filter_new_with_stream (memstream);
crlf_filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE,
CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
flagstr = imap_create_flag_list (flags);
else
flagstr = NULL;
-
+
response = camel_imap_command (store, NULL, ex, "APPEND %F%s%s {%d}",
folder->full_name, flagstr ? " " : "",
flagstr ? flagstr : "", ba->len);
g_free (flagstr);
-
+
if (!response) {
if (camel_exception_get_id(ex) == CAMEL_EXCEPTION_SERVICE_INVALID && !store->nocustomappend) {
camel_exception_clear(ex);
g_byte_array_free (ba, TRUE);
return NULL;
}
-
+
/* send the rest of our data - the mime message */
response2 = camel_imap_command_continuation (store, (const char *) ba->data, ba->len, ex);
g_byte_array_free (ba, TRUE);
camel_imap_response_free (store, response);
if (!response2)
return response2;
-
+
if (store->capabilities & IMAP_CAPABILITY_UIDPLUS) {
*uid = camel_strstrcase (response2->status, "[APPENDUID ");
if (*uid)
}
} else
*uid = NULL;
-
+
return response2;
}
response = do_append (folder, message, info, &uid, ex);
if (!response)
return;
-
+
if (uid) {
/* Cache first, since freeing response may trigger a
* summary update that will want this information.
g_free (uid);
} else if (appended_uid)
*appended_uid = NULL;
-
+
camel_imap_response_free (store, response);
-
+
/* Make sure a "folder_changed" is emitted. */
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
if (store->current_folder != folder ||
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
CamelImapResponse *response;
char *uid;
-
+
response = do_append (folder, message, info, &uid, ex);
if (!response)
return;
-
+
if (uid) {
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
const char *olduid = camel_message_info_uid (info);
-
+
CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
camel_imap_message_cache_copy (imap_folder->cache, olduid,
imap_folder->cache, uid, ex);
g_free (uid);
} else if (appended_uid)
*appended_uid = NULL;
-
+
camel_imap_response_free (store, response);
}
CamelImapResponse *response;
char *uidset;
int uid = 0, last=0, i;
-
+
while (uid < uids->len && !camel_exception_is_set (ex)) {
uidset = imap_uid_array_to_set (source->summary, uids, uid, UID_SET_LIMIT, &uid);
return;
count = camel_folder_summary_count (dest->summary);
-
+
qsort (uids->pdata, uids->len, sizeof (void *), uid_compar);
-
+
/* Now copy the messages */
do_copy(source, uids, dest, delete_originals, ex);
if (camel_exception_is_set (ex))
if (store->current_folder != dest ||
camel_folder_summary_count (dest->summary) == count)
camel_folder_refresh_info (dest, ex);
-
+
/* FIXME */
if (transferred_uids)
*transferred_uids = NULL;
const char *uid;
CamelMimeMessage *message;
CamelMessageInfo *info;
-
+
qsort (uids->pdata, uids->len, sizeof (void *), uid_compar);
-
+
/* This is trickier than append_resyncing, because some of
* the messages we are copying may have been copied or
* appended into @source while we were offline, in which case
part_spec_push (struct _part_spec_stack **stack, int part)
{
struct _part_spec_stack *node;
-
+
node = g_new (struct _part_spec_stack, 1);
node->parent = *stack;
node->part = part;
-
+
*stack = node;
}
{
struct _part_spec_stack *node;
int part;
-
+
g_return_val_if_fail (*stack != NULL, 0);
-
+
node = *stack;
*stack = node->parent;
-
+
part = node->part;
g_free (node);
-
+
return part;
}
char *part_spec, *buf;
size_t len = 1;
int part;
-
+
node = ci;
while (node->parent) {
CamelMessageContentInfo *child;
-
+
/* FIXME: is this only supposed to apply if 'node' is a multipart? */
if (node->parent->parent &&
camel_content_type_is (node->parent->type, "message", "*") &&
node = node->parent;
continue;
}
-
+
child = node->parent->childs;
for (part = 1; child; part++) {
if (child == node)
break;
-
+
child = child->next;
}
-
+
part_spec_push (&stack, part);
-
+
len += 2;
while ((part = part / 10))
len++;
-
+
node = node->parent;
}
-
+
buf = part_spec = g_malloc (len);
part_spec[0] = '\0';
-
+
while (stack) {
part = part_spec_pop (&stack);
buf += sprintf (buf, "%d%s", part, stack ? "." : "");
}
-
+
return part_spec;
}
CamelDataWrapper *content = NULL;
CamelStream *stream;
char *part_spec;
-
+
part_spec = content_info_get_part_spec (ci);
d(printf("get content '%s' '%s' (frommsg = %d)\n", part_spec, camel_content_type_format(ci->type), frommsg));
CamelMultipartSigned *body_mp;
char *spec;
int ret;
-
+
/* Note: because we get the content parts uninterpreted anyway, we could potentially
just use the normalmultipart code, except that multipart/signed wont let you yet! */
-
+
body_mp = camel_multipart_signed_new ();
/* need to set this so it grabs the boundary and other info about the signed type */
/* we assume that part->content_type is more accurate/full than ci->type */
camel_data_wrapper_set_mime_type_field (CAMEL_DATA_WRAPPER (body_mp), CAMEL_DATA_WRAPPER (part)->mime_type);
-
+
spec = g_alloca(strlen(part_spec) + 6);
if (frommsg)
sprintf(spec, part_spec[0] ? "%s.TEXT" : "TEXT", part_spec);
else
strcpy(spec, part_spec);
g_free(part_spec);
-
+
stream = camel_imap_folder_fetch_data (imap_folder, uid, spec, FALSE, ex);
if (stream) {
ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (body_mp), stream);
return NULL;
}
}
-
+
return (CamelDataWrapper *) body_mp;
} else if (camel_content_type_is (ci->type, "multipart", "*")) {
CamelMultipart *body_mp;
char *child_spec;
int speclen, num, isdigest;
-
+
if (camel_content_type_is (ci->type, "multipart", "encrypted"))
body_mp = (CamelMultipart *) camel_multipart_encrypted_new ();
else
body_mp = camel_multipart_new ();
-
+
/* need to set this so it grabs the boundary and other info about the multipart */
/* we assume that part->content_type is more accurate/full than ci->type */
camel_data_wrapper_set_mime_type_field (CAMEL_DATA_WRAPPER (body_mp), CAMEL_DATA_WRAPPER (part)->mime_type);
isdigest = camel_content_type_is(((CamelDataWrapper *)part)->mime_type, "multipart", "digest");
-
+
speclen = strlen (part_spec);
child_spec = g_malloc (speclen + 17); /* dot + 10 + dot + MIME + nul */
memcpy (child_spec, part_spec, speclen);
if (speclen > 0)
child_spec[speclen++] = '.';
g_free (part_spec);
-
+
ci = ci->childs;
num = 1;
while (ci) {
stream = camel_imap_folder_fetch_data (imap_folder, uid, child_spec, FALSE, ex);
if (stream) {
int ret;
-
+
part = camel_mime_part_new ();
ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (part), stream);
camel_object_unref (CAMEL_OBJECT (stream));
g_free (child_spec);
return NULL;
}
-
+
content = get_content (imap_folder, uid, part, ci, FALSE, ex);
}
-
+
if (!stream || !content) {
camel_object_unref (CAMEL_OBJECT (body_mp));
g_free (child_spec);
camel_multipart_add_part (body_mp, part);
camel_object_unref(part);
-
+
ci = ci->next;
}
-
+
g_free (child_spec);
-
+
return (CamelDataWrapper *) body_mp;
} else if (camel_content_type_is (ci->type, "message", "rfc822")) {
content = (CamelDataWrapper *) get_message (imap_folder, uid, ci->childs, ex);
camel_object_unref (CAMEL_OBJECT (msg));
return NULL;
}
-
+
content = get_content (imap_folder, uid, CAMEL_MIME_PART (msg), ci, TRUE, ex);
if (!content) {
camel_object_unref (CAMEL_OBJECT (msg));
camel_data_wrapper_set_mime_type_field(content, camel_mime_part_get_content_type((CamelMimePart *)msg));
camel_medium_set_content_object (CAMEL_MEDIUM (msg), content);
camel_object_unref (CAMEL_OBJECT (content));
-
+
return msg;
}
{
CamelMimeMessage *msg;
int ret;
-
+
if (!stream) {
stream = camel_imap_folder_fetch_data (imap_folder, uid, "",
FALSE, ex);
{
if (!ci->type)
return TRUE;
-
+
if (camel_content_type_is (ci->type, "multipart", "*")
|| camel_content_type_is (ci->type, "message", "rfc822")) {
if (!ci->childs)
GData *fetch_data = NULL;
char *body, *found_uid;
int i;
-
+
CAMEL_SERVICE_REC_LOCK(store, connect_lock);
if (!camel_imap_store_connected(store, ex)) {
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
_("This message is not currently available"));
goto fail;
}
-
+
response = camel_imap_command (store, folder, ex, "UID FETCH %s BODY", uid);
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
body = NULL;
}
}
-
+
if (body) {
/* NB: small race here, setting the info.content */
imap_parse_body ((const char **) &body, folder, mi->info.content);
if (fetch_data)
g_datalist_clear (&fetch_data);
-
+
camel_imap_response_free (store, response);
} else {
camel_exception_clear(ex);
camel_message_info_dump((CamelMessageInfo *)mi);
camel_debug_end();
}
-
+
/* FETCH returned OK, but we didn't parse a BODY
* response. Courier will return invalid BODY
* responses for invalidly MIMEd messages, so
camel_medium_set_header (CAMEL_MEDIUM (msg), "X-Evolution-Source", store->base_url);
fail:
camel_message_info_free(&mi->info);
-
+
return msg;
}
{
register const unsigned char *inptr;
int *val, colons = 0;
-
+
*hour = *min = *sec = 0;
-
+
val = hour;
for (inptr = *in; *inptr && !isspace ((int) *inptr); inptr++) {
if (*inptr == ':') {
else
*val = (*val * 10) + (*inptr - '0');
}
-
+
*in = inptr;
-
+
return TRUE;
}
unsigned char *buf;
struct tm tm;
time_t date;
-
+
memset ((void *) &tm, 0, sizeof (struct tm));
-
+
tm.tm_mday = strtoul ((char *) inptr, (char **) &buf, 10);
if (buf == inptr || *buf != '-')
return (time_t) -1;
-
+
inptr = buf + 1;
if (inptr[3] != '-')
return (time_t) -1;
-
+
for (n = 0; n < 12; n++) {
if (!g_ascii_strncasecmp ((gchar *) inptr, tm_months[n], 3))
break;
}
-
+
if (n >= 12)
return (time_t) -1;
-
+
tm.tm_mon = n;
-
+
inptr += 4;
-
+
n = strtoul ((char *) inptr, (char **) &buf, 10);
if (buf == inptr || *buf != ' ')
return (time_t) -1;
-
+
tm.tm_year = n - 1900;
-
+
inptr = buf + 1;
if (!decode_time (&inptr, &hour, &min, &sec))
return (time_t) -1;
-
+
tm.tm_hour = hour;
tm.tm_min = min;
tm.tm_sec = sec;
-
+
n = strtol ((char *) inptr, NULL, 10);
-
+
date = e_mktime_utc (&tm);
-
+
/* date is now GMT of the time we want, but not offset by the timezone ... */
-
+
/* this should convert the time to the GMT equiv time */
date -= ((n / 100) * 60 * 60) + (n % 100) * 60;
-
+
return date;
}
CamelImapMessageInfo *mi;
const char *idate;
int seq;
-
+
seq = GPOINTER_TO_INT (g_datalist_get_data (&data, "SEQUENCE"));
if (seq < first)
return;
stream = g_datalist_get_data (&data, "BODY_PART_STREAM");
if (!stream)
return;
-
+
if (seq - first >= messages->len)
g_ptr_array_set_size (messages, seq - first + 1);
-
+
msg = camel_mime_message_new ();
if (camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream) == -1) {
camel_object_unref (CAMEL_OBJECT (msg));
return;
}
-
+
mi = (CamelImapMessageInfo *)camel_folder_summary_info_new_from_message (folder->summary, msg);
camel_object_unref (CAMEL_OBJECT (msg));
-
+
if ((idate = g_datalist_get_data (&data, "INTERNALDATE")))
mi->info.date_received = decode_internaldate ((const unsigned char *) idate);
-
+
if (mi->info.date_received == -1)
mi->info.date_received = mi->info.date_sent;
-
+
messages->pdata[seq - first] = mi;
}
CamelStream *stream;
char *uid, *resp;
GData *data;
-
+
if (store->server_level >= IMAP_LEVEL_IMAP4REV1) {
if (store->headers == IMAP_FETCH_ALL_HEADERS)
header_spec = g_string_new ("HEADER");
header_spec = g_string_new ("0");
d(printf("Header is : %s", header_spec->str));
-
+
/* Figure out if any of the new messages are already cached (which
* may be the case if we're re-syncing after disconnected operation).
* If so, get their UIDs, FLAGS, and SIZEs. If not, get all that
camel_message_info_free(&mi->info);
} else
uidval = 0;
-
+
size = (exists - seq) * (IMAP_PRETEND_SIZEOF_FLAGS + IMAP_PRETEND_SIZEOF_SIZE + IMAP_PRETEND_SIZEOF_HEADERS);
got = 0;
if (!camel_imap_command_start (store, folder, ex,
return;
}
camel_operation_start (NULL, _("Fetching summary information for new messages in %s"), folder->name);
-
+
/* Parse the responses. We can't add a message to the summary
* until we've gotten its headers, and there's no guarantee
* the server will send the responses in a useful order...
g_free (resp);
if (!data)
continue;
-
+
seq = GPOINTER_TO_INT (g_datalist_get_data (&data, "SEQUENCE"));
if (seq < first) {
g_datalist_clear (&data);
continue;
}
-
+
if (g_datalist_get_data (&data, "FLAGS"))
got += IMAP_PRETEND_SIZEOF_FLAGS;
if (g_datalist_get_data (&data, "RFC822.SIZE"))
stream = g_datalist_get_data (&data, "BODY_PART_STREAM");
if (stream) {
got += IMAP_PRETEND_SIZEOF_HEADERS;
-
+
/* Use the stream now so we don't tie up many
* many fds if we're fetching many many messages.
*/
add_message_from_data (folder, messages, first, data);
g_datalist_set_data (&data, "BODY_PART_STREAM", NULL);
}
-
+
camel_operation_progress (NULL, got * 100 / size);
g_ptr_array_add (fetch_data, data);
}
camel_operation_end (NULL);
-
+
if (type == CAMEL_IMAP_RESPONSE_ERROR)
goto lose;
-
+
/* Free the final tagged response */
g_free (resp);
-
+
/* Figure out which headers we still need to fetch. */
needheaders = g_ptr_array_new ();
size = got = 0;
data = fetch_data->pdata[i];
if (g_datalist_get_data (&data, "BODY_PART_LEN"))
continue;
-
+
uid = g_datalist_get_data (&data, "UID");
if (uid) {
g_ptr_array_add (needheaders, uid);
size += IMAP_PRETEND_SIZEOF_HEADERS;
}
}
-
+
/* And fetch them */
if (needheaders->len) {
char *uidset;
int uid = 0;
-
+
qsort (needheaders->pdata, needheaders->len,
sizeof (void *), uid_compar);
-
+
camel_operation_start (NULL, _("Fetching summary information for new messages in %s"), folder->name);
-
+
while (uid < needheaders->len) {
uidset = imap_uid_array_to_set (folder->summary, needheaders, uid, UID_SET_LIMIT, &uid);
if (!camel_imap_command_start (store, folder, ex,
goto lose;
}
g_free (uidset);
-
+
while ((type = camel_imap_command_response (store, &resp, ex))
== CAMEL_IMAP_RESPONSE_UNTAGGED) {
data = parse_fetch_response (imap_folder, resp);
g_free (resp);
if (!data)
continue;
-
+
stream = g_datalist_get_data (&data, "BODY_PART_STREAM");
if (stream) {
add_message_from_data (folder, messages, first, data);
}
g_datalist_clear (&data);
}
-
+
if (type == CAMEL_IMAP_RESPONSE_ERROR) {
g_ptr_array_free (needheaders, TRUE);
camel_operation_end (NULL);
goto lose;
}
}
- g_string_free (header_spec, TRUE);
+ g_string_free (header_spec, TRUE);
g_ptr_array_free (needheaders, TRUE);
camel_operation_end (NULL);
}
-
+
/* Now finish up summary entries (fix UIDs, set flags and size) */
for (i = 0; i < fetch_data->len; i++) {
data = fetch_data->pdata[i];
-
+
seq = GPOINTER_TO_INT (g_datalist_get_data (&data, "SEQUENCE"));
if (seq >= first + messages->len) {
g_datalist_clear (&data);
continue;
}
-
+
mi = messages->pdata[seq - first];
if (mi == NULL) {
CamelMessageInfo *pmi = NULL;
int j;
-
+
/* This is a kludge around a bug in Exchange
* 5.5 that sometimes claims multiple messages
* have the same UID. See bug #17694 for
* will have a clone in his/her message-list,
* but at least we don't crash.
*/
-
+
/* find the previous valid message info */
for (j = seq - first - 1; j >= 0; j--) {
pmi = messages->pdata[j];
if (pmi != NULL)
break;
}
-
+
if (pmi == NULL) {
/* Server response is *really* fucked up,
I guess we just pretend it never happened? */
continue;
}
-
+
mi = (CamelImapMessageInfo *)camel_message_info_clone(pmi);
}
-
+
uid = g_datalist_get_data (&data, "UID");
if (uid)
mi->info.uid = g_strdup (uid);
size = GPOINTER_TO_INT (g_datalist_get_data (&data, "RFC822.SIZE"));
if (size)
mi->info.size = size;
-
+
g_datalist_clear (&data);
}
g_ptr_array_free (fetch_data, TRUE);
-
+
/* And add the entries to the summary, etc. */
for (i = 0; i < messages->len; i++) {
mi = messages->pdata[i];
if (folder->summary->messages->pdata[seq] == info)
break;
}
-
+
g_warning("Message already present? %s", camel_message_info_uid(mi));
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Unexpected server response: Identical UIDs provided for messages %d and %d"),
seq + 1, i + first);
-
+
camel_message_info_free(&info->info);
break;
}
-
+
camel_folder_summary_add (folder->summary, (CamelMessageInfo *)mi);
camel_folder_change_info_add_uid (changes, camel_message_info_uid (mi));
-
+
if ((mi->info.flags & CAMEL_IMAP_MESSAGE_RECENT))
camel_folder_change_info_recent_uid(changes, camel_message_info_uid (mi));
}
if ((mi = messages->pdata[i]))
camel_message_info_free(&mi->info);
}
-
+
g_ptr_array_free (messages, TRUE);
-
+
return;
-
+
lose:
if (fetch_data) {
for (i = 0; i < fetch_data->len; i++) {
CamelFolderChangeInfo *changes;
CamelMessageInfo *info;
int len;
-
+
changes = camel_folder_change_info_new ();
if (expunged) {
int i, id;
-
+
for (i = 0; i < expunged->len; i++) {
id = g_array_index (expunged, int, i);
info = camel_folder_summary_index (folder->summary, id - 1);
/* I guess a message that we never retrieved got expunged? */
continue;
}
-
+
camel_folder_change_info_remove_uid (changes, camel_message_info_uid (info));
CAMEL_IMAP_FOLDER_REC_LOCK (imap_folder, cache_lock);
camel_imap_message_cache_remove (imap_folder->cache, camel_message_info_uid (info));
camel_message_info_free(info);
}
}
-
+
len = camel_folder_summary_count (folder->summary);
if (exists > len)
imap_update_summary (folder, exists, changes, ex);
-
+
if (camel_folder_change_info_changed (changes))
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes);
-
+
camel_folder_change_info_free (changes);
camel_folder_summary_save (folder->summary);
}
GData *fetch_data;
char *found_uid;
int i;
-
+
/* EXPUNGE responses have to modify the cache, which means
* they have to grab the cache_lock while holding the
* connect_lock.
stream = camel_imap_message_cache_get (imap_folder->cache, uid, "", ex);
}
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
-
+
if (stream || cache_only)
return stream;
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return NULL;
}
-
+
camel_exception_clear (ex);
if (store->server_level < IMAP_LEVEL_IMAP4REV1 && !*section_text) {
response = camel_imap_command (store, folder, ex,
}
/* We won't need the connect_lock again after this. */
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
-
+
if (!response) {
CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
return NULL;
}
-
+
for (i = 0; i < response->untagged->len; i++) {
fetch_data = parse_fetch_response (imap_folder, response->untagged->pdata[i]);
found_uid = g_datalist_get_data (&fetch_data, "UID");
stream = g_datalist_get_data (&fetch_data, "BODY_PART_STREAM");
if (found_uid && stream && !strcmp (uid, found_uid))
break;
-
+
g_datalist_clear (&fetch_data);
stream = NULL;
}
camel_object_ref (CAMEL_OBJECT (stream));
g_datalist_clear (&fetch_data);
}
-
+
return stream;
}
char *start, *part_spec = NULL, *body = NULL, *uid = NULL, *idate = NULL;
gboolean cache_header = TRUE, header = FALSE;
size_t body_len = 0;
-
+
if (*response != '(') {
long seq;
-
+
if (*response != '*' || *(response + 1) != ' ')
return NULL;
seq = strtoul (response + 2, &response, 10);
if (g_ascii_strncasecmp (response, " FETCH (", 8) != 0)
return NULL;
response += 7;
-
+
g_datalist_set_data (&data, "SEQUENCE", GINT_TO_POINTER (seq));
}
-
+
do {
/* Skip the initial '(' or the ' ' between elements */
response++;
-
+
if (!g_ascii_strncasecmp (response, "FLAGS ", 6)) {
guint32 flags;
-
+
response += 6;
/* FIXME user flags */
flags = imap_parse_flag_list (&response);
-
+
g_datalist_set_data (&data, "FLAGS", GUINT_TO_POINTER (flags));
} else if (!g_ascii_strncasecmp (response, "RFC822.SIZE ", 12)) {
unsigned long size;
-
+
response += 12;
size = strtoul (response, &response, 10);
g_datalist_set_data (&data, "RFC822.SIZE", GUINT_TO_POINTER (size));
} else if (!g_ascii_strncasecmp (response, "BODY[", 5) ||
!g_ascii_strncasecmp (response, "RFC822 ", 7)) {
char *p;
-
+
if (*response == 'B') {
response += 5;
-
+
/* HEADER], HEADER.FIELDS (...)], or 0] */
if (!g_ascii_strncasecmp (response, "HEADER", 6)) {
header = TRUE;
cache_header = FALSE;
} else if (!g_ascii_strncasecmp (response, "0]", 2))
header = TRUE;
-
+
p = strchr (response, ']');
if (!p || *(p + 1) != ' ')
break;
-
+
if (cache_header)
part_spec = g_strndup (response, p - response);
else
part_spec = g_strdup ("HEADER.FIELDS");
-
+
response = p + 2;
} else {
part_spec = g_strdup ("");
response += 7;
-
+
if (!g_ascii_strncasecmp (response, "HEADER", 6))
header = TRUE;
}
-
+
body = imap_parse_nstring ((const char **) &response, &body_len);
if (!response) {
g_free (part_spec);
break;
}
-
+
if (!body)
body = g_strdup ("");
g_datalist_set_data_full (&data, "BODY_PART_SPEC", part_spec, g_free);
}
} else if (!g_ascii_strncasecmp (response, "UID ", 4)) {
int len;
-
+
len = strcspn (response + 4, " )");
uid = g_strndup (response + 4, len);
g_datalist_set_data_full (&data, "UID", uid, g_free);
response += 4 + len;
} else if (!g_ascii_strncasecmp (response, "INTERNALDATE ", 13)) {
int len;
-
+
response += 13;
if (*response == '"') {
response++;
break;
}
} while (response && *response != ')');
-
+
if (!response || *response != ')') {
g_datalist_clear (&data);
return NULL;
}
-
+
if (uid && body) {
CamelStream *stream;
-
+
if (header && !cache_header) {
stream = camel_stream_mem_new_with_buffer (body, body_len);
} else {
if (stream == NULL)
stream = camel_stream_mem_new_with_buffer (body, body_len);
}
-
+
if (stream)
g_datalist_set_data_full (&data, "BODY_PART_STREAM", stream,
(GDestroyNotify) camel_object_unref);
}
-
+
return data;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-imap-folder.h: class for an imap folder */
-/*
+/*
* Authors:
* Dan Winship <danw@ximian.com>
- * Jeffrey Stedfast <fejj@ximian.com>
+ * Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright (C) 2000, 2001 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
CamelDiscoFolder parent_object;
struct _CamelImapFolderPrivate *priv;
-
+
CamelFolderSearch *search;
CamelImapMessageCache *cache;
typedef struct {
CamelDiscoFolderClass parent_class;
- /* Virtual methods */
-
+ /* Virtual methods */
+
} CamelImapFolderClass;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-imap-message-cache.c: Class for an IMAP message cache */
-/*
- * Author:
+/*
+ * Author:
* Dan Winship <danw@ximian.com>
*
* Copyright (C) 2001 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
camel_imap_message_cache_get_type (void)
{
static CamelType camel_imap_message_cache_type = CAMEL_INVALID_TYPE;
-
+
if (camel_imap_message_cache_type == CAMEL_INVALID_TYPE) {
camel_imap_message_cache_type = camel_type_register (
CAMEL_OBJECT_TYPE, "CamelImapMessageCache",
/**
* camel_imap_message_cache_set_path:
- * @cache:
- * @path:
- *
+ * @cache:
+ * @path:
+ *
* Set the path used for the message cache.
**/
void
{
CamelStream *stream;
int fd;
-
+
#ifdef G_OS_WIN32
/* Trailing periods in file names are silently dropped on
* Win32, argh. The code in this file requires the period to
stream = g_hash_table_lookup (cache->parts, *key);
if (stream)
camel_object_unref (CAMEL_OBJECT (stream));
-
+
fd = g_open (*path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
if (fd == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
g_free (*path);
return NULL;
}
-
+
return camel_stream_fs_new_with_fd (fd);
}
{
char *path, *key;
CamelStream *stream;
-
+
stream = insert_setup (cache, uid, part_spec, &path, &key, ex);
if (!stream)
return NULL;
-
+
if (camel_stream_write (stream, data, len) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to cache message %s: %s"),
uid, g_strerror (errno));
return insert_abort (path, stream);
}
-
+
return insert_finish (cache, uid, path, key, stream);
}
{
char *path, *key;
CamelStream *stream;
-
+
stream = insert_setup (cache, uid, part_spec, &path, &key, ex);
if (!stream)
return;
-
+
if (camel_stream_write_to_stream (data_stream, stream) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to cache message %s: %s"),
stream = insert_setup (cache, uid, part_spec, &path, &key, ex);
if (!stream)
return;
-
+
if (camel_data_wrapper_write_to_stream (wrapper, stream) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to cache message %s: %s"),
{
CamelStream *stream;
char *path, *key;
-
+
if (uid[0] == 0)
return NULL;
-
+
#ifdef G_OS_WIN32
/* See comment in insert_setup() */
if (!*part_spec)
g_free (path);
return stream;
}
-
+
stream = camel_stream_fs_new_with_name (path, O_RDONLY, 0);
if (stream) {
cache_put (cache, uid, key, stream);
_("Failed to cache %s: %s"),
part_spec, g_strerror (errno));
}
-
+
g_free (path);
-
+
return stream;
}
CamelStream *stream;
char *part;
int i;
-
+
subparts = g_hash_table_lookup (source->parts, source_uid);
if (!subparts || !subparts->len)
return;
-
+
for (i = 0; i < subparts->len; i++) {
part = strchr (subparts->pdata[i], '.');
if (!part++)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-imap-message-cache.h: Class for an IMAP message cache */
-/*
- * Author:
+/*
+ * Author:
* Dan Winship <danw@ximian.com>
*
* Copyright (C) 2001 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct {
CamelFolderClass parent_class;
- /* Virtual methods */
-
+ /* Virtual methods */
+
} CamelImapMessageCacheClass;
CamelServiceAuthType camel_imap_password_authtype = {
N_("Password"),
-
+
N_("This option will connect to the IMAP server using a "
"plaintext password."),
-
+
"",
TRUE
};
add_hash (&hash, u->authmech);
add_hash (&hash, u->host);
hash ^= u->port;
-
+
return hash;
}
else
return FALSE;
}
-
+
if (s2 == NULL)
return FALSE;
-
+
return strcmp (s1, s2) == 0;
}
imap_url_equal (gconstpointer a, gconstpointer b)
{
const CamelURL *u1 = a, *u2 = b;
-
+
return check_equal (u1->protocol, u2->protocol)
&& check_equal (u1->user, u2->user)
&& check_equal (u1->authmech, u2->authmech)
CAMEL_FOLDER_SEARCH_CLASS (camel_imap_search_class);
imap_search_parent_class = (CamelFolderSearchClass *)camel_type_get_global_classfuncs (camel_folder_search_get_type ());
-
+
/* virtual method overload */
camel_folder_search_class->body_contains = imap_body_contains;
}
camel_imap_search_get_type (void)
{
static CamelType camel_imap_search_type = CAMEL_INVALID_TYPE;
-
+
if (camel_imap_search_type == CAMEL_INVALID_TYPE) {
camel_imap_search_type = camel_type_register (
CAMEL_FOLDER_SEARCH_TYPE, "CamelImapSearch",
return -1;
d(printf("Saving search cache entry to '%s': %s\n", mr->hash, mr->terms[0]));
-
+
/* we write the whole thing, then re-write the header magic, saves fancy sync code */
memcpy(&header.mark, " ", 4);
header.termcount = 0;
struct _camel_search_words *words;
GString *search;
int i;
-
+
if (mr->lastuid >= is->lastuid && mr->validity == is->validity)
return 0;
-
+
d(printf ("updating match record for uid's %d:%d\n", mr->lastuid+1, is->lastuid));
-
+
/* TODO: Handle multiple search terms */
-
+
/* This handles multiple search words within a single term */
words = camel_search_words_split (mr->terms[0]);
search = g_string_new ("");
g_string_append_printf (search, "UID %d:%d", mr->lastuid + 1, is->lastuid);
for (i = 0; i < words->len; i++) {
char *w = words->words[i]->word, c;
-
+
g_string_append_printf (search, " BODY \"");
while ((c = *w++)) {
if (c == '\\' || c == '"')
g_string_append_c (search, '"');
}
camel_search_words_free (words);
-
+
/* We only try search using utf8 if its non us-ascii text? */
if ((words->type & CAMEL_SEARCH_WORD_8BIT) && (store->capabilities & IMAP_CAPABILITY_utf8_search)) {
response = camel_imap_command (store, folder, NULL,
result = camel_imap_response_extract (store, response, "SEARCH", NULL);
if (!result)
return -1;
-
+
p = result + sizeof ("* SEARCH");
for (p = strtok_r (p, " ", &lasts); p; p = strtok_r (NULL, " ", &lasts)) {
uid = strtoul(p, NULL, 10);
CamelImapSearch *is = (CamelImapSearch *)s;
char *uid;
ESExpResult *r;
- CamelMessageInfo *info;
+ CamelMessageInfo *info;
GHashTable *uid_hash = NULL;
GPtrArray *array;
int i, j;
camel_imap_store_summary_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
camel_imap_store_summary_parent = (CamelStoreSummaryClass *)camel_store_summary_get_type();
type = camel_type_register((CamelType)camel_imap_store_summary_parent, "CamelImapStoreSummary",
(CamelObjectInitFunc) camel_imap_store_summary_init,
(CamelObjectFinalizeFunc) camel_imap_store_summary_finalise);
}
-
+
return type;
}
* camel_imap_store_summary_new:
*
* Create a new CamelImapStoreSummary object.
- *
+ *
* Return value: A new CamelImapStoreSummary widget.
**/
CamelImapStoreSummary *
/**
* camel_imap_store_summary_full_name:
- * @s:
- * @path:
- *
+ * @s:
+ * @path:
+ *
* Retrieve a summary item by full name.
*
* A referenced to the summary item is returned, which may be
* ref'd or free'd as appropriate.
- *
+ *
* Return value: The summary item, or NULL if the @full_name name
* is not available.
* It must be freed using camel_store_summary_info_free().
} else {
if (full_name[len] == ns->sep)
len++;
-
+
prefix = camel_imap_store_summary_full_to_path(s, full_name+len, ns->sep);
if (*ns->path) {
pathu8 = g_strdup_printf ("%s/%s", ns->path, prefix);
if (camel_imap_store_summary_parent->summary_header_save((CamelStoreSummary *)s, out) == -1
|| camel_file_util_encode_fixed_int32(out, CAMEL_IMAP_STORE_SUMMARY_VERSION) == -1
|| camel_file_util_encode_fixed_int32(out, is->capabilities) == -1
- || camel_file_util_encode_fixed_int32(out, count) == -1)
+ || camel_file_util_encode_fixed_int32(out, count) == -1)
return -1;
if (is->namespace && namespace_save(s, out, is->namespace) == -1)
#include "camel-imap-summary.h"
#include "camel-imap-utils.h"
-#define d(x)
+#define d(x)
/* Specified in RFC 2060 */
#define IMAP_PORT "143"
CAMEL_STORE_CLASS (camel_imap_store_class);
CamelDiscoStoreClass *camel_disco_store_class =
CAMEL_DISCO_STORE_CLASS (camel_imap_store_class);
-
+
parent_class = CAMEL_DISCO_STORE_CLASS (camel_type_get_global_classfuncs (camel_disco_store_get_type ()));
-
+
/* virtual method overload */
camel_object_class->setv = imap_setv;
camel_object_class->getv = imap_getv;
-
+
camel_service_class->construct = construct;
camel_service_class->query_auth_types = query_auth_types;
camel_service_class->get_name = imap_get_name;
-
+
camel_store_class->hash_folder_name = hash_folder_name;
camel_store_class->compare_folder_name = compare_folder_name;
camel_store_class->create_folder = create_folder;
camel_store_class->noop = imap_noop;
camel_store_class->get_trash = imap_get_trash;
camel_store_class->get_junk = imap_get_junk;
-
+
camel_disco_store_class->can_work_offline = can_work_offline;
camel_disco_store_class->connect_online = imap_connect_online;
camel_disco_store_class->connect_offline = imap_connect_offline;
camel_store_summary_save((CamelStoreSummary *)imap_store->summary);
camel_object_unref(imap_store->summary);
}
-
+
if (imap_store->base_url)
g_free (imap_store->base_url);
if (imap_store->storage_path)
camel_imap_store_init (gpointer object, gpointer klass)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (object);
-
+
imap_store->istream = NULL;
imap_store->ostream = NULL;
-
+
imap_store->dir_sep = '\0';
imap_store->current_folder = NULL;
imap_store->connected = FALSE;
camel_imap_store_get_type (void)
{
static CamelType camel_imap_store_type = CAMEL_INVALID_TYPE;
-
+
if (camel_imap_store_type == CAMEL_INVALID_TYPE) {
camel_imap_store_type =
camel_type_register (CAMEL_DISCO_STORE_TYPE,
(CamelObjectInitFunc) camel_imap_store_init,
(CamelObjectFinalizeFunc) camel_imap_store_finalize);
}
-
+
return camel_imap_store_type;
}
imap_store->dir_sep = is->namespace->sep;
}
}
-
+
imap_store->capabilities = is->capabilities;
imap_set_server_level(imap_store);
}
CamelImapStore *store = (CamelImapStore *) object;
guint32 tag, flags;
int i;
-
+
for (i = 0; i < args->argc; i++) {
tag = args->argv[i].tag;
-
+
/* make sure this is an arg we're supposed to handle */
if ((tag & CAMEL_ARG_TAG) <= CAMEL_IMAP_STORE_ARG_FIRST ||
(tag & CAMEL_ARG_TAG) >= CAMEL_IMAP_STORE_ARG_FIRST + 100)
case CAMEL_IMAP_STORE_OVERRIDE_NAMESPACE:
flags = args->argv[i].ca_int ? IMAP_PARAM_OVERRIDE_NAMESPACE : 0;
flags |= (store->parameters & ~IMAP_PARAM_OVERRIDE_NAMESPACE);
-
+
if (store->parameters != flags) {
store->parameters = flags;
/* the current imap code will need to do a reconnect for this to take effect */
/* error?? */
continue;
}
-
+
/* let our parent know that we've handled this arg */
camel_argv_ignore (args, i);
}
-
+
/* FIXME: if we need to reconnect for a change to take affect,
we need to do it here... or, better yet, somehow chain it
up to CamelService's setv implementation. */
-
+
return CAMEL_OBJECT_CLASS (parent_class)->setv (object, ex, args);
}
CamelImapStore *store = (CamelImapStore *) object;
guint32 tag;
int i;
-
+
for (i = 0; i < args->argc; i++) {
tag = args->argv[i].tag;
-
+
/* make sure this is an arg we're supposed to handle */
if ((tag & CAMEL_ARG_TAG) <= CAMEL_IMAP_STORE_ARG_FIRST ||
(tag & CAMEL_ARG_TAG) >= CAMEL_IMAP_STORE_ARG_FIRST + 100)
continue;
-
+
switch (tag) {
case CAMEL_IMAP_STORE_NAMESPACE:
*args->argv[i].ca_str = store->namespace;
break;
}
}
-
+
return CAMEL_OBJECT_CLASS (parent_class)->getv (object, ex, args);
}
CamelImapStore *store = CAMEL_IMAP_STORE (service);
CamelImapResponse *response;
char *result;
-
+
/* Find out the IMAP capabilities */
/* We assume we have utf8 capable search until a failed search tells us otherwise */
store->capabilities = IMAP_CAPABILITY_utf8_search;
result = camel_imap_response_extract (store, response, "CAPABILITY ", ex);
if (!result)
return FALSE;
-
+
/* Skip over "* CAPABILITY ". */
parse_capability(store, result+13);
g_free (result);
g_free (result);
}
}
-
+
imap_set_server_level (store);
-
+
if (store->summary->capabilities != store->capabilities) {
store->summary->capabilities = store->capabilities;
camel_store_summary_touch((CamelStoreSummary *)store->summary);
camel_store_summary_save((CamelStoreSummary *)store->summary);
}
-
+
return TRUE;
}
gboolean force_imap4 = FALSE;
gboolean clean_quit = TRUE;
char *buf;
-
+
if (ssl_mode != MODE_CLEAR) {
#ifdef HAVE_SSL
if (ssl_mode == MODE_TLS) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect to %s: %s"),
service->url->host, _("SSL unavailable"));
-
+
return FALSE;
#endif /* HAVE_SSL */
} else {
tcp_stream = camel_tcp_stream_raw_new ();
}
-
+
if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai) == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
_("Could not connect to %s: %s"),
service->url->host,
g_strerror (errno));
-
+
camel_object_unref (tcp_stream);
-
+
return FALSE;
}
-
+
store->ostream = tcp_stream;
store->istream = camel_stream_buffer_new (tcp_stream, CAMEL_STREAM_BUFFER_READ);
-
+
store->connected = TRUE;
store->preauthed = FALSE;
store->command = 0;
camel_object_unref (store->istream);
store->istream = NULL;
}
-
+
if (store->ostream) {
camel_object_unref (store->ostream);
store->ostream = NULL;
}
-
+
store->connected = FALSE;
-
+
return FALSE;
}
-
+
if (!strncmp(buf, "* PREAUTH", 9))
store->preauthed = TRUE;
-
+
if (strstr (buf, "Courier-IMAP") || getenv("CAMEL_IMAP_BRAINDAMAGED")) {
/* Courier-IMAP is braindamaged. So far this flag only
* works around the fact that Courier-IMAP is known to
**/
force_imap4 = TRUE;
}
-
+
g_free (buf);
-
+
/* get the imap server capabilities */
if (!imap_get_capability (service, ex)) {
if (store->istream) {
camel_object_unref (store->istream);
store->istream = NULL;
}
-
+
if (store->ostream) {
camel_object_unref (store->ostream);
store->ostream = NULL;
}
-
+
store->connected = FALSE;
return FALSE;
}
-
+
if (force_imap4) {
store->capabilities &= ~IMAP_CAPABILITY_IMAP4REV1;
store->server_level = IMAP_LEVEL_IMAP4;
}
-
+
if (ssl_mode != MODE_TLS) {
/* we're done */
return TRUE;
}
-
+
#ifdef HAVE_SSL
if (!(store->capabilities & IMAP_CAPABILITY_STARTTLS)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to IMAP server %s in secure mode: %s"),
service->url->host, _("STARTTLS not supported"));
-
+
goto exception;
}
-
+
/* as soon as we send a STARTTLS command, all hope is lost of a clean QUIT if problems arise */
clean_quit = FALSE;
-
+
response = camel_imap_command (store, NULL, ex, "STARTTLS");
if (!response) {
camel_object_unref (store->istream);
store->istream = store->ostream = NULL;
return FALSE;
}
-
+
camel_imap_response_free_without_processing (store, response);
-
+
/* Okay, now toggle SSL/TLS mode */
if (camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream)) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
service->url->host, _("SSL is not available in this build"));
goto exception;
#endif /* HAVE_SSL */
-
+
/* rfc2595, section 4 states that after a successful STLS
command, the client MUST discard prior CAPA responses */
if (!imap_get_capability (service, ex)) {
camel_object_unref (store->istream);
store->istream = NULL;
}
-
+
if (store->ostream) {
camel_object_unref (store->ostream);
store->ostream = NULL;
}
-
+
store->connected = FALSE;
-
+
return FALSE;
}
- if (store->capabilities & IMAP_CAPABILITY_LOGINDISABLED ) {
+ if (store->capabilities & IMAP_CAPABILITY_LOGINDISABLED ) {
clean_quit = TRUE;
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to IMAP server %s in secure mode: %s"), service->url->host, _("Unknown error"));
}
return TRUE;
-
+
exception:
-
+
if (clean_quit && store->connected) {
/* try to disconnect cleanly */
response = camel_imap_command (store, NULL, ex, "LOGOUT");
if (response)
camel_imap_response_free_without_processing (store, response);
}
-
+
if (store->istream) {
camel_object_unref (store->istream);
store->istream = NULL;
}
-
+
if (store->ostream) {
camel_object_unref (store->ostream);
store->ostream = NULL;
}
-
+
store->connected = FALSE;
-
+
return FALSE;
}
char *full_cmd;
char *child_env[7];
- /* Put full details in the environment, in case the connection
+ /* Put full details in the environment, in case the connection
program needs them */
buf = camel_url_to_string(service->url, 0);
child_env[i++] = g_strdup_printf("URL=%s", buf);
full_cmd = tmp;
break;
}
-
+
len = pc - buf;
var = NULL;
full_cmd = tmp;
buf = pc + 2;
}
-
+
g_free(cmd_copy);
cmd_stream = camel_stream_process_new ();
-
+
ret = camel_stream_process_connect (CAMEL_STREAM_PROCESS(cmd_stream),
full_cmd, (const char **)child_env);
while (i)
g_free(child_env[--i]);
-
+
if (ret == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect with command \"%s\": %s"),
full_cmd, g_strerror (errno));
-
+
camel_object_unref (cmd_stream);
g_free (full_cmd);
return FALSE;
}
g_free (full_cmd);
-
+
store->ostream = cmd_stream;
store->istream = camel_stream_buffer_new (cmd_stream, CAMEL_STREAM_BUFFER_READ);
-
+
store->connected = TRUE;
store->preauthed = FALSE;
store->command = 0;
-
+
/* Read the greeting, if any, and deal with PREAUTH */
if (camel_imap_store_readline (store, &buf, ex) < 0) {
if (store->istream) {
camel_object_unref (store->istream);
store->istream = NULL;
}
-
+
if (store->ostream) {
camel_object_unref (store->ostream);
store->ostream = NULL;
}
-
+
store->connected = FALSE;
return FALSE;
}
if (!strncmp(buf, "* PREAUTH", 9))
store->preauthed = TRUE;
g_free (buf);
-
+
/* get the imap server capabilities */
if (!imap_get_capability (service, ex)) {
if (store->istream) {
camel_object_unref (store->istream);
store->istream = NULL;
}
-
+
if (store->ostream) {
camel_object_unref (store->ostream);
store->ostream = NULL;
}
-
+
store->connected = FALSE;
return FALSE;
}
-
+
return TRUE;
-
+
}
#endif
if (camel_url_get_param(service->url, "use_command")
&& (command = camel_url_get_param(service->url, "command")))
return connect_to_server_process(service, command, ex);
-#endif
+#endif
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
serv = "imap";
port = IMAP_PORT;
}
-
+
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
port = NULL;
}
-
+
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
camel_exception_clear (ex);
ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
}
-
+
if (ai == NULL)
return FALSE;
-
+
ret = connect_to_server (service, ai, mode, ex);
-
+
camel_freeaddrinfo (ai);
-
+
return ret;
}
CamelServiceAuthType *authtype;
GList *sasl_types, *t, *next;
gboolean connected;
-
+
if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (store), ex))
return NULL;
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
connected = store->istream != NULL && store->connected;
if (!connected)
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
if (!connected)
return NULL;
-
+
sasl_types = camel_sasl_authtype_list (FALSE);
for (t = sasl_types; t; t = next) {
authtype = t->data;
next = t->next;
-
+
if (!g_hash_table_lookup (store->authtypes, authtype->authproto)) {
sasl_types = g_list_remove_link (sasl_types, t);
g_list_free_1 (t);
}
}
-
+
return g_list_prepend (sasl_types, &camel_imap_password_authtype);
}
fi->name = g_strdup (_("Inbox"));
else
fi->name = g_strdup (name);
-
+
return fi;
}
static void
-imap_folder_effectively_unsubscribed(CamelImapStore *imap_store,
+imap_folder_effectively_unsubscribed(CamelImapStore *imap_store,
const char *folder_name, CamelException *ex)
{
CamelFolderInfo *fi;
name++;
else
name = folder_name;
-
+
storage_path = g_strdup_printf ("%s/folders", imap_store->storage_path);
folder_dir = imap_path_to_physical (storage_path, folder_name);
g_free (storage_path);
g_free (folder_dir);
goto event;
}
-
+
summary_file = g_strdup_printf ("%s/summary", folder_dir);
summary = camel_imap_summary_new (NULL, summary_file);
if (!summary) {
g_free (folder_dir);
goto event;
}
-
+
cache = camel_imap_message_cache_new (folder_dir, summary, ex);
if (cache)
camel_imap_message_cache_clear (cache);
-
+
camel_object_unref (cache);
camel_object_unref (summary);
-
+
g_unlink (summary_file);
g_free (summary_file);
-
+
journal_file = g_strdup_printf ("%s/journal", folder_dir);
g_unlink (journal_file);
g_free (journal_file);
state_file = g_strdup_printf("%s/subfolders", folder_dir);
g_rmdir(state_file);
g_free(state_file);
-
+
g_rmdir (folder_dir);
g_free (folder_dir);
-
+
event:
camel_store_summary_remove_path((CamelStoreSummary *)imap_store->summary, folder_name);
}
static gboolean
-imap_check_folder_still_extant (CamelImapStore *imap_store, const char *full_name,
+imap_check_folder_still_extant (CamelImapStore *imap_store, const char *full_name,
CamelException *ex)
{
CamelImapResponse *response;
{
GPtrArray *folders;
int i;
-
+
folders = camel_object_bag_list(CAMEL_STORE (store)->folders);
-
+
for (i = 0; i <folders->len; i++) {
CamelFolder *folder = folders->pdata[i];
if (camel_exception_is_set (ex) &&
imap_check_folder_still_extant (store, folder->full_name, ex) == FALSE) {
gchar *namedup;
-
+
/* the folder was deleted (may happen when we come back online
* after being offline */
-
+
namedup = g_strdup (folder->full_name);
camel_object_unref(folder);
imap_folder_effectively_unsubscribed (store, namedup, ex);
} else
camel_object_unref(folder);
}
-
+
g_ptr_array_free (folders, TRUE);
}
#endif
CamelImapResponse *response;
char *resp;
char *sasl_resp;
-
+
response = camel_imap_command (store, NULL, ex, "AUTHENTICATE %s", mech);
if (!response)
return FALSE;
-
+
sasl = camel_sasl_new ("imap", mech, CAMEL_SERVICE (store));
while (!camel_sasl_authenticated (sasl)) {
resp = camel_imap_response_extract_continuation (store, response, ex);
if (!resp)
goto lose;
-
+
sasl_resp = camel_sasl_challenge_base64 (sasl, imap_next_word (resp), ex);
g_free (resp);
if (!sasl_resp || camel_exception_is_set (ex))
goto break_and_lose;
-
+
response = camel_imap_command_continuation (store, sasl_resp, strlen (sasl_resp), ex);
g_free (sasl_resp);
if (!response)
goto lose;
}
-
+
resp = camel_imap_response_extract_continuation (store, response, NULL);
if (resp) {
/* Oops. SASL claims we're done, but the IMAP server
g_free (resp);
goto lose;
}
-
+
camel_object_unref (sasl);
-
+
return TRUE;
-
+
break_and_lose:
/* Get the server out of "waiting for continuation data" mode. */
response = camel_imap_command_continuation (store, "*", 1, NULL);
if (response)
camel_imap_response_free (store, response);
-
+
lose:
if (!camel_exception_is_set (ex)) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("Bad authentication response from server."));
}
-
+
camel_object_unref (sasl);
-
+
return FALSE;
}
char *errbuf = NULL;
gboolean authenticated = FALSE;
const char *auth_domain;
-
+
auth_domain = camel_url_get_param (service->url, "auth-domain");
-
+
if (store->preauthed) {
if (camel_verbose_debug)
fprintf(stderr, "Server %s has preauthenticated us.\n",
service->url->authmech);
return FALSE;
}
-
+
authtype = camel_sasl_authtype (service->url->authmech);
if (!authtype) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
service->url->authmech);
return FALSE;
}
-
+
if (!authtype->need_password) {
authenticated = try_auth (store, authtype->authproto, ex);
if (!authenticated)
return FALSE;
}
}
-
+
while (!authenticated) {
if (errbuf) {
/* We need to un-cache the password before prompting again */
g_free (service->url->passwd);
service->url->passwd = NULL;
}
-
+
if (!service->url->passwd) {
char *prompt;
-
+
prompt = g_strdup_printf (_("%sPlease enter the IMAP "
"password for %s@%s"),
errbuf ? errbuf : "",
g_free (prompt);
g_free (errbuf);
errbuf = NULL;
-
+
if (!service->url->passwd) {
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
_("You did not enter a password."));
return FALSE;
}
}
-
+
if (!store->connected) {
/* Some servers (eg, courier) will disconnect on
* a bad password. So reconnect here.
if (!connect_to_server_wrapper (service, ex))
return FALSE;
}
-
+
if (authtype)
authenticated = try_auth (store, authtype->authproto, ex);
else {
if (!authenticated) {
if (camel_exception_get_id(ex) == CAMEL_EXCEPTION_USER_CANCEL)
return FALSE;
-
+
errbuf = g_strdup_printf (_("Unable to authenticate "
"to IMAP server.\n%s\n\n"),
camel_exception_get_description (ex));
camel_exception_clear (ex);
}
}
-
+
return TRUE;
}
can_work_offline (CamelDiscoStore *disco_store)
{
CamelImapStore *store = CAMEL_IMAP_STORE (disco_store);
-
+
return camel_store_summary_count((CamelStoreSummary *)store->summary) != 0;
}
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
-
+
/* Get namespace and hierarchy separator */
if ((store->capabilities & IMAP_CAPABILITY_NAMESPACE) &&
!(store->parameters & IMAP_PARAM_OVERRIDE_NAMESPACE)) {
response = camel_imap_command (store, NULL, ex, "NAMESPACE");
if (!response)
goto done;
-
+
result = camel_imap_response_extract (store, response, "NAMESPACE", ex);
if (!result)
goto done;
-
+
#if 0
/* new code... */
namespaces = imap_parse_namespace_response (result);
imap_namespaces_destroy (namespaces);
/* end new code */
#endif
-
+
name = camel_strstrcase (result, "NAMESPACE ((");
if (name) {
char *sep;
-
+
name += 12;
store->namespace = imap_parse_string ((const char **) &name, &len);
if (name && *name++ == ' ') {
}
g_free (result);
}
-
+
if (!store->namespace)
store->namespace = g_strdup ("");
-
+
if (!store->dir_sep) {
if (store->server_level >= IMAP_LEVEL_IMAP4REV1) {
/* This idiom means "tell me the hierarchy separator
}
if (!response)
goto done;
-
+
result = camel_imap_response_extract (store, response, "LIST", NULL);
if (result) {
imap_parse_list_response (store, result, NULL, &store->dir_sep, NULL);
store->dir_sep = '/'; /* Guess */
}
}
-
+
/* canonicalize the namespace to end with dir_sep */
len = strlen (store->namespace);
if (len && store->namespace[len - 1] != store->dir_sep) {
gchar *tmp;
-
+
tmp = g_strdup_printf ("%s%c", store->namespace, store->dir_sep);
g_free (store->namespace);
store->namespace = tmp;
}
-
+
ns = camel_imap_store_summary_namespace_new(store->summary, store->namespace, store->dir_sep);
camel_imap_store_summary_namespace_set(store->summary, ns);
-
+
if ((store->parameters & IMAP_PARAM_SUBSCRIPTIONS)
&& camel_store_summary_count((CamelStoreSummary *)store->summary) == 0) {
CamelStoreInfo *si;
char *pattern;
-
+
get_folders_sync(store, store->namespace, ex);
if (camel_exception_is_set(ex))
goto done;
}
store->refresh_stamp = time(NULL);
}
-
-
+
+
done:
/* save any changes we had */
camel_store_summary_save((CamelStoreSummary *)store->summary);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
-
+
if (camel_exception_is_set (ex))
camel_service_disconnect (service, TRUE, NULL);
-
+
return !camel_exception_is_set (ex);
}
if (!disco_store->diary)
return FALSE;
-
+
store->connected = !camel_exception_is_set (ex);
return store->connected;
}
camel_object_unref(store->istream);
store->istream = NULL;
}
-
+
if (store->ostream) {
camel_stream_close(store->ostream);
camel_object_unref(store->ostream);
store->ostream = NULL;
}
-
+
store->connected = FALSE;
if (store->current_folder) {
camel_object_unref (store->current_folder);
store->current_folder = NULL;
}
-
+
if (store->authtypes) {
g_hash_table_foreach_remove (store->authtypes,
free_key, NULL);
g_hash_table_destroy (store->authtypes);
store->authtypes = NULL;
}
-
+
if (store->namespace && !(store->parameters & IMAP_PARAM_OVERRIDE_NAMESPACE)) {
g_free (store->namespace);
store->namespace = NULL;
}
-
+
return TRUE;
}
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
CamelImapResponse *response;
-
+
if (store->connected && clean) {
response = camel_imap_command (store, NULL, NULL, "LOGOUT");
camel_imap_response_free (store, response);
}
-
+
imap_disconnect_offline (service, clean, ex);
-
+
return TRUE;
}
camel_message_info_free(info);
}
}
-
+
return FALSE;
}
CamelImapStore *imap_store = (CamelImapStore *) store;
CamelImapResponse *response;
CamelFolder *current_folder;
-
+
CAMEL_SERVICE_REC_LOCK (imap_store, connect_lock);
if (!camel_imap_store_connected(imap_store, ex))
imap_status_item_free (struct imap_status_item *items)
{
struct imap_status_item *next;
-
+
while (items != NULL) {
next = items->next;
g_free (items->name);
struct imap_status_item *items, *item, *tail;
CamelImapResponse *response;
char *status, *name, *p;
-
+
/* FIXME: we assume the server is STATUS-capable */
-
+
response = camel_imap_command (imap_store, NULL, NULL,
"STATUS %F (%s)",
folder_name,
camel_exception_clear (&ex);
return NULL;
}
-
+
if (!(status = camel_imap_response_extract (imap_store, response, "STATUS", NULL)))
return NULL;
-
+
p = status + strlen ("* STATUS ");
while (*p == ' ')
p++;
-
+
/* skip past the mailbox string */
if (*p == '"') {
p++;
p++;
break;
}
-
+
p++;
}
} else {
while (*p != ' ')
p++;
}
-
+
while (*p == ' ')
p++;
-
+
if (*p++ != '(') {
g_free (status);
return NULL;
}
-
+
while (*p == ' ')
p++;
-
+
if (*p == ')') {
g_free (status);
return NULL;
}
-
+
items = NULL;
tail = (struct imap_status_item *) &items;
-
+
do {
name = p;
while (*p != ' ')
p++;
-
+
item = g_malloc (sizeof (struct imap_status_item));
item->next = NULL;
item->name = g_strndup (name, p - name);
item->value = strtoul (p, &p, 10);
-
+
tail->next = item;
tail = item;
-
+
while (*p == ' ')
p++;
} while (*p != ')');
-
+
g_free (status);
-
+
return items;
}
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
return NULL;
}
-
+
if (!g_ascii_strcasecmp (folder_name, "INBOX"))
folder_name = "INBOX";
if (!response) {
char *folder_real, *parent_name, *parent_real;
const char *c;
-
+
if (camel_exception_get_id(ex) == CAMEL_EXCEPTION_USER_CANCEL) {
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
return NULL;
}
-
+
camel_exception_clear (ex);
-
+
if (!(flags & CAMEL_STORE_FOLDER_CREATE)) {
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
_("No such folder %s"), folder_name);
return NULL;
}
-
+
parent_name = strrchr(folder_name, '/');
c = parent_name ? parent_name+1 : folder_name;
while (*c && *c != imap_store->dir_sep && !strchr ("#%*", *c))
c++;
-
+
if (*c != '\0') {
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
} else {
parent_real = NULL;
}
-
+
if (parent_real != NULL) {
gboolean need_convert = FALSE;
char *resp, *thisone;
guint32 flags;
int i;
-
+
if (!(response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %G", parent_real))) {
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
g_free (parent_name);
g_free (parent_real);
return NULL;
}
-
+
/* FIXME: does not handle unexpected circumstances very well */
for (i = 0; i < response->untagged->len; i++) {
resp = response->untagged->pdata[i];
-
+
if (!imap_parse_list_response (imap_store, resp, &flags, NULL, &thisone))
continue;
-
+
if (!strcmp (parent_name, thisone)) {
if (flags & CAMEL_FOLDER_NOINFERIORS)
need_convert = TRUE;
}
-
+
g_free (thisone);
}
-
+
camel_imap_response_free (imap_store, response);
-
+
/* if not, check if we can delete it and recreate it */
if (need_convert) {
struct imap_status_item *items, *item;
guint32 messages = 0;
CamelException lex;
char *name;
-
+
item = items = get_folder_status (imap_store, parent_name, "MESSAGES");
while (item != NULL) {
if (!g_ascii_strcasecmp (item->name, "MESSAGES")) {
messages = item->value;
break;
}
-
+
item = item->next;
}
-
+
imap_status_item_free (items);
-
+
if (messages > 0) {
camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
_("The parent folder is not allowed to contain subfolders"));
g_free (parent_real);
return NULL;
}
-
+
/* delete the old parent and recreate it */
camel_exception_init (&lex);
delete_folder (store, parent_name, &lex);
g_free (parent_real);
return NULL;
}
-
+
/* add the dirsep to the end of parent_name */
name = g_strdup_printf ("%s%c", parent_real, imap_store->dir_sep);
response = camel_imap_command (imap_store, NULL, ex, "CREATE %G",
name);
g_free (name);
-
+
if (!response) {
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
g_free (parent_name);
} else
camel_imap_response_free (imap_store, response);
}
-
+
g_free (parent_real);
}
-
+
g_free (parent_name);
folder_real = camel_imap_store_summary_path_to_full(imap_store->summary, folder_name, imap_store->dir_sep);
camel_imap_store_summary_add_from_full(imap_store->summary, folder_real, imap_store->dir_sep);
camel_imap_response_free (imap_store, response);
-
+
response = camel_imap_command (imap_store, NULL, NULL, "SELECT %F", folder_name);
}
g_free(folder_real);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot create folder `%s': folder exists."),
folder_name);
-
+
camel_imap_response_free_without_processing (imap_store, response);
-
+
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
-
+
return NULL;
}
}
}
camel_imap_response_free_without_processing (imap_store, response);
-
+
CAMEL_SERVICE_REC_UNLOCK (imap_store, connect_lock);
-
+
return new_folder;
}
camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
_("No such folder %s"), folder_name);
}
-
+
return new_folder;
}
if (!camel_imap_store_connected(imap_store, ex))
goto fail;
-
+
/* make sure this folder isn't currently SELECTed */
response = camel_imap_command (imap_store, NULL, ex, "SELECT INBOX");
if (!response)
else
npath = g_strdup(new_name);
nfull = camel_imap_store_summary_path_to_full(imap_store->summary, npath, imap_store->dir_sep);
-
+
/* workaround for broken server (courier uses '.') that doesn't rename
subordinate folders as required by rfc 2060 */
if (imap_store->dir_sep == '.') {
if (!camel_imap_store_connected(imap_store, ex))
goto fail;
-
+
/* make sure this folder isn't currently SELECTed - it's
actually possible to rename INBOX but if you do another
INBOX will immediately be created by the server */
manage_subscriptions(store, old_name, TRUE);
goto fail;
}
-
+
camel_imap_response_free (imap_store, response);
/* rename summary, and handle broken server */
g_warning ("Could not rename message cache '%s' to '%s': %s: cache reset",
oldpath, newpath, strerror (errno));
}
-
+
g_free (oldpath);
g_free (newpath);
fail:
gboolean need_convert;
int i = 0, flags;
const char *c;
-
+
if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (store), ex))
return NULL;
if (!parent_name)
parent_name = "";
-
+
c = folder_name;
while (*c && *c != imap_store->dir_sep && !strchr ("#%*", *c))
c++;
-
+
if (*c != '\0') {
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
_("The folder name \"%s\" is invalid because it contains the character \"%c\""),
folder_name, *c);
return NULL;
}
-
+
/* check if the parent allows inferiors */
/* FIXME: use storesummary directly */
g_free(parent_real);
return NULL;
}
-
+
/* FIXME: does not handle unexpected circumstances very well */
for (i = 0; i < response->untagged->len && !need_convert; i++) {
resp = response->untagged->pdata[i];
-
+
if (!imap_parse_list_response (imap_store, resp, &flags, NULL, &thisone))
continue;
-
+
if (strcmp (thisone, parent_name) == 0) {
if (flags & CAMEL_FOLDER_NOINFERIORS)
need_convert = TRUE;
g_free(thisone);
}
-
+
camel_imap_response_free (imap_store, response);
-
+
camel_exception_init (&internal_ex);
-
+
/* if not, check if we can delete it and recreate it */
if (need_convert) {
struct imap_status_item *items, *item;
guint32 messages = 0;
char *name;
-
+
item = items = get_folder_status (imap_store, parent_name, "MESSAGES");
while (item != NULL) {
if (!g_ascii_strcasecmp (item->name, "MESSAGES")) {
messages = item->value;
break;
}
-
+
item = item->next;
}
-
+
imap_status_item_free (items);
-
+
if (messages > 0) {
camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE,
_("The parent folder is not allowed to contain subfolders"));
g_free(parent_real);
return NULL;
}
-
+
/* delete the old parent and recreate it */
delete_folder (store, parent_name, &internal_ex);
if (camel_exception_is_set (&internal_ex)) {
camel_exception_xfer (ex, &internal_ex);
return NULL;
}
-
+
/* add the dirsep to the end of parent_name */
name = g_strdup_printf ("%s%c", parent_real, imap_store->dir_sep);
response = camel_imap_command (imap_store, NULL, ex, "CREATE %G",
name);
g_free (name);
-
+
if (!response) {
g_free(parent_real);
return NULL;
root = imap_build_folder_info(imap_store, parent_name);
}
-
+
/* ok now we can create the folder */
real_name = camel_imap_store_summary_path_to_full(imap_store->summary, folder_name, imap_store->dir_sep);
full_name = imap_concat (imap_store, parent_real, real_name);
g_free(real_name);
response = camel_imap_command (imap_store, NULL, ex, "CREATE %G", full_name);
-
+
if (response) {
CamelImapStoreInfo *si;
CamelFolderInfo *fi;
g_free (full_name);
g_free(parent_real);
-
+
return root;
}
if (!g_ascii_strcasecmp(fi->full_name, "inbox")) {
flags |= CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_TYPE_INBOX;
fi->name = g_strdup (_("Inbox"));
- } else
+ } else
fi->name = g_strdup(camel_store_info_name(imap_store->summary, si));
-
+
/* HACK: some servers report noinferiors for all folders (uw-imapd)
We just translate this into nochildren, and let the imap layer enforce
it. See create folder */
if (flags & CAMEL_FOLDER_NOINFERIORS)
flags = (flags & ~CAMEL_FOLDER_NOINFERIORS) | CAMEL_FOLDER_NOCHILDREN;
fi->flags = flags;
-
+
url = camel_url_new (imap_store->base_url, NULL);
path = alloca(strlen(fi->full_name)+2);
sprintf(path, "/%s", fi->full_name);
if (store->namespace && store->namespace[0]) {
char *pattern;
-
+
get_folders_sync(store, "INBOX", &m->ex);
if (camel_exception_is_set(&m->ex))
goto done;
get_folders_sync(imap_store, "INBOX", ex);
if (camel_exception_is_set(ex))
goto fail;
-
+
i = strlen(imap_store->namespace)-1;
pattern = g_alloca(i+5);
strcpy(pattern, imap_store->namespace);
}
} else {
char *name;
-
+
name = camel_imap_store_summary_full_from_path(imap_store->summary, top);
if (name == NULL)
name = camel_imap_store_summary_path_to_full(imap_store->summary, top, imap_store->dir_sep);
if (si == NULL)
continue;
-
+
if ((!strcmp(name, camel_imap_store_info_full_name(imap_store->summary, si))
|| imap_match_pattern(imap_store->dir_sep, pattern, camel_imap_store_info_full_name(imap_store->summary, si))
|| (include_inbox && !g_ascii_strcasecmp (camel_imap_store_info_full_name(imap_store->summary, si), "INBOX")))
it. See create folder */
if (fi->flags & CAMEL_FOLDER_NOINFERIORS)
fi->flags = (fi->flags & ~CAMEL_FOLDER_NOINFERIORS) | CAMEL_FOLDER_NOCHILDREN;
-
+
/* blah, this gets lost somewhere, i can't be bothered finding out why */
if (!g_ascii_strcasecmp(fi->full_name, "inbox"))
fi->flags = (fi->flags & ~CAMEL_FOLDER_TYPE_MASK) | CAMEL_FOLDER_TYPE_INBOX;
-
+
if (si->flags & CAMEL_FOLDER_NOSELECT) {
CamelURL *url = camel_url_new(fi->uri, NULL);
-
+
camel_url_set_param (url, "noselect", "yes");
g_free(fi->uri);
fi->uri = camel_url_to_string (url, 0);
if (!camel_imap_store_connected (imap_store, ex))
goto done;
-
+
response = camel_imap_command (imap_store, NULL, ex,
"SUBSCRIBE %F", folder_name);
if (!response)
goto done;
camel_imap_response_free (imap_store, response);
-
+
si = camel_store_summary_path((CamelStoreSummary *)imap_store->summary, folder_name);
if (si) {
if ((si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) == 0) {
}
camel_store_summary_info_free((CamelStoreSummary *)imap_store->summary, si);
}
-
+
if (imap_store->renaming) {
/* we don't need to emit a "folder_subscribed" signal
if we are in the process of renaming folders, so we
fi = imap_build_folder_info(imap_store, folder_name);
fi->flags |= CAMEL_FOLDER_NOCHILDREN;
-
+
camel_object_trigger_event (CAMEL_OBJECT (store), "folder_subscribed", fi);
camel_folder_info_free (fi);
done:
CamelImapResponse *response;
CAMEL_SERVICE_REC_LOCK(store, connect_lock);
-
+
if (!camel_imap_store_connected (imap_store, ex))
goto done;
-
+
response = camel_imap_command (imap_store, NULL, ex,
"UNSUBSCRIBE %F", folder_name);
if (!response)
{
CamelMessageInfo *info;
int i, max;
-
+
max = camel_folder_summary_count (folder->summary);
for (i = 0; i < max; i++) {
info = camel_folder_summary_index (folder->summary, i);
return TRUE;
}
}
-
+
return FALSE;
}
#endif
char linebuf[1024] = {0};
GByteArray *ba;
ssize_t nread;
-
+
g_return_val_if_fail (CAMEL_IS_IMAP_STORE (store), -1);
g_return_val_if_fail (dest, -1);
-
+
*dest = NULL;
-
+
/* Check for connectedness. Failed (or cancelled) operations will
* close the connection. We can't expect a read to have any
* meaning if we reconnect, so always set an exception.
*/
-
+
if (!camel_imap_store_connected (store, ex))
return -1;
-
+
stream = CAMEL_STREAM_BUFFER (store->istream);
-
+
ba = g_byte_array_new ();
while ((nread = camel_stream_buffer_gets (stream, linebuf, sizeof (linebuf))) > 0) {
g_byte_array_append (ba, linebuf, nread);
if (linebuf[nread - 1] == '\n')
break;
}
-
+
if (nread <= 0) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Operation cancelled"));
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Server unexpectedly disconnected: %s"),
g_strerror (errno));
-
+
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
g_byte_array_free (ba, TRUE);
return -1;
}
-
+
if (camel_verbose_debug) {
fprintf (stderr, "received: ");
fwrite (ba->data, 1, ba->len, stderr);
}
-
+
/* camel-imap-command.c:imap_read_untagged expects the CRLFs
to be stripped off and be nul-terminated *sigh* */
nread = ba->len - 1;
ba->data[nread - 1] = '\0';
nread--;
}
-
+
*dest = ba->data;
g_byte_array_free (ba, FALSE);
-
+
return nread;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-imap-store.h : class for an imap store */
-/*
+/*
* Authors: Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright (C) 2000 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#define IMAP_FETCH_MINIMAL_HEADERS 3
struct _CamelImapStore {
- CamelDiscoStore parent_object;
-
+ CamelDiscoStore parent_object;
+
CamelStream *istream;
CamelStream *ostream;
struct _CamelImapStoreSummary *summary;
-
+
/* Information about the command channel / connection status */
guint connected:1;
guint preauthed:1;
char tag_prefix;
guint32 command;
CamelFolder *current_folder;
-
+
/* Information about the server */
CamelImapServerLevel server_level;
guint32 capabilities, parameters;
/* NB: namespace should be handled by summary->namespace */
char *namespace, dir_sep, *base_url, *storage_path;
GHashTable *authtypes;
-
+
time_t refresh_stamp;
guint32 headers;
summary_header_load (CamelFolderSummary *s, FILE *in)
{
CamelImapSummary *ims = CAMEL_IMAP_SUMMARY (s);
-
+
if (camel_imap_summary_parent->summary_header_load (s, in) == -1)
return -1;
/* Version 1 */
if (camel_file_util_decode_fixed_int32(in, &ims->version) == -1)
return -1;
-
+
if (ims->version == 2) {
/* Version 2: for compat with version 2 of the imap4 summary files */
int have_mlist;
-
+
if (camel_file_util_decode_fixed_int32 (in, &have_mlist) == -1)
return -1;
}
-
+
if (camel_file_util_decode_fixed_int32(in, &ims->validity) == -1)
return -1;
-
+
if (ims->version > CAMEL_IMAP_SUMMARY_VERSION) {
g_warning("Unkown summary version\n");
errno = EINVAL;
CamelMimeMessage *message,
const CamelMessageInfo *info);
-void camel_imap_summary_add_offline_uncached (CamelFolderSummary *summary,
+void camel_imap_summary_add_offline_uncached (CamelFolderSummary *summary,
const char *uid,
const CamelMessageInfo *info);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-imap-types.h: IMAP types */
-/*
+/*
* Copyright (C) 2001 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
imap_next_word (const char *buf)
{
const char *word;
-
+
/* skip over current word */
word = buf;
while (*word && *word != ' ')
word++;
-
+
/* skip over white space */
while (*word && *word == ' ')
word++;
-
+
return word;
}
imap_namespace_destroy (struct _namespace *namespace)
{
struct _namespace *node, *next;
-
+
node = namespace;
while (node) {
next = node->next;
const char *inptr;
char *astring;
size_t len;
-
+
inptr = *in;
-
+
list = NULL;
tail = (struct _namespace *) &list;
-
+
if (g_ascii_strncasecmp (inptr, "NIL", 3) != 0) {
if (*inptr++ != '(')
goto exception;
-
+
while (*inptr && *inptr != ')') {
if (*inptr++ != '(')
goto exception;
-
+
node = g_new (struct _namespace, 1);
node->next = NULL;
-
+
/* get the namespace prefix */
astring = imap_parse_astring (&inptr, &len);
if (!astring) {
g_free (node);
goto exception;
}
-
+
/* decode IMAP's modified UTF-7 into UTF-8 */
node->prefix = imap_mailbox_decode (astring, len);
g_free (astring);
g_free (node);
goto exception;
}
-
+
tail->next = node;
tail = node;
-
+
/* get the namespace directory delimiter */
inptr = imap_next_word (inptr);
-
+
if (!g_ascii_strncasecmp (inptr, "NIL", 3)) {
inptr = imap_next_word (inptr);
node->delim = '\0';
} else if (*inptr++ == '"') {
if (*inptr == '\\')
inptr++;
-
+
node->delim = *inptr++;
-
+
if (*inptr++ != '"')
goto exception;
} else
goto exception;
-
+
if (*inptr == ' ') {
/* parse extra flags... for now we
don't save them, but in the future
we may want to? */
while (*inptr == ' ')
inptr++;
-
+
while (*inptr && *inptr != ')') {
/* this should be a QSTRING or ATOM */
inptr = imap_next_word (inptr);
/* skip over the param list */
imap_skip_list (&inptr);
}
-
+
while (*inptr == ' ')
inptr++;
}
}
-
+
if (*inptr++ != ')')
goto exception;
-
+
/* there shouldn't be spaces according to the
ABNF grammar, but we all know how closely
people follow specs */
while (*inptr == ' ')
inptr++;
}
-
+
if (*inptr == ')')
inptr++;
} else {
inptr += 3;
}
-
+
*in = inptr;
*namespace = list;
-
+
return TRUE;
-
+
exception:
-
+
/* clean up any namespaces we may have allocated */
imap_namespace_destroy (list);
-
+
return FALSE;
}
namespace_dump (struct _namespace *namespace)
{
struct _namespace *node;
-
+
if (namespace) {
printf ("(");
node = namespace;
printf ("\"%c\")", node->delim);
else
printf ("NUL)");
-
+
node = node->next;
if (node)
printf (" ");
}
-
+
printf (")");
} else {
printf ("NIL");
{
struct _namespaces *namespaces;
const char *inptr;
-
+
d(printf ("parsing: %s\n", response));
-
+
if (*response != '*')
return NULL;
-
+
inptr = imap_next_word (response);
if (g_ascii_strncasecmp (inptr, "NAMESPACE", 9) != 0)
return NULL;
-
+
inptr = imap_next_word (inptr);
-
+
namespaces = g_new (struct _namespaces, 1);
namespaces->personal = NULL;
namespaces->other = NULL;
namespaces->shared = NULL;
-
+
if (!imap_namespace_decode (&inptr, &namespaces->personal))
goto exception;
-
+
if (*inptr != ' ')
goto exception;
-
+
while (*inptr == ' ')
inptr++;
-
+
if (!imap_namespace_decode (&inptr, &namespaces->other))
goto exception;
-
+
if (*inptr != ' ')
goto exception;
-
+
while (*inptr == ' ')
inptr++;
-
+
if (!imap_namespace_decode (&inptr, &namespaces->shared))
goto exception;
-
+
d(namespaces_dump (namespaces));
-
+
return namespaces;
-
+
exception:
-
+
imap_namespaces_destroy (namespaces);
-
+
return NULL;
}
gboolean is_lsub = FALSE;
const char *word;
size_t len;
-
+
if (*buf != '*')
return FALSE;
-
+
word = imap_next_word (buf);
if (g_ascii_strncasecmp (word, "LIST", 4) && g_ascii_strncasecmp (word, "LSUB", 4))
return FALSE;
-
+
/* check if we are looking at an LSUB response */
if (word[1] == 'S' || word[1] == 's')
is_lsub = TRUE;
-
+
/* get the flags */
word = imap_next_word (word);
if (*word != '(')
return FALSE;
-
+
if (flags)
*flags = 0;
-
+
word++;
while (*word != ')') {
len = strcspn (word, " )");
else if (!g_ascii_strncasecmp (word, "\\HasNoChildren", len))
*flags |= CAMEL_FOLDER_NOCHILDREN;
}
-
+
word += len;
while (*word == ' ')
word++;
}
-
+
/* get the directory separator */
word = imap_next_word (word);
if (!strncmp (word, "NIL", 3)) {
return FALSE;
} else
return FALSE;
-
+
if (folder) {
char *astring;
char *mailbox;
-
+
/* get the folder name */
word = imap_next_word (word);
astring = imap_parse_astring (&word, &len);
g_free (astring);
if (!mailbox)
return FALSE;
-
+
/* Kludge around Courier imap's LSUB response for INBOX when it
* isn't subscribed to.
*
*/
if (is_lsub && flags && !g_ascii_strcasecmp (mailbox, "INBOX"))
*flags &= ~CAMEL_FOLDER_NOSELECT;
-
+
*folder = mailbox;
}
-
+
return TRUE;
}
GPtrArray *heirarchy;
char **paths;
const char *p;
-
+
p = folder_name;
if (*p == store->dir_sep)
p++;
-
+
heirarchy = g_ptr_array_new ();
-
+
while (*p) {
if (*p == '"') {
p++;
p++;
continue;
}
-
+
if (*p == store->dir_sep)
g_ptr_array_add (heirarchy, g_strndup (folder_name, p - folder_name));
-
+
p++;
}
-
+
g_ptr_array_add (heirarchy, g_strdup (folder_name));
g_ptr_array_add (heirarchy, NULL);
-
+
paths = (char **) heirarchy->pdata;
g_ptr_array_free (heirarchy, FALSE);
-
+
return paths;
}
{
GString *gstr;
char *flag_list;
-
+
gstr = g_string_new ("(");
if (flags & CAMEL_MESSAGE_ANSWERED)
char *flag_list = *flag_list_p;
guint32 flags = 0;
int len;
-
+
if (*flag_list++ != '(') {
*flag_list_p = NULL;
return 0;
}
-
+
while (*flag_list && *flag_list != ')') {
len = strcspn (flag_list, " )");
if (!g_ascii_strncasecmp (flag_list, "\\Answered", len))
flags |= CAMEL_IMAP_MESSAGE_LABEL4;
else if (!g_ascii_strncasecmp(flag_list, "$Label5", len))
flags |= CAMEL_IMAP_MESSAGE_LABEL5;
-
+
flag_list += len;
if (*flag_list == ' ')
flag_list++;
}
-
+
if (*flag_list++ != ')') {
*flag_list_p = NULL;
return 0;
}
-
+
*flag_list_p = flag_list;
return flags;
}
/* 50 */1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1,
/* 60 */1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/* 70 */1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
#define imap_is_atom_char(c) ((imap_atom_specials[(c)&0xff] & 0x01) != 0)
{
const char *str = *str_p;
char *out;
-
+
if (!str)
return NULL;
else if (*str == '"') {
char *p;
size_t size;
-
+
str++;
size = strcspn (str, "\"") + 1;
p = out = g_malloc (size);
-
+
/* a quoted string cannot be broken into multiple lines */
while (*str && *str != '"' && *str != '\n') {
if (*str == '\\')
*str_p = NULL;
return NULL;
}
-
+
out = g_strndup (str, *len);
*str_p = str + *len;
return out;
} else if (type == IMAP_ASTRING && imap_is_atom_char ((unsigned char)*str)) {
while (imap_is_atom_char ((unsigned char) *str))
str++;
-
+
*len = str - *str_p;
out = g_strndup (*str_p, *len);
*str_p += *len;
skip_asn (const char **str_p)
{
const char *str = *str_p;
-
+
if (!str)
return;
else if (*str == '"') {
*str_p = NULL;
} else if (*str == '{') {
unsigned long len;
-
+
len = strtoul (str + 1, (char **) &str, 10);
if (*str != '}' || *(str + 1) != '\n' ||
strlen (str + 2) < len) {
const char *parms = *parms_p;
char *name, *value;
size_t len;
-
+
if (!g_ascii_strncasecmp (parms, "nil", 3)) {
*parms_p += 3;
return 0;
}
-
+
if (*parms++ != '(')
return -1;
-
+
while (parms && *parms != ')') {
name = imap_parse_nstring (&parms, &len);
skip_char (&parms, ' ');
value = imap_parse_nstring (&parms, &len);
-
+
if (name && value)
camel_content_type_set_param (type, name, value);
g_free (name);
g_free (value);
-
+
if (parms && *parms == ' ')
parms++;
}
-
+
if (!parms || *parms++ != ')')
return -1;
-
+
*parms_p = parms;
-
+
return 0;
}
size_t len;
size_t size;
char *p;
-
+
if (*inptr++ != '(')
return NULL;
-
+
if (ci == NULL) {
ci = camel_folder_summary_content_info_new (folder->summary);
g_ptr_array_add (cis, ci);
}
-
+
if (*inptr == '(') {
/* body_type_mpart */
CamelMessageContentInfo *tail, *children = NULL;
-
+
tail = (CamelMessageContentInfo *) &children;
-
+
do {
if (!(child = imap_body_decode (&inptr, NULL, folder, cis)))
return NULL;
-
+
child->parent = ci;
tail->next = child;
tail = child;
} while (*inptr == '(');
-
+
if (*inptr++ != ' ')
return NULL;
-
+
if (g_ascii_strncasecmp (inptr, "nil", 3) != 0) {
subtype = imap_parse_string (&inptr, &len);
} else {
subtype = NULL;
inptr += 3;
}
-
+
ctype = camel_content_type_new ("multipart", subtype ? subtype : "mixed");
g_free (subtype);
-
+
if (*inptr++ != ')') {
camel_content_type_unref (ctype);
return NULL;
}
-
+
ci->type = ctype;
ci->childs = children;
} else {
} else {
return NULL;
}
-
+
if (*inptr++ != ' ') {
g_free (type);
return NULL;
}
-
+
if (g_ascii_strncasecmp (inptr, "nil", 3) != 0) {
subtype = imap_parse_string (&inptr, &len);
if (inptr == NULL) {
subtype = NULL;
inptr += 3;
}
-
+
camel_strdown (type);
camel_strdown (subtype);
ctype = camel_content_type_new (type, subtype);
g_free (subtype);
g_free (type);
-
+
if (*inptr++ != ' ')
goto exception;
-
+
/* content-type params */
if (parse_params (&inptr, ctype) == -1)
goto exception;
-
+
if (*inptr++ != ' ')
goto exception;
-
+
/* content-id */
if (g_ascii_strncasecmp (inptr, "nil", 3) != 0) {
id = imap_parse_string (&inptr, &len);
goto exception;
} else
inptr += 3;
-
+
if (*inptr++ != ' ')
goto exception;
-
+
/* description */
if (g_ascii_strncasecmp (inptr, "nil", 3) != 0) {
description = imap_parse_string (&inptr, &len);
goto exception;
} else
inptr += 3;
-
+
if (*inptr++ != ' ')
goto exception;
-
+
/* encoding */
if (g_ascii_strncasecmp (inptr, "nil", 3) != 0) {
encoding = imap_parse_string (&inptr, &len);
goto exception;
} else
inptr += 3;
-
+
if (*inptr++ != ' ')
goto exception;
-
+
/* size */
size = strtoul ((const char *) inptr, &p, 10);
/* check if the size wasn't negative */
goto exception;
inptr = (const unsigned char *) p;
-
+
if (camel_content_type_is (ctype, "message", "rfc822")) {
/* body_type_msg */
if (*inptr++ != ' ')
goto exception;
-
+
/* envelope */
imap_skip_list (&inptr);
-
+
if (!inptr || *inptr++ != ' ')
goto exception;
-
+
/* body */
if (!(child = imap_body_decode (&inptr, NULL, folder, cis)))
goto exception;
child->parent = ci;
-
+
if (!inptr || *inptr++ != ' ')
goto exception;
-
+
/* lines */
strtoul ((const char *) inptr, &p, 10);
inptr = (const unsigned char *) p;
} else if (camel_content_type_is (ctype, "text", "*")) {
if (!inptr || *inptr++ != ' ')
goto exception;
-
+
/* lines */
strtoul ((const char *) inptr, &p, 10);
inptr = (const unsigned char *) p;
} else {
/* body_type_basic */
}
-
+
if (!inptr || *inptr++ != ')')
goto exception;
-
+
ci->type = ctype;
ci->id = id;
ci->description = description;
ci->size = size;
ci->childs = child;
}
-
+
*in = inptr;
-
+
return ci;
-
+
exception:
-
+
camel_content_type_unref (ctype);
g_free (id);
g_free (description);
g_free (encoding);
-
+
return NULL;
}
CamelMessageContentInfo *child;
GPtrArray *children;
int i;
-
+
if (!inptr || *inptr != '(') {
*body_p = NULL;
return;
}
-
+
children = g_ptr_array_new ();
-
+
if (!(imap_body_decode (&inptr, ci, folder, children))) {
for (i = 0; i < children->len; i++) {
child = children->pdata[i];
-
+
/* content_info_free will free all the child
* nodes, but we don't want that. */
child->next = NULL;
child->parent = NULL;
child->childs = NULL;
-
+
camel_folder_summary_content_info_free (folder->summary, child);
}
*body_p = NULL;
} else {
*body_p = inptr;
}
-
+
g_ptr_array_free (children, TRUE);
}
const char *p;
char *quoted, *q;
int len;
-
+
g_assert (strchr (str, '\r') == NULL);
-
+
len = strlen (str);
p = str;
while ((p = strpbrk (p, "\"\\"))) {
len++;
p++;
}
-
+
quoted = q = g_malloc (len + 3);
*q++ = '"';
for (p = str; *p; ) {
}
*q++ = '"';
*q = '\0';
-
+
return quoted;
}
{
CamelMessageInfo *info;
unsigned long uid;
-
+
info = camel_folder_summary_index (summary, index);
uid = strtoul (camel_message_info_uid (info), NULL, 10);
camel_message_info_free(info);
* *not* included in the returned set string.
*
* Note: @uids MUST be in sorted order for this code to work properly.
- *
+ *
* Return value: the set, which the caller must free with g_free()
**/
char *
int si, scount;
GString *gset;
char *set;
-
+
g_return_val_if_fail (uids->len > uid, NULL);
-
+
gset = g_string_new (uids->pdata[uid]);
last_uid = strtoul (uids->pdata[uid], NULL, 10);
next_summary_uid = 0;
scount = camel_folder_summary_count (summary);
-
+
for (uid++, si = 0; uid < uids->len && !UID_SET_FULL (gset->len, maxlen); uid++) {
/* Find the next UID in the summary after the one we
* just wrote out.
next_summary_uid = get_summary_uid_numeric (summary, si);
if (last_uid >= next_summary_uid)
next_summary_uid = (unsigned long) -1;
-
+
/* Now get the next UID from @uids */
this_uid = strtoul (uids->pdata[uid], NULL, 10);
if (this_uid == next_summary_uid || this_uid == last_uid + 1)
}
g_string_append_printf (gset, ",%lu", this_uid);
}
-
+
last_uid = this_uid;
}
-
+
if (range)
g_string_append_printf (gset, ":%lu", last_uid);
-
+
*lastuid = uid;
-
+
set = gset->str;
g_string_free (gset, FALSE);
-
+
return set;
}
char *p, *q;
unsigned long uid, suid;
int si, scount;
-
+
arr = g_ptr_array_new ();
scount = camel_folder_summary_count (summary);
-
+
p = (char *)uids;
si = 0;
do {
if (p == q)
goto lose;
g_ptr_array_add (arr, g_strndup (p, q - p));
-
+
if (*q == ':') {
/* Find the summary entry for the UID after the one
* we just saw.
}
if (si >= scount)
suid = uid + 1;
-
+
uid = strtoul (q + 1, &p, 10);
if (p == q + 1)
goto lose;
-
+
/* Add each summary UID until we find one
* larger than the end of the range
*/
} else
p = q;
} while (*p++ == ',');
-
+
return arr;
-
+
lose:
g_warning ("Invalid uid set %s", uids);
imap_uid_array_free (arr);
imap_uid_array_free (GPtrArray *arr)
{
int i;
-
+
for (i = 0; i < arr->len; i++)
g_free (arr->pdata[i]);
g_ptr_array_free (arr, TRUE);
imap_concat (CamelImapStore *imap_store, const char *prefix, const char *suffix)
{
size_t len;
-
+
len = strlen (prefix);
if (len == 0 || prefix[len - 1] == imap_store->dir_sep)
return g_strdup_printf ("%s%s", prefix, suffix);
buf = g_alloca (inlen + 1);
memcpy (buf, in, inlen);
buf[inlen] = 0;
-
+
return camel_utf8_utf7 (buf);
}
imap_mailbox_decode (const unsigned char *in, size_t inlen)
{
char *buf;
-
+
buf = g_alloca (inlen + 1);
memcpy (buf, in, inlen);
buf[inlen] = 0;
-
+
return camel_utf7_utf8 (buf);
}
g_free (imap_wrapper->uid);
if (imap_wrapper->part)
g_free (imap_wrapper->part_spec);
-
+
g_mutex_free (imap_wrapper->priv->lock);
-
+
g_free (imap_wrapper->priv);
}
imap_wrapper_hydrate (CamelImapWrapper *imap_wrapper, CamelStream *stream)
{
CamelDataWrapper *data_wrapper = (CamelDataWrapper *) imap_wrapper;
-
+
camel_object_ref (stream);
data_wrapper->stream = stream;
data_wrapper->offline = FALSE;
-
+
camel_object_unref (imap_wrapper->folder);
imap_wrapper->folder = NULL;
g_free (imap_wrapper->uid);
write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
CamelImapWrapper *imap_wrapper = CAMEL_IMAP_WRAPPER (data_wrapper);
-
+
CAMEL_IMAP_WRAPPER_LOCK (imap_wrapper, lock);
if (data_wrapper->offline) {
CamelStream *datastream;
-
+
datastream = camel_imap_folder_fetch_data (
imap_wrapper->folder, imap_wrapper->uid,
imap_wrapper->part_spec, FALSE, NULL);
#endif
return -1;
}
-
+
imap_wrapper_hydrate (imap_wrapper, datastream);
camel_object_unref (datastream);
}
CAMEL_IMAP_WRAPPER_UNLOCK (imap_wrapper, lock);
-
+
return parent_class->write_to_stream (data_wrapper, stream);
}
imap4_string_get_type (const char *str)
{
int type = 0;
-
+
while (*str) {
if (!is_atom (*str)) {
if (is_qsafe (*str))
}
str++;
}
-
+
return type;
}
{
while (is_atom (*str))
str++;
-
+
return *str == '\0';
}
{
while (is_qsafe (*str))
str++;
-
+
return *str == '\0';
}
#endif
CamelStream *stream, *null;
CamelMimeFilter *crlf;
size_t len;
-
+
if (literal->type == CAMEL_IMAP4_LITERAL_STRING)
return strlen (literal->literal.string);
-
+
null = camel_stream_null_new ();
crlf = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
stream = (CamelStream *) camel_stream_filter_new_with_stream (null);
camel_stream_filter_add ((CamelStreamFilter *) stream, crlf);
camel_object_unref (crlf);
-
+
switch (literal->type) {
case CAMEL_IMAP4_LITERAL_STREAM:
camel_stream_write_to_stream (literal->literal.stream, stream);
g_assert_not_reached ();
break;
}
-
+
len = ((CamelStreamNull *) null)->written;
-
+
camel_object_unref (stream);
camel_object_unref (null);
-
+
return len;
}
command_part_new (void)
{
CamelIMAP4CommandPart *part;
-
+
part = g_new (CamelIMAP4CommandPart, 1);
part->next = NULL;
part->buffer = NULL;
part->buflen = 0;
part->literal = NULL;
-
+
return part;
}
{
CamelIMAP4CommandPart *part;
CamelIMAP4Literal *literal;
-
+
switch (imap4_string_get_type (string)) {
case IMAP4_STRING_ATOM:
/* string is safe as it is... */
literal = g_new (CamelIMAP4Literal, 1);
literal->type = CAMEL_IMAP4_LITERAL_STRING;
literal->literal.string = g_strdup (string);
-
+
g_string_append_printf (str, "{%lu}\r\n", strlen (string));
-
+
(*tail)->buffer = g_strdup (str->str);
(*tail)->buflen = str->len;
(*tail)->literal = literal;
-
+
part = command_part_new ();
(*tail)->next = part;
(*tail) = part;
-
+
g_string_truncate (str, 0);
}
break;
CamelIMAP4Command *ic;
const char *start;
GString *str;
-
+
tail = parts = command_part_new ();
-
+
str = g_string_new ("");
start = format;
-
+
while (*format) {
register char ch = *format++;
-
+
if (ch == '%') {
CamelIMAP4Literal *literal;
CamelIMAP4Folder *folder;
size_t len;
void *obj;
int c, d;
-
+
g_string_append_len (str, start, format - start - 1);
-
+
switch (*format) {
case '%':
/* literal % */
case 'L':
/* Literal */
obj = va_arg (args, void *);
-
+
literal = g_new (CamelIMAP4Literal, 1);
if (CAMEL_IS_DATA_WRAPPER (obj)) {
literal->type = CAMEL_IMAP4_LITERAL_WRAPPER;
} else {
g_assert_not_reached ();
}
-
+
camel_object_ref (obj);
-
+
/* FIXME: take advantage of LITERAL+? */
len = camel_imap4_literal_length (literal);
g_string_append_printf (str, "{%lu}\r\n", len);
-
+
tail->buffer = g_strdup (str->str);
tail->buflen = str->len;
tail->literal = literal;
-
+
part = command_part_new ();
tail->next = part;
tail = part;
-
+
g_string_truncate (str, 0);
-
+
break;
case 'V':
/* a string vector of arguments which may need to be quoted or made into literals */
while (*function != ' ')
function--;
function++;
-
+
function = g_strdup (function);
-
+
strv = va_arg (args, char **);
for (d = 0; strv[d]; d++) {
if (d > 0)
g_string_append (str, function);
imap4_command_append_string (engine, &tail, str, strv[d]);
}
-
+
g_free (function);
break;
case 'S':
g_string_append_c (str, *format);
break;
}
-
+
format++;
-
+
start = format;
}
}
-
+
g_string_append (str, start);
tail->buffer = str->str;
tail->buflen = str->len;
tail->literal = NULL;
g_string_free (str, FALSE);
-
+
ic = g_new0 (CamelIMAP4Command, 1);
((EDListNode *) ic)->next = NULL;
((EDListNode *) ic)->prev = NULL;
ic->ref_count = 1;
ic->parts = parts;
ic->part = parts;
-
+
camel_exception_init (&ic->ex);
-
+
if (imap4_folder) {
camel_object_ref (imap4_folder);
ic->folder = imap4_folder;
} else
ic->folder = NULL;
-
+
return ic;
}
{
CamelIMAP4Command *command;
va_list args;
-
+
va_start (args, format);
command = camel_imap4_command_newv (engine, folder, format, args);
va_end (args);
-
+
return command;
}
{
CamelIMAP4CommandPart *part, *next;
int i;
-
+
if (ic == NULL)
return;
-
+
ic->ref_count--;
if (ic->ref_count == 0) {
if (ic->folder)
camel_object_unref (ic->folder);
-
+
g_free (ic->tag);
-
+
for (i = 0; i < ic->resp_codes->len; i++) {
CamelIMAP4RespCode *resp_code;
-
+
resp_code = ic->resp_codes->pdata[i];
camel_imap4_resp_code_free (resp_code);
}
g_ptr_array_free (ic->resp_codes, TRUE);
-
+
g_hash_table_foreach (ic->untagged, (GHFunc) g_free, NULL);
g_hash_table_destroy (ic->untagged);
-
+
camel_exception_clear (&ic->ex);
-
+
part = ic->parts;
while (part != NULL) {
g_free (part->buffer);
camel_object_unref (part->literal->literal.wrapper);
break;
}
-
+
g_free (part->literal);
}
-
+
next = part->next;
g_free (part);
part = next;
}
-
+
g_free (ic);
}
}
CamelDataWrapper *wrapper;
CamelMimeFilter *crlf;
char *string;
-
+
if (literal->type == CAMEL_IMAP4_LITERAL_STRING) {
string = literal->literal.string;
if (camel_stream_write (stream, string, strlen (string)) == -1)
return -1;
-
+
return 0;
}
-
+
crlf = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
ostream = (CamelStream *) camel_stream_filter_new_with_stream (stream);
camel_stream_filter_add ((CamelStreamFilter *) ostream, crlf);
camel_object_unref (crlf);
-
+
/* write the literal */
switch (literal->type) {
case CAMEL_IMAP4_LITERAL_STREAM:
goto exception;
break;
}
-
+
camel_object_unref (ostream);
ostream = NULL;
-
+
#if 0
if (camel_stream_write (stream, "\r\n", 2) == -1)
return -1;
#endif
-
+
return 0;
-
+
exception:
-
+
camel_object_unref (ostream);
-
+
return -1;
}
camel_imap4_token_t token;
unsigned char *linebuf;
size_t len;
-
+
g_assert (ic->part != NULL);
-
+
if (ic->part == ic->parts) {
ic->tag = g_strdup_printf ("%c%.5u", engine->tagprefix, engine->tag++);
camel_stream_printf (engine->ostream, "%s ", ic->tag);
d(fprintf (stderr, "sending: %s ", ic->tag));
}
-
+
if (camel_debug ("imap4:command")) {
int sending = ic->part != ic->parts;
unsigned char *eoln, *eob;
-
+
linebuf = ic->part->buffer;
eob = linebuf + ic->part->buflen;
-
+
do {
eoln = linebuf;
while (eoln < eob && *eoln != '\n')
eoln++;
-
+
if (eoln < eob)
eoln++;
-
+
if (sending)
fwrite ("sending: ", 1, 10, stderr);
fwrite (linebuf, 1, eoln - linebuf, stderr);
-
+
linebuf = eoln + 1;
sending = 1;
} while (linebuf < eob);
}
-
+
linebuf = ic->part->buffer;
len = ic->part->buflen;
-
+
if (camel_stream_write (engine->ostream, linebuf, len) == -1) {
camel_exception_setv (&ic->ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed sending command to IMAP server %s: %s"),
engine->url->host, g_strerror (errno));
goto exception;
}
-
+
if (camel_stream_flush (engine->ostream) == -1) {
camel_exception_setv (&ic->ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed sending command to IMAP server %s: %s"),
engine->url->host, g_strerror (errno));
goto exception;
}
-
+
/* now we need to read the response(s) from the IMAP4 server */
-
+
do {
if (camel_imap4_engine_next_token (engine, &token, &ic->ex) == -1)
goto exception;
-
+
if (token.token == '+') {
/* we got a continuation response from the server */
literal = ic->part->literal;
-
+
if (camel_imap4_engine_line (engine, &linebuf, &len, &ic->ex) == -1)
goto exception;
-
+
if (literal) {
if (imap4_literal_write_to_stream (literal, engine->ostream) == -1)
goto exception;
-
+
g_free (linebuf);
linebuf = NULL;
-
+
break;
} else if (ic->plus) {
/* command expected a '+' response - probably AUTHENTICATE? */
g_free (linebuf);
return -1;
}
-
+
/* now we need to wait for a "<tag> OK/NO/BAD" response */
} else {
/* FIXME: error?? */
g_assert_not_reached ();
}
-
+
g_free (linebuf);
linebuf = NULL;
} else if (token.token == '*') {
} else if (token.token == CAMEL_IMAP4_TOKEN_ATOM && !strcmp (token.v.atom, ic->tag)) {
/* we got "<tag> OK/NO/BAD" */
d(fprintf (stderr, "got %s response\n", token.v.atom));
-
+
if (camel_imap4_engine_next_token (engine, &token, &ic->ex) == -1)
goto exception;
-
+
if (token.token == CAMEL_IMAP4_TOKEN_ATOM) {
if (!strcmp (token.v.atom, "OK"))
result = CAMEL_IMAP4_RESULT_OK;
result = CAMEL_IMAP4_RESULT_NO;
else if (!strcmp (token.v.atom, "BAD"))
result = CAMEL_IMAP4_RESULT_BAD;
-
+
if (result == CAMEL_IMAP4_RESULT_NONE) {
d(fprintf (stderr, "expected OK/NO/BAD but got %s\n", token.v.atom));
goto unexpected;
}
-
+
if (camel_imap4_engine_next_token (engine, &token, &ic->ex) == -1)
goto exception;
-
+
if (token.token == '[') {
/* we have a response code */
camel_imap4_stream_unget_token (engine->istream, &token);
unexpected_token (&token);
fprintf (stderr, "\n");
}
-
+
goto unexpected;
}
-
+
break;
} else {
if (camel_debug ("imap4:command")) {
unexpected_token (&token);
fprintf (stderr, "\n");
}
-
+
unexpected:
-
+
/* no fucking clue what we got... */
if (camel_imap4_engine_line (engine, &linebuf, &len, &ic->ex) == -1)
goto exception;
-
+
camel_exception_setv (&ic->ex, CAMEL_EXCEPTION_SYSTEM,
_("Unexpected response from IMAP4 server %s: %s"),
engine->url->host, linebuf);
-
+
g_free (linebuf);
-
+
goto exception;
}
} while (1);
-
+
/* status should always be ACTIVE here... */
if (ic->status == CAMEL_IMAP4_COMMAND_ACTIVE) {
ic->part = ic->part->next;
return 1;
}
}
-
+
return 0;
-
+
exception:
-
+
ic->status = CAMEL_IMAP4_COMMAND_ERROR;
-
+
return -1;
}
camel_imap4_command_reset (CamelIMAP4Command *ic)
{
int i;
-
+
for (i = 0; i < ic->resp_codes->len; i++)
camel_imap4_resp_code_free (ic->resp_codes->pdata[i]);
g_ptr_array_set_size (ic->resp_codes, 0);
-
+
ic->status = CAMEL_IMAP4_COMMAND_QUEUED;
ic->result = CAMEL_IMAP4_RESULT_NONE;
ic->part = ic->parts;
g_free (ic->tag);
ic->tag = NULL;
-
+
camel_exception_clear (&ic->ex);
}
struct _CamelIMAP4CommandPart *next;
unsigned char *buffer;
size_t buflen;
-
+
CamelIMAP4Literal *literal;
} CamelIMAP4CommandPart;
struct _CamelIMAP4Command {
EDListNode node;
-
+
struct _CamelIMAP4Engine *engine;
-
+
unsigned int ref_count:26;
unsigned int status:3;
unsigned int result:3;
int id;
-
+
char *tag;
-
+
GPtrArray *resp_codes;
-
+
struct _CamelIMAP4Folder *folder;
CamelException ex;
-
+
/* command parts - logical breaks in the overall command based on literals */
CamelIMAP4CommandPart *parts;
-
+
/* current part */
CamelIMAP4CommandPart *part;
-
+
/* untagged handlers */
GHashTable *untagged;
-
+
/* '+' callback/data */
CamelIMAP4PlusCallback plus;
void *user_data;
camel_imap4_engine_get_type (void)
{
static CamelType type = 0;
-
+
if (!type) {
type = camel_type_register (camel_object_get_type (),
"CamelIMAP4Engine",
(CamelObjectInitFunc) camel_imap4_engine_init,
(CamelObjectFinalizeFunc) camel_imap4_engine_finalize);
}
-
+
return type;
}
camel_imap4_engine_class_init (CamelIMAP4EngineClass *klass)
{
parent_class = camel_type_get_global_classfuncs (CAMEL_OBJECT_TYPE);
-
+
klass->tagprefix = 'A';
}
{
engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
engine->level = CAMEL_IMAP4_LEVEL_UNKNOWN;
-
+
engine->session = NULL;
engine->service = NULL;
engine->url = NULL;
-
+
engine->istream = NULL;
engine->ostream = NULL;
-
+
engine->authtypes = g_hash_table_new (g_str_hash, g_str_equal);
-
+
engine->capa = 0;
-
+
/* this is the suggested default, impacts the max command line length we'll send */
engine->maxlentype = CAMEL_IMAP4_ENGINE_MAXLEN_LINE;
engine->maxlen = 1000;
-
+
engine->namespaces.personal = NULL;
engine->namespaces.other = NULL;
engine->namespaces.shared = NULL;
-
+
if (klass->tagprefix > 'Z')
klass->tagprefix = 'A';
-
+
engine->tagprefix = klass->tagprefix++;
engine->tag = 0;
-
+
engine->nextid = 1;
-
+
engine->folder = NULL;
-
+
e_dlist_init (&engine->queue);
}
{
CamelIMAP4Engine *engine = (CamelIMAP4Engine *) object;
EDListNode *node;
-
+
if (engine->istream)
camel_object_unref (engine->istream);
-
+
if (engine->ostream)
camel_object_unref (engine->ostream);
-
+
g_hash_table_foreach (engine->authtypes, (GHFunc) g_free, NULL);
g_hash_table_destroy (engine->authtypes);
-
+
camel_imap4_namespace_clear (&engine->namespaces.personal);
camel_imap4_namespace_clear (&engine->namespaces.other);
camel_imap4_namespace_clear (&engine->namespaces.shared);
-
+
if (engine->folder)
camel_object_unref (engine->folder);
-
+
while ((node = e_dlist_remhead (&engine->queue))) {
node->next = NULL;
node->prev = NULL;
-
+
camel_imap4_command_unref ((CamelIMAP4Command *) node);
}
}
camel_imap4_engine_new (CamelService *service, CamelIMAP4ReconnectFunc reconnect)
{
CamelIMAP4Engine *engine;
-
+
g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
-
+
engine = (CamelIMAP4Engine *) camel_object_new (CAMEL_TYPE_IMAP4_ENGINE);
engine->session = service->session;
engine->url = service->url;
engine->service = service;
engine->reconnect = reconnect;
-
+
return engine;
}
{
camel_imap4_token_t token;
int code;
-
+
g_return_val_if_fail (CAMEL_IS_IMAP4_ENGINE (engine), -1);
g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
-
+
if (engine->istream)
camel_object_unref (engine->istream);
-
+
if (engine->ostream)
camel_object_unref (engine->ostream);
-
+
engine->istream = (CamelIMAP4Stream *) camel_imap4_stream_new (stream);
engine->ostream = camel_stream_buffer_new (stream, CAMEL_STREAM_BUFFER_WRITE);
engine->state = CAMEL_IMAP4_ENGINE_CONNECTED;
camel_object_unref (stream);
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
-
+
if (token.token != '*') {
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
if ((code = camel_imap4_engine_handle_untagged_1 (engine, &token, ex)) == -1) {
goto exception;
} else if (code != CAMEL_IMAP4_UNTAGGED_OK && code != CAMEL_IMAP4_UNTAGGED_PREAUTH) {
engine->url->host);
goto exception;
}
-
+
return 0;
-
+
exception:
-
+
engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
-
+
camel_object_unref (engine->istream);
engine->istream = NULL;
camel_object_unref (engine->ostream);
engine->ostream = NULL;
-
+
return -1;
}
{
CamelIMAP4Command *ic;
int id, retval = 0;
-
+
ic = camel_imap4_engine_prequeue (engine, NULL, "CAPABILITY\r\n");
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
retval = -1;
}
-
+
camel_imap4_command_unref (ic);
-
+
if (retval == -1 || !(engine->capa & CAMEL_IMAP4_CAPABILITY_XGWEXTENSIONS))
return retval;
-
+
ic = camel_imap4_engine_prequeue (engine, NULL, "XGWEXTENSIONS\r\n");
camel_imap4_command_register_untagged (ic, "XGWEXTENSIONS", parse_xgwextensions);
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
retval = -1;
}
-
+
camel_imap4_command_unref (ic);
-
+
return retval;
}
GPtrArray *array = NULL;
CamelIMAP4Command *ic;
int id, i;
-
+
if (engine->capa & CAMEL_IMAP4_CAPABILITY_NAMESPACE) {
ic = camel_imap4_engine_prequeue (engine, NULL, "NAMESPACE\r\n");
} else {
camel_imap4_command_register_untagged (ic, "LIST", camel_imap4_untagged_list);
ic->user_data = array = g_ptr_array_new ();
}
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
-
+
if (array != NULL)
g_ptr_array_free (array, TRUE);
-
+
return -1;
}
-
+
if (array != NULL) {
if (ic->result == CAMEL_IMAP4_RESULT_OK) {
CamelIMAP4Namespace *namespace;
-
+
g_assert (array->len >= 1);
list = array->pdata[0];
-
+
namespace = g_new (CamelIMAP4Namespace, 1);
namespace->next = NULL;
namespace->path = g_strdup ("");
namespace->sep = list->delim;
-
+
engine->namespaces.personal = namespace;
} else {
/* should never *ever* happen */
}
-
+
for (i = 0; i < array->len; i++) {
list = array->pdata[i];
g_free (list->name);
g_free (list);
}
-
+
g_ptr_array_free (array, TRUE);
}
-
+
camel_imap4_command_unref (ic);
-
+
return 0;
}
CamelIMAP4Command *ic;
int id, retval = 0;
int i;
-
+
g_return_val_if_fail (CAMEL_IS_IMAP4_ENGINE (engine), -1);
g_return_val_if_fail (CAMEL_IS_IMAP4_FOLDER (folder), -1);
-
+
/* POSSIBLE FIXME: if the folder to be selected will already
* be selected by the time the queue is emptied, simply
* no-op? */
-
+
ic = camel_imap4_engine_queue (engine, folder, "SELECT %F\r\n", folder);
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
return -1;
}
-
+
switch (ic->result) {
case CAMEL_IMAP4_RESULT_OK:
/*folder->mode = 0;*/
break;
}
}
-
+
/*if (folder->mode == 0) {
folder->mode = CAMEL_FOLDER_MODE_READ_ONLY;
g_warning ("Expected to find [READ-ONLY] or [READ-WRITE] in SELECT response");
}*/
-
+
break;
case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
g_assert_not_reached ();
retval = -1;
}
-
+
camel_imap4_command_unref (ic);
-
+
return retval;
}
parse_xgwextensions (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
{
int i;
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
while (token->token == CAMEL_IMAP4_TOKEN_ATOM) {
for (i = 0; imap4_xgwextensions[i].name; i++) {
if (!g_ascii_strcasecmp (imap4_xgwextensions[i].name, token->v.atom))
engine->capa |= imap4_xgwextensions[i].flag;
}
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
}
-
+
if (token->token != '\n') {
d(fprintf (stderr, "expected '\\n' at the end of the XGWEXTENSIONS response\n"));
goto unexpected;
}
-
+
return 0;
-
+
unexpected:
-
+
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
-
+
return -1;
}
{
camel_imap4_token_t token;
int i;
-
+
/* we assume UTF8 searches work until proven otherwise */
engine->capa = CAMEL_IMAP4_CAPABILITY_utf8_search;
engine->level = 0;
-
+
g_hash_table_foreach_remove (engine->authtypes, (GHRFunc) auth_free, NULL);
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
while (token.token == CAMEL_IMAP4_TOKEN_ATOM) {
if (!g_ascii_strncasecmp ("AUTH=", token.v.atom, 5)) {
CamelServiceAuthType *auth;
-
+
if ((auth = camel_sasl_authtype (token.v.atom + 5)) != NULL)
g_hash_table_insert (engine->authtypes, g_strdup (token.v.atom + 5), auth);
} else {
engine->capa |= imap4_capabilities[i].flag;
}
}
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
}
-
+
if (token.token != sentinel) {
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
/* unget our sentinel token */
camel_imap4_stream_unget_token (engine->istream, &token);
-
+
/* figure out which version of IMAP4 we are dealing with */
if (engine->capa & CAMEL_IMAP4_CAPABILITY_IMAP4REV1) {
engine->level = CAMEL_IMAP4_LEVEL_IMAP4REV1;
} else {
engine->level = CAMEL_IMAP4_LEVEL_UNKNOWN;
}
-
+
return 0;
}
engine_parse_flags_list (CamelIMAP4Engine *engine, CamelIMAP4RespCode *resp, int perm, CamelException *ex)
{
guint32 flags = 0;
-
+
if (camel_imap4_parse_flags_list (engine, &flags, ex) == -1)
return-1;
-
+
if (resp != NULL)
resp->v.flags = flags;
-
+
if (engine->current && engine->current->folder) {
if (perm)
((CamelFolder *) engine->current->folder)->permanent_flags = flags;
"response for a folder, yet we do not currently have a folder selected?\n",
perm ? "PERMANENTFLAGS" : "FLAGS");
}
-
+
return 0;
}
engine_parse_flags (CamelIMAP4Engine *engine, CamelException *ex)
{
camel_imap4_token_t token;
-
+
if (engine_parse_flags_list (engine, NULL, FALSE, ex) == -1)
return -1;
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != '\n') {
d(fprintf (stderr, "Expected to find a '\\n' token after the FLAGS response\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
return 0;
}
CamelIMAP4Namespace *namespaces[3], *node, *tail;
camel_imap4_token_t token;
int i, n = 0;
-
+
camel_imap4_namespace_clear (&engine->namespaces.personal);
camel_imap4_namespace_clear (&engine->namespaces.other);
camel_imap4_namespace_clear (&engine->namespaces.shared);
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
do {
namespaces[n] = NULL;
tail = (CamelIMAP4Namespace *) &namespaces[n];
-
+
if (token.token == '(') {
/* decode the list of namespace pairs */
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
-
+
while (token.token == '(') {
/* decode a namespace pair */
-
+
/* get the path name token */
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
-
+
if (token.token != CAMEL_IMAP4_TOKEN_QSTRING) {
d(fprintf (stderr, "Expected to find a qstring token as first element in NAMESPACE pair\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
node = g_new (CamelIMAP4Namespace, 1);
node->next = NULL;
node->path = g_strdup (token.v.qstring);
-
+
/* get the path delimiter token */
if (camel_imap4_engine_next_token (engine, &token, ex) == -1) {
g_free (node->path);
g_free (node);
-
+
goto exception;
}
-
+
switch (token.token) {
case CAMEL_IMAP4_TOKEN_NIL:
node->sep = '\0';
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
g_free (node->path);
g_free (node);
-
+
goto exception;
}
-
+
tail->next = node;
tail = node;
-
+
/* canonicalise the namespace path */
if (node->path[strlen (node->path) - 1] == node->sep)
node->path[strlen (node->path) - 1] = '\0';
-
+
/* canonicalise if this is an INBOX namespace */
if (!g_ascii_strncasecmp (node->path, "INBOX", 5) &&
(node->path[6] == '\0' || node->path[6] == node->sep))
memcpy (node->path, "INBOX", 5);
-
+
/* get the closing ')' for this namespace pair */
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
-
+
if (token.token != ')') {
d(fprintf (stderr, "Expected to find a ')' token to close the current namespace pair\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
-
+
goto exception;
}
-
+
/* get the next token (should be either '(' or ')') */
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
}
-
+
if (token.token != ')') {
d(fprintf (stderr, "Expected to find a ')' to close the current namespace list\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
/* get the next token (should be either '(', NIL, or '\n') */
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
-
+
n++;
} while (n < 3);
-
+
engine->namespaces.personal = namespaces[0];
engine->namespaces.other = namespaces[1];
engine->namespaces.shared = namespaces[2];
-
+
return 0;
-
+
exception:
-
+
for (i = 0; i <= n; i++)
camel_imap4_namespace_clear (&namespaces[i]);
-
+
return -1;
}
camel_imap4_token_t token;
unsigned char *linebuf;
size_t len;
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != '[') {
d(fprintf (stderr, "Expected a '[' token (followed by a RESP-CODE)\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != CAMEL_IMAP4_TOKEN_ATOM) {
d(fprintf (stderr, "Expected an atom token containing a RESP-CODE\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
for (code = 0; imap4_resp_codes[code].name; code++) {
if (!strcmp (imap4_resp_codes[code].name, token.v.atom)) {
if (engine->current && imap4_resp_codes[code].save) {
break;
}
}
-
+
switch (code) {
case CAMEL_IMAP4_RESP_CODE_ALERT:
/* nothing to do here, handled after switch statement */
case CAMEL_IMAP4_RESP_CODE_UIDNEXT:
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
-
+
if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as an argument to the UIDNEXT RESP-CODE\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
if (resp != NULL)
resp->v.uidnext = token.v.number;
-
+
break;
case CAMEL_IMAP4_RESP_CODE_UIDVALIDITY:
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
-
+
if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as an argument to the UIDVALIDITY RESP-CODE\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
if (resp != NULL)
resp->v.uidvalidity = token.v.number;
-
+
break;
case CAMEL_IMAP4_RESP_CODE_UNSEEN:
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as an argument to the UNSEEN RESP-CODE\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
if (resp != NULL)
resp->v.unseen = token.v.number;
-
+
break;
case CAMEL_IMAP4_RESP_CODE_NEWNAME:
/* this RESP-CODE may actually be removed - see here:
* http://www.washington.edu/imap4/listarch/2001/msg00058.html */
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != CAMEL_IMAP4_TOKEN_ATOM && token.token != CAMEL_IMAP4_TOKEN_QSTRING) {
d(fprintf (stderr, "Expected an atom or qstring token as the first argument to the NEWNAME RESP-CODE\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
if (resp != NULL)
resp->v.newname[0] = g_strdup (token.v.atom);
-
+
if (token.token != CAMEL_IMAP4_TOKEN_ATOM && token.token != CAMEL_IMAP4_TOKEN_QSTRING) {
d(fprintf (stderr, "Expected an atom or qstring token as the second argument to the NEWNAME RESP-CODE\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
if (resp != NULL)
resp->v.newname[1] = g_strdup (token.v.atom);
-
+
break;
case CAMEL_IMAP4_RESP_CODE_APPENDUID:
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as the first argument to the APPENDUID RESP-CODE\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
if (resp != NULL)
resp->v.appenduid.uidvalidity = token.v.number;
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as the second argument to the APPENDUID RESP-CODE\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
if (resp != NULL)
resp->v.appenduid.uid = token.v.number;
-
+
break;
case CAMEL_IMAP4_RESP_CODE_COPYUID:
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an nz_number token as the first argument to the COPYUID RESP-CODE\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
if (resp != NULL)
resp->v.copyuid.uidvalidity = token.v.number;
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != CAMEL_IMAP4_TOKEN_ATOM && token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an atom or numeric token as the second argument to the COPYUID RESP-CODE\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
if (resp != NULL) {
if (token.token == CAMEL_IMAP4_TOKEN_NUMBER)
resp->v.copyuid.srcset = g_strdup_printf ("%lu", token.v.number);
else
resp->v.copyuid.srcset = g_strdup (token.v.atom);
}
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != CAMEL_IMAP4_TOKEN_ATOM && token.token != CAMEL_IMAP4_TOKEN_NUMBER) {
d(fprintf (stderr, "Expected an atom or numeric token as the third argument to the APPENDUID RESP-CODE\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
if (resp != NULL) {
if (token.token == CAMEL_IMAP4_TOKEN_NUMBER)
resp->v.copyuid.destset = g_strdup_printf ("%lu", token.v.number);
else
resp->v.copyuid.destset = g_strdup (token.v.atom);
}
-
+
break;
default:
d(fprintf (stderr, "Unknown RESP-CODE encountered: %s\n", token.v.atom));
-
+
/* extensions are of the form: "[" atom [SPACE 1*<any TEXT_CHAR except "]">] "]" */
-
+
/* eat up the TEXT_CHARs */
while (token.token != ']' && token.token != '\n') {
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
}
-
+
break;
}
-
+
while (token.token != ']' && token.token != '\n') {
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
}
-
+
if (token.token != ']') {
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
d(fprintf (stderr, "Expected to find a ']' token after the RESP-CODE\n"));
return -1;
}
-
+
if (code == CAMEL_IMAP4_RESP_CODE_ALERT) {
if (camel_imap4_engine_line (engine, &linebuf, &len, ex) == -1)
goto exception;
-
+
camel_session_alert_user (engine->session, CAMEL_SESSION_ALERT_INFO, linebuf, FALSE);
g_free (linebuf);
} else if (resp != NULL && code == CAMEL_IMAP4_RESP_CODE_PARSE) {
if (camel_imap4_engine_line (engine, &linebuf, &len, ex) == -1)
goto exception;
-
+
resp->v.parse = linebuf;
} else {
/* eat up the rest of the response */
if (camel_imap4_engine_line (engine, NULL, NULL, ex) == -1)
goto exception;
}
-
+
if (resp != NULL)
g_ptr_array_add (engine->current->resp_codes, resp);
-
+
return 0;
-
+
exception:
-
+
if (resp != NULL)
camel_imap4_resp_code_free (resp);
-
+
return -1;
}
CamelIMAP4UntaggedCallback untagged;
CamelFolder *folder;
unsigned int v;
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
if (token->token == CAMEL_IMAP4_TOKEN_ATOM) {
if (!strcmp ("BYE", token->v.atom)) {
/* we don't care if we fail here, either way we've been disconnected */
camel_imap4_engine_line (engine, NULL, NULL, NULL);
}
}
-
+
engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
-
+
/* we don't return -1 here because there may be more untagged responses after the BYE */
} else if (!strcmp ("CAPABILITY", token->v.atom)) {
/* capability tokens follow */
if (engine_parse_capability (engine, '\n', ex) == -1)
return -1;
-
+
/* find the eoln token */
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
if (token->token != '\n') {
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
return -1;
} else if (!strcmp ("NO", token->v.atom) || !strcmp ("BAD", token->v.atom)) {
code = !strcmp ("NO", token->v.atom) ? CAMEL_IMAP4_UNTAGGED_NO : CAMEL_IMAP4_UNTAGGED_BAD;
-
+
/* our command has been rejected */
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
if (token->token == '[') {
/* we have a resp code */
camel_imap4_stream_unget_token (engine->istream, token);
}
} else if (!strcmp ("OK", token->v.atom)) {
code = CAMEL_IMAP4_UNTAGGED_OK;
-
+
if (engine->state == CAMEL_IMAP4_ENGINE_CONNECTED) {
/* initial server greeting */
engine->state = CAMEL_IMAP4_ENGINE_PREAUTH;
}
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
if (token->token == '[') {
/* we have a resp code */
camel_imap4_stream_unget_token (engine->istream, token);
}
} else if (!strcmp ("PREAUTH", token->v.atom)) {
code = CAMEL_IMAP4_UNTAGGED_PREAUTH;
-
+
if (engine->state == CAMEL_IMAP4_ENGINE_CONNECTED)
engine->state = CAMEL_IMAP4_ENGINE_AUTHENTICATED;
-
+
if (camel_imap4_engine_parse_resp_code (engine, ex) == -1)
return -1;
} else if (ic && (untagged = g_hash_table_lookup (ic->untagged, token->v.atom))) {
return -1;
} else {
d(fprintf (stderr, "Unhandled atom token in untagged response: %s", token->v.atom));
-
+
if (camel_imap4_engine_eat_line (engine, ex) == -1)
return -1;
}
} else if (token->token == CAMEL_IMAP4_TOKEN_NUMBER) {
/* we probably have something like "* 1 EXISTS" */
v = token->v.number;
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
if (token->token != CAMEL_IMAP4_TOKEN_ATOM) {
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
-
+
return -1;
}
-
+
/* which folder is this EXISTS/EXPUNGE/RECENT acting on? */
if (engine->current && engine->current->folder)
folder = (CamelFolder *) engine->current->folder;
folder = (CamelFolder *) engine->folder;
else
folder = NULL;
-
+
/* NOTE: these can be over-ridden by a registered untagged response handler */
if (!strcmp ("EXISTS", token->v.atom)) {
camel_imap4_summary_set_exists (folder->summary, v);
} else {
d(fprintf (stderr, "Unrecognized untagged response: * %lu %s\n", v, token->v.atom));
}
-
+
/* find the eoln token */
if (camel_imap4_engine_eat_line (engine, ex) == -1)
return -1;
} else {
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
-
+
return -1;
}
-
+
return code;
}
camel_imap4_engine_handle_untagged (CamelIMAP4Engine *engine, CamelException *ex)
{
camel_imap4_token_t token;
-
+
g_return_if_fail (CAMEL_IS_IMAP4_ENGINE (engine));
-
+
do {
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
-
+
if (token.token != '*')
break;
-
+
if (camel_imap4_engine_handle_untagged_1 (engine, &token, ex) == -1)
goto exception;
} while (1);
-
+
camel_imap4_stream_unget_token (engine->istream, &token);
-
+
return;
-
+
exception:
-
+
engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
}
imap4_process_command (CamelIMAP4Engine *engine, CamelIMAP4Command *ic)
{
int retval;
-
+
while ((retval = camel_imap4_command_step (ic)) == 0)
;
-
+
if (retval == -1) {
engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
return -1;
}
-
+
return 0;
}
{
CamelIMAP4Command *ic;
const char *cmd;
-
+
ic = (CamelIMAP4Command *) engine->queue.head;
cmd = (const char *) ic->parts->buffer;
-
+
if (!ic->folder || ic->folder == engine->folder ||
!strncmp (cmd, "SELECT ", 7) || !strncmp (cmd, "EXAMINE ", 8)) {
/* no need to pre-queue a SELECT */
return;
}
-
+
/* we need to pre-queue a SELECT */
ic = camel_imap4_engine_prequeue (engine, (CamelFolder *) ic->folder, "SELECT %F\r\n", ic->folder);
ic->user_data = engine;
-
+
camel_imap4_command_unref (ic);
}
{
const char *cmd;
int retval = 0;
-
+
cmd = ic->parts->buffer;
if (!strncmp (cmd, "SELECT ", 7) || !strncmp (cmd, "EXAMINE ", 8)) {
if (ic->result == CAMEL_IMAP4_RESULT_OK) {
if (engine->folder)
camel_object_unref (engine->folder);
engine->folder = ic->folder;
-
+
engine->state = CAMEL_IMAP4_ENGINE_SELECTED;
} else if (ic->user_data == engine) {
/* the engine pre-queued this SELECT command */
} else if (!strncmp (cmd, "LOGOUT", 6)) {
engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
}
-
+
return retval;
}
CamelIMAP4Command *ic, *nic;
GPtrArray *resp_codes;
int retval = -1;
-
+
if (e_dlist_empty (&engine->queue))
return 0;
-
+
/* This sucks... it would be nicer if we didn't have to check the stream's disconnected status */
if ((engine->state == CAMEL_IMAP4_ENGINE_DISCONNECTED || engine->istream->disconnected) && !engine->reconnecting) {
CamelException rex;
gboolean connected;
-
+
camel_exception_init (&rex);
engine->reconnecting = TRUE;
connected = engine->reconnect (engine, &rex);
engine->reconnecting = FALSE;
-
+
if (!connected) {
/* pop the first command and act as tho it failed (which, technically, it did...) */
ic = (CamelIMAP4Command *) e_dlist_remhead (&engine->queue);
ic->status = CAMEL_IMAP4_COMMAND_ERROR;
camel_exception_xfer (&ic->ex, &rex);
camel_imap4_command_unref (ic);
-
+
/* FIXME: in a perfect world, if the connect failure was due to the user cancelling the
* passwd dialog, we'd either send a LOGOUT command here -or- we'd leave the connection
* open but in the PREAUTH state that we'd later be able to handle if the user queued
engine->istream = NULL;
camel_object_unref (engine->ostream);
engine->ostream = NULL;
-
+
return -1;
}
}
-
+
/* check to see if we need to pre-queue a SELECT, if so do it */
engine_prequeue_folder_select (engine);
-
+
engine->current = ic = (CamelIMAP4Command *) e_dlist_remhead (&engine->queue);
ic->status = CAMEL_IMAP4_COMMAND_ACTIVE;
-
+
if (imap4_process_command (engine, ic) != -1) {
if (engine_state_change (engine, ic) == -1) {
/* This can ONLY happen if @ic was the pre-queued SELECT command
* information as possible, we move all @ic status information
* over to @nic and pretend we just processed @nic.
**/
-
+
nic = (CamelIMAP4Command *) e_dlist_remhead (&engine->queue);
-
+
nic->status = ic->status;
nic->result = ic->result;
resp_codes = nic->resp_codes;
nic->resp_codes = ic->resp_codes;
ic->resp_codes = resp_codes;
-
+
camel_exception_xfer (&nic->ex, &ic->ex);
-
+
camel_imap4_command_unref (ic);
ic = nic;
}
-
+
retval = ic->id;
}
-
+
camel_imap4_command_unref (ic);
-
+
return retval;
}
{
CamelIMAP4Command *ic;
va_list args;
-
+
g_return_val_if_fail (CAMEL_IS_IMAP4_ENGINE (engine), NULL);
-
+
va_start (args, format);
ic = camel_imap4_command_newv (engine, (CamelIMAP4Folder *) folder, format, args);
va_end (args);
-
+
ic->id = engine->nextid++;
e_dlist_addtail (&engine->queue, (EDListNode *) ic);
camel_imap4_command_ref (ic);
-
+
return ic;
}
{
CamelIMAP4Command *ic;
va_list args;
-
+
g_return_val_if_fail (CAMEL_IS_IMAP4_ENGINE (engine), NULL);
-
+
va_start (args, format);
ic = camel_imap4_command_newv (engine, (CamelIMAP4Folder *) folder, format, args);
va_end (args);
-
+
if (e_dlist_empty (&engine->queue)) {
e_dlist_addtail (&engine->queue, (EDListNode *) ic);
ic->id = engine->nextid++;
} else {
CamelIMAP4Command *nic;
EDListNode *node;
-
+
node = (EDListNode *) ic;
e_dlist_addhead (&engine->queue, node);
nic = (CamelIMAP4Command *) node->next;
ic->id = nic->id - 1;
-
+
if (ic->id == 0) {
/* increment all command ids */
node = engine->queue.head;
}
}
}
-
+
camel_imap4_command_ref (ic);
-
+
return ic;
}
camel_imap4_engine_dequeue (CamelIMAP4Engine *engine, CamelIMAP4Command *ic)
{
EDListNode *node = (EDListNode *) ic;
-
+
if (node->next == NULL && node->prev == NULL)
return;
-
+
e_dlist_remove (node);
node->next = NULL;
node->prev = NULL;
-
+
camel_imap4_command_unref (ic);
}
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("IMAP4 server %s unexpectedly disconnected: %s"),
engine->url->host, errno ? g_strerror (errno) : _("Unknown"));
-
+
engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
-
+
return -1;
}
-
+
return 0;
}
unsigned char *literal;
int retval;
size_t n;
-
+
do {
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token == CAMEL_IMAP4_TOKEN_LITERAL) {
while ((retval = camel_imap4_stream_literal (engine->istream, &literal, &n)) == 1)
;
-
+
if (retval == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("IMAP4 server %s unexpectedly disconnected: %s"),
engine->url->host, errno ? g_strerror (errno) : _("Unknown"));
-
+
engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
-
+
return -1;
}
}
} while (token.token != '\n');
-
+
return 0;
}
unsigned char *buf;
size_t buflen;
int retval;
-
+
if (line != NULL)
linebuf = g_byte_array_new ();
-
+
while ((retval = camel_imap4_stream_line (engine->istream, &buf, &buflen)) > 0) {
if (linebuf != NULL)
g_byte_array_append (linebuf, buf, buflen);
}
-
+
if (retval == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("IMAP4 server %s unexpectedly disconnected: %s"),
engine->url->host, errno ? g_strerror (errno) : _("Unknown"));
-
+
if (linebuf != NULL)
g_byte_array_free (linebuf, TRUE);
-
+
engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
-
+
return -1;
}
-
+
if (linebuf != NULL) {
g_byte_array_append (linebuf, buf, buflen);
-
+
*line = linebuf->data;
*len = linebuf->len;
-
+
g_byte_array_free (linebuf, FALSE);
}
-
+
return 0;
}
unsigned char *buf;
size_t buflen;
int retval;
-
+
if (literal != NULL)
literalbuf = g_byte_array_new ();
-
+
while ((retval = camel_imap4_stream_literal (engine->istream, &buf, &buflen)) > 0) {
if (literalbuf != NULL)
g_byte_array_append (literalbuf, buf, buflen);
}
-
+
if (retval == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("IMAP4 server %s unexpectedly disconnected: %s"),
engine->url->host, errno ? g_strerror (errno) : _("Unknown"));
-
+
if (literalbuf != NULL)
g_byte_array_free (literalbuf, TRUE);
-
+
engine->state = CAMEL_IMAP4_ENGINE_DISCONNECTED;
-
+
return -1;
}
-
+
if (literalbuf != NULL) {
g_byte_array_append (literalbuf, buf, buflen);
g_byte_array_append (literalbuf, "", 1);
-
+
*literal = literalbuf->data;
*len = literalbuf->len - 1;
-
+
g_byte_array_free (literalbuf, FALSE);
}
-
+
return 0;
}
{
camel_imap4_token_t token;
size_t n;
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
switch (token.token) {
case CAMEL_IMAP4_TOKEN_NIL:
*nstring = NULL;
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
return 0;
}
default:
break;
}
-
+
g_free (rcode);
}
CAMEL_IMAP4_CAPABILITY_ACL = (1 << 10),
CAMEL_IMAP4_CAPABILITY_MULTIAPPEND = (1 << 11),
CAMEL_IMAP4_CAPABILITY_UNSELECT = (1 << 12),
-
+
CAMEL_IMAP4_CAPABILITY_XGWEXTENSIONS = (1 << 16),
CAMEL_IMAP4_CAPABILITY_XGWMOVE = (1 << 17),
-
+
CAMEL_IMAP4_CAPABILITY_useful_lsub = (1 << 30),
CAMEL_IMAP4_CAPABILITY_utf8_search = (1 << 31),
};
struct _CamelIMAP4Engine {
CamelObject parent_object;
-
+
CamelIMAP4ReconnectFunc reconnect;
gboolean reconnecting;
-
+
CamelSession *session;
CamelService *service;
CamelURL *url;
-
+
camel_imap4_engine_t state;
camel_imap4_level_t level;
guint32 capa;
-
+
guint32 maxlen:31;
guint32 maxlentype:1;
-
+
CamelIMAP4NamespaceList namespaces;
GHashTable *authtypes; /* supported authtypes */
-
+
struct _CamelIMAP4Stream *istream;
CamelStream *ostream;
-
+
unsigned char tagprefix; /* 'A'..'Z' */
unsigned int tag; /* next command tag */
int nextid;
-
+
struct _CamelIMAP4Folder *folder; /* currently selected folder */
-
+
EDList queue; /* queue of waiting commands */
struct _CamelIMAP4Command *current;
};
struct _CamelIMAP4EngineClass {
CamelObjectClass parent_class;
-
+
unsigned char tagprefix;
};
camel_imap4_folder_get_type (void)
{
static CamelType type = 0;
-
+
if (!type) {
type = camel_type_register (camel_offline_folder_get_type (),
"CamelIMAP4Folder",
(CamelObjectInitFunc) camel_imap4_folder_init,
(CamelObjectFinalizeFunc) camel_imap4_folder_finalize);
}
-
+
return type;
}
CamelFolderClass *folder_class = (CamelFolderClass *) klass;
CamelObjectClass *object_class = (CamelObjectClass *) klass;
int i;
-
+
parent_class = (CamelOfflineFolderClass *) camel_type_get_global_classfuncs (CAMEL_OFFLINE_FOLDER_TYPE);
-
+
if (imap4_folder_props == NULL) {
for (i = 0; i < G_N_ELEMENTS (imap4_prop_list); i++) {
imap4_prop_list[i].description = _(imap4_prop_list[i].description);
imap4_folder_props = g_slist_prepend (imap4_folder_props, &imap4_prop_list[i]);
}
}
-
+
object_class->getv = imap4_getv;
object_class->setv = imap4_setv;
-
+
folder_class->sync = imap4_sync;
folder_class->refresh_info = imap4_refresh_info;
folder_class->expunge = imap4_expunge;
camel_imap4_folder_init (CamelIMAP4Folder *folder, CamelIMAP4FolderClass *klass)
{
((CamelFolder *) folder)->folder_flags |= CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY | CAMEL_FOLDER_HAS_SEARCH_CAPABILITY;
-
+
folder->utf7_name = NULL;
folder->cachedir = NULL;
folder->journal = NULL;
camel_imap4_folder_finalize (CamelObject *object)
{
CamelIMAP4Folder *folder = (CamelIMAP4Folder *) object;
-
+
camel_object_unref (folder->search);
-
+
if (folder->cache)
camel_object_unref (folder->cache);
-
+
if (folder->journal) {
camel_offline_journal_write (folder->journal, NULL);
camel_object_unref (folder->journal);
}
-
+
g_free (folder->utf7_name);
g_free (folder->cachedir);
}
CamelArgGetV props;
int i, count = 0;
guint32 tag;
-
+
for (i = 0; i < args->argc; i++) {
CamelArgGet *arg = &args->argv[i];
-
+
tag = arg->tag;
-
+
switch (tag & CAMEL_ARG_TAG) {
case CAMEL_OBJECT_ARG_PERSISTENT_PROPERTIES:
case CAMEL_FOLDER_ARG_PROPERTIES:
count++;
continue;
}
-
+
arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
}
-
+
if (count)
return ((CamelObjectClass *) parent_class)->getv (object, ex, args);
-
+
return 0;
}
gboolean save = FALSE;
guint32 tag;
int i;
-
+
for (i = 0; i < args->argc; i++) {
CamelArg *arg = &args->argv[i];
-
+
tag = arg->tag;
-
+
switch (tag & CAMEL_ARG_TAG) {
case CAMEL_IMAP4_FOLDER_ARG_ENABLE_MLIST:
if (folder->enable_mlist != arg->ca_int) {
default:
continue;
}
-
+
arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
}
-
+
if (save)
camel_object_state_write (object);
-
+
return ((CamelObjectClass *) parent_class)->setv (object, ex, args);
}
const char *inptr = full_name;
int subdirs = 0;
char *path, *p;
-
+
if (*full_name == '\0')
return g_strdup (toplevel_dir);
-
+
while (*inptr != '\0') {
if (*inptr == '/')
subdirs++;
inptr++;
}
-
+
path = g_malloc (strlen (toplevel_dir) + (inptr - full_name) + (12 * subdirs) + 2);
p = g_stpcpy (path, toplevel_dir);
-
+
if (p[-1] != '/')
*p++ = '/';
-
+
inptr = full_name;
while (*inptr != '\0') {
while (*inptr != '/' && *inptr != '\0')
*p++ = *inptr++;
-
+
if (*inptr == '/') {
p = g_stpcpy (p, "/subfolders/");
inptr++;
-
+
/* strip extranaeous '/'s */
while (*inptr == '/')
inptr++;
}
}
-
+
*p = '\0';
-
+
return path;
}
CamelIMAP4Store *imap4_store = (CamelIMAP4Store *) store;
char *toplevel_dir;
char *path;
-
+
toplevel_dir = g_strdup_printf ("%s/folders", imap4_store->storage_path);
path = imap4_build_filename (toplevel_dir, full_name);
g_free (toplevel_dir);
-
+
return path;
}
CamelFolder *folder;
char *path;
char sep;
-
+
if (!(p = strrchr (full_name, '/')))
p = (char *) full_name;
else
p++;
-
+
name = g_alloca (strlen (p) + 1);
strcpy (name, p);
-
+
utf7_name = g_alloca (strlen (full_name) + 1);
strcpy (utf7_name, full_name);
-
+
sep = camel_imap4_get_path_delim (((CamelIMAP4Store *) store)->summary, full_name);
if (sep != '/') {
p = utf7_name;
p++;
}
}
-
+
utf7_name = camel_utf8_utf7 (utf7_name);
-
+
folder = (CamelFolder *) (imap4_folder = (CamelIMAP4Folder *) camel_object_new (CAMEL_TYPE_IMAP4_FOLDER));
camel_folder_construct (folder, store, full_name, name);
imap4_folder->utf7_name = utf7_name;
-
+
folder->summary = camel_imap4_summary_new (folder);
imap4_folder->cachedir = imap4_store_build_filename (store, folder->full_name);
g_mkdir_with_parents (imap4_folder->cachedir, 0777);
-
+
imap4_folder->cache = camel_data_cache_new (imap4_folder->cachedir, 0, NULL);
-
+
path = imap4_get_summary_filename (imap4_folder->cachedir);
camel_folder_summary_set_filename (folder->summary, path);
g_free (path);
-
+
path = imap4_get_journal_filename (imap4_folder->cachedir);
imap4_folder->journal = camel_imap4_journal_new (imap4_folder, path);
g_free (path);
-
+
path = g_build_filename (imap4_folder->cachedir, "cmeta", NULL);
camel_object_set (folder, NULL, CAMEL_OBJECT_STATE_FILE, path, NULL);
g_free (path);
-
+
if (camel_object_state_read (folder) == -1) {
/* set our defaults */
imap4_folder->enable_mlist = TRUE;
}
-
+
if (!g_ascii_strcasecmp (full_name, "INBOX")) {
if (camel_url_get_param (((CamelService *) store)->url, "filter"))
folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
if (camel_url_get_param (((CamelService *) store)->url, "filter_junk"))
folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK;
}
-
+
imap4_folder->search = camel_imap4_search_new (((CamelIMAP4Store *) store)->engine, imap4_folder->cachedir);
-
+
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
/* we don't care if the summary loading fails here */
camel_folder_summary_load (folder->summary);
-
+
if (camel_imap4_engine_select_folder (((CamelIMAP4Store *) store)->engine, folder, ex) == -1) {
camel_object_unref (folder);
folder = NULL;
}
-
+
if (folder && camel_imap4_summary_flush_updates (folder->summary, ex) == -1) {
camel_object_unref (folder);
folder = NULL;
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
_("Cannot access folder `%s': %s"),
full_name, g_strerror (ENOENT));
-
+
camel_object_unref (folder);
folder = NULL;
}
}
-
+
return folder;
}
CamelIMAP4Command *ic;
int i, id, retval = 0;
char *set = NULL;
-
+
for (i = 0; i < infos->len; ) {
i += camel_imap4_get_uid_set (engine, folder->summary, infos, i, 30 + strlen (flag), &set);
-
+
ic = camel_imap4_engine_queue (engine, folder, "UID STORE %s %cFLAGS.SILENT (%s)\r\n", set, onoff, flag);
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
g_free (set);
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
-
+
return -1;
}
-
+
switch (ic->result) {
case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
retval = -1;
break;
}
-
+
camel_imap4_command_unref (ic);
-
+
if (retval == -1)
return -1;
}
-
+
return 0;
}
flags_diff_t diff;
int retval = 0;
int i, j;
-
+
on_set = g_ptr_array_new ();
off_set = g_ptr_array_new ();
-
+
/* construct commands to sync system and user flags */
for (i = 0; i < G_N_ELEMENTS (imap4_flags); i++) {
if (!(imap4_flags[i].flag & folder->permanent_flags))
continue;
-
+
for (j = 0; j < sync->len; j++) {
iinfo = (CamelIMAP4MessageInfo *) (info = sync->pdata[j]);
camel_imap4_flags_diff (&diff, iinfo->server_flags, iinfo->info.flags);
}
}
}
-
+
if (on_set->len > 0) {
if ((retval = imap4_sync_flag (folder, on_set, '+', imap4_flags[i].name, ex)) == -1)
break;
-
+
g_ptr_array_set_size (on_set, 0);
}
-
+
if (off_set->len > 0) {
if ((retval = imap4_sync_flag (folder, off_set, '-', imap4_flags[i].name, ex)) == -1)
break;
-
+
g_ptr_array_set_size (off_set, 0);
}
}
-
+
g_ptr_array_free (on_set, TRUE);
g_ptr_array_free (off_set, TRUE);
-
+
if (retval == -1)
return-1;
-
+
for (i = 0; i < sync->len; i++) {
iinfo = (CamelIMAP4MessageInfo *) (info = sync->pdata[i]);
iinfo->info.flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED;
iinfo->server_flags = iinfo->info.flags & folder->permanent_flags;
}
-
+
return 0;
}
GPtrArray *sync;
int id, max, i;
int retval;
-
+
if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return;
-
+
CAMEL_SERVICE_REC_LOCK (folder->parent_store, connect_lock);
-
+
/* gather a list of changes to sync to the server */
if (folder->permanent_flags) {
sync = g_ptr_array_new ();
if (iinfo->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED) {
camel_imap4_flags_diff (&diff, iinfo->server_flags, iinfo->info.flags);
diff.changed &= folder->permanent_flags;
-
+
/* weed out flag changes that we can't sync to the server */
if (!diff.changed)
camel_message_info_free(info);
camel_message_info_free(info);
}
}
-
+
if (sync->len > 0) {
retval = imap4_sync_changes (folder, sync, ex);
-
+
for (i = 0; i < sync->len; i++)
camel_message_info_free(sync->pdata[i]);
-
+
g_ptr_array_free (sync, TRUE);
-
+
if (retval == -1)
goto done;
} else {
g_ptr_array_free (sync, TRUE);
}
}
-
+
if (expunge && !((CamelIMAP4Folder *) folder)->read_only) {
ic = camel_imap4_engine_queue (engine, folder, "EXPUNGE\r\n");
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
switch (ic->result) {
case CAMEL_IMAP4_RESULT_OK:
camel_imap4_summary_flush_updates (folder->summary, ex);
folder->full_name);
break;
}
-
+
camel_imap4_command_unref (ic);
} else {
camel_imap4_summary_flush_updates (folder->summary, ex);
}
-
+
camel_folder_summary_save (folder->summary);
-
+
done:
-
+
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
}
CamelFolder *selected = (CamelFolder *) engine->folder;
CamelIMAP4Command *ic;
int id;
-
+
if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return;
-
+
CAMEL_SERVICE_REC_LOCK (folder->parent_store, connect_lock);
-
+
if (folder != selected) {
if (camel_imap4_engine_select_folder (engine, folder, ex) == -1)
goto done;
-
+
((CamelIMAP4Summary *) folder->summary)->update_flags = TRUE;
} else {
ic = camel_imap4_engine_queue (engine, NULL, "NOOP\r\n");
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE)
camel_exception_xfer (ex, &ic->ex);
-
+
camel_imap4_command_unref (ic);
-
+
if (camel_exception_is_set (ex))
goto done;
}
-
+
camel_imap4_summary_flush_updates (folder->summary, ex);
-
+
done:
-
+
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
}
CamelMessageInfo *info;
CamelMimeFilter *crlf;
guint32 flags;
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
/* parse the FETCH response list */
if (token->token != '(') {
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
-
+
do {
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token == ')' || token->token == '\n')
break;
-
+
if (token->token != CAMEL_IMAP4_TOKEN_ATOM)
goto unexpected;
-
+
if (!strcmp (token->v.atom, "BODY[")) {
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token != ']')
goto unexpected;
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token != CAMEL_IMAP4_TOKEN_LITERAL)
goto unexpected;
-
+
fstream = (CamelStream *) camel_stream_filter_new_with_stream (stream);
crlf = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_DECODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
camel_stream_filter_add ((CamelStreamFilter *) fstream, crlf);
camel_object_unref (crlf);
-
+
camel_stream_write_to_stream ((CamelStream *) engine->istream, fstream);
camel_stream_flush (fstream);
camel_object_unref (fstream);
} else if (!strcmp (token->v.atom, "UID")) {
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token != CAMEL_IMAP4_TOKEN_NUMBER || token->v.number == 0)
goto unexpected;
} else if (!strcmp (token->v.atom, "FLAGS")) {
* given to us if another client recently changed the flags... */
if (camel_imap4_parse_flags_list (engine, &flags, ex) == -1)
goto exception;
-
+
if ((info = camel_folder_summary_index (summary, index - 1))) {
iinfo = (CamelIMAP4MessageInfo *) info;
iinfo->info.flags = camel_imap4_merge_flags (iinfo->server_flags, iinfo->info.flags, flags);
iinfo->server_flags = flags;
-
+
changes = camel_folder_change_info_new ();
camel_folder_change_info_change_uid (changes, camel_message_info_uid (info));
camel_object_trigger_event (engine->folder, "folder_changed", changes);
camel_folder_change_info_free (changes);
-
+
camel_message_info_free(info);
}
} else {
d(fprintf (stderr, "huh? %s?...\n", token->v.atom));
}
} while (1);
-
+
if (token->token != ')') {
d(fprintf (stderr, "expected ')' to close untagged FETCH response\n"));
goto unexpected;
}
-
+
return 0;
-
+
unexpected:
-
+
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
-
+
exception:
-
+
return -1;
}
CamelStream *stream, *cache;
CamelIMAP4Command *ic;
int id;
-
+
CAMEL_SERVICE_REC_LOCK (folder->parent_store, connect_lock);
-
+
if (imap4_folder->cache && (stream = camel_data_cache_get (imap4_folder->cache, "cache", uid, ex))) {
message = camel_mime_message_new ();
-
+
if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream) == -1) {
if (errno == EINTR) {
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
message = NULL;
}
}
-
+
camel_object_unref (stream);
}
-
+
if (message != NULL) {
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
return message;
}
-
+
if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("This message is not available in offline mode."));
return NULL;
}
-
+
/* Note: While some hard-core IMAP extremists are probably
* going to flame me for fetching entire messages here, it's
* the *only* sure-fire way of working with all IMAP
ic = camel_imap4_engine_queue (engine, folder, "UID FETCH %s BODY.PEEK[]\r\n", uid);
camel_imap4_command_register_untagged (ic, "FETCH", untagged_fetch);
ic->user_data = stream = camel_stream_mem_new ();
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
camel_object_unref (stream);
goto done;
}
-
+
switch (ic->result) {
case CAMEL_IMAP4_RESULT_OK:
camel_stream_reset (stream);
message = camel_mime_message_new ();
camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream);
camel_stream_reset (stream);
-
+
/* cache the message locally */
if (imap4_folder->cache && (cache = camel_data_cache_add (imap4_folder->cache, "cache", uid, NULL))) {
if (camel_stream_write_to_stream (stream, cache) == -1
camel_data_cache_remove (imap4_folder->cache, "cache", uid, NULL);
camel_object_unref (cache);
}
-
+
break;
case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
uid, folder->full_name);
break;
}
-
+
camel_imap4_command_unref (ic);
-
+
camel_object_unref (stream);
-
+
done:
-
+
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
-
+
return message;
}
char date[50];
struct tm tm;
int id, i;
-
+
if (appended_uid)
*appended_uid = NULL;
-
+
if (((CamelIMAP4Folder *) folder)->read_only) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot append message to folder `%s': Folder is read-only"),
folder->full_name);
return;
}
-
+
if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
camel_imap4_journal_append ((CamelIMAP4Journal *) imap4_folder->journal, message, info, appended_uid, ex);
return;
}
-
+
CAMEL_SERVICE_REC_LOCK (folder->parent_store, connect_lock);
-
+
/* construct the option flags list */
if (iinfo->info.flags & folder->permanent_flags) {
p = g_stpcpy (flags, " (");
-
+
for (i = 0; i < G_N_ELEMENTS (imap4_flags); i++) {
if ((iinfo->info.flags & imap4_flags[i].flag) & folder->permanent_flags) {
p = g_stpcpy (p, imap4_flags[i].name);
*p++ = ' ';
}
}
-
+
p[-1] = ')';
*p = '\0';
} else {
flags[0] = '\0';
}
-
+
/* construct the optional date_time string */
if (iinfo->info.date_received > (time_t) 0) {
int tzone;
-
+
#ifdef HAVE_LOCALTIME_R
localtime_r (&iinfo->info.date_received, &tm);
#else
memcpy (&tm, localtime (&iinfo->info.date_received), sizeof (tm));
#endif
-
+
#if defined (HAVE_TM_GMTOFF)
tzone = -tm.tm_gmtoff;
#elif defined (HAVE_TIMEZONE)
#else
#error Neither HAVE_TIMEZONE nor HAVE_TM_GMTOFF defined. Rerun autoheader, autoconf, etc.
#endif
-
+
sprintf (date, " \"%02d-%s-%04d %02d:%02d:%02d %+05d\"",
tm.tm_mday, tm_months[tm.tm_mon], tm.tm_year + 1900,
tm.tm_hour, tm.tm_min, tm.tm_sec, tzone);
} else {
date[0] = '\0';
}
-
+
retry:
-
+
ic = camel_imap4_engine_queue (engine, NULL, "APPEND %F%s%s %L\r\n", folder, flags, date, message);
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
return;
}
-
+
switch (ic->result) {
case CAMEL_IMAP4_RESULT_OK:
if (!appended_uid || !(engine->capa & CAMEL_IMAP4_CAPABILITY_UIDPLUS))
break;
-
+
for (i = 0; i < ic->resp_codes->len; i++) {
resp = ic->resp_codes->pdata[i];
if (resp->code == CAMEL_IMAP4_RESP_CODE_APPENDUID) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot append message to folder `%s': Unknown error"),
folder->full_name);
-
+
for (i = 0; i < ic->resp_codes->len; i++) {
resp = ic->resp_codes->pdata[i];
if (resp->code == CAMEL_IMAP4_RESP_CODE_TRYCREATE) {
char *parent_name, *p;
-
+
parent_name = g_alloca (strlen (folder->full_name) + 1);
strcpy (parent_name, folder->full_name);
if (!(p = strrchr (parent_name, '/')))
*parent_name = '\0';
else
*p = '\0';
-
+
if (!(fi = camel_store_create_folder (folder->parent_store, parent_name, folder->name, &lex))) {
camel_exception_clear (&lex);
break;
}
-
+
camel_store_free_folder_info (folder->parent_store, fi);
camel_imap4_command_unref (ic);
camel_exception_clear (ex);
goto retry;
}
}
-
+
break;
case CAMEL_IMAP4_RESULT_BAD:
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot append message to folder `%s': Bad command"),
folder->full_name);
-
+
break;
default:
g_assert_not_reached ();
}
-
+
camel_imap4_command_unref (ic);
-
+
CAMEL_SERVICE_REC_UNLOCK (folder->parent_store, connect_lock);
}
info_uid_sort (const CamelMessageInfo **info0, const CamelMessageInfo **info1)
{
guint32 uid0, uid1;
-
+
uid0 = strtoul (camel_message_info_uid (*info0), NULL, 10);
uid1 = strtoul (camel_message_info_uid (*info1), NULL, 10);
-
+
if (uid0 == uid1)
return 0;
-
+
return uid0 < uid1 ? -1 : 1;
}
CamelException lex;
GPtrArray *infos;
char *set;
-
+
if (transferred_uids)
*transferred_uids = NULL;
-
+
camel_exception_init (&lex);
imap4_sync (src, FALSE, &lex);
if (camel_exception_is_set (&lex)) {
camel_exception_xfer (ex, &lex);
return;
}
-
+
infos = g_ptr_array_new ();
for (i = 0; i < uids->len; i++) {
if (!(info = camel_folder_summary_uid (src->summary, uids->pdata[i])))
continue;
-
+
g_ptr_array_add (infos, info);
}
-
+
if (infos->len == 0) {
g_ptr_array_free (infos, TRUE);
return;
}
-
+
g_ptr_array_sort (infos, (GCompareFunc) info_uid_sort);
-
+
CAMEL_SERVICE_REC_LOCK (src->parent_store, connect_lock);
-
+
/* check for offline operation */
if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
CamelIMAP4Journal *journal = (CamelIMAP4Journal *) ((CamelIMAP4Folder *) dest)->journal;
CamelMimeMessage *message;
-
+
for (i = 0; i < infos->len; i++) {
info = infos->pdata[i];
-
+
if (!(message = imap4_get_message (src, camel_message_info_uid (info), ex)))
break;
-
+
camel_imap4_journal_append (journal, message, info, NULL, ex);
camel_object_unref (message);
-
+
if (camel_exception_is_set (ex))
break;
-
+
if (move)
camel_folder_set_message_flags (src, camel_message_info_uid (info),
CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED);
}
-
+
goto done;
}
-
+
dest_namelen = strlen (camel_imap4_folder_utf7_name ((CamelIMAP4Folder *) dest));
-
+
for (i = 0; i < infos->len; i += n) {
n = camel_imap4_get_uid_set (engine, src->summary, infos, i, 10 + dest_namelen, &set);
-
+
if (move && (engine->capa & CAMEL_IMAP4_CAPABILITY_XGWMOVE))
ic = camel_imap4_engine_queue (engine, src, "UID XGWMOVE %s %F\r\n", set, dest);
else
ic = camel_imap4_engine_queue (engine, src, "UID COPY %s %F\r\n", set, dest);
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
g_free (set);
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
g_free (set);
goto done;
}
-
+
switch (ic->result) {
case CAMEL_IMAP4_RESULT_NO:
/* FIXME: would be good to save the NO reason into the err message */
_("Cannot copy messages from folder `%s' to folder `%s': Unknown"),
src->full_name, dest->full_name);
}
-
+
goto done;
case CAMEL_IMAP4_RESULT_BAD:
if (move) {
_("Cannot copy messages from folder `%s' to folder `%s': Bad command"),
src->full_name, dest->full_name);
}
-
+
goto done;
}
-
+
camel_imap4_command_unref (ic);
-
+
if (move && !(engine->capa & CAMEL_IMAP4_CAPABILITY_XGWMOVE)) {
for (j = i; j < n; j++) {
info = infos->pdata[j];
camel_folder_set_message_flags (src, camel_message_info_uid (info),
CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED);
}
-
+
camel_folder_summary_touch (src->summary);
}
}
-
+
done:
-
+
for (i = 0; i < infos->len; i++)
camel_message_info_free (infos->pdata[i]);
g_ptr_array_free (infos, TRUE);
-
+
CAMEL_SERVICE_REC_UNLOCK (src->parent_store, connect_lock);
}
{
CamelIMAP4Folder *imap4_folder = (CamelIMAP4Folder *) folder;
GPtrArray *matches;
-
+
CAMEL_SERVICE_REC_LOCK(folder->parent_store, connect_lock);
-
+
camel_folder_search_set_folder (imap4_folder->search, folder);
matches = camel_folder_search_search (imap4_folder->search, expr, NULL, ex);
-
+
CAMEL_SERVICE_REC_UNLOCK(folder->parent_store, connect_lock);
-
+
return matches;
}
{
CamelIMAP4Folder *imap4_folder = (CamelIMAP4Folder *) folder;
GPtrArray *matches;
-
+
if (uids->len == 0)
return g_ptr_array_new ();
-
+
CAMEL_SERVICE_REC_LOCK(folder->parent_store, connect_lock);
-
+
camel_folder_search_set_folder (imap4_folder->search, folder);
matches = camel_folder_search_search (imap4_folder->search, expr, uids, ex);
-
+
CAMEL_SERVICE_REC_UNLOCK(folder->parent_store, connect_lock);
-
+
return matches;
}
imap4_search_free (CamelFolder *folder, GPtrArray *uids)
{
CamelIMAP4Folder *imap4_folder = (CamelIMAP4Folder *) folder;
-
+
g_return_if_fail (imap4_folder->search);
-
+
CAMEL_SERVICE_REC_LOCK(folder->parent_store, connect_lock);
-
+
camel_folder_search_free_result (imap4_folder->search, uids);
-
+
CAMEL_SERVICE_REC_UNLOCK(folder->parent_store, connect_lock);
}
struct _CamelIMAP4Folder {
CamelOfflineFolder parent_object;
-
+
CamelFolderSearch *search;
-
+
CamelOfflineJournal *journal;
CamelDataCache *cache;
-
+
char *cachedir;
char *utf7_name;
-
+
unsigned int read_only:1;
unsigned int enable_mlist:1;
};
struct _CamelIMAP4FolderClass {
CamelOfflineFolderClass parent_class;
-
+
};
camel_imap4_journal_get_type (void)
{
static CamelType type = 0;
-
+
if (!type) {
type = camel_type_register (camel_offline_journal_get_type (),
"CamelIMAP4Journal",
(CamelObjectInitFunc) camel_imap4_journal_init,
(CamelObjectFinalizeFunc) camel_imap4_journal_finalize);
}
-
+
return type;
}
camel_imap4_journal_class_init (CamelIMAP4JournalClass *klass)
{
CamelOfflineJournalClass *journal_class = (CamelOfflineJournalClass *) klass;
-
+
parent_class = (CamelOfflineJournalClass *) camel_type_get_global_classfuncs (CAMEL_TYPE_OFFLINE_JOURNAL);
-
+
journal_class->entry_free = imap4_entry_free;
journal_class->entry_load = imap4_entry_load;
journal_class->entry_write = imap4_entry_write;
{
CamelIMAP4Journal *journal = (CamelIMAP4Journal *) object;
int i;
-
+
if (journal->failed) {
for (i = 0; i < journal->failed->len; i++)
camel_message_info_free (journal->failed->pdata[i]);
imap4_entry_free (CamelOfflineJournal *journal, EDListNode *entry)
{
CamelIMAP4JournalEntry *imap4_entry = (CamelIMAP4JournalEntry *) entry;
-
+
g_free (imap4_entry->v.append_uid);
g_free (imap4_entry);
}
imap4_entry_load (CamelOfflineJournal *journal, FILE *in)
{
CamelIMAP4JournalEntry *entry;
-
+
entry = g_malloc0 (sizeof (CamelIMAP4JournalEntry));
-
+
if (camel_file_util_decode_uint32 (in, &entry->type) == -1)
goto exception;
-
+
switch (entry->type) {
case CAMEL_IMAP4_JOURNAL_ENTRY_APPEND:
if (camel_file_util_decode_string (in, &entry->v.append_uid) == -1)
goto exception;
-
+
break;
default:
goto exception;
}
-
+
return (EDListNode *) entry;
-
+
exception:
-
+
switch (entry->type) {
case CAMEL_IMAP4_JOURNAL_ENTRY_APPEND:
g_free (entry->v.append_uid);
default:
g_assert_not_reached ();
}
-
+
g_free (entry);
-
+
return NULL;
}
imap4_entry_write (CamelOfflineJournal *journal, EDListNode *entry, FILE *out)
{
CamelIMAP4JournalEntry *imap4_entry = (CamelIMAP4JournalEntry *) entry;
-
+
if (camel_file_util_encode_uint32 (out, imap4_entry->type) == -1)
return -1;
-
+
switch (imap4_entry->type) {
case CAMEL_IMAP4_JOURNAL_ENTRY_APPEND:
if (camel_file_util_encode_string (out, imap4_entry->v.append_uid))
return -1;
-
+
break;
default:
g_assert_not_reached ();
}
-
+
return 0;
}
CamelStream *stream;
CamelException lex;
char *uid = NULL;
-
+
/* if the message isn't in the cache, the user went behind our backs so "not our problem" */
if (!imap4_folder->cache || !(stream = camel_data_cache_get (imap4_folder->cache, "cache", entry->v.append_uid, ex)))
goto done;
-
+
message = camel_mime_message_new ();
if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream) == -1) {
camel_object_unref (message);
camel_object_unref (stream);
goto done;
}
-
+
camel_object_unref (stream);
-
+
if (!(info = camel_folder_summary_uid (folder->summary, entry->v.append_uid))) {
/* info not in the summary, either because the summary
* got corrupted or because the previous time this
* journal was replay'd, it failed [1] */
info = camel_message_info_new (NULL);
}
-
+
camel_exception_init (&lex);
camel_folder_append_message (folder, message, info, &uid, &lex);
camel_object_unref (message);
-
+
if (camel_exception_is_set (&lex)) {
/* Remove the message-info from the summary even if we fail or the next
* summary downsync will break because info indexes will be wrong */
camel_folder_summary_remove_uid (folder->summary, entry->v.append_uid);
camel_message_info_free (info);
}
-
+
camel_exception_xfer (ex, &lex);
-
+
return -1;
}
-
+
if (uid != NULL && (real = camel_folder_summary_uid (folder->summary, uid))) {
/* Copy the system flags and user flags/tags over to the real
message-info now stored in the summary to prevent the user
from losing any of this meta-data */
imap4_message_info_dup_to ((CamelMessageInfoBase *) real, (CamelMessageInfoBase *) info);
}
-
+
camel_message_info_free (info);
g_free (uid);
-
+
done:
-
+
camel_folder_summary_remove_uid (folder->summary, entry->v.append_uid);
camel_data_cache_remove (imap4_folder->cache, "cache", entry->v.append_uid, NULL);
-
+
return 0;
}
imap4_entry_play (CamelOfflineJournal *journal, EDListNode *entry, CamelException *ex)
{
CamelIMAP4JournalEntry *imap4_entry = (CamelIMAP4JournalEntry *) entry;
-
+
switch (imap4_entry->type) {
case CAMEL_IMAP4_JOURNAL_ENTRY_APPEND:
return imap4_entry_play_append (journal, imap4_entry, ex);
camel_imap4_journal_new (CamelIMAP4Folder *folder, const char *filename)
{
CamelOfflineJournal *journal;
-
+
g_return_val_if_fail (CAMEL_IS_IMAP4_FOLDER (folder), NULL);
-
+
journal = (CamelOfflineJournal *) camel_object_new (camel_imap4_journal_get_type ());
camel_offline_journal_construct (journal, (CamelFolder *) folder, filename);
-
+
return journal;
}
{
CamelFolderSummary *summary = ((CamelOfflineJournal *) journal)->folder->summary;
int i;
-
+
for (i = 0; i < journal->failed->len; i++)
camel_folder_summary_add (summary, journal->failed->pdata[i]);
-
+
g_ptr_array_set_size (journal->failed, 0);
}
CamelStream *cache;
guint32 nextuid;
char *uid;
-
+
if (imap4_folder->cache == NULL) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot append message in offline mode: cache unavailable"));
return;
}
-
+
nextuid = camel_folder_summary_next_uid (folder->summary);
uid = g_strdup_printf ("-%lu", nextuid);
-
+
if (!(cache = camel_data_cache_add (imap4_folder->cache, "cache", uid, ex))) {
folder->summary->nextuid--;
g_free (uid);
return;
}
-
+
if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) message, cache) == -1
|| camel_stream_flush (cache) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
g_free (uid);
return;
}
-
+
camel_object_unref (cache);
-
+
entry = g_new (CamelIMAP4JournalEntry, 1);
entry->type = CAMEL_IMAP4_JOURNAL_ENTRY_APPEND;
entry->v.append_uid = uid;
-
+
e_dlist_addtail (&journal->queue, (EDListNode *) entry);
-
+
info = camel_folder_summary_info_new_from_message (folder->summary, message);
g_free(info->uid);
info->uid = g_strdup (uid);
-
+
imap4_message_info_dup_to ((CamelMessageInfoBase *) info, (CamelMessageInfoBase *) mi);
-
+
camel_folder_summary_add (folder->summary, info);
-
+
if (appended_uid)
*appended_uid = g_strdup (uid);
}
struct _CamelIMAP4JournalEntry {
EDListNode node;
-
+
int type;
-
+
union {
char *append_uid;
} v;
struct _CamelIMAP4Journal {
CamelOfflineJournal parent_object;
-
+
GPtrArray *failed;
};
struct _CamelIMAP4JournalClass {
CamelOfflineJournalClass parent_class;
-
+
};
static CamelProvider imap4_provider = {
"imap4",
N_("IMAP4rev1"),
-
+
N_("For reading and storing mail on IMAPv4rev1 servers."),
-
+
"mail",
-
+
CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE |
CAMEL_PROVIDER_IS_STORAGE | CAMEL_PROVIDER_SUPPORTS_SSL,
-
+
CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH | CAMEL_URL_FRAGMENT_IS_PATH,
-
+
imap4_conf_entries,
-
+
/* ... */
};
CamelServiceAuthType camel_imap4_password_authtype = {
N_("Password"),
-
+
N_("This option will connect to the IMAPv4rev1 server using a "
"plaintext password."),
-
+
"",
TRUE
};
{
const CamelURL *u = (CamelURL *)key;
guint hash = 0;
-
+
add_hash (&hash, u->user);
add_hash (&hash, u->authmech);
add_hash (&hash, u->host);
hash ^= u->port;
-
+
return hash;
}
else
return FALSE;
}
-
+
if (s2 == NULL)
return FALSE;
-
+
return strcmp (s1, s2) == 0;
}
imap4_url_equal (gconstpointer a, gconstpointer b)
{
const CamelURL *u1 = a, *u2 = b;
-
+
return check_equal (u1->protocol, u2->protocol)
&& check_equal (u1->user, u2->user)
&& check_equal (u1->authmech, u2->authmech)
imap4_provider.authtypes = camel_sasl_authtype_list (FALSE);
imap4_provider.authtypes = g_list_prepend (imap4_provider.authtypes, &camel_imap4_password_authtype);
imap4_provider.translation_domain = GETTEXT_PACKAGE;
-
+
camel_provider_register (&imap4_provider);
}
camel_imap4_search_get_type (void)
{
static CamelType type = 0;
-
+
if (!type) {
type = camel_type_register (camel_folder_search_get_type (),
"CamelIMAP4Search",
(CamelObjectInitFunc) camel_imap4_search_init,
(CamelObjectFinalizeFunc) camel_imap4_search_finalize);
}
-
+
return type;
}
camel_imap4_search_class_init (CamelIMAP4SearchClass *klass)
{
CamelFolderSearchClass *search_class = (CamelFolderSearchClass *) klass;
-
+
parent_class = (CamelFolderSearchClass *) camel_type_get_global_classfuncs (CAMEL_FOLDER_SEARCH_TYPE);
-
+
search_class->body_contains = imap4_body_contains;
}
camel_imap4_search_new (CamelIMAP4Engine *engine, const char *cachedir)
{
CamelIMAP4Search *search;
-
+
search = (CamelIMAP4Search *) camel_object_new (camel_imap4_search_get_type ());
camel_folder_search_construct ((CamelFolderSearch *) search);
search->engine = engine;
-
+
return (CamelFolderSearch *) search;
}
GPtrArray *matches = ic->user_data;
CamelMessageInfo *info;
char uid[12];
-
+
while (1) {
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
if (token->token == '\n')
break;
-
+
if (token->token != CAMEL_IMAP4_TOKEN_NUMBER || token->v.number == 0)
goto unexpected;
-
+
sprintf (uid, "%lu", token->v.number);
if ((info = camel_folder_summary_uid (summary, uid))) {
g_ptr_array_add (matches, (char *) camel_message_info_uid (info));
camel_message_info_free (info);
}
}
-
+
return 0;
-
+
unexpected:
-
+
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
-
+
return -1;
}
int id, i, n;
size_t used;
char *set;
-
+
if (((CamelOfflineStore *) engine->service)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return parent_class->body_contains (f, argc, argv, search);
-
+
summary_set = search->summary_set ? search->summary_set : search->summary;
-
+
/* check the simple cases */
if (argc == 0 || summary_set->len == 0) {
/* match nothing */
r = e_sexp_result_new (f, ESEXP_RES_ARRAY_PTR);
r->value.ptrarray = g_ptr_array_new ();
}
-
+
return r;
} else if (argc == 1 && argv[0]->type == ESEXP_RES_STRING && argv[0]->value.string[0] == '\0') {
/* match everything */
r->value.ptrarray->pdata[i] = (char *) camel_message_info_uid (info);
}
}
-
+
return r;
}
-
+
strings = g_ptr_array_new ();
for (i = 0; i < argc; i++) {
if (argv[i]->type == ESEXP_RES_STRING && argv[i]->value.string[0] != '\0') {
utf8_search = TRUE;
break;
}
-
+
inptr++;
}
}
}
}
-
+
if (strings->len == 0) {
/* match everything */
g_ptr_array_free (strings, TRUE);
-
+
if (search->current) {
r = e_sexp_result_new (f, ESEXP_RES_BOOL);
r->value.bool = TRUE;
r->value.ptrarray->pdata[i] = (char *) camel_message_info_uid (info);
}
}
-
+
return r;
}
-
+
g_ptr_array_add (strings, NULL);
matches = g_ptr_array_new ();
infos = g_ptr_array_new ();
-
+
if (search->current) {
g_ptr_array_add (infos, search->current);
} else {
for (i = 0; i < summary_set->len; i++)
infos->pdata[i] = summary_set->pdata[i];
}
-
+
retry:
if (utf8_search && (engine->capa & CAMEL_IMAP4_CAPABILITY_utf8_search))
expr = "UID SEARCH CHARSET UTF-8 UID %s BODY %V\r\n";
else
expr = "UID SEARCH UID %s BODY %V\r\n";
-
+
used = strlen (expr) + (5 * (strings->len - 2));
-
+
for (i = 0; i < infos->len; i += n) {
n = camel_imap4_get_uid_set (engine, search->folder->summary, infos, i, used, &set);
-
+
ic = camel_imap4_engine_queue (engine, search->folder, expr, set, strings->pdata);
camel_imap4_command_register_untagged (ic, "SEARCH", untagged_search);
ic->user_data = matches;
g_free (set);
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_imap4_command_unref (ic);
goto done;
}
-
-
+
+
if (ic->result == CAMEL_IMAP4_RESULT_NO && utf8_search && (engine->capa & CAMEL_IMAP4_CAPABILITY_utf8_search)) {
int j;
-
+
/* might be because the server is lame and doesn't support UTF-8 */
for (j = 0; j < ic->resp_codes->len; j++) {
CamelIMAP4RespCode *resp = ic->resp_codes->pdata[j];
-
+
if (resp->code == CAMEL_IMAP4_RESP_CODE_BADCHARSET) {
engine->capa &= ~CAMEL_IMAP4_CAPABILITY_utf8_search;
camel_imap4_command_unref (ic);
}
}
}
-
+
if (ic->result != CAMEL_IMAP4_RESULT_OK) {
camel_imap4_command_unref (ic);
break;
}
-
+
camel_imap4_command_unref (ic);
}
-
+
done:
-
+
g_ptr_array_free (strings, TRUE);
g_ptr_array_free (infos, TRUE);
-
+
if (search->current) {
const char *uid;
-
+
uid = camel_message_info_uid (search->current);
r = e_sexp_result_new (f, ESEXP_RES_BOOL);
r->value.bool = FALSE;
break;
}
}
-
+
g_ptr_array_free (matches, TRUE);
} else {
r = e_sexp_result_new (f, ESEXP_RES_ARRAY_PTR);
r->value.ptrarray = matches;
}
-
+
return r;
}
struct _CamelIMAP4Search {
CamelFolderSearch parent_object;
-
+
struct _CamelIMAP4Engine *engine;
-
+
guint32 lastuid; /* current 'last uid' for the folder */
guint32 validity; /* validity of the current folder */
-
+
CamelDataCache *cache; /* disk-cache for searches */
-
+
/* cache of body search matches */
EDList matches;
GHashTable *matches_hash;
struct _CamelIMAP4SearchClass {
CamelFolderSearchClass parent_class;
-
+
};
imap4_init_bits (unsigned short bit, unsigned short bitcopy, int remove, unsigned char *vals)
{
int i, len = strlen (vals);
-
+
if (!remove) {
for (i = 0; i < len; i++)
camel_imap4_specials[vals[i]] |= bit;
camel_imap4_specials_init (void)
{
int i;
-
+
for (i = 0; i < 256; i++) {
camel_imap4_specials[i] = 0;
if (i <= 0x1f || i >= 0x7f)
camel_imap4_specials[i] |= IS_CTRL;
}
-
+
camel_imap4_specials[' '] |= IS_SPACE;
-
+
imap4_init_bits (IS_LWSP, 0, 0, CHARS_LWSP);
imap4_init_bits (IS_ASPECIAL, 0, 0, CHARS_ATOM_SPECIALS);
imap4_init_bits (IS_QSPECIAL, 0, 0, CHARS_QUOTED_SPECIALS);
enum {
IS_ASPECIAL = (1 << 0),
IS_CTRL = (1 << 1),
- IS_LWSP = (1 << 2),
+ IS_LWSP = (1 << 2),
IS_QSPECIAL = (1 << 3),
IS_SPACE = (1 << 4),
IS_WILDCARD = (1 << 5),
camel_imap4_store_summary_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (camel_store_summary_get_type (),
"CamelIMAP4StoreSummary",
(CamelObjectInitFunc) camel_imap4_store_summary_init,
(CamelObjectFinalizeFunc) camel_imap4_store_summary_finalize);
}
-
+
return type;
}
camel_imap4_store_summary_class_init (CamelIMAP4StoreSummaryClass *klass)
{
CamelStoreSummaryClass *ssklass = (CamelStoreSummaryClass *) klass;
-
+
parent_class = (CamelStoreSummaryClass *) camel_store_summary_get_type ();
-
+
ssklass->summary_header_load = summary_header_load;
ssklass->summary_header_save = summary_header_save;
-
+
ssklass->store_info_load = store_info_load;
ssklass->store_info_save = store_info_save;
ssklass->store_info_free = store_info_free;
camel_imap4_store_summary_finalize (CamelObject *obj)
{
CamelIMAP4StoreSummary *s = (CamelIMAP4StoreSummary *) obj;
-
+
if (s->namespaces)
camel_imap4_namespace_list_free (s->namespaces);
}
CamelIMAP4Namespace *ns, *tail = NULL;
CamelIMAP4NamespaceList *nsl;
guint32 i, j, n;
-
+
nsl = g_malloc (sizeof (CamelIMAP4NamespaceList));
nsl->personal = NULL;
nsl->shared = NULL;
nsl->other = NULL;
-
+
for (j = 0; j < 3; j++) {
switch (j) {
case 0:
tail = (CamelIMAP4Namespace *) &nsl->other;
break;
}
-
+
if (camel_file_util_decode_fixed_int32 (in, &n) == -1)
goto exception;
-
+
for (i = 0; i < n; i++) {
guint32 sep;
char *path;
-
+
if (camel_file_util_decode_string (in, &path) == -1)
goto exception;
-
+
if (camel_file_util_decode_uint32 (in, &sep) == -1) {
g_free (path);
goto exception;
}
-
+
tail->next = ns = g_malloc (sizeof (CamelIMAP4Namespace));
ns->sep = sep & 0xff;
ns->path = path;
tail = ns;
}
}
-
+
return nsl;
-
+
exception:
-
+
camel_imap4_namespace_list_free (nsl);
-
+
return NULL;
}
{
CamelIMAP4StoreSummary *is = (CamelIMAP4StoreSummary *) s;
guint32 version, capa;
-
+
if (parent_class->summary_header_load (s, in) == -1)
return -1;
-
+
if (camel_file_util_decode_fixed_int32 (in, &version) == -1)
return -1;
-
+
is->version = version;
if (version < CAMEL_IMAP4_STORE_SUMMARY_VERSION_0) {
g_warning ("IMAP4 store summary header version too low");
errno = EINVAL;
return -1;
}
-
+
if (camel_file_util_decode_fixed_int32 (in, &capa) == -1)
return -1;
-
+
is->capa = capa;
-
+
if (!(is->namespaces = load_namespaces (in)))
return -1;
-
+
return 0;
}
{
CamelIMAP4Namespace *ns, *cur = NULL;
guint32 i, n;
-
+
for (i = 0; i < 3; i++) {
switch (i) {
case 0:
cur = nsl->other;
break;
}
-
+
for (ns = cur, n = 0; ns; n++)
ns = ns->next;
-
+
if (camel_file_util_encode_fixed_int32 (out, n) == -1)
return -1;
-
+
ns = cur;
while (ns != NULL) {
if (camel_file_util_encode_string (out, ns->path) == -1)
return -1;
-
+
if (camel_file_util_encode_uint32 (out, ns->sep) == -1)
return -1;
-
+
ns = ns->next;
}
}
-
+
return 0;
}
summary_header_save (CamelStoreSummary *s, FILE *out)
{
CamelIMAP4StoreSummary *is = (CamelIMAP4StoreSummary *) s;
-
+
if (parent_class->summary_header_save (s, out) == -1)
return -1;
-
+
if (camel_file_util_encode_fixed_int32 (out, is->version) == -1)
return -1;
-
+
if (camel_file_util_encode_fixed_int32 (out, is->capa) == -1)
return -1;
-
+
if (save_namespaces (out, is->namespaces) == -1)
return -1;
-
+
return 0;
}
* camel_imap4_store_summary_new:
*
* Create a new CamelIMAP4StoreSummary object.
- *
+ *
* Returns a new CamelIMAP4StoreSummary object.
**/
CamelIMAP4StoreSummary *
{
CamelStoreSummary *ss = (CamelStoreSummary *) s;
CamelStoreInfo *si;
-
+
if ((si = camel_store_summary_path (ss, fi->full_name))) {
if (fi->unread != -1) {
si->unread = fi->unread;
ss->flags |= CAMEL_STORE_SUMMARY_DIRTY;
}
-
+
if (fi->total != -1) {
si->total = fi->total;
ss->flags |= CAMEL_STORE_SUMMARY_DIRTY;
}
-
+
camel_store_summary_info_free (ss, si);
return;
}
-
+
si = camel_store_summary_info_new (ss);
si->path = g_strdup (fi->full_name);
si->uri = g_strdup (fi->uri);
si->flags = fi->flags;
si->unread = fi->unread;
si->total = fi->total;
-
+
camel_store_summary_add (ss, si);
-
+
/* FIXME: should this be recursive? */
}
camel_imap4_store_summary_unnote_info (CamelIMAP4StoreSummary *s, CamelFolderInfo *fi)
{
CamelStoreSummary *ss = (CamelStoreSummary *) s;
-
+
camel_store_summary_remove_path (ss, fi->full_name);
}
{
CamelFolderInfo *fi;
const char *name;
-
+
fi = g_malloc0 (sizeof (CamelFolderInfo));
fi->full_name = g_strdup (camel_store_info_path (s, si));
fi->uri = g_strdup (camel_store_info_uri (s, si));
fi->flags = si->flags;
fi->unread = si->unread;
fi->total = si->total;
-
+
name = camel_store_info_name (s, si);
if (!g_ascii_strcasecmp (fi->full_name, "INBOX")) {
fi->flags |= CAMEL_FOLDER_SYSTEM | CAMEL_FOLDER_TYPE_INBOX;
} else {
fi->name = g_strdup (name);
}
-
+
return fi;
}
CamelStoreInfo *si;
size_t toplen, len;
int i;
-
+
toplen = strlen (top);
folders = g_ptr_array_new ();
-
+
for (i = 0; i < ss->folders->len; i++) {
si = ss->folders->pdata[i];
if (strncmp (si->path, top, toplen) != 0)
continue;
-
+
len = strlen (si->path);
if (toplen > 0 && len > toplen && si->path[toplen] != '/')
continue;
-
+
if (len == toplen) {
/* found toplevel folder */
g_ptr_array_add (folders, store_info_to_folder_info (ss, si));
continue;
}
-
+
if ((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) || !strchr (si->path + toplen + 1, '/'))
g_ptr_array_add (folders, store_info_to_folder_info (ss, si));
}
-
+
fi = camel_folder_info_build (folders, top, '/', TRUE);
g_ptr_array_free (folders, TRUE);
-
+
return fi;
}
struct _CamelIMAP4StoreSummary {
CamelStoreSummary summary;
-
+
struct _CamelIMAP4StoreSummaryPrivate *priv;
-
+
/* header info */
guint32 version;
-
+
CamelIMAP4NamespaceList *namespaces;
guint32 capa;
};
camel_imap4_store_get_type (void)
{
static CamelType type = 0;
-
+
if (!type) {
type = camel_type_register (camel_offline_store_get_type (),
"CamelIMAP4Store",
(CamelObjectInitFunc) camel_imap4_store_init,
(CamelObjectFinalizeFunc) camel_imap4_store_finalize);
}
-
+
return type;
}
imap4_compare_folder_name (gconstpointer a, gconstpointer b)
{
gconstpointer aname = a, bname = b;
-
+
if (g_ascii_strcasecmp (a, "INBOX") == 0)
aname = "INBOX";
if (g_ascii_strcasecmp (b, "INBOX") == 0)
bname = "INBOX";
-
+
return g_str_equal (aname, bname);
}
{
CamelServiceClass *service_class = (CamelServiceClass *) klass;
CamelStoreClass *store_class = (CamelStoreClass *) klass;
-
+
parent_class = (CamelOfflineStoreClass *) camel_type_get_global_classfuncs (CAMEL_TYPE_OFFLINE_STORE);
-
+
service_class->construct = imap4_construct;
service_class->get_name = imap4_get_name;
service_class->connect = imap4_connect;
service_class->disconnect = imap4_disconnect;
service_class->query_auth_types = imap4_query_auth_types;
-
+
store_class->hash_folder_name = imap4_hash_folder_name;
store_class->compare_folder_name = imap4_compare_folder_name;
-
+
store_class->get_folder = imap4_get_folder;
store_class->create_folder = imap4_create_folder;
store_class->delete_folder = imap4_delete_folder;
camel_imap4_store_finalize (CamelObject *object)
{
CamelIMAP4Store *store = (CamelIMAP4Store *) object;
-
+
if (store->summary) {
camel_store_summary_save ((CamelStoreSummary *) store->summary);
camel_object_unref (store->summary);
}
-
+
if (store->engine)
camel_object_unref (store->engine);
-
+
g_free (store->storage_path);
}
{
CamelIMAP4Store *store = (CamelIMAP4Store *) service;
char *buf;
-
+
CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
if (camel_exception_is_set (ex))
return;
-
+
if (camel_url_get_param (url, "use_lsub"))
((CamelStore *) store)->flags |= CAMEL_STORE_SUBSCRIPTIONS;
-
+
store->storage_path = camel_session_get_storage_path (session, service, ex);
store->engine = camel_imap4_engine_new (service, imap4_reconnect);
-
+
/* setup/load the summary */
buf = g_alloca (strlen (store->storage_path) + 32);
sprintf (buf, "%s/.summary", store->storage_path);
store->summary = camel_imap4_store_summary_new ();
camel_store_summary_set_filename ((CamelStoreSummary *) store->summary, buf);
-
+
buf = camel_url_to_string (service->url, CAMEL_URL_HIDE_ALL);
url = camel_url_new (buf, NULL);
g_free (buf);
camel_store_summary_set_uri_base ((CamelStoreSummary *) store->summary, url);
camel_url_free (url);
-
+
camel_store_summary_load ((CamelStoreSummary *) store->summary);
}
CamelIMAP4Command *ic;
int id;
#endif
-
+
if (ssl_mode != MODE_CLEAR) {
#ifdef HAVE_SSL
if (ssl_mode == MODE_TLS) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect to %s: %s"),
service->url->host, _("SSL unavailable"));
-
+
return FALSE;
#endif /* HAVE_SSL */
} else {
tcp_stream = camel_tcp_stream_raw_new ();
}
-
+
if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai) == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
_("Could not connect to %s: %s"),
service->url->host,
g_strerror (errno));
-
+
camel_object_unref (tcp_stream);
-
+
return FALSE;
}
-
+
/* set some socket options to better tailor the connection to our needs */
sockopt.option = CAMEL_SOCKOPT_NODELAY;
sockopt.value.no_delay = TRUE;
camel_tcp_stream_setsockopt ((CamelTcpStream *) tcp_stream, &sockopt);
-
+
sockopt.option = CAMEL_SOCKOPT_KEEPALIVE;
sockopt.value.keep_alive = TRUE;
camel_tcp_stream_setsockopt ((CamelTcpStream *) tcp_stream, &sockopt);
-
+
if (camel_imap4_engine_take_stream (engine, tcp_stream, ex) == -1)
return FALSE;
-
+
if (camel_imap4_engine_capability (engine, ex) == -1)
return FALSE;
-
+
camel_imap4_store_summary_set_capabilities (((CamelIMAP4Store *) service)->summary, engine->capa);
-
+
if (ssl_mode != MODE_TLS) {
/* we're done */
return TRUE;
}
-
+
#ifdef HAVE_SSL
if (!(engine->capa & CAMEL_IMAP4_CAPABILITY_STARTTLS)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to IMAP server %s in secure mode: "
"Server does not support STARTTLS"),
service->url->host);
-
+
return FALSE;
}
-
+
ic = camel_imap4_engine_prequeue (engine, NULL, "STARTTLS\r\n");
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->result != CAMEL_IMAP4_RESULT_OK) {
if (ic->result != CAMEL_IMAP4_RESULT_OK) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
} else {
camel_exception_xfer (ex, &ic->ex);
}
-
+
camel_imap4_command_unref (ic);
-
+
return FALSE;
}
-
+
camel_imap4_command_unref (ic);
-
+
if (camel_tcp_stream_ssl_enable_ssl ((CamelTcpStreamSSL *) tcp_stream) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to IMAP server %s in secure mode: %s"),
service->url->host, _("TLS negotiations failed"));
return FALSE;
}
-
+
return TRUE;
#else
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to IMAP server %s in secure mode: %s"),
service->url->host, _("SSL is not available in this build"));
-
+
return FALSE;
#endif /* HAVE_SSL */
}
int mode, ret, i;
const char *port;
char *serv;
-
+
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
serv = "imap";
port = "143";
}
-
+
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
port = NULL;
}
-
+
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
camel_exception_clear (ex);
ai = camel_getaddrinfo (service->url->host, port, &hints, ex);
}
-
+
if (ai == NULL)
return FALSE;
-
+
ret = connect_to_server (engine, ai, mode, ex);
-
+
camel_freeaddrinfo (ai);
-
+
return ret;
}
/* Perform a single challenge iteration */
CamelSasl *sasl = ic->user_data;
char *challenge;
-
+
if (camel_sasl_authenticated (sasl)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("Cannot authenticate to IMAP server %s using the %s authentication mechanism"),
engine->url->host, engine->url->authmech);
return -1;
}
-
+
while (isspace (*linebuf))
linebuf++;
-
+
if (*linebuf == '\0')
linebuf = NULL;
-
+
if (!(challenge = camel_sasl_challenge_base64 (sasl, (const char *) linebuf, ex)))
return -1;
-
+
d(fprintf (stderr, "sending : %s\r\n", challenge));
-
+
if (camel_stream_printf (engine->ostream, "%s\r\n", challenge) == -1) {
g_free (challenge);
return -1;
}
-
+
g_free (challenge);
-
+
if (camel_stream_flush (engine->ostream) == -1)
return -1;
-
+
return 0;
}
CamelSasl *sasl = NULL;
CamelIMAP4Command *ic;
int id;
-
+
if (service->url->authmech)
mech = g_hash_table_lookup (engine->authtypes, service->url->authmech);
-
+
if ((!mech || (mech && mech->need_password)) && !service->url->passwd) {
guint32 flags = CAMEL_SESSION_PASSWORD_SECRET;
char *prompt;
-
+
if (reprompt)
flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
-
+
prompt = g_strdup_printf (_("%sPlease enter the IMAP password for %s on host %s"),
errmsg ? errmsg : "",
service->url->user,
service->url->host);
-
+
service->url->passwd = camel_session_get_password (session, service, NULL, prompt, "password", flags, ex);
-
+
g_free (prompt);
-
+
if (!service->url->passwd)
return FALSE;
}
-
+
if (service->url->authmech) {
sasl = camel_sasl_new ("imap", mech->authproto, service);
-
+
ic = camel_imap4_engine_prequeue (engine, NULL, "AUTHENTICATE %s\r\n", service->url->authmech);
ic->plus = sasl_auth;
ic->user_data = sasl;
ic = camel_imap4_engine_prequeue (engine, NULL, "LOGIN %S %S\r\n",
service->url->user, service->url->passwd);
}
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (sasl != NULL)
camel_object_unref (sasl);
-
+
if (id == -1 || ic->status == CAMEL_IMAP4_COMMAND_ERROR) {
/* unrecoverable error */
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
-
+
return FALSE;
}
-
+
if (ic->result != CAMEL_IMAP4_RESULT_OK) {
camel_imap4_command_unref (ic);
-
+
/* try again */
-
+
return TRUE;
}
-
+
camel_imap4_command_unref (ic);
-
+
return FALSE;
}
gboolean reprompt = FALSE;
char *errmsg = NULL;
CamelException lex;
-
+
if (!connect_to_server_wrapper (engine, ex))
return FALSE;
-
+
if (engine->state != CAMEL_IMAP4_ENGINE_AUTHENTICATED) {
#define CANT_USE_AUTHMECH (!g_hash_table_lookup (engine->authtypes, service->url->authmech))
if (service->url->authmech && CANT_USE_AUTHMECH) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("Cannot authenticate to IMAP server %s using %s"),
service->url->host, service->url->authmech);
-
+
return FALSE;
}
-
+
camel_exception_init (&lex);
while (imap4_try_authenticate (engine, reprompt, errmsg, &lex)) {
g_free (errmsg);
reprompt = TRUE;
}
g_free (errmsg);
-
+
if (camel_exception_is_set (&lex)) {
camel_exception_xfer (ex, &lex);
return FALSE;
}
}
-
+
if (camel_imap4_engine_namespace (engine, ex) == -1)
return FALSE;
-
+
camel_imap4_store_summary_set_namespaces (((CamelIMAP4Store *) service)->summary, &engine->namespaces);
-
+
return TRUE;
}
{
CamelIMAP4Store *store = (CamelIMAP4Store *) service;
gboolean retval;
-
+
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
-
+
CAMEL_SERVICE_REC_LOCK (service, connect_lock);
if (store->engine->state == CAMEL_IMAP4_ENGINE_DISCONNECTED)
retval = imap4_reconnect (store->engine, ex);
else
retval = TRUE;
CAMEL_SERVICE_REC_UNLOCK (service, connect_lock);
-
+
return retval;
}
CamelIMAP4Store *store = (CamelIMAP4Store *) service;
CamelIMAP4Command *ic;
int id;
-
+
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return TRUE;
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
if (clean && store->engine->state != CAMEL_IMAP4_ENGINE_DISCONNECTED) {
ic = camel_imap4_engine_queue (store->engine, NULL, "LOGOUT\r\n");
while ((id = camel_imap4_engine_iterate (store->engine)) < ic->id && id != -1)
;
-
+
camel_imap4_command_unref (ic);
}
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
-
+
return 0;
}
CamelServiceAuthType *authtype;
GList *sasl_types, *t, *next;
gboolean connected;
-
+
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return NULL;
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
connected = connect_to_server_wrapper (store->engine, ex);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
if (!connected)
return NULL;
-
+
sasl_types = camel_sasl_authtype_list (FALSE);
for (t = sasl_types; t; t = next) {
authtype = t->data;
next = t->next;
-
+
if (!g_hash_table_lookup (store->engine->authtypes, authtype->authproto)) {
sasl_types = g_list_remove_link (sasl_types, t);
g_list_free_1 (t);
}
}
-
+
return g_list_prepend (sasl_types, &camel_imap4_password_authtype);
}
char *real_name, *p;
char sep = '\0';
int len;
-
+
if (*folder_name) {
sep = camel_imap4_get_path_delim (((CamelIMAP4Store *) store)->summary, folder_name);
-
+
if (sep != '/') {
p = real_name = g_alloca (strlen (folder_name) + 1);
strcpy (real_name, folder_name);
*p = sep;
p++;
}
-
+
folder_name = real_name;
}
-
+
real_name = camel_utf8_utf7 (folder_name);
} else
real_name = g_strdup ("");
-
+
if (wildcard) {
len = strlen (real_name);
real_name = g_realloc (real_name, len + 3);
-
+
if (len > 0)
real_name[len++] = sep;
-
+
real_name[len++] = wildcard;
real_name[len] = '\0';
}
-
+
return real_name;
}
char *utf7_name;
int create;
int id, i;
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
if ((flags & CAMEL_STORE_FOLDER_CREATE) != 0) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create IMAP folders in offline mode."));
} else {
folder = camel_imap4_folder_new (store, folder_name, ex);
}
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
-
+
return folder;
}
-
+
/* make sure the folder exists - try LISTing it? */
utf7_name = imap4_folder_utf7_name (store, folder_name, '\0');
ic = camel_imap4_engine_queue (engine, NULL, "LIST \"\" %S\r\n", utf7_name);
camel_imap4_command_register_untagged (ic, "LIST", camel_imap4_untagged_list);
ic->user_data = array = g_ptr_array_new ();
g_free (utf7_name);
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
g_ptr_array_free (array, TRUE);
goto done;
}
-
+
create = array->len == 0;
-
+
for (i = 0; i < array->len; i++) {
list = array->pdata[i];
g_free (list->name);
g_free (list);
}
-
+
g_ptr_array_free (array, TRUE);
-
+
if (ic->result != CAMEL_IMAP4_RESULT_OK) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot get folder `%s' on IMAP server %s: Unknown"),
camel_imap4_command_unref (ic);
goto done;
}
-
+
camel_imap4_command_unref (ic);
-
+
if (create) {
const char *basename;
char *parent;
int len;
-
+
if (!(flags & CAMEL_STORE_FOLDER_CREATE))
goto done;
-
+
if (!(basename = strrchr (folder_name, '/')))
basename = folder_name;
else
basename++;
-
+
len = basename > folder_name ? (basename - folder_name) - 1 : 0;
parent = g_alloca (len + 1);
memcpy (parent, folder_name, len);
parent[len] = '\0';
-
+
if (!(fi = imap4_create_folder (store, parent, basename, ex)))
goto done;
-
+
camel_store_free_folder_info (store, fi);
}
-
+
folder = camel_imap4_folder_new (store, folder_name, ex);
-
+
done:
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
-
+
return folder;
}
GPtrArray *array;
char *utf7_name;
int id, i;
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
utf7_name = imap4_folder_utf7_name (store, folder_name, '\0');
-
+
ic = camel_imap4_engine_queue (engine, NULL, "LIST \"\" %S\r\n", utf7_name);
camel_imap4_command_register_untagged (ic, "LIST", camel_imap4_untagged_list);
ic->user_data = array = g_ptr_array_new ();
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
-
+
for (i = 0; i < array->len; i++) {
list = array->pdata[i];
g_free (list->name);
g_free (list);
}
-
+
goto done;
}
-
+
if (ic->result != CAMEL_IMAP4_RESULT_OK) {
camel_imap4_command_unref (ic);
-
+
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot get LIST information for `%s' on IMAP server %s: %s"),
folder_name, engine->url->host, ic->result == CAMEL_IMAP4_RESULT_BAD ?
_("Bad command") : _("Unknown"));
-
+
for (i = 0; i < array->len; i++) {
list = array->pdata[i];
g_free (list->name);
g_free (list);
}
-
+
goto done;
}
-
+
flags = 0;
for (i = 0; i < array->len; i++) {
list = array->pdata[i];
g_free (list->name);
g_free (list);
}
-
+
done:
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
-
+
g_ptr_array_free (array, TRUE);
g_free (utf7_name);
-
+
return (flags & CAMEL_FOLDER_NOINFERIORS) == 0;
}
CamelURL *url;
const char *c;
int id;
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
utf7_name = imap4_folder_utf7_name (store, folder_name, '\0');
ic = camel_imap4_engine_queue (engine, NULL, "CREATE %S%s\r\n", utf7_name, subfolder_hint);
g_free (utf7_name);
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
goto done;
}
-
+
switch (ic->result) {
case CAMEL_IMAP4_RESULT_OK:
url = camel_url_copy (engine->url);
camel_url_set_fragment (url, folder_name);
-
+
c = strrchr (folder_name, '/');
-
+
fi = g_malloc0 (sizeof (CamelFolderInfo));
fi->full_name = g_strdup (folder_name);
fi->name = g_strdup (c ? c + 1: folder_name);
fi->flags = 0;
fi->unread = -1;
fi->total = -1;
-
+
camel_imap4_store_summary_note_info (((CamelIMAP4Store *) store)->summary, fi);
-
+
camel_object_trigger_event (store, "folder_created", fi);
break;
case CAMEL_IMAP4_RESULT_NO:
default:
g_assert_not_reached ();
}
-
+
camel_imap4_command_unref (ic);
-
+
done:
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
-
+
return fi;
}
CamelFolderInfo *fi = NULL;
char hint[2];
char sep;
-
+
sep = camel_imap4_get_path_delim (((CamelIMAP4Store *) store)->summary, folder_name);
sprintf (hint, "%c", sep);
-
+
imap4_delete_folder (store, folder_name, ex);
if (camel_exception_is_set (ex))
return FALSE;
-
+
if (!(fi = imap4_folder_create (store, folder_name, hint, ex)))
return FALSE;
-
+
camel_folder_info_free (fi);
-
+
return TRUE;
}
const char *c;
char *name;
char sep;
-
+
sep = camel_imap4_get_path_delim (((CamelIMAP4Store *) store)->summary, parent_name);
-
+
c = folder_name;
while (*c != '\0') {
if (*c == sep || strchr ("/#%*", *c)) {
folder_name, *c);
return NULL;
}
-
+
c++;
}
-
+
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create IMAP folders in offline mode."));
return NULL;
}
-
+
if (parent_name != NULL && *parent_name) {
CamelException lex;
-
+
camel_exception_init (&lex);
if (!imap4_folder_can_contain_folders (store, parent_name, &lex)) {
if (camel_exception_is_set (&lex)) {
camel_exception_xfer (ex, &lex);
return NULL;
}
-
+
if (!imap4_folder_recreate (store, parent_name, &lex)) {
camel_exception_xfer (ex, &lex);
return NULL;
}
}
-
+
name = g_strdup_printf ("%s/%s", parent_name, folder_name);
} else
name = g_strdup (folder_name);
-
+
fi = imap4_folder_create (store, name, "", ex);
g_free (name);
-
+
return fi;
}
CamelURL *url;
const char *p;
int id;
-
+
if (!g_ascii_strcasecmp (folder_name, "INBOX")) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot delete folder `%s': Special folder"),
folder_name);
-
+
return;
}
-
+
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot delete IMAP folders in offline mode."));
return;
}
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
if (selected && !strcmp (folder_name, selected->full_name))
ic0 = camel_imap4_engine_queue (engine, NULL, "CLOSE\r\n");
-
+
utf7_name = imap4_folder_utf7_name (store, folder_name, '\0');
ic = camel_imap4_engine_queue (engine, NULL, "DELETE %S\r\n", utf7_name);
g_free (utf7_name);
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
if (ic0 && ic0->status != CAMEL_IMAP4_COMMAND_COMPLETE)
camel_exception_xfer (ex, &ic0->ex);
else
camel_exception_xfer (ex, &ic->ex);
-
+
if (ic0 != NULL)
camel_imap4_command_unref (ic0);
-
+
camel_imap4_command_unref (ic);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return;
}
-
+
if (ic0 != NULL)
camel_imap4_command_unref (ic0);
-
+
switch (ic->result) {
case CAMEL_IMAP4_RESULT_OK:
/* deleted */
url = camel_url_copy (engine->url);
camel_url_set_fragment (url, folder_name);
-
+
p = strrchr (folder_name, '/');
-
+
fi = g_malloc0 (sizeof (CamelFolderInfo));
fi->full_name = g_strdup (folder_name);
fi->name = g_strdup (p ? p + 1: folder_name);
fi->flags = 0;
fi->unread = -1;
fi->total = -1;
-
+
camel_imap4_store_summary_unnote_info (((CamelIMAP4Store *) store)->summary, fi);
-
+
camel_object_trigger_event (store, "folder_deleted", fi);
-
+
camel_folder_info_free (fi);
break;
case CAMEL_IMAP4_RESULT_NO:
folder_name);
break;
}
-
+
camel_imap4_command_unref (ic);
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
}
char *old_uname, *new_uname;
CamelIMAP4Command *ic;
int id;
-
+
if (!g_ascii_strcasecmp (old_name, "INBOX")) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot rename folder `%s' to `%s': Special folder"),
old_name, new_name);
-
+
return;
}
-
+
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot rename IMAP folders in offline mode."));
return;
}
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
old_uname = imap4_folder_utf7_name (store, old_name, '\0');
new_uname = imap4_folder_utf7_name (store, new_name, '\0');
-
+
ic = camel_imap4_engine_queue (engine, NULL, "RENAME %S %S\r\n", old_uname, new_uname);
g_free (old_uname);
g_free (new_uname);
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return;
}
-
+
switch (ic->result) {
case CAMEL_IMAP4_RESULT_OK:
/* FIXME: need to update state on the renamed folder object */
old_name, new_name);
break;
}
-
+
camel_imap4_command_unref (ic);
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
}
{
camel_imap4_list_t *list, *last;
int i;
-
+
last = array->pdata[0];
for (i = 1; i < array->len; i++) {
list = array->pdata[i];
GPtrArray *array;
char *mailbox;
int id, i;
-
+
mailbox = imap4_folder_utf7_name (store, fi->full_name, '\0');
ic = camel_imap4_engine_queue (engine, NULL, "STATUS %S (MESSAGES UNSEEN)\r\n", mailbox);
g_free (mailbox);
-
+
camel_imap4_command_register_untagged (ic, "STATUS", camel_imap4_untagged_status);
ic->user_data = array = g_ptr_array_new ();
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_imap4_command_unref (ic);
g_ptr_array_free (array, TRUE);
return;
}
-
+
for (i = 0; i < array->len; i++) {
status = array->pdata[i];
attr = status->attr_list;
g_free (attr);
attr = next;
}
-
+
g_free (status->mailbox);
g_free (status);
}
-
+
camel_imap4_command_unref (ic);
g_ptr_array_free (array, TRUE);
}
GPtrArray *array;
char *mailbox;
int id, i;
-
+
mailbox = imap4_folder_utf7_name (store, fi->full_name, '\0');
ic = camel_imap4_engine_queue (engine, NULL, "LSUB \"\" %S\r\n", mailbox);
camel_imap4_command_register_untagged (ic, "LSUB", camel_imap4_untagged_list);
ic->user_data = array = g_ptr_array_new ();
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
camel_imap4_command_unref (ic);
for (i = 0; i < array->len; i++) {
lsub = array->pdata[i];
-
+
if (!strcmp (lsub->name, mailbox))
fi->flags |= CAMEL_FOLDER_SUBSCRIBED;
-
+
g_free (lsub->name);
g_free (lsub);
}
-
+
g_ptr_array_free (array, TRUE);
}
char *name, *p;
CamelURL *url;
int i;
-
+
if (array->len == 0) {
g_ptr_array_free (array, TRUE);
return NULL;
}
-
+
g_ptr_array_sort (array, (GCompareFunc) list_sort);
-
+
list_remove_duplicates (array);
-
+
url = camel_url_copy (engine->url);
-
+
if (!strcmp (top, "") && (flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE)) {
/* clear the folder-info cache */
camel_store_summary_clear ((CamelStoreSummary *) ((CamelIMAP4Store *) store)->summary);
}
-
+
for (i = 0; i < array->len; i++) {
list = array->pdata[i];
fi = g_malloc0 (sizeof (CamelFolderInfo));
-
+
p = name = camel_utf7_utf8 (list->name);
while (*p != '\0') {
if (*p == list->delim)
*p = '/';
p++;
}
-
+
p = strrchr (name, '/');
camel_url_set_fragment (url, name);
-
+
fi->full_name = name;
fi->name = g_strdup (p ? p + 1: name);
fi->uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
fi->flags = list->flags | (lsub ? CAMEL_FOLDER_SUBSCRIBED : 0);
fi->unread = -1;
fi->total = -1;
-
+
if (!g_ascii_strcasecmp (fi->full_name, "INBOX"))
fi->flags |= CAMEL_FOLDER_SYSTEM | CAMEL_FOLDER_TYPE_INBOX;
-
+
/* SELECTED folder, just get it from the folder */
if (folder && !strcmp (folder->full_name, fi->full_name)) {
camel_object_get (folder, NULL, CAMEL_FOLDER_TOTAL, &fi->total, CAMEL_FOLDER_UNREAD, &fi->unread, 0);
} else if (!(flags & CAMEL_STORE_FOLDER_INFO_FAST)) {
imap4_status (store, fi);
}
-
+
if (!(fi->flags & CAMEL_FOLDER_SUBSCRIBED))
imap4_subscription_info (store, fi);
-
+
array->pdata[i] = fi;
-
+
camel_imap4_store_summary_note_info (((CamelIMAP4Store *) store)->summary, fi);
-
+
if (!g_ascii_strcasecmp (fi->full_name, "INBOX")) {
g_free (fi->name);
fi->name = g_strdup (_("Inbox"));
}
-
+
g_free (list->name);
g_free (list);
}
-
+
fi = camel_folder_info_build (array, top, '/', TRUE);
-
+
camel_url_free (url);
-
+
g_ptr_array_free (array, TRUE);
-
+
camel_store_summary_save ((CamelStoreSummary *) ((CamelIMAP4Store *) store)->summary);
-
+
return fi;
}
char *pattern;
char wildcard;
int id, i;
-
+
if (top == NULL)
top = "";
-
+
if (!(namespace = camel_url_get_param (((CamelService *) store)->url, "namespace")))
namespace = "";
-
+
if (!strcmp (top, ""))
base = namespace;
else
base = top;
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
#ifdef USE_FOLDER_INFO_CACHE_LOGIC_FOR_SPEED
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL
|| engine->state == CAMEL_IMAP4_ENGINE_DISCONNECTED) {
fi = inbox;
}
}
-
+
if (fi == NULL && ((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
/* folder info hasn't yet been cached and the store hasn't been
* connected yet, but the network is available so we can connect
return fi;
}
#endif
-
+
#ifdef USE_FOLDER_INFO_CACHE_LOGIC_FOR_SPEED
check_online:
#endif
-
+
if (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)
cmd = "LSUB";
else
cmd = "LIST";
-
+
wildcard = (flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) ? '*' : '%';
pattern = imap4_folder_utf7_name (store, base, wildcard);
array = g_ptr_array_new ();
-
+
if (base == namespace && *namespace) {
/* Make sure to get INBOX: we always use LIST so the user sees his/her INBOX even
if it isn't subscribed and the user has enabled "Only show subscribed folders" */
camel_imap4_command_register_untagged (ic1, "LIST", camel_imap4_untagged_list);
ic1->user_data = array;
}
-
+
if (*top != '\0') {
size_t len;
char sep;
-
+
len = strlen (pattern);
sep = pattern[len - 2];
pattern[len - 2] = '\0';
-
+
ic0 = camel_imap4_engine_queue (engine, NULL, "%s \"\" %S\r\n", cmd, pattern);
camel_imap4_command_register_untagged (ic0, cmd, camel_imap4_untagged_list);
ic0->user_data = array;
-
+
pattern[len - 2] = sep;
}
-
+
ic = camel_imap4_engine_queue (engine, NULL, "%s \"\" %S\r\n", cmd, pattern);
camel_imap4_command_register_untagged (ic, cmd, camel_imap4_untagged_list);
ic->user_data = array;
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
if (ic1 && ic1->status != CAMEL_IMAP4_COMMAND_COMPLETE)
camel_exception_xfer (ex, &ic1->ex);
camel_exception_xfer (ex, &ic0->ex);
else
camel_exception_xfer (ex, &ic->ex);
-
+
if (ic1 != NULL)
camel_imap4_command_unref (ic1);
-
+
if (ic0 != NULL)
camel_imap4_command_unref (ic0);
-
+
camel_imap4_command_unref (ic);
-
+
for (i = 0; i < array->len; i++) {
list = array->pdata[i];
g_free (list->name);
g_free (list);
}
-
+
g_ptr_array_free (array, TRUE);
g_free (pattern);
-
+
goto done;
}
-
+
if (ic1 != NULL)
camel_imap4_command_unref (ic1);
-
+
if (ic0 != NULL)
camel_imap4_command_unref (ic0);
-
+
if (ic->result != CAMEL_IMAP4_RESULT_OK) {
camel_imap4_command_unref (ic);
-
+
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot get %s information for pattern `%s' on IMAP server %s: %s"),
cmd, pattern, engine->url->host, ic->result == CAMEL_IMAP4_RESULT_BAD ?
_("Bad command") : _("Unknown"));
-
+
for (i = 0; i < array->len; i++) {
list = array->pdata[i];
g_free (list->name);
g_free (list);
}
-
+
g_ptr_array_free (array, TRUE);
-
+
g_free (pattern);
-
+
goto done;
}
-
+
g_free (pattern);
-
+
fi = imap4_build_folder_info (store, top, flags, array);
-
+
done:
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
-
+
return fi;
}
CamelURL *url;
const char *p;
int id;
-
+
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot subscribe to IMAP folders in offline mode."));
return;
}
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
utf7_name = imap4_folder_utf7_name (store, folder_name, '\0');
ic = camel_imap4_engine_queue (engine, NULL, "SUBSCRIBE %S\r\n", utf7_name);
g_free (utf7_name);
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return;
}
-
+
switch (ic->result) {
case CAMEL_IMAP4_RESULT_OK:
/* subscribed */
url = camel_url_copy (engine->url);
camel_url_set_fragment (url, folder_name);
-
+
p = strrchr (folder_name, '/');
-
+
fi = g_malloc0 (sizeof (CamelFolderInfo));
fi->full_name = g_strdup (folder_name);
fi->name = g_strdup (p ? p + 1: folder_name);
fi->flags = CAMEL_FOLDER_NOCHILDREN;
fi->unread = -1;
fi->total = -1;
-
+
camel_imap4_store_summary_note_info (((CamelIMAP4Store *) store)->summary, fi);
-
+
camel_object_trigger_event (store, "folder_subscribed", fi);
camel_folder_info_free (fi);
break;
folder_name);
break;
}
-
+
camel_imap4_command_unref (ic);
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
}
CamelURL *url;
const char *p;
int id;
-
+
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot unsubscribe from IMAP folders in offline mode."));
return;
}
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
utf7_name = imap4_folder_utf7_name (store, folder_name, '\0');
ic = camel_imap4_engine_queue (engine, NULL, "UNSUBSCRIBE %S\r\n", utf7_name);
g_free (utf7_name);
-
+
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_exception_xfer (ex, &ic->ex);
camel_imap4_command_unref (ic);
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
return;
}
-
+
switch (ic->result) {
case CAMEL_IMAP4_RESULT_OK:
/* unsubscribed */
url = camel_url_copy (engine->url);
camel_url_set_fragment (url, folder_name);
-
+
p = strrchr (folder_name, '/');
-
+
fi = g_malloc0 (sizeof (CamelFolderInfo));
fi->full_name = g_strdup (folder_name);
fi->name = g_strdup (p ? p + 1: folder_name);
fi->flags = 0;
fi->unread = -1;
fi->total = -1;
-
+
camel_imap4_store_summary_unnote_info (((CamelIMAP4Store *) store)->summary, fi);
-
+
camel_object_trigger_event (store, "folder_unsubscribed", fi);
camel_folder_info_free (fi);
break;
folder_name);
break;
}
-
+
camel_imap4_command_unref (ic);
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
}
CamelFolder *folder = (CamelFolder *) engine->folder;
CamelIMAP4Command *ic;
int id;
-
+
if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
return;
-
+
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
-
+
if (folder) {
camel_folder_sync (folder, FALSE, ex);
if (camel_exception_is_set (ex)) {
return;
}
}
-
+
ic = camel_imap4_engine_queue (engine, NULL, "NOOP\r\n");
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE)
camel_exception_xfer (ex, &ic->ex);
-
+
camel_imap4_command_unref (ic);
-
+
if (folder && !camel_exception_is_set (ex))
camel_imap4_summary_flush_updates (folder->summary, ex);
-
+
CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
}
struct _CamelIMAP4Store {
CamelOfflineStore parent_object;
-
+
struct _CamelIMAP4StoreSummary *summary;
struct _CamelIMAP4Engine *engine;
char *storage_path;
struct _CamelIMAP4StoreClass {
CamelOfflineStoreClass parent_class;
-
+
};
camel_imap4_stream_get_type (void)
{
static CamelType type = 0;
-
+
if (!type) {
type = camel_type_register (CAMEL_STREAM_TYPE,
"CamelIMAP4Stream",
(CamelObjectInitFunc) camel_imap4_stream_init,
(CamelObjectFinalizeFunc) camel_imap4_stream_finalize);
}
-
+
return type;
}
camel_imap4_stream_class_init (CamelIMAP4StreamClass *klass)
{
CamelStreamClass *stream_class = (CamelStreamClass *) klass;
-
+
parent_class = (CamelStreamClass *) camel_type_get_global_classfuncs (CAMEL_STREAM_TYPE);
-
+
/* virtual method overload */
stream_class->read = stream_read;
stream_class->write = stream_write;
camel_imap4_stream_init (CamelIMAP4Stream *imap4, CamelIMAP4StreamClass *klass)
{
imap4->stream = NULL;
-
+
imap4->mode = CAMEL_IMAP4_STREAM_MODE_TOKEN;
imap4->disconnected = FALSE;
imap4->have_unget = FALSE;
imap4->eol = FALSE;
-
+
imap4->literal = 0;
-
+
imap4->inbuf = imap4->realbuf + IMAP4_READ_PRELEN;
imap4->inptr = imap4->inbuf;
imap4->inend = imap4->inbuf;
-
+
imap4->tokenbuf = g_malloc (IMAP4_TOKEN_LEN);
imap4->tokenptr = imap4->tokenbuf;
imap4->tokenleft = IMAP4_TOKEN_LEN;
camel_imap4_stream_finalize (CamelObject *object)
{
CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) object;
-
+
if (imap4->stream)
camel_object_unref (imap4->stream);
-
+
g_free (imap4->tokenbuf);
}
unsigned char *inbuf, *inptr, *inend;
ssize_t nread;
size_t inlen;
-
+
if (imap4->disconnected) {
errno = EINVAL;
return -1;
}
-
+
inbuf = imap4->inbuf;
inptr = imap4->inptr;
inend = imap4->inend;
inlen = inend - inptr;
-
+
g_assert (inptr <= inend);
-
+
/* attempt to align 'inend' with realbuf + SCAN_HEAD */
if (inptr >= inbuf) {
inbuf -= inlen < IMAP4_READ_PRELEN ? inlen : IMAP4_READ_PRELEN;
inbuf += inlen;
} else if (inptr > imap4->realbuf) {
size_t shift;
-
+
shift = MIN (inptr - imap4->realbuf, inend - inbuf);
memmove (inptr - shift, inptr, inlen);
inptr -= shift;
/* we can't shift... */
inbuf = inend;
}
-
+
imap4->inptr = inptr;
imap4->inend = inbuf;
inend = imap4->realbuf + IMAP4_READ_PRELEN + IMAP4_READ_BUFLEN - 1;
-
+
if ((nread = camel_stream_read (imap4->stream, inbuf, inend - inbuf)) == -1)
return -1;
else if (nread == 0)
imap4->disconnected = TRUE;
-
+
imap4->inend += nread;
-
+
return imap4->inend - imap4->inptr;
}
{
CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) stream;
ssize_t len, nread = 0;
-
+
if (imap4->mode == CAMEL_IMAP4_STREAM_MODE_LITERAL) {
/* don't let our caller read past the end of the literal */
n = MIN (n, imap4->literal);
}
-
+
if (imap4->inptr < imap4->inend) {
len = MIN (n, imap4->inend - imap4->inptr);
memcpy (buffer, imap4->inptr, len);
imap4->inptr += len;
nread = len;
}
-
+
if (nread < n) {
if ((len = camel_stream_read (imap4->stream, buffer + nread, n - nread)) == 0)
imap4->disconnected = TRUE;
else if (len == -1)
return -1;
-
+
nread += len;
}
-
+
if (imap4->mode == CAMEL_IMAP4_STREAM_MODE_LITERAL) {
imap4->literal -= nread;
-
+
if (imap4->literal == 0) {
imap4->mode = CAMEL_IMAP4_STREAM_MODE_TOKEN;
imap4->eol = TRUE;
}
}
-
+
return nread;
}
{
CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) stream;
ssize_t nwritten;
-
+
if (imap4->disconnected) {
errno = EINVAL;
return -1;
}
-
+
if ((nwritten = camel_stream_write (imap4->stream, buffer, n)) == 0)
imap4->disconnected = TRUE;
-
+
return nwritten;
}
stream_flush (CamelStream *stream)
{
CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) stream;
-
+
return camel_stream_flush (imap4->stream);
}
stream_close (CamelStream *stream)
{
CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) stream;
-
+
if (camel_stream_close (imap4->stream) == -1)
return -1;
-
+
camel_object_unref (imap4->stream);
imap4->stream = NULL;
-
+
imap4->disconnected = TRUE;
-
+
return 0;
}
stream_eos (CamelStream *stream)
{
CamelIMAP4Stream *imap4 = (CamelIMAP4Stream *) stream;
-
+
if (imap4->eol)
return TRUE;
-
+
if (imap4->disconnected && imap4->inptr == imap4->inend)
return TRUE;
-
+
if (camel_stream_eos (imap4->stream))
return TRUE;
-
+
return FALSE;
}
camel_imap4_stream_new (CamelStream *stream)
{
CamelIMAP4Stream *imap4;
-
+
g_return_val_if_fail (CAMEL_IS_STREAM (stream), NULL);
-
+
imap4 = (CamelIMAP4Stream *) camel_object_new (CAMEL_TYPE_IMAP4_STREAM);
camel_object_ref (stream);
imap4->stream = stream;
-
+
return (CamelStream *) imap4;
}
size_t literal = 0;
guint32 nz_number;
int ret;
-
+
g_return_val_if_fail (CAMEL_IS_IMAP4_STREAM (stream), -1);
g_return_val_if_fail (stream->mode != CAMEL_IMAP4_STREAM_MODE_LITERAL, -1);
g_return_val_if_fail (token != NULL, -1);
-
+
if (stream->have_unget) {
memcpy (token, &stream->unget, sizeof (camel_imap4_token_t));
stream->have_unget = FALSE;
return 0;
}
-
+
token_clear (stream);
-
+
inptr = stream->inptr;
inend = stream->inend;
*inend = '\0';
-
+
do {
if (inptr == inend) {
if ((ret = imap4_fill (stream)) < 0) {
token->token = CAMEL_IMAP4_TOKEN_NO_DATA;
return 0;
}
-
+
inptr = stream->inptr;
inend = stream->inend;
*inend = '\0';
}
-
+
while (*inptr == ' ' || *inptr == '\r')
inptr++;
} while (inptr == inend);
-
+
do {
if (inptr < inend) {
if (*inptr == '"') {
/* qstring token */
escaped = FALSE;
start = inptr;
-
+
/* eat the beginning " */
inptr++;
-
+
p = inptr;
while (inptr < inend) {
if (*inptr == '"' && !escaped)
break;
-
+
if (*inptr == '\\' && !escaped) {
token_save (stream, p, inptr - p);
escaped = TRUE;
escaped = FALSE;
}
}
-
+
token_save (stream, p, inptr - p);
-
+
if (inptr == inend) {
stream->inptr = start;
goto refill;
}
-
+
/* eat the ending " */
inptr++;
-
+
/* nul-terminate the atom token */
token_save (stream, "", 1);
-
+
token->token = CAMEL_IMAP4_TOKEN_QSTRING;
token->v.qstring = stream->tokenbuf;
-
+
d(fprintf (stderr, "token: \"%s\"\n", token->v.qstring));
-
+
break;
} else if (strchr ("+*()[]\n", *inptr)) {
/* special character token */
token->token = *inptr++;
-
+
if (camel_debug ("imap4:stream")) {
if (token->token != '\n')
fprintf (stderr, "token: %c\n", token->token);
else
fprintf (stderr, "token: \\n\n");
}
-
+
break;
} else if (*inptr == '{') {
/* literal identifier token */
if ((p = strchr (inptr, '}')) && strchr (p, '\n')) {
inptr++;
-
+
while (isdigit ((int) *inptr) && literal < UINT_MAX / 10)
literal = (literal * 10) + (*inptr++ - '0');
-
+
if (*inptr != '}') {
if (isdigit ((int) *inptr))
g_warning ("illegal literal identifier: literal too large");
else if (*inptr != '+')
g_warning ("illegal literal identifier: garbage following size");
-
+
while (*inptr != '}')
inptr++;
}
-
+
/* skip over '}' */
inptr++;
-
+
/* skip over any trailing whitespace */
while (*inptr == ' ' || *inptr == '\r')
inptr++;
-
+
if (*inptr != '\n') {
g_warning ("illegal token following literal identifier: %s", inptr);
-
+
/* skip ahead to the eoln */
inptr = strchr (inptr, '\n');
}
-
+
/* skip over '\n' */
inptr++;
-
+
token->token = CAMEL_IMAP4_TOKEN_LITERAL;
token->v.literal = literal;
-
+
d(fprintf (stderr, "token: {%lu}\n", literal));
-
+
stream->mode = CAMEL_IMAP4_STREAM_MODE_LITERAL;
stream->literal = literal;
stream->eol = FALSE;
-
+
break;
} else {
stream->inptr = inptr;
nz_number = strtoul ((char *) inptr, (char **) &start, 10);
if (start == inend)
goto refill;
-
+
if (*start == ':' || *start == ',') {
/* workaround for 'set' tokens (APPENDUID / COPYUID) */
goto atom_token;
}
-
+
inptr = start;
token->token = CAMEL_IMAP4_TOKEN_NUMBER;
token->v.number = nz_number;
-
+
d(fprintf (stderr, "token: %lu\n", nz_number));
-
+
break;
} else if (is_atom (*inptr)) {
atom_token:
/* simple atom token */
start = inptr;
-
+
while (inptr < inend && is_atom (*inptr))
inptr++;
-
+
if (inptr == inend) {
stream->inptr = start;
goto refill;
}
-
+
token_save (stream, start, inptr - start);
-
+
/* nul-terminate the atom token */
token_save (stream, "", 1);
-
+
if (!strcmp (stream->tokenbuf, "NIL")) {
/* special atom token */
token->token = CAMEL_IMAP4_TOKEN_NIL;
token->v.atom = stream->tokenbuf;
d(fprintf (stderr, "token: %s\n", token->v.atom));
}
-
+
break;
} else if (*inptr == '\\') {
/* possible flag token ("\" atom) */
start = inptr++;
-
+
while (inptr < inend && is_atom (*inptr))
inptr++;
-
+
if (inptr == inend) {
stream->inptr = start;
goto refill;
}
-
+
/* handle the \* case */
if ((inptr - start) == 1 && *inptr == '*')
inptr++;
-
+
if ((inptr - start) > 1) {
token_save (stream, start, inptr - start);
-
+
/* nul-terminate the flag token */
token_save (stream, "", 1);
-
+
token->token = CAMEL_IMAP4_TOKEN_FLAG;
token->v.atom = stream->tokenbuf;
d(fprintf (stderr, "token: %s\n", token->v.atom));
} else {
refill:
token_clear (stream);
-
+
if (imap4_fill (stream) <= 0) {
token->token = CAMEL_IMAP4_TOKEN_ERROR;
return -1;
}
-
+
inptr = stream->inptr;
inend = stream->inend;
*inend = '\0';
}
} while (inptr < inend);
-
+
stream->inptr = inptr;
-
+
return 0;
}
{
if (stream->have_unget)
return -1;
-
+
if (token->token != CAMEL_IMAP4_TOKEN_NO_DATA) {
memcpy (&stream->unget, token, sizeof (camel_imap4_token_t));
stream->have_unget = TRUE;
}
-
+
return 0;
}
{
register unsigned char *inptr;
unsigned char *inend;
-
+
g_return_val_if_fail (CAMEL_IS_IMAP4_STREAM (stream), -1);
g_return_val_if_fail (stream->mode != CAMEL_IMAP4_STREAM_MODE_LITERAL, -1);
g_return_val_if_fail (line != NULL, -1);
g_return_val_if_fail (len != NULL, -1);
-
+
inptr = stream->inptr;
inend = stream->inend;
-
+
*inend = '\0';
if (inptr == inend || ((inend - inptr) < 2 && *inptr != '\n')) {
if (imap4_fill (stream) == -1 && stream->inptr == stream->inend)
return -1;
}
-
+
*line = stream->inptr;
inptr = stream->inptr;
inend = stream->inend;
*inend = '\n';
-
+
while (*inptr != '\n')
inptr++;
-
+
*len = (inptr - stream->inptr);
-
+
if (inptr > stream->inptr && inptr[-1] == '\r')
inptr[-1] = '\0';
-
+
if (inptr < inend) {
/* got the eoln */
inptr[0] = '\0';
*len += 1;
-
+
stream->inptr = inptr + 1;
-
+
return 0;
}
-
+
stream->inptr = inptr;
-
+
return 1;
}
{
unsigned char *inptr, *inend;
size_t nread;
-
+
g_return_val_if_fail (CAMEL_IS_IMAP4_STREAM (stream), -1);
g_return_val_if_fail (stream->mode == CAMEL_IMAP4_STREAM_MODE_LITERAL, -1);
g_return_val_if_fail (literal != NULL, -1);
g_return_val_if_fail (len != NULL, -1);
-
+
if (stream->eol) {
*len = 0;
return 0;
}
-
+
if ((stream->inend - stream->inptr) < 1) {
/* keep our buffer full to the optimal size */
if (imap4_fill (stream) == -1 && stream->inptr == stream->inend)
return -1;
}
-
+
*literal = inptr = stream->inptr;
inend = stream->inend;
if ((inend - inptr) > stream->literal)
inend = inptr + stream->literal;
else
inend = stream->inend;
-
+
*len = nread = inend - inptr;
-
+
stream->literal -= nread;
stream->inptr += nread;
-
+
if (stream->literal == 0) {
stream->mode = CAMEL_IMAP4_STREAM_MODE_TOKEN;
stream->eol = TRUE;
return 0;
}
-
+
return 1;
}
struct _CamelIMAP4Stream {
CamelStream parent_object;
-
+
CamelStream *stream;
-
+
guint disconnected:1; /* disconnected state */
guint have_unget:1; /* have an unget token */
guint mode:1; /* TOKEN vs LITERAL */
guint eol:1; /* end-of-literal */
-
+
size_t literal;
-
+
/* i/o buffers */
unsigned char realbuf[IMAP4_READ_PRELEN + IMAP4_READ_BUFLEN + 1];
unsigned char *inbuf;
unsigned char *inptr;
unsigned char *inend;
-
+
/* token buffers */
unsigned char *tokenbuf;
unsigned char *tokenptr;
unsigned int tokenleft;
-
+
camel_imap4_token_t unget;
};
struct _CamelIMAP4StreamClass {
CamelStreamClass parent_class;
-
+
/* Virtual methods */
};
camel_imap4_summary_get_type (void)
{
static CamelType type = 0;
-
+
if (!type) {
type = camel_type_register (CAMEL_FOLDER_SUMMARY_TYPE,
"CamelIMAP4Summary",
(CamelObjectInitFunc) camel_imap4_summary_init,
(CamelObjectFinalizeFunc) camel_imap4_summary_finalize);
}
-
+
return type;
}
camel_imap4_summary_class_init (CamelIMAP4SummaryClass *klass)
{
CamelFolderSummaryClass *summary_class = (CamelFolderSummaryClass *) klass;
-
+
parent_class = (CamelFolderSummaryClass *) camel_type_get_global_classfuncs (camel_folder_summary_get_type ());
-
+
summary_class->summary_header_load = imap4_header_load;
summary_class->summary_header_save = imap4_header_save;
summary_class->message_info_new_from_header = imap4_message_info_new_from_header;
camel_imap4_summary_init (CamelIMAP4Summary *summary, CamelIMAP4SummaryClass *klass)
{
CamelFolderSummary *folder_summary = (CamelFolderSummary *) summary;
-
+
folder_summary->flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_DELETED |
CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_SEEN;
-
+
folder_summary->message_info_size = sizeof (CamelIMAP4MessageInfo);
folder_summary->content_info_size = sizeof (CamelIMAP4MessageContentInfo);
-
+
((CamelFolderSummary *) summary)->flags |= CAMEL_IMAP4_SUMMARY_HAVE_MLIST;
-
+
summary->update_flags = TRUE;
summary->uidvalidity_changed = FALSE;
}
camel_imap4_summary_new (CamelFolder *folder)
{
CamelFolderSummary *summary;
-
+
summary = (CamelFolderSummary *) camel_object_new (CAMEL_TYPE_IMAP4_SUMMARY);
summary->folder = folder;
-
+
return summary;
}
imap4_header_load (CamelFolderSummary *summary, FILE *fin)
{
CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
-
+
if (CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_load (summary, fin) == -1)
return -1;
-
+
if (camel_file_util_decode_fixed_int32 (fin, &imap4_summary->version) == -1)
return -1;
-
+
if (imap4_summary->version > CAMEL_IMAP4_SUMMARY_VERSION) {
g_warning ("Unknown IMAP4 summary version\n");
errno = EINVAL;
return -1;
}
-
+
if (imap4_summary->version == 2) {
/* check that we have Mailing-List info */
int have_mlist;
-
+
if (camel_file_util_decode_fixed_int32 (fin, &have_mlist) == -1)
return -1;
-
+
if (have_mlist)
summary->flags |= CAMEL_IMAP4_SUMMARY_HAVE_MLIST;
else
summary->flags ^= CAMEL_IMAP4_SUMMARY_HAVE_MLIST;
}
-
+
if (camel_file_util_decode_fixed_int32 (fin, &imap4_summary->uidvalidity) == -1)
return -1;
-
+
return 0;
}
imap4_header_save (CamelFolderSummary *summary, FILE *fout)
{
CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
-
+
if (CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_save (summary, fout) == -1)
return -1;
-
+
if (camel_file_util_encode_fixed_int32 (fout, CAMEL_IMAP4_SUMMARY_VERSION) == -1)
return -1;
-
+
if (camel_file_util_encode_fixed_int32 (fout, imap4_summary->uidvalidity) == -1)
return -1;
-
+
return 0;
}
const char *domain = NULL;
int part = 0;
size_t n;
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token == CAMEL_IMAP4_TOKEN_NIL) {
return 0;
} else if (token.token != '(') {
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
if (addrs->len > 0)
g_string_append (addrs, ", ");
-
+
do {
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
goto exception;
-
+
literal = NULL;
switch (token.token) {
case CAMEL_IMAP4_TOKEN_NIL:
case CAMEL_IMAP4_TOKEN_LITERAL:
if (camel_imap4_engine_literal (engine, &literal, &n, ex) == -1)
goto exception;
-
+
switch (part) {
case 0:
name = camel_header_decode_string (literal, NULL);
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
goto exception;
}
-
+
part++;
} while (part < 4);
-
+
addr = g_strdup_printf ("%s@%s", user, domain);
g_free (literal);
g_free (user);
-
+
cia = camel_header_address_new_name (name, addr);
g_free (name);
g_free (addr);
-
+
addr = camel_header_address_list_format (cia);
camel_header_address_unref (cia);
-
+
g_string_append (addrs, addr);
g_free (addr);
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != ')') {
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
return 0;
-
+
exception:
-
+
g_free (name);
g_free (user);
-
+
return -1;
}
{
camel_imap4_token_t token;
GString *addrs;
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token == CAMEL_IMAP4_TOKEN_NIL) {
*addrlist = NULL;
return 0;
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
addrs = g_string_new ("");
-
+
do {
if (camel_imap4_engine_next_token (engine, &token, ex) == -1) {
g_string_free (addrs, TRUE);
return -1;
}
-
+
if (token.token == '(') {
camel_imap4_stream_unget_token (engine->istream, &token);
-
+
if (envelope_decode_address (engine, addrs, ex) == -1) {
g_string_free (addrs, TRUE);
return -1;
return -1;
}
} while (1);
-
+
*addrlist = addrs->str;
g_string_free (addrs, FALSE);
-
+
return 0;
}
camel_imap4_token_t token;
const char *nstring;
size_t n;
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
switch (token.token) {
case CAMEL_IMAP4_TOKEN_NIL:
*date = (time_t) -1;
case CAMEL_IMAP4_TOKEN_LITERAL:
if (camel_imap4_engine_literal (engine, &literal, &n, ex) == -1)
return -1;
-
+
nstring = literal;
break;
default:
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
*date = camel_header_decode_date (nstring, NULL);
-
+
g_free (literal);
-
+
return 0;
}
camel_imap4_token_t token;
unsigned char *literal;
size_t n;
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
switch (token.token) {
case CAMEL_IMAP4_TOKEN_NIL:
*nstring = NULL;
case CAMEL_IMAP4_TOKEN_LITERAL:
if (camel_imap4_engine_literal (engine, &literal, &n, ex) == -1)
return -1;
-
+
if (rfc2047) {
*nstring = camel_header_decode_string (literal, NULL);
g_free (literal);
} else
*nstring = literal;
-
+
break;
default:
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
return 0;
}
CamelSummaryReferences *references;
unsigned char md5sum[16];
guint32 i, n;
-
+
refs = camel_header_references_decode (refstr);
irt = camel_header_references_inreplyto_decode (irtstr);
-
+
if (!refs && !irt)
return NULL;
-
+
if (irt) {
/* The References field is populated from the `References' and/or `In-Reply-To'
headers. If both headers exist, take the first thing in the In-Reply-To header
that looks like a Message-ID, and append it to the References header. */
-
+
if (refs) {
r = irt;
while (r->next != NULL)
r = r->next;
r->next = refs;
}
-
+
refs = irt;
}
-
+
n = camel_header_references_list_size (&refs);
references = g_malloc (sizeof (CamelSummaryReferences) + (sizeof (CamelSummaryMessageID) * (n - 1)));
references->size = n;
-
+
for (i = 0, r = refs; r != NULL; i++, r = r->next) {
md5_get_digest (r->id, strlen (r->id), md5sum);
memcpy (references->references[i].id.hash, md5sum, sizeof (CamelSummaryMessageID));
}
-
+
camel_header_references_list_clear (&refs);
-
+
return references;
}
CamelIMAP4MessageInfo *iinfo = (CamelIMAP4MessageInfo *) info;
unsigned char md5sum[16];
char *nstring, *msgid;
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
if (token->token != '(') {
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
-
+
if (envelope_decode_date (engine, &iinfo->info.date_sent, ex) == -1)
goto exception;
-
+
/* subject */
if (envelope_decode_nstring (engine, &nstring, TRUE, ex) == -1)
goto exception;
iinfo->info.subject = camel_pstring_strdup (nstring);
g_free(nstring);
-
+
/* from */
if (envelope_decode_addresses (engine, &nstring, ex) == -1)
goto exception;
iinfo->info.from = camel_pstring_strdup (nstring);
g_free(nstring);
-
+
/* sender */
if (envelope_decode_addresses (engine, &nstring, ex) == -1)
goto exception;
g_free (nstring);
-
+
/* reply-to */
if (envelope_decode_addresses (engine, &nstring, ex) == -1)
goto exception;
g_free (nstring);
-
+
/* to */
if (envelope_decode_addresses (engine, &nstring, ex) == -1)
goto exception;
iinfo->info.to = camel_pstring_strdup (nstring);
g_free(nstring);
-
+
/* cc */
if (envelope_decode_addresses (engine, &nstring, ex) == -1)
goto exception;
iinfo->info.cc = camel_pstring_strdup (nstring);
g_free(nstring);
-
+
/* bcc */
if (envelope_decode_addresses (engine, &nstring, ex) == -1)
goto exception;
g_free (nstring);
-
+
/* in-reply-to */
if (envelope_decode_nstring (engine, &nstring, FALSE, ex) == -1)
goto exception;
-
+
if (nstring != NULL) {
if (!iinfo->info.references)
iinfo->info.references = decode_references (NULL, nstring);
-
+
g_free (nstring);
}
-
+
/* message-id */
if (envelope_decode_nstring (engine, &nstring, FALSE, ex) == -1)
goto exception;
-
+
if (nstring != NULL) {
if ((msgid = camel_header_msgid_decode (nstring))) {
md5_get_digest (msgid, strlen (msgid), md5sum);
}
g_free (nstring);
}
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
if (token->token != ')') {
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
goto exception;
}
-
+
return 0;
-
+
exception:
-
+
return -1;
}
{
register const unsigned char *inptr = (const unsigned char *) *in;
int *val, colons = 0;
-
+
*hour = *min = *sec = 0;
-
+
val = hour;
for ( ; *inptr && !isspace ((int) *inptr); inptr++) {
if (*inptr == ':') {
else
*val = (*val * 10) + (*inptr - '0');
}
-
+
*in = inptr;
-
+
return TRUE;
}
mktime_utc (struct tm *tm)
{
time_t tt;
-
+
tm->tm_isdst = -1;
tt = mktime (tm);
-
+
#if defined (HAVE_TM_GMTOFF)
tt += tm->tm_gmtoff;
#elif defined (HAVE_TIMEZONE)
} else
tt -= timezone;
#endif
-
+
return tt;
}
struct tm tm;
time_t date;
char *buf;
-
+
memset ((void *) &tm, 0, sizeof (struct tm));
-
+
tm.tm_mday = strtoul (inptr, &buf, 10);
if (buf == inptr || *buf != '-')
return (time_t) -1;
-
+
inptr = buf + 1;
if (inptr[3] != '-')
return (time_t) -1;
-
+
for (n = 0; n < 12; n++) {
if (!g_ascii_strncasecmp (inptr, tm_months[n], 3))
break;
}
-
+
if (n >= 12)
return (time_t) -1;
-
+
tm.tm_mon = n;
-
+
inptr += 4;
-
+
n = strtoul (inptr, &buf, 10);
if (buf == inptr || *buf != ' ')
return (time_t) -1;
-
+
tm.tm_year = n - 1900;
-
+
inptr = buf + 1;
if (!decode_time (&inptr, &hour, &min, &sec))
return (time_t) -1;
-
+
tm.tm_hour = hour;
tm.tm_min = min;
tm.tm_sec = sec;
-
+
n = strtol (inptr, NULL, 10);
-
+
date = mktime_utc (&tm);
-
+
/* date is now GMT of the time we want, but not offset by the timezone ... */
-
+
/* this should convert the time to the GMT equiv time */
date -= ((n / 100) * 60 * 60) + (n % 100) * 60;
-
+
return date;
}
{
struct imap4_envelope_t *envelope;
int i;
-
+
for (i = 0; i < fetch->added->len; i++) {
if (!(envelope = fetch->added->pdata[i]))
continue;
-
+
camel_message_info_free (envelope->info);
g_free (envelope);
}
-
+
g_ptr_array_free (fetch->added, TRUE);
g_hash_table_destroy (fetch->uid_hash);
camel_folder_change_info_free (fetch->changes);
{
CamelSession *session = ((CamelService *) summary->folder->parent_store)->session;
char *warning;
-
+
warning = g_strdup_printf ("IMAP server did not respond with an untagged FETCH response "
"for message #%lu. This is illegal according to rfc3501 (and "
"the older rfc2060). You will need to contact your\n"
"Hint: If your IMAP server is Courier-IMAP, it is likely that this "
"message is simply unreadable by the IMAP server and will need "
"to be given read permissions.", msg);
-
+
camel_session_alert_user (session, CAMEL_SESSION_ALERT_WARNING, warning, FALSE);
g_free (warning);
}
struct imap4_envelope_t *envelope;
CamelMessageInfo *info;
guint32 i;
-
+
changes = fetch->changes;
-
+
for (i = 0; i < fetch->added->len; i++) {
if (!(envelope = fetch->added->pdata[i])) {
courier_imap_is_a_piece_of_shit (fetch->summary, i + fetch->first);
break;
}
-
+
if (envelope->changed != IMAP4_FETCH_ALL) {
d(fprintf (stderr, "Hmmm, IMAP4 server didn't give us everything for message %d\n", i + 1));
camel_message_info_free (envelope->info);
g_free (envelope);
continue;
}
-
+
if ((info = camel_folder_summary_uid (fetch->summary, camel_message_info_uid (envelope->info)))) {
camel_message_info_free (envelope->info);
camel_message_info_free (info);
g_free (envelope);
continue;
}
-
+
camel_folder_change_info_add_uid (changes, camel_message_info_uid (envelope->info));
-
+
if ((((CamelMessageInfoBase *) envelope->info)->flags & CAMEL_IMAP4_MESSAGE_RECENT))
camel_folder_change_info_recent_uid (changes, camel_message_info_uid (envelope->info));
-
+
camel_folder_summary_add (fetch->summary, envelope->info);
g_free (envelope);
}
-
+
g_ptr_array_free (fetch->added, TRUE);
g_hash_table_destroy (fetch->uid_hash);
-
+
if (camel_folder_change_info_changed (changes))
camel_object_trigger_event (fetch->summary->folder, "folder_changed", changes);
camel_folder_change_info_free (changes);
-
+
g_free (fetch);
}
CamelMessageInfo *info;
guint32 flags;
int total, i;
-
+
changes = fetch->changes;
-
+
total = camel_folder_summary_count (fetch->summary);
for (i = 0; i < total; i++) {
info = camel_folder_summary_index (fetch->summary, i);
/* update it with the new flags */
new_iinfo = (CamelIMAP4MessageInfo *) envelope->info;
iinfo = (CamelIMAP4MessageInfo *) info;
-
+
flags = iinfo->info.flags;
iinfo->info.flags = camel_imap4_merge_flags (iinfo->server_flags, iinfo->info.flags, new_iinfo->server_flags);
iinfo->server_flags = new_iinfo->server_flags;
if (iinfo->info.flags != flags)
camel_folder_change_info_change_uid (changes, camel_message_info_uid (info));
}
-
+
camel_message_info_free (info);
}
-
+
for (i = 0; i < fetch->added->len; i++) {
if (!(envelope = fetch->added->pdata[i])) {
courier_imap_is_a_piece_of_shit (fetch->summary, i + fetch->first);
continue;
}
-
+
camel_message_info_free (envelope->info);
g_free (envelope);
}
-
+
g_ptr_array_free (fetch->added, TRUE);
g_hash_table_destroy (fetch->uid_hash);
-
+
if (camel_folder_change_info_changed (changes))
camel_object_trigger_event (fetch->summary->folder, "folder_changed", changes);
camel_folder_change_info_free (changes);
-
+
g_free (fetch);
}
guint32 changed = 0;
const char *iuid;
char uid[12];
-
+
if (index < fetch->first) {
/* we already have this message envelope cached -
* server is probably notifying us of a FLAGS change
} else {
if (index > (added->len + fetch->first - 1))
g_ptr_array_set_size (added, index - fetch->first + 1);
-
+
if (!(envelope = added->pdata[index - fetch->first])) {
iinfo = (CamelIMAP4MessageInfo *) (info = camel_message_info_new (summary));
envelope = g_new (struct imap4_envelope_t, 1);
iinfo = (CamelIMAP4MessageInfo *) (info = envelope->info);
}
}
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
/* parse the FETCH response list */
if (token->token != '(') {
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
-
+
do {
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token == ')' || token->token == '\n')
break;
-
+
if (token->token != CAMEL_IMAP4_TOKEN_ATOM)
goto unexpected;
-
+
if (!strcmp (token->v.atom, "ENVELOPE")) {
if (envelope) {
if (decode_envelope (engine, info, token, ex) == -1)
goto exception;
-
+
changed |= IMAP4_FETCH_ENVELOPE;
} else {
CamelMessageInfo *tmp;
int rv;
-
+
g_warning ("Hmmm, server is sending us ENVELOPE data for a message we didn't ask for (message %lu)\n",
index);
tmp = camel_message_info_new (summary);
rv = decode_envelope (engine, tmp, token, ex);
camel_message_info_free(tmp);
-
+
if (rv == -1)
goto exception;
}
} else if (!strcmp (token->v.atom, "FLAGS")) {
guint32 server_flags = 0;
-
+
if (camel_imap4_parse_flags_list (engine, &server_flags, ex) == -1)
return -1;
-
+
iinfo->info.flags = camel_imap4_merge_flags (iinfo->server_flags, iinfo->info.flags, server_flags);
iinfo->server_flags = server_flags;
-
+
changed |= IMAP4_FETCH_FLAGS;
} else if (!strcmp (token->v.atom, "INTERNALDATE")) {
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
switch (token->token) {
case CAMEL_IMAP4_TOKEN_NIL:
iinfo->info.date_received = (time_t) -1;
default:
goto unexpected;
}
-
+
changed |= IMAP4_FETCH_INTERNALDATE;
} else if (!strcmp (token->v.atom, "RFC822.SIZE")) {
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token != CAMEL_IMAP4_TOKEN_NUMBER)
goto unexpected;
-
+
iinfo->info.size = token->v.number;
-
+
changed |= IMAP4_FETCH_RFC822SIZE;
} else if (!strcmp (token->v.atom, "UID")) {
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token != CAMEL_IMAP4_TOKEN_NUMBER || token->v.number == 0)
goto unexpected;
-
+
sprintf (uid, "%lu", token->v.number);
iuid = camel_message_info_uid (info);
if (iuid != NULL && iuid[0] != '\0') {
const char *refs, *str;
char *mlist;
size_t n;
-
+
/* '(' */
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token != '(')
goto unexpected;
-
+
/* header name list */
do {
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token == ')')
break;
-
+
switch (token->token) {
case CAMEL_IMAP4_TOKEN_ATOM:
case CAMEL_IMAP4_TOKEN_QSTRING:
case CAMEL_IMAP4_TOKEN_LITERAL:
if (camel_imap4_engine_literal (engine, &literal, &n, ex) == -1)
return -1;
-
+
g_free (literal);
break;
default:
goto unexpected;
}
-
+
/* we don't care what the list was... */
} while (1);
-
+
/* ']' */
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token != ']')
goto unexpected;
-
+
/* literal */
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token != CAMEL_IMAP4_TOKEN_LITERAL)
goto unexpected;
-
+
parser = camel_mime_parser_new ();
camel_mime_parser_init_with_stream (parser, (CamelStream *) engine->istream);
-
+
switch (camel_mime_parser_step (parser, NULL, NULL)) {
case CAMEL_MIME_PARSER_STATE_HEADER:
case CAMEL_MIME_PARSER_STATE_MESSAGE:
case CAMEL_MIME_PARSER_STATE_MULTIPART:
h = camel_mime_parser_headers_raw (parser);
-
+
/* find our mailing-list header */
mlist = camel_header_raw_check_mailing_list (&h);
iinfo->info.mlist = camel_pstring_strdup (mlist);
g_free (mlist);
-
+
/* check if we possibly have attachments */
if ((str = camel_header_raw_find (&h, "Content-Type", NULL))) {
content_type = camel_content_type_decode (str);
iinfo->info.flags |= CAMEL_MESSAGE_ATTACHMENTS;
camel_content_type_unref (content_type);
}
-
+
/* check for References: */
g_free (iinfo->info.references);
refs = camel_header_raw_find (&h, "References", NULL);
default:
break;
}
-
+
camel_object_unref (parser);
} else {
/* wtf? */
d(fprintf (stderr, "huh? %s?...\n", token->v.atom));
}
} while (1);
-
+
if (envelope) {
envelope->changed |= changed;
if ((envelope->changed & fetch->need) == fetch->need)
} else if (changed & IMAP4_FETCH_FLAGS) {
camel_folder_change_info_change_uid (fetch->changes, camel_message_info_uid (info));
}
-
+
if (token->token != ')')
goto unexpected;
-
+
return 0;
-
+
unexpected:
-
+
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
-
+
exception:
-
+
return -1;
}
CamelIMAP4Command *ic;
const char *query;
guint32 total;
-
+
engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
-
+
total = (imap4_summary->exists - seqid) + 1;
fetch = g_new (struct imap4_fetch_all_t, 1);
fetch->uid_hash = g_hash_table_new (g_str_hash, g_str_equal);
fetch->need = IMAP4_FETCH_ALL;
fetch->total = total;
fetch->count = 0;
-
+
if (((CamelIMAP4Folder *) folder)->enable_mlist)
query = "UID FETCH %s:* (" IMAP4_ALL " BODY.PEEK[HEADER.FIELDS (" MORE_HEADER_FIELDS ")])\r\n";
else
query = "UID FETCH %s:* (" IMAP4_ALL " BODY.PEEK[HEADER.FIELDS (" BASE_HEADER_FIELDS ")])\r\n";
-
+
ic = camel_imap4_engine_queue (engine, folder, query, uid);
-
+
camel_imap4_command_register_untagged (ic, "FETCH", untagged_fetch_all);
ic->user_data = fetch;
-
+
return ic;
}
CamelIMAP4Command *ic;
guint32 total;
int scount;
-
+
engine = ((CamelIMAP4Store *) folder->parent_store)->engine;
-
+
scount = camel_folder_summary_count (summary);
info[0] = camel_folder_summary_index (summary, 0);
if (scount > 1)
info[1] = camel_folder_summary_index (summary, scount - 1);
else
info[1] = NULL;
-
+
total = imap4_summary->exists < scount ? imap4_summary->exists : scount;
fetch = g_new (struct imap4_fetch_all_t, 1);
fetch->uid_hash = g_hash_table_new (g_str_hash, g_str_equal);
fetch->need = IMAP4_FETCH_UID | IMAP4_FETCH_FLAGS;
fetch->total = total;
fetch->count = 0;
-
+
if (info[1] != NULL) {
ic = camel_imap4_engine_queue (engine, folder, "UID FETCH %s:%s (FLAGS)\r\n",
camel_message_info_uid (info[0]),
ic = camel_imap4_engine_queue (engine, folder, "UID FETCH %s:* (FLAGS)\r\n",
camel_message_info_uid (info[0]));
}
-
+
camel_message_info_free (info[0]);
-
+
camel_imap4_command_register_untagged (ic, "FETCH", untagged_fetch_all);
ic->user_data = fetch;
-
+
return ic;
}
imap4_message_info_new_from_header (CamelFolderSummary *summary, struct _camel_header_raw *header)
{
CamelMessageInfo *info;
-
+
info = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->message_info_new_from_header (summary, header);
-
+
((CamelIMAP4MessageInfo *) info)->server_flags = 0;
-
+
return info;
}
{
CamelIMAP4MessageInfo *minfo;
CamelMessageInfo *info;
-
+
if (!(info = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->message_info_load (summary, fin)))
return NULL;
-
+
minfo = (CamelIMAP4MessageInfo *) info;
-
+
if (camel_file_util_decode_uint32 (fin, &minfo->server_flags) == -1)
goto exception;
-
+
return info;
-
+
exception:
-
+
camel_message_info_free(info);
-
+
return NULL;
}
imap4_message_info_save (CamelFolderSummary *summary, FILE *fout, CamelMessageInfo *info)
{
CamelIMAP4MessageInfo *minfo = (CamelIMAP4MessageInfo *) info;
-
+
if (CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->message_info_save (summary, fout, info) == -1)
return -1;
-
+
if (camel_file_util_encode_uint32 (fout, minfo->server_flags) == -1)
return -1;
-
+
return 0;
}
{
const CamelIMAP4MessageInfo *src = (const CamelIMAP4MessageInfo *) mi;
CamelIMAP4MessageInfo *dest;
-
+
dest = (CamelIMAP4MessageInfo *) CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->message_info_clone (summary, mi);
dest->server_flags = src->server_flags;
-
+
/* FIXME: parent clone should do this */
dest->info.content = camel_folder_summary_content_info_new (summary);
-
+
return (CamelMessageInfo *) dest;
}
camel_imap4_summary_set_exists (CamelFolderSummary *summary, guint32 exists)
{
CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
-
+
g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
-
+
imap4_summary->exists = exists;
}
camel_imap4_summary_set_recent (CamelFolderSummary *summary, guint32 recent)
{
CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
-
+
g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
-
+
imap4_summary->recent = recent;
}
camel_imap4_summary_set_unseen (CamelFolderSummary *summary, guint32 unseen)
{
CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
-
+
g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
-
+
imap4_summary->unseen = unseen;
}
camel_imap4_summary_set_uidnext (CamelFolderSummary *summary, guint32 uidnext)
{
g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
-
+
summary->nextuid = uidnext;
}
CamelFolderChangeInfo *changes;
CamelMessageInfo *info;
int i, count;
-
+
changes = camel_folder_change_info_new ();
count = camel_folder_summary_count (summary);
for (i = 0; i < count; i++) {
if (!(info = camel_folder_summary_index (summary, i)))
continue;
-
+
camel_folder_change_info_remove_uid (changes, camel_message_info_uid (info));
camel_message_info_free(info);
}
-
+
camel_folder_summary_clear (summary);
-
+
if (uncache)
camel_data_cache_clear (((CamelIMAP4Folder *) summary->folder)->cache, "cache", NULL);
-
+
if (camel_folder_change_info_changed (changes))
camel_object_trigger_event (summary->folder, "folder_changed", changes);
camel_folder_change_info_free (changes);
camel_imap4_summary_set_uidvalidity (CamelFolderSummary *summary, guint32 uidvalidity)
{
CamelIMAP4Summary *imap4_summary = (CamelIMAP4Summary *) summary;
-
+
g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
-
+
if (imap4_summary->uidvalidity == uidvalidity)
return;
-
+
imap4_summary_clear (summary, TRUE);
-
+
imap4_summary->uidvalidity = uidvalidity;
-
+
imap4_summary->uidvalidity_changed = TRUE;
}
CamelFolderChangeInfo *changes;
CamelMessageInfo *info;
const char *uid;
-
+
g_return_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary));
-
+
seqid--;
if (!(info = camel_folder_summary_index (summary, seqid)))
return;
-
+
imap4_summary->exists--;
-
+
uid = camel_message_info_uid (info);
camel_data_cache_remove (((CamelIMAP4Folder *) summary->folder)->cache, "cache", uid, NULL);
-
+
changes = camel_folder_change_info_new ();
camel_folder_change_info_remove_uid (changes, uid);
-
+
camel_message_info_free(info);
camel_folder_summary_remove_index (summary, seqid);
-
+
camel_object_trigger_event (summary->folder, "folder_changed", changes);
camel_folder_change_info_free (changes);
}
info_uid_sort (const CamelMessageInfo **info0, const CamelMessageInfo **info1)
{
guint32 uid0, uid1;
-
+
uid0 = strtoul (camel_message_info_uid (*info0), NULL, 10);
uid1 = strtoul (camel_message_info_uid (*info1), NULL, 10);
-
+
if (uid0 == uid1)
return 0;
-
+
return uid0 < uid1 ? -1 : 1;
}
#endif
guint32 iuid, seqid = 0;
int scount, id;
char uid[16];
-
+
g_return_val_if_fail (CAMEL_IS_IMAP4_SUMMARY (summary), -1);
-
+
/* FIXME: what do we do if replaying the journal fails? */
camel_offline_journal_replay (journal, NULL);
-
+
if (imap4_folder->enable_mlist && !(summary->flags & CAMEL_IMAP4_SUMMARY_HAVE_MLIST)) {
/* need to refetch all summary info to get info->mlist */
imap4_summary_clear (summary, FALSE);
}
-
+
summary->flags = (summary->flags & ~CAMEL_IMAP4_SUMMARY_HAVE_MLIST);
if (imap4_folder->enable_mlist)
summary->flags |= CAMEL_IMAP4_SUMMARY_HAVE_MLIST;
else
summary->flags ^= CAMEL_IMAP4_SUMMARY_HAVE_MLIST;
-
+
engine = ((CamelIMAP4Store *) summary->folder->parent_store)->engine;
scount = camel_folder_summary_count (summary);
-
+
if (imap4_summary->uidvalidity_changed) {
/* need to refetch everything */
g_assert (scount == 0);
* have since been expunged from the server by another
* client */
ic = imap4_summary_fetch_flags (summary);
-
+
camel_operation_start (NULL, _("Scanning for changed messages"));
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_imap4_journal_readd_failed ((CamelIMAP4Journal *) journal);
imap4_fetch_all_free (ic->user_data);
camel_operation_end (NULL);
return -1;
}
-
+
imap4_fetch_all_update (ic->user_data);
camel_imap4_command_unref (ic);
camel_operation_end (NULL);
-
+
scount = camel_folder_summary_count (summary);
if (imap4_summary->exists < scount) {
/* broken server? wtf? this should never happen... */
/* need to fetch new envelopes */
first = scount + 1;
}
-
+
if (seqid != 0 && seqid <= imap4_summary->exists) {
if (scount > 0) {
info = camel_folder_summary_index (summary, scount - 1);
} else {
strcpy (uid, "1");
}
-
+
ic = imap4_summary_fetch_all (summary, seqid, uid);
-
+
camel_operation_start (NULL, _("Fetching envelopes of new messages"));
while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
;
-
+
if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
camel_imap4_journal_readd_failed ((CamelIMAP4Journal *) journal);
imap4_fetch_all_free (ic->user_data);
camel_operation_end (NULL);
return -1;
}
-
+
imap4_fetch_all_add (ic->user_data);
camel_imap4_command_unref (ic);
camel_operation_end (NULL);
}
-
+
imap4_summary->update_flags = FALSE;
imap4_summary->uidvalidity_changed = FALSE;
-
+
camel_imap4_journal_readd_failed ((CamelIMAP4Journal *) journal);
-
+
return 0;
}
struct _CamelIMAP4MessageInfo {
CamelMessageInfoBase info;
-
+
guint32 server_flags;
};
struct _CamelIMAP4MessageContentInfo {
CamelMessageContentInfo info;
-
+
};
struct _CamelIMAP4Summary {
CamelFolderSummary parent_object;
-
+
guint32 version;
-
+
guint32 exists;
guint32 recent;
guint32 unseen;
-
+
guint32 uidvalidity;
-
+
guint uidvalidity_changed:1;
guint update_flags:1;
};
struct _CamelIMAP4SummaryClass {
CamelFolderSummaryClass parent_class;
-
+
};
camel_imap4_merge_flags (guint32 original, guint32 local, guint32 server)
{
flags_diff_t diff;
-
+
camel_imap4_flags_diff (&diff, original, local);
-
+
return camel_imap4_flags_merge (&diff, server);
}
camel_imap4_namespace_clear (CamelIMAP4Namespace **ns)
{
CamelIMAP4Namespace *node, *next;
-
+
node = *ns;
while (node != NULL) {
next = node->next;
g_free (node);
node = next;
}
-
+
*ns = NULL;
}
imap4_namespace_copy (const CamelIMAP4Namespace *ns)
{
CamelIMAP4Namespace *list, *node, *tail;
-
+
list = NULL;
tail = (CamelIMAP4Namespace *) &list;
-
+
while (ns != NULL) {
tail->next = node = g_malloc (sizeof (CamelIMAP4Namespace));
node->path = g_strdup (ns->path);
ns = ns->next;
tail = node;
}
-
+
tail->next = NULL;
-
+
return list;
}
camel_imap4_namespace_list_copy (const CamelIMAP4NamespaceList *nsl)
{
CamelIMAP4NamespaceList *new;
-
+
new = g_malloc (sizeof (CamelIMAP4NamespaceList));
new->personal = imap4_namespace_copy (nsl->personal);
new->other = imap4_namespace_copy (nsl->other);
new->shared = imap4_namespace_copy (nsl->shared);
-
+
return new;
}
const char *slash;
size_t len;
char *top;
-
+
g_return_val_if_fail (s->namespaces != NULL, '/');
-
+
if ((slash = strchr (full_name, '/')))
len = (slash - full_name);
else
len = strlen (full_name);
-
+
top = g_alloca (len + 1);
memcpy (top, full_name, len);
top[len] = '\0';
-
+
if (!g_ascii_strcasecmp (top, "INBOX"))
strcpy (top, "INBOX");
-
+
retry:
namespace = s->namespaces->personal;
while (namespace != NULL) {
return namespace->sep;
namespace = namespace->next;
}
-
+
namespace = s->namespaces->other;
while (namespace != NULL) {
if (!strcmp (namespace->path, top))
return namespace->sep;
namespace = namespace->next;
}
-
+
namespace = s->namespaces->shared;
while (namespace != NULL) {
if (!strcmp (namespace->path, top))
return namespace->sep;
namespace = namespace->next;
}
-
+
if (top[0] != '\0') {
/* look for a default namespace? */
top[0] = '\0';
goto retry;
}
-
+
return '/';
}
uidset_range_free (struct _uidset_range *range)
{
struct _uidset_range *next;
-
+
while (range != NULL) {
next = range->next;
g_free (range);
uidset->ranges->last = (guint32) -1;
uidset->ranges->next = NULL;
uidset->ranges->buflen = 0;
-
+
uidset->tail = uidset->ranges;
uidset->summary = summary;
uidset->maxlen = maxlen;
size_t uidlen, len;
const char *colon;
guint32 index;
-
+
/* Note: depends on integer overflow for initial 'add' */
for (index = tail->last + 1; index < messages->len; index++) {
if (info == messages->pdata[index])
break;
}
-
+
g_assert (index < messages->len);
-
+
uidlen = strlen (iuid);
-
+
if (tail->buflen == 0) {
/* first add */
tail->first = tail->last = index;
/* make sure we've got enough room to add this one... */
if ((uidset->setlen + uidlen + 1) > uidset->maxlen)
return -1;
-
+
tail->buf[tail->buflen++] = ':';
uidset->setlen++;
} else {
colon = strchr (tail->buf, ':') + 1;
-
+
len = strlen (colon);
uidset->setlen -= len;
tail->buflen -= len;
}
-
+
strcpy (tail->buf + tail->buflen, iuid);
uidset->setlen += uidlen;
tail->buflen += uidlen;
-
+
tail->last = index;
} else if ((uidset->setlen + uidlen + 1) < uidset->maxlen) {
/* the beginning of a new range */
/* can't add this one... */
return -1;
}
-
+
d(fprintf (stderr, "added uid %s to uidset (summary index = %lu)\n", iuid, index));
-
+
if (uidset->setlen < uidset->maxlen)
return 0;
-
+
return 1;
}
struct _uidset_range *range;
GString *string;
char *str;
-
+
string = g_string_new ("");
-
+
range = uidset->ranges;
while (range != NULL) {
g_string_append (string, range->buf);
if (range)
g_string_append_c (string, ',');
}
-
+
str = string->str;
g_string_free (string, FALSE);
-
+
return str;
}
size_t maxlen;
int rv = 0;
int i;
-
+
if (engine->maxlentype == CAMEL_IMAP4_ENGINE_MAXLEN_LINE)
maxlen = engine->maxlen - linelen;
else
maxlen = engine->maxlen;
-
+
uidset_init (&uidset, summary, maxlen);
-
+
for (i = cur; i < infos->len && rv != 1; i++) {
if ((rv = uidset_add (&uidset, infos->pdata[i])) == -1)
break;
}
-
+
if (i > cur)
*set = uidset_to_string (&uidset);
-
+
uidset_range_free (uidset.ranges);
-
+
return (i - cur);
}
camel_imap4_utils_set_unexpected_token_error (CamelException *ex, CamelIMAP4Engine *engine, camel_imap4_token_t *token)
{
GString *errmsg;
-
+
if (ex == NULL)
return;
-
+
errmsg = g_string_new ("");
g_string_append_printf (errmsg, _("Unexpected token in response from IMAP server %s: "),
engine->url->host);
-
+
switch (token->token) {
case CAMEL_IMAP4_TOKEN_NIL:
g_string_append (errmsg, "NIL");
g_string_append_c (errmsg, (unsigned char) (token->token & 0xff));
break;
}
-
+
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, errmsg->str);
-
+
g_string_free (errmsg, TRUE);
}
{ "\\Seen", CAMEL_MESSAGE_SEEN },
{ "\\Recent", CAMEL_IMAP4_MESSAGE_RECENT },
{ "\\*", CAMEL_MESSAGE_USER },
-
+
/* user flags */
{ "Junk", CAMEL_MESSAGE_JUNK },
{ "NonJunk", 0 },
camel_imap4_token_t token;
guint32 new = 0;
int i;
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
if (token.token != '(') {
d(fprintf (stderr, "Expected to find a '(' token starting the flags list\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
-
+
while (token.token == CAMEL_IMAP4_TOKEN_ATOM || token.token == CAMEL_IMAP4_TOKEN_FLAG) {
/* parse the flags list */
for (i = 0; i < G_N_ELEMENTS (imap4_flags); i++) {
break;
}
}
-
+
if (i == G_N_ELEMENTS (imap4_flags))
d(fprintf (stderr, "Encountered unknown flag: %s\n", token.v.atom));
-
+
if (camel_imap4_engine_next_token (engine, &token, ex) == -1)
return -1;
}
-
+
if (token.token != ')') {
d(fprintf (stderr, "Expected to find a ')' token terminating the flags list\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, &token);
return -1;
}
-
+
*flags = new;
-
+
return 0;
}
char delim;
size_t n;
int i;
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
/* parse the flag list */
if (token->token != '(')
goto unexpected;
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
while (token->token == CAMEL_IMAP4_TOKEN_FLAG || token->token == CAMEL_IMAP4_TOKEN_ATOM) {
for (i = 0; i < G_N_ELEMENTS (list_flags); i++) {
if (!g_ascii_strcasecmp (list_flags[i].name, token->v.atom)) {
break;
}
}
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
}
-
+
if (token->token != ')')
goto unexpected;
-
+
/* parse the path delimiter */
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
switch (token->token) {
case CAMEL_IMAP4_TOKEN_NIL:
delim = '\0';
default:
goto unexpected;
}
-
+
/* parse the folder name */
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
list = g_new (camel_imap4_list_t, 1);
list->flags = flags;
list->delim = delim;
-
+
switch (token->token) {
case CAMEL_IMAP4_TOKEN_ATOM:
list->name = g_strdup (token->v.atom);
literal = g_string_new ("");
while ((i = camel_imap4_stream_literal (engine->istream, &buf, &n)) == 1)
g_string_append_len (literal, buf, n);
-
+
if (i == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("IMAP server %s unexpectedly disconnected: %s"),
g_string_free (literal, TRUE);
return -1;
}
-
+
g_string_append_len (literal, buf, n);
list->name = literal->str;
g_string_free (literal, FALSE);
g_free (list);
goto unexpected;
}
-
+
g_ptr_array_add (array, list);
-
+
return camel_imap4_engine_eat_line (engine, ex);
-
+
unexpected:
-
+
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
-
+
return -1;
}
camel_imap4_status_free (camel_imap4_status_t *status)
{
camel_imap4_status_attr_t *attr, *next;
-
+
attr = status->attr_list;
while (attr != NULL) {
next = attr->next;
g_free (attr);
attr = next;
}
-
+
g_free (status->mailbox);
g_free (status);
}
size_t len;
int type;
int i;
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
switch (token->token) {
case CAMEL_IMAP4_TOKEN_ATOM:
mailbox = g_strdup (token->v.atom);
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1) {
g_free (mailbox);
return -1;
}
-
+
if (token->token != '(') {
d(fprintf (stderr, "Expected to find a '(' token after the mailbox token in the STATUS response\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
g_free (mailbox);
return -1;
}
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1) {
g_free (mailbox);
return -1;
}
-
+
tail = (camel_imap4_status_attr_t *) &list;
-
+
while (token->token == CAMEL_IMAP4_TOKEN_ATOM) {
/* parse the status messages list */
type = CAMEL_IMAP4_STATUS_UNKNOWN;
break;
}
}
-
+
if (type == CAMEL_IMAP4_STATUS_UNKNOWN)
fprintf (stderr, "unrecognized token in STATUS list: %s\n", token->v.atom);
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
-
+
if (token->token != CAMEL_IMAP4_TOKEN_NUMBER)
break;
-
+
attr = g_new (camel_imap4_status_attr_t, 1);
attr->next = NULL;
attr->type = type;
attr->value = token->v.number;
-
+
tail->next = attr;
tail = attr;
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
goto exception;
}
-
+
status = g_new (camel_imap4_status_t, 1);
status->mailbox = mailbox;
status->attr_list = list;
list = NULL;
-
+
g_ptr_array_add (array, status);
-
+
if (token->token != ')') {
d(fprintf (stderr, "Expected to find a ')' token terminating the untagged STATUS response\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
-
+
if (camel_imap4_engine_next_token (engine, token, ex) == -1)
return -1;
-
+
if (token->token != '\n') {
d(fprintf (stderr, "Expected to find a '\\n' token after the STATUS response\n"));
camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
return -1;
}
-
+
return 0;
-
+
exception:
-
+
g_free (mailbox);
-
+
attr = list;
while (attr != NULL) {
list = attr->next;
g_free (attr);
attr = list;
}
-
+
return -1;
}
(CamelObjectInitFunc) object_init,
(CamelObjectFinalizeFunc) object_finalise);
}
-
+
return type;
}
driver = CAMEL_IMAPP_DRIVER (camel_object_new (CAMEL_IMAPP_DRIVER_TYPE));
ie = driver->engine = camel_imapp_engine_new(stream);
-
+
camel_imapp_engine_add_handler(ie, "FETCH", (CamelIMAPPEngineFunc)driver_resp_fetch, driver);
camel_imapp_engine_add_handler(ie, "EXPUNGE", (CamelIMAPPEngineFunc)driver_resp_expunge, driver);
camel_imapp_engine_add_handler(ie, "EXISTS", (CamelIMAPPEngineFunc)driver_resp_exists, driver);
}
summary = ((CamelFolder *)folder)->summary;
-
+
ic = camel_imapp_engine_command_new(id->engine, "SELECT", NULL, "SELECT %t", folder->raw_name);
camel_imapp_engine_command_queue(id->engine, ic);
while (camel_imapp_engine_iterate(id->engine, ic)>0)
count = camel_folder_summary_count(summary);
for (j=0;j<sizeof(flag_table)/sizeof(flag_table[0]);j++) {
int flush;
-
+
if ((orset & flag_table[j].flag) == 0)
continue;
|| (!on && (((flags ^ sflags) & ~flags) & flag_table[j].flag))) {
if (ic == NULL)
ic = camel_imapp_engine_command_new(id->engine, "STORE", NULL, "UID STORE ");
- flush = imapp_uidset_add(&ss, ic, camel_message_info_uid(info));
+ flush = imapp_uidset_add(&ss, ic, camel_message_info_uid(info));
}
camel_message_info_free((CamelMessageInfo *)info);
}
if (id->list_commands) {
GSList *top = id->list_commands;
-
+
id->list_commands = top->next;
ic = top->data;
g_slist_free_1(top);
if (depth < 10
&& (linfo->name[0] == 0 || linfo->name[strlen(linfo->name)-1] != c)) {
CamelIMAPPCommand *ic;
-
+
ic = camel_imapp_engine_command_new(id->engine, "LIST", NULL, "LIST \"\" %t%c%%", linfo->name, c);
id->list_commands = g_slist_prepend(id->list_commands, ic);
camel_imapp_engine_command_queue(id->engine, ic);
case IMAP_UIDVALIDITY:
sdata->uidvalidity = sinfo->u.uidvalidity;
break;
-#if 0
+#if 0
/* not defined yet ... */
case IMAP_UIDNEXT:
printf("got uidnext for folder: %d\n", sinfo->u.uidnext);
break;
-#endif
+#endif
case IMAP_UNSEEN:
sdata->unseen = sinfo->u.unseen;
break;
info->info.uid = g_strdup(uidtmp);
printf("inserting empty uid %s\n", uidtmp);
}
-
+
camel_folder_summary_add(summary, (CamelMessageInfo *)info);
}
info = (CamelIMAPPMessageInfo *)camel_folder_summary_index(summary, id-1);
#include "camel-imapp-stream.h"
#include "camel-imapp-utils.h"
-#define e(x)
+#define e(x)
#define c(x) /* command build debug */
static void imap_engine_command_addv(CamelIMAPPEngine *imap, CamelIMAPPCommand *ic, const char *fmt, va_list ap);
(CamelObjectInitFunc) object_init,
(CamelObjectFinalizeFunc) object_finalise);
}
-
+
return type;
}
struct _handler *h;
const unsigned char *p;
unsigned char *o, c;
-
+
h = g_malloc0(sizeof(*h) + strlen(response));
h->func = func;
h->data = data;
int tok;
struct _handler *h;
struct _status_info *sinfo;
-
+
e(printf("got untagged response\n"));
id = 0;
tok = camel_imapp_stream_token(imap->stream, &token, &len);
if (imap->select_response)
imap->select_response->uidvalidity = sinfo->u.uidvalidity;
break;
-#if 0
+#if 0
/* not defined yet ... */
case IMAP_UIDNEXT:
printf("got uidnext for folder: %d\n", sinfo->u.uidnext);
break;
-#endif
+#endif
case IMAP_UNSEEN:
if (imap->select_response)
imap->select_response->unseen = sinfo->u.unseen;
{
CamelIMAPPCommand *ic;
CamelIMAPPCommandPart *cp;
-
+
printf("got continuation response\n");
ic = imap->literal;
char *resp;
unsigned char *token;
int tok, len;
-
+
tok = camel_imapp_stream_token(imap->stream, &token, &len);
resp = camel_sasl_challenge_base64((CamelSasl *)cp->ob, token, ex);
if (camel_exception_is_set(ex))
camel_exception_throw_ex(ex);
camel_exception_free(ex);
-
+
printf("got auth continuation, feeding token '%s' back to auth mech\n", resp);
-
+
camel_stream_write((CamelStream *)imap->stream, resp, strlen(resp));
-
+
/* we want to keep getting called until we get a status reponse from the server
ignore what sasl tells us */
imap->literal = ic;
-
+
break; }
default:
/* should we just ignore? */
camel_exception_throw(1, "continuation response for non-continuation request");
}
-
+
camel_imapp_engine_skip(imap);
-
+
cp = cp->next;
if (cp->next) {
ic->current = cp;
printf("%p: queueing continuation\n", ic);
camel_stream_printf((CamelStream *)imap->stream, "\r\n");
}
-
+
if (imap->literal == NULL) {
ic = (CamelIMAPPCommand *)e_dlist_remhead(&imap->queue);
if (ic) {
} else {
camel_exception_throw(1, "got response tag unexpectedly: %s", token);
}
-
+
if (imap->literal != NULL) {
printf("Warning: continuation command '%s' finished with outstanding continuation\n", imap->literal->name);
ic = imap->literal;
e_dlist_addtail(&imap->done, (EDListNode *)ic);
imap->literal = NULL;
}
-
+
ic = (CamelIMAPPCommand *)e_dlist_remhead(&imap->queue);
if (ic) {
printf("found outstanding op, queueing\n");
camel_imapp_engine_command_queue(imap, ic);
}
-
+
return 1;
}
CamelIMAPPCommandPart *cp;
CamelStreamNull *null;
unsigned int ob_size = 0;
-
+
switch(type & CAMEL_IMAPP_COMMAND_MASK) {
case CAMEL_IMAPP_COMMAND_DATAWRAPPER:
case CAMEL_IMAPP_COMMAND_STREAM:
c(printf("command has %d parts\n", len(&ic->parts)));
if (ic->mem->buffer->len > 0)
imap_engine_command_add_part(imap, ic, CAMEL_IMAPP_COMMAND_SIMPLE, NULL);
-
+
c(printf("command has %d parts\n", len(&ic->parts)));
camel_object_unref((CamelObject *)ic->mem);
/* see if we need to pre-queue a select command to select the right folder first */
if (ic->select && (imap->last_select == NULL || strcmp(ic->select, imap->last_select) != 0)) {
CamelIMAPPCommand *select;
-
+
/* of course ... we can't do anything like store/search if we have to select
first, because it'll mess up all the sequence numbers ... hrm ... bugger */
camel_imapp_engine_command_queue(imap, select);
/* how does it get freed? handle inside engine? */
}
-
+
/* first, check if command can be sent yet ... queue if not */
if (imap->literal != NULL) {
printf("%p: queueing while literal active\n", ic);
guint32 recent;
guint32 uidvalidity;
guint32 unseen;
- guint32 permanentflags;
+ guint32 permanentflags;
};
enum {
#include "camel-imapp-exception.h"
#include "camel-imapp-stream.h"
-#define t(x)
+#define t(x)
#define io(x) x
static CamelObjectClass *parent_class = NULL;
}
is->literal -= max;
-
+
return max;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-imap-folder.c : class for a imap folder */
-/*
+/*
* Authors: Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2002 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
imap_folder_class_init (CamelIMAPPFolderClass *camel_imapp_folder_class)
{
CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS(camel_imapp_folder_class);
-
+
parent_class = CAMEL_FOLDER_CLASS(camel_folder_get_type());
-
+
/* virtual method overload */
camel_folder_class->refresh_info = imap_refresh_info;
camel_folder_class->sync = imap_sync;
-
+
camel_folder_class->get_message = imap_get_message;
}
folder->folder_flags |= (CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY |
CAMEL_FOLDER_HAS_SEARCH_CAPABILITY);
-
+
folder->permanent_flags = CAMEL_MESSAGE_ANSWERED |
CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_DRAFT |
CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_USER;
camel_imapp_folder_get_type (void)
{
static CamelType camel_imapp_folder_type = CAMEL_INVALID_TYPE;
-
+
if (!camel_imapp_folder_type) {
camel_imapp_folder_type = camel_type_register (CAMEL_FOLDER_TYPE, "CamelIMAPPFolder",
sizeof (CamelIMAPPFolder),
imap_folder_init,
(CamelObjectFinalizeFunc) imap_finalize);
}
-
+
return camel_imapp_folder_type;
}
char *root;
d(printf("opening imap folder '%s'\n", path));
-
+
folder = CAMEL_FOLDER (camel_object_new (CAMEL_IMAPP_FOLDER_TYPE));
camel_folder_construct(folder, store, path, path);
}
#endif
-static void
+static void
imap_refresh_info (CamelFolder *folder, CamelException *ex)
{
printf("imapp refresh info?\n");
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-imap-folder.h : Class for a IMAP folder */
-/*
+/*
* Authors: Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2002 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-pop3-provider.c: pop3 provider registration code */
-/*
+/*
* Authors :
* Dan Winship <danw@ximian.com>
* Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2002 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
static CamelProvider imapp_provider = {
"imapp",
-
+
N_("IMAP+"),
-
+
N_("Experimental IMAP 4(.1) client\n"
"This is untested and unsupported code, you want to use plain imap instead.\n\n"
" !!! DO NOT USE THIS FOR PRODUCTION EMAIL !!!\n"),
"mail",
-
+
CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE |
CAMEL_PROVIDER_IS_STORAGE | CAMEL_PROVIDER_SUPPORTS_SSL,
-
+
CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH,
-
+
imapp_conf_entries,
-
+
/* ... */
};
CamelServiceAuthType camel_imapp_password_authtype = {
N_("Password"),
-
+
N_("This option will connect to the IMAP server using a "
"plaintext password."),
-
+
"",
TRUE
};
camel_imapp_store_summary_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
camel_imapp_store_summary_parent = (CamelStoreSummaryClass *)camel_store_summary_get_type();
type = camel_type_register((CamelType)camel_imapp_store_summary_parent, "CamelIMAPPStoreSummary",
(CamelObjectInitFunc) camel_imapp_store_summary_init,
(CamelObjectFinalizeFunc) camel_imapp_store_summary_finalise);
}
-
+
return type;
}
* camel_imapp_store_summary_new:
*
* Create a new CamelIMAPPStoreSummary object.
- *
+ *
* Return value: A new CamelIMAPPStoreSummary widget.
**/
CamelIMAPPStoreSummary *
/**
* camel_imapp_store_summary_full_name:
- * @s:
- * @path:
- *
+ * @s:
+ * @path:
+ *
* Retrieve a summary item by full name.
*
* A referenced to the summary item is returned, which may be
* ref'd or free'd as appropriate.
- *
+ *
* Return value: The summary item, or NULL if the @full_name name
* is not available.
* It must be freed using camel_store_summary_info_free().
} else {
if (full_name[len] == ns->sep)
len++;
-
+
prefix = camel_imapp_store_summary_full_to_path(s, full_name+len, ns->sep);
if (*ns->path) {
pathu8 = g_strdup_printf ("%s/%s", ns->path, prefix);
if (camel_imapp_store_summary_parent->summary_header_save((CamelStoreSummary *)s, out) == -1
|| camel_file_util_encode_fixed_int32(out, CAMEL_IMAPP_STORE_SUMMARY_VERSION) == -1
|| camel_file_util_encode_fixed_int32(out, is->capabilities) == -1
- || camel_file_util_encode_fixed_int32(out, count) == -1)
+ || camel_file_util_encode_fixed_int32(out, count) == -1)
return -1;
if (is->namespace && namespace_save(s, out, is->namespace) == -1)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-imap-store.c : class for a imap store */
-/*
+/*
* Authors: Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2000-2002 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS(camel_imapp_store_class);
parent_class = CAMEL_STORE_CLASS(camel_type_get_global_classfuncs(camel_store_get_type()));
-
+
/* virtual method overload */
camel_service_class->construct = imap_construct;
/*camel_service_class->get_name = imap_get_name;*/
CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
if (camel_exception_is_set(ex))
return;
-
+
CAMEL_TRY {
store->summary = camel_imapp_store_summary_new();
root = camel_session_get_storage_path(service->session, service, ex);
port = "143";
}
-#ifdef HAVE_SSL
+#ifdef HAVE_SSL
if (camel_url_get_param (service->url, "use_ssl")) {
if (try_starttls)
tcp_stream = camel_tcp_stream_ssl_new_raw (service->session, service->url->host, STARTTLS_FLAGS);
} else {
tcp_stream = camel_tcp_stream_raw_new ();
}
-#else
+#else
tcp_stream = camel_tcp_stream_raw_new ();
#endif /* HAVE_SSL */
if (ex->id)
camel_exception_throw_ex(ex);
-
+
ret = camel_tcp_stream_connect(CAMEL_TCP_STREAM(tcp_stream), ai);
camel_freeaddrinfo(ai);
if (ret == -1) {
#ifdef HAVE_SSL
const char *use_ssl;
int i, ssl_mode;
-
+
use_ssl = camel_url_get_param (service->url, "use_ssl");
if (use_ssl) {
for (i = 0; ssl_options[i].value; i++)
ssl_mode = ssl_options[i].mode;
} else
ssl_mode = USE_SSL_NEVER;
-
+
if (ssl_mode == USE_SSL_ALWAYS) {
/* First try the ssl port */
if (!connect_to_server (service, ssl_mode, FALSE, ex)) {
return FALSE;
}
}
-
+
return TRUE;
} else if (ssl_mode == USE_SSL_WHEN_POSSIBLE) {
/* If the server supports STARTTLS, use it */
CamelException ex;
camel_exception_init(&ex);
-
+
prompt = g_strdup_printf (_("%sPlease enter the IMAP password for %s@%s"),
store->login_error?store->login_error:"",
((CamelService *)store)->url->user,
store_get_login(struct _CamelIMAPPDriver *driver, char **login, char **pass, CamelIMAPPStore *store)
{
store_get_pass(store);
-
+
*login = g_strdup(((CamelService *)store)->url->user);
*pass = g_strdup(((CamelService *)store)->url->passwd);
}
if (store->cache == NULL) {
char *root;
-
+
root = camel_session_get_storage_path(service->session, service, ex);
if (root) {
store->cache = camel_data_cache_new(root, 0, ex);
CamelIMAPPStore *store = CAMEL_IMAPP_STORE (service);
/* FIXME: logout */
-
+
if (!CAMEL_SERVICE_CLASS (parent_class)->disconnect (service, clean, ex))
return FALSE;
camel_object_unref(store->driver);
store->driver = NULL;
}
-
+
return TRUE;
}
folder_info_dump(fi->child, depth+2);
fi = fi->next;
}
-
+
}
static CamelFolderInfo *
} CAMEL_CATCH (e) {
camel_exception_xfer(ex, e);
} CAMEL_DONE;
-
+
camel_imapp_engine_command_free(istore->driver->engine, ic);
printf("got folder list:\n");
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-imap-store.h : class for an imap store */
-/*
+/*
* Authors: Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2002 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#include "camel-imapp-exception.h"
#include "camel-imapp-stream.h"
-#define t(x)
+#define t(x)
#define io(x) x
static void setup_table(void);
}
is->literal -= max;
-
+
return max;
}
/* 50 */1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
/* 60 */1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/* 70 */1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
#define imap_is_atom(c) ((imap_specials[(c)&0xff] & 0x01) != 0)
}
return 0;
-}
+}
static int
summary_header_save(CamelFolderSummary *s, FILE *out)
struct _imap_keyword { char *name; camel_imapp_id_t id; };
/*
gperf input file
- best hash generated using: gperf -o -s-2 -k1,'$' -t -H imap_hash -N imap_tokenise -L ANSI-C
+ best hash generated using: gperf -o -s-2 -k1,'$' -t -H imap_hash -N imap_tokenise -L ANSI-C
*/
#define TOTAL_KEYWORDS 23
imap_free_body(list);
list = next;
}
-
+
if (cinfo->type)
camel_content_type_unref(cinfo->type);
g_free(cinfo->id);
if (tok == ')')
break;
camel_imapp_stream_ungettoken(is, tok, token, len);
-
+
camel_imapp_stream_astring(is, &token);
param = alloca(strlen(token)+1);
strcpy(param, token);
dinfo->refcount = 1;
/* should be string */
camel_imapp_stream_astring(is, &token);
-
+
dinfo->disposition = g_strdup(token);
imap_parse_param_list(is, &dinfo->params);
case IMAP_TOK_TOKEN:
default:
camel_exception_throw(1, "body_fld_disp: expecting nil or list");
}
-
+
p(printf("body_fld_lang\n"));
/* body_fld_lang ::= nstring / "(" 1#string ")" */
-
+
/* we just drop the lang string/list, save it somewhere? */
-
+
tok = camel_imapp_stream_token(is, &token, &len);
switch (tok) {
case '(':
{
unsigned char *token, *type;
struct _CamelMessageContentInfo *cinfo;
-
+
/* body_fields ::= body_fld_param SPACE body_fld_id SPACE
body_fld_desc SPACE body_fld_enc SPACE
body_fld_octets */
camel_imapp_stream_astring(is, &token);
cinfo->type = camel_content_type_new(type, token);
imap_parse_param_list(is, &cinfo->type->params);
-
+
/* body_fld_id ::= nstring */
camel_imapp_stream_nstring(is, &token);
cinfo->id = g_strdup(token);
-
+
/* body_fld_desc ::= nstring */
camel_imapp_stream_nstring(is, &token);
cinfo->description = g_strdup(token);
-
+
/* body_fld_enc ::= (<"> ("7BIT" / "8BIT" / "BINARY" / "BASE64"/
"QUOTED-PRINTABLE") <">) / string */
camel_imapp_stream_astring(is, &token);
cinfo->encoding = g_strdup(token);
-
+
/* body_fld_octets ::= number */
cinfo->size = camel_imapp_stream_number(is);
} CAMEL_CATCH(ex) {
return (CamelMessageInfo *)minfo;
}
-
+
struct _CamelMessageContentInfo *
imap_parse_body(CamelIMAPPStream *is)
{
} else {
/* body_type_1part ::= (body_type_basic / body_type_msg / body_type_text)
[SPACE body_ext_1part]
-
+
body_type_basic ::= media_basic SPACE body_fields
body_type_text ::= media_text SPACE body_fields SPACE body_fld_lines
body_type_msg ::= media_message SPACE body_fields SPACE envelope
camel_imapp_stream_ungettoken(is, tok, token, len);
}
camel_imapp_stream_nstring_stream(is, &finfo->body);
- finfo->got |= FETCH_BODY;
+ finfo->got |= FETCH_BODY;
} else {
camel_exception_throw(1, "unknown body response");
}
sinfo->condition = IMAP_UNKNOWN;
printf("Got unknown response code: %s: ignored\n", token);
}
-
+
/* ignore anything we dont know about */
do {
tok = camel_imapp_stream_token(is, &token, &len);
struct _list_info * volatile linfo;
linfo = g_malloc0(sizeof(*linfo));
-
+
CAMEL_TRY {
/* mailbox_list ::= "(" #("\Marked" / "\Noinferiors" /
"\Noselect" / "\Unmarked" / flag_extension) ")"
/* ********************************************************************** */
-/* should this just return a FolderInfo?
+/* should this just return a FolderInfo?
should this just return the name & flags & separator by reference? */
struct _list_info {
guint32 flags:24;
g_free(local_folder->index_path);
camel_folder_change_info_free(local_folder->changes);
-
+
g_mutex_free(local_folder->priv->search_lock);
-
+
g_free(local_folder->priv);
}
int forceindex, len;
CamelURL *url;
CamelLocalStore *ls = (CamelLocalStore *)parent_store;
-
+
folder = (CamelFolder *)lf;
name = g_path_get_basename(full_name);
if ((flags & CAMEL_STORE_FOLDER_CREATE) != 0) {
url = camel_url_copy (((CamelService *) parent_store)->url);
camel_url_set_fragment (url, full_name);
-
+
fi = g_new0 (CamelFolderInfo, 1);
fi->full_name = g_strdup (full_name);
fi->name = g_strdup (name);
fi->uri = camel_url_to_string (url, 0);
fi->unread = camel_folder_get_unread_message_count(folder);
fi->flags = CAMEL_FOLDER_NOCHILDREN;
-
+
camel_url_free (url);
-
+
camel_object_trigger_event(CAMEL_OBJECT (parent_store), "folder_created", fi);
camel_folder_info_free(fi);
}
((CamelService *)folder->parent_store)->url->protocol);
else
/* a full path + protocol */
- folder->description = g_strdup_printf(_("%s (%s)"), path,
+ folder->description = g_strdup_printf(_("%s (%s)"), path,
((CamelService *)folder->parent_store)->url->protocol);
}
*arg->ca_str = folder->description;
local_delete(CamelFolder *folder)
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
-
+
if (lf->index)
camel_index_delete(lf->index);
*
* Copyright (C) 1999 Ximian (www.ximian.com/).
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct {
CamelFolderClass parent_class;
- /* Virtual methods */
-
+ /* Virtual methods */
+
/* summary factory, only used at init */
CamelLocalSummary *(*create_summary)(CamelLocalFolder *lf, const char *path, const char *folder, CamelIndex *index);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
+ *
* Authors: Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2000 Ximian (www.ximian.com).
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
{
const CamelURL *u = v;
guint hash = 0;
-
+
#define ADD_HASH(s) if (s) hash ^= g_str_hash (s);
-
+
ADD_HASH (u->protocol);
ADD_HASH (u->user);
ADD_HASH (u->authmech);
ADD_HASH (u->path);
ADD_HASH (u->query);
hash ^= u->port;
-
+
return hash;
}
else
return FALSE;
}
-
+
if (s2 == NULL)
return FALSE;
*
* Copyright (C) 2000 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
{
CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_local_store_class);
CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS (camel_local_store_class);
-
+
parent_class = CAMEL_STORE_CLASS (camel_type_get_global_classfuncs (camel_store_get_type ()));
/* virtual method overload */
camel_local_store_get_type (void)
{
static CamelType camel_local_store_type = CAMEL_INVALID_TYPE;
-
+
if (camel_local_store_type == CAMEL_INVALID_TYPE) {
camel_local_store_type = camel_type_register (CAMEL_STORE_TYPE, "CamelLocalStore",
sizeof (CamelLocalStore),
NULL,
(CamelObjectFinalizeFunc) camel_local_store_finalize);
}
-
+
return camel_local_store_type;
}
strcpy(path, ((CamelLocalStore *)store)->toplevel_dir);
if (G_IS_DIR_SEPARATOR(path[len-1]))
path[len-1] = '\0';
-
+
if (!g_path_is_absolute(path)) {
camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
_("Store root %s is not an absolute path"), path);
path, g_strerror (errno));
return NULL;
}
-
+
/* need to create the dir heirarchy */
if (g_mkdir_with_parents (path, 0777) == -1 && errno != EEXIST) {
camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
path, g_strerror (errno));
return NULL;
}
-
+
return (CamelFolder *) 0xdeadbeef;
}
CamelFolder *lf;
char *name;
char *str;
-
+
/* remove metadata only */
name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
str = g_strdup_printf("%s.ev-summary", name);
} else {
camel_exception_clear (&lex);
}
-
+
if (str == NULL)
str = g_strdup_printf ("%s.cmeta", name);
-
+
if (g_unlink (str) == -1 && errno != ENOENT) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not delete folder meta file `%s': %s"),
g_free (str);
return;
}
-
+
g_free (str);
g_free (name);
-
+
fi = g_new0 (CamelFolderInfo, 1);
fi->full_name = g_strdup (folder_name);
fi->name = g_path_get_basename (folder_name);
fi->uri = g_strdup_printf ("%s:%s#%s", ((CamelService *) store)->url->protocol,
CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
fi->unread = -1;
-
+
camel_object_trigger_event (store, "folder_deleted", fi);
-
+
camel_folder_info_free (fi);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-mbox-store.h : class for an mbox store */
-/*
+/*
*
* Copyright (C) 2000 Ximian, Inc. <bertrand@helixcode.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
G_BEGIN_DECLS
typedef struct {
- CamelStore parent_object;
+ CamelStore parent_object;
char *toplevel_dir;
} CamelLocalStore;
camel_local_summary_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_folder_summary_get_type(), "CamelLocalSummary",
sizeof (CamelLocalSummary),
(CamelObjectInitFunc) camel_local_summary_init,
(CamelObjectFinalizeFunc) camel_local_summary_finalise);
}
-
+
return type;
}
camel_local_summary_class_init(CamelLocalSummaryClass *klass)
{
CamelFolderSummaryClass *sklass = (CamelFolderSummaryClass *) klass;
-
+
camel_local_summary_parent = CAMEL_FOLDER_SUMMARY_CLASS(camel_type_get_global_classfuncs(camel_folder_summary_get_type()));
sklass->summary_header_load = summary_header_load;
}
printf("\nMemory used by summary:\n\n");
- printf("Total of %d messages\n", camel_folder_summary_count(s));
+ printf("Total of %d messages\n", camel_folder_summary_count(s));
printf("Total: %d bytes (ave %f)\n", stats.citotal + stats.mitotal,
(double)(stats.citotal+stats.mitotal)/(double)camel_folder_summary_count(s));
printf("Message Info: %d (ave %f)\n", stats.mitotal, (double)stats.mitotal/(double)stats.micount);
/**
* camel_local_summary_write_headers:
- * @fd:
- * @header:
- * @xevline:
+ * @fd:
+ * @header:
+ * @xevline:
* @status:
* @xstatus:
- *
+ *
* Write a bunch of headers to the file @fd. IF xevline is non NULL, then
* an X-Evolution header line is created at the end of all of the headers.
* If @status is non NULL, then a Status header line is also written.
* The headers written are termianted with a blank line.
- *
+ *
* Return value: -1 on error, otherwise the number of bytes written.
**/
int
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not save summary: %s: %s"),
cls->folder_path, g_strerror (errno));
-
+
g_warning ("Could not save summary for %s: %s", cls->folder_path, strerror (errno));
}
char *xev;
d(printf("Adding message to summary\n"));
-
+
mi = (CamelLocalMessageInfo *)camel_folder_summary_add_from_message((CamelFolderSummary *)cls, msg);
if (mi) {
d(printf("Added, uid = %s\n", mi->uid));
camel_message_info_set_user_flag((CamelMessageInfo *)mi, flag->name, TRUE);
flag = flag->next;
}
-
+
while (tag) {
camel_message_info_set_user_tag((CamelMessageInfo *)mi, tag->name, tag->value);
tag = tag->next;
if (flag || tag) {
val = g_string_new ("");
-
+
if (flag) {
while (flag) {
g_string_append (val, flag->name);
}
ret = out->str;
g_string_free (out, FALSE);
-
+
return ret;
}
if (mi == NULL)
return 0;
- /* check for additional data */
+ /* check for additional data */
header = strchr(xev, ';');
if (header) {
params = camel_header_param_list_decode(header+1);
/* shortcut, no need to look it up in the index library */
doindex = TRUE;
}
-
+
if (cls->index
&& (doindex
|| cls->index_force
camel_folder_summary_set_index(s, NULL);
}
}
-
+
return (CamelMessageInfo *)mi;
}
guint32 version; /* file version being loaded */
char *folder_path; /* name of matching folder */
-
+
CamelIndex *index;
unsigned int index_force:1; /* do we force index during creation? */
unsigned int check_force:1; /* does a check force a full check? */
*
* Copyright (C) 1999, 2003 Ximian Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
(CamelObjectInitFunc) maildir_init,
(CamelObjectFinalizeFunc) maildir_finalize);
}
-
+
return camel_maildir_folder_type;
}
CamelMessageInfo *mi;
CamelMaildirMessageInfo *mdi;
char *name, *dest = NULL;
-
+
d(printf("Appending message\n"));
/* add it to the summary/assign the uid, etc */
mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
if (camel_exception_is_set (ex))
return;
-
+
mdi = (CamelMaildirMessageInfo *)mi;
d(printf("Appending message: uid is %s filename is %s\n", camel_message_info_uid(mi), mdi->filename));
output_stream = camel_stream_fs_new_with_name (name, O_WRONLY|O_CREAT, 0600);
if (output_stream == NULL)
goto fail_write;
-
+
if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, output_stream) == -1
|| camel_stream_close (output_stream) == -1)
goto fail_write;
-
+
/* now move from tmp to cur (bypass new, does it matter?) */
dest = g_strdup_printf("%s/cur/%s", lf->folder_path, camel_maildir_info_filename (mdi));
if (rename (name, dest) == -1)
g_free (dest);
g_free (name);
-
+
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed",
((CamelLocalFolder *)maildir_folder)->changes);
camel_folder_change_info_clear (((CamelLocalFolder *)maildir_folder)->changes);
-
+
if (appended_uid)
*appended_uid = g_strdup(camel_message_info_uid(mi));
return;
-
+
fail_write:
-
+
/* remove the summary info so we are not out-of-sync with the mh folder */
camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (folder->summary),
camel_message_info_uid (mi));
-
+
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
_("Maildir append message canceled"));
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot append message to maildir folder: %s: %s"),
name, g_strerror (errno));
-
+
if (output_stream) {
camel_object_unref (CAMEL_OBJECT (output_stream));
unlink (name);
}
-
+
g_free (name);
g_free (dest);
}
*
* Copyright (C) 1999 Ximian Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct {
CamelLocalFolderClass parent_class;
-
+
/* Virtual methods */
-
+
} CamelMaildirFolderClass;
/* public methods */
*
* Authors: Michael Zucchi <notzed@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
static gboolean scan_equal(const void *a, const void *b)
{
const struct _scan_node *v1 = a, *v2 = b;
-
+
return v1->inode == v2->inode && v1->dnode == v2->dnode;
}
*
* Authors: Michael Zucchi <notzed@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct {
CamelLocalStore parent_object;
-
+
} CamelMaildirStore;
typedef struct {
CamelLocalStoreClass parent_class;
-
+
} CamelMaildirStoreClass;
/* public methods */
camel_maildir_summary_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_local_summary_get_type (), "CamelMaildirSummary",
sizeof(CamelMaildirSummary),
(CamelObjectInitFunc)camel_maildir_summary_init,
(CamelObjectFinalizeFunc)camel_maildir_summary_finalise);
}
-
+
return type;
}
* @index: Index if one is reqiured.
*
* Create a new CamelMaildirSummary object.
- *
+ *
* Return value: A new #CamelMaildirSummary object.
**/
CamelMaildirSummary *camel_maildir_summary_new(struct _CamelFolder *folder, const char *filename, const char *maildirdir, CamelIndex *index)
*p++ = flagbits[i].flag;
}
*p = 0;
-
+
return g_strdup(buf);
}
while ( (d = readdir(dir)) ) {
if (d->d_name[0] == '.')
continue;
-
+
/* map the filename -> uid */
uid = strchr(d->d_name, ':');
if (uid) {
uid = g_strndup(d->d_name, uid-d->d_name);
else
uid = g_strdup(d->d_name);
-
+
info = g_hash_table_lookup(left, uid);
if (info) {
camel_message_info_free(info);
#else
# ifdef DOEPOOLV
info->strings = e_poolv_set(info->strings, CAMEL_MAILDIR_INFO_FILENAME, d->d_name, FALSE);
-# else
+# else
g_free(mdi->filename);
mdi->filename = g_strdup(d->d_name);
# endif
*
* Copyright (C) 1999, 2003 Ximian Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
filter_from = (CamelMimeFilter *) camel_mime_filter_from_new();
camel_stream_filter_add((CamelStreamFilter *) filter_stream, filter_from);
camel_object_unref (filter_from);
-
+
if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) message, filter_stream) == -1 ||
camel_stream_write (filter_stream, "\n", 1) == -1 ||
camel_stream_flush (filter_stream) == -1)
goto fail_write;
-
+
/* filter stream ref's the output stream itself, so we need to unref it too */
camel_object_unref (filter_stream);
camel_object_unref (output_stream);
g_free(fromline);
-
+
/* now we 'fudge' the summary to tell it its uptodate, because its idea of uptodate has just changed */
/* the stat really shouldn't fail, we just wrote to it */
if (g_stat (lf->folder_path, &st) == 0) {
((CamelFolderSummary *) mbs)->time = st.st_mtime;
mbs->folder_size = st.st_size;
}
-
+
/* unlock as soon as we can */
camel_local_folder_unlock(lf);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot append message to mbox file: %s: %s"),
lf->folder_path, g_strerror (errno));
-
+
if (output_stream) {
/* reset the file to original size */
do {
retval = ftruncate (((CamelStreamFs *) output_stream)->fd, mbs->folder_size);
} while (retval == -1 && errno == EINTR);
-
+
camel_object_unref (output_stream);
}
-
+
if (filter_stream)
camel_object_unref (filter_stream);
-
+
g_free(fromline);
-
+
/* remove the summary info so we are not out-of-sync with the mbox */
camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (mbs), camel_message_info_uid (mi));
-
+
/* and tell the summary it's up-to-date */
if (g_stat (lf->folder_path, &st) == 0) {
((CamelFolderSummary *) mbs)->time = st.st_mtime;
mbs->folder_size = st.st_size;
}
-
+
fail:
/* make sure we unlock the folder - before we start triggering events into appland */
camel_local_folder_unlock(lf);
camel_local_folder_unlock(lf);
return NULL;
}
-
+
retry:
/* get the message summary info */
info = (CamelMboxMessageInfo *) camel_folder_summary_uid(folder->summary, uid);
frompos = info->frompos;
camel_message_info_free((CamelMessageInfo *)info);
-
+
/* we use an fd instead of a normal stream here - the reason is subtle, camel_mime_part will cache
the whole message in memory if the stream is non-seekable (which it is when built from a parser
with no stream). This means we dont have to lock the mbox for the life of the message, but only
_("The folder appears to be irrecoverably corrupted."));
goto fail;
}
-
+
message = camel_mime_message_new();
if (camel_mime_part_construct_from_parser((CamelMimePart *)message, parser) == -1) {
camel_exception_setv(ex, errno==EINTR?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_SYSTEM,
if (parser)
camel_object_unref((CamelObject *)parser);
-
+
/* use the opportunity to notify of changes (particularly if we had a rebuild) */
if (camel_folder_change_info_changed(lf->changes)) {
camel_object_trigger_event((CamelObject *)folder, "folder_changed", lf->changes);
camel_folder_change_info_clear(lf->changes);
}
-
+
return message;
}
*
* Copyright (C) 1999 Ximian .
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct {
CamelLocalFolderClass parent_class;
- /* Virtual methods */
-
+ /* Virtual methods */
+
} CamelMboxFolderClass;
/* public methods */
*
* Copyright(C) 2000 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#include "camel-mbox-folder.h"
#include "camel-mbox-store.h"
-#define d(x)
+#define d(x)
static CamelLocalStoreClass *parent_class = NULL;
CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS(camel_mbox_store_class);
parent_class =(CamelLocalStoreClass *)camel_type_get_global_classfuncs(camel_local_store_get_type());
-
+
/* virtual method overload */
camel_store_class->get_folder = get_folder;
camel_store_class->delete_folder = delete_folder;
camel_store_class->rename_folder = rename_folder;
camel_store_class->create_folder = create_folder;
-
+
camel_store_class->get_folder_info = get_folder_info;
camel_store_class->free_folder_info = camel_store_free_folder_info_full;
camel_mbox_store_get_type(void)
{
static CamelType camel_mbox_store_type = CAMEL_INVALID_TYPE;
-
+
if (camel_mbox_store_type == CAMEL_INVALID_TYPE) {
camel_mbox_store_type = camel_type_register(CAMEL_LOCAL_STORE_TYPE, "CamelMboxStore",
sizeof(CamelMboxStore),
NULL,
NULL);
}
-
+
return camel_mbox_store_type;
}
ignore_file(const char *filename, gboolean sbd)
{
int flen, len, i;
-
+
/* TODO: Should probably just be 1 regex */
flen = strlen(filename);
if (flen > 0 && filename[flen-1] == '~')
if (len < flen && !strcmp(filename + flen - len, extensions[i]))
return TRUE;
}
-
+
if (sbd && flen > 4 && !strcmp(filename + flen - 4, ".sbd"))
return TRUE;
-
+
return FALSE;
}
{
struct stat st;
char *name;
-
+
if (!((CamelStoreClass *) parent_class)->get_folder(store, folder_name, flags, ex))
return NULL;
-
+
name = camel_local_store_get_full_path(store, folder_name);
-
+
if (g_stat(name, &st) == -1) {
char *basename;
char *dirname;
int fd;
-
+
if (errno != ENOENT) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot get folder `%s': %s"),
g_free(name);
return NULL;
}
-
+
if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) {
camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
_("Cannot get folder `%s': folder does not exist."),
g_free(name);
return NULL;
}
-
+
/* sanity check the folder name */
basename = g_path_get_basename (folder_name);
-
+
if (basename[0] == '.' || ignore_file (basename, TRUE)) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot create a folder by this name."));
return NULL;
}
g_free (basename);
-
+
dirname = g_path_get_dirname(name);
if (g_mkdir_with_parents(dirname, 0777) == -1 && errno != EEXIST) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
g_free(name);
return NULL;
}
-
+
g_free(dirname);
-
+
fd = g_open(name, O_LARGEFILE | O_WRONLY | O_CREAT | O_APPEND | O_BINARY, 0666);
if (fd == -1) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
g_free(name);
return NULL;
}
-
+
g_free(name);
close(fd);
} else if (!S_ISREG(st.st_mode)) {
return NULL;
} else
g_free(name);
-
+
return camel_mbox_folder_new(store, folder_name, flags, ex);
}
CamelFolder *lf;
char *name, *path;
struct stat st;
-
+
name = camel_local_store_get_full_path(store, folder_name);
path = g_strdup_printf("%s.sbd", name);
-
+
if (g_rmdir(path) == -1 && errno != ENOENT) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not delete folder `%s':\n%s"),
g_free(name);
return;
}
-
+
g_free(path);
-
+
if (g_stat(name, &st) == -1) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not delete folder `%s':\n%s"),
g_free(name);
return;
}
-
+
if (!S_ISREG(st.st_mode)) {
camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
_("`%s' is not a regular file."), name);
g_free(name);
return;
}
-
+
if (st.st_size != 0) {
camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_NON_EMPTY,
_("Folder `%s' is not empty. Not deleted."),
g_free(name);
return;
}
-
+
if (g_unlink(name) == -1 && errno != ENOENT) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not delete folder `%s':\n%s"),
g_free(name);
return;
}
-
+
/* FIXME: we have to do our own meta cleanup here rather than
* calling our parent class' delete_folder() method since our
* naming convention is different. Need to find a way for
g_free(name);
return;
}
-
+
g_free(path);
-
+
path = camel_local_store_get_meta_path(store, folder_name, ".ev-summary-meta");
if (g_unlink(path) == -1 && errno != ENOENT) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
g_free(name);
return;
}
-
+
g_free(path);
path = camel_local_store_get_meta_path(store, folder_name, ".ibex");
g_free(name);
return;
}
-
+
g_free(path);
path = NULL;
} else {
camel_exception_clear(&lex);
}
-
+
if (path == NULL)
path = camel_local_store_get_meta_path(store, folder_name, ".cmeta");
-
+
if (g_unlink(path) == -1 && errno != ENOENT) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not delete folder meta file `%s': %s"),
path, g_strerror(errno));
-
+
g_free(path);
g_free(name);
return;
}
-
+
g_free(path);
g_free(name);
-
+
fi = g_new0(CamelFolderInfo, 1);
fi->full_name = g_strdup(folder_name);
fi->name = g_path_get_basename(folder_name);
fi->uri = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, folder_name);
fi->unread = -1;
-
+
camel_object_trigger_event(store, "folder_deleted", fi);
-
+
camel_folder_info_free(fi);
}
char *path, *name, *dir;
CamelFolder *folder;
struct stat st;
-
+
if (!g_path_is_absolute(toplevel_dir)) {
camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
_("Store root %s is not an absolute path"), toplevel_dir);
return NULL;
}
-
+
if (folder_name[0] == '.' || ignore_file(folder_name, TRUE)) {
camel_exception_set(ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot create a folder by this name."));
return NULL;
}
-
+
if (parent_name && *parent_name)
name = g_strdup_printf("%s/%s", parent_name, folder_name);
else
name = g_strdup(folder_name);
-
+
path = camel_local_store_get_full_path(store, name);
-
+
dir = g_path_get_dirname(path);
if (g_mkdir_with_parents(dir, 0777) == -1 && errno != EEXIST) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot create directory `%s': %s."),
dir, g_strerror(errno));
-
+
g_free(path);
g_free(name);
g_free(dir);
-
+
return NULL;
}
-
+
g_free(dir);
-
+
if (g_stat(path, &st) == 0 || errno != ENOENT) {
camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
_("Cannot create folder: %s: %s"),
path, errno ? g_strerror(errno) :
_("Folder already exists"));
-
+
g_free(path);
g_free(name);
-
+
return NULL;
}
-
+
g_free(path);
-
+
folder =((CamelStoreClass *)((CamelObject *) store)->klass)->get_folder(store, name, CAMEL_STORE_FOLDER_CREATE, ex);
if (folder) {
camel_object_unref(folder);
info =((CamelStoreClass *)((CamelObject *) store)->klass)->get_folder_info(store, name, 0, ex);
}
-
+
g_free(name);
-
+
return info;
}
struct stat st;
int ret = -1;
int err = 0;
-
+
if (ext != NULL) {
oldpath = camel_local_store_get_meta_path(ls, old_name, ext);
newpath = camel_local_store_get_meta_path(ls, new_name, ext);
oldpath = camel_local_store_get_full_path(ls, old_name);
newpath = camel_local_store_get_full_path(ls, new_name);
}
-
+
if (g_stat(oldpath, &st) == -1) {
if (missingok && errno == ENOENT) {
ret = 0;
ret = -1;
#endif
}
-
+
g_free(oldpath);
g_free(newpath);
-
+
return ret;
}
CamelLocalFolder *folder = NULL;
char *oldibex, *newibex, *newdir;
int errnosav;
-
+
if (new[0] == '.' || ignore_file(new, TRUE)) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("The new folder name is illegal."));
return;
}
-
+
/* try to rollback failures, has obvious races */
-
+
oldibex = camel_local_store_get_meta_path(store, old, ".ibex");
newibex = camel_local_store_get_meta_path(store, new, ".ibex");
-
+
newdir = g_path_get_dirname(newibex);
if (g_mkdir_with_parents(newdir, 0777) == -1) {
if (errno != EEXIST) {
g_free(oldibex);
g_free(newibex);
g_free(newdir);
-
+
return;
}
-
+
g_free(newdir);
newdir = NULL;
}
-
+
folder = camel_object_bag_get(store->folders, old);
if (folder && folder->index) {
if (camel_index_rename(folder->index, newibex) == -1 && errno != ENOENT) {
goto ibex_failed;
}
}
-
+
if (xrename(store, old, new, ".ev-summary", TRUE) == -1) {
errnosav = errno;
goto summary_failed;
errnosav = errno;
goto cmeta_failed;
}
-
+
if (xrename(store, old, new, ".sbd", TRUE) == -1) {
errnosav = errno;
goto subdir_failed;
}
-
+
if (xrename(store, old, new, NULL, FALSE) == -1) {
errnosav = errno;
goto base_failed;
}
-
+
g_free(oldibex);
g_free(newibex);
-
+
if (folder)
camel_object_unref(folder);
-
+
return;
-
+
base_failed:
xrename(store, new, old, ".sbd", TRUE);
subdir_failed:
xrename(store, new, old, ".cmeta", TRUE);
-cmeta_failed:
+cmeta_failed:
xrename(store, new, old, ".ev-summary", TRUE);
xrename(store, new, old, ".ev-summary-meta", TRUE);
summary_failed:
g_rmdir(newdir);
g_free(newdir);
}
-
+
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not rename '%s' to %s: %s"),
old, new, g_strerror(errnosav));
-
+
g_free(newibex);
g_free(oldibex);
-
+
if (folder)
camel_object_unref(folder);
}
inode_hash(const void *d)
{
const struct _inode *v = d;
-
+
return v->inode ^ v->dnode;
}
inode_equal(const void *a, const void *b)
{
const struct _inode *v1 = a, *v2 = b;
-
+
return v1->inode == v2->inode && v1->dnode == v2->dnode;
}
/* This should be fast enough not to have to test for INFO_FAST */
path = camel_local_store_get_meta_path(store, fi->full_name, ".ev-summary");
folderpath = camel_local_store_get_full_path(store, fi->full_name);
-
+
mbs = (CamelMboxSummary *)camel_mbox_summary_new(NULL, path, folderpath, NULL);
if (camel_folder_summary_header_load((CamelFolderSummary *)mbs) != -1) {
fi->unread = ((CamelFolderSummary *)mbs)->unread_count;
GHashTable *folder_hash;
const char *dent;
GDir *dir;
-
+
tail = folders = NULL;
-
+
if (!(dir = g_dir_open(root, 0, NULL)))
return NULL;
-
+
folder_hash = g_hash_table_new(g_str_hash, g_str_equal);
-
+
/* FIXME: it would be better if we queue'd up the recursive
* scans till the end so that we can limit the number of
* directory descriptors open at any given time... */
-
+
while ((dent = g_dir_read_name(dir))) {
char *short_name, *full_name, *path, *ext;
struct stat st;
-
+
if (dent[0] == '.')
continue;
-
+
if (ignore_file(dent, FALSE))
continue;
-
+
path = g_strdup_printf("%s/%s", root, dent);
if (g_stat(path, &st) == -1) {
g_free(path);
continue;
}
-#ifndef G_OS_WIN32
+#ifndef G_OS_WIN32
if (S_ISDIR(st.st_mode)) {
struct _inode in = { st.st_dev, st.st_ino };
-
+
if (g_hash_table_lookup(visited, &in)) {
g_free(path);
continue;
}
}
-#endif
+#endif
short_name = g_strdup(dent);
if ((ext = strrchr(short_name, '.')) && !strcmp(ext, ".sbd"))
*ext = '\0';
-
+
if (name != NULL)
full_name = g_strdup_printf("%s/%s", name, short_name);
else
full_name = g_strdup(short_name);
-
+
if ((fi = g_hash_table_lookup(folder_hash, short_name)) != NULL) {
g_free(short_name);
g_free(full_name);
-
+
if (S_ISDIR(st.st_mode)) {
fi->flags =(fi->flags & ~CAMEL_FOLDER_NOCHILDREN) | CAMEL_FOLDER_CHILDREN;
} else {
} else {
fi = g_new0(CamelFolderInfo, 1);
fi->parent = parent;
-
+
camel_url_set_fragment (url, full_name);
-
+
fi->uri = camel_url_to_string (url, 0);
fi->name = short_name;
fi->full_name = full_name;
fi->flags = CAMEL_FOLDER_NOSELECT;
else
fi->flags = CAMEL_FOLDER_NOCHILDREN;
-
+
if (tail == NULL)
folders = fi;
else
tail->next = fi;
-
+
tail = fi;
-
+
g_hash_table_insert(folder_hash, fi->name, fi);
}
-
+
if (!S_ISDIR(st.st_mode)) {
fill_fi(store, fi, flags);
} else if ((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE)) {
struct _inode in = { st.st_dev, st.st_ino };
-
+
if (g_hash_table_lookup(visited, &in) == NULL) {
#ifndef G_OS_WIN32
struct _inode *inew = g_new(struct _inode, 1);
-
+
*inew = in;
g_hash_table_insert(visited, inew, inew);
#endif
fi->flags =(fi->flags & ~CAMEL_FOLDER_CHILDREN) | CAMEL_FOLDER_NOCHILDREN;
}
}
-
+
g_free(path);
}
-
+
g_dir_close(dir);
-
+
g_hash_table_destroy(folder_hash);
-
+
return folders;
}
char *basename;
struct stat st;
CamelURL *url;
-
+
top = top ? top : "";
path = camel_local_store_get_full_path(store, top);
-
+
if (*top == '\0') {
/* requesting root dir scan */
if (g_stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
g_free(path);
return NULL;
}
-
+
visited = g_hash_table_new(inode_hash, inode_equal);
#ifndef G_OS_WIN32
inode = g_malloc0(sizeof(*inode));
inode->dnode = st.st_dev;
inode->inode = st.st_ino;
-
+
g_hash_table_insert(visited, inode, inode);
#endif
url = camel_url_copy (((CamelService *) store)->url);
g_hash_table_destroy(visited);
camel_url_free (url);
g_free (path);
-
+
return fi;
}
-
+
/* requesting scan of specific folder */
if (g_stat(path, &st) == -1 || !S_ISREG(st.st_mode)) {
g_free(path);
return NULL;
}
-
+
visited = g_hash_table_new(inode_hash, inode_equal);
-
+
basename = g_path_get_basename(top);
-
+
url = camel_url_copy (((CamelService *) store)->url);
camel_url_set_fragment (url, top);
-
+
fi = g_new0(CamelFolderInfo, 1);
fi->parent = NULL;
fi->uri = camel_url_to_string (url, 0);
fi->full_name = g_strdup(top);
fi->unread = -1;
fi->total = -1;
-
+
subdir = g_strdup_printf("%s.sbd", path);
if (g_stat(subdir, &st) == 0) {
if (S_ISDIR(st.st_mode))
fill_fi(store, fi, flags);
} else
fill_fi(store, fi, flags);
-
+
camel_url_free (url);
-
+
if (fi->child)
fi->flags |= CAMEL_FOLDER_CHILDREN;
else
fi->flags |= CAMEL_FOLDER_NOCHILDREN;
-
+
g_free(subdir);
-
+
g_hash_table_foreach(visited, inode_free, NULL);
g_hash_table_destroy(visited);
g_free(path);
-
+
return fi;
}
const char *inptr = full_name;
int subdirs = 0;
char *path, *p;
-
+
while (*inptr != '\0') {
if (G_IS_DIR_SEPARATOR (*inptr))
subdirs++;
inptr++;
}
-
+
path = g_malloc (strlen (ls->toplevel_dir) + (inptr - full_name) + (4 * subdirs) + 1);
p = g_stpcpy (path, ls->toplevel_dir);
-
+
inptr = full_name;
while (*inptr != '\0') {
while (!G_IS_DIR_SEPARATOR (*inptr) && *inptr != '\0')
*p++ = *inptr++;
-
+
if (G_IS_DIR_SEPARATOR (*inptr)) {
p = g_stpcpy (p, ".sbd/");
inptr++;
-
+
/* strip extranaeous '/'s */
while (G_IS_DIR_SEPARATOR (*inptr))
inptr++;
}
}
-
+
*p = '\0';
-
+
return path;
}
/*#define USE_HIDDEN_META_FILES*/
#ifdef USE_HIDDEN_META_FILES
char *name, *slash;
-
+
name = g_alloca (strlen (full_name) + strlen (ext) + 2);
if ((slash = strrchr (full_name, '/')))
sprintf (name, "%.*s.%s%s", slash - full_name + 1, full_name, slash + 1, ext);
else
sprintf (name, ".%s%s", full_name, ext);
-
+
return mbox_get_full_path(ls, name);
#else
char *full_path, *path;
-
+
full_path = mbox_get_full_path(ls, full_name);
path = g_strdup_printf ("%s%s", full_path, ext);
g_free (full_path);
-
+
return path;
#endif
}
*
* Copyright (C) 2000 Ximian, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
G_BEGIN_DECLS
typedef struct {
- CamelLocalStore parent_object;
-
+ CamelLocalStore parent_object;
+
} CamelMboxStore;
typedef struct {
camel_mbox_summary_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_local_summary_get_type(), "CamelMboxSummary",
sizeof (CamelMboxSummary),
(CamelObjectInitFunc) camel_mbox_summary_init,
(CamelObjectFinalizeFunc) camel_mbox_summary_finalise);
}
-
+
return type;
}
static gboolean
{
CamelFolderSummaryClass *sklass = (CamelFolderSummaryClass *)klass;
CamelLocalSummaryClass *lklass = (CamelLocalSummaryClass *)klass;
-
+
camel_mbox_summary_parent = (CamelLocalSummaryClass *)camel_type_get_global_classfuncs(camel_local_summary_get_type());
sklass->summary_header_load = summary_header_load;
#ifdef STATUS_PINE
sklass->info_set_flags = mbox_info_set_flags;
#endif
-
+
lklass->encode_x_evolution = mbox_summary_encode_x_evolution;
lklass->check = mbox_summary_check;
lklass->sync = mbox_summary_sync;
camel_mbox_summary_init(CamelMboxSummary *obj)
{
struct _CamelFolderSummary *s = (CamelFolderSummary *)obj;
-
+
/* subclasses need to set the right instance data sizes */
s->message_info_size = sizeof(CamelMboxMessageInfo);
s->content_info_size = sizeof(CamelMboxMessageContentInfo);
* camel_mbox_summary_new:
*
* Create a new CamelMboxSummary object.
- *
+ *
* Return value: A new CamelMboxSummary widget.
**/
CamelMboxSummary *
p = uidstr = camel_message_info_uid(mi);
while (*p && isdigit(*p))
p++;
-
+
if (*p == 0 && sscanf(uidstr, "%u", &uid) == 1) {
return g_strdup_printf("%08x-%04x", uid, mi->info.flags & 0xffff);
} else {
mi->frompos = -1;
}
-
+
return (CamelMessageInfo *)mi;
}
mbi->frompos = camel_mime_parser_tell_start_from(mp);
}
-
+
return mi;
}
mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_load(s, in);
if (mi) {
CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi;
-
+
if (camel_file_util_decode_off_t(in, &mbi->frompos) == -1)
goto error;
}
-
+
return mi;
error:
camel_message_info_free(mi);
camel_operation_end(NULL);
return -1;
}
-
+
if (fstat(fd, &st) == 0)
size = st.st_size;
while (camel_mime_parser_step(mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM) {
CamelMessageInfo *info;
off_t pc = camel_mime_parser_tell_start_from (mp) + 1;
-
+
camel_operation_progress (NULL, (int) (((float) pc / size) * 100));
info = camel_folder_summary_add_from_parser(s, mp);
camel_message_info_free(mi);
}
mbs->changes = NULL;
-
+
/* update the file size/mtime in the summary */
if (ok != -1) {
if (g_stat(cls->folder_path, &st) == 0) {
tmpname = NULL;
camel_operation_end(NULL);
-
+
return 0;
error:
if (fd != -1)
close(fd);
-
+
if (fdout != -1)
close(fdout);
-
+
if (tmpname)
g_unlink(tmpname);
camel_object_unref((CamelObject *)mp);
camel_operation_end(NULL);
-
+
return 0;
error:
if (fd != -1)
camel_message_info_free((CamelMessageInfo *)info);
}
}
-
+
return 0;
error:
g_free(xevnew);
-
+
if (mp)
camel_object_unref((CamelObject *)mp);
if (info)
{
size_t i;
char *p;
-
+
p = status;
for (i = 0; i < G_N_ELEMENTS (status_flags); i++)
if (status_flags[i].flag & flags)
guint32 flags = 0;
size_t i;
char c;
-
+
p = status;
while ((c = *p++)) {
for (i = 0; i < G_N_ELEMENTS (status_flags); i++)
if (status_flags[i].tag == c)
flags |= status_flags[i].flag;
}
-
+
return flags;
}
*
* Copyright (C) 1999, 2003 Ximian Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
if (camel_exception_is_set (ex))
return;
-
+
d(printf("Appending message: uid is %s\n", camel_message_info_uid(mi)));
-
+
/* write it out, use the uid we got from the summary */
name = g_strdup_printf("%s/%s", lf->folder_path, camel_message_info_uid(mi));
output_stream = camel_stream_fs_new_with_name(name, O_WRONLY|O_CREAT, 0600);
if (output_stream == NULL)
goto fail_write;
-
+
if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, output_stream) == -1
|| camel_stream_close (output_stream) == -1)
goto fail_write;
-
+
/* close this? */
camel_object_unref (CAMEL_OBJECT (output_stream));
g_free(name);
-
+
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed",
((CamelLocalFolder *)mh_folder)->changes);
camel_folder_change_info_clear (((CamelLocalFolder *)mh_folder)->changes);
-
+
if (appended_uid)
*appended_uid = g_strdup(camel_message_info_uid(mi));
return;
-
+
fail_write:
-
+
/* remove the summary info so we are not out-of-sync with the mh folder */
camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (folder->summary),
camel_message_info_uid (mi));
-
+
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
_("MH append message canceled"));
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot append message to mh folder: %s: %s"),
name, g_strerror (errno));
-
+
if (output_stream) {
camel_object_unref (CAMEL_OBJECT (output_stream));
unlink (name);
}
-
+
g_free (name);
}
*
* Copyright (C) 1999 Ximian Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct {
CamelLocalFolderClass parent_class;
-
+
/* Virtual methods */
-
+
} CamelMhFolderClass;
/* public methods */
*
* Authors: Michael Zucchi <notzed@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
tmpnew = g_alloca (strlen (root) + 16);
sprintf (tmpnew, "%s.folders~", root);
-
+
out = camel_stream_fs_new_with_name(tmpnew, O_WRONLY|O_CREAT|O_TRUNC, 0666);
if (out == NULL)
goto fail;
g_free (name);
return NULL;
}
-
+
g_free(name);
return camel_mh_folder_new(store, folder_name, flags, ex);
char *base;
base = strrchr(path, '/');
-
+
camel_url_set_fragment (url, path);
-
+
/* Build the folder info structure. */
fi = g_malloc0(sizeof(*fi));
fi->uri = camel_url_to_string (url, 0);
if (path[0]) {
fullpath = alloca (strlen (root) + strlen (path) + 2);
sprintf (fullpath, "%s/%s", root, path);
- } else
+ } else
fullpath = (char *)root;
if (stat(fullpath, &st) == -1 || !S_ISDIR(st.st_mode))
if (strncmp(top, line, toplen) != 0
|| (line[toplen] != 0 && line[toplen] != '/'))
continue;
-
+
/* check is not sub-subdir if not recursive */
if ((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) == 0
&& (tmp = strrchr(line, '/'))
static gboolean inode_equal(const void *a, const void *b)
{
const struct _inode *v1 = a, *v2 = b;
-
+
return v1->inode == v2->inode && v1->dnode == v2->dnode;
}
CamelFolderInfo *fi = NULL;
CamelURL *url;
char *root;
-
+
root = ((CamelService *)store)->url->path;
-
+
url = camel_url_copy (((CamelService *) store)->url);
-
+
/* use .folders if we are supposed to */
if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) {
folders_scan(store, url, root, top, &fi, flags);
g_hash_table_foreach(visited, inode_free, NULL);
g_hash_table_destroy(visited);
}
-
+
camel_url_free (url);
-
+
return fi;
}
*
* Authors: Michael Zucchi <notzed@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct {
CamelLocalStoreClass parent_class;
-
+
} CamelMhStoreClass;
/* public methods */
camel_mh_summary_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_local_summary_get_type (), "CamelMhSummary",
sizeof(CamelMhSummary),
(CamelObjectInitFunc)camel_mh_summary_init,
(CamelObjectFinalizeFunc)camel_mh_summary_finalise);
}
-
+
return type;
}
* camel_mh_summary_new:
*
* Create a new CamelMhSummary object.
- *
+ *
* Return value: A new #CamelMhSummary object.
**/
CamelMhSummary *camel_mh_summary_new(struct _CamelFolder *folder, const char *filename, const char *mhdir, CamelIndex *index)
/* FIXME: put this in folder_summary::remove()? */
if (cls->index)
camel_index_delete_name(cls->index, (char *)uid);
-
+
camel_folder_change_info_remove_uid(changes, uid);
camel_folder_summary_remove((CamelFolderSummary *)cls, (CamelMessageInfo *)info);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*-
- *
+ *
* Authors: Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2001-2003 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
}
retry++;
}
-
+
close (mf->lockfd);
mf->lockfd = -1;
-
+
return -1;
}
*
* Copyright (C) 2001 Ximian Inc (www.ximian.com/)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* Copyright (C) 2001 Ximian Inc (www.ximian.com/)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
{
CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_spool_store_class);
CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS (camel_spool_store_class);
-
+
parent_class = CAMEL_STORE_CLASS(camel_mbox_store_get_type());
/* virtual method overload */
camel_spool_store_get_type (void)
{
static CamelType camel_spool_store_type = CAMEL_INVALID_TYPE;
-
+
if (camel_spool_store_type == CAMEL_INVALID_TYPE) {
camel_spool_store_type = camel_type_register (camel_mbox_store_get_type(), "CamelSpoolStore",
sizeof (CamelSpoolStore),
NULL,
NULL);
}
-
+
return camel_spool_store_type;
}
}
if (path != NULL) {
- fi = spool_new_fi(store, parent, fip, path, CAMEL_FOLDER_NOSELECT);
+ fi = spool_new_fi(store, parent, fip, path, CAMEL_FOLDER_NOSELECT);
fip = &fi->child;
parent = fi;
}
-
+
while ( (d = readdir(dir)) ) {
if (strcmp(d->d_name, ".") == 0
|| strcmp(d->d_name, "..") == 0)
continue;
-
+
tmp = g_strdup_printf("%s/%s", name, d->d_name);
if (stat(tmp, &st) == 0) {
if (path)
} else if (S_ISDIR(st.st_mode)) {
struct _inode in = { st.st_dev, st.st_ino };
-
+
/* see if we've visited already */
if (g_hash_table_lookup(visited, &in) == NULL) {
struct _inode *inew = g_malloc(sizeof(*inew));
-
+
*inew = in;
g_hash_table_insert(visited, inew, inew);
static gboolean inode_equal(const void *a, const void *b)
{
const struct _inode *v1 = a, *v2 = b;
-
+
return v1->inode == v2->inode && v1->dnode == v2->dnode;
}
*
* Copyright (C) 2001 Ximian Inc (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
} camel_spool_store_t;
typedef struct {
- CamelMboxStore parent_object;
+ CamelMboxStore parent_object;
camel_spool_store_t type;
} CamelSpoolStore;
camel_spool_summary_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_mbox_summary_get_type(), "CamelSpoolSummary",
sizeof (CamelSpoolSummary),
(CamelObjectInitFunc) camel_spool_summary_init,
(CamelObjectFinalizeFunc) camel_spool_summary_finalise);
}
-
+
return type;
}
camel_spool_summary_init(CamelSpoolSummary *obj)
{
struct _CamelFolderSummary *s = (CamelFolderSummary *)obj;
-
+
/* message info size is from mbox parent */
/* and a unique file version */
unlink(tmpname);
camel_operation_end(NULL);
-
+
return 0;
error:
if (fd != -1)
close(fd);
-
+
if (fdout != -1)
close(fdout);
-
+
if (tmpname[0] != '\0')
unlink(tmpname);
d(printf("Have to add new headers, re-syncing from the start to accomplish this\n"));
if (((CamelMboxSummaryClass *)((CamelObject *)cls)->klass)->sync_full((CamelMboxSummary *)cls, FALSE, changeinfo, ex) == -1)
return -1;
-
+
if (stat(cls->folder_path, &st) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Unknown error: %s"),
struct _CamelSpoolSummary {
CamelMboxSummary parent;
-
+
};
struct _CamelSpoolSummaryClass {
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-auth.c : authentication for nntp */
-/*
+/*
*
* Copyright (C) 2000 Ximian, Inc. <toshok@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
if (!service->url->authmech && !service->url->passwd) {
gchar *prompt;
-
+
prompt = g_strdup_printf (_("Please enter the NNTP password for %s@%s"),
service->url->user, service->url->host);
service->url->passwd =
camel_session_get_password (session, prompt,
TRUE, service, "password", ex);
g_free (prompt);
-
+
if (!service->url->passwd) {
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
+ camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
"You didn\'t enter a password.");
resp = 666;
goto done;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-auth.h : authentication for nntp */
-/*
+/*
*
- * Author : Chris Toshok <toshok@ximian.com>
+ * Author : Chris Toshok <toshok@ximian.com>
*
* Copyright (C) 1999 Ximian .
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-folder.c : Class for a news folder
*
- * Authors : Chris Toshok <toshok@ximian.com>
+ * Authors : Chris Toshok <toshok@ximian.com>
* Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2001-2003 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
nntp_store = (CamelNNTPStore *) folder->parent_store;
nntp_folder = (CamelNNTPFolder *) folder;
-
+
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
camel_nntp_command(nntp_store, ex, nntp_folder, &line, NULL);
changes = nntp_folder->changes;
nntp_folder->changes = camel_folder_change_info_new();
}
-
+
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
-
+
if (changes) {
camel_object_trigger_event ((CamelObject *) folder, "folder_changed", changes);
camel_folder_change_info_free (changes);
} else if (ret != -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get message %s: %s"), msgid, line);
}
-
+
return stream;
-
+
fail:
if (errno == EINTR)
camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled"));
else
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get message %s: %s"), msgid, g_strerror (errno));
-
+
return NULL;
}
return;
}
*msgid++ = 0;
-
+
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
-
+
stream = nntp_folder_download_message ((CamelNNTPFolder *) disco_folder, article, msgid, ex);
if (stream)
camel_object_unref (stream);
nntp_store = (CamelNNTPStore *) folder->parent_store;
nntp_folder = (CamelNNTPFolder *) folder;
-
+
article = alloca(strlen(uid)+1);
strcpy(article, uid);
msgid = strchr (article, ',');
*msgid++ = 0;
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
-
+
/* Lookup in cache, NEWS is global messageid's so use a global cache path */
stream = camel_data_cache_get (nntp_store->cache, "cache", msgid, NULL);
if (stream == NULL) {
if (stream == NULL)
goto fail;
}
-
+
message = camel_mime_message_new ();
if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream) == -1) {
if (errno == EINTR)
} else {
changes = NULL;
}
-
+
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
-
+
if (changes) {
camel_object_trigger_event ((CamelObject *) folder, "folder_changed", changes);
camel_folder_change_info_free (changes);
}
-
+
return message;
}
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
GPtrArray *matches;
-
+
CAMEL_NNTP_FOLDER_LOCK(nntp_folder, search_lock);
-
+
if (nntp_folder->search == NULL)
nntp_folder->search = camel_folder_search_new ();
-
+
camel_folder_search_set_folder (nntp_folder->search, folder);
matches = camel_folder_search_search(nntp_folder->search, expression, NULL, ex);
-
+
CAMEL_NNTP_FOLDER_UNLOCK(nntp_folder, search_lock);
-
+
return matches;
}
if (uids->len == 0)
return g_ptr_array_new();
-
+
CAMEL_NNTP_FOLDER_LOCK(folder, search_lock);
-
+
if (nntp_folder->search == NULL)
nntp_folder->search = camel_folder_search_new ();
-
+
camel_folder_search_set_folder (nntp_folder->search, folder);
matches = camel_folder_search_search(nntp_folder->search, expression, uids, ex);
-
+
CAMEL_NNTP_FOLDER_UNLOCK(folder, search_lock);
-
+
return matches;
}
nntp_folder_search_free (CamelFolder *folder, GPtrArray *result)
{
CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
-
+
camel_folder_search_free_result (nntp_folder->search, result);
}
-static void
+static void
nntp_folder_append_message_online (CamelFolder *folder, CamelMimeMessage *mime_message,
const CamelMessageInfo *info, char **appended_uid,
CamelException *ex)
unsigned int u;
struct _camel_header_raw *header, *savedhdrs, *n, *tail;
char *group, *line;
-
+
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
-
+
/* send 'POST' command */
ret = camel_nntp_command (nntp_store, ex, NULL, &line, "post");
if (ret != 340) {
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
return;
}
-
+
/* the 'Newsgroups: ' header */
group = g_strdup_printf ("Newsgroups: %s\r\n", folder->full_name);
-
+
/* setup stream filtering */
crlffilter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS);
filtered_stream = camel_stream_filter_new_with_stream (stream);
camel_stream_filter_add (filtered_stream, crlffilter);
camel_object_unref (crlffilter);
-
+
/* remove mail 'To', 'CC', and 'BCC' headers */
savedhdrs = NULL;
tail = (struct _camel_header_raw *) &savedhdrs;
-
+
header = (struct _camel_header_raw *) &CAMEL_MIME_PART (mime_message)->headers;
n = header->next;
while (n != NULL) {
} else {
header = n;
}
-
+
n = header->next;
}
-
+
/* write the message */
if (camel_stream_write(stream, group, strlen(group)) == -1
|| camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (mime_message), CAMEL_STREAM (filtered_stream)) == -1
header->next = savedhdrs;
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
-
+
return;
}
CamelException *ex)
{
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("You cannot post NNTP messages while working offline!"));
+ _("You cannot post NNTP messages while working offline!"));
}
/* I do not know what to do this exactly. Looking at the IMAP implementation for this, it
_("You cannot copy messages from a NNTP folder!"));
}
-static void
+static void
nntp_folder_init (CamelNNTPFolder *nntp_folder, CamelNNTPFolderClass *klass)
{
struct _CamelNNTPFolderPrivate *p;
-
+
nntp_folder->changes = camel_folder_change_info_new ();
p = nntp_folder->priv = g_malloc0 (sizeof (*nntp_folder->priv));
p->search_lock = g_mutex_new ();
p->cache_lock = g_mutex_new ();
}
-static void
+static void
nntp_folder_finalise (CamelNNTPFolder *nntp_folder)
{
struct _CamelNNTPFolderPrivate *p;
-
+
camel_folder_summary_save (((CamelFolder*) nntp_folder)->summary);
-
+
p = nntp_folder->priv;
g_mutex_free (p->search_lock);
g_mutex_free (p->cache_lock);
{
CamelDiscoFolderClass *camel_disco_folder_class = CAMEL_DISCO_FOLDER_CLASS (camel_nntp_folder_class);
CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_nntp_folder_class);
-
+
parent_class = CAMEL_DISCO_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_disco_folder_get_type ()));
folder_class = CAMEL_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_folder_get_type ()));
-
+
/* virtual method definition */
-
+
/* virtual method overload */
camel_disco_folder_class->sync_online = nntp_folder_sync_online;
camel_disco_folder_class->sync_resyncing = nntp_folder_sync_offline;
- camel_disco_folder_class->sync_offline = nntp_folder_sync_offline;
+ camel_disco_folder_class->sync_offline = nntp_folder_sync_offline;
camel_disco_folder_class->cache_message = nntp_folder_cache_message;
camel_disco_folder_class->append_online = nntp_folder_append_message_online;
camel_disco_folder_class->append_resyncing = nntp_folder_append_message_online;
camel_disco_folder_class->transfer_resyncing = nntp_folder_transfer_message;
camel_disco_folder_class->transfer_offline = nntp_folder_transfer_message;
camel_disco_folder_class->refresh_info_online = nntp_folder_refresh_info_online;
-
+
camel_folder_class->set_message_flags = nntp_folder_set_message_flags;
camel_folder_class->get_message = nntp_folder_get_message;
camel_folder_class->search_by_expression = nntp_folder_search_by_expression;
camel_nntp_folder_get_type (void)
{
static CamelType camel_nntp_folder_type = CAMEL_INVALID_TYPE;
-
+
if (camel_nntp_folder_type == CAMEL_INVALID_TYPE) {
camel_nntp_folder_type = camel_type_register (CAMEL_DISCO_FOLDER_TYPE, "CamelNNTPFolder",
sizeof (CamelNNTPFolder),
(CamelObjectInitFunc) nntp_folder_init,
(CamelObjectFinalizeFunc) nntp_folder_finalise);
}
-
+
return camel_nntp_folder_type;
}
CamelService *service;
CamelStoreInfo *si;
gboolean subscribed = TRUE;
-
+
service = (CamelService *) parent;
root = camel_session_get_storage_path (service->session, service, ex);
if (root == NULL)
return NULL;
-
+
/* If this doesn't work, stuff wont save, but let it continue anyway */
g_mkdir_with_parents (root, 0777);
-
+
folder = (CamelFolder *) camel_object_new (CAMEL_NNTP_FOLDER_TYPE);
nntp_folder = (CamelNNTPFolder *)folder;
-
+
camel_folder_construct (folder, parent, folder_name, folder_name);
folder->folder_flags |= CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY|CAMEL_FOLDER_HAS_SEARCH_CAPABILITY;
-
+
nntp_folder->storage_path = g_build_filename (root, folder->full_name, NULL);
g_free (root);
-
+
root = g_strdup_printf ("%s.cmeta", nntp_folder->storage_path);
camel_object_set(nntp_folder, NULL, CAMEL_OBJECT_STATE_FILE, root, NULL);
camel_object_state_read(nntp_folder);
folder->summary = (CamelFolderSummary *) camel_nntp_summary_new (folder, root);
g_free(root);
camel_folder_summary_load (folder->summary);
-
+
si = camel_store_summary_path ((CamelStoreSummary *) ((CamelNNTPStore*) parent)->summary, folder_name);
if (si) {
subscribed = (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) != 0;
camel_store_summary_info_free ((CamelStoreSummary *) ((CamelNNTPStore*) parent)->summary, si);
}
-
+
if (subscribed) {
camel_folder_refresh_info(folder, ex);
if (camel_exception_is_set(ex)) {
folder = NULL;
}
}
-
+
return folder;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-folder.h : NNTP group (folder) support. */
-/*
+/*
*
- * Author : Chris Toshok <toshok@ximian.com>
+ * Author : Chris Toshok <toshok@ximian.com>
*
* Copyright (C) 2000 Ximian .
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct _CamelNNTPFolderClass {
CamelDiscoFolderClass parent;
- /* Virtual methods */
-
+ /* Virtual methods */
+
} CamelNNTPFolderClass;
/* public methods */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-grouplist.c : getting/updating the list of newsgroups on the server. */
-/*
- * Author : Chris Toshok <toshok@ximian.com>
+/*
+ * Author : Chris Toshok <toshok@ximian.com>
*
* Copyright (C) 2000 Ximian .
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
entry->low = atoi (split_line[2]);
g_strfreev (split_line);
-
+
list->group_list = g_list_prepend (list->group_list, entry);
}
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-grouplist.h : getting/updating the list of newsgroups on the server. */
-/*
- * Author : Chris Toshok <toshok@ximian.com>
+/*
+ * Author : Chris Toshok <toshok@ximian.com>
*
* Copyright (C) 2000 Ximian .
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
for (i = 0; i < group->ranges->len; i ++) {
guint range_low = g_array_index (group->ranges, ArticleRange, i).low;
guint range_high = g_array_index (group->ranges, ArticleRange, i).high;
-
+
/* if it's already part of a range, return immediately. */
if (low >= range_low &&
low <= range_high &&
tmp_range.high = high;
group->ranges = g_array_append_val (group->ranges, tmp_range);
newsrc->dirty = TRUE;
- }
+ }
}
int
if (group) {
for (i = 0; i < group->ranges->len; i++) {
- if (num >= g_array_index (group->ranges, ArticleRange, i).low &&
+ if (num >= g_array_index (group->ranges, ArticleRange, i).low &&
num <= g_array_index (group->ranges, ArticleRange, i).high) {
ret = TRUE;
break;
return FALSE;
}
-gboolean
+gboolean
camel_nntp_newsrc_group_is_subscribed (CamelNNTPNewsrc *newsrc, const char *group_name)
{
NewsrcGroup *group;
fprintf (fp, "\n");
}
-void
+void
camel_nntp_newsrc_write_to_file(CamelNNTPNewsrc *newsrc, FILE *fp)
{
struct newsrc_fp newsrc_fp;
return NULL;
(*p) ++;
-
+
/* if we just incremented to the end of the buffer, return NULL */
if (**p == '\0')
return NULL;
newsrc->filename = filename;
newsrc->groups = g_hash_table_new (g_str_hash, g_str_equal);
newsrc->lock = g_mutex_new();
-
+
if ((fd = g_open(filename, O_RDONLY, 0)) == -1) {
g_warning ("~/.newsrc-%s not present.\n", server);
return newsrc;
*
* Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-provider.c: nntp provider registration code */
-/*
+/*
* Authors :
* Chris Toshok <toshok@ximian.com>
*
* Copyright (C) 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
news_provider.url_equal = nntp_url_equal;
news_provider.authtypes = g_list_append (NULL, &camel_nntp_password_authtype);
news_provider.translation_domain = GETTEXT_PACKAGE;
-
+
camel_provider_register(&news_provider);
}
add_hash (&hash, u->user);
add_hash (&hash, u->host);
hash ^= u->port;
-
+
return hash;
}
else
return FALSE;
}
-
+
if (s2 == NULL)
return FALSE;
nntp_url_equal (gconstpointer a, gconstpointer b)
{
const CamelURL *u1 = a, *u2 = b;
-
+
return check_equal(u1->protocol, u2->protocol)
&& check_equal (u1->user, u2->user)
&& check_equal (u1->host, u2->host)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-resp-codes.h : #defines for all the response codes we care about */
-/*
+/*
*
* Copyright (C) 2000 Ximian, Inc. <toshok@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
camel_nntp_store_summary_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
camel_nntp_store_summary_parent = (CamelStoreSummaryClass *)camel_store_summary_get_type();
type = camel_type_register((CamelType)camel_nntp_store_summary_parent, "CamelNNTPStoreSummary",
(CamelObjectInitFunc) camel_nntp_store_summary_init,
(CamelObjectFinalizeFunc) camel_nntp_store_summary_finalise);
}
-
+
return type;
}
{
int count, i;
CamelNNTPStoreInfo *info;
-
+
count = camel_store_summary_count ((CamelStoreSummary *) s);
for (i = 0; i < count; i++) {
info = (CamelNNTPStoreInfo *)camel_store_summary_index ((CamelStoreSummary *) s, i);
camel_store_summary_info_free ((CamelStoreSummary *) s, (CamelStoreInfo *)info);
}
}
-
+
return NULL;
}
*p = 0;
} else
path = (char *) full_name;
-
+
return camel_utf7_utf8 (path);
}
int state=0;
char *subpath, *last = NULL;
CamelStoreInfo *si;
-
+
/* check to see if we have a subpath of path already defined */
subpath = g_alloca (strlen (path) + 1);
strcpy (subpath, path);
*last = 0;
}
} while (si == NULL && last);
-
+
/* path is already present, use the raw version we have */
if (si && strlen (subpath) == strlen (path)) {
f = g_strdup (camel_nntp_store_info_full_name (s, si));
camel_store_summary_info_free ((CamelStoreSummary *) s, si);
return f;
}
-
+
f = full = g_alloca (strlen (path)*2+1);
if (si)
p = path + strlen (subpath);
else
p = path;
-
+
while ((c = camel_utf8_getc ((const unsigned char **) &p))) {
switch (state) {
case 0:
}
}
camel_utf8_putc ((unsigned char **) &f, c);
-
+
/* merge old path part if required */
f = camel_utf8_utf7 (full);
if (si) {
camel_store_summary_info_free ((CamelStoreSummary *) s, si);
f = full;
}
-
+
return f;
}
char *pathu8;
int len;
char *full_name;
-
+
d(printf("adding full name '%s' '%c'\n", full, dir_sep));
-
+
len = strlen (full);
full_name = g_alloca (len+1);
strcpy(full_name, full);
if (full_name[len-1] == dir_sep)
full_name[len-1] = 0;
-
+
info = camel_nntp_store_summary_full_name (s, full_name);
if (info) {
camel_store_summary_info_free ((CamelStoreSummary *) s, (CamelStoreInfo *) info);
d(printf(" already there\n"));
return info;
}
-
+
pathu8 = camel_nntp_store_summary_full_to_path (s, full_name, dir_sep);
-
+
info = (CamelNNTPStoreInfo *) camel_store_summary_add_from_path ((CamelStoreSummary *) s, pathu8);
if (info) {
d(printf(" '%s' -> '%s'\n", pathu8, full_name));
camel_store_info_set_string((CamelStoreSummary *)s, (CamelStoreInfo *)info, CAMEL_NNTP_STORE_INFO_FULL_NAME, full_name);
} else
d(printf(" failed\n"));
-
+
return info;
}
{
CamelNNTPStoreSummary *is = (CamelNNTPStoreSummary *) s;
gint32 version, nil;
-
+
if (camel_nntp_store_summary_parent->summary_header_load ((CamelStoreSummary *) s, in) == -1
|| camel_file_util_decode_fixed_int32 (in, &version) == -1)
return -1;
-
+
is->version = version;
-
+
if (version < CAMEL_NNTP_STORE_SUMMARY_VERSION_0) {
g_warning("Store summary header version too low");
return -1;
}
-
+
if (fread (is->last_newslist, 1, NNTP_DATE_SIZE, in) < NNTP_DATE_SIZE)
return -1;
-
+
camel_file_util_decode_fixed_int32 (in, &nil);
return 0;
summary_header_save (CamelStoreSummary *s, FILE *out)
{
CamelNNTPStoreSummary *is = (CamelNNTPStoreSummary *) s;
-
+
/* always write as latest version */
if (camel_nntp_store_summary_parent->summary_header_save ((CamelStoreSummary *) s, out) == -1
|| camel_file_util_encode_fixed_int32 (out, CAMEL_NNTP_STORE_SUMMARY_VERSION) == -1
|| fwrite (is->last_newslist, 1, NNTP_DATE_SIZE, out) < NNTP_DATE_SIZE
|| camel_file_util_encode_fixed_int32 (out, 0) == -1)
return -1;
-
+
return 0;
}
store_info_load (CamelStoreSummary *s, FILE *in)
{
CamelNNTPStoreInfo *ni;
-
+
ni = (CamelNNTPStoreInfo *) camel_nntp_store_summary_parent->store_info_load (s, in);
if (ni) {
if (camel_file_util_decode_string (in, &ni->full_name) == -1) {
}
/* set the URL */
}
-
+
return (CamelStoreInfo *) ni;
}
store_info_save (CamelStoreSummary *s, FILE *out, CamelStoreInfo *mi)
{
CamelNNTPStoreInfo *isi = (CamelNNTPStoreInfo *)mi;
-
+
if (camel_nntp_store_summary_parent->store_info_save (s, out, mi) == -1
|| camel_file_util_encode_string (out, isi->full_name) == -1
|| camel_file_util_encode_uint32(out, isi->first) == -1
|| camel_file_util_encode_uint32(out, isi->last) == -1)
return -1;
-
+
return 0;
}
store_info_free (CamelStoreSummary *s, CamelStoreInfo *mi)
{
CamelNNTPStoreInfo *nsi = (CamelNNTPStoreInfo *) mi;
-
+
g_free (nsi->full_name);
camel_nntp_store_summary_parent->store_info_free (s, mi);
}
store_info_string(CamelStoreSummary *s, const CamelStoreInfo *mi, int type)
{
CamelNNTPStoreInfo *nsi = (CamelNNTPStoreInfo *)mi;
-
+
/* FIXME: Locks? */
-
+
g_assert (mi != NULL);
-
+
switch (type) {
case CAMEL_NNTP_STORE_INFO_FULL_NAME:
return nsi->full_name;
store_info_set_string(CamelStoreSummary *s, CamelStoreInfo *mi, int type, const char *str)
{
CamelNNTPStoreInfo *nsi = (CamelNNTPStoreInfo *)mi;
-
+
g_assert(mi != NULL);
-
+
switch (type) {
case CAMEL_NNTP_STORE_INFO_FULL_NAME:
d(printf("Set full name %s -> %s\n", nsi->full_name, str));
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
*
* Copyright (C) 2001-2003 Ximian, Inc. <www.ximain.com>
*
* Authors: Christopher Toshok <toshok@ximian.com>
* Michael Zucchi <notzed@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
unsigned char *buf;
unsigned int len;
char *path;
-
+
CAMEL_SERVICE_REC_LOCK(store, connect_lock);
if (ssl_mode != MODE_CLEAR) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect to %s: %s"),
service->url->host, _("SSL unavailable"));
-
+
goto fail;
#endif /* HAVE_SSL */
} else {
tcp_stream = camel_tcp_stream_raw_new ();
}
-
+
if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai) == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
_("Could not connect to %s: %s"),
service->url->host,
g_strerror (errno));
-
+
camel_object_unref (tcp_stream);
-
+
goto fail;
}
-
+
store->stream = (CamelNNTPStream *) camel_nntp_stream_new (tcp_stream);
camel_object_unref (tcp_stream);
-
+
/* Read the greeting, if any. */
if (camel_nntp_stream_line (store->stream, &buf, &len) == -1) {
if (errno == EINTR)
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not read greeting from %s: %s"),
service->url->host, g_strerror (errno));
-
+
camel_object_unref (store->stream);
store->stream = NULL;
-
+
goto fail;
}
-
+
len = strtoul (buf, (char **) &buf, 10);
if (len != 200 && len != 201) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("NNTP server %s returned error code %d: %s"),
service->url->host, len, buf);
-
+
camel_object_unref (store->stream);
store->stream = NULL;
-
+
goto fail;
}
&& service->url->user[0]
&& camel_nntp_try_authenticate(store, ex) != NNTP_AUTH_ACCEPTED)
goto fail;
-
+
/* set 'reader' mode & ignore return code, also ping the server, inn goes offline very quickly otherwise */
if (camel_nntp_raw_command_auth (store, ex, (char **) &buf, "mode reader") == -1
|| camel_nntp_raw_command_auth (store, ex, (char **) &buf, "date") == -1)
if (xover_setup(store, ex) == -1)
goto fail;
-
+
path = g_build_filename (store->storage_path, ".ev-journal", NULL);
disco_store->diary = camel_disco_diary_new (disco_store, path, ex);
- g_free (path);
-
+ g_free (path);
+
retval = TRUE;
g_free(store->current_folder);
store->current_folder = NULL;
-
+
fail:
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
return retval;
int mode, ret, i;
char *serv;
const char *port;
-
+
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
serv = "nntp";
port = NNTP_PORT;
}
-
+
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
port = NULL;
}
-
+
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
}
if (ai == NULL)
return FALSE;
-
+
ret = connect_to_server (service, ai, mode, ex);
-
+
camel_freeaddrinfo (ai);
-
+
return ret;
}
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(service);
CamelDiscoStore *disco_store = (CamelDiscoStore *) nntp_store;
char *path;
-
+
if (nntp_store->storage_path == NULL)
return FALSE;
-
+
/* setup store-wide cache */
if (nntp_store->cache == NULL) {
nntp_store->cache = camel_data_cache_new (nntp_store->storage_path, 0, ex);
if (nntp_store->cache == NULL)
return FALSE;
-
+
/* Default cache expiry - 2 weeks old, or not visited in 5 days */
camel_data_cache_set_expire_age (nntp_store->cache, 60*60*24*14);
camel_data_cache_set_expire_access (nntp_store->cache, 60*60*24*5);
- }
-
+ }
+
path = g_build_filename (nntp_store->storage_path, ".ev-journal", NULL);
disco_store->diary = camel_disco_diary_new (disco_store, path, ex);
g_free (path);
-
+
if (!disco_store->diary)
return FALSE;
-
+
return TRUE;
}
{
CamelNNTPStore *store = CAMEL_NNTP_STORE (service);
char *line;
-
+
CAMEL_SERVICE_REC_LOCK(store, connect_lock);
-
+
if (clean) {
camel_nntp_raw_command (store, ex, &line, "quit");
camel_exception_clear(ex);
}
-
+
if (!service_class->disconnect (service, clean, ex)) {
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
return FALSE;
}
-
+
camel_object_unref (store->stream);
store->stream = NULL;
g_free(store->current_folder);
store->current_folder = NULL;
CAMEL_SERVICE_REC_UNLOCK(store, connect_lock);
-
+
return TRUE;
}
nntp_disconnect_offline (CamelService *service, gboolean clean, CamelException *ex)
{
CamelDiscoStore *disco = CAMEL_DISCO_STORE(service);
-
+
if (!service_class->disconnect (service, clean, ex))
return FALSE;
-
+
if (disco->diary) {
camel_object_unref (disco->diary);
disco->diary = NULL;
}
-
+
return TRUE;
}
return g_strdup_printf ("%s", service->url->host);
else
return g_strdup_printf (_("USENET News via %s"), service->url->host);
-
+
}
extern CamelServiceAuthType camel_nntp_password_authtype;
{
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
CamelFolder *folder;
-
+
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
-
+
folder = camel_nntp_folder_new(store, folder_name, ex);
-
+
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
-
+
return folder;
}
{
char *resptr, *tmp;
const char *ptr2;
-
+
resptr = tmp = g_malloc0 (strlen (name) + 1);
-
+
while ((ptr2 = strchr (name, '.'))) {
if (ptr2 == name) {
name++;
continue;
}
-
+
*resptr++ = *name;
*resptr++ = '.';
name = ptr2 + 1;
}
-
+
strcpy (resptr, name);
return tmp;
}
CamelFolderInfo *fi = g_malloc0(sizeof(*fi));
CamelURL *url;
char *path;
-
+
fi->full_name = g_strdup (si->path);
-
+
if (short_notation)
fi->name = nntp_newsgroup_name_short (si->path);
else
fi->name = g_strdup (si->path);
-
+
fi->unread = si->unread;
fi->total = si->total;
fi->flags = si->flags;
url = camel_url_new_with_base (base_url, path);
fi->uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
camel_url_free (url);
-
+
return fi;
}
char *path;
fi->full_name = g_strdup (name);
-
+
if (short_notation)
fi->name = nntp_newsgroup_name_short (name);
else
fi->name = g_strdup (name);
-
+
fi->unread = -1;
-
+
path = alloca(strlen(fi->full_name)+2);
sprintf(path, "/%s", fi->full_name);
url = camel_url_new_with_base (base_url, path);
fi->uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
camel_url_free (url);
-
+
return fi;
}
int i;
CamelStoreInfo *si;
CamelFolderInfo *first = NULL, *last = NULL, *fi = NULL;
-
+
/* since we do not do a tree, any request that is not for root is sure to give no results */
if (top != NULL && top[0] != 0)
return NULL;
-
+
for (i=0;(si = camel_store_summary_index ((CamelStoreSummary *) store->summary, i));i++) {
if (si == NULL)
continue;
}
camel_store_summary_info_free ((CamelStoreSummary *) store->summary, si);
}
-
+
return first;
}
char *tmpname;
char *top = g_strconcat(orig_top?orig_top:"", ".", NULL);
int toplen = strlen(top);
-
+
for (i = 0; (si = camel_store_summary_index ((CamelStoreSummary *) store->summary, i)); i++) {
if ((subscribed_or_flag || (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED))
&& (root_or_flag || strncmp (si->path, top, toplen) == 0)) {
the item we added last, we need to add a portion of this item to
the list as a placeholder */
if (!last ||
- strncmp(si->path, last->full_name, strlen(last->full_name)) != 0 ||
+ strncmp(si->path, last->full_name, strlen(last->full_name)) != 0 ||
si->path[strlen(last->full_name)] != '.') {
tmpname = g_strdup(si->path);
*(strchr(tmpname + toplen, '.')) = '\0';
}
camel_store_summary_info_free((CamelStoreSummary *)store->summary, si);
}
-
+
g_free(top);
return first;
}
char *ptr;
nntp_store->summary->last_newslist[0] = 0;
-
+
if (ret == 111) {
ptr = line + 3;
while (*ptr == ' ' || *ptr == '\t')
ptr++;
-
+
if (strlen (ptr) == NNTP_DATE_SIZE) {
memcpy (nntp_store->summary->last_newslist, ptr, NNTP_DATE_SIZE);
return TRUE;
CamelFolderInfo *fi = NULL;
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
-
+
if (top == NULL)
top = "";
-
+
if (online && (top == NULL || top[0] == 0)) {
/* we may need to update */
if (summary->last_newslist[0] != 0) {
/* Some servers don't support date (!), so fallback if they dont */
if (!nntp_get_date (nntp_store, NULL))
goto do_complete_list_nodate;
-
+
ret = camel_nntp_command (nntp_store, ex, NULL, (char **) &line, "newgroups %s", date);
if (ret == -1)
goto error;
g_hash_table_foreach(all, store_info_remove, nntp_store->summary);
g_hash_table_destroy(all);
}
-
+
/* sort the list */
g_ptr_array_sort (CAMEL_STORE_SUMMARY (nntp_store->summary)->folders, store_info_sort);
if (ret < 0)
goto error;
-
+
camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
}
-
+
fi = nntp_store_get_cached_folder_info (nntp_store, top, flags, ex);
error:
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
{
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(store);
CamelFolderInfo *first = NULL;
-
+
dd(printf("g_f_i: fast %d subscr %d recursive %d online %d top \"%s\"\n",
flags & CAMEL_STORE_FOLDER_INFO_FAST,
flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED,
flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE,
online,
top?top:""));
-
+
if (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)
first = nntp_store_get_subscribed_folder_info (nntp_store, top, flags, ex);
else
first = nntp_store_get_folder_info_all (nntp_store, top, flags, online, ex);
-
+
return first;
}
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
CamelStoreInfo *si;
int truth = FALSE;
-
+
si = camel_store_summary_path ((CamelStoreSummary *) nntp_store->summary, folder_name);
if (si) {
truth = (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) != 0;
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(store);
CamelStoreInfo *si;
CamelFolderInfo *fi;
-
+
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
-
+
si = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
if (!si) {
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
return;
}
}
-
+
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
}
CamelFolderInfo *fi;
CamelStoreInfo *fitem;
CAMEL_SERVICE_REC_LOCK(nntp_store, connect_lock);
-
+
fitem = camel_store_summary_path(CAMEL_STORE_SUMMARY(nntp_store->summary), folder_name);
-
+
if (!fitem) {
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
_("You cannot unsubscribe to this newsgroup:\n\n"
return;
}
}
-
+
CAMEL_SERVICE_REC_UNLOCK(nntp_store, connect_lock);
}
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (object);
struct _CamelNNTPStorePrivate *p = nntp_store->priv;
struct _xover_header *xover, *xn;
-
+
camel_service_disconnect ((CamelService *)object, TRUE, NULL);
-
+
if (nntp_store->summary) {
camel_store_summary_save ((CamelStoreSummary *) nntp_store->summary);
camel_object_unref (nntp_store->summary);
- }
+ }
camel_object_unref (nntp_store->mem);
nntp_store->mem = NULL;
if (nntp_store->stream)
camel_object_unref (nntp_store->stream);
-
+
if (nntp_store->base_url)
g_free (nntp_store->base_url);
if (nntp_store->storage_path)
if (nntp_store->cache)
camel_object_unref(nntp_store->cache);
-
+
g_free(p);
}
parent_class = CAMEL_DISCO_STORE_CLASS (camel_type_get_global_classfuncs (camel_disco_store_get_type ()));
service_class = CAMEL_SERVICE_CLASS (camel_type_get_global_classfuncs (camel_service_get_type ()));
-
+
/* virtual method overload */
camel_service_class->construct = nntp_construct;
camel_service_class->query_auth_types = nntp_store_query_auth_types;
camel_service_class->get_name = nntp_store_get_name;
-
+
camel_disco_store_class->can_work_offline = nntp_can_work_offline;
camel_disco_store_class->connect_online = nntp_connect_online;
camel_disco_store_class->connect_offline = nntp_connect_offline;
camel_disco_store_class->get_folder_online = nntp_get_folder;
camel_disco_store_class->get_folder_resyncing = nntp_get_folder;
camel_disco_store_class->get_folder_offline = nntp_get_folder;
-
+
camel_disco_store_class->get_folder_info_online = nntp_get_folder_info_online;
camel_disco_store_class->get_folder_info_resyncing = nntp_get_folder_info_online;
camel_disco_store_class->get_folder_info_offline = nntp_get_folder_info_offline;
-
+
camel_store_class->free_folder_info = camel_store_free_folder_info_full;
-
+
camel_store_class->folder_subscribed = nntp_store_folder_subscribed;
camel_store_class->subscribe_folder = nntp_store_subscribe_folder;
camel_store_class->unsubscribe_folder = nntp_store_unsubscribe_folder;
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(service);
CamelURL *summary_url;
char *tmp;
-
+
/* construct the parent first */
CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
if (camel_exception_is_set (ex))
return;
-
+
/* find out the storage path, base url */
nntp_store->storage_path = camel_session_get_storage_path (session, service, ex);
if (!nntp_store->storage_path)
return;
-
+
/* FIXME */
nntp_store->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD |
CAMEL_URL_HIDE_PARAMS |
CAMEL_URL_HIDE_AUTH));
-
+
tmp = g_build_filename (nntp_store->storage_path, ".ev-store-summary", NULL);
nntp_store->summary = camel_nntp_store_summary_new ();
- camel_store_summary_set_filename ((CamelStoreSummary *) nntp_store->summary, tmp);
+ camel_store_summary_set_filename ((CamelStoreSummary *) nntp_store->summary, tmp);
summary_url = camel_url_new (nntp_store->base_url, NULL);
camel_store_summary_set_uri_base ((CamelStoreSummary *) nntp_store->summary, summary_url);
g_free (tmp);
-
+
camel_url_free (summary_url);
if (camel_store_summary_load ((CamelStoreSummary *)nntp_store->summary) == 0)
;
-
+
/* get options */
if (camel_url_get_param (url, "show_short_notation"))
nntp_store->do_short_folder_notation = TRUE;
nntp_store->cache = camel_data_cache_new(nntp_store->storage_path, 0, ex);
if (nntp_store->cache == NULL)
return;
-
+
/* Default cache expiry - 2 weeks old, or not visited in 5 days */
camel_data_cache_set_expire_age(nntp_store->cache, 60*60*24*14);
camel_data_cache_set_expire_access(nntp_store->cache, 60*60*24*5);
CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE(object);
CamelStore *store = CAMEL_STORE (object);
struct _CamelNNTPStorePrivate *p;
-
+
store->flags = CAMEL_STORE_SUBSCRIPTIONS;
-
+
nntp_store->mem = (CamelStreamMem *)camel_stream_mem_new();
-
+
p = nntp_store->priv = g_malloc0(sizeof(*p));
}
camel_nntp_store_get_type (void)
{
static CamelType camel_nntp_store_type = CAMEL_INVALID_TYPE;
-
+
if (camel_nntp_store_type == CAMEL_INVALID_TYPE) {
camel_nntp_store_type =
camel_type_register (CAMEL_DISCO_STORE_TYPE,
(CamelObjectInitFunc) nntp_store_init,
(CamelObjectFinalizeFunc) nntp_store_finalize);
}
-
+
return camel_nntp_store_type;
}
CamelSession *session = camel_service_get_session (service);
int ret;
char *line = NULL;
-
+
if (!service->url->user) {
camel_exception_setv(ex, CAMEL_EXCEPTION_INVALID_PARAM,
_("Authentication requested but no username provided"));
prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);
g_free(prompt);
g_free(base);
-
+
if (!service->url->passwd)
return -1;
}
char *s;
int d;
unsigned int u, u2;
-
+
g_assert(store->stream->mode != CAMEL_NNTP_STREAM_DATA);
camel_nntp_stream_set_mode(store->stream, CAMEL_NNTP_STREAM_LINE);
-
+
ps = p = fmt;
while ((c = *p++)) {
switch (c) {
}
}
}
-
+
camel_stream_write ((CamelStream *) store->mem, ps, p-ps-1);
dd(printf("NNTP_COMMAND: '%.*s'\n", (int)store->mem->buffer->len, store->mem->buffer->data));
camel_stream_write ((CamelStream *) store->mem, "\r\n", 2);
-
+
if (camel_stream_write((CamelStream *) store->stream, store->mem->buffer->data, store->mem->buffer->len) == -1)
goto ioerror;
/* FIXME: hack */
camel_stream_reset ((CamelStream *) store->mem);
g_byte_array_set_size (store->mem->buffer, 0);
-
+
if (camel_nntp_stream_line (store->stream, (unsigned char **) line, &u) == -1)
goto ioerror;
-
+
u = strtoul (*line, NULL, 10);
-
+
/* Handle all switching to data mode here, to make callers job easier */
if (u == 215 || (u >= 220 && u <=224) || (u >= 230 && u <= 231))
camel_nntp_stream_set_mode(store->stream, CAMEL_NNTP_STREAM_DATA);
-
+
return u;
ioerror:
va_list ap;
int ret, retry;
unsigned int u;
-
+
if (((CamelDiscoStore *)store)->status == CAMEL_DISCO_STORE_OFFLINE) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
_("Not connected."));
return -1;
}
-
+
retry = 0;
do {
retry ++;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-store.h : class for an nntp store */
-/*
+/*
*
* Copyright (C) 2000 Ximian, Inc. <toshok@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
};
struct _CamelNNTPStore {
- CamelDiscoStore parent_object;
-
+ CamelDiscoStore parent_object;
+
struct _CamelNNTPStorePrivate *priv;
-
+
guint32 extensions;
-
+
unsigned int posting_allowed:1;
unsigned int do_short_folder_notation:1;
unsigned int folder_hierarchy_relative:1;
struct _CamelNNTPStoreSummary *summary;
-
+
struct _CamelNNTPStream *stream;
struct _CamelStreamMem *mem;
-
+
struct _CamelDataCache *cache;
-
+
char *current_folder, *storage_path, *base_url;
struct _xover_header *xover;
camel_nntp_summary_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register(camel_folder_summary_get_type(), "CamelNNTPSummary",
sizeof (CamelNNTPSummary),
(CamelObjectInitFunc) camel_nntp_summary_init,
(CamelObjectFinalizeFunc) camel_nntp_summary_finalise);
}
-
+
return type;
}
camel_nntp_summary_class_init(CamelNNTPSummaryClass *klass)
{
CamelFolderSummaryClass *sklass = (CamelFolderSummaryClass *) klass;
-
+
camel_nntp_summary_parent = CAMEL_FOLDER_SUMMARY_CLASS(camel_type_get_global_classfuncs(camel_folder_summary_get_type()));
sklass->message_info_new_from_header = message_info_new_from_header;
camel_folder_summary_set_filename((CamelFolderSummary *)cns, path);
camel_folder_summary_set_build_content((CamelFolderSummary *)cns, FALSE);
-
+
return cns;
}
mi->uid = cns->priv->uid;
cns->priv->uid = NULL;
}
-
+
return (CamelMessageInfo *)mi;
}
n = strtoul(line, &line, 10);
if (n != i)
g_warning("retrieved message '%u' when i expected '%u'?\n", n, i);
-
+
/* FIXME: use camel-mime-utils.c function for parsing msgid? */
if ((msgid = strchr(line, '<')) && (line = strchr(msgid+1, '>'))){
line[1] = 0;
count--;
i--;
}
-
+
camel_message_info_free(mi);
}
}
camel_message_info_free(mi);
}
}
-
+
if (si->info.unread != unread
|| si->info.total != count
|| si->first != f
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-grouplist.h : getting/updating the list of newsgroups on the server. */
-/*
- * Author : Chris Toshok <toshok@ximian.com>
+/*
+ * Author : Chris Toshok <toshok@ximian.com>
*
* Copyright (C) 2000 Ximian .
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-utils.c : utilities used by the nntp code. */
-/*
- * Author : Chris Toshok <toshok@ximian.com>
+/*
+ * Author : Chris Toshok <toshok@ximian.com>
*
* Copyright (C) 2000 Ximian .
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
date = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_DATE].index];
message_id = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_MESSAGE_ID].index];
bytes = split_line [nntp_store->overview_field [CAMEL_NNTP_OVER_BYTES].index];
-
+
/* if the overview format flagged this
field as "full", skip over the
preceding field name and colon */
char *line;
int line_length;
- line = camel_stream_buffer_read_line (
+ line = camel_stream_buffer_read_line (
CAMEL_STREAM_BUFFER ( nntp_istream ));
line_length = strlen ( line );
char *brk;
CamelMessageInfo *minfo;
int ret;
-
+
minfo = camel_folder_summary_index(summary, index);
if(minfo == NULL)
return 0;
tmp = g_strdup(camel_message_info_uid(minfo));
camel_message_info_free(minfo);
-
+
if((brk = strchr(tmp, ',')) == NULL)
ret = 0;
else {
*brk = 0;
ret = atoi(tmp);
}
-
+
g_free(tmp);
-
+
return ret;
}
if(last_summary < first_message)
camel_folder_summary_clear(folder->summary);
else {
- while(uid_num(folder->summary, 0) < first_message)
+ while(uid_num(folder->summary, 0) < first_message)
camel_folder_summary_remove_index(folder->summary, 0);
-
+
if(last_summary >= last_message)
return;
-
+
first_message = last_summary;
}
}
-
+
if (status == NNTP_NO_SUCH_GROUP) {
/* XXX throw invalid group exception */
- camel_exception_setv (ex,
+ camel_exception_setv (ex,
CAMEL_EXCEPTION_FOLDER_INVALID,
"group %s not found on server",
folder->name);
#if 0
get_HEAD_headers (nntp_store, folder, first_message, last_message, ex);
#endif
- }
+ }
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-nntp-utils.h : Utilities for the NNTP provider */
-/*
+/*
*
- * Author : Chris Toshok <toshok@ximian.com>
+ * Author : Chris Toshok <toshok@ximian.com>
*
* Copyright (C) 1999 Ximian .
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
if (pe->stream)
camel_object_unref(pe->stream);
-
+
g_list_free(pe->auth);
if (pe->apop)
g_free(pe->apop);
extern CamelServiceAuthType camel_pop3_apop_authtype;
unsigned char *line, *apop, *apopend;
unsigned int len;
-
+
/* first, read the greeting */
if (camel_pop3_stream_line (pe->stream, &line, &len) == -1
|| strncmp ((char *) line, (char *) "+OK", 3) != 0)
return -1;
-
+
if ((apop = (unsigned char *) strchr ((char *) line + 3, '<'))
&& (apopend = (unsigned char *) strchr ((char *) apop, '>'))) {
apopend[1] = 0;
pe->capa = CAMEL_POP3_CAP_APOP;
pe->auth = g_list_append (pe->auth, &camel_pop3_apop_authtype);
}
-
+
pe->auth = g_list_prepend (pe->auth, &camel_pop3_password_authtype);
-
+
return 0;
}
pe->stream = (CamelPOP3Stream *)camel_pop3_stream_new(source);
pe->state = CAMEL_POP3_ENGINE_AUTH;
pe->flags = flags;
-
+
if (read_greeting (pe) == -1) {
camel_object_unref (pe);
return NULL;
}
-
+
get_capabilities (pe);
-
+
return pe;
}
camel_pop3_engine_reget_capabilities (CamelPOP3Engine *engine)
{
g_return_if_fail (CAMEL_IS_POP3_ENGINE (engine));
-
+
get_capabilities (engine);
}
get_capabilities(CamelPOP3Engine *pe)
{
CamelPOP3Command *pc;
-
+
if (!(pe->flags & CAMEL_POP3_ENGINE_DISABLE_EXTENSIONS)) {
pc = camel_pop3_engine_command_new(pe, CAMEL_POP3_COMMAND_MULTI, cmd_capa, NULL, "CAPA\r\n");
while (camel_pop3_engine_iterate(pe, pc) > 0)
;
camel_pop3_engine_command_free(pe, pc);
-
+
if (pe->state == CAMEL_POP3_ENGINE_TRANSACTION && !(pe->capa & CAMEL_POP3_CAP_UIDL)) {
/* check for UIDL support manually */
pc = camel_pop3_engine_command_new (pe, CAMEL_POP3_COMMAND_SIMPLE, NULL, NULL, "UIDL 1\r\n");
while (camel_pop3_engine_iterate (pe, pc) > 0)
;
-
+
if (pc->state == CAMEL_POP3_COMMAND_OK)
pe->capa |= CAMEL_POP3_CAP_UIDL;
-
+
camel_pop3_engine_command_free (pe, pc);
}
}
/* Set next command */
pe->current = (CamelPOP3Command *)e_dlist_remhead(&pe->active);
-
+
/* check the queue for sending any we can now send also */
pw = (CamelPOP3Command *)pe->queue.head;
pn = pw->next;
pc->func = func;
pc->func_data = data;
pc->flags = flags;
-
+
va_start(ap, fmt);
pc->data = g_strdup_vprintf(fmt, ap);
pc->state = CAMEL_POP3_COMMAND_IDLE;
struct _CamelPOP3Engine {
CamelObject parent;
-
+
guint32 flags;
-
+
camel_pop3_engine_t state;
GList *auth; /* authtypes supported */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-pop3-folder.c : class for a pop3 folder */
-/*
+/*
* Authors:
* Dan Winship <danw@ximian.com>
* Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2002 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
camel_pop3_folder_class_init (CamelPOP3FolderClass *camel_pop3_folder_class)
{
CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS(camel_pop3_folder_class);
-
+
parent_class = CAMEL_FOLDER_CLASS(camel_folder_get_type());
-
+
/* virtual method overload */
camel_folder_class->refresh_info = pop3_refresh_info;
camel_folder_class->sync = pop3_sync;
-
+
camel_folder_class->get_message_count = pop3_get_message_count;
camel_folder_class->get_uids = pop3_get_uids;
camel_folder_class->free_uids = camel_folder_free_shallow;
-
+
camel_folder_class->get_message = pop3_get_message;
camel_folder_class->set_message_flags = pop3_set_message_flags;
}
camel_pop3_folder_get_type (void)
{
static CamelType camel_pop3_folder_type = CAMEL_INVALID_TYPE;
-
+
if (!camel_pop3_folder_type) {
camel_pop3_folder_type = camel_type_register (CAMEL_FOLDER_TYPE, "CamelPOP3Folder",
sizeof (CamelPOP3Folder),
NULL,
(CamelObjectFinalizeFunc) pop3_finalize);
}
-
+
return camel_pop3_folder_type;
}
;
camel_pop3_engine_command_free(pop3_store->engine, fi[0]->cmd);
}
-
+
g_free(fi[0]->uid);
g_free(fi[0]);
}
-
+
g_ptr_array_free(pop3_folder->uids, TRUE);
g_hash_table_destroy(pop3_folder->uids_uid);
}
CamelFolder *folder;
d(printf("opening pop3 INBOX folder\n"));
-
+
folder = CAMEL_FOLDER (camel_object_new (CAMEL_POP3_FOLDER_TYPE));
camel_folder_construct (folder, parent, "inbox", "inbox");
-
+
/* mt-ok, since we dont have the folder-lock for new() */
camel_folder_refresh_info (folder, ex);/* mt-ok */
if (camel_exception_is_set (ex)) {
camel_object_unref (CAMEL_OBJECT (folder));
folder = NULL;
}
-
+
return folder;
}
unsigned int id;
CamelPOP3FolderInfo *fi;
CamelPOP3Folder *folder = data;
-
+
do {
ret = camel_pop3_stream_line(stream, &line, &len);
if (ret>=0) {
} while (ret>0);
}
-static void
+static void
pop3_refresh_info (CamelFolder *folder, CamelException *ex)
{
CamelPOP3Store *pop3_store = CAMEL_POP3_STORE (folder->parent_store);
}
/* TODO: check every id has a uid & commands returned OK too? */
-
+
camel_pop3_engine_command_free(pop3_store->engine, pcl);
-
+
if (pop3_store->engine->capa & CAMEL_POP3_CAP_UIDL) {
camel_pop3_engine_command_free(pop3_store->engine, pcu);
} else {
/* dont need this anymore */
g_hash_table_destroy(pop3_folder->uids_id);
-
+
camel_operation_end (NULL);
return;
}
pop3_store = CAMEL_POP3_STORE (folder->parent_store);
if(pop3_store->delete_after && !expunge)
- {
+ {
d(printf("%s(%d): pop3_store->delete_after = [%d], expunge=[%d]\n",
__FILE__, __LINE__, pop3_store->delete_after, expunge));
camel_operation_start(NULL, _("Expunging old messages"));
- camel_pop3_delete_old(folder, pop3_store->delete_after,ex);
- }
+ camel_pop3_delete_old(folder, pop3_store->delete_after,ex);
+ }
if (!expunge) {
return;
- }
-
+ }
+
camel_operation_start(NULL, _("Expunging deleted messages"));
-
+
for (i = 0; i < pop3_folder->uids->len; i++) {
fi = pop3_folder->uids->pdata[i];
/* busy already? wait for that to finish first */
CamelMessageInfo *minfo;
pop3_folder = CAMEL_POP3_FOLDER (folder);
- pop3_store = CAMEL_POP3_STORE (CAMEL_FOLDER(pop3_folder)->parent_store);
+ pop3_store = CAMEL_POP3_STORE (CAMEL_FOLDER(pop3_folder)->parent_store);
temp = time(&temp);
d(printf("%s(%d): pop3_folder->uids->len=[%d]\n", __FILE__, __LINE__, pop3_folder->uids->len));
int day_lag = time_diff/(60*60*24);
d(printf("%s(%d): message_time= [%ld]\n", __FILE__, __LINE__, message_time));
- d(printf("%s(%d): day_lag=[%d] \t days_to_delete=[%d]\n",
+ d(printf("%s(%d): day_lag=[%d] \t days_to_delete=[%d]\n",
__FILE__, __LINE__, day_lag, days_to_delete));
if( day_lag > days_to_delete)
while (camel_pop3_engine_iterate(pop3_store->engine, fi->cmd) > 0) {
; /* do nothing - iterating until end */
}
-
+
camel_pop3_engine_command_free(pop3_store->engine, fi->cmd);
fi->cmd = NULL;
}
d(printf("%s(%d): Deleting old messages\n", __FILE__, __LINE__));
- fi->cmd = camel_pop3_engine_command_new(pop3_store->engine,
+ fi->cmd = camel_pop3_engine_command_new(pop3_store->engine,
0,
NULL,
NULL,
camel_pop3_store_expunge (pop3_store, ex);
return 0;
-
+
}
static void
} else {
fi->err = 0;
}
-
+
camel_object_unref((CamelObject *)fi->stream);
fi->stream = NULL;
}
goto fail;
}
}
-
+
/* check to see if we have safely written flag set */
if (pop3_store->cache == NULL
|| (stream = camel_data_cache_get(pop3_store->cache, "cache", fi->uid, NULL)) == NULL
last = MIN(i+10, pop3_folder->uids->len);
for (;i<last;i++) {
CamelPOP3FolderInfo *pfi = pop3_folder->uids->pdata[i];
-
+
if (pfi->uid && pfi->cmd == NULL) {
pfi->stream = camel_data_cache_add(pop3_store->cache, "cache", pfi->uid, NULL);
if (pfi->stream) {
pop3_get_message_count (CamelFolder *folder)
{
CamelPOP3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder);
-
+
return pop3_folder->uids->len;
}
if (fi[0]->uid)
g_ptr_array_add(uids, fi[0]->uid);
}
-
+
return uids;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-pop3-folder.h : Class for a POP3 folder */
-/*
+/*
* Authors:
* Dan Winship <danw@ximian.com>
* Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2002 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct {
CamelFolderClass parent_class;
- /* Virtual methods */
-
+ /* Virtual methods */
+
} CamelPOP3FolderClass;
/* public methods */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-pop3-provider.c: pop3 provider registration code */
-/*
+/*
* Authors :
* Dan Winship <danw@ximian.com>
* Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
static CamelProvider pop3_provider = {
"pop",
-
+
N_("POP"),
-
+
N_("For connecting to and downloading mail from POP servers."),
-
+
"mail",
-
+
CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE |
CAMEL_PROVIDER_SUPPORTS_SSL,
-
+
CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH,
-
+
pop3_conf_entries,
-
+
/* ... */
};
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-pop3-store.c : class for a pop3 store */
-/*
+/*
* Authors:
* Dan Winship <danw@ximian.com>
* Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2000-2002 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
static gboolean pop3_disconnect (CamelService *service, gboolean clean, CamelException *ex);
static GList *query_auth_types (CamelService *service, CamelException *ex);
-static CamelFolder *get_folder (CamelStore *store, const char *folder_name,
+static CamelFolder *get_folder (CamelStore *store, const char *folder_name,
guint32 flags, CamelException *ex);
static CamelFolder *get_trash (CamelStore *store, CamelException *ex);
CAMEL_STORE_CLASS (camel_pop3_store_class);
parent_class = CAMEL_STORE_CLASS (camel_type_get_global_classfuncs (camel_store_get_type ()));
-
+
/* virtual method overload */
camel_service_class->query_auth_types = query_auth_types;
camel_service_class->connect = pop3_connect;
int clean_quit = TRUE;
int ret;
const gchar *delete_days;
-
+
if (ssl_mode != MODE_CLEAR) {
#ifdef HAVE_SSL
if (ssl_mode == MODE_TLS) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect to %s: %s"),
service->url->host, _("SSL unavailable"));
-
+
return FALSE;
#endif /* HAVE_SSL */
} else {
tcp_stream = camel_tcp_stream_raw_new ();
}
-
+
if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
_("Could not connect to %s: %s"),
service->url->host,
g_strerror (errno));
-
+
camel_object_unref (tcp_stream);
-
+
return FALSE;
}
-
+
/* parent class connect initialization */
if (CAMEL_SERVICE_CLASS (parent_class)->connect (service, ex) == FALSE) {
camel_object_unref (tcp_stream);
return FALSE;
}
-
+
if (camel_url_get_param (service->url, "disable_extensions"))
flags |= CAMEL_POP3_ENGINE_DISABLE_EXTENSIONS;
-
- if ((delete_days = (gchar *) camel_url_get_param(service->url,"delete_after")))
+
+ if ((delete_days = (gchar *) camel_url_get_param(service->url,"delete_after")))
store->delete_after = atoi(delete_days);
-
+
if (!(store->engine = camel_pop3_engine_new (tcp_stream, flags))) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to read a valid greeting from POP server %s"),
camel_object_unref (tcp_stream);
return FALSE;
}
-
+
if (ssl_mode != MODE_TLS) {
camel_object_unref (tcp_stream);
return TRUE;
}
-
+
#ifdef HAVE_SSL
if (!(store->engine->capa & CAMEL_POP3_CAP_STLS)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
service->url->host, _("STLS not supported by server"));
goto stls_exception;
}
-
+
/* as soon as we send a STLS command, all hope is lost of a clean QUIT if problems arise */
clean_quit = FALSE;
-
+
pc = camel_pop3_engine_command_new (store->engine, 0, NULL, NULL, "STLS\r\n");
while (camel_pop3_engine_iterate (store->engine, NULL) > 0)
;
-
+
ret = pc->state == CAMEL_POP3_COMMAND_OK;
camel_pop3_engine_command_free (store->engine, pc);
-
+
if (ret == FALSE) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to POP server %s in secure mode: %s"),
service->url->host, store->engine->line);
goto stls_exception;
}
-
+
/* Okay, now toggle SSL/TLS mode */
ret = camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream));
-
+
if (ret == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to POP server %s in secure mode: %s"),
service->url->host, _("TLS is not available in this build"));
goto stls_exception;
#endif /* HAVE_SSL */
-
+
camel_object_unref (tcp_stream);
-
+
/* rfc2595, section 4 states that after a successful STLS
command, the client MUST discard prior CAPA responses */
camel_pop3_engine_reget_capabilities (store->engine);
-
+
return TRUE;
-
+
stls_exception:
if (clean_quit) {
/* try to disconnect cleanly */
;
camel_pop3_engine_command_free (store->engine, pc);
}
-
+
camel_object_unref (CAMEL_OBJECT (store->engine));
camel_object_unref (CAMEL_OBJECT (tcp_stream));
store->engine = NULL;
-
+
return FALSE;
}
serv = "pop3";
port = POP3S_PORT;
}
-
+
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
port = NULL;
}
-
+
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
camel_exception_clear (ex);
ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
}
-
+
if (ai == NULL)
return FALSE;
-
+
ret = connect_to_server (service, ai, mode, ex);
-
+
camel_freeaddrinfo (ai);
-
+
return ret;
}
}
camel_object_unref((CamelObject *)sasl);
return 0;
-
+
ioerror:
if (errno == EINTR) {
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
CamelPOP3Store *store = (CamelPOP3Store *)service;
CamelPOP3Command *pcu = NULL, *pcp = NULL;
int status;
-
+
/* override, testing only */
/*printf("Forcing authmech to 'login'\n");
service->url->authmech = g_strdup("LOGIN");*/
-
+
if (!service->url->passwd) {
char *prompt;
guint32 flags = CAMEL_SESSION_PASSWORD_SECRET;
-
+
if (reprompt)
flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
-
+
prompt = g_strdup_printf (_("%sPlease enter the POP password for %s on host %s"),
errmsg ? errmsg : "",
service->url->user,
}
d++;
}
-
+
secret = g_alloca(strlen(store->engine->apop)+strlen(service->url->passwd)+1);
sprintf(secret, "%s%s", store->engine->apop, service->url->passwd);
md5_get_digest(secret, strlen (secret), md5sum);
for (s = md5sum, d = md5asc; d < md5asc + 32; s++, d += 2)
sprintf (d, "%.2x", *s);
-
+
pcp = camel_pop3_engine_command_new(store->engine, 0, NULL, NULL, "APOP %s %s\r\n",
service->url->user, md5asc);
} else {
return try_sasl(store, service->url->authmech, ex) == -1;
l = l->next;
}
-
+
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
_("Unable to connect to POP server %s: "
"No support for requested authentication mechanism."),
CAMEL_SERVICE (store)->url->host);
return FALSE;
}
-
+
while ((status = camel_pop3_engine_iterate(store->engine, pcp)) > 0)
;
-
+
if (status == -1) {
if (errno == EINTR) {
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
"Error sending password: %s"),
CAMEL_SERVICE (store)->url->host,
store->engine->line ? (char *)store->engine->line : _("Unknown error"));
-
+
camel_pop3_engine_command_free(store->engine, pcp);
-
+
if (pcu)
camel_pop3_engine_command_free(store->engine, pcu);
-
+
return status;
}
CamelSession *session;
char *errbuf = NULL;
int status;
-
+
session = camel_service_get_session (service);
-
+
if (store->cache == NULL) {
char *root;
}
}
}
-
+
if (!connect_to_server_wrapper (service, ex))
return FALSE;
-
+
while (1) {
status = pop3_try_authenticate (service, reprompt, errbuf, ex);
g_free (errbuf);
errbuf = NULL;
-
+
/* we only re-prompt if we failed to authenticate, any other error and we just abort */
if (status == 0 && camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE) {
errbuf = g_strdup_printf ("%s\n\n", camel_exception_get_description (ex));
} else
break;
}
-
+
g_free (errbuf);
-
+
if (status == -1 || camel_exception_is_set(ex)) {
camel_service_disconnect(service, TRUE, ex);
return FALSE;
}
-
+
/* Now that we are in the TRANSACTION state, try regetting the capabilities */
store->engine->state = CAMEL_POP3_ENGINE_TRANSACTION;
camel_pop3_engine_reget_capabilities (store->engine);
-
+
return TRUE;
}
pop3_disconnect (CamelService *service, gboolean clean, CamelException *ex)
{
CamelPOP3Store *store = CAMEL_POP3_STORE (service);
-
+
if (clean) {
CamelPOP3Command *pc;
-
+
pc = camel_pop3_engine_command_new(store->engine, 0, NULL, NULL, "QUIT\r\n");
while (camel_pop3_engine_iterate(store->engine, NULL) > 0)
;
camel_pop3_engine_command_free(store->engine, pc);
}
-
+
if (!CAMEL_SERVICE_CLASS (parent_class)->disconnect (service, clean, ex))
return FALSE;
-
+
camel_object_unref((CamelObject *)store->engine);
store->engine = NULL;
-
+
return TRUE;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-pop3-store.h : class for an pop3 store */
-/*
+/*
* Authors:
* Dan Winship <danw@ximian.com>
* Michael Zucchi <notzed@ximian.com>
*
* Copyright (C) 2000-2002 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
CamelPOP3Engine *engine; /* pop processing engine */
struct _CamelDataCache *cache;
-
+
guint delete_after;
} CamelPOP3Store;
stream_write(CamelStream *stream, const char *buffer, size_t n)
{
CamelPOP3Stream *is = (CamelPOP3Stream *)stream;
-
+
if (strncmp (buffer, "PASS ", 5) != 0)
dd(printf("POP3_STREAM_WRITE(%d):\n%.*s\n", (int)n, (int)n, buffer));
else
dd(printf("POP3_STREAM_WRITE(%d):\nPASS xxxxxxxx\n", (int)n));
-
+
return camel_stream_write(is->source, buffer, n);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-sendmail-provider.c: sendmail provider registration code */
-/*
+/*
* Authors :
* Dan Winship <danw@ximian.com>
*
* Copyright (C) 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
camel_provider_module_init(void)
{
sendmail_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = camel_sendmail_transport_get_type();
-
+
sendmail_provider.url_hash = camel_url_hash;
sendmail_provider.url_equal = camel_url_equal;
sendmail_provider.translation_domain = GETTEXT_PACKAGE;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-sendmail-transport.c: Sendmail-based transport class. */
-/*
+/*
*
* Authors: Dan Winship <danw@ximian.com>
*
* Copyright 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
camel_sendmail_transport_get_type (void)
{
static CamelType camel_sendmail_transport_type = CAMEL_INVALID_TYPE;
-
+
if (camel_sendmail_transport_type == CAMEL_INVALID_TYPE) {
camel_sendmail_transport_type =
camel_type_register (CAMEL_TRANSPORT_TYPE, "CamelSendmailTransport",
(CamelObjectInitFunc) NULL,
NULL);
}
-
+
return camel_sendmail_transport_type;
}
sigset_t mask, omask;
CamelStream *out;
pid_t pid;
-
+
if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (from), 0, NULL, &from_addr))
return FALSE;
-
+
len = camel_address_length (recipients);
argv = g_malloc ((len + 6) * sizeof (char *));
argv[0] = "sendmail";
argv[2] = "-f";
argv[3] = from_addr;
argv[4] = "--";
-
+
for (i = 0; i < len; i++) {
if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (recipients), i, NULL, &addr)) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
g_free (argv);
return FALSE;
}
-
+
argv[i + 5] = addr;
}
-
+
argv[i + 5] = NULL;
-
+
/* unlink the bcc headers */
savedbcc = NULL;
tail = (struct _camel_header_raw *) &savedbcc;
-
+
header = (struct _camel_header_raw *) &CAMEL_MIME_PART (message)->headers;
n = header->next;
while (n != NULL) {
} else {
header = n;
}
-
+
n = header->next;
}
-
+
if (pipe (fd) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not create pipe to sendmail: "
"%s: mail not sent"),
g_strerror (errno));
-
+
/* restore the bcc headers */
header->next = savedbcc;
-
+
return FALSE;
}
-
+
/* Block SIGCHLD so the calling application doesn't notice
* sendmail exiting before we do.
*/
sigemptyset (&mask);
sigaddset (&mask, SIGCHLD);
sigprocmask (SIG_BLOCK, &mask, &omask);
-
+
pid = fork ();
switch (pid) {
case -1:
close (fd[1]);
sigprocmask (SIG_SETMASK, &omask, NULL);
g_free (argv);
-
+
/* restore the bcc headers */
header->next = savedbcc;
-
+
return FALSE;
case 0:
/* Child process */
dup2 (nullfd, STDERR_FILENO);*/
close (nullfd);
close (fd[1]);
-
+
execv (SENDMAIL_PATH, (char **)argv);
_exit (255);
}
g_free (argv);
-
+
/* Parent process. Write the message out. */
close (fd[0]);
out = camel_stream_fs_new_with_fd (fd[1]);
-
+
/* workaround for lame sendmail implementations that can't handle CRLF eoln sequences */
filter = camel_stream_filter_new_with_stream (out);
crlf = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_DECODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
camel_stream_filter_add (filter, crlf);
camel_object_unref (crlf);
camel_object_unref (out);
-
+
out = (CamelStream *) filter;
if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), out) == -1
|| camel_stream_close (out) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not send message: %s"),
g_strerror (errno));
-
+
/* Wait for sendmail to exit. */
while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR)
;
-
+
sigprocmask (SIG_SETMASK, &omask, NULL);
-
+
/* restore the bcc headers */
header->next = savedbcc;
-
+
return FALSE;
}
-
+
camel_object_unref (CAMEL_OBJECT (out));
-
+
/* Wait for sendmail to exit. */
while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR)
;
-
+
sigprocmask (SIG_SETMASK, &omask, NULL);
-
+
/* restore the bcc headers */
header->next = savedbcc;
-
+
if (!WIFEXITED (wstat)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("sendmail exited with signal %s: "
}
return FALSE;
}
-
+
return TRUE;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-sendmail-transport.h: Sendmail-based transport class */
-/*
+/*
*
- * Author :
+ * Author :
* Dan Winship <danw@ximian.com>
*
* Copyright 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
smtp_provider.url_hash = camel_url_hash;
smtp_provider.url_equal = camel_url_equal;
smtp_provider.translation_domain = GETTEXT_PACKAGE;
-
+
camel_provider_register(&smtp_provider);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-smtp-transport.c : class for a smtp transport */
-/*
+/*
* Authors: Jeffrey Stedfast <fejj@ximian.com>
*
* Copyright (C) 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
CAMEL_TRANSPORT_CLASS (camel_smtp_transport_class);
CamelServiceClass *camel_service_class =
CAMEL_SERVICE_CLASS (camel_smtp_transport_class);
-
+
parent_class = CAMEL_TRANSPORT_CLASS (camel_type_get_global_classfuncs (camel_transport_get_type ()));
-
+
/* virtual method overload */
camel_service_class->construct = smtp_construct;
camel_service_class->connect = smtp_connect;
camel_service_class->disconnect = smtp_disconnect;
camel_service_class->query_auth_types = query_auth_types;
camel_service_class->get_name = get_name;
-
+
camel_transport_class->send_to = smtp_send_to;
}
camel_smtp_transport_init (gpointer object)
{
CamelSmtpTransport *smtp = CAMEL_SMTP_TRANSPORT (object);
-
+
smtp->flags = 0;
smtp->connected = FALSE;
}
camel_smtp_transport_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (CAMEL_TRANSPORT_TYPE,
"CamelSmtpTransport",
(CamelObjectInitFunc) camel_smtp_transport_init,
NULL);
}
-
+
return type;
}
return _("Start mail input; end with <CRLF>.<CRLF>");
case 554:
return _("Transaction failed");
-
+
/* AUTH error codes: */
case 432:
return _("A password transition is needed");
return _("Temporary authentication failure");
case 530:
return _("Authentication required");
-
+
default:
return _("Unknown");
}
CamelStream *tcp_stream;
char *respbuf = NULL;
int ret;
-
+
if (!CAMEL_SERVICE_CLASS (parent_class)->connect (service, ex))
return FALSE;
-
+
/* set some smtp transport defaults */
transport->flags = 0;
transport->authtypes = NULL;
-
+
if (ssl_mode != MODE_CLEAR) {
#ifdef HAVE_SSL
if (ssl_mode == MODE_TLS) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect to %s: %s"),
service->url->host, _("SSL unavailable"));
-
+
return FALSE;
#endif /* HAVE_SSL */
} else {
tcp_stream = camel_tcp_stream_raw_new ();
}
-
+
if ((ret = camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai)) == -1) {
if (errno == EINTR)
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Could not connect to %s: %s"),
service->url->host, g_strerror (errno));
-
+
camel_object_unref (tcp_stream);
-
+
return FALSE;
}
-
+
transport->connected = TRUE;
-
+
/* get the localaddr - needed later by smtp_helo */
transport->localaddr = camel_tcp_stream_get_local_address (CAMEL_TCP_STREAM (tcp_stream), &transport->localaddrlen);
-
+
transport->ostream = tcp_stream;
transport->istream = camel_stream_buffer_new (tcp_stream, CAMEL_STREAM_BUFFER_READ);
-
+
/* Read the greeting, note whether the server is ESMTP or not. */
do {
/* Check for "220" */
}
} while (*(respbuf+3) == '-'); /* if we got "220-" then loop again */
g_free (respbuf);
-
+
/* Try sending EHLO */
transport->flags |= CAMEL_SMTP_TRANSPORT_IS_ESMTP;
if (!smtp_helo (transport, ex)) {
if (!transport->connected)
return FALSE;
-
+
/* Fall back to HELO */
camel_exception_clear (ex);
transport->flags &= ~CAMEL_SMTP_TRANSPORT_IS_ESMTP;
if (!smtp_helo (transport, ex) && !transport->connected)
return FALSE;
}
-
+
/* clear any EHLO/HELO exception and assume that any SMTP errors encountered were non-fatal */
camel_exception_clear (ex);
-
+
if (ssl_mode != MODE_TLS) {
/* we're done */
return TRUE;
}
-
+
#ifdef HAVE_SSL
if (!(transport->flags & CAMEL_SMTP_TRANSPORT_STARTTLS)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to connect to SMTP server %s in secure mode: %s"),
service->url->host, _("STARTTLS not supported"));
-
+
goto exception_cleanup;
}
-
+
d(fprintf (stderr, "sending : STARTTLS\r\n"));
if (camel_stream_write (tcp_stream, "STARTTLS\r\n", 10) == -1) {
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
g_strerror (errno));
goto exception_cleanup;
}
-
+
respbuf = NULL;
-
+
do {
/* Check for "220 Ready for TLS" */
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
-
+
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
-
+
if (!respbuf || strncmp (respbuf, "220", 3)) {
smtp_set_exception (transport, FALSE, respbuf, _("STARTTLS command failed"), ex);
g_free (respbuf);
goto exception_cleanup;
}
} while (*(respbuf+3) == '-'); /* if we got "220-" then loop again */
-
+
/* Okay, now toggle SSL/TLS mode */
if (camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream)) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
service->url->host, _("SSL is not available in this build"));
goto exception_cleanup;
#endif /* HAVE_SSL */
-
+
/* We are supposed to re-EHLO after a successful STARTTLS to
re-fetch any supported extensions. */
if (!smtp_helo (transport, ex) && !transport->connected)
return FALSE;
-
+
return TRUE;
-
+
exception_cleanup:
-
+
camel_object_unref (transport->istream);
transport->istream = NULL;
camel_object_unref (transport->ostream);
transport->ostream = NULL;
-
+
transport->connected = FALSE;
-
+
return FALSE;
}
int mode, ret, i;
char *serv;
const char *port;
-
+
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
serv = "smtp";
port = SMTP_PORT;
}
-
+
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
port = NULL;
}
-
+
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
camel_exception_clear (ex);
ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
}
-
+
if (ai == NULL)
return FALSE;
-
+
ret = connect_to_server (service, ai, mode, ex);
-
+
camel_freeaddrinfo (ai);
-
+
return ret;
}
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
gboolean has_authtypes;
-
+
/* We (probably) need to check popb4smtp before we connect ... */
if (service->url->authmech && !strcmp (service->url->authmech, "POPB4SMTP")) {
int truth;
GByteArray *chal;
CamelSasl *sasl;
-
+
sasl = camel_sasl_new ("smtp", "POPB4SMTP", service);
chal = camel_sasl_challenge (sasl, NULL, ex);
truth = camel_sasl_authenticated (sasl);
if (chal)
g_byte_array_free (chal, TRUE);
camel_object_unref (sasl);
-
+
if (!truth)
return FALSE;
-
+
return connect_to_server_wrapper (service, ex);
}
-
+
if (!connect_to_server_wrapper (service, ex))
return FALSE;
-
+
/* check to see if AUTH is required, if so...then AUTH ourselves */
has_authtypes = transport->authtypes ? g_hash_table_size (transport->authtypes) > 0 : FALSE;
if (service->url->authmech && (transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP) && has_authtypes) {
CamelServiceAuthType *authtype;
gboolean authenticated = FALSE;
char *errbuf = NULL;
-
+
if (!g_hash_table_lookup (transport->authtypes, service->url->authmech)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("SMTP server %s does not support requested "
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
-
+
authtype = camel_sasl_authtype (service->url->authmech);
if (!authtype) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
-
+
if (!authtype->need_password) {
/* authentication mechanism doesn't need a password,
so if it fails there's nothing we can do */
return FALSE;
}
}
-
+
/* keep trying to login until either we succeed or the user cancels */
while (!authenticated) {
if (errbuf) {
g_free (service->url->passwd);
service->url->passwd = NULL;
}
-
+
if (!service->url->passwd) {
char *prompt;
-
+
prompt = g_strdup_printf (_("%sPlease enter the SMTP password for %s on host %s"),
errbuf ? errbuf : "", service->url->user,
service->url->host);
-
+
service->url->passwd = camel_session_get_password (session, service, NULL,
prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);
-
+
g_free (prompt);
g_free (errbuf);
errbuf = NULL;
-
+
if (!service->url->passwd) {
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
}
-
+
authenticated = smtp_auth (transport, authtype->authproto, ex);
if (!authenticated) {
errbuf = g_strdup_printf (_("Unable to authenticate "
}
}
}
-
+
return TRUE;
}
smtp_disconnect (CamelService *service, gboolean clean, CamelException *ex)
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
-
+
/*if (!service->connected)
* return TRUE;
*/
-
+
if (transport->connected && clean) {
/* send the QUIT command to the SMTP server */
smtp_quit (transport, ex);
}
-
+
if (!CAMEL_SERVICE_CLASS (parent_class)->disconnect (service, clean, ex))
return FALSE;
-
+
if (transport->authtypes) {
g_hash_table_foreach (transport->authtypes, authtypes_free, NULL);
g_hash_table_destroy (transport->authtypes);
transport->authtypes = NULL;
}
-
+
if (transport->istream) {
camel_object_unref (transport->istream);
transport->istream = NULL;
}
-
+
if (transport->ostream) {
camel_object_unref (transport->ostream);
transport->ostream = NULL;
}
-
+
g_free(transport->localaddr);
transport->localaddr = NULL;
-
+
transport->connected = FALSE;
-
+
return TRUE;
}
{
const unsigned char *start, *end;
GHashTable *table = NULL;
-
+
/* advance to the first token */
start = buffer;
while (isspace ((int) *start) || *start == '=')
start++;
-
+
if (!*start)
return NULL;
-
+
table = g_hash_table_new (g_str_hash, g_str_equal);
-
+
for ( ; *start; ) {
char *type;
-
+
/* advance to the end of the token */
end = start;
while (*end && !isspace ((int) *end))
end++;
-
+
type = g_strndup (start, end - start);
g_hash_table_insert (table, type, type);
-
+
/* advance to the next token */
start = end;
while (isspace ((int) *start))
start++;
}
-
+
return table;
}
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
CamelServiceAuthType *authtype;
GList *types, *t, *next;
-
+
if (!connect_to_server_wrapper (service, ex))
return NULL;
-
+
types = g_list_copy (service->provider->authtypes);
for (t = types; t; t = next) {
authtype = t->data;
next = t->next;
-
+
if (!g_hash_table_lookup (transport->authtypes, authtype->authproto)) {
types = g_list_remove_link (types, t);
g_list_free_1 (t);
}
}
-
+
smtp_disconnect (service, TRUE, NULL);
-
+
return types;
}
gboolean has_8bit_parts;
const char *addr;
int i, len;
-
+
if (!smtp_transport->connected) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
_("Cannot send message: service not connected."));
return FALSE;
}
-
+
if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (from), 0, NULL, &addr)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot send message: sender address not valid."));
return FALSE;
}
-
+
camel_operation_start (NULL, _("Sending message"));
-
+
/* find out if the message has 8bit mime parts */
has_8bit_parts = camel_mime_message_has_8bit_parts (message);
-
+
/* rfc1652 (8BITMIME) requires that you notify the ESMTP daemon that
you'll be sending an 8bit mime message at "MAIL FROM:" time. */
if (!smtp_mail (smtp_transport, addr, has_8bit_parts, ex)) {
camel_operation_end (NULL);
return FALSE;
}
-
+
len = camel_address_length (recipients);
if (len == 0) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
camel_operation_end (NULL);
return FALSE;
}
-
+
cia = CAMEL_INTERNET_ADDRESS (recipients);
for (i = 0; i < len; i++) {
char *enc;
-
+
if (!camel_internet_address_get (cia, i, NULL, &addr)) {
camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot send message: one or more invalid recipients"));
camel_operation_end (NULL);
return FALSE;
}
-
+
enc = camel_internet_address_encode_address(NULL, NULL, addr);
if (!smtp_rcpt (smtp_transport, enc, ex)) {
g_free(enc);
}
g_free(enc);
}
-
+
if (!smtp_data (smtp_transport, message, ex)) {
camel_operation_end (NULL);
return FALSE;
}
-
+
/* reset the service for our next transfer session */
if (!smtp_rset (smtp_transport, ex))
camel_exception_clear (ex);
-
+
camel_operation_end (NULL);
-
+
return TRUE;
}
smtp_next_token (const char *buf)
{
const unsigned char *token;
-
+
token = (const unsigned char *) buf;
while (*token && !isspace ((int) *token))
token++;
-
+
while (*token && isspace ((int) *token))
token++;
-
+
return (const char *) token;
}
unsigned char *inptr, *outptr;
const unsigned char *inend;
char *outbuf;
-
+
outptr = outbuf = g_malloc (len + 1);
-
+
inptr = (unsigned char *) in;
inend = inptr + len;
while (inptr < inend) {
} else
*outptr++ = *inptr++;
}
-
+
*outptr = '\0';
-
+
return outbuf;
}
char *buffer = NULL;
GString *string;
int error;
-
+
if (!respbuf || !(transport->flags & CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES)) {
fake_status_code:
error = respbuf ? atoi (respbuf) : 0;
g_string_free (string, TRUE);
goto fake_status_code;
}
-
+
g_string_append (string, token);
if (*(rbuf + 3) == '-') {
g_free (buffer);
g_free (buffer);
buffer = NULL;
}
-
+
rbuf = buffer;
} while (rbuf);
-
+
buffer = smtp_decode_status_code (string->str, string->len);
g_string_free (string, TRUE);
if (!buffer)
goto fake_status_code;
-
+
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
"%s: %s", message, buffer);
-
+
g_free (buffer);
}
-
+
if (!respbuf) {
/* we got disconnected */
if (disconnect)
const char *token, *numeric = NULL;
struct sockaddr *addr;
socklen_t addrlen;
-
+
/* these are flags that we set, so unset them in case we
are being called a second time (ie, after a STARTTLS) */
transport->flags &= ~(CAMEL_SMTP_TRANSPORT_8BITMIME |
CAMEL_SMTP_TRANSPORT_ENHANCEDSTATUSCODES |
CAMEL_SMTP_TRANSPORT_STARTTLS);
-
+
if (transport->authtypes) {
g_hash_table_foreach (transport->authtypes, authtypes_free, NULL);
g_hash_table_destroy (transport->authtypes);
transport->authtypes = NULL;
}
-
+
camel_operation_start_transient (NULL, _("SMTP Greeting"));
-
+
addr = transport->localaddr;
addrlen = transport->localaddrlen;
-
+
if (camel_getnameinfo (addr, addrlen, &name, NULL, NI_NUMERICHOST, NULL) != 0) {
name = g_strdup ("localhost.localdomain");
} else {
else
numeric = "";
}
-
+
token = (transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP) ? "EHLO" : "HELO";
if (numeric)
cmdbuf = g_strdup_printf("%s [%s%s]\r\n", token, numeric, name);
else
cmdbuf = g_strdup_printf("%s %s\r\n", token, name);
g_free (name);
-
+
d(fprintf (stderr, "sending : %s", cmdbuf));
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
_("HELO command failed: %s"), g_strerror (errno));
camel_operation_end (NULL);
-
+
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
-
+
return FALSE;
}
g_free (cmdbuf);
-
+
do {
/* Check for "250" */
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
-
+
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
-
+
if (!respbuf || strncmp (respbuf, "250", 3)) {
smtp_set_exception (transport, FALSE, respbuf, _("HELO command failed"), ex);
camel_operation_end (NULL);
g_free (respbuf);
-
+
return FALSE;
}
-
+
token = respbuf + 4;
-
+
if (transport->flags & CAMEL_SMTP_TRANSPORT_IS_ESMTP) {
if (!strncmp (token, "8BITMIME", 8)) {
d(fprintf (stderr, "This server supports 8bit MIME\n"));
* format. We want to let the standard way have priority over the
* broken way.
**/
-
+
if (token[4] == '=')
transport->flags |= CAMEL_SMTP_TRANSPORT_AUTH_EQUAL;
else
transport->flags &= ~CAMEL_SMTP_TRANSPORT_AUTH_EQUAL;
-
+
/* parse for supported AUTH types */
token += 5;
-
+
if (transport->authtypes) {
g_hash_table_foreach (transport->authtypes, authtypes_free, NULL);
g_hash_table_destroy (transport->authtypes);
}
-
+
transport->authtypes = esmtp_get_authtypes (token);
}
}
}
} while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */
g_free (respbuf);
-
+
camel_operation_end (NULL);
-
+
return TRUE;
}
char *cmdbuf, *respbuf = NULL, *challenge;
gboolean auth_challenge = FALSE;
CamelSasl *sasl = NULL;
-
+
camel_operation_start_transient (NULL, _("SMTP Authentication"));
-
+
sasl = camel_sasl_new ("smtp", mech, CAMEL_SERVICE (transport));
if (!sasl) {
camel_operation_end (NULL);
_("Error creating SASL authentication object."));
return FALSE;
}
-
+
challenge = camel_sasl_challenge_base64 (sasl, NULL, ex);
if (challenge) {
auth_challenge = TRUE;
} else {
cmdbuf = g_strdup_printf ("AUTH %s\r\n", mech);
}
-
+
d(fprintf (stderr, "sending : %s", cmdbuf));
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
goto lose;
}
g_free (cmdbuf);
-
+
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
-
+
while (!camel_sasl_authenticated (sasl)) {
if (!respbuf) {
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
_("AUTH command failed: %s"), g_strerror (errno));
goto lose;
}
-
+
/* the server challenge/response should follow a 334 code */
if (strncmp (respbuf, "334", 3) != 0) {
smtp_set_exception (transport, FALSE, respbuf, _("AUTH command failed"), ex);
g_free (respbuf);
goto lose;
}
-
+
if (FALSE) {
broken_smtp_server:
d(fprintf (stderr, "Your SMTP server's implementation of the %s SASL\n"
"for the first time (specifically Section 4).\n",
mech));
}
-
+
/* eat whtspc */
for (challenge = respbuf + 4; isspace (*challenge); challenge++);
-
+
challenge = camel_sasl_challenge_base64 (sasl, challenge, ex);
g_free (respbuf);
if (challenge == NULL)
goto break_and_lose;
-
+
/* send our challenge */
cmdbuf = g_strdup_printf ("%s\r\n", challenge);
g_free (challenge);
goto lose;
}
g_free (cmdbuf);
-
+
/* get the server's response */
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
}
-
+
/* check that the server says we are authenticated */
if (!respbuf || strncmp (respbuf, "235", 3)) {
if (respbuf && auth_challenge && !strncmp (respbuf, "334", 3)) {
g_free (respbuf);
goto lose;
}
-
+
g_free (respbuf);
camel_object_unref (sasl);
camel_operation_end (NULL);
-
+
return TRUE;
-
+
break_and_lose:
/* Get the server out of "waiting for continuation data" mode. */
d(fprintf (stderr, "sending : *\n"));
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
g_free (respbuf);
-
+
lose:
if (!camel_exception_is_set (ex)) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("Bad authentication response from server.\n"));
}
-
+
camel_object_unref (sasl);
camel_operation_end (NULL);
-
+
return FALSE;
}
{
/* we gotta tell the smtp server who we are. (our email addy) */
char *cmdbuf, *respbuf = NULL;
-
+
if (transport->flags & CAMEL_SMTP_TRANSPORT_8BITMIME && has_8bit_parts)
cmdbuf = g_strdup_printf ("MAIL FROM:<%s> BODY=8BITMIME\r\n", sender);
else
cmdbuf = g_strdup_printf ("MAIL FROM:<%s>\r\n", sender);
-
+
d(fprintf (stderr, "sending : %s", cmdbuf));
-
+
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
_("MAIL FROM command failed: %s: mail not sent"),
g_strerror (errno));
-
+
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
-
+
return FALSE;
}
g_free (cmdbuf);
-
+
do {
/* Check for "250 Sender OK..." */
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
-
+
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
-
+
if (!respbuf || strncmp (respbuf, "250", 3)) {
smtp_set_exception (transport, TRUE, respbuf, _("MAIL FROM command failed"), ex);
g_free (respbuf);
}
} while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */
g_free (respbuf);
-
+
return TRUE;
}
/* we gotta tell the smtp server who we are going to be sending
* our email to */
char *cmdbuf, *respbuf = NULL;
-
+
cmdbuf = g_strdup_printf ("RCPT TO:<%s>\r\n", recipient);
-
+
d(fprintf (stderr, "sending : %s", cmdbuf));
-
+
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
_("RCPT TO command failed: %s: mail not sent"),
g_strerror (errno));
-
+
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
-
+
return FALSE;
}
g_free (cmdbuf);
-
+
do {
/* Check for "250 Recipient OK..." */
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
-
+
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
-
+
if (!respbuf || strncmp (respbuf, "250", 3)) {
char *message;
-
+
message = g_strdup_printf (_("RCPT TO <%s> failed"), recipient);
smtp_set_exception (transport, TRUE, respbuf, message, ex);
g_free (message);
}
} while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */
g_free (respbuf);
-
+
return TRUE;
}
CamelStreamFilter *filtered_stream;
CamelMimeFilter *crlffilter;
int ret;
-
+
/* If the server doesn't support 8BITMIME, set our required encoding to be 7bit */
if (!(transport->flags & CAMEL_SMTP_TRANSPORT_8BITMIME))
enctype = CAMEL_BESTENC_7BIT;
-
+
/* FIXME: should we get the best charset too?? */
/* Changes the encoding of all mime parts to fit within our required
encoding type and also force any text parts with long lines (longer
than 998 octets) to wrap by QP or base64 encoding them. */
camel_mime_message_set_best_encoding (message, CAMEL_BESTENC_GET_ENCODING, enctype);
-
+
cmdbuf = g_strdup ("DATA\r\n");
-
+
d(fprintf (stderr, "sending : %s", cmdbuf));
-
+
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
_("DATA command failed: %s: mail not sent"),
g_strerror (errno));
-
+
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
-
+
return FALSE;
}
g_free (cmdbuf);
-
+
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
-
+
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
-
+
if (!respbuf || strncmp (respbuf, "354", 3)) {
/* we should have gotten instructions on how to use the DATA command:
* 354 Enter mail, end with "." on a line by itself
g_free (respbuf);
return FALSE;
}
-
+
g_free (respbuf);
respbuf = NULL;
-
+
/* setup stream filtering */
crlffilter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS);
filtered_stream = camel_stream_filter_new_with_stream (transport->ostream);
camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (crlffilter));
camel_object_unref (crlffilter);
-
+
/* unlink the bcc headers */
savedbcc = NULL;
tail = (struct _camel_header_raw *) &savedbcc;
-
+
header = (struct _camel_header_raw *) &CAMEL_MIME_PART (message)->headers;
n = header->next;
while (n != NULL) {
} else {
header = n;
}
-
+
n = header->next;
}
-
+
/* write the message */
ret = camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (filtered_stream));
-
+
/* restore the bcc headers */
header->next = savedbcc;
-
+
if (ret == -1) {
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
_("DATA command failed: %s: mail not sent"),
g_strerror (errno));
-
+
camel_object_unref (filtered_stream);
-
+
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
-
+
return FALSE;
}
-
+
camel_stream_flush (CAMEL_STREAM (filtered_stream));
camel_object_unref (filtered_stream);
-
+
/* terminate the message body */
-
+
d(fprintf (stderr, "sending : \\r\\n.\\r\\n\n"));
-
+
if (camel_stream_write (transport->ostream, "\r\n.\r\n", 5) == -1) {
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
_("DATA command failed: %s: mail not sent"),
g_strerror (errno));
-
+
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
-
+
return FALSE;
}
-
+
do {
/* Check for "250 Sender OK..." */
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
-
+
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
-
+
if (!respbuf || strncmp (respbuf, "250", 3)) {
smtp_set_exception (transport, TRUE, respbuf, _("DATA command failed"), ex);
g_free (respbuf);
}
} while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */
g_free (respbuf);
-
+
return TRUE;
}
{
/* we are going to reset the smtp server (just to be nice) */
char *cmdbuf, *respbuf = NULL;
-
+
cmdbuf = g_strdup ("RSET\r\n");
-
+
d(fprintf (stderr, "sending : %s", cmdbuf));
-
+
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
_("RSET command failed: %s"), g_strerror (errno));
-
+
camel_service_disconnect ((CamelService *) transport, FALSE, NULL);
-
+
return FALSE;
}
g_free (cmdbuf);
-
+
do {
/* Check for "250" */
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
-
+
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
-
+
if (!respbuf || strncmp (respbuf, "250", 3)) {
smtp_set_exception (transport, TRUE, respbuf, _("RSET command failed"), ex);
g_free (respbuf);
}
} while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */
g_free (respbuf);
-
+
return TRUE;
}
{
/* we are going to reset the smtp server (just to be nice) */
char *cmdbuf, *respbuf = NULL;
-
+
cmdbuf = g_strdup ("QUIT\r\n");
-
+
d(fprintf (stderr, "sending : %s", cmdbuf));
-
+
if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) {
g_free (cmdbuf);
camel_exception_setv (ex, errno == EINTR ? CAMEL_EXCEPTION_USER_CANCEL : CAMEL_EXCEPTION_SYSTEM,
_("QUIT command failed: %s"), g_strerror (errno));
-
+
return FALSE;
}
g_free (cmdbuf);
-
+
do {
/* Check for "221" */
g_free (respbuf);
respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream));
-
+
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
-
+
if (!respbuf || strncmp (respbuf, "221", 3)) {
smtp_set_exception (transport, FALSE, respbuf, _("QUIT command failed"), ex);
g_free (respbuf);
}
} while (*(respbuf+3) == '-'); /* if we got "221-" then loop again */
g_free (respbuf);
-
+
return TRUE;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-smtp-transport.h : class for an smtp transfer */
-/*
+/*
* Authors:
* Jeffrey Stedfast <fejj@stampede.org>
*
* Copyright (C) 2000 Ximian, Inc. (www.ximian.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
typedef struct {
CamelTransport parent_object;
-
+
CamelStream *istream, *ostream;
-
+
guint32 flags;
-
+
gboolean connected;
struct sockaddr *localaddr;
socklen_t localaddrlen;
-
+
GHashTable *authtypes;
} CamelSmtpTransport;
#define MAX_LOOP (10000)
#define MAX_THREADS (5)
-#define d(x)
+#define d(x)
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
camel_test_push("provider %s", local_providers[j]);
path = g_strdup_printf("%s:///tmp/camel-test/%s", local_providers[j], local_providers[j]);
-
+
for (i=0;i<MAX_THREADS;i++)
pthread_create(&threads[i], 0, worker, NULL);
-
- for (i=0;i<MAX_THREADS;i++)
+
+ for (i=0;i<MAX_THREADS;i++)
pthread_join(threads[i], NULL);
-
+
test_free(path);
camel_test_pull();
#define MAX_LOOP (10000)
#define MAX_THREADS (5)
-#define d(x)
+#define d(x)
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
char *expr;
} searches[] = {
{ { 1, 1, 0 }, "(header-matches \"subject\" \"Test1 message99 subject\")" },
-
+
{ { 100, 50, 0 }, "(header-contains \"subject\" \"subject\")" },
{ { 100, 50, 0 }, "(header-contains \"subject\" \"Subject\")" },
{ { 100/13+1, 50/13+1, 0 }, "(user-flag \"every13\")" },
{ { 1, 1, 0 }, "(= \"7tag1\" (user-tag \"every7\"))" },
{ { 100/11+1, 50/11+1, 0 }, "(= \"11tag\" (user-tag \"every11\"))" },
-
+
{ { 100/13 + 100/17 + 1, 50/13 + 50/17 + 2, 0 }, "(user-flag \"every13\" \"every17\")" },
{ { 100/13 + 100/17 + 1, 50/13 + 50/17 + 2, 0 }, "(or (user-flag \"every13\") (user-flag \"every17\"))" },
{ { 1, 0, 0 }, "(and (user-flag \"every13\") (user-flag \"every17\"))" },
-
+
{ { 0, 0, 0 }, "(and (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"Test2\"))" },
/* we get 11 here as the header-contains is a substring match */
{ { 11, 6, 0 }, "(and (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"subject\"))" },
{ { 1, 1, 0 }, "(and (header-contains \"subject\" \"Test19\") (header-contains \"subject\" \"subject\"))" },
{ { 0, 0, 0 }, "(and (header-contains \"subject\" \"Test191\") (header-contains \"subject\" \"subject\"))" },
{ { 1, 1, 0 }, "(and (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"message99\"))" },
-
+
{ { 22, 11, 0 }, "(or (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"Test2\"))" },
{ { 2, 1, 0 }, "(or (header-contains \"subject\" \"Test16\") (header-contains \"subject\" \"Test99\"))" },
{ { 1, 1, 0 }, "(or (header-contains \"subject\" \"Test123\") (header-contains \"subject\" \"Test99\"))" },
{ { 100, 50, 0 }, "(or (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"subject\"))" },
{ { 11, 6, 0 }, "(or (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"message99\"))" },
-
+
/* 72000 is 24*60*100 == half the 'sent date' of the messages */
{ { 100/2, 50/2, 0 }, "(> 72000 (get-sent-date))" },
{ { 100/2-1, 50/2, 0 }, "(< 72000 (get-sent-date))" },
{ { 1, 0, 0 }, "(= 72000 (get-sent-date))" },
{ { 0, 0, 0 }, "(= 72001 (get-sent-date))" },
-
+
{ { (100/2-1)/17+1, (50/2-1)/17+1, 0 }, "(and (user-flag \"every17\") (< 72000 (get-sent-date)))" },
{ { (100/2-1)/17+1, (50/2-1)/17, 0 }, "(and (user-flag \"every17\") (> 72000 (get-sent-date)))" },
{ { (100/2-1)/13+1, (50/2-1)/13+1, 0 }, "(and (user-flag \"every13\") (< 72000 (get-sent-date)))" },
{ { (100/2-1)/13+1, (50/2-1)/13+1, 0 }, "(and (user-flag \"every13\") (> 72000 (get-sent-date)))" },
-
+
{ { 100/2+100/2/17, 50/2+50/2/17, 0 }, "(or (user-flag \"every17\") (< 72000 (get-sent-date)))" },
{ { 100/2+100/2/17+1, 50/2+50/2/17+1, 0 }, "(or (user-flag \"every17\") (> 72000 (get-sent-date)))" },
{ { 100/2+100/2/13, 50/2+50/2/13+1, 0 }, "(or (user-flag \"every13\") (< 72000 (get-sent-date)))" },
#define MAX_MESSAGES (100)
#define MAX_THREADS (10)
-#define d(x)
+#define d(x)
#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0]))
store = camel_session_get_store(session, path, ex);
check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
test_free(path);
-
+
if (index == 0)
folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex);
else
mailboxes[i].folder = folder = camel_store_get_folder(store, mailboxes[i].name, CAMEL_STORE_FOLDER_CREATE, ex);
check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
check(folder != NULL);
-
+
/* we need an empty folder for this to work */
test_folder_counts(folder, 0, 0);
pull();
mbox = camel_stream_fs_new_with_name("/tmp/camel-test/inbox", O_WRONLY|O_CREAT|O_EXCL, 0600);
for (j=0;j<100;j++) {
char *content, *subject;
-
+
push("creating test message");
msg = test_message_create_simple();
content = g_strdup_printf("data%d content\n", j);
test_free(content);
subject = g_strdup_printf("Test%d message%d subject", j, 100-j);
camel_mime_message_set_subject(msg, subject);
-
+
camel_mime_message_set_date(msg, j*60*24, 0);
pull();
-
+
camel_stream_printf(mbox, "From \n");
check(camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, mbox) != -1);
-#if 0
+#if 0
push("appending simple message %d", j);
camel_folder_append_message(folder, msg, NULL, ex);
check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
pull();
-#endif
+#endif
test_free(subject);
-
+
check_unref(msg, 1);
}
check(camel_stream_close(mbox) != -1);
check(camel_address_length(CAMEL_ADDRESS(addr)) == camel_address_length(CAMEL_ADDRESS(addr2)));
for (j=0;j<camel_address_length(CAMEL_ADDRESS(addr));j++) {
-
+
check(camel_internet_address_get(addr, j, &r1, &a1) == TRUE);
check(camel_internet_address_get(addr2, j, &r2, &a2) == TRUE);
dump_action(int id, struct _state *s, void *d)
{
struct _stack *node;
-
+
printf("\nThread %d:\n", id);
-
+
node = s->state;
if (node) {
printf("Current action:\n");
indie = 1;
printf("\n\nReceived fatal signal %d\n", sig);
g_hash_table_foreach(info_table, (GHFunc)dump_action, 0);
-
+
if (camel_test_verbose > 2) {
printf("Attach debugger to pid %d to debug\n", getpid());
sleep(1000);
}
return info;
}
-
+
void camel_test_init(int argc, char **argv)
{
struct stat st;
char *path;
int i;
-
+
setup = 1;
-
+
/* yeah, we do need ot thread init, even though camel isn't compiled with enable threads */
g_thread_init (NULL);
-
+
path = g_strdup_printf ("/tmp/camel-test");
if (mkdir (path, 0700) == -1 && errno != EEXIST)
abort ();
-
+
if (stat (path, &st) == -1)
abort ();
-
+
if (!S_ISDIR (st.st_mode) || access (path, R_OK | W_OK | X_OK) == -1)
abort ();
-
+
camel_init (path, FALSE);
g_free (path);
-
+
camel_type_init ();
-
+
info_table = g_hash_table_new(0, 0);
-
+
signal(SIGSEGV, die);
signal(SIGABRT, die);
const unsigned char *inptr = in, *start = inptr;
const unsigned char *inend = in + inlen;
int octets;
-
+
while (inptr < inend) {
octets = 0;
while (inptr < inend && octets < 16) {
printf ("%.2X ", *inptr++);
octets++;
}
-
+
while (octets < 16) {
printf (" ");
octets++;
}
-
+
printf (" ");
-
+
while (start < inptr) {
fputc (isprint ((int) *start) ? *start : '.', stdout);
start++;
}
-
+
fputc ('\n', stdout);
}
}
content = (CamelStreamMem *)camel_stream_mem_new();
camel_data_wrapper_decode_to_stream(dw, (CamelStream *)content);
-
+
if (content->buffer->len != len) {
printf ("original text:\n");
hexdump (text, len);
-
+
printf ("new text:\n");
hexdump (content->buffer->data, content->buffer->len);
}
-
+
check_msg(content->buffer->len == len, "buffer->len = %d, len = %d", content->buffer->len, len);
check_msg(memcmp(content->buffer->data, text, content->buffer->len) == 0, "len = %d", len);
{
CamelMimeMessage *msg2;
CamelStreamMem *mem1, *mem2;
-
+
mem1 = (CamelStreamMem *) camel_stream_mem_new ();
check_msg(camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, (CamelStream *) mem1) != -1, "write_to_stream 1 failed");
camel_stream_reset ((CamelStream *) mem1);
-
+
msg2 = camel_mime_message_new ();
check_msg(camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg2, (CamelStream *) mem1) != -1, "construct_from_stream 1 failed");
camel_stream_reset ((CamelStream *) mem1);
-
+
mem2 = (CamelStreamMem *) camel_stream_mem_new ();
check_msg(camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg2, (CamelStream *) mem2) != -1, "write_to_stream 2 failed");
camel_stream_reset ((CamelStream *) mem2);
-
+
if (mem1->buffer->len != mem2->buffer->len) {
CamelDataWrapper *content;
-
+
printf ("mem1 stream:\n%.*s\n", mem1->buffer->len, mem1->buffer->data);
printf ("mem2 stream:\n%.*s\n\n", mem2->buffer->len, mem2->buffer->data);
}
check_unref(msg2, 1);
-
+
check_msg (mem1->buffer->len == mem2->buffer->len,
"mem1->buffer->len = %d, mem2->buffer->len = %d",
mem1->buffer->len, mem2->buffer->len);
-
+
check_msg (memcmp (mem1->buffer->data, mem2->buffer->data, mem1->buffer->len) == 0, "msg/stream compare");
-
+
camel_object_unref (mem1);
camel_object_unref (mem2);
-
+
return 0;
}
printf("%s part encoding: %s\n", s, camel_transfer_encoding_to_string(part->encoding));
containee = camel_medium_get_content_object (CAMEL_MEDIUM (part));
-
+
if (containee == NULL)
return;
printf ("%sContent-Type: %s\n", s, mime_type);
g_free (mime_type);
printf("%s encoding: %s\n", s, camel_transfer_encoding_to_string(((CamelDataWrapper *)containee)->encoding));
-
+
/* using the object types is more accurate than using the mime/types */
if (CAMEL_IS_MULTIPART (containee)) {
parts = camel_multipart_get_number (CAMEL_MULTIPART (containee));
for (i = 0; i < parts; i++) {
CamelMimePart *part = camel_multipart_get_part (CAMEL_MULTIPART (containee), i);
-
+
message_dump_rec(msg, part, depth+1);
}
} else if (CAMEL_IS_MIME_MESSAGE (containee)) {
camel_test_session_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (
camel_session_get_type (),
NULL,
NULL);
}
-
+
return type;
}
camel_test_session_new (const char *path)
{
CamelSession *session;
-
+
session = CAMEL_SESSION (camel_object_new (CAMEL_TEST_SESSION_TYPE));
-
+
camel_session_construct (session, path);
-
+
return session;
}
typedef struct _CamelTestSession {
CamelSession parent_object;
-
+
} CamelTestSession;
typedef struct _CamelTestSessionClass {
CamelSessionClass parent_class;
-
+
} CamelTestSessionClass;
CamelType camel_test_session_get_type (void);
test_message_write_file(msg, "test1.msg");
check_unref(msg, 1);
pull();
-
+
push("read from test1.msg");
msg2 = test_message_read_file("test1.msg");
pull();
text = texts[j].text;
len = texts[j].len;
for (i=0;i<CAMEL_TRANSFER_NUM_ENCODINGS;i++) {
-
+
push("test simple message, encoding %s", camel_transfer_encoding_to_string(i));
msg = test_message_create_simple();
test_message_write_file(msg, "test1.msg");
check_unref(msg, 1);
pull();
-
+
push("read from test1.msg");
msg2 = test_message_read_file("test1.msg");
pull();
check(strcmp(format, test_address[i].utf8) == 0);
test_free(format);
pull();
-
+
push("Comparing re-encoded output");
addr2 = CAMEL_INTERNET_ADDRESS(camel_internet_address_new());
enc = camel_address_encode(CAMEL_ADDRESS(addr));
unlink("test3.msg");
test_message_write_file(msg, "test3.msg");
pull();
-
+
push("read from test3.msg");
msg2 = test_message_read_file("test3.msg");
pull();
CamelDataWrapper *content;
char *mime_type;
int i = 0;
-
+
while (i < depth) {
printf (" ");
i++;
}
-
+
content = camel_medium_get_content_object ((CamelMedium *) mime_part);
-
+
mime_type = camel_data_wrapper_get_mime_type (content);
printf ("Content-Type: %s\n", mime_type);
g_free (mime_type);
-
+
if (CAMEL_IS_MULTIPART (content)) {
guint num, index = 0;
-
+
num = camel_multipart_get_number ((CamelMultipart *) content);
while (index < num) {
mime_part = camel_multipart_get_part ((CamelMultipart *) content, index);
struct dirent *dent;
DIR *dir;
int fd;
-
+
camel_test_init (argc, argv);
-
+
camel_test_start ("Message Test Suite");
-
+
if (!(dir = opendir ("../data/messages")))
return 77;
-
+
while ((dent = readdir (dir)) != NULL) {
CamelMimeMessage *message;
CamelStream *stream;
char *filename;
struct stat st;
-
+
if (dent->d_name[0] == '.')
continue;
-
+
filename = g_strdup_printf ("../data/messages/%s", dent->d_name);
if (stat (filename, &st) == -1 || !S_ISREG (st.st_mode)) {
g_free (filename);
continue;
}
-
+
if ((fd = open (filename, O_RDONLY)) == -1) {
g_free (filename);
continue;
}
-
+
push ("testing message `%s`", filename);
g_free (filename);
-
+
stream = camel_stream_fs_new_with_fd (fd);
message = camel_mime_message_new ();
camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream);
camel_stream_reset (stream);
-
+
/*dump_mime_struct ((CamelMimePart *) message, 0);*/
test_message_compare (message);
-
+
camel_object_unref (message);
camel_object_unref (stream);
-
+
pull ();
}
-
+
closedir (dir);
-
+
camel_test_end ();
-
+
return 0;
}
#define CHUNK_SIZE 4096
-int
+int
main (int argc, char **argv)
{
ssize_t comp_progress, comp_correct_chunk, comp_filter_chunk;
struct dirent *dent;
int i, test = 0;
DIR *dir;
-
+
camel_test_init(argc, argv);
-
+
dir = opendir (SOURCEDIR);
if (!dir)
return 1;
-
+
while ((dent = readdir (dir))) {
char *infile, *outfile, *charset, *work;
const char *ext;
-
+
ext = strrchr (dent->d_name, '.');
if (!(!strncmp (dent->d_name, "charset-", 8) && ext && !strcmp (ext, ".in")))
continue;
-
+
work = g_strdup_printf ("Charset filter, test case %d (%s)", test++, dent->d_name);
camel_test_start (work);
g_free (work);
-
+
infile = g_strdup_printf ("%s/%s", SOURCEDIR, dent->d_name);
if (!(source = camel_stream_fs_new_with_name (infile, 0, O_RDONLY))) {
camel_test_fail ("Failed to open input case in \"%s\"", infile);
continue;
}
g_free (infile);
-
+
outfile = g_strdup_printf ("%s/%.*s.out", SOURCEDIR, ext - dent->d_name, dent->d_name);
-
+
if (!(correct = camel_stream_fs_new_with_name (outfile, 0, O_RDONLY))) {
camel_test_fail ("Failed to open correct output in \"%s\"", outfile);
g_free (outfile);
continue;
}
g_free (outfile);
-
+
if (!(filter = camel_stream_filter_new_with_stream (CAMEL_STREAM (source)))) {
camel_test_fail ("Couldn't create CamelStreamFilter??");
continue;
}
-
+
charset = g_strdup (dent->d_name + 8);
ext = strchr (charset, '.');
*((char *) ext) = '\0';
-
+
if (!(f = (CamelMimeFilter *) camel_mime_filter_charset_new_convert (charset, "UTF-8"))) {
camel_test_fail ("Couldn't create CamelMimeFilterCharset??");
g_free (charset);
continue;
}
g_free (charset);
-
+
camel_stream_filter_add (filter, f);
camel_object_unref (f);
-
+
camel_test_push ("Running filter and comparing to correct result");
-
+
comp_progress = 0;
-
+
while (1) {
comp_correct_chunk = camel_stream_read (correct, comp_correct, CHUNK_SIZE);
comp_filter_chunk = 0;
-
+
if (comp_correct_chunk == 0)
break;
-
+
while (comp_filter_chunk < comp_correct_chunk) {
ssize_t delta;
-
- delta = camel_stream_read (CAMEL_STREAM (filter),
- comp_filter + comp_filter_chunk,
+
+ delta = camel_stream_read (CAMEL_STREAM (filter),
+ comp_filter + comp_filter_chunk,
CHUNK_SIZE - comp_filter_chunk);
-
+
if (delta == 0) {
camel_test_fail ("Chunks are different sizes: correct is %d, "
"filter is %d, %d bytes into stream",
comp_correct_chunk, comp_filter_chunk, comp_progress);
}
-
+
comp_filter_chunk += delta;
}
-
+
for (i = 0; i < comp_filter_chunk; i++) {
if (comp_correct[i] != comp_filter[i]) {
camel_test_fail ("Difference: correct is %c, filter is %c, "
"%d bytes into stream",
- comp_correct[i],
+ comp_correct[i],
comp_filter[i],
comp_progress + i);
}
}
-
+
comp_progress += comp_filter_chunk;
}
-
+
camel_test_pull ();
-
+
/* inefficient */
camel_test_push ("Cleaning up");
camel_object_unref (CAMEL_OBJECT (filter));
camel_object_unref (CAMEL_OBJECT (correct));
camel_object_unref (CAMEL_OBJECT (source));
camel_test_pull ();
-
+
camel_test_end ();
}
-
+
closedir (dir);
-
+
return 0;
}
CRLF_DONE
};
-int
+int
main (int argc, char **argv)
{
CamelStream *source;
ssize_t comp_progress, comp_correct_chunk, comp_filter_chunk;
int comp_i;
char comp_correct[CHUNK_SIZE], comp_filter[CHUNK_SIZE];
-
+
camel_test_init(argc, argv);
-
+
for (i = 0; i < NUM_CASES; i++) {
int j;
-
+
work = g_strdup_printf ("CRLF/DOT filter, test case %d", i);
camel_test_start (work);
g_free (work);
-
+
for (j = CRLF_ENCODE; j < CRLF_DONE; j++) {
CamelMimeFilterCRLFDirection direction;
char *infile = NULL, *outfile = NULL;
-
+
switch (j) {
case CRLF_ENCODE:
camel_test_push ("Test of the encoder");
default:
break;
}
-
+
camel_test_push ("Initializing objects");
source = camel_stream_fs_new_with_name (infile, 0, O_RDONLY);
if (!source) {
continue;
}
g_free (infile);
-
+
correct = camel_stream_fs_new_with_name (outfile, 0, O_RDONLY);
if (!correct) {
camel_test_fail ("Failed to open correct output in \"%s\"", outfile);
continue;
}
g_free (outfile);
-
+
filter = camel_stream_filter_new_with_stream (CAMEL_STREAM (source));
if (!filter) {
camel_test_fail ("Couldn't create CamelStreamFilter??");
continue;
}
-
+
sh = camel_mime_filter_crlf_new (direction, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS);
if (!sh) {
camel_test_fail ("Couldn't create CamelMimeFilterCrlf??");
continue;
}
-
+
camel_stream_filter_add (filter, sh);
camel_test_pull ();
-
+
camel_test_push ("Running filter and comparing to correct result");
-
+
comp_progress = 0;
-
+
while (1) {
comp_correct_chunk = camel_stream_read (correct, comp_correct, CHUNK_SIZE);
comp_filter_chunk = 0;
-
+
if (comp_correct_chunk == 0)
break;
-
+
while (comp_filter_chunk < comp_correct_chunk) {
ssize_t delta;
-
- delta = camel_stream_read (CAMEL_STREAM (filter),
- comp_filter + comp_filter_chunk,
+
+ delta = camel_stream_read (CAMEL_STREAM (filter),
+ comp_filter + comp_filter_chunk,
CHUNK_SIZE - comp_filter_chunk);
-
+
if (delta == 0) {
camel_test_fail ("Chunks are different sizes: correct is %d, "
"filter is %d, %d bytes into stream",
comp_correct_chunk, comp_filter_chunk, comp_progress);
}
-
+
comp_filter_chunk += delta;
}
-
+
for (comp_i = 0; comp_i < comp_filter_chunk; comp_i++) {
if (comp_correct[comp_i] != comp_filter[comp_i]) {
camel_test_fail ("Difference: correct is %c, filter is %c, "
"%d bytes into stream",
- comp_correct[comp_i],
+ comp_correct[comp_i],
comp_filter[comp_i],
comp_progress + comp_i);
}
}
-
+
comp_progress += comp_filter_chunk;
}
-
+
camel_test_pull ();
-
+
/* inefficient */
camel_test_push ("Cleaning up");
camel_object_unref (CAMEL_OBJECT (filter));
camel_object_unref (CAMEL_OBJECT (source));
camel_object_unref (CAMEL_OBJECT (sh));
camel_test_pull ();
-
+
camel_test_pull ();
}
-
+
camel_test_end ();
}
-
+
return 0;
}
check_count(indisk, 2);
id = camel_stream_filter_add((CamelStreamFilter *)filter, f);
check_count(f, 2);
-
+
check(camel_stream_write_to_stream(filter, (CamelStream *)in) > 0);
check_msg(in->buffer->len == out->buffer->len
&& memcmp(in->buffer->data, out->buffer->data, in->buffer->len) == 0,
camel_test_pull();
}
-int
+int
main (int argc, char **argv)
{
int i;
camel_test_init(argc, argv);
-
+
camel_test_start("HTML Stream filtering");
for (i=0;i<100;i++) {
"Tasmiania with fur\r\n=46rom here or there ?\r\n" },
};
-int
+int
main (int argc, char **argv)
{
CamelStreamFilter *filter;
CamelMimeFilter *sh;
int i;
-
+
camel_test_init(argc, argv);
camel_test_start("canonicalisation filter tests");
}
camel_test_end();
-
+
return 0;
}
{ "=?iso-8859-1?q?th?= =?iso-8859-1?q?is?= is some text", "this is some text", 0 },
{ "=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=",
"If you can read this you understand the example.", 0 },
-#if 0
+#if 0
/* And oddly enough, camel fails on these, removed for now */
/* second half: brokenly encoded rfc2047 words */
{
char *decoded;
int i;
-
+
camel_test_init (argc, argv);
-
+
camel_test_start ("rfc2047 decoding");
-
+
for (i = 0; i < G_N_ELEMENTS (test1); i++) {
camel_test_push ("rfc2047 decoding[%d] '%s'", i, test1[i].encoded);
decoded = camel_header_decode_string (test1[i].encoded, "iso-8859-1");
g_free (decoded);
camel_test_pull ();
}
-
+
camel_test_end ();
-
+
camel_test_start ("rfc2047 ctext decoding");
-
+
for (i = 0; i < G_N_ELEMENTS (test2); i++) {
camel_test_push ("rfc2047 ctext decoding[%d] '%s'", i, test2[i].encoded);
decoded = camel_header_format_ctext (test2[i].encoded, "iso-8859-1");
g_free (decoded);
camel_test_pull ();
}
-
+
camel_test_end ();
-
+
return 0;
}
char *html, *url, *p;
int i, errors = 0;
guint32 flags;
-
+
camel_test_init (argc, argv);
-
+
camel_test_start ("URL scanning");
-
+
flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES;
for (i = 0; i < num_url_tests; i++) {
camel_test_push ("'%s' => '%s'", url_tests[i].text, url_tests[i].url ? url_tests[i].url : "None");
-
+
html = camel_text_to_html (url_tests[i].text, flags, 0);
-
+
url = strstr (html, "href=\"");
if (url) {
url += 6;
p = strchr (url, '"');
if (p)
*p = '\0';
-
+
while ((p = strstr (url, "&")))
memmove (p + 1, p + 5, strlen (p + 5) + 1);
}
-
+
if ((url && (!url_tests[i].url || strcmp (url, url_tests[i].url) != 0)) ||
(!url && url_tests[i].url)) {
printf ("FAILED on \"%s\" -> %s\n (got %s)\n\n",
url ? url : "(nothing)");
errors++;
}
-
+
g_free (html);
}
-
+
printf ("\n%d errors\n", errors);
-
+
camel_test_end ();
-
+
return errors;
}
typedef struct _CamelPgpSession {
CamelSession parent_object;
-
+
} CamelPgpSession;
typedef struct _CamelPgpSessionClass {
CamelSessionClass parent_class;
-
+
} CamelPgpSessionClass;
{
CamelSessionClass *camel_session_class =
CAMEL_SESSION_CLASS (camel_pgp_session_class);
-
+
/* virtual method override */
camel_session_class->get_password = get_password;
}
camel_pgp_session_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (
camel_test_session_get_type (),
(CamelObjectInitFunc) init,
NULL);
}
-
+
return type;
}
camel_pgp_session_new (const char *path)
{
CamelSession *session;
-
+
session = CAMEL_SESSION (camel_object_new (CAMEL_PGP_SESSION_TYPE));
-
+
camel_session_construct (session, path);
-
+
return session;
}
int ret;
camel_test_init (argc, argv);
-
+
/* clear out any camel-test data */
system ("/bin/rm -rf /tmp/camel-test");
system ("/bin/mkdir /tmp/camel-test");
setenv ("GNUPGHOME", "/tmp/camel-test/.gnupg", 1);
-
+
/* import the gpg keys */
if ((ret = system ("gpg < /dev/null > /dev/null 2>&1")) == -1)
return 77;
else if (WEXITSTATUS (ret) == 127)
return 77;
-
+
system ("gpg --import ../data/camel-test.gpg.pub > /dev/null 2>&1");
system ("gpg --import ../data/camel-test.gpg.sec > /dev/null 2>&1");
-
+
session = camel_pgp_session_new ("/tmp/camel-test");
-
+
ex = camel_exception_new ();
-
+
ctx = camel_gpg_context_new (session);
camel_gpg_context_set_always_trust (CAMEL_GPG_CONTEXT (ctx), TRUE);
-
+
camel_test_start ("Test of PGP/MIME functions");
-
+
mime_part = camel_mime_part_new ();
camel_mime_part_set_content (mime_part, test_msg, strlen (test_msg), "text/plain");
camel_mime_part_set_description (mime_part, "Test of PGP/MIME multipart/signed stuff");
-
+
camel_test_push ("PGP/MIME signing");
mps = camel_multipart_signed_new ();
camel_multipart_signed_sign (mps, ctx, mime_part, "no.user@no.domain", CAMEL_CIPHER_HASH_SHA1, ex);
check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
camel_test_pull ();
-
+
camel_object_unref (mime_part);
camel_exception_clear (ex);
-
+
camel_test_push ("PGP/MIME verify");
valid = camel_multipart_signed_verify (mps, ctx, ex);
check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
check_msg (camel_cipher_validity_get_valid (valid), "%s", camel_cipher_validity_get_description (valid));
camel_cipher_validity_free (valid);
camel_test_pull ();
-
+
camel_object_unref (mps);
camel_exception_clear (ex);
-
+
mime_part = camel_mime_part_new ();
camel_mime_part_set_content (mime_part, test_msg, strlen (test_msg), "text/plain");
camel_mime_part_set_description (mime_part, "Test of PGP/MIME multipart/encrypted stuff");
-
+
camel_test_push ("PGP/MIME encrypt");
recipients = g_ptr_array_new ();
g_ptr_array_add (recipients, "no.user@no.domain");
-
+
mpe = camel_multipart_encrypted_new ();
camel_multipart_encrypted_encrypt (mpe, mime_part, ctx, "no.user@no.domain", recipients, ex);
check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
g_ptr_array_free (recipients, TRUE);
camel_test_pull ();
-
+
camel_exception_clear (ex);
camel_object_unref (mime_part);
-
+
camel_test_push ("PGP/MIME decrypt");
mime_part = camel_multipart_encrypted_decrypt (mpe, ctx, ex);
check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
camel_object_unref (mime_part);
camel_object_unref (mpe);
camel_test_pull ();
-
+
camel_object_unref (CAMEL_OBJECT (ctx));
camel_object_unref (CAMEL_OBJECT (session));
-
+
camel_test_end ();
-
+
return 0;
}
typedef struct _CamelPgpSession {
CamelSession parent_object;
-
+
} CamelPgpSession;
typedef struct _CamelPgpSessionClass {
CamelSessionClass parent_class;
-
+
} CamelPgpSessionClass;
{
CamelSessionClass *camel_session_class =
CAMEL_SESSION_CLASS (camel_pgp_session_class);
-
+
/* virtual method override */
camel_session_class->get_password = get_password;
}
camel_pgp_session_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (
camel_test_session_get_type (),
(CamelObjectInitFunc) init,
NULL);
}
-
+
return type;
}
camel_pgp_session_new (const char *path)
{
CamelSession *session;
-
+
session = CAMEL_SESSION (camel_object_new (CAMEL_PGP_SESSION_TYPE));
-
+
camel_session_construct (session, path);
-
+
return session;
}
if (getenv("CAMEL_TEST_GPG") == NULL)
return 77;
-
+
camel_test_init (argc, argv);
-
+
/* clear out any camel-test data */
system ("/bin/rm -rf /tmp/camel-test");
system ("/bin/mkdir /tmp/camel-test");
setenv ("GNUPGHOME", "/tmp/camel-test/.gnupg", 1);
-
+
/* import the gpg keys */
if ((ret = system ("gpg < /dev/null > /dev/null 2>&1")) == -1)
return 77;
system ("gpg --import " TEST_DATA_DIR "/camel-test.gpg.sec > /dev/null 2>&1");
session = camel_pgp_session_new ("/tmp/camel-test");
-
+
ex = camel_exception_new ();
-
+
ctx = camel_gpg_context_new (session);
camel_gpg_context_set_always_trust (CAMEL_GPG_CONTEXT (ctx), TRUE);
-
+
camel_test_start ("Test of PGP functions");
stream1 = camel_stream_mem_new ();
return 77;
}
camel_test_pull ();
-
+
camel_exception_clear (ex);
-
+
camel_test_push ("PGP verify");
valid = camel_cipher_verify (ctx, sigpart, ex);
check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
check_msg (camel_cipher_validity_get_valid (valid), "%s", camel_cipher_validity_get_description (valid));
camel_cipher_validity_free (valid);
camel_test_pull ();
-
+
camel_object_unref(conpart);
camel_object_unref(sigpart);
-
+
stream1 = camel_stream_mem_new ();
camel_stream_write (stream1, "Hello, I am a test of encryption/decryption.", 44);
camel_stream_reset (stream1);
camel_object_unref(dw);
encpart = camel_mime_part_new();
-
+
camel_exception_clear (ex);
-
+
camel_test_push ("PGP encrypt");
recipients = g_ptr_array_new ();
g_ptr_array_add (recipients, "no.user@no.domain");
camel_test_pull ();
camel_exception_clear (ex);
-
+
camel_test_push ("PGP decrypt");
outpart = camel_mime_part_new();
valid = camel_cipher_decrypt (ctx, encpart, outpart, ex);
camel_object_unref(outpart);
camel_test_pull ();
-
+
camel_object_unref (CAMEL_OBJECT (ctx));
camel_object_unref (CAMEL_OBJECT (session));
-
+
camel_test_end ();
-
+
return 0;
}
typedef struct _CamelTestSession {
CamelSession parent_object;
-
+
} CamelTestSession;
typedef struct _CamelTestSessionClass {
CamelSessionClass parent_class;
-
+
} CamelTestSessionClass;
{
CamelSessionClass *camel_session_class =
CAMEL_SESSION_CLASS (camel_test_session_class);
-
+
/* virtual method override */
camel_session_class->get_password = get_password;
}
camel_test_session_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
-
+
if (type == CAMEL_INVALID_TYPE) {
type = camel_type_register (
camel_test_session_get_type (),
(CamelObjectInitFunc) init,
NULL);
}
-
+
return type;
}
camel_test_session_new (const char *path)
{
CamelSession *session;
-
+
session = CAMEL_SESSION (camel_object_new (CAMEL_TEST_SESSION_TYPE));
-
+
camel_session_construct (session, path);
-
+
return session;
}
GPtrArray *recipients;
GByteArray *buf;
char *before, *after;
-
+
camel_test_init (argc, argv);
-
+
ex = camel_exception_new ();
-
+
/* clear out any camel-test data */
system ("/bin/rm -rf /tmp/camel-test");
-
+
session = camel_test_session_new ("/tmp/camel-test");
-
+
ctx = camel_smime_context_new (session);
-
+
camel_test_start ("Test of S/MIME PKCS7 functions");
-
+
stream1 = camel_stream_mem_new ();
camel_stream_write (stream1, "Hello, I am a test stream.", 25);
camel_stream_reset (stream1);
-
+
stream2 = camel_stream_mem_new ();
-
+
camel_test_push ("PKCS7 signing");
camel_smime_sign (ctx, "smime@xtorshun.org", CAMEL_CIPHER_HASH_SHA1,
stream1, stream2, ex);
check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
camel_test_pull ();
-
+
camel_exception_clear (ex);
-
+
camel_test_push ("PKCS7 verify");
camel_stream_reset (stream1);
camel_stream_reset (stream2);
check_msg (camel_cipher_validity_get_valid (valid), "%s", camel_cipher_validity_get_description (valid));
camel_cipher_validity_free (valid);
camel_test_pull ();
-
+
camel_object_unref (CAMEL_OBJECT (stream1));
camel_object_unref (CAMEL_OBJECT (stream2));
-
+
stream1 = camel_stream_mem_new ();
stream2 = camel_stream_mem_new ();
stream3 = camel_stream_mem_new ();
-
+
camel_stream_write (stream1, "Hello, I am a test of encryption/decryption.", 44);
camel_stream_reset (stream1);
-
+
camel_exception_clear (ex);
-
+
camel_test_push ("PKCS7 encrypt");
recipients = g_ptr_array_new ();
g_ptr_array_add (recipients, "smime@xtorshun.org");
check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
g_ptr_array_free (recipients, TRUE);
camel_test_pull ();
-
+
camel_stream_reset (stream2);
camel_exception_clear (ex);
-
+
camel_test_push ("PKCS7 decrypt");
camel_smime_decrypt (ctx, stream2, stream3, ex);
check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex));
g_free (before);
g_free (after);
camel_test_pull ();
-
+
camel_object_unref (CAMEL_OBJECT (ctx));
camel_object_unref (CAMEL_OBJECT (session));
-
+
camel_test_end ();
-
+
return 0;
}
check_unref(ss, 1);
check(close(fd) == -1);
pull();
-
+
(void)unlink("stream.txt");
}
push("stream subrange %d-%d", ranges[i].lower, ranges[i].upper);
sus = (CamelSeekableSubstream *)camel_seekable_substream_new(ss, ranges[i].lower, ranges[i].upper);
check(sus != NULL);
-
+
test_seekable_substream_writepart((CamelStream *)sus, j);
test_seekable_substream_readpart((CamelStream *)sus);
-
+
sus2 = (CamelSeekableSubstream *)camel_seekable_substream_new(ss, ranges[i].lower, ranges[i].upper);
check(sus2 != NULL);
test_seekable_substream_readpart((CamelStream *)sus2);
-
+
check_unref(sus, 1);
check_unref(sus2, 1);
pull();
sus2 = (CamelSeekableSubstream *)camel_seekable_substream_new(ss, ranges[i].lower, ranges[i].upper);
check(sus2 != NULL);
test_seekable_substream_readpart((CamelStream *)sus2);
-
+
check_unref(sus, 1);
check_unref(sus2, 1);
pull();
</para>
+<!-- ##### ARG EContact:phone ##### -->
+<para>
+
+</para>
+
<!-- ##### ARG EContact:photo ##### -->
<para>
@E_CONTACT_IM_GADUGADU_WORK_3:
@E_CONTACT_IM_GADUGADU:
@E_CONTACT_GEO:
+@E_CONTACT_TEL:
@E_CONTACT_FIELD_LAST:
@E_CONTACT_FIELD_FIRST:
@E_CONTACT_LAST_SIMPLE_STRING:
</para>
-
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
-
<!-- ##### SECTION Stability_Level ##### -->
enum {
ISO_UNSUPPORTED = 0,
-
+
/* iso-8859-1 */
ISO_DASH_D_DASH_D_LOWER = (1 << 0),
ISO_DASH_D_DASH_D = (1 << 1),
ISO_D_D = (1 << 3),
ISO_UNDER_D_DASH_D = (1 << 4),
NO_ISO_D_DASH_D = (1 << 5),
-
+
/* iso-10646-1 */
/*ISO_DASH_D_DASH_D_LOWER = (1 << 0),*/
/*ISO_DASH_D_DASH_D = (1 << 1),*/
ISO_DASH_D = (1 << 4),
ISO_D = (1 << 5),
UCS4 = (1 << 6),
-
+
/* iso-2022-jp */
ISO_DASH_D_DASH_S_LOWER = (1 << 0),
ISO_DASH_D_DASH_S = (1 << 1),
iconv_t cd;
FILE *fp;
int i;
-
+
fp = fopen ("iconv-detect.h", "w");
if (fp == NULL)
exit (255);
-
+
fprintf (fp, "/* This is an auto-generated header, DO NOT EDIT! */\n\n");
-
+
iso8859 = ISO_UNSUPPORTED;
info = iso8859_tests;
/*printf ("#define DEFAULT_ISO_FORMAT(iso,codepage)\t");*/
break;
}
}
-
+
if (iso8859 == ISO_UNSUPPORTED) {
fprintf (stderr, "System doesn't support any ISO-8859-1 formats\n");
fprintf (fp, "#define ICONV_ISO_D_FORMAT \"%s\"\n", info[0].format);
} else {
fprintf (fp, "#define ICONV_ISO_D_FORMAT \"%s\"\n", info[i].format);
}
-
+
iso2022 = ISO_UNSUPPORTED;
info = iso2022_tests;
/*printf ("#define ISO_2022_FORMAT(iso,codepage)\t");*/
break;
}
}
-
+
if (iso2022 == ISO_UNSUPPORTED) {
fprintf (stderr, "System doesn't support any ISO-2022 formats\n");
fprintf (fp, "#define ICONV_ISO_S_FORMAT \"%s\"\n", info[0].format);
} else {
fprintf (fp, "#define ICONV_ISO_S_FORMAT \"%s\"\n", info[i].format);
}
-
+
iso10646 = ISO_UNSUPPORTED;
info = iso10646_tests;
/*printf ("#define ISO_10646_FORMAT(iso,codepage)\t");*/
break;
}
}
-
+
/* we don't need a printf format for iso-10646 because there is only 1 */
if (iso10646 == ISO_UNSUPPORTED) {
fprintf (stderr, "System doesn't support any ISO-10646-1 formats\n");
} else {
fprintf (fp, "#define ICONV_10646 \"%s\"\n", info[i].charset);
}
-
+
fclose (fp);
-
+
exit (0);
}
* use the entire filename for the backup name.
*/
len = strlen(name) + strlen(BACKUP_PREFIX) + MAX_LSN_TO_TEXT;
-
+
if ((ret = __os_malloc(dbenv, len, &retp)) != 0)
return (ret);
* has an open OPD cursor whose state might need to
* be preserved.
*/
- if ((!(multi & DB_MULTIPLE_KEY) &&
+ if ((!(multi & DB_MULTIPLE_KEY) &&
dbc_arg->internal->opd == NULL) ||
F_ISSET(dbc_arg, DBC_TRANSIENT))
dbc_n = dbc_arg;
blr \n\
success: \n\
li r3,1 \n\
- blr");
+ blr");
}
#define MUTEX_SET(tsl) __db_mutex_set(tsl)
#endif
100% Public Domain
-----------------
-Modified 7/98
+Modified 7/98
By James H. Brown <jbrown@burgoyne.com>
Still 100% Public Domain
be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
"a"s).
-I also changed the declaration of variables i & j in SHA1Update to
+I also changed the declaration of variables i & j in SHA1Update to
unsigned long from unsigned int for the same reason.
These changes should make no difference to any 32 bit implementations since
Modified 4/01
By Saul Kravitz <Saul.Kravitz@celera.com>
Still 100% PD
-Modified to run on Compaq Alpha hardware.
+Modified to run on Compaq Alpha hardware.
*/
{
printf("%s (%d,%d) %x %x %x %x %x\n",
msg,
- context->count[0], context->count[1],
+ context->count[0], context->count[1],
context->state[0],
context->state[1],
context->state[2],
/*
* __db_SHA1Transform --
- *
+ *
* PUBLIC: void __db_SHA1Transform __P((u_int32_t *, unsigned char *));
*/
void
/* SHA1Init - Initialize new context */
-/*
+/*
* __db_SHA1Init --
* Initialize new context
*
__db_SHA1Transform(context->state, context->buffer);
#endif
}
-
+
/*************************************************************/
MUTEX_UNSET(&mutexp->tas);
ret = 0;
-
+
if (mutexp->nwaiters > 0) {
GET_HANDLE(mutexp, event);
-/* This file is Based on output from
+/* This file is Based on output from
* Perl/Pollution/Portability Version 2.0000 */
#ifndef _P_P_PORTABILITY_H_
# define pTHX_
# define aTHX
# define aTHX_
-#endif
+#endif
#ifndef PTR2IV
# define PTR2IV(d) (IV)(d)
#endif
-
+
#ifndef INT2PTR
# define INT2PTR(any,d) (any)(d)
#endif
# if defined(CRIPPLED_CC) || defined(USE_THREADS)
static SV * newRV_noinc (SV * sv)
{
- SV *nsv = (SV*)newRV(sv);
- SvREFCNT_dec(sv);
- return nsv;
+ SV *nsv = (SV*)newRV(sv);
+ SvREFCNT_dec(sv);
+ return nsv;
}
# else
# define newRV_noinc(sv) \
# define PERL_UNUSED_DECL __attribute__((unused))
#else
# define PERL_UNUSED_DECL
-#endif
+#endif
#ifndef dNOOP
# define dNOOP extern int Perl___notused PERL_UNUSED_DECL
#define aMY_CXT_
#define _aMY_CXT
-#endif
+#endif
#endif /* START_MY_CXT */
#ifndef DBM_setFilter
-/*
- The DBM_setFilter & DBM_ckFilter macros are only used by
- the *DB*_File modules
+/*
+ The DBM_setFilter & DBM_ckFilter macros are only used by
+ the *DB*_File modules
*/
#define DBM_setFilter(db_type,code) \
-/* This file is Based on output from
+/* This file is Based on output from
* Perl/Pollution/Portability Version 2.0000 */
#ifndef _P_P_PORTABILITY_H_
# define pTHX_
# define aTHX
# define aTHX_
-#endif
+#endif
#ifndef PTR2IV
# define PTR2IV(d) (IV)(d)
#endif
-
+
#ifndef INT2PTR
# define INT2PTR(any,d) (any)(d)
#endif
# if defined(CRIPPLED_CC) || defined(USE_THREADS)
static SV * newRV_noinc (SV * sv)
{
- SV *nsv = (SV*)newRV(sv);
- SvREFCNT_dec(sv);
- return nsv;
+ SV *nsv = (SV*)newRV(sv);
+ SvREFCNT_dec(sv);
+ return nsv;
}
# else
# define newRV_noinc(sv) \
# define PERL_UNUSED_DECL __attribute__((unused))
#else
# define PERL_UNUSED_DECL
-#endif
+#endif
#ifndef dNOOP
# define dNOOP extern int Perl___notused PERL_UNUSED_DECL
#define aMY_CXT_
#define _aMY_CXT
-#endif
+#endif
#endif /* START_MY_CXT */
#ifndef DBM_setFilter
-/*
- The DBM_setFilter & DBM_ckFilter macros are only used by
- the *DB*_File modules
+/*
+ The DBM_setFilter & DBM_ckFilter macros are only used by
+ the *DB*_File modules
*/
#define DBM_setFilter(db_type,code) \
-/*
+/*
- version.c -- Perl 5 interface to Berkeley DB
+ version.c -- Perl 5 interface to Berkeley DB
written by Paul Marquess <Paul.Marquess@btinternet.com>
last modified 2nd Jan 2002
*/
#define PERL_NO_GET_CONTEXT
-#include "EXTERN.h"
+#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
__getBerkeleyDBInfo()
#endif
{
-#ifdef dTHX
+#ifdef dTHX
dTHX;
-#endif
+#endif
SV * version_sv = perl_get_sv("DB_File::db_version", GV_ADD|GV_ADDMULTI) ;
SV * ver_sv = perl_get_sv("DB_File::db_ver", GV_ADD|GV_ADDMULTI) ;
SV * compat_sv = perl_get_sv("DB_File::db_185_compat", GV_ADD|GV_ADDMULTI) ;
(void)db_version(&Major, &Minor, &Patch) ;
/* Check that the versions of db.h and libdb.a are the same */
- if (Major != DB_VERSION_MAJOR || Minor != DB_VERSION_MINOR
+ if (Major != DB_VERSION_MAJOR || Minor != DB_VERSION_MINOR
|| Patch != DB_VERSION_PATCH)
- croak("\nDB_File needs compatible versions of libdb & db.h\n\tyou have db.h version %d.%d.%d and libdb version %d.%d.%d\n",
- DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
+ croak("\nDB_File needs compatible versions of libdb & db.h\n\tyou have db.h version %d.%d.%d and libdb version %d.%d.%d\n",
+ DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
Major, Minor, Patch) ;
-
+
/* check that libdb is recent enough -- we need 2.3.4 or greater */
if (Major == 2 && (Minor < 3 || (Minor == 3 && Patch < 4)))
croak("DB_File needs Berkeley DB 2.3.4 or greater, you have %d.%d.%d\n",
Major, Minor, Patch) ;
-
+
{
char buffer[40] ;
sprintf(buffer, "%d.%d", Major, Minor) ;
- sv_setpv(version_sv, buffer) ;
+ sv_setpv(version_sv, buffer) ;
sprintf(buffer, "%d.%03d%03d", Major, Minor, Patch) ;
- sv_setpv(ver_sv, buffer) ;
+ sv_setpv(ver_sv, buffer) ;
}
-
+
#else /* ! DB_VERSION_MAJOR */
sv_setiv(version_sv, 1) ;
sv_setiv(ver_sv, 1) ;
"DB_ENV->set_rep_transport must be called before DB_ENV->rep_start");
return (EINVAL);
}
-
+
/* We'd better not have any logged files open if we are a client. */
if (LF_ISSET(DB_REP_CLIENT) && (ret = __dbreg_nofiles(dbenv)) != 0) {
__db_err(dbenv, "DB_ENV->rep_start called with open files");
#include "dbinc_auto/rpc_server_ext.h"
/*
- * PUBLIC: __env_cachesize_reply *__db_env_cachesize_4001
+ * PUBLIC: __env_cachesize_reply *__db_env_cachesize_4001
* PUBLIC: __P((__env_cachesize_msg *, struct svc_req *));
*/
__env_cachesize_reply *
}
/*
- * PUBLIC: __env_dbremove_reply *__db_env_dbremove_4001
+ * PUBLIC: __env_dbremove_reply *__db_env_dbremove_4001
* PUBLIC: __P((__env_dbremove_msg *, struct svc_req *));
*/
__env_dbremove_reply *
}
/*
- * PUBLIC: __env_dbrename_reply *__db_env_dbrename_4001
+ * PUBLIC: __env_dbrename_reply *__db_env_dbrename_4001
* PUBLIC: __P((__env_dbrename_msg *, struct svc_req *));
*/
__env_dbrename_reply *
}
/*
- * PUBLIC: __env_encrypt_reply *__db_env_encrypt_4001
+ * PUBLIC: __env_encrypt_reply *__db_env_encrypt_4001
* PUBLIC: __P((__env_encrypt_msg *, struct svc_req *));
*/
__env_encrypt_reply *
}
/*
- * PUBLIC: __txn_discard_reply *__db_txn_discard_4001
+ * PUBLIC: __txn_discard_reply *__db_txn_discard_4001
* PUBLIC: __P((__txn_discard_msg *, struct svc_req *));
*/
__txn_discard_reply *
}
/*
- * PUBLIC: __txn_prepare_reply *__db_txn_prepare_4001
+ * PUBLIC: __txn_prepare_reply *__db_txn_prepare_4001
* PUBLIC: __P((__txn_prepare_msg *, struct svc_req *));
*/
__txn_prepare_reply *
}
/*
- * PUBLIC: __txn_recover_reply *__db_txn_recover_4001
+ * PUBLIC: __txn_recover_reply *__db_txn_recover_4001
* PUBLIC: __P((__txn_recover_msg *, struct svc_req *));
*/
__txn_recover_reply *
}
/*
- * PUBLIC: __db_associate_reply *__db_db_associate_4001
+ * PUBLIC: __db_associate_reply *__db_db_associate_4001
* PUBLIC: __P((__db_associate_msg *, struct svc_req *));
*/
__db_associate_reply *
}
/*
- * PUBLIC: __db_bt_maxkey_reply *__db_db_bt_maxkey_4001
+ * PUBLIC: __db_bt_maxkey_reply *__db_db_bt_maxkey_4001
* PUBLIC: __P((__db_bt_maxkey_msg *, struct svc_req *));
*/
__db_bt_maxkey_reply *
}
/*
- * PUBLIC: __db_bt_minkey_reply *__db_db_bt_minkey_4001
+ * PUBLIC: __db_bt_minkey_reply *__db_db_bt_minkey_4001
* PUBLIC: __P((__db_bt_minkey_msg *, struct svc_req *));
*/
__db_bt_minkey_reply *
}
/*
- * PUBLIC: __db_extentsize_reply *__db_db_extentsize_4001
+ * PUBLIC: __db_extentsize_reply *__db_db_extentsize_4001
* PUBLIC: __P((__db_extentsize_msg *, struct svc_req *));
*/
__db_extentsize_reply *
}
/*
- * PUBLIC: __db_h_ffactor_reply *__db_db_h_ffactor_4001
+ * PUBLIC: __db_h_ffactor_reply *__db_db_h_ffactor_4001
* PUBLIC: __P((__db_h_ffactor_msg *, struct svc_req *));
*/
__db_h_ffactor_reply *
}
/*
- * PUBLIC: __db_key_range_reply *__db_db_key_range_4001
+ * PUBLIC: __db_key_range_reply *__db_db_key_range_4001
* PUBLIC: __P((__db_key_range_msg *, struct svc_req *));
*/
__db_key_range_reply *
}
/*
- * PUBLIC: __db_pagesize_reply *__db_db_pagesize_4001
+ * PUBLIC: __db_pagesize_reply *__db_db_pagesize_4001
* PUBLIC: __P((__db_pagesize_msg *, struct svc_req *));
*/
__db_pagesize_reply *
}
/*
- * PUBLIC: __db_re_delim_reply *__db_db_re_delim_4001
+ * PUBLIC: __db_re_delim_reply *__db_db_re_delim_4001
* PUBLIC: __P((__db_re_delim_msg *, struct svc_req *));
*/
__db_re_delim_reply *
}
/*
- * PUBLIC: __db_truncate_reply *__db_db_truncate_4001
+ * PUBLIC: __db_truncate_reply *__db_db_truncate_4001
* PUBLIC: __P((__db_truncate_msg *, struct svc_req *));
*/
__db_truncate_reply *
*/
if (td->status == TXN_PREPARED)
return (__db_panic(dbenv, ret));
-
+
if ((t_ret = txnp->abort(txnp)) != 0)
ret = t_ret;
return (ret);
gconf_client_suggest_sync (account_list->priv->gconf, NULL);
}
-void
+void
e_account_list_prune_proxies (EAccountList *account_list)
{
EAccount *account;
EIterator *iter;
-
+
for (iter = e_list_get_iterator (E_LIST (account_list));
e_iterator_is_valid (iter);
e_iterator_next (iter)) {
account = (EAccount *)e_iterator_get (iter);
- if (account->parent_uid)
+ if (account->parent_uid)
e_account_list_remove (account_list, account);
}
g_object_unref (iter);
}
-void
+void
e_account_list_remove_account_proxies (EAccountList *accounts, EAccount *account)
{
EAccount *child_account;
/**
* e_account_list_add:
- * @accounts:
- * @account:
- *
+ * @accounts:
+ * @account:
+ *
* Add an account to the account list. Will emit the account-changed
* event.
**/
/**
* e_account_list_change:
- * @accounts:
- * @account:
- *
+ * @accounts:
+ * @account:
+ *
* Signal that the details of an account have changed.
**/
void
/**
* e_account_list_remove:
- * @accounts:
- * @account:
- *
+ * @accounts:
+ * @account:
+ *
* Remove an account from the account list, and emit the
* account-removed signal. If the account was the default account,
* then reset the default to the first account.
/**
* e_account_list_get_default:
- * @accounts:
- *
+ * @accounts:
+ *
* Get the default account. If no default is specified, or the default
* has become stale, then the first account is made the default.
- *
+ *
* Return value: The account or NULL if no accounts are defined.
**/
const EAccount *
/**
* e_account_list_set_default:
- * @accounts:
- * @account:
- *
+ * @accounts:
+ * @account:
+ *
* Set the account @account to be the default account.
**/
void
/**
* e_account_list_find:
- * @accounts:
+ * @accounts:
* @type: Type of search.
* @key: Search key.
- *
+ *
* Perform a search of the account list on a single key.
*
* @type must be set from one of the following search types:
* E_ACCOUNT_FIND_NAME - Find an account by account name.
* E_ACCOUNT_FIND_ID_NAME - Find an account by the owner's identity name.
* E_ACCOUNT_FIND_ID_ADDRESS - Find an account by the owner's identity address.
- *
+ *
* Return value: The account or NULL if it doesn't exist.
**/
const EAccount *
if (!key)
return NULL;
-
+
for (it = e_list_get_iterator ((EList *)accounts);
e_iterator_is_valid (it);
e_iterator_next (it)) {
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2003 Ximian, Inc.
*
* This library is free software; you can redistribute it and/or
lock mail accounts Relatively difficult -- involves redesign of the XML blobs which describe accounts
disable adding mail accounts Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable
disable editing mail accounts Relatively difficult -- involves redesign of the XML blobs which describe accounts
-disable removing mail accounts
+disable removing mail accounts
lock default character encoding Simple -- Gconf key + a little UI work to desensitize widgets, etc
-disable free busy publishing
+disable free busy publishing
disable specific mime types (from being viewed) 90% done already (Unknown MIME types still pose a problem)
-lock image loading preference
-lock junk mail filtering settings
+lock image loading preference
+lock junk mail filtering settings
** junk mail per account
-lock work week
-lock first day of work week
-lock working hours
-disable forward as icalendar
-lock color options for tasks
-lock default contact filing format
+lock work week
+lock first day of work week
+lock working hours
+disable forward as icalendar
+lock color options for tasks
+lock default contact filing format
* forbid signatures Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable
* lock user to having 1 specific signature Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable
* forbid adding/removing signatures Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable
-* lock each account to a certain signature Relatively difficult -- involved redesign of the XML blobs which describe accounts
-* set default folders
-set trash emptying frequency
+* lock each account to a certain signature Relatively difficult -- involved redesign of the XML blobs which describe accounts
+* set default folders
+set trash emptying frequency
* lock displayed mail headers Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable
* lock authentication type (for incoming mail) Relatively difficult -- involves redesign of the XML blobs which describe accounts
* lock authentication type (for outgoing mail) Relatively difficult -- involves redesign of the XML blobs which describe accounts
account->transport = g_new0 (EAccountService, 1);
account->parent_uid = NULL;
-
+
account->source->auto_check = FALSE;
account->source->auto_check_time = 10;
}
receipt_policy_to_str (EAccountReceiptPolicy val)
{
char *ret = NULL;
-
+
switch (val) {
case E_ACCOUNT_RECEIPT_NEVER:
ret = "never";
/* set a fake sig uid so the migrate code can handle this */
gboolean autogen = FALSE;
int sig_id = 0;
-
+
xml_set_bool (node, "auto", &autogen);
xml_set_int (node, "default", &sig_id);
-
+
if (autogen) {
id->sig_uid = g_strdup ("::0");
changed = TRUE;
{
g_free (dest->name);
dest->name = g_strdup (src->name);
-
+
dest->enabled = src->enabled;
-
+
g_free (dest->id->name);
dest->id->name = g_strdup (src->id->name);
g_free (dest->id->address);
g_free (dest->id->organization);
dest->id->organization = g_strdup (src->id->organization);
dest->id->sig_uid = g_strdup (src->id->sig_uid);
-
+
g_free (dest->source->url);
dest->source->url = g_strdup (src->source->url);
dest->source->keep_on_server = src->source->keep_on_server;
dest->source->auto_check = src->source->auto_check;
dest->source->auto_check_time = src->source->auto_check_time;
dest->source->save_passwd = src->source->save_passwd;
-
+
g_free (dest->transport->url);
dest->transport->url = g_strdup (src->transport->url);
dest->transport->save_passwd = src->transport->save_passwd;
-
+
g_free (dest->drafts_folder_uri);
dest->drafts_folder_uri = g_strdup (src->drafts_folder_uri);
-
+
g_free (dest->sent_folder_uri);
dest->sent_folder_uri = g_strdup (src->sent_folder_uri);
-
+
dest->always_cc = src->always_cc;
g_free (dest->cc_addrs);
dest->cc_addrs = g_strdup (src->cc_addrs);
-
+
dest->always_bcc = src->always_bcc;
g_free (dest->bcc_addrs);
dest->bcc_addrs = g_strdup (src->bcc_addrs);
-
+
dest->receipt_policy = src->receipt_policy;
-
+
g_free (dest->pgp_key);
dest->pgp_key = g_strdup (src->pgp_key);
dest->pgp_encrypt_to_self = src->pgp_encrypt_to_self;
dest->pgp_always_sign = src->pgp_always_sign;
dest->pgp_no_imip_sign = src->pgp_no_imip_sign;
dest->pgp_always_trust = src->pgp_always_trust;
-
+
dest->smime_sign_default = src->smime_sign_default;
g_free (dest->smime_sign_key);
dest->smime_sign_key = g_strdup (src->smime_sign_key);
dest->smime_encrypt_to_self = src->smime_encrypt_to_self;
g_free (dest->smime_encrypt_key);
dest->smime_encrypt_key = g_strdup (src->smime_encrypt_key);
-
+
g_signal_emit(dest, signals[CHANGED], 0, -1);
}
node = xmlNewChild (root, NULL, (xmlChar*)"receipt-policy", NULL);
xmlSetProp (node, (xmlChar*)"policy", receipt_policy_to_str (account->receipt_policy));
-
+
node = xmlNewChild (root, NULL, (xmlChar*)"pgp", NULL);
xmlSetProp (node, (xmlChar*)"encrypt-to-self", (xmlChar*)(account->pgp_encrypt_to_self ? "true" : "false"));
xmlSetProp (node, (xmlChar*)"always-trust", (xmlChar*)(account->pgp_always_trust ? "true" : "false"));
if (account->parent_uid) {
node = xmlNewChild (root, NULL, (xmlChar*)"proxy", NULL);
xmlNewTextChild (node, NULL, (xmlChar*)"parent-uid", (xmlChar*)account->parent_uid);
- }
+ }
xmlDocDumpMemory (doc, &xmlbuf, &n);
xmlFreeDoc (doc);
{ /* E_ACCOUNT_BCC_ADDRS */ 0, TYPE_STRING, G_STRUCT_OFFSET(EAccount, bcc_addrs) },
{ /* E_ACCOUNT_RECEIPT_POLICY */ 0, TYPE_INT, G_STRUCT_OFFSET(EAccount, receipt_policy) },
-
+
{ /* E_ACCOUNT_PGP_KEY */ 0, TYPE_STRING, G_STRUCT_OFFSET(EAccount, pgp_key) },
{ /* E_ACCOUNT_PGP_ENCRYPT_TO_SELF */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, pgp_encrypt_to_self) },
{ /* E_ACCOUNT_PGP_ALWAYS_SIGN */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, pgp_always_sign) },
struct _system_info *info;
g_return_if_fail (gconf_entry_get_key (entry) != NULL);
-
+
if (!(value = gconf_entry_get_value (entry)))
return;
-
+
tkey = strrchr(entry->key, '/');
g_return_if_fail (tkey != NULL);
((account_info[type].type & TYPE_STRUCT)? \
(((char **)(((char *)ea)+account_info[type].offset))[0] + account_info[type].struct_offset): \
(((char *)ea)+account_info[type].offset))
-
+
const char *e_account_get_string(EAccount *ea, e_account_item_t type)
{
return *((const char **)addr(ea, type));
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2003 Ximian, Inc.
*
* This library is free software; you can redistribute it and/or
E_ACCOUNT_BCC_ADDRS,
E_ACCOUNT_RECEIPT_POLICY,
-
+
E_ACCOUNT_PGP_KEY,
E_ACCOUNT_PGP_ENCRYPT_TO_SELF,
E_ACCOUNT_PGP_ALWAYS_SIGN,
char *address;
char *reply_to;
char *organization;
-
+
char *sig_uid;
} EAccountIdentity;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2005 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2005 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* e-data-server-module.c - Interface to e-d-s extensions
- *
+ *
* Copyright (C) 2004 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
*
* Authors: Chris Toshok <toshok@ximian.com>
* Dave Camp <dave@ximian.com>
- *
+ *
*/
#include <config.h>
};
struct _EDataServerModuleClass {
- GTypeModuleClass parent;
+ GTypeModuleClass parent;
};
static GType e_data_server_module_get_type (void);
e_data_server_module_load (GTypeModule *gmodule)
{
EDataServerModule *module;
-
+
module = E_DATA_SERVER_MODULE (gmodule);
-
+
module->library = g_module_open (module->path, G_MODULE_BIND_LAZY);
if (!module->library) {
g_warning (g_module_error ());
g_module_close (module->library);
-
+
return FALSE;
}
module->initialize (gmodule);
-
+
return TRUE;
}
e_data_server_module_unload (GTypeModule *gmodule)
{
EDataServerModule *module;
-
+
module = E_DATA_SERVER_MODULE (gmodule);
-
+
module->shutdown ();
-
+
g_module_close (module->library);
-
+
module->initialize = NULL;
module->shutdown = NULL;
module->list_types = NULL;
e_data_server_module_finalize (GObject *object)
{
EDataServerModule *module;
-
+
module = E_DATA_SERVER_MODULE (object);
g_free (module->path);
const GType *types;
int num_types;
int i;
-
+
module->list_types (&types, &num_types);
-
+
for (i = 0; i < num_types; i++) {
e_data_server_module_add_type (types[i]);
}
e_data_server_module_load_file (const char *filename)
{
EDataServerModule *module;
-
+
module = g_object_new (E_DATA_SERVER_TYPE_MODULE, NULL);
module->path = g_strdup (filename);
-
+
if (g_type_module_use (G_TYPE_MODULE (module))) {
add_module_objects (module);
g_type_module_unuse (G_TYPE_MODULE (module));
load_module_dir (const char *dirname)
{
GDir *dir;
-
+
dir = g_dir_open (dirname, 0, NULL);
-
+
if (dir) {
const char *name;
-
+
while ((name = g_dir_read_name (dir))) {
if (g_str_has_suffix (name, "." G_MODULE_SUFFIX)) {
char *filename;
- filename = g_build_filename (dirname,
- name,
+ filename = g_build_filename (dirname,
+ name,
NULL);
e_data_server_module_load_file (filename);
g_free (filename);
if (!initialized) {
initialized = TRUE;
-
+
load_module_dir (E_DATA_SERVER_EXTENSIONDIR);
}
}
{
GList *l;
GList *ret = NULL;
-
+
for (l = module_objects; l != NULL; l = l->next) {
if (G_TYPE_CHECK_INSTANCE_TYPE (G_OBJECT (l->data),
type)) {
}
}
- return ret;
+ return ret;
}
void
e_data_server_extension_list_free (GList *extensions)
{
GList *l;
-
+
for (l = extensions; l != NULL; l = l->next) {
g_object_unref (l->data);
}
g_list_free (extensions);
}
-void
+void
e_data_server_module_add_type (GType type)
{
GObject *object;
g_message ("adding type `%s'", g_type_name (type));
object = g_object_new (type, NULL);
- g_object_weak_ref (object,
+ g_object_weak_ref (object,
(GWeakNotify)module_object_weak_notify,
NULL);
return NULL;
}
-/**
+/**
* e_util_unicode_get_utf8:
* @text: The string to take the UTF-8 character from.
* @out: The location to store the UTF-8 character in.
- *
+ *
* Get a UTF-8 character from the beginning of @text.
*
- * Returns: A pointer to the next character in @text after @out.
+ * Returns: A pointer to the next character in @text after @out.
**/
gchar *
e_util_unicode_get_utf8 (const gchar *text, gunichar *out)
return (*out == (gunichar)-1) ? NULL : g_utf8_next_char (text);
}
-/**
+/**
* e_util_utf8_strstrcase:
* @haystack: The string to search in.
* @needle: The string to search for.
- *
+ *
* Find the first instance of @needle in @haystack, ignoring case. (No
* proper case folding or decomposing is done.) Both @needle and
* @haystack are UTF-8 strings.
return 0;
}
-/**
+/**
* e_util_utf8_strstrcasedecomp:
* @haystack: The string to search in.
* @needle: The string to search for.
- *
+ *
* Find the first instance of @needle in @haystack, where both @needle
* and @haystack are UTF-8 strings. Both strings are stripped and
* decomposed for comparison, and case is ignored.
int retval;
g_return_val_if_fail (s1 != NULL && s2 != NULL, -1);
-
+
if (strcmp (s1, s2) == 0)
return 0;
return retval;
}
-/**
+/**
* e_strftime:
* @s: The string array to store the result in.
* @max: The size of array @s.
return ret;
}
-/**
+/**
* e_utf8_strftime:
* @s: The string array to store the result in.
* @max: The size of array @s.
*
* Returns: The number of characters placed in @s.
**/
-size_t
+size_t
e_utf8_strftime(char *s, size_t max, const char *fmt, const struct tm *tm)
{
size_t sz, ret;
const char *unsafe_chars = " /'\"`&();|<>$%{}!\\:*?#";
#else
const char *unsafe_chars = " /'\"`&();|<>$%{}!#";
-#endif
-
+#endif
+
g_return_if_fail (string != NULL);
p = string;
* written?
*/
if (!g_unichar_isprint(c) || ( c < 0xff && strchr (unsafe_chars, c&0xff ))) {
- while (ts<p)
+ while (ts<p)
*ts++ = '_';
}
}
gchar *p = strrchr (*full_prefix, '\\');
if (p != NULL)
*p = '\0';
-
+
p = strrchr (*full_prefix, '\\');
if (p && (g_ascii_strcasecmp (p + 1, "bin") == 0))
*p = '\0';
gchar *p = _mbsrchr (*cp_prefix, '\\');
if (p != NULL)
*p = '\0';
-
+
p = _mbsrchr (*cp_prefix, '\\');
if (p && (g_ascii_strcasecmp (p + 1, "bin") == 0))
*p = '\0';
static void
setup (void)
{
- char *full_pfx;
- char *cp_pfx;
+ char *full_pfx;
+ char *cp_pfx;
G_LOCK (mutex);
if (prefix != NULL) {
#include "db.h"
#include "md5-utils.h"
-struct _EDbHashPrivate
+struct _EDbHashPrivate
{
DB *db;
};
dbt->size = 16;
}
-void
+void
e_dbhash_add (EDbHash *edbh, const gchar *key, const gchar *data)
{
DB *db;
g_return_if_fail (data != NULL);
db = edbh->priv->db;
-
+
/* Key dbt */
string_to_dbt (key, &dkey);
db->put (db, NULL, &dkey, &ddata, 0);
}
-void
+void
e_dbhash_remove (EDbHash *edbh, const char *key)
{
DB *db;
DBT dkey;
-
+
g_return_if_fail (edbh != NULL);
g_return_if_fail (edbh->priv != NULL);
g_return_if_fail (key != NULL);
db = edbh->priv->db;
-
+
/* Key dbt */
string_to_dbt (key, &dkey);
db->del (db, NULL, &dkey, 0);
}
-void
+void
e_dbhash_foreach_key (EDbHash *edbh, EDbHashFunc func, gpointer user_data)
{
DB *db;
DBT ddata;
DBC *dbc;
int db_error = 0;
-
+
g_return_if_fail (edbh != NULL);
g_return_if_fail (edbh->priv != NULL);
g_return_if_fail (func != NULL);
DBT dkey;
DBT ddata;
guchar compare_hash[16];
-
+
g_return_val_if_fail (edbh != NULL, FALSE);
g_return_val_if_fail (edbh->priv != NULL, FALSE);
g_return_val_if_fail (key != NULL, FALSE);
g_return_val_if_fail (compare_hash != NULL, FALSE);
db = edbh->priv->db;
-
+
/* Key dbt */
string_to_dbt (key, &dkey);
/* Lookup in database */
memset (&ddata, 0, sizeof (DBT));
db->get (db, NULL, &dkey, &ddata, 0);
-
+
/* Compare */
if (ddata.data) {
md5_get_digest (compare_data, strlen (compare_data), compare_hash);
-
+
if (memcmp (ddata.data, compare_hash, sizeof (guchar) * 16))
return E_DBHASH_STATUS_DIFFERENT;
} else {
return E_DBHASH_STATUS_NOT_FOUND;
}
-
+
return E_DBHASH_STATUS_SAME;
}
e_dbhash_write (EDbHash *edbh)
{
DB *db;
-
+
g_return_if_fail (edbh != NULL);
g_return_if_fail (edbh->priv != NULL);
db = edbh->priv->db;
-
+
/* Flush database to disk */
db->sync (db, 0);
}
-void
+void
e_dbhash_destroy (EDbHash *edbh)
{
DB *db;
-
+
g_return_if_fail (edbh != NULL);
g_return_if_fail (edbh->priv != NULL);
db = edbh->priv->db;
-
+
/* Close datbase */
db->close (db, 0);
-
+
g_free (edbh->priv);
g_free (edbh);
}
priv = cache->priv;
/* FIXME: the property is being set twice. Need to investigate
- * why and fix. Until then, we just return when called the
+ * why and fix. Until then, we just return when called the
* second time*/
if (priv->filename)
return;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2007 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2007 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* e-iconv.c
* Copyright 2000, 2001, Ximian, Inc.
*
#include "iconv-detect.h"
-#define cd(x)
+#define cd(x)
#ifdef G_THREADS_ENABLED
static GStaticMutex lock = G_STATIC_MUTEX_INIT;
e_strdown (char *str)
{
register char *s = str;
-
+
while (*s) {
if (*s >= 'A' && *s <= 'Z')
*s += 0x20;
s++;
}
-
+
return str;
}
e_strup (char *str)
{
register char *s = str;
-
+
while (*s) {
if (*s >= 'a' && *s <= 'z')
*s -= 0x20;
s++;
}
-
+
return str;
}
locale_parse_lang (const char *locale)
{
char *codeset, *lang;
-
+
if ((codeset = strchr (locale, '.')))
lang = g_strndup (locale, codeset - locale);
else
lang = g_strdup (locale);
-
+
/* validate the language */
if (strlen (lang) >= 2) {
if (lang[2] == '-' || lang[2] == '_') {
/* canonicalise the lang */
e_strdown (lang);
-
+
/* validate the country code */
if (strlen (lang + 3) > 2) {
/* invalid country code */
g_free (lang);
lang = NULL;
}
-
+
locale_lang = lang;
} else {
/* invalid language */
}
iconv_charsets = g_hash_table_new(g_str_hash, g_str_equal);
-
+
for (i = 0; known_iconv_charsets[i].charset != NULL; i++) {
from = g_strdup(known_iconv_charsets[i].charset);
to = g_strdup(known_iconv_charsets[i].iconv_name);
e_dlist_init(&iconv_cache_list);
iconv_cache = g_hash_table_new(g_str_hash, g_str_equal);
iconv_cache_open = g_hash_table_new(NULL, NULL);
-
+
#ifndef G_OS_WIN32
locale = setlocale (LC_ALL, NULL);
#else
locale = g_win32_getlocale ();
#endif
-
+
if (!locale || !strcmp (locale, "C") || !strcmp (locale, "POSIX")) {
/* The locale "C" or "POSIX" is a portable locale; its
* LC_CTYPE part corresponds to the 7-bit ASCII character
* set.
*/
-
+
locale_charset = NULL;
locale_lang = NULL;
} else {
* ISO-8859-1 or UTF-8.
*/
char *codeset, *p;
-
+
codeset = strchr (locale, '.');
if (codeset) {
codeset++;
-
+
/* ; is a hack for debian systems and / is a hack for Solaris systems */
for (p = codeset; *p && !strchr ("@;/", *p); p++);
locale_charset = g_strndup (codeset, p - codeset);
/* charset unknown */
locale_charset = NULL;
}
-#endif
+#endif
#endif /* !G_OS_WIN32 */
-
+
/* parse the locale lang */
locale_parse_lang (locale);
name = g_alloca (strlen (charset) + 1);
strcpy (name, charset);
e_strdown (name);
-
+
e_iconv_init(TRUE);
ret = g_hash_table_lookup(iconv_charsets, name);
if (ret != NULL) {
/* Convert iso-nnnn-n or isonnnn-n or iso_nnnn-n to iso-nnnn-n or isonnnn-n */
int iso, codepage;
char *p;
-
+
tmp = name + 3;
if (*tmp == '-' || *tmp == '_')
tmp++;
-
+
iso = strtoul (tmp, &p, 10);
-
+
if (iso == 10646) {
/* they all become ICONV_10646 */
ret = g_strdup (ICONV_10646);
tmp = p;
if (*tmp == '-' || *tmp == '_')
tmp++;
-
+
codepage = strtoul (tmp, &p, 10);
-
+
if (p > tmp) {
/* codepage is numeric */
#ifdef __aix__
tmp = name+10;
if (!strncmp(tmp, "cp", 2))
tmp+=2;
- ret = g_strdup_printf("CP%s", tmp);
+ ret = g_strdup_printf("CP%s", tmp);
} else {
/* Just assume its ok enough as is, case and all */
ret = g_strdup(charset);
errno = EINVAL;
return (iconv_t) -1;
}
-
+
to = e_iconv_charset_name (oto);
from = e_iconv_charset_name (ofrom);
tofrom = g_alloca (strlen (to) + strlen (from) + 2);
}
iconv_cache_size++;
-
+
ic = g_malloc(sizeof(*ic));
e_dlist_init(&ic->open);
ic->conv = g_strdup(tofrom);
cd(printf("using existing iconv converter '%s'\n", ic->conv));
ip = in->ip;
if (ip != (iconv_t)-1) {
- /* work around some broken iconv implementations
- * that die if the length arguments are NULL
+ /* work around some broken iconv implementations
+ * that die if the length arguments are NULL
*/
size_t buggy_iconv_len = 0;
char *buggy_iconv_buf = NULL;
e_iconv_locale_language (void)
{
e_iconv_init (FALSE);
-
+
return locale_lang;
}
e_iconv_charset_language (const char *charset)
{
int i;
-
+
if (!charset)
return NULL;
-
+
charset = e_iconv_charset_name (charset);
for (i = 0; i < NUM_CJKR_LANGS; i++) {
if (!g_ascii_strcasecmp (cjkr_lang_map[i].charset, charset))
return cjkr_lang_map[i].lang;
}
-
+
return NULL;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* e-iconv.h
* Copyright 2000, 2001, Ximian, Inc.
*
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Authors:
+ * Authors:
* Christopher James Lahey <clahey@umich.edu>
*
* Copyright (C) 2000 Ximian, Inc.
}
/*
- * Virtual functions:
+ * Virtual functions:
*/
const void *
e_iterator_get (EIterator *iterator)
/* Signals */
void (*invalidate) (EIterator *iterator);
-
+
/* Virtual functions */
const void * (*get) (EIterator *iterator);
void (*reset) (EIterator *iterator);
void e_iterator_insert (EIterator *iterator,
const void *object,
gboolean before);
-void e_iterator_set (EIterator *iterator,
+void e_iterator_set (EIterator *iterator,
const void *object);
gboolean e_iterator_is_valid (EIterator *iterator);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Authors:
+ * Authors:
* Christopher James Lahey <clahey@umich.edu>
*
* Copyright (C) 2000 Ximian, Inc.
static void e_list_iterator_init (EListIterator *list);
static void e_list_iterator_class_init (EListIteratorClass *klass);
-
+
static void e_list_iterator_invalidate (EIterator *iterator);
static gboolean e_list_iterator_is_valid (EIterator *iterator);
static void e_list_iterator_set (EIterator *iterator,
}
/*
- * Virtual functions:
+ * Virtual functions:
*/
static void
e_list_iterator_dispose (GObject *object)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Authors:
+ * Authors:
* Christopher James Lahey <clahey@umich.edu>
*
* Copyright (C) 2000 Ximian, Inc.
list->iterators = g_list_remove(list->iterators, iterator);
}
-/*
- * Virtual functions
+/*
+ * Virtual functions
*/
static void
e_list_dispose (GObject *object)
GObjectClass parent_class;
};
-EList *e_list_new (EListCopyFunc copy,
+EList *e_list_new (EListCopyFunc copy,
EListFreeFunc free,
void *closure);
void e_list_construct (EList *list,
- EListCopyFunc copy,
+ EListCopyFunc copy,
EListFreeFunc free,
void *closure);
EList *e_list_duplicate (EList *list);
int e_list_length (EList *list);
/* For iterators to call. */
-void e_list_remove_link (EList *list,
+void e_list_remove_link (EList *list,
GList *link);
void e_list_remove_iterator (EList *list,
EIterator *iterator);
* Authors: Michael Zucchi <notzed@ximian.com>
* Jacob Berkman <jacob@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* e_memchunk_new:
* @atomcount: The number of atoms stored in a single malloc'd block of memory.
* @atomsize: The size of each allocation.
- *
+ *
* Create a new memchunk header. Memchunks are an efficient way to allocate
* and deallocate identical sized blocks of memory quickly, and space efficiently.
- *
+ *
* e_memchunks are effectively the same as gmemchunks, only faster (much), and
* they use less memory overhead for housekeeping.
*
/**
* memchunk_alloc:
- * @m:
- *
+ * @m:
+ *
* Allocate a new atom size block of memory from a memchunk.
**/
void *e_memchunk_alloc(MemChunk *m)
/**
* e_memchunk_free:
- * @m:
+ * @m:
* @mem: Address of atom to free.
- *
+ *
* Free a single atom back to the free pool of atoms in the given
* memchunk.
**/
/**
* e_memchunk_empty:
- * @m:
- *
+ * @m:
+ *
* Clean out the memchunk buffers. Marks all allocated memory as free blocks,
* but does not give it back to the system. Can be used if the memchunk
* is to be used repeatedly.
/**
* e_memchunk_clean:
- * @m:
- *
- * Scan all empty blocks and check for blocks which can be free'd
+ * @m:
+ *
+ * Scan all empty blocks and check for blocks which can be free'd
* back to the system.
*
* This routine may take a while to run if there are many allocated
while (ci) {
if (ci->count == m->blocksize) {
MemChunkFreeNode *prev = NULL;
-
+
f = m->free;
while (f) {
if (tree_search (ci, (void *) f) == 0) {
} else {
prev = f;
}
-
+
f = f->next;
}
-
+
g_ptr_array_remove_fast(m->blocks, ci->base);
g_free(ci->base);
}
/**
* e_memchunk_destroy:
- * @m:
- *
+ * @m:
+ *
* Free the memchunk header, and all associated memory.
**/
void
* struct alignment, E_MEMPOOL_ALIGN_WORD aligns to 16 bits (2 bytes),
* and E_MEMPOOL_ALIGN_BYTE aligns to the nearest byte. The default
* is to align to native structures.
- *
+ *
* Create a new mempool header. Mempools can be used to efficiently
* allocate data which can then be freed as a whole.
*
*
* However, each allocation cannot be freed individually, only all
* or nothing.
- *
- * Return value:
+ *
+ * Return value:
**/
MemPool *e_mempool_new(int blocksize, int threshold, EMemPoolFlags flags)
{
/**
* e_mempool_alloc:
- * @pool:
- * @size:
- *
+ * @pool:
+ * @size:
+ *
* Allocate a new data block in the mempool. Size will
* be rounded up to the mempool's alignment restrictions
* before being used.
/**
* e_mempool_flush:
- * @pool:
+ * @pool:
* @freeall: Free all system allocated blocks as well.
- *
+ *
* Flush used memory and mark allocated blocks as free.
*
* If @freeall is #TRUE, then all allocated blocks are free'd
/**
* e_mempool_destroy:
- * @pool:
- *
+ * @pool:
+ *
* Free all memory associated with a mempool.
**/
void e_mempool_destroy(MemPool *pool)
* e_strv_new:
* @size: The number of elements in the strv. Currently this is limited
* to 254 elements.
- *
+ *
* Create a new strv (string array) header. strv's can be used to
* create and work with arrays of strings that can then be compressed
* into a space-efficient static structure. This is useful
* The size limit is currently 254 elements. This will probably not
* change as arrays of this size suffer significant performance
* penalties when looking up strings with high indices.
- *
- * Return value:
+ *
+ * Return value:
**/
struct _EStrv *
e_strv_new(int size)
/**
* e_strv_set_ref:
- * @strv:
- * @index:
- * @str:
- *
+ * @strv:
+ * @index:
+ * @str:
+ *
* Set a string array element by reference. The string
* is not copied until the array is packed.
- *
+ *
* If @strv has been packed, then it is unpacked ready
* for more inserts, and should be packed again once finished with.
* The memory used by the original @strv is not freed until
/**
* e_strv_set_ref_free:
- * @strv:
- * @index:
- * @str:
- *
+ * @strv:
+ * @index:
+ * @str:
+ *
* Set a string by reference, similar to set_ref, but also
* free the string when finished with it. The string
* is not copied until the strv is packed, and not at
* all if the index is overwritten.
- *
+ *
* Return value: @strv if already unpacked, otherwise an packed
* EStrv.
**/
/**
* e_strv_set:
- * @strv:
- * @index:
- * @str:
- *
+ * @strv:
+ * @index:
+ * @str:
+ *
* Set a string array reference. The string @str is copied
* into the string array at location @index.
- *
+ *
* If @strv has been packed, then it is unpacked ready
* for more inserts, and should be packed again once finished with.
*
/**
* e_strv_pack:
- * @strv:
- *
+ * @strv:
+ *
* Pack the @strv into a space efficient structure for later lookup.
*
* All strings are packed into a single allocated block, separated
* by single \0 characters, together with a count byte.
- *
- * Return value:
+ *
+ * Return value:
**/
struct _EStrv *
e_strv_pack(struct _EStrv *strv)
/**
* e_strv_get:
- * @strv:
- * @index:
- *
+ * @strv:
+ * @index:
+ *
* Retrieve a string by index. This function works
* identically on both packed and unpacked strv's, although
* may be much slower on a packed strv.
- *
- * Return value:
+ *
+ * Return value:
**/
char *
e_strv_get(struct _EStrv *strv, int index)
/**
* e_strv_destroy:
- * @strv:
- *
+ * @strv:
+ *
* Free a strv and all associated memory. Works on packed
* or unpacked strv's.
**/
if (new_time - last_time < 5)
return;
- printf("poolv profile: %lu hits, %lu misses: %d%% hit rate, memory: %lu, instances: %lu\n",
- poolv_hits, poolv_misses,
+ printf("poolv profile: %lu hits, %lu misses: %d%% hit rate, memory: %lu, instances: %lu\n",
+ poolv_hits, poolv_misses,
(int)(100.0 * ((double) poolv_hits / (double) (poolv_hits + poolv_misses))),
poolv_mem, poolv_count);
}
time_end("allocating 1000000 malloc");
#endif
-
+
}
#endif
* Authors: Michael Zucchi <notzed@ximian.com>
* Jacob Berkman <jacob@ximian.com>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#ifndef G_OS_WIN32
if (pipe (fds) != -1)
return 0;
-
+
fds[0] = -1;
fds[1] = -1;
-
+
return -1;
#else
SOCKET temp, socket1 = -1, socket2 = -1;
struct timeval tv;
temp = socket (AF_INET, SOCK_STREAM, 0);
-
+
if (temp == INVALID_SOCKET) {
goto out0;
}
-
+
arg = 1;
if (ioctlsocket (temp, FIONBIO, &arg) == SOCKET_ERROR) {
goto out0;
}
socket1 = socket (AF_INET, SOCK_STREAM, 0);
-
+
if (socket1 == INVALID_SOCKET) {
goto out0;
}
arg = 1;
- if (ioctlsocket (socket1, FIONBIO, &arg) == SOCKET_ERROR) {
+ if (ioctlsocket (socket1, FIONBIO, &arg) == SOCKET_ERROR) {
goto out1;
}
out0:
closesocket (temp);
errno = EMFILE; /* FIXME: use the real syscall errno? */
-
+
fds[0] = -1;
fds[1] = -1;
-
+
return -1;
#endif
/**
* em_cache_new:
- * @timeout:
- * @nodesize:
- * @nodefree:
- *
+ * @timeout:
+ * @nodesize:
+ * @nodefree:
+ *
* Setup a new timeout cache. @nodesize is the size of nodes in the
* cache, and @nodefree will be called to free YOUR content.
- *
- * Return value:
+ *
+ * Return value:
**/
EMCache *
em_cache_new(time_t timeout, size_t nodesize, GFreeFunc nodefree)
/**
* em_cache_destroy:
- * @emc:
- *
+ * @emc:
+ *
* destroy the cache, duh.
**/
void
/**
* em_cache_lookup:
- * @emc:
- * @key:
- *
+ * @emc:
+ * @key:
+ *
* Lookup a cache node. once you're finished with it, you need to
* unref it.
- *
- * Return value:
+ *
+ * Return value:
**/
EMCacheNode *
em_cache_lookup(EMCache *emc, const char *key)
/**
* em_cache_node_new:
- * @emc:
- * @key:
- *
+ * @emc:
+ * @key:
+ *
* Create a new key'd cache node. The node will not be added to the
* cache until you insert it.
- *
- * Return value:
+ *
+ * Return value:
**/
EMCacheNode *
em_cache_node_new(EMCache *emc, const char *key)
/**
* em_cache_node_unref:
- * @emc:
- * @n:
- *
+ * @emc:
+ * @n:
+ *
* unref a cache node, you can only unref nodes which have been looked
* up.
**/
/**
* em_cache_add:
- * @emc:
- * @n:
- *
+ * @emc:
+ * @n:
+ *
* Add a cache node to the cache, once added the memory is owned by
* the cache. If there are conflicts and the old node is still in
* use, then the new node is not added, otherwise it is added and any
/**
* em_cache_clear:
- * @emc:
- *
+ * @emc:
+ *
* clear the cache. just for api completeness.
**/
void
if (PR_CreatePipe (&fds[0], &fds[1]) != PR_FAILURE)
return 0;
#endif
-
+
fds[0] = NULL;
fds[1] = NULL;
-
+
return -1;
}
#endif
msg = g_malloc0(sizeof(*msg));
msg->reply_port = E_THREAD_QUIT_REPLYPORT;
e_msgport_put(e->server_port, msg);
- l = l->next;
+ l = l->next;
}
/* then, wait for everyone to quit */
func = e->destroy;
func_data = e->destroy_data;
pthread_mutex_unlock(&e->mutex);
-
+
if (func)
func(e, m, func_data);
}
func = e->received;
func_data = e->received_data;
pthread_mutex_unlock(&e->mutex);
-
+
if (func)
func(e, m, func_data);
else
func = e->lost;
func_data = e->lost_data;
pthread_mutex_unlock(&e->mutex);
-
+
if (func)
func(e, m, func_data);
}
-/*
+/*
* Copyright 2000 Ximian (www.ximian.com).
*
* A simple, extensible s-exp evaluation engine.
*
- * Author :
+ * Author :
* Michael Zucchi <notzed@ximian.com>
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
G_CSET_LATINS
G_CSET_LATINC ) /* cset_identifier_nth */,
( ";\n" ) /* cpair_comment_single */,
-
+
FALSE /* case_sensitive */,
-
+
TRUE /* skip_comment_multi */,
TRUE /* skip_comment_single */,
TRUE /* scan_comment_multi */,
if (f->error)
g_free(f->error);
-
+
va_start(args, why);
f->error = g_strdup_vprintf(why, args);
va_end(args);
int type=-1;
int bool = TRUE;
int i;
-
+
r(printf("( and\n"));
r = e_sexp_result_new(f, ESEXP_RES_UNDEFINED);
-
+
for (i=0;bool && i<argc;i++) {
r1 = e_sexp_term_eval(f, argv[i]);
if (type == -1)
} else if (r1->type == ESEXP_RES_ARRAY_PTR) {
char **a1;
int l1, j;
-
+
a1 = (char **)r1->value.ptrarray->pdata;
l1 = r1->value.ptrarray->len;
for (j=0;j<l1;j++) {
}
e_sexp_result_free(f, r1);
}
-
+
if (type == ESEXP_RES_ARRAY_PTR) {
lambdafoo.count = argc;
lambdafoo.uids = g_ptr_array_new();
r->type = ESEXP_RES_BOOL;
r->value.bool = bool;
}
-
+
g_hash_table_destroy(ht);
-
+
return r;
}
int type = -1;
int bool = FALSE;
int i;
-
+
r(printf("(or \n"));
r = e_sexp_result_new(f, ESEXP_RES_UNDEFINED);
-
+
for (i=0;!bool && i<argc;i++) {
r1 = e_sexp_term_eval(f, argv[i]);
if (type == -1)
} else if (r1->type == ESEXP_RES_ARRAY_PTR) {
char **a1;
int l1, j;
-
+
a1 = (char **)r1->value.ptrarray->pdata;
l1 = r1->value.ptrarray->len;
for (j=0;j<l1;j++) {
g_hash_table_insert(ht, a1[j], (void *)1);
}
} else if (r1->type == ESEXP_RES_BOOL) {
- bool |= r1->value.bool;
+ bool |= r1->value.bool;
}
e_sexp_result_free(f, r1);
}
-
+
if (type == ESEXP_RES_ARRAY_PTR) {
lambdafoo.count = argc;
lambdafoo.uids = g_ptr_array_new();
r->value.bool = bool;
}
g_hash_table_destroy(ht);
-
+
return r;
}
struct _ESExpResult *r, *r1, *r2;
r = e_sexp_result_new(f, ESEXP_RES_UNDEFINED);
-
+
if (argc == 2) {
r1 = e_sexp_term_eval(f, argv[0]);
r2 = e_sexp_term_eval(f, argv[1]);
struct _ESExpResult *r, *r1, *r2;
r = e_sexp_result_new(f, ESEXP_RES_UNDEFINED);
-
+
if (argc == 2) {
r1 = e_sexp_term_eval(f, argv[0]);
r2 = e_sexp_term_eval(f, argv[1]);
struct _ESExpResult *r, *r1, *r2;
r = e_sexp_result_new(f, ESEXP_RES_BOOL);
-
+
if (argc == 2) {
r1 = e_sexp_term_eval(f, argv[0]);
r2 = e_sexp_term_eval(f, argv[1]);
eval_dump_result(ESExpResult *r, int depth)
{
int i;
-
+
if (r==NULL) {
printf("null result???\n");
return;
for (i=0;i<depth;i++)
printf(" ");
-
+
switch (t->type) {
case ESEXP_TERM_STRING:
printf(" \"%s\"", t->value.string);
if (t==NULL) {
return;
}
-
+
switch (t->type) {
case ESEXP_TERM_INT:
case ESEXP_TERM_BOOL:
p(printf("found %d subterms\n", size));
*len = size;
-
+
p(printf("done parsing values\n"));
return terms;
}
struct _ESExpTerm *t = NULL;
GScanner *gs = f->scanner;
struct _ESExpSymbol *s;
-
+
p(printf("parsing value\n"));
-
+
token = g_scanner_get_next_token(gs);
switch(token) {
case G_TOKEN_EOF:
e_sexp_fatal_error (f, "Invalid format for a integer value");
return NULL;
}
-
+
negative = TRUE;
/* fall through... */
case G_TOKEN_INT:
break;
case '#': {
char *str;
-
+
p(printf("got bool?\n"));
token = g_scanner_get_next_token(gs);
if (token != G_TOKEN_IDENTIFIER) {
e_sexp_fatal_error (f, "Invalid format for a boolean value");
return NULL;
}
-
+
str = g_scanner_cur_value (gs).v_identifier;
-
+
g_assert (str != NULL);
if (!(strlen (str) == 1 && (str[0] == 't' || str[0] == 'f'))) {
e_sexp_fatal_error (f, "Invalid format for a boolean value");
return NULL;
}
-
+
t = parse_term_new(f, ESEXP_TERM_BOOL);
t->value.bool = (str[0] == 't');
break; }
e_sexp_get_type (void)
{
static GType type = 0;
-
+
if (!type) {
static const GTypeInfo info = {
sizeof (ESExpClass),
0, /* n_preallocs */
(GInstanceInitFunc) e_sexp_init,
};
-
+
type = g_type_register_static (G_TYPE_OBJECT, "ESExp", &info, 0);
}
-
+
return type;
}
#endif
ESExp *f = g_malloc0 (sizeof (ESExp));
e_sexp_init (f);
#endif
-
+
return f;
}
/**
* e_sexp_encode_bool:
- * @s:
- * @state:
- *
+ * @s:
+ * @state:
+ *
* Encode a bool into an s-expression @s. Bools are
* encoded using #t #f syntax.
**/
* e_sexp_encode_string:
* @s: Destination string.
* @string: String expression.
- *
+ *
* Add a c string @string to the s-expression stored in
* the gstring @s. Quotes are added, and special characters
* are escaped appropriately.
#endif
GScanner *scanner; /* for parsing text version */
ESExpTerm *tree; /* root of expression tree */
-
+
/* private stuff */
jmp_buf failenv;
char *error;
-
+
/* TODO: may also need a pool allocator for term strings, so we dont lose them
in error conditions? */
struct _EMemChunk *term_chunks;
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
- signals[CHANGED] =
+ signals[CHANGED] =
g_signal_new ("changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- signals[SOURCE_ADDED] =
+ signals[SOURCE_ADDED] =
g_signal_new ("source_added",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
- signals[SOURCE_REMOVED] =
+ signals[SOURCE_REMOVED] =
g_signal_new ("source_removed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
e_source_group_set_name (new, GC name);
e_source_group_set_base_uri (new, GC base_uri);
-
+
for (p = root->children; p != NULL; p = p->next) {
ESource *new_source;
g_return_val_if_fail (E_IS_SOURCE_GROUP (group), FALSE);
g_return_val_if_fail (xml != NULL, FALSE);
-
+
xmldoc = xmlParseDoc (XC xml);
success = e_source_group_update_from_xmldoc (group, xmldoc, changed_return);
g_free, g_free);
changed = TRUE;
}
-
+
new_sources_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
for (nodep = root->children; nodep != NULL; nodep = nodep->next) {
xmlNodePtr root = doc->children;
xmlChar *name;
char *retval;
-
+
if (root && root->name) {
if (strcmp (GC root->name, "group") != 0)
return NULL;
}
- else
+ else
return NULL;
name = xmlGetProp (root, XC "uid");
if (group->priv->readonly)
return;
-
+
if (group->priv->name != NULL &&
strcmp (group->priv->name, name) == 0)
return;
{
g_return_if_fail (E_IS_SOURCE_GROUP (group));
g_return_if_fail (base_uri != NULL);
-
+
if (group->priv->readonly)
return;
-
+
if (group->priv->base_uri == base_uri)
return;
gboolean readonly)
{
GSList *i;
-
+
g_return_if_fail (E_IS_SOURCE_GROUP (group));
-
+
if (group->priv->readonly)
return;
-
+
if (group->priv->readonly == readonly)
return;
group->priv->readonly = readonly;
for (i = group->priv->sources; i != NULL; i = i->next)
- e_source_set_readonly (E_SOURCE (i->data), readonly);
+ e_source_set_readonly (E_SOURCE (i->data), readonly);
g_signal_emit (group, signals[CHANGED], 0);
}
if (group->priv->readonly)
return FALSE;
-
+
if (e_source_group_peek_source_by_uid (group, e_source_peek_uid (source)) != NULL)
return FALSE;
if (group->priv->readonly)
return FALSE;
-
+
for (p = group->priv->sources; p != NULL; p = p->next) {
ESource *source = E_SOURCE (p->data);
properties_node = xmlNewChild (root, NULL, XC "properties", NULL);
g_hash_table_foreach (group->priv->properties, (GHFunc) property_dump_cb, properties_node);
}
-
+
xmlDocSetRootElement (doc, root);
for (p = group->priv->sources; p != NULL; p = p->next)
/* FIXME if the order changes, the function doesn't notice. */
- if (changed)
+ if (changed)
g_signal_emit (list, signals[CHANGED], 0);
}
g_source_remove (priv->sync_idle_id);
priv->sync_idle_id = 0;
-
+
if (! e_source_list_sync (E_SOURCE_LIST (object), &error))
g_warning ("Could not update \"%s\": %s",
priv->gconf_path, error->message);
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
- signals[CHANGED] =
+ signals[CHANGED] =
g_signal_new ("changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- signals[GROUP_REMOVED] =
+ signals[GROUP_REMOVED] =
g_signal_new ("group_removed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
- signals[GROUP_ADDED] =
+ signals[GROUP_ADDED] =
g_signal_new ("group_added",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
/* returns the type */
static GType
-get_source_list_type (void)
+get_source_list_type (void)
{
static GType type = 0;
-
+
if (!type) {
if (!(type = g_type_from_name ("ESourceList")))
type = e_source_list_get_type ();
ESourceList *
e_source_list_new_for_gconf_default (const char *path)
-{
+{
ESourceList *list;
g_return_val_if_fail (path != NULL, NULL);
for (p = list->priv->groups; p != NULL; p = p->next) {
ESourceGroup *group = E_SOURCE_GROUP (p->data);
ESource *source;
-
+
source = e_source_group_peek_source_by_uid (group, uid);
if (source)
return source;
for (p = list->priv->groups; p != NULL; p = p->next) {
ESourceGroup *group = E_SOURCE_GROUP (p->data);
GSList *sources;
-
+
sources = e_source_group_peek_sources (group);
if (sources && sources->data)
return E_SOURCE (sources->data);
const char *uid)
{
ESourceGroup *group;
-
+
g_return_val_if_fail (E_IS_SOURCE_LIST (list), FALSE);
g_return_val_if_fail (uid != NULL, FALSE);
const char *uid)
{
GSList *p;
-
+
g_return_val_if_fail (E_IS_SOURCE_LIST (list), FALSE);
g_return_val_if_fail (uid != NULL, FALSE);
for (p = list->priv->groups; p != NULL; p = p->next) {
ESourceGroup *group = E_SOURCE_GROUP (p->data);
ESource *source;
-
+
source = e_source_group_peek_source_by_uid (group, uid);
if (source)
return e_source_group_remove_source_by_uid (group, uid);
GSList *conf_list = NULL, *temp = NULL, *p = NULL;
xmlDocPtr xmldoc;
ESourceGroup *group = NULL;
- GSList *groups = NULL;
+ GSList *groups = NULL;
gboolean conf_to_list = TRUE, list_to_conf = TRUE;
-
+
g_return_val_if_fail (list != NULL, FALSE);
conf_list = gconf_client_get_list (list->priv->gconf_client,
break;
}
} else {
- conf_to_list = FALSE;
+ conf_to_list = FALSE;
break;
}
}
g_slist_free (conf_list);
return FALSE;
}
-
+
groups = e_source_list_peek_groups (list);
-
- /* From list to conf */
+
+ /* From list to conf */
for (p = groups ; p != NULL; p = p->next) {
group = E_SOURCE_GROUP (p->data);
if (strcmp (gconf_xml, source_group_xml))
continue;
else
- break;
+ break;
}
g_free (source_group_xml);
/* If there is mismatch return FALSE */
if (!list_to_conf)
return FALSE;
-
+
return TRUE;
}
char *absolute_uri;
gboolean readonly;
-
+
gchar *color_spec;
GHashTable *properties;
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
- signals[CHANGED] =
+ signals[CHANGED] =
g_signal_new ("changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
* e_source_update_from_xml_node:
* @source: An ESource.
* @node: A pointer to the node to parse.
- *
+ *
* Update the ESource properties from @node.
- *
+ *
* Return value: %TRUE if the data in @node was recognized and parsed into
* acceptable values for @source, %FALSE otherwise.
**/
g_free, g_free);
changed = TRUE;
}
-
+
for (node = node->children; node; node = node->next) {
if (!node->name)
continue;
}
retval = TRUE;
-
+
done:
if (changed)
g_signal_emit (source, signals[CHANGED], 0);
/**
* e_source_name_from_xml_node:
* @node: A pointer to an XML node.
- *
+ *
* Assuming that @node is a valid ESource specification, retrieve the name of
* the source from it.
- *
+ *
* Return value: Name of the source in the specified @node. The caller must
* free the string.
**/
gchar *uri_str;
g_return_val_if_fail (source->priv->group != NULL, NULL);
-
+
base_uri_str = e_source_group_peek_base_uri (source->priv->group);
/* If last character in base URI is a slash, just concat the
if (source->priv->readonly)
return;
-
+
if (source->priv->group == group)
return;
if (source->priv->readonly)
return;
-
+
if (source->priv->name != NULL &&
strcmp (source->priv->name, name) == 0)
return;
if (source->priv->readonly)
return;
-
+
if (source->priv->relative_uri == relative_uri)
return;
source->priv->relative_uri = g_strdup (relative_uri);
/* reset the absolute uri */
- if (source->priv->absolute_uri &&
+ if (source->priv->absolute_uri &&
(absolute_uri = e_source_build_absolute_uri (source))) {
g_free (source->priv->absolute_uri);
source->priv->absolute_uri = absolute_uri;
source->priv->readonly = readonly;
g_signal_emit (source, signals[CHANGED], 0);
-
+
}
void
/**
* e_source_peek_color_spec:
* @source: an ESource
- *
+ *
* Return the textual representation of the color for @source, or %NULL if it
* has none. The returned string should be parsable by #gdk_color_parse().
- *
+ *
* Return value: a string specifying the color
*
* Since: 1.10
* @source: An ESource
* @color_return: Pointer to a variable where the returned color will be
* stored.
- *
+ *
* If @source has an associated color, return it in *@color_return.
- *
+ *
* Return value: %TRUE if the @source has a defined color (and hence
* *@color_return was set), %FALSE otherwise.
**/
{
int nbytes = GetLocaleInfo (GetThreadLocale (), lctype, NULL, 0);
char *tem;
- GQuark quark;
+ GQuark quark;
if (nbytes == 0)
return "???";
get_locale_string (LOCALE_STIMEFORMAT),
NULL);
const char *posix_d_t_fmt = translate_picture (d_t_fmt);
-
+
g_free (d_t_fmt);
-
+
if (!recursive (posix_d_t_fmt))
{
if (*decided == loc)
result->tm_isdst = -1;
return E_TIME_PARSE_NONE;
}
-
+
locale_str = g_locale_from_utf8 (value, -1, NULL, NULL, NULL);
pos = (const char *) locale_str;
if (!locale_str)
return E_TIME_PARSE_INVALID;
-
+
/* Skip whitespace */
while (n = (int)((unsigned char)*pos), isspace (n) != 0)
pos++;
case the user can choose between 12 and 24-hour time formats. */
static gboolean
locale_supports_12_hour_format (void)
-{
+{
struct tm tmp_tm = { 0 };
char s[16];
* formats with am/pm can be used.
*
* Returns: E_TIME_PARSE_OK if the string was successfully parsed,
- * E_TIME_PARSE_NONE if the string was empty, or
+ * E_TIME_PARSE_NONE if the string was empty, or
* E_TIME_PARSE_INVALID if the string could not be parsed.
*/
ETimeParseStatus
format[num_formats++] = _("%a %m/%d/%Y %I:%M:%S %p");
}
- /* strptime format of a weekday, a date and a time,
+ /* strptime format of a weekday, a date and a time,
in 24-hour format. */
format[num_formats++] = _("%a %m/%d/%Y %H:%M:%S");
* e_time_parse_date:
* @value: A date string.
* @result: Return value for the parsed date.
- *
+ *
* Takes in a date string entered by the user and tries to convert it to
* a struct #tm.
- *
+ *
* Returns: An #ETimeParseStatus result code indicating whether
* @value was an empty string, a valid date, or an invalid date.
**/
/* according to the current locale */
format [0] = ("%x");
-
+
/* strptime format of a weekday and a date. */
format[1] = _("%a %m/%d/%Y");
if (result->tm_year < 0) {
t = time (NULL);
today_tm = localtime (&t);
-
+
/* This should convert it into a value from 0 to 99. */
result->tm_year += 1900;
-
+
/* Now add on the century. */
result->tm_year += today_tm->tm_year
- (today_tm->tm_year % 100);
}
}
-
+
return status;
}
* @show_zero_seconds: A #gboolean.
* @buffer: The #char buffer to store the result in.
* @buffer_size: The length of @buffer.
- *
+ *
* Creates a string representation of a time value in @date_tm and
* stores it in @buffer. @buffer_size should be at least 64.
**/
/* strftime format of a time in 12-hour format. */
format = _("%I:%M:%S %p");
}
-
+
/* strftime returns 0 if the string doesn't fit, and leaves the buffer
undefined, so we set it to the empty string in that case. */
if (e_utf8_strftime (buffer, buffer_size, format, date_tm) == 0)
/**
* e_mktime_utc:
* @tm: The #tm to convert to a calendar time representation.
- *
+ *
* Like mktime(3), but assumes UTC instead of local timezone.
- *
+ *
* Returns: The calendar time representation of @tm.
**/
time_t
* @E_TIME_PARSE_OK: The time string was parsed successfully.
* @E_TIME_PARSE_NONE: The time string was empty.
* @E_TIME_PARSE_INVALID: The time string was not formatted correctly.
- **/
+ **/
typedef enum {
E_TIME_PARSE_OK,
E_TIME_PARSE_NONE,
struct _trie_state root;
GPtrArray *fail_states;
gboolean icase;
-
+
EMemChunk *match_chunks;
EMemChunk *state_chunks;
};
const unsigned char *inend = inptr + inlen;
register unsigned char c, r;
register gunichar u, m;
-
+
if (inlen == 0)
return 0;
-
+
r = *inptr++;
if (r < 0x80) {
*in = inptr;
do {
if (inptr >= inend)
return 0;
-
+
c = *inptr++;
if ((c & 0xc0) != 0x80)
goto error;
-
+
u = (u << 6) | (c & 0x3f);
r <<= 1;
m <<= 5;
} while (r & 0x40);
-
+
*in = inptr;
-
+
u &= ~m;
} else {
error:
*in = (*in)+1;
u = 0xfffe;
}
-
+
return u;
}
e_trie_new (gboolean icase)
{
ETrie *trie;
-
+
trie = g_new (ETrie, 1);
trie->root.next = NULL;
trie->root.fail = NULL;
trie->root.match = NULL;
trie->root.final = 0;
-
+
trie->fail_states = g_ptr_array_sized_new (8);
trie->icase = icase;
-
+
trie->match_chunks = e_memchunk_new (8, sizeof (struct _trie_match));
trie->state_chunks = e_memchunk_new (8, sizeof (struct _trie_state));
-
+
return trie;
}
g (struct _trie_state *s, gunichar c)
{
struct _trie_match *m = s->match;
-
+
while (m && m->c != c)
m = m->next;
-
+
return m;
}
trie_insert (ETrie *trie, int depth, struct _trie_state *q, gunichar c)
{
struct _trie_match *m;
-
+
m = e_memchunk_alloc (trie->match_chunks);
m->next = q->match;
m->c = c;
-
+
q->match = m;
q = m->state = e_memchunk_alloc (trie->state_chunks);
q->match = NULL;
q->fail = &trie->root;
q->final = 0;
q->id = -1;
-
+
if (trie->fail_states->len < depth + 1) {
unsigned int size = trie->fail_states->len;
-
+
size = MAX (size + 64, depth + 1);
g_ptr_array_set_size (trie->fail_states, size);
}
-
+
q->next = trie->fail_states->pdata[depth];
trie->fail_states->pdata[depth] = q;
-
+
return q;
}
#if 1
-static void
+static void
dump_trie (struct _trie_state *s, int depth)
{
char *p = g_alloca ((depth * 2) + 1);
struct _trie_match *m;
-
+
memset (p, ' ', depth * 2);
p[depth * 2] = '\0';
-
+
fprintf (stderr, "%s[state] %p: final=%d; pattern-id=%d; fail=%p\n",
p, s, s->final, s->id, s->fail);
m = s->match;
fprintf (stderr, " %s'%c' -> %p\n", p, m->c, m->state);
if (m->state)
dump_trie (m->state, depth + 1);
-
+
m = m->next;
}
}
struct _trie_match *m, *n;
int i, depth = 0;
gunichar c;
-
+
/* Step 1: add the pattern to the trie */
-
+
q = &trie->root;
-
+
while ((c = trie_utf8_getc (&inptr, -1))) {
if (trie->icase)
c = g_unichar_tolower (c);
-
+
m = g (q, c);
if (m == NULL) {
q = trie_insert (trie, depth, q, c);
} else {
q = m->state;
}
-
+
depth++;
}
-
+
q->final = depth;
q->id = pattern_id;
-
+
/* Step 2: compute failure graph */
-
+
for (i = 0; i < trie->fail_states->len; i++) {
q = trie->fail_states->pdata[i];
while (q) {
r = q->fail;
while (r && (n = g (r, c)) == NULL)
r = r->fail;
-
+
if (r != NULL) {
q1->fail = n->state;
if (q1->fail->final > q1->final)
else
q1->fail = &trie->root;
}
-
+
m = m->next;
}
-
+
q = q->next;
}
}
-
+
d(fprintf (stderr, "\nafter adding pattern '%s' to trie %p:\n", pattern, trie));
d(dump_trie (&trie->root, 0));
}
struct _trie_state *q;
struct _trie_match *m = NULL; /* init to please gcc */
gunichar c;
-
+
inptr = (const unsigned char *) buffer;
inend = inptr + buflen;
-
+
q = &trie->root;
pat = prev = inptr;
while ((c = trie_utf8_getc (&inptr, inlen))) {
inlen = (inend - inptr);
-
+
if (c != 0xfffe) {
if (trie->icase)
c = g_unichar_tolower (c);
-
+
while (q != NULL && (m = g (q, c)) == NULL)
q = q->fail;
-
+
if (q == &trie->root)
pat = prev;
-
+
if (q == NULL) {
q = &trie->root;
pat = inptr;
} else if (m != NULL) {
q = m->state;
-
+
if (q->final) {
if (matched_id)
*matched_id = q->id;
-
+
return (const char *) pat;
}
}
}
-
+
prev = inptr;
}
-
+
return NULL;
}
/**
* e_uid_new:
- *
+ *
* Generate a new unique string for use e.g. in account lists.
- *
+ *
* Return value: The newly generated UID. The caller should free the string
* when it's done with it.
**/
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser 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
const char *last_at = NULL;
const char *p;
char *shrouded;
-
+
if (url == NULL)
return NULL;
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2001-2003 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or
/**
* e_xml_to_hash:
- * @doc: The #xmlDoc to store in a hash table.
+ * @doc: The #xmlDoc to store in a hash table.
* @type: The value type to use as a key in the hash table.
*
* Creates a #GHashTable representation of the #xmlDoc @doc.
doc = e_xml_parse_file (filename);
if (!doc) {
e_xmlhash_destroy (hash);
-
+
return NULL;
}
hash->objects = e_xml_to_hash (doc, E_XML_HASH_TYPE_OBJECT_UID);
} else {
hash->objects = g_hash_table_new (g_str_hash, g_str_equal);
}
-
+
return hash;
}
*
* Returns: E_XMLHASH_STATUS_SAME if the value and @compare_data are
* equal,E_XMLHASH_STATUS_DIFFERENT if they are different, or
- * E_XMLHASH_STATUS_NOT_FOUND if there is no entry in @hash with
+ * E_XMLHASH_STATUS_NOT_FOUND if there is no entry in @hash with
* its key equal to @key.
**/
EXmlHashStatus
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2001-2003 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2005 Novell, Inc.
*
* This program is free software; you can redistribute it and/or
filesave = g_build_filename (dirname, savebasename, NULL);
g_free (savebasename);
g_free (dirname);
-
+
fd = g_open (filesave, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0600);
if (fd == -1) {
g_free (filesave);
return -1;
}
-
+
xmlDocDumpFormatMemory (doc, &xmlbuf, &size, TRUE);
if (size <= 0) {
close (fd);
errno = ENOMEM;
return -1;
}
-
+
n = (size_t) size;
do {
do {
w = write (fd, xmlbuf + written, n - written);
} while (w == -1 && errno == EINTR);
-
+
if (w > 0)
written += w;
} while (w != -1 && written < n);
-
+
xmlFree (xmlbuf);
-
+
if (written < n || fsync (fd) == -1) {
errnosave = errno;
close (fd);
while ((ret = close (fd)) == -1 && errno == EINTR)
;
-
+
if (ret == -1) {
g_free (filesave);
return -1;
}
-
+
if (g_rename (filesave, filename) == -1) {
errnosave = errno;
g_unlink (filesave);
return -1;
}
g_free (filesave);
-
+
return 0;
}
g_return_val_if_fail (parent != NULL, NULL);
g_return_val_if_fail (child_name != NULL, NULL);
-
+
for (child = parent->xmlChildrenNode; child != NULL; child = child->next) {
if (xmlStrcmp (child->name, child_name) == 0) {
return child;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2005 Novell, Inc.
*
* This program is free software; you can redistribute it and/or
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* libedataserver-private.h: For e-d-s (not just libedataserver)
* Copyright 2005, Novell, Inc.
*
/*
* Note: this code is not required on little-endian machines.
*/
-static void
+static void
_byte_reverse (guchar *buf, guint32 longs)
{
guint32 t;
/**
* md5_init: Initialise an md5 context object
- * @ctx: md5 context
- *
- * Initialise an md5 buffer.
+ * @ctx: md5 context
+ *
+ * Initialise an md5 buffer.
*
**/
-void
+void
md5_init (MD5Context *ctx)
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
-
+
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
* @ctx: context object used for md5 computaion
* @buf: buffer to add
* @len: buffer length
- *
+ *
* Update context to reflect the concatenation of another buffer full
* of bytes. Use this to progressively construct an md5 hash.
**/
-void
+void
md5_update (MD5Context *ctx, const guchar *buf, guint32 len)
{
guint32 t;
-
+
/* Update bitcount */
-
+
t = ctx->bits[0];
if ((ctx->bits[0] = t + ((guint32) len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
-
+
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
-
+
/* Handle any leading odd-sized chunks */
-
+
if (t) {
guchar *p = (guchar *) ctx->in + t;
-
+
t = 64 - t;
if (len < t) {
memcpy (p, buf, len);
len -= t;
}
/* Process data in 64-byte chunks */
-
+
while (len >= 64) {
memcpy (ctx->in, buf, 64);
#if G_BYTE_ORDER == G_BIG_ENDIAN
buf += 64;
len -= 64;
}
-
+
/* Handle any remaining bytes of data. */
-
+
memcpy (ctx->in, buf, len);
}
/*
- * Final wrapup - pad to 64-byte boundary with the bit pattern
+ * Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
/**
* md5_final: copy the final md5 hash to a bufer
* @digest: 16 bytes buffer
* @ctx: context containing the calculated md5
- *
+ *
* copy the final md5 hash to a bufer
**/
-void
+void
md5_final (MD5Context *ctx, guchar digest[16])
{
guint32 count;
guchar *p;
-
+
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
-
+
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
p = ctx->in + count;
*p++ = 0x80;
-
+
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
-
+
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
_byte_reverse (ctx->in, 16);
#endif
md5_transform (ctx->buf, (guint32 *) ctx->in);
-
+
/* Now fill the next block with 56 bytes */
memset (ctx->in, 0, 56);
} else {
#if G_BYTE_ORDER == G_BIG_ENDIAN
_byte_reverse (ctx->in, 14);
#endif
-
+
/* Append length in bits and transform */
((guint32 *) ctx->in)[14] = ctx->bits[0];
((guint32 *) ctx->in)[15] = ctx->bits[1];
-
+
md5_transform (ctx->buf, (guint32 *) ctx->in);
#if G_BYTE_ORDER == G_BIG_ENDIAN
_byte_reverse ((guchar *) ctx->buf, 4);
* reflect the addition of 16 longwords of new data. md5_Update blocks
* the data and converts bytes into longwords for this routine.
*/
-static void
+static void
md5_transform (guint32 buf[4], const guint32 in[16])
{
register guint32 a, b, c, d;
-
+
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
-
+
MD5STEP (F1, a, b, c, d, in[0] + 0xd76aa478, 7);
MD5STEP (F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
MD5STEP (F1, c, d, a, b, in[2] + 0x242070db, 17);
MD5STEP (F1, d, a, b, c, in[13] + 0xfd987193, 12);
MD5STEP (F1, c, d, a, b, in[14] + 0xa679438e, 17);
MD5STEP (F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
+
MD5STEP (F2, a, b, c, d, in[1] + 0xf61e2562, 5);
MD5STEP (F2, d, a, b, c, in[6] + 0xc040b340, 9);
MD5STEP (F2, c, d, a, b, in[11] + 0x265e5a51, 14);
MD5STEP (F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
MD5STEP (F2, c, d, a, b, in[7] + 0x676f02d9, 14);
MD5STEP (F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
+
MD5STEP (F3, a, b, c, d, in[5] + 0xfffa3942, 4);
MD5STEP (F3, d, a, b, c, in[8] + 0x8771f681, 11);
MD5STEP (F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
MD5STEP (F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
MD5STEP (F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
MD5STEP (F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
+
MD5STEP (F4, a, b, c, d, in[0] + 0xf4292244, 6);
MD5STEP (F4, d, a, b, c, in[7] + 0x432aff97, 10);
MD5STEP (F4, c, d, a, b, in[14] + 0xab9423a7, 15);
MD5STEP (F4, d, a, b, c, in[11] + 0xbd3af235, 10);
MD5STEP (F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
MD5STEP (F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
+
buf[0] += a;
buf[1] += b;
buf[2] += c;
* @buffer: byte buffer
* @buffer_size: buffer size (in bytes)
* @digest: 16 bytes buffer receiving the hash code.
- *
- * Get the md5 hash of a buffer. The result is put in
+ *
+ * Get the md5 hash of a buffer. The result is put in
* the 16 bytes buffer @digest .
**/
void
md5_get_digest (const gchar *buffer, gint buffer_size, guchar digest[16])
-{
+{
MD5Context ctx;
md5_init (&ctx);
md5_update (&ctx, (guchar*)buffer, buffer_size);
md5_final (&ctx, digest);
-
+
}
* md5_get_digest_from_file: get the md5 hash of a file
* @filename: file name
* @digest: 16 bytes buffer receiving the hash code.
- *
- * Get the md5 hash of a file. The result is put in
+ *
+ * Get the md5 hash of a file. The result is put in
* the 16 bytes buffer @digest .
**/
void
md5_get_digest_from_file (const gchar *filename, guchar digest[16])
-{
+{
MD5Context ctx;
guchar tmp_buf[1024];
gint nb_bytes_read;
if (!fp) {
return;
}
-
+
while ((nb_bytes_read = fread (tmp_buf, 1, sizeof (tmp_buf), fp)) > 0)
md5_update (&ctx, tmp_buf, nb_bytes_read);
-
+
if (ferror(fp)) {
fclose(fp);
return;
}
fclose(fp);
-
+
md5_final (&ctx, digest);
}
fprintf (stderr, "No such group \"%s\".\n", group_arg);
exit (1);
}
- }
+ }
e_source_list_sync (list, NULL);
}
if (source_arg == NULL) {
fprintf (stderr,
- "When using --set-relative-uri, you need to specify a source using "
+ "When using --set-relative-uri, you need to specify a source using "
"--source.\n");
exit (1);
}
if (add_source_arg == NULL && source_arg == NULL) {
fprintf (stderr,
- "When using --unset-color, you need to specify a source using --source\n");
+ "When using --unset-color, you need to specify a source using --source\n");
exit (1);
}
GtkWidget *dialog;
/* XXX "LDAP" has to be removed from the folowing message
- so that it wil valid for other servers which provide
+ so that it wil valid for other servers which provide
anonymous access*/
dialog = gtk_message_dialog_new (NULL,
addressbook_authenticate (book, TRUE, data->source, load_source_auth_cb, closure);
g_free (stripped_uri);
-
+
return;
}
}
const gchar *uri = e_book_get_uri (book);
gchar *stripped_uri = remove_parameters_from_uri (uri);
const gchar *auth_domain = e_source_get_property (source, "auth-domain");
-
+
component_name = auth_domain ? auth_domain : "Addressbook";
uri = stripped_uri;
auth_required_cb (EBook *book, gpointer data)
{
LoadSourceData *load_source_data = g_new0 (LoadSourceData, 1);
-
+
load_source_data->source = g_object_ref (g_object_ref (e_book_get_source (book)));
addressbook_authenticate (book, FALSE, load_source_data->source,
auth = e_source_get_property (load_source_data->source, "auth");
if (auth && strcmp (auth, "none")) {
g_signal_connect (book, "auth_required", (GCallback) auth_required_cb, NULL);
-
+
if (e_book_is_online (book)) {
addressbook_authenticate (book, FALSE, load_source_data->source,
load_source_auth_cb, closure);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2005 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
gtk_tree_model_get (model, &iter, COLUMN_CATEGORY, &category_name, -1);
gtk_entry_set_text (GTK_ENTRY (prop_dialog->category_name), category_name);
gtk_widget_set_sensitive (prop_dialog->category_name, FALSE);
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (prop_dialog->category_icon),
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (prop_dialog->category_icon),
e_categories_get_icon_file_for (category_name));
if (gtk_dialog_run (GTK_DIALOG (prop_dialog->the_dialog)) == GTK_RESPONSE_OK) {
if (icon_file)
icon = gdk_pixbuf_new_from_file (icon_file, NULL);
gtk_list_store_append (model, &iter);
- gtk_list_store_set (model, &iter,
+ gtk_list_store_set (model, &iter,
COLUMN_ACTIVE, FALSE,
COLUMN_ICON, icon,
COLUMN_CATEGORY, cat_list->data,
if (initial_category_list)
e_categories_dialog_set_categories (dialog, initial_category_list);
- g_signal_connect (G_OBJECT (dialog->priv->categories_entry), "changed",
+ g_signal_connect (G_OBJECT (dialog->priv->categories_entry), "changed",
G_CALLBACK (entry_changed_cb), dialog);
return GTK_WIDGET (dialog);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2005 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
calc_width = (gint) cell->xpad * 2 + color_width;
calc_height = (gint) cell->ypad * 2 + color_height;
-
+
if (cell_area && color_width > 0 && color_height > 0) {
if (x_offset) {
*x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
- (1.0 - cell->xalign) : cell->xalign) *
+ (1.0 - cell->xalign) : cell->xalign) *
(cell_area->width - calc_width));
*x_offset = MAX (*x_offset, 0);
}
gdk_colormap_alloc_color (
gdk_colormap_get_system(), priv->color, FALSE, TRUE);
-
+
gc = gdk_gc_new (window);
gdk_gc_set_foreground (gc, priv->color);
gdk_draw_rectangle (
ECellRendererColorPrivate *priv;
priv = E_CELL_RENDERER_COLOR_GET_PRIVATE (object);
-
+
switch (property_id) {
case PROP_COLOR:
if (priv->color != NULL)
/* However, if it was a pending view, calculate and emit the differences between that
* and the current view, and move the pending view up to current.
- *
+ *
* This is O(m * n), and can be sped up with a temporary hash table if needed. */
/* Deletions */
* @iter: a destination #GtkTreeIter to set
*
* Sets @iter to point to the contact row matching @uid.
- *
+ *
* Return value: %TRUE if the contact was found, and @iter was set. %FALSE otherwise.
**/
gboolean
EDestination *destination = g_ptr_array_index (destination_store->destinations, i);
destination_list = g_list_prepend (destination_list, destination);
}
-
+
destination_list = g_list_reverse(destination_list);
return destination_list;
e_destination_store_remove_destination_nth (EDestinationStore *destination_store, int n)
{
EDestination *destination;
-
+
g_return_if_fail ( n >= 0);
destination = g_ptr_array_index(destination_store->destinations, n);
EDestination *destination);
void e_destination_store_remove_destination (EDestinationStore *destination_store,
EDestination *destination);
-void e_destination_store_remove_destination_nth (EDestinationStore *destination_store,
+void e_destination_store_remove_destination_nth (EDestinationStore *destination_store,
int n);
guint e_destination_store_get_destination_count (EDestinationStore *destination_store);
GtkTreePath *e_destination_store_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter);
gchar *name;
GtkBox *section_box;
- GtkLabel *label;
+ GtkLabel *label;
GtkButton *transfer_button;
GtkButton *remove_button;
GtkTreeView *destination_view;
GtkTreeSelection *selection;
ESourceList *source_list;
char *gladefile;
- GConfClient *gconf_client;
+ GConfClient *gconf_client;
char *uid;
ENameSelectorDialogPrivate *priv = E_NAME_SELECTOR_DIALOG_GET_PRIVATE (name_selector_dialog);
priv->destination_index = 0;
-
+
/* Get Glade GUI */
gladefile = g_build_filename (E_DATA_SERVER_UI_GLADEDIR,
"e-name-selector-dialog.glade",
widget, "changed",
G_CALLBACK (source_changed), name_selector_dialog);
g_object_unref (source_list);
-
+
gconf_client = gconf_client_get_default();
uid = gconf_client_get_string (gconf_client, "/apps/evolution/addressbook/display/primary_addressbook",
NULL);
gtk_window_set_title (GTK_WINDOW (name_selector_dialog), _("Select Contacts from Address Book"));
gtk_widget_grab_focus (widget);
}
-
+
/* Partial, repeatable destruction. Release references. */
static void
e_name_selector_dialog_dispose (GObject *object)
/* Set up transfer button */
g_signal_connect_swapped (section.transfer_button, "clicked",
G_CALLBACK (transfer_button_clicked), name_selector_dialog);
-
+
/*data for the remove callback*/
data = g_malloc0(sizeof(SelData));
data->view = section.destination_view;
/*Associate to an object destroy so that it gets freed*/
g_object_set_data_full ((GObject *)section.destination_view, "sel-remove-data", data, g_free);
-
+
g_signal_connect(section.remove_button, "clicked",
G_CALLBACK (remove_button_clicked), data);
-
+
/* Set up view */
column = gtk_tree_view_column_new ();
cell_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ());
gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (section.transfer_button));
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, TRUE, 6);
gtk_size_group_add_widget (name_selector_dialog->button_size_group, GTK_WIDGET (section.transfer_button));
-
+
/*to get the image embedded in the button*/
widget = gtk_alignment_new (0.7, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (section.transfer_button), GTK_WIDGET (widget));
image = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
-
+
widget = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (section.remove_button));
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
vbox = gtk_vbox_new (FALSE, 0);
-
+
widget = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (section.label));
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, TRUE, 0);
* -------------------- */
static void
-status_message(EBookView *view, const gchar *message, ENameSelectorDialog *dialog)
+status_message(EBookView *view, const gchar *message, ENameSelectorDialog *dialog)
{
if(message == NULL)
gtk_label_set_text(dialog->status_label, "");
{
ENameSelectorDialog *name_selector_dialog = E_NAME_SELECTOR_DIALOG (data);
EContactStore *contact_store;
- EBookView *view;
+ EBookView *view;
if (status != E_BOOK_ERROR_OK) {
/* TODO: Handle errors gracefully */
GtkTreeSelection *contact_selection;
gboolean have_selection = FALSE;
gint i;
-
+
contact_selection = gtk_tree_view_get_selection (name_selector_dialog->contact_view);
if (gtk_tree_selection_count_selected_rows (contact_selection))
have_selection = TRUE;
contact_store = e_name_selector_model_peek_contact_store (name_selector_dialog->name_selector_model);
/* If we have no sections, we can't transfer */
- if (name_selector_dialog->sections->len == 0)
+ if (name_selector_dialog->sections->len == 0)
return;
/* Get the contact to be transferred */
e_destination_store_remove_destination (destination_store, destination);
}
-static gboolean
+static gboolean
remove_selection (ENameSelectorDialog *name_selector_dialog, GtkTreeView *tree_view)
{
gint section_index;
{
GtkTreeView *view;
ENameSelectorDialog *name_selector_dialog;
-
- view = data->view;
+
+ view = data->view;
name_selector_dialog = data->dlg_ptr;
remove_selection (name_selector_dialog, view);
}
-
-static gboolean
-destination_key_press (ENameSelectorDialog *name_selector_dialog,
+
+static gboolean
+destination_key_press (ENameSelectorDialog *name_selector_dialog,
GdkEventKey *event, GtkTreeView *tree_view)
{
gtk_tree_path_free (path);
return ;
}
-
+
gtk_tree_path_free (path);
sort_iter_to_contact_store_iter (name_selector_dialog, &iter, &email_n);
* @name_selector_dialog: an #ENameSelectorDialog
* @index: index of the destination section, starting from 0.
*
- * Sets the index number of the destination section.
+ * Sets the index number of the destination section.
**/
void
e_name_selector_dialog_set_destination_index (ENameSelectorDialog *name_selector_dialog,
/* Install properties */
/* Install signals */
-
+
signals[UPDATED] = g_signal_new ("updated",
E_TYPE_NAME_SELECTOR_ENTRY,
G_SIGNAL_RUN_FIRST,
destination = find_destination_at_position (name_selector_entry, pos);
if (!destination)
return;
-
+
text = gtk_entry_get_text (GTK_ENTRY (name_selector_entry));
raw_address = get_address_at_position (text, pos);
g_assert (raw_address);
{
const gchar *text;
gint index_start, index_end;
- gint selection_start, selection_end;
+ gint selection_start, selection_end;
gunichar str_context [2], str_b_context [2];
gint len;
gint i;
gboolean already_selected = FALSE, del_space = FALSE, del_comma = FALSE;
- if (start_pos == end_pos)
+ if (start_pos == end_pos)
return;
text = gtk_entry_get_text (GTK_ENTRY (name_selector_entry));
len = g_utf8_strlen (text, -1);
- if (gtk_editable_get_selection_bounds (GTK_EDITABLE (name_selector_entry),
- &selection_start,
- &selection_end))
+ if (gtk_editable_get_selection_bounds (GTK_EDITABLE (name_selector_entry),
+ &selection_start,
+ &selection_end))
if ((g_utf8_get_char (g_utf8_offset_to_pointer (text, selection_end)) == 0) ||
(g_utf8_get_char (g_utf8_offset_to_pointer (text, selection_end)) == ','))
already_selected = TRUE;
-
+
get_utf8_string_context (text, start_pos, str_context, 2);
get_utf8_string_context (text, end_pos, str_b_context, 2);
index_start = get_index_at_position (text, start_pos);
index_end = get_index_at_position (text, end_pos);
-
+
g_signal_stop_emission_by_name (name_selector_entry, "delete_text");
-
+
/* If the deletion touches more than one destination, the first one is changed
* and the rest are removed. If the last destination wasn't completely deleted,
* it becomes part of the first one, since the separator between them was
if (!email || !*email)
continue;
-
+
if (!get_range_by_index (text, i, &range_start, &range_end)) {
g_warning ("ENameSelectorEntry is out of sync with model!");
return;
g_signal_handlers_unblock_by_func (name_selector_entry, user_insert_text, name_selector_entry);
}
-
+
remove_destination_by_index (name_selector_entry, i);
}
-
+
/* Do the actual deletion */
-
+
if (end_pos == start_pos +1 && index_end == index_start) {
/* We could be just deleting the empty text */
char *c;
EDestination *dest = find_destination_by_index (name_selector_entry, index_end);
/* If we have deleted the last comma, let us autocomplete normally
*/
-
+
if (dest && len - end_pos != 0) {
-
+
EDestination *destination1 = find_destination_by_index (name_selector_entry, index_start);
char *ttext;
const char *email=NULL;
g_signal_handlers_unblock_by_func (name_selector_entry, user_delete_text, name_selector_entry);
g_signal_handlers_unblock_by_func (name_selector_entry, user_insert_text, name_selector_entry);
}
-
+
if (range_start != -1) {
start_pos = range_start;
end_pos = start_pos+1;
}
gtk_editable_delete_text (GTK_EDITABLE (name_selector_entry),
start_pos, end_pos);
-
+
/*If the user is deleting a '"' new destinations have to be created for ',' between the quoted text
Like "fd,ty,uy" is a one entity, but if you remove the quotes it has to be broken doan into 3 seperate
addresses.
insert_destination_at_position (name_selector_entry, j+1);
}
}
-
+
}
/* Let model know about changes */
g_source_remove (name_selector_entry->type_ahead_complete_cb_id);
name_selector_entry->type_ahead_complete_cb_id = 0;
}
-
+
g_signal_handlers_unblock_by_func (name_selector_entry, user_delete_text, name_selector_entry);
}
gint range_len;
const gchar *text;
gchar *cue_str;
-
+
cursor_pos = gtk_editable_get_position (GTK_EDITABLE (name_selector_entry));
if (cursor_pos < 0)
return;
return;
cue_str = get_entry_substring (name_selector_entry, range_start, range_end);
-#if 0
+#if 0
if (!find_existing_completion (name_selector_entry, cue_str, &contact,
&textrep, &matched_field)) {
g_free (cue_str);
return;
}
-#endif
- g_free (cue_str);
+#endif
+ g_free (cue_str);
sync_destination_at_position (name_selector_entry, cursor_pos, &cursor_pos);
/* Place cursor at end of address */
if (priv->is_completing) {
char *str_context=NULL;
-
+
str_context = gtk_editable_get_chars (GTK_EDITABLE (name_selector_entry), range_end, range_end+1);
-
+
if (str_context[0] != ',') {
/* At the end*/
gtk_editable_insert_text (GTK_EDITABLE (name_selector_entry), ", ", -1, &range_end);
/* Move it close to next destination*/
range_end = range_end+2;
-
+
}
}
gtk_editable_set_position (GTK_EDITABLE (name_selector_entry), range_end);
g_signal_emit (name_selector_entry, signals[UPDATED], 0, destination, NULL);
-
+
priv->is_completing = FALSE;
}
user_focus_in (ENameSelectorEntry *name_selector_entry, GdkEventFocus *event_focus)
{
/*
- * To preserve selected text, do not propagate the event any more.
+ * To preserve selected text, do not propagate the event any more.
*/
return TRUE;
if (!event_focus->in && priv->is_completing) {
entry_activate (name_selector_entry);
}
-
+
if (name_selector_entry->type_ahead_complete_cb_id) {
g_source_remove (name_selector_entry->type_ahead_complete_cb_id);
name_selector_entry->type_ahead_complete_cb_id = 0;
if (!destination)
return;
-
+
g_assert (n >= 0);
entry_text = gtk_entry_get_text (GTK_ENTRY (name_selector_entry));
gboolean result;
gint email_num;
ENameSelectorEntry *name_selector_entry = E_NAME_SELECTOR_ENTRY (data);
-
+
destination = name_selector_entry->popup_destination;
contact = e_destination_get_contact (destination);
if (!contact)
int position, start, end;
position = GPOINTER_TO_INT(g_object_get_data ((GObject *)name_selector_entry, "index"));
-
+
email_list = e_destination_get_address(destination);
- text = gtk_entry_get_text (GTK_ENTRY (name_selector_entry));
+ text = gtk_entry_get_text (GTK_ENTRY (name_selector_entry));
get_range_at_position (text, position, &start, &end);
g_signal_handlers_block_by_func (name_selector_entry, user_delete_text, name_selector_entry);
popup_activate_list (EDestination *destination, GtkWidget *item)
{
gboolean status = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (item));
-
- e_destination_set_ignored (destination, !status);
+
+ e_destination_set_ignored (destination, !status);
}
static void
contact = e_destination_get_contact (destination);
if (!contact)
return;
-
+
e_destination_set_ignored (destination, !status);
}
for (iter = (GList *)dests; iter; iter = iter->next) {
EDestination *dest = (EDestination *) iter->data;
const char *email = e_destination_get_email (dest);
-
+
if (!email || *email == '\0')
- continue;
+ continue;
if (length > 1) {
menu_item = gtk_check_menu_item_new_with_label (email);
- g_signal_connect (menu_item, "toggled", G_CALLBACK (destination_set_list), dest);
+ g_signal_connect (menu_item, "toggled", G_CALLBACK (destination_set_list), dest);
} else {
menu_item = gtk_menu_item_new_with_label (email);
}
-
+
gtk_widget_show (menu_item);
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
show_menu = TRUE;
if (length > 1) {
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), !e_destination_is_ignored(dest));
g_signal_connect_swapped (menu_item, "activate", G_CALLBACK (popup_activate_list),
- dest);
+ dest);
}
}
-
+
} else {
email_list = e_contact_get (contact, E_CONTACT_EMAIL);
len = g_list_length (email_list);
if (!email || *email == '\0')
continue;
-
+
if (len > 1) {
menu_item = gtk_radio_menu_item_new_with_label (group, email);
group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
g_signal_connect (menu_item, "toggled", G_CALLBACK (destination_set_email), destination);
} else {
- menu_item = gtk_menu_item_new_with_label (email);
+ menu_item = gtk_menu_item_new_with_label (email);
}
-
+
gtk_widget_show (menu_item);
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
show_menu = TRUE;
- g_object_set_data (G_OBJECT (menu_item), "order", GINT_TO_POINTER (i));
+ g_object_set_data (G_OBJECT (menu_item), "order", GINT_TO_POINTER (i));
if ( i == email_num && len > 1 ) {
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
/* Expand a list inline */
if (is_list) {
/* To Translators: This would be similiar to "Expand MyList Inline" where MyList is a Contact List*/
- edit_label = g_strdup_printf (_("E_xpand %s Inline"), (char *)e_contact_get_const (contact, E_CONTACT_FILE_AS));
+ edit_label = g_strdup_printf (_("E_xpand %s Inline"), (char *)e_contact_get_const (contact, E_CONTACT_FILE_AS));
menu_item = gtk_menu_item_new_with_mnemonic (edit_label);
g_free (edit_label);
gtk_widget_show (menu_item);
/* Cut Contact Item */
cut_label = g_strdup_printf (_("C_ut %s"), (char *)e_contact_get_const (contact, E_CONTACT_FILE_AS));
menu_item = gtk_menu_item_new_with_mnemonic (cut_label);
- g_free (cut_label);
+ g_free (cut_label);
gtk_widget_show (menu_item);
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
-
+
g_signal_connect_swapped (menu_item, "activate", G_CALLBACK (popup_activate_cut),
name_selector_entry);
-
+
if (show_menu) {
menu_item = gtk_separator_menu_item_new ();
gtk_widget_show (menu_item);
/* Edit Contact item */
- edit_label = g_strdup_printf (_("_Edit %s"), (char *)e_contact_get_const (contact, E_CONTACT_FILE_AS));
+ edit_label = g_strdup_printf (_("_Edit %s"), (char *)e_contact_get_const (contact, E_CONTACT_FILE_AS));
menu_item = gtk_menu_item_new_with_mnemonic (edit_label);
g_free (edit_label);
gtk_widget_show (menu_item);
/**
* e_name_selector_entry_peek_destination_store:
* @name_selector_entry: an #ENameSelectorEntry
- *
+ *
* Gets the #EDestinationStore being used to store @name_selector_entry's destinations.
*
* Return value: An #EDestinationStore.
* Boston, MA 02110-1301, USA.
*
* Authors: Srinivasa Ragavan <sragavan@novell.com>
- * : Devashish Sharma <sdevashish@novell.com>
+ * : Devashish Sharma <sdevashish@novell.com>
*/
#include <config.h>
/* Show a maximum of 10 rows in the popup list view */
count = list->rows;
- if (count > MAX_ROW)
+ if (count > MAX_ROW)
count = MAX_ROW;
if (count <= 0)
count = 1;
enl_popup_size (list);
gdk_window_get_origin (((GtkWidget *)list)->window, &x, &y);
y = y +((GtkWidget *)list)->allocation.height;
-
+
gtk_window_move (list->popup, x, y);
}
static void
enl_popup_grab (ENameSelectorList *list)
{
- int len;
-
+ int len;
+
gtk_grab_add (GTK_WIDGET (list->popup));
-
+
gdk_pointer_grab (((GtkWidget *)list->popup)->window, TRUE,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
gdk_keyboard_grab (((GtkWidget *)list->popup)->window, TRUE, GDK_CURRENT_TIME);
gtk_widget_grab_focus ((GtkWidget *)list);
-
+
/* Build the listview from the model */
gtk_tree_view_set_model (GTK_TREE_VIEW (list->tree_view), GTK_TREE_MODEL(((ENameSelectorEntry *)list)->destination_store));
/* If any selection of text is present, unselect it */
len = strlen(gtk_entry_get_text(GTK_ENTRY(list)));
- gtk_editable_select_region (GTK_EDITABLE(list), len, -1);
+ gtk_editable_select_region (GTK_EDITABLE(list), len, -1);
}
static void
{
if (!GTK_WIDGET_HAS_GRAB(list->popup))
return;
-
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
+
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
gtk_grab_remove ( GTK_WIDGET (list->popup));
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
}
enl_entry_focus_in (ENameSelectorList *list, GdkEventFocus *event, gpointer dummy)
{
int len;
-
+
/* FIXME: Dont select every thing by default- Code is there but still it does */
len = strlen(gtk_entry_get_text(GTK_ENTRY(list)));
gtk_editable_select_region (GTK_EDITABLE(list), len, -1);
-
+
return TRUE;
}
if (GTK_WIDGET_VISIBLE (list->popup) && !GTK_WIDGET_HAS_GRAB(list->popup)) {
enl_popup_ungrab (list);
gtk_widget_hide ((GtkWidget *)list->popup);
-
+
return FALSE;
}
{
if (event->type == GDK_ENTER_NOTIFY && !GTK_WIDGET_HAS_GRAB (list->popup))
enl_popup_grab (list);
-
+
return TRUE;
}
GtkTreeSelection *selection;
GtkTreeIter iter;
GtkTreePath *path;
-
+
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list->tree_view));
iter.stamp = ((ENameSelectorEntry *) list)->destination_store->stamp;
iter.user_data = GINT_TO_POINTER (n-1);
gtk_tree_view_set_cursor ( GTK_TREE_VIEW (list->tree_view), path, gtk_tree_view_get_column( GTK_TREE_VIEW (list->tree_view), 0), FALSE);
gtk_widget_grab_focus (list->tree_view);
/*Fixme: We should grab the focus to the column. How? */
-
+
gtk_tree_path_free (path);
}
static gboolean
-enl_entry_key_press_event (ENameSelectorList *list,
+enl_entry_key_press_event (ENameSelectorList *list,
GdkEventKey *event,
gpointer dummy)
{
GtkTreeIter iter;
int n, len;
GtkTreeSelection *selection;
-
+
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (E_NAME_SELECTOR_ENTRY (list)->destination_store), &iter, path))
return;
-
+
selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (list->tree_view));
len = e_destination_store_get_destination_count (E_NAME_SELECTOR_ENTRY (list)->destination_store);
n = GPOINTER_TO_INT (iter.user_data);
-
+
e_destination_store_remove_destination_nth (((ENameSelectorEntry *) list)->destination_store, n);
-
+
/* If the last one is deleted select the last but one or the deleted +1 */
if (n == len -1)
n -= 1;
-
+
/* We deleted the last entry */
if (len == 1) {
enl_popup_ungrab (list);
iter.stamp = ((ENameSelectorEntry *) list)->destination_store->stamp;
iter.user_data = GINT_TO_POINTER (n);
- gtk_tree_selection_unselect_all (selection);
+ gtk_tree_selection_unselect_all (selection);
gtk_tree_selection_select_iter (selection, &iter);
-
+
gtk_tree_path_free (path);
list->rows = e_destination_store_get_destination_count (((ENameSelectorEntry *) list)->destination_store);
enl_popup_size (list);
-
+
}
static void
popup_activate_list (EDestination *destination, GtkWidget *item)
{
gboolean status = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (item));
-
- e_destination_set_ignored (destination, !status);
+
+ e_destination_set_ignored (destination, !status);
}
static void
contact = e_destination_get_contact (destination);
if (!contact)
return;
-
+
e_destination_set_ignored (destination, !status);
}
if ( !GTK_WIDGET_HAS_GRAB (list->popup))
enl_popup_grab (list);
-
+
gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW (list->tree_view), event->x, event->y, &path, NULL);
selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (list->tree_view));
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (E_NAME_SELECTOR_ENTRY (list)->destination_store), &iter, path))
return FALSE;
-
- gtk_tree_selection_unselect_all (selection);
+
+ gtk_tree_selection_unselect_all (selection);
gtk_tree_selection_select_iter (selection, &iter);
if (event->button != 3) {
return FALSE;
}
-
+
name_selector_entry = E_NAME_SELECTOR_ENTRY (list);
- destination = e_destination_store_get_destination ( ((ENameSelectorEntry *)list)->destination_store, &iter);
+ destination = e_destination_store_get_destination ( ((ENameSelectorEntry *)list)->destination_store, &iter);
if (!destination)
return FALSE;
for (iters = (GList *)dests; iters; iters = iters->next) {
EDestination *dest = (EDestination *) iters->data;
const char *email = e_destination_get_email (dest);
-
+
if (!email || *email == '\0')
- continue;
+ continue;
if (length > 1) {
menu_item = gtk_check_menu_item_new_with_label (email);
- g_signal_connect (menu_item, "toggled", G_CALLBACK (destination_set_list), dest);
+ g_signal_connect (menu_item, "toggled", G_CALLBACK (destination_set_list), dest);
} else {
menu_item = gtk_menu_item_new_with_label (email);
}
-
+
gtk_widget_show (menu_item);
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
show_menu = TRUE;
if (length > 1) {
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), !e_destination_is_ignored(dest));
g_signal_connect_swapped (menu_item, "activate", G_CALLBACK (popup_activate_list),
- dest);
+ dest);
}
}
-
+
} else {
email_list = e_contact_get (contact, E_CONTACT_EMAIL);
len = g_list_length (email_list);
if (!email || *email == '\0')
continue;
-
+
if (len > 1) {
menu_item = gtk_radio_menu_item_new_with_label (group, email);
group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
g_signal_connect (menu_item, "toggled", G_CALLBACK (destination_set_email), destination);
} else {
- menu_item = gtk_menu_item_new_with_label (email);
+ menu_item = gtk_menu_item_new_with_label (email);
}
-
+
gtk_widget_show (menu_item);
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
show_menu = TRUE;
- g_object_set_data (G_OBJECT (menu_item), "order", GINT_TO_POINTER (i));
+ g_object_set_data (G_OBJECT (menu_item), "order", GINT_TO_POINTER (i));
if ( i == email_num && len > 1 ) {
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
g_signal_connect (menu_item, "activate", G_CALLBACK (popup_delete_row),
row_info);
-
+
return TRUE;
paths = g_list_reverse (paths);
g_list_foreach (paths, (GFunc) delete_row, list);
g_list_free (paths);
- } else if (event->keyval != GDK_Up && event->keyval != GDK_Down
+ } else if (event->keyval != GDK_Up && event->keyval != GDK_Down
&& event->keyval != GDK_Shift_R && event->keyval != GDK_Shift_L
&& event->keyval != GDK_Control_R && event->keyval != GDK_Control_L){
-
+
enl_popup_ungrab (list);
gtk_widget_hide ( GTK_WIDGET (list->popup));
gtk_widget_event (GTK_WIDGET (list), (GdkEvent *)event);
return FALSE;
}
-void
+void
e_name_selector_list_expand_clicked(ENameSelectorList *list)
{
{
ENameSelectorList *list = (ENameSelectorList *)widget;
GTK_WIDGET_CLASS (e_name_selector_list_parent_class)->realize (widget);
-
+
gtk_tree_view_set_model ( GTK_TREE_VIEW (list->tree_view), GTK_TREE_MODEL(((ENameSelectorEntry *)list)->destination_store));
}
list->store = e_destination_store_new ();
list->menu = NULL;
-
+
list->tree_view = GTK_WIDGET (gtk_tree_view_new_with_model (GTK_TREE_MODEL(entry->destination_store)));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (list->tree_view), FALSE);
gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (list->tree_view), FALSE);
-
+
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list->tree_view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
gtk_tree_selection_unselect_all (selection);
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
- GTK_SHADOW_NONE);
+ GTK_SHADOW_NONE);
gtk_widget_set_size_request (GTK_SCROLLED_WINDOW (scroll)->vscrollbar, -1, 0);
list->popup = GTK_WINDOW (gtk_window_new (GTK_WINDOW_POPUP));
popup_frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (popup_frame),
GTK_SHADOW_ETCHED_IN);
-
+
gtk_container_add (GTK_CONTAINER (list->popup), popup_frame);
-
+
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (popup_frame), vbox);
g_signal_connect (GTK_WIDGET (list->popup), "button-press-event", G_CALLBACK(enl_popup_button_press), list);
g_signal_connect (GTK_WIDGET (list->popup), "focus-out-event", G_CALLBACK(enl_popup_focus_out), list);
g_signal_connect (GTK_WIDGET (list->popup), "enter-notify-event", G_CALLBACK (enl_popup_enter_notify), list);
-
+
}
ENameSelectorList *
GType e_name_selector_list_get_type (void);
ENameSelectorList *e_name_selector_list_new (void);
-void e_name_selector_list_expand_clicked (ENameSelectorList *list);
+void e_name_selector_list_expand_clicked (ENameSelectorList *list);
G_END_DECLS
#endif
/**
* e_name_selector_model_peek_contact_store:
* @name_selector_model: an #ENameSelectorModel
- *
+ *
* Gets the #EContactStore associated with @name_selector_model.
*
* Return value: An #EContactStore.
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser 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
void (*dispatch) (struct _EPassMsg *);
/* input */
- struct _GtkWindow *parent;
+ struct _GtkWindow *parent;
const gchar *component;
const gchar *key;
const gchar *title;
{
GnomeKeyringAttributeList *attributes;
GnomeKeyringResult result;
- GList *matches = NULL, *tmp;
+ GList *matches = NULL, *tmp;
gchar *default_keyring = NULL;
result = gnome_keyring_get_default_keyring_sync (&default_keyring);
if (!default_keyring) {
if (gnome_keyring_create_sync ("default", NULL) != GNOME_KEYRING_RESULT_OK)
return;
- default_keyring = g_strdup ("default");
+ default_keyring = g_strdup ("default");
}
d(g_print ("Get Default %d\n", result));
-
+
/* Not called at all */
attributes = gnome_keyring_attribute_list_new ();
gnome_keyring_attribute_list_append_string (attributes, "application", "Evolution");
result = gnome_keyring_find_items_sync (GNOME_KEYRING_ITEM_NETWORK_PASSWORD, attributes, &matches);
d(g_print ("Find Items %d\n", result));
-
+
gnome_keyring_attribute_list_free (attributes);
if (result) {
d(g_print ("Delete Items %d\n", result));
}
}
-
+
g_free (default_keyring);
}
#endif
{
GnomeKeyringAttributeList *attributes;
GnomeKeyringResult result;
- GList *matches = NULL, *tmp;
+ GList *matches = NULL, *tmp;
gchar *default_keyring = NULL;
result = gnome_keyring_get_default_keyring_sync (&default_keyring);
if (!default_keyring) {
if (gnome_keyring_create_sync ("default", NULL) != GNOME_KEYRING_RESULT_OK)
return;
- default_keyring = g_strdup ("default");
- }
+ default_keyring = g_strdup ("default");
+ }
d(g_print ("Get Default %d\n", result));
-
+
attributes = gnome_keyring_attribute_list_new ();
gnome_keyring_attribute_list_append_string (attributes, "application", "Evolution");
result = gnome_keyring_find_items_sync (GNOME_KEYRING_ITEM_NETWORK_PASSWORD, attributes, &matches);
d(g_print ("Find Items %d\n", result));
-
+
gnome_keyring_attribute_list_free (attributes);
if (result) {
d(g_print ("Delete Items %d\n", result));
}
}
-
+
g_free (default_keyring);
/* free up the session passwords */
/* LDAP doesnt use username in url. Let the url be the user key. So safe it */
gchar *keycopy = g_strdup (msg->key);
gint i;
-
+
for (i = 0; i < strlen (keycopy); i ++)
if (keycopy[i] == '/' || keycopy[i] =='=')
- keycopy[i] = '_';
+ keycopy[i] = '_';
uri->user = keycopy;
}
-
+
attributes = gnome_keyring_attribute_list_new ();
gnome_keyring_attribute_list_append_string (attributes, "user", uri->user);
gnome_keyring_attribute_list_append_string (attributes, "server", uri->host);
gnome_keyring_attribute_list_append_string (attributes, "application", "Evolution");
-
+
result = gnome_keyring_item_create_sync (NULL, /* Use default keyring */
GNOME_KEYRING_ITEM_NETWORK_PASSWORD, /* type */
msg->key, /* name */
value, /* password */
TRUE, /* Update if already exists */
&item_id);
-
+
d(g_print ("Remember %s: %d/%d\n", msg->key, result, item_id));
gnome_keyring_attribute_list_free (attributes);
/* now remove it from our session hash */
g_hash_table_remove (password_cache, msg->key);
-
+
e_uri_free (uri);
}
}
{
GnomeKeyringAttributeList *attributes;
GnomeKeyringResult result;
- GList *matches = NULL, *tmp;
- gchar *default_keyring = NULL;
+ GList *matches = NULL, *tmp;
+ gchar *default_keyring = NULL;
EUri *uri = e_uri_new (msg->key);
if (!strcmp (uri->protocol, "ldap") && !uri->user) {
for (i = 0; i < strlen (keycopy); i ++)
if (keycopy[i] == '/' || keycopy[i] =='=')
- keycopy[i] = '_';
+ keycopy[i] = '_';
uri->user = keycopy;
}
-
+
g_hash_table_remove (password_cache, msg->key);
if (!uri->host && !uri->user)
/* No need to remove from keyring for pass phrases */
goto exit;
-
+
result = gnome_keyring_get_default_keyring_sync (&default_keyring);
if (!default_keyring) {
if (gnome_keyring_create_sync ("default", NULL) != GNOME_KEYRING_RESULT_OK)
goto exit;
- default_keyring = g_strdup ("default");
+ default_keyring = g_strdup ("default");
}
d(g_print ("Get Default %d\n", result));
-
+
attributes = gnome_keyring_attribute_list_new ();
gnome_keyring_attribute_list_append_string (attributes, "user", uri->user);
gnome_keyring_attribute_list_append_string (attributes, "server", uri->host);
result = gnome_keyring_find_items_sync (GNOME_KEYRING_ITEM_NETWORK_PASSWORD, attributes, &matches);
d(g_print ("Find Items %d\n", result));
-
+
gnome_keyring_attribute_list_free (attributes);
if (result) {
} else if (!strcmp (attr->name, "server")) {
present++;
if (strcmp (attr->value.string, uri->host))
- accept = FALSE;
+ accept = FALSE;
}
}
if (present == 2 && accept) {
result = gnome_keyring_item_delete_sync (default_keyring, ((GnomeKeyringFound *) tmp->data)->item_id);
- d(g_print ("Delete Items %s %s %d\n", uri->host, uri->user, result));
+ d(g_print ("Delete Items %s %s %d\n", uri->host, uri->user, result));
}
- }
+ }
}
-
+
g_free (default_keyring);
exit:
gchar *passwd;
GnomeKeyringAttributeList *attributes;
GnomeKeyringResult result;
- GList *matches = NULL, *tmp;
+ GList *matches = NULL, *tmp;
passwd = g_hash_table_lookup (password_cache, msg->key);
if (passwd) {
msg->password = g_strdup (passwd);
} else {
EUri *uri = e_uri_new (msg->key);
-
+
if (!strcmp (uri->protocol, "ldap") && !uri->user) {
/* LDAP doesnt use username in url. Let the url be the user key. So safe it */
gchar *keycopy = g_strdup (msg->key);
for (i = 0; i < strlen (keycopy); i ++)
if (keycopy[i] == '/' || keycopy[i] =='=')
- keycopy[i] = '_';
+ keycopy[i] = '_';
uri->user = keycopy;
}
-
+
if (uri->host && uri->user) {
/* We dont store passphrases.*/
result = gnome_keyring_find_items_sync (GNOME_KEYRING_ITEM_NETWORK_PASSWORD, attributes, &matches);
d(g_print ("Find Items %d\n", result));
-
+
gnome_keyring_attribute_list_free (attributes);
if (result) {
} else if (!strcmp (attr->name, "server") && attr->value.string) {
present++;
if (strcmp (attr->value.string, uri->host))
- accept = FALSE;
+ accept = FALSE;
}
}
if (present == 2 && accept) {
msg->password = g_strdup (((GnomeKeyringFound *) tmp->data)->secret);
break;
}
- }
+ }
}
}
-
+
e_uri_free (uri);
}
-}
+}
#endif
static void
ep_add_password (msg);
}
if (*msg->remember && type == E_PASSWORDS_REMEMBER_FOREVER)
- ep_remember_password (msg);
+ ep_remember_password (msg);
msg->noreply = noreply;
}
while (mn) {
if ((mw->dispatch == ep_forget_password
|| mw->dispatch == ep_get_password
- || mw->dispatch == ep_ask_password)
+ || mw->dispatch == ep_ask_password)
&& (strcmp (mw->component, msg->component) == 0
&& strcmp (mw->key, msg->key) == 0)) {
e_dlist_remove ((EDListNode *)mw);
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (password_dialog)->vbox), vbox, TRUE, FALSE, 0);
gtk_container_set_border_width ((GtkContainer *)vbox, 12);
-
+
msg->entry = gtk_entry_new ();
a11y = gtk_widget_get_accessible (msg->entry);
gtk_box_pack_start (GTK_BOX (vbox), msg->entry, TRUE, FALSE, 3);
gtk_widget_show (msg->entry);
gtk_widget_grab_focus (msg->entry);
-
+
if ((msg->flags & E_PASSWORDS_REPROMPT)) {
ep_get_password (msg);
if (msg->password) {
msg->check = gtk_check_button_new_with_mnemonic (type == E_PASSWORDS_REMEMBER_FOREVER
? _("_Remember this password")
: _("_Remember this password for the remainder of this session"));
-
+
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (msg->check), *msg->remember);
gtk_box_pack_start (GTK_BOX (vbox), msg->check, TRUE, FALSE, 3);
gtk_widget_set_sensitive (msg->check, FALSE);
gtk_widget_show (msg->check);
}
-
+
msg->noreply = noreply;
g_signal_connect (password_dialog, "response", G_CALLBACK (pass_response), msg);
/**
* e_passwords_cancel:
- *
+ *
* Cancel any outstanding password operations and close any dialogues
* currently being shown.
**/
/**
* e_passwords_set_online:
- * @state:
- *
+ * @state:
+ *
* Set the offline-state of the application. This is a work-around
* for having the backends fully offline aware, and returns a
* cancellation response instead of prompting for passwords.
e_passwords_forget_passwords (void)
{
EPassMsg *msg = ep_msg_new (ep_forget_passwords);
-
+
ep_msg_send (msg);
ep_msg_free (msg);
}
void
e_passwords_clear_passwords (const gchar *component_name)
{
- EPassMsg *msg = ep_msg_new (ep_clear_passwords);
+ EPassMsg *msg = ep_msg_new (ep_clear_passwords);
msg->component = component_name;
ep_msg_send (msg);
passwd = msg->password;
msg->password = NULL;
ep_msg_free (msg);
-
+
return passwd;
}
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser 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
E_PASSWORDS_PASSPHRASE = 1<<12, /* We are asking a passphrase */
} EPasswordsRememberType;
-char * e_passwords_ask_password (const char *title,
+char * e_passwords_ask_password (const char *title,
const char*component_name, const char *key,
const char *prompt,
EPasswordsRememberType remember_type,
object_class->dispose = e_source_option_menu_dispose;
object_class->finalize = e_source_option_menu_finalize;
- signals[SOURCE_SELECTED] =
+ signals[SOURCE_SELECTED] =
g_signal_new ("source_selected",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
ESourceList *list;
GtkTreeStore *tree_store;
-
+
GHashTable *selected_sources;
GtkTreeRowReference *saved_primary_selection;
ESourceGroup *primary_source_group;
-
+
int rebuild_model_idle_id;
gboolean toggled_last;
create_rebuild_data (ESourceSelector *selector)
{
ESourceSelectorRebuildData *rebuild_data;
-
+
rebuild_data = g_new0 (ESourceSelectorRebuildData, 1);
-
+
rebuild_data->selector = selector;
- rebuild_data->remaining_uids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
+ rebuild_data->remaining_uids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
(GDestroyNotify) gtk_tree_row_reference_free);
rebuild_data->deleted_uids = NULL;
free_rebuild_data (ESourceSelectorRebuildData *rebuild_data)
{
GSList *p;
-
+
g_hash_table_destroy (rebuild_data->remaining_uids);
for (p = rebuild_data->deleted_uids; p; p = p->next)
gtk_tree_row_reference_free (p->data);
g_slist_free (rebuild_data->deleted_uids);
-
+
g_free (rebuild_data);
}
if (E_SOURCE (data) == source) {
g_object_unref (data);
-
+
return TRUE;
}
-
+
g_object_unref (data);
} while (gtk_tree_model_iter_next (model, source_iter));
}
uid = e_source_group_peek_uid (E_SOURCE_GROUP (node));
if (e_source_list_peek_group_by_uid (rebuild_data->selector->priv->list, uid)) {
- g_hash_table_insert (rebuild_data->remaining_uids, g_strdup (uid),
+ g_hash_table_insert (rebuild_data->remaining_uids, g_strdup (uid),
gtk_tree_row_reference_new (model, path));
} else {
- rebuild_data->deleted_uids = g_slist_prepend (rebuild_data->deleted_uids,
+ rebuild_data->deleted_uids = g_slist_prepend (rebuild_data->deleted_uids,
gtk_tree_row_reference_new (model, path));
}
} else {
uid = e_source_peek_uid (E_SOURCE (node));
if (e_source_list_peek_source_by_uid (rebuild_data->selector->priv->list, uid)) {
- g_hash_table_insert (rebuild_data->remaining_uids, g_strdup (uid),
+ g_hash_table_insert (rebuild_data->remaining_uids, g_strdup (uid),
gtk_tree_row_reference_new (model, path));
} else {
- rebuild_data->deleted_uids = g_slist_prepend (rebuild_data->deleted_uids,
+ rebuild_data->deleted_uids = g_slist_prepend (rebuild_data->deleted_uids,
gtk_tree_row_reference_new (model, path));
-
+
if (g_hash_table_remove (rebuild_data->selector->priv->selected_sources, node))
rebuild_data->selection_changed = TRUE;
}
}
-
+
g_object_unref (node);
return FALSE;
}
-
+
static ESource *
find_source (ESourceSelector *selector, ESource *source)
{
GtkTreeIter iter;
GSList *groups, *p;
gboolean set_primary;
-
+
tree_store = selector->priv->tree_store;
rebuild_data = create_rebuild_data (selector);
set_primary = e_source_selector_peek_primary_selection (selector) != NULL;
-
+
/* Remove any delete sources or groups */
gtk_tree_model_foreach (GTK_TREE_MODEL (tree_store), rebuild_existing_cb, rebuild_data);
for (p = rebuild_data->deleted_uids; p; p = p->next) {
GtkTreeRowReference *row_ref = p->data;
GtkTreePath *path;
-
+
path = gtk_tree_row_reference_get_path (row_ref);
gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &iter, path);
gtk_tree_store_remove (tree_store, &iter);
gtk_tree_path_free (path);
}
-
+
/* Add new sources/groups or call row_changed in case they were renamed */
groups = e_source_list_peek_groups (selector->priv->list);
for (p = groups; p != NULL; p = p->next) {
GSList *sources, *q;
GtkTreeRowReference *row_ref;
gint position;
-
+
row_ref = g_hash_table_lookup (rebuild_data->remaining_uids, e_source_group_peek_uid (group));
if (!row_ref) {
gtk_tree_store_append (GTK_TREE_STORE (tree_store), &iter, NULL);
gtk_tree_store_set (GTK_TREE_STORE (tree_store), &iter, 0, group, -1);
} else {
GtkTreePath *path;
-
+
path = gtk_tree_row_reference_get_path (row_ref);
gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &iter, path);
gtk_tree_path_free (path);
}
-
+
sources = get_sorted_sources (e_source_group_peek_sources (group));
for (q = sources, position = 0; q != NULL; q = q->next, position++) {
ESource *source = E_SOURCE (q->data);
gtk_tree_store_set (GTK_TREE_STORE (tree_store), &child_iter, 0, source, -1);
} else {
GtkTreePath *path;
-
+
path = gtk_tree_row_reference_get_path (row_ref);
gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &child_iter, path);
-
+
gtk_tree_model_row_changed (GTK_TREE_MODEL (tree_store), path, &child_iter);
gtk_tree_path_free (path);
if (set_primary && !e_source_selector_peek_primary_selection (selector))
e_source_selector_set_primary_selection (selector, e_source_list_peek_source_any (selector->priv->list));
-
+
free_rebuild_data (rebuild_data);
}
NULL);
} else {
ESource *source;
-
+
g_assert (E_IS_SOURCE (data));
source = E_SOURCE (data);
-
+
g_object_set (renderer,
"text", e_source_peek_name (source),
"weight", PANGO_WEIGHT_NORMAL,
g_object_set (renderer,
"visible", FALSE,
NULL);
- } else {
+ } else {
ESource *source;
GdkPixbuf *pixbuf = NULL;
const gchar *color_spec;
g_assert (E_IS_SOURCE (data));
source = E_SOURCE (data);
-
+
color_spec = e_source_peek_color_spec (source);
if (color_spec != NULL && gdk_color_parse (color_spec, &color)) {
guint32 rgba;
gdk_pixbuf_fill (pixbuf, rgba);
}
-
+
g_object_set (renderer,
"visible", pixbuf != NULL,
"pixbuf", pixbuf,
NULL);
-
+
if (pixbuf)
g_object_unref (pixbuf);
}
if (selector->priv->toggled_last) {
selector->priv->toggled_last = FALSE;
-
+
return FALSE;
- }
+ }
if (path_currently_selected)
return TRUE;
gtk_tree_model_get (model, &iter, 0, &data, -1);
if (E_IS_SOURCE_GROUP (data)) {
g_object_unref (data);
-
+
return FALSE;
}
unselect_source (selector, source);
else
select_source (selector, source);
-
+
selector->priv->toggled_last = TRUE;
-
+
gtk_tree_model_row_changed (model, path, &iter);
g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
}
gtk_tree_path_free (path);
-
- g_object_unref (data);
+
+ g_object_unref (data);
}
static void
test_collapse_row_callback (GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
{
ESourceSelector *selector = data;
- ESourceSelectorPrivate *priv;
+ ESourceSelectorPrivate *priv;
GtkTreeIter child_iter;
-
+
priv = selector->priv;
/* Clear this because something else has been clicked on now */
if (priv->saved_primary_selection)
return FALSE;
-
+
if (!gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (selector)), NULL, &child_iter))
return FALSE;
-
+
if (gtk_tree_store_is_ancestor (priv->tree_store, iter, &child_iter)) {
GtkTreePath *child_path;
-
+
child_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tree_store), &child_iter);
priv->saved_primary_selection = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->tree_store), child_path);
gtk_tree_path_free (child_path);
}
-
+
return FALSE;
}
row_expanded_callback (GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
{
ESourceSelector *selector = data;
- ESourceSelectorPrivate *priv;
+ ESourceSelectorPrivate *priv;
GtkTreePath *child_path;
GtkTreeIter child_iter;
-
+
priv = selector->priv;
if (!priv->saved_primary_selection)
return FALSE;
-
+
child_path = gtk_tree_row_reference_get_path (priv->saved_primary_selection);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->tree_store), &child_iter, child_path);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->tree_store), &child_iter, child_path);
if (gtk_tree_store_is_ancestor (priv->tree_store, iter, &child_iter)) {
GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector));
}
gtk_tree_path_free (child_path);
-
- return FALSE;
+
+ return FALSE;
}
static gboolean
ESource *source;
gboolean res = FALSE;
- source = e_source_selector_peek_primary_selection (selector);
+ source = e_source_selector_peek_primary_selection (selector);
g_signal_emit (selector, signals[POPUP_EVENT], 0, source, NULL, &res);
return res;
}
gboolean res = FALSE;
priv->toggled_last = FALSE;
-
+
/* only process right-clicks */
if (event->button != 3 || event->type != GDK_BUTTON_PRESS)
return FALSE;
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), event->x, event->y, &path, NULL, NULL, NULL)) {
GtkTreeIter iter;
gpointer data;
-
+
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->tree_store), &iter, path)) {
gtk_tree_model_get (GTK_TREE_MODEL (priv->tree_store), &iter, 0, &data, -1);
- /* Do not emit popup since we will not be able to get the source */
+ /* Do not emit popup since we will not be able to get the source */
if (E_IS_SOURCE_GROUP (data)) {
/* do i need to ref it here */
ESourceGroup *group;
-
+
group = E_SOURCE_GROUP (data);g_object_ref (group);
priv->primary_source_group = group;
/* data shuld be unreffed after creating the
- * new source*/
+ * new source*/
return res;
}
-
+
source = E_SOURCE (data);
}
}
widget_class->popup_menu = selector_popup_menu;
- signals[SELECTION_CHANGED] =
+ signals[SELECTION_CHANGED] =
g_signal_new ("selection_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- signals[PRIMARY_SELECTION_CHANGED] =
+ signals[PRIMARY_SELECTION_CHANGED] =
g_signal_new ("primary_selection_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
void *data;
const char *name = NULL;
gboolean status = TRUE;
-
+
gtk_tree_model_get (model, iter, 0, &data, -1);
if (E_IS_SOURCE_GROUP (data))
name = e_source_group_peek_name (E_SOURCE_GROUP (data));
else {
g_assert (E_IS_SOURCE (data));
-
+
name = e_source_peek_name (E_SOURCE (data));
}
if (name)
status = g_ascii_strncasecmp (name, key, strlen(key)) != 0;
-
+
g_object_unref (data);
-
+
return status;
}
priv = g_new0 (ESourceSelectorPrivate, 1);
selector->priv = priv;
-
+
gtk_tree_view_set_search_column (GTK_TREE_VIEW (selector), 0);
gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (selector), group_search_function, NULL, NULL);
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (selector), TRUE);
-
+
g_signal_connect (G_OBJECT (selector), "button_press_event",
G_CALLBACK (selector_button_press_event), selector);
/**
* e_source_selector_new:
* @list: A source list.
- *
+ *
* Create a new view for @list. The view will update automatically when @list
* changes.
- *
+ *
* Return value: The newly created widget.
**/
GtkWidget *
/**
* e_source_selector_get_selection:
* @selector: an #ESourceSelector
- *
+ *
* Get the list of selected sources, i.e. those that were enabled through the
* corresponding checkboxes in the tree.
- *
+ *
* Return value: A list of the ESources currently selected. The sources will
* be in the same order as they appear on the screen, and the list should be
* freed using e_source_selector_free_selection().
/**
* e_source_selector_get_primary_source_group:
* @selector: an #ESourceSelector
- *
+ *
* Gets the primary source group associated with the selector.
*
* Return value: primary_source_group if selector is valid, NULL otherwise.
e_source_selector_get_primary_source_group (ESourceSelector *selector)
{
g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), NULL);
-
+
return selector->priv->primary_source_group;
}
/**
* e_source_list_free_selection:
* @list: A selection list returned by e_source_selector_get_selection().
- *
+ *
* Free the selection list.
**/
void
/**
* e_source_selector_show_selection:
* @selector: An ESourceSelector widget
- *
+ *
* Specify whether the checkboxes in the ESourceSelector should be shown or
* not.
**/
/**
* e_source_selector_selection_shown:
* @selector: an #ESourceSelector
- *
+ *
* Check whether the checkboxes in the ESourceSelector are being shown or not.
- *
+ *
* Return value: %TRUE if the checkboxes are shown, %FALSE otherwise.
**/
gboolean
* e_source_selector_select_source:
* @selector: An #ESourceSelector widget
* @source: An #ESource.
- *
+ *
* Select @source in @selector.
**/
void
ESource *source)
{
GtkTreeIter parent_iter, source_iter;
-
+
g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
g_return_if_fail (E_IS_SOURCE (source));
if (find_source_iter (selector, source, &parent_iter, &source_iter)) {
GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store);
GtkTreePath *path;
-
+
path = gtk_tree_model_get_path (model, &source_iter);
gtk_tree_model_row_changed (model, path, &source_iter);
gtk_tree_path_free (path);
-
+
g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
- }
+ }
}
/**
* e_source_selector_unselect_source:
* @selector: An #ESourceSelector widget
* @source: An #ESource.
- *
+ *
* Unselect @source in @selector.
**/
void
if (find_source_iter (selector, source, &parent_iter, &source_iter)) {
GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store);
GtkTreePath *path;
-
+
path = gtk_tree_model_get_path (model, &source_iter);
gtk_tree_model_row_changed (model, path, &source_iter);
gtk_tree_path_free (path);
-
+
g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
}
}
* e_source_selector_source_is_selected:
* @selector: An #ESourceSelector widget
* @source: An #ESource.
- *
+ *
* Check whether @source is selected in @selector.
- *
+ *
* Return value: %TRUE if @source is currently selected, %FALSE otherwise.
**/
gboolean
/**
* e_source_selector_peek_primary_selection:
* @selector: An #ESourceSelector widget
- *
+ *
* Get the primary selected source. The primary selection is the one that is
* highlighted through the normal #GtkTreeView selection mechanism (as opposed
* to the "normal" selection, which is the set of source whose checkboxes are
* checked).
- *
+ *
* Return value: The selected source.
**/
ESource *
if (selector->priv->saved_primary_selection) {
GtkTreePath *child_path;
-
+
child_path = gtk_tree_row_reference_get_path (selector->priv->saved_primary_selection);
if (child_path) {
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (selector->priv->tree_store), &iter, child_path))
if (! E_IS_SOURCE (data)) {
g_object_unref (data);
-
+
return NULL;
}
-
+
g_object_unref (data);
-
+
return E_SOURCE (data);
}
* e_source_selector_set_primary_selection:
* @selector: an #ESourceSelector widget
* @source: an #ESource to select
- *
+ *
* Set the primary selected source.
**/
void
if (!source)
return;
-
+
if (find_source_iter (selector, source, &parent_iter, &source_iter)) {
GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector));
GtkTreePath *path;
-
+
/* We block the signal because this all needs to be atomic */
g_signal_handlers_block_matched (selection, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, selection_changed_callback, NULL);
gtk_tree_selection_unselect_all (selection);
g_signal_handlers_unblock_matched (selection, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, selection_changed_callback, NULL);
clear_saved_primary_selection (selector);
-
+
path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tree_store), &parent_iter);
-
+
if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (selector), path)) {
gtk_tree_selection_select_iter (selection, &source_iter);
} else {
GtkTreePath *child_path;
-
- child_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tree_store), &source_iter);
+
+ child_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tree_store), &source_iter);
priv->saved_primary_selection = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->tree_store), child_path);
gtk_tree_path_free (child_path);
gtk_tree_model_row_changed (GTK_TREE_MODEL (priv->tree_store), path, &source_iter);
g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
}
-
+
g_signal_emit (selector, signals[PRIMARY_SELECTION_CHANGED], 0);
}
-
+
gtk_tree_path_free (path);
} else {
- g_warning (G_STRLOC ": Cannot find source %p (%s) in selector %p",
+ g_warning (G_STRLOC ": Cannot find source %p (%s) in selector %p",
source, e_source_peek_name (source), selector);
}
}
* @child_iter: a #GtkTreeIter to set
* @permutation_n: a permutation index to set
* @generator_iter: a #GtkTreeIter indicating the row to convert
- *
+ *
* Converts a @tree_model_generator row into a child row and permutation index.
* The permutation index is the index of the generated row based on this
* child row, with the first generated row based on this child row being 0.
const char *gconf_path;
gtk_init (&argc, &argv);
-
+
if (argc < 2)
gconf_path = "/apps/evolution/calendar/sources";
else
fprintf (stderr, "%s\n", failed);
exit (1);
}
- /* else fall through */
+ /* else fall through */
default:
fprintf (stderr, "Unknown error.\n");
lose:
e2k_action_free (act);
- return FALSE;
+ return FALSE;
}
/**
gchar *filename = g_build_filename (CONNECTOR_PREFIX,
"etc/connector.conf",
NULL);
-
+
fd = g_open (filename, O_RDONLY, 0);
g_free (filename);
}
return g_hash_table_lookup (config_options, option);
}
-static gboolean
+static gboolean
validate (const char *owa_url, char *user, char *password, ExchangeParams *exchange_params, E2kAutoconfigResult *result)
{
E2kAutoconfig *ac;
const char *old, *new;
char *path, *mailbox;
- ac = e2k_autoconfig_new (owa_url, user, password,
+ ac = e2k_autoconfig_new (owa_url, user, password,
E2K_AUTOCONFIG_USE_EITHER);
e2k_operation_init (&op);
if (*result == E2K_AUTOCONFIG_OK) {
/*
- * On error code 403 and SSL seen in server response
+ * On error code 403 and SSL seen in server response
* e2k_autoconfig_get_context() tries to
* connect using https if owa url has http and vice versa.
* And also re-sets the owa_uri in E2kAutoconfig.
- * So even if the uri is incorrect,
+ * So even if the uri is incorrect,
* e2k_autoconfig_check_exchange() will return success.
* In this case of account set up, owa_url paramter will still
* have wrong url entered, and we throw the error, instead of
- * going ahead with account setup and failing later.
+ * going ahead with account setup and failing later.
*/
if (g_str_has_prefix (ac->owa_uri, "http:")) {
if (!g_str_has_prefix (owa_url, "http:"))
if (*result == E2K_AUTOCONFIG_OK) {
*result = e2k_autoconfig_check_global_catalog (ac, &op);
e2k_operation_free (&op);
-
- /* find mailbox and owa_path values */
+
+ /* find mailbox and owa_path values */
euri = e2k_uri_new (ac->home_uri);
path = g_strdup (euri->path + 1);
e2k_uri_free (euri);
exchange_params->owa_path = g_strdup_printf ("%s%s", "/", path);
g_free (path);
exchange_params->host = g_strdup (ac->pf_server);
- if (ac->gc_server)
+ if (ac->gc_server)
exchange_params->ad_server = g_strdup (ac->gc_server);
exchange_params->is_ntlm = ac->saw_ntlm;
uri = e_uri_new (owa_url);
key = g_strdup_printf ("%s%s/", pkey, uri->host); /* FIXME */
e_uri_free (uri);
-
+
try_auth_again:
username = g_strdup (*user);
if (password) {
/* This can be the case, where user presses authenticate button and
* later cancels the account setup or removal of account fails for
- * some reason. We need to prompt for the password always when
+ * some reason. We need to prompt for the password always when
* authenticate button is pressed */
e_passwords_forget_password ("Exchange", key);
}
-
+
prompt = g_strdup_printf (_("Enter password for %s"), username);
password = e_passwords_ask_password (_("Enter password"),
"Exchange", key, prompt,
valid = validate (owa_url, username, password, exchange_params, result);
if (valid) {
- /* generate the proper key once the host name
- * is read and remember password temporarily,
- * so that at the end of * account creation,
+ /* generate the proper key once the host name
+ * is read and remember password temporarily,
+ * so that at the end of * account creation,
* user will not be prompted, for password will
- * not be asked again.
+ * not be asked again.
*/
*remember_password = remember;
g_free (key);
if (exchange_params->is_ntlm)
- key = g_strdup_printf ("exchange://%s;auth=NTLM@%s/",
+ key = g_strdup_printf ("exchange://%s;auth=NTLM@%s/",
username, exchange_params->host);
else
key = g_strdup_printf ("exchange://%s@%s/", username, exchange_params->host);
}
else {
if (try == 0) {
- /* Check for name as e-mail id and try once again
- * extracing username from e-mail id.
+ /* Check for name as e-mail id and try once again
+ * extracing username from e-mail id.
*/
usernames = g_strsplit (*user, "@", 2);
if (usernames && usernames[0] && usernames[1]) {
suri = soup_uri_new (uri);
if (!suri)
return NULL;
-
+
if (!suri->host) {
soup_uri_free (suri);
return NULL;
g_object_unref (ctx->priv->async_session);
/* Set a default timeout value of 30 seconds.
- FIXME: Make timeout configurable
+ FIXME: Make timeout configurable
*/
if (g_getenv ("SOUP_SESSION_TIMEOUT"))
timeout = atoi (g_getenv ("SOUP_SESSION_TIMEOUT"));
-
+
ctx->priv->session = soup_session_sync_new_with_options (
SOUP_SESSION_USE_NTLM, !authmech || !strcmp (authmech, "NTLM"),
SOUP_SESSION_TIMEOUT, timeout,
}
g_string_append (propxml, "\r\n</D:prop>\r\n</D:propfind>");
- msg = e2k_soup_message_new_full (ctx, base_uri,
+ msg = e2k_soup_message_new_full (ctx, base_uri,
hrefs ? "BPROPFIND" : "PROPFIND",
"text/xml", SOUP_BUFFER_SYSTEM_OWNED,
propxml->str, propxml->len);
* Notifications can be used *only* to discover changes made by other
* clients! The code cannot assume that it will receive a notification
* for every change that it makes to the server, for two reasons:
- *
+ *
* First, if multiple notifications occur within @min_interval seconds
* of each other, the later ones will be suppressed, to avoid
* excessive traffic between the client and the server as the client
const char *body,
gulong length);
void e2k_context_queue_message (E2kContext *ctx,
- SoupMessage *msg,
- SoupMessageCallbackFn callback,
+ SoupMessage *msg,
+ SoupMessageCallbackFn callback,
gpointer user_data);
E2kHTTPStatus e2k_context_send_message (E2kContext *ctx,
E2kOperation *op,
e2k_freebusy_add_interval (fb, busy,
e2k_parse_timestamp (start),
e2k_parse_timestamp (end));
-
+
}
return e2k_result_iter_free (iter);
start_tm.tm_year++;
start_tm.tm_mon = 0;
}
- }
+ }
e2k_properties_set_int_array (props, month_list_prop, monthyears);
datas = g_ptr_array_new ();
E2K_GC_DEBUG_MSG(("GC: Using global mailbox store limits\n"));
}
ldap_value_free (quota_setting_values);
-
+
quota_limit_values = ldap_get_values (gc->priv->ldap, msg, "mDBStorageQuota");
if (quota_limit_values) {
entry->quota_warn = atoi(quota_limit_values[0]);
E2K_GC_DEBUG_MSG(("GC: mDBStorageQuota %s\n", quota_limit_values[0]));
- ldap_value_free (quota_limit_values);
+ ldap_value_free (quota_limit_values);
}
quota_limit_values = ldap_get_values (gc->priv->ldap, msg, "mDBOverQuotaLimit");
if (quota_limit_values) {
entry->quota_nosend = atoi(quota_limit_values[0]);
E2K_GC_DEBUG_MSG(("GC: mDBOverQuotaLimit %s\n", quota_limit_values[0]));
- ldap_value_free (quota_limit_values);
+ ldap_value_free (quota_limit_values);
}
quota_limit_values = ldap_get_values (gc->priv->ldap, msg, "mDBOverHardQuotaLimit");
if (quota_limit_values) {
entry->quota_norecv = atoi(quota_limit_values[0]);
E2K_GC_DEBUG_MSG(("GC: mDBHardQuotaLimit %s\n", quota_limit_values[0]));
- ldap_value_free (quota_limit_values);
+ ldap_value_free (quota_limit_values);
}
}
static void
-get_account_control_values (E2kGlobalCatalog *gc, E2kOperation *op,
+get_account_control_values (E2kGlobalCatalog *gc, E2kOperation *op,
LDAPMessage *msg, E2kGlobalCatalogEntry *entry)
{
char **values;
entry->mask |= E2K_GLOBAL_CATALOG_LOOKUP_ACCOUNT_CONTROL;
ldap_value_free (values);
}
-
+
}
/**
}
if (dn_value->str[0])
dn = g_strndup (dn_value->str, strlen(dn_value->str) - 1);
- else
+ else
dn = NULL;
g_string_free (dn_value, TRUE);
return dn;
}
-double
+double
lookup_passwd_max_age (E2kGlobalCatalog *gc, E2kOperation *op)
{
char **values = NULL, *filter = NULL, *val=NULL;
int ldap_error, msgid;
double maxAge=0;
gchar *dn=NULL;
-
+
attrs[0] = "maxPwdAge";
attrs[1] = NULL;
ldap_error = get_ldap_connection (gc, op, gc->priv->server, LDAP_PORT, &ldap);
if (ldap_error != LDAP_SUCCESS) {
- E2K_GC_DEBUG_MSG(("GC: Establishing ldap connection failed : 0x%02x\n\n",
+ E2K_GC_DEBUG_MSG(("GC: Establishing ldap connection failed : 0x%02x\n\n",
ldap_error));
- return -1;
+ return -1;
}
- ldap_error = ldap_search_ext (ldap, dn, LDAP_SCOPE_BASE, filter, (char **)attrs,
+ ldap_error = ldap_search_ext (ldap, dn, LDAP_SCOPE_BASE, filter, (char **)attrs,
FALSE, NULL, NULL, NULL, 0, &msgid);
if (!ldap_error) {
ldap_error = gc_ldap_result (ldap, op, msgid, &msg);
values = ldap_get_values (ldap, msg, "maxPwdAge");
if (!values) {
- E2K_GC_DEBUG_MSG(("GC: couldn't retrieve maxPwdAge\n"));
+ E2K_GC_DEBUG_MSG(("GC: couldn't retrieve maxPwdAge\n"));
return -1;
}
if (values[0]) {
val = values[0];
if (*val == '-')
- ++val;
+ ++val;
maxAge = strtod (val, NULL);
}
E2kSid *sid;
char *email, *exchange_server, *mailbox, *legacy_exchange_dn;
GPtrArray *delegates, *delegators;
- int quota_warn, quota_nosend, quota_norecv;
+ int quota_warn, quota_nosend, quota_norecv;
int user_account_control;
E2kGlobalCatalogLookupFlags mask;
E2kGlobalCatalogCallback callback,
gpointer user_data);
-double lookup_passwd_max_age (E2kGlobalCatalog *gc,
+double lookup_passwd_max_age (E2kGlobalCatalog *gc,
E2kOperation *op);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Copyright (C) 2001 Ximian, Inc.
*
* This library is free software; you can redistribute it and/or
*
* Computes the MAPI proptag value of @prop, which must be the name
* of a MAPI property.
- *
+ *
* Return value: the MAPI proptag value
**/
guint32
if (!e2k_rule_extract_byte (data, len, &nprops))
return FALSE;
-
+
props = g_new0 (E2kPropValue, nprops);
for (i = 0; i < nprops; i++) {
if (!e2k_rule_extract_propvalue (data, len, &props[i])) {
const char *propname2);
E2kRestriction *e2k_restriction_bitmask (const char *propname,
E2kRestrictionBitop bitop,
- guint32 mask);
+ guint32 mask);
E2kRestriction *e2k_restriction_size (const char *propname,
E2kRestrictionRelop relop,
guint32 size);
ret = string->str;
g_string_free (string, FALSE);
return ret;
-}
+}
static gboolean
action_to_xml (E2kAction *act, xmlNode *actionset)
top = xmlNewChild (ruleset, NULL, "rule", NULL);
- xmlSetProp (top, "source",
+ xmlSetProp (top, "source",
(rule->state & E2K_RULE_STATE_ONLY_WHEN_OOF) ?
"oof" : "incoming");
xmlSetProp (top, "enabled", (rule->state & E2K_RULE_STATE_ENABLED) ? "1" : "0");
E2kActionType type;
guint32 flavor;
guint32 flags;
-
+
union {
struct {
GByteArray *store_entryid;
GByteArray *folder_source_key;
} xfer;
-
+
struct {
GByteArray *entryid;
guint8 reply_template_guid[16];
ace.Mask = object_denied;
set_ace (sd, &ace);
}
-
+
ace.Header.AceType = E2K_ACCESS_ALLOWED_ACE_TYPE;
ace.Header.AceFlags = E2K_CONTAINER_INHERIT_ACE;
ace.Mask = container_allowed;
g_datalist_clear (&uri->params);
g_free (uri->query);
g_free (uri->fragment);
-
+
g_free (uri);
}
}
printf ("%s\n", results[0].href);
props = g_ptr_array_new ();
e2k_properties_foreach (results[0].props, add_prop, props);
- qsort (props->pdata, props->len, sizeof (gpointer), prop_compar);
+ qsort (props->pdata, props->len, sizeof (gpointer), prop_compar);
for (i = 0; i < props->len; i++)
print_prop (props->pdata[i]);
int status;
char *eml_str, *top = uri, fav_uri[1024];
-
+
/* list the contents and search for the favorite properties */
e2k_operation_init (&op);
prop = E2K_PR_DAV_DISPLAY_NAME;
E2kGlobalCatalogEntry *entry;
E2kGlobalCatalogLookupType type;
guint32 flags;
- int i, pwd_exp_days;
+ int i, pwd_exp_days;
double maxAge;
if (*user == '/')
if (entry->quota_warn || entry->quota_nosend || entry->quota_norecv )
printf (" Mail Quota Info:\n");
- if (entry->quota_warn)
+ if (entry->quota_warn)
printf (" Issue Quota warning at : %d\n", entry->quota_warn);
if (entry->quota_nosend)
printf (" Stop sending mails at : %d\n", entry->quota_nosend);
printf (" Stop sending and recieving mails at : %d\n", entry->quota_norecv);
if (entry->user_account_control)
printf (" user_account_control : %d\n", entry->user_account_control);
-
+
maxAge = lookup_passwd_max_age (gc, &op);
printf("Password max age is %f \n", maxAge);
if (euri->protocol)
printf("Protocol : %s \n", euri->protocol);
- else
- printf ("Protocol : NULL \n");
+ else
+ printf ("Protocol : NULL \n");
if (euri->user)
printf("User : %s \n", euri->user);
- else
- printf ("User : NULL \n");
+ else
+ printf ("User : NULL \n");
if (euri->domain)
printf("Domain : %s \n", euri->domain);
- else
- printf ("Domain : NULL \n");
+ else
+ printf ("Domain : NULL \n");
if (euri->authmech)
printf("Authmech : %s \n", euri->authmech);
- else
- printf ("Authmech : NULL \n");
+ else
+ printf ("Authmech : NULL \n");
if (euri->passwd)
printf("Password : %s \n", euri->passwd);
- else
- printf ("Password : NULL \n");
+ else
+ printf ("Password : NULL \n");
if (euri->host)
printf("Host : %s \n", euri->host);
- else
- printf ("Host : NULL \n");
+ else
+ printf ("Host : NULL \n");
if (euri->port)
printf("Port : %d \n", euri->port);
- else
- printf ("Port : NULL \n");
+ else
+ printf ("Port : NULL \n");
if (euri->path)
printf("Path : %s \n", euri->path);
- else
- printf ("Path : NULL \n");
+ else
+ printf ("Path : NULL \n");
if (euri->params) {
printf("\nParams : \n");
- temp = e2k_uri_get_param (euri, "ad_server");
+ temp = e2k_uri_get_param (euri, "ad_server");
if (temp) printf ("\tAd server = %s\n", temp);
else printf ("\tAd server = NULL \n");
- temp = e2k_uri_get_param (euri, "ad_limit");
+ temp = e2k_uri_get_param (euri, "ad_limit");
if (temp) printf ("\tAd Limit = %s\n", temp);
else printf ("\tAd Limit = NULL\n");
- temp = e2k_uri_get_param (euri, "passwd_exp_warn_period");
+ temp = e2k_uri_get_param (euri, "passwd_exp_warn_period");
if (temp) printf ("\tPasswd expiry warn period = %s\n", temp);
else printf ("\tPasswd expiry warn period = NULL \n");
- temp = e2k_uri_get_param (euri, "offline_sync");
+ temp = e2k_uri_get_param (euri, "offline_sync");
if (temp) printf ("\tOffline Sync = %s\n", temp);
else printf ("\tOffline Sync = NULL \n");
- temp = e2k_uri_get_param (euri, "owa_path");
+ temp = e2k_uri_get_param (euri, "owa_path");
if (temp) printf ("\tOwa path = %s\n", temp);
else printf ("\tOwa path = NULL \n");
- temp = e2k_uri_get_param (euri, "pf_server");
+ temp = e2k_uri_get_param (euri, "pf_server");
if (temp) printf ("\tPf server = %s\n", temp);
else printf ("\tPf server = NULL \n");
- temp = e2k_uri_get_param (euri, "use_ssl");
+ temp = e2k_uri_get_param (euri, "use_ssl");
if (temp) printf ("\tSSL = %s\n", temp);
else printf ("\tSSL = NULL\n");
- temp = e2k_uri_get_param (euri, "mailbox");
+ temp = e2k_uri_get_param (euri, "mailbox");
if (temp) printf ("\tMailbox = %s\n", temp);
else printf ("\tMailbox = NULL \n");
- temp = e2k_uri_get_param (euri, "filter");
+ temp = e2k_uri_get_param (euri, "filter");
if (temp) printf ("\tFilter = %s\n", temp);
else printf ("\tFilter = NULL \n");
- temp = e2k_uri_get_param (euri, "filter_junk");
+ temp = e2k_uri_get_param (euri, "filter_junk");
if (temp) printf ("\tFilter junk = %s\n", temp);
else printf ("\tFilter junk = NULL \n");
- temp = e2k_uri_get_param (euri, "filter_junk_inbox");
+ temp = e2k_uri_get_param (euri, "filter_junk_inbox");
if (temp) printf ("\tFilter junk inbox = %s\n", temp);
else printf ("\tFilter junk inbox = NULL \n");
- temp = e2k_uri_get_param (euri, "owa_protocol");
+ temp = e2k_uri_get_param (euri, "owa_protocol");
if (temp) printf ("\tOwa protocol = %s\n", temp);
else printf ("\tOwa protocol = NULL \n");
- temp = e2k_uri_get_param (euri, "owa_url");
+ temp = e2k_uri_get_param (euri, "owa_url");
if (temp) printf ("\tOwa url = %s\n", temp);
else printf ("\tOwa url = NULL \n");
}
- else
- printf ("Params : NULL \n");
+ else
+ printf ("Params : NULL \n");
if (euri->query)
printf("Query : %s \n", euri->query);
- else
- printf ("Query : NULL \n");
+ else
+ printf ("Query : NULL \n");
if (euri->fragment)
printf("Fragment : %s \n", euri->fragment);
- else
- printf ("Fragment : NULL \n");
+ else
+ printf ("Fragment : NULL \n");
}
void
new_path = g_strdup (comps[0]);
g_strfreev (comps);
- return new_path;
+ return new_path;
}
-#define d(x)
+#define d(x)
/**
* e_folder_exchange_new:
g_return_val_if_fail (physical_uri != NULL, NULL);
g_return_val_if_fail (internal_uri != NULL, NULL);
- d(g_print ("e_folder_exchange_new: name=[%s], type=[%s], internal_uri=[%s], physical_uri=[%s]\n",
+ d(g_print ("e_folder_exchange_new: name=[%s], type=[%s], internal_uri=[%s], physical_uri=[%s]\n",
name, type, internal_uri, physical_uri));
efe = g_object_new (E_TYPE_FOLDER_EXCHANGE, NULL);
efe->priv->outlook_class = g_strdup (outlook_class);
/* Add ESources */
- if (hier->type == EXCHANGE_HIERARCHY_PERSONAL ||
+ if (hier->type == EXCHANGE_HIERARCHY_PERSONAL ||
hier->type == EXCHANGE_HIERARCHY_FAVORITES) {
-
+
if ((strcmp (type, "calendar") == 0) ||
(strcmp (type, "calendar/public") == 0)) {
- add_folder_esource (hier->account,
- EXCHANGE_CALENDAR_FOLDER,
- name,
+ add_folder_esource (hier->account,
+ EXCHANGE_CALENDAR_FOLDER,
+ name,
physical_uri);
}
else if ((strcmp (type, "tasks") == 0) ||
(strcmp (type, "tasks/public") == 0)) {
- add_folder_esource (hier->account,
- EXCHANGE_TASKS_FOLDER,
- name,
+ add_folder_esource (hier->account,
+ EXCHANGE_TASKS_FOLDER,
+ name,
physical_uri);
}
else if ((strcmp (type, "contacts") == 0) ||
(strcmp (type, "contacts/public") == 0)) {
- add_folder_esource (hier->account,
- EXCHANGE_CONTACTS_FOLDER,
- name,
+ add_folder_esource (hier->account,
+ EXCHANGE_CONTACTS_FOLDER,
+ name,
physical_uri);
}
}
g_return_val_if_fail (E_IS_FOLDER_EXCHANGE (folder), NULL);
return E_FOLDER_EXCHANGE (folder)->priv->hier;
-}
+}
/**
* e_folder_exchange_get_storage_file:
E2kHTTPStatus
e_folder_exchange_put_new (EFolder *folder,
E2kOperation *op,
- const char *object_name,
+ const char *object_name,
E2kContextTestCallback test_callback,
gpointer user_data,
const char *content_type,
g_return_val_if_fail (E_IS_FOLDER_EXCHANGE (folder), E2K_HTTP_MALFORMED);
/* remove ESources */
- hier = e_folder_exchange_get_hierarchy (folder);
+ hier = e_folder_exchange_get_hierarchy (folder);
if (hier->type == EXCHANGE_HIERARCHY_PERSONAL ||
hier->type == EXCHANGE_HIERARCHY_FAVORITES) {
if ((strcmp (folder_type, "calendar") == 0) ||
(strcmp (folder_type, "calendar/public") == 0)) {
- remove_folder_esource (hier->account,
+ remove_folder_esource (hier->account,
EXCHANGE_CALENDAR_FOLDER,
physical_uri);
}
physical_uri);
}
else if ((strcmp (folder_type, "contacts") == 0) ||
- (strcmp (folder_type, "contacts/public") == 0)) {
+ (strcmp (folder_type, "contacts/public") == 0)) {
remove_folder_esource (hier->account,
EXCHANGE_CONTACTS_FOLDER,
physical_uri);
* e_folder_tree_new:
* @folder_destroy_notify: Function to be called when a folder gets removed from the tree
* @closure: Additional data to pass to @folder_destroy_notify
- *
+ *
* Create a new EFolderTree.
- *
+ *
* Return value: A pointer to the newly created EFolderTree.
**/
EFolderTree *
/**
* e_folder_tree_destroy:
* @folder_tree: A pointer to an EFolderTree
- *
+ *
* Destroy @folder_tree.
**/
void
* @folder_tree: A pointer to an EFolderTree
* @path: Path at which the new folder must be added
* @data: Data associated with the new folder
- *
+ *
* Insert a new folder at @path, with the specified @data.
*
* Return value: %TRUE if successful, %FALSE if failed.
* e_folder_tree_remove:
* @folder_tree: A pointer to an EFolderTree
* @path: Path of the folder to remove
- *
+ *
* Remove the folder at @path from @folder_tree.
*
* Return value: %TRUE if successful, %FALSE if failed.
void *closure)
{
int *count = closure;
-
+
(*count)++;
}
/**
* e_folder_tree_get_count:
* @folder_tree: A pointer to an EFolderTree
- *
+ *
* Gets the number of folders in the tree
- *
+ *
* Return value: The number of folders in the tree
**/
int
e_folder_tree_get_count (EFolderTree *folder_tree)
{
int count = 0;
-
+
e_folder_tree_foreach (folder_tree, count_nodes, &count);
-
+
return count;
}
-
+
/**
* e_folder_tree_get_folder:
* @folder_tree: A pointer to an EFolderTree
* @path: Path of the folder for which we want to get the data
- *
+ *
* Get the data for the folder at @path.
- *
+ *
* Return value: The pointer to the data for the folder at @path.
**/
void *
* e_folder_tree_get_subfolders:
* @folder_tree: A pointer to an EFolderTree
* @path: A path in @folder_tree
- *
+ *
* Get a list of the paths of the subfolders of @path.
- *
+ *
* Return value: A list of pointers to the paths of the subfolders. The list
* and the strings must be freed by the caller.
**/
/**
* e_folder_tree_foreach:
- * @folder_tree:
- * @foreach_func:
- * @data:
- *
+ * @folder_tree:
+ * @foreach_func:
+ * @data:
+ *
* Call @foreach_func with the specified @data for all the folders
* in @folder_tree, starting at the root node.
**/
* e_folder_tree_get_path_for_data:
* @folder_tree: A pointer to an EFolderTree
* @data: The data for the folder for which the path is needed
- *
+ *
* Look up the path for the specified @data.
- *
+ *
* Return value: The path for the folder that holds that @data.
**/
const char *
EFolderTree *e_folder_tree_new (EFolderDestroyNotify folder_destroy_notify,
void *closure);
-
+
void e_folder_tree_destroy (EFolderTree *folder_tree);
-
+
gboolean e_folder_tree_add (EFolderTree *folder_tree,
const char *path,
void *data);
const char *path);
GList *e_folder_tree_get_subfolders (EFolderTree *folder_tree,
const char *path);
-
+
void e_folder_tree_foreach (EFolderTree *folder_tree,
EFolderTreeForeachFunc foreach_func,
void *data);
/**
* e_folder_get_custom_icon:
* @folder: An EFolder
- *
+ *
* Get the name of the custom icon for @folder, or NULL if no custom icon is
* associated with it.
**/
/**
* e_folder_get_sorting_priority:
* @folder: An EFolder
- *
+ *
* Get the sorting priority for @folder.
- *
+ *
* Return value: Sorting priority value for @folder.
**/
int
* @folder: An EFolder
* @icon_name: Name of the icon to be set (to be found in the standard
* Evolution icon dir)
- *
+ *
* Set a custom icon for @folder (thus overriding the default icon, which is
* the one associated to the type of the folder).
**/
* e_folder_set_sorting_priority:
* @folder: An EFolder
* @sorting_priority: A sorting priority number
- *
+ *
* Set the sorting priority for @folder. Folders have a default sorting
* priority of zero; when deciding the sort order in the Evolution folder tree,
* folders with the same priority value are compared by name, while folders
p = strrchr (path, '/');
if (p && p != path) {
char *name;
-
+
name = g_strndup (path, p - path);
folder = e_folder_tree_get_folder (priv->folder_tree, name);
g_free (name);
* e_storage_get_path_for_physical_uri:
* @storage: A storage
* @physical_uri: A physical URI
- *
+ *
* Look for the folder having the specified @physical_uri.
- *
+ *
* Return value: The path of the folder having the specified @physical_uri in
* @storage. If such a folder does not exist, just return NULL. The return
* value must be freed by the caller.
#include <stdlib.h>
#include <string.h>
-#define d(x)
+#define d(x)
#define ADS_UF_DONT_EXPIRE_PASSWORD 0x10000
#define ONE_HUNDRED_NANOSECOND 0.000000100
#define SECONDS_IN_DAY 86400
ExchangeFolderSize *fsize;
GMutex *connect_lock;
- gboolean connecting, connected;
+ gboolean connecting, connected;
int account_online;
GPtrArray *hierarchies;
g_hash_table_insert (account->priv->fresh_folders,
key,
folder);
- }
-
+ }
+
key = (char *) e_folder_get_physical_uri (folder);
if (!g_hash_table_lookup (account->priv->folders, key)) {
/* Avoid dupilcations since the user could add a folder as
key = (char *) e_folder_exchange_get_internal_uri (folder);
if (!g_hash_table_lookup (account->priv->folders, key)) {
- /* The internal_uri for public folders and favorites folder
- is same !!! Without this check the folder value could
+ /* The internal_uri for public folders and favorites folder
+ is same !!! Without this check the folder value could
overwrite the previously added folder. */
g_object_ref (folder);
g_hash_table_insert (account->priv->folders,
table_updated = 1;
}
- if (permanent_uri && (!g_hash_table_lookup (account->priv->folders,
+ if (permanent_uri && (!g_hash_table_lookup (account->priv->folders,
permanent_uri))) {
g_object_ref (folder);
g_hash_table_insert (account->priv->folders,
folder);
table_updated = 1;
}
-
+
if (table_updated)
{
- g_hash_table_insert (account->priv->hierarchies_by_folder,
+ g_hash_table_insert (account->priv->hierarchies_by_folder,
folder, hier);
g_signal_emit (account, signals[NEW_FOLDER], 0, folder);
hierarchy_removed_folder (ExchangeHierarchy *hier, EFolder *folder,
ExchangeAccount *account)
{
- if (!g_hash_table_lookup (account->priv->folders,
+ if (!g_hash_table_lookup (account->priv->folders,
e_folder_exchange_get_path (folder)))
return;
- g_hash_table_remove (account->priv->folders,
+ g_hash_table_remove (account->priv->folders,
e_folder_exchange_get_path (folder));
- g_hash_table_remove (account->priv->folders,
+ g_hash_table_remove (account->priv->folders,
e_folder_get_physical_uri (folder));
- /* Dont remove this for favorites, as the internal_uri is shared
+ /* Dont remove this for favorites, as the internal_uri is shared
by the public folder as well */
if (hier->type != EXCHANGE_HIERARCHY_FAVORITES) {
- g_hash_table_remove (account->priv->folders,
+ g_hash_table_remove (account->priv->folders,
e_folder_exchange_get_internal_uri (folder));
}
g_hash_table_remove (account->priv->hierarchies_by_folder, folder);
ExchangeHierarchy *hier;
EFolder *parent;
- g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
+ g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR);
if (!get_parent_and_name (account, &path, &parent, &hier))
EFolder *folder;
const char *int_uri;
- g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
+ g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR);
d(g_print ("exchange_account_remove_folder: path=[%s]\n", path));
int_uri = e_folder_exchange_get_internal_uri (folder);
- if (g_hash_table_find (account->priv->standard_uris,
+ if (g_hash_table_find (account->priv->standard_uris,
check_if_sf, (char *)int_uri)) {
return EXCHANGE_ACCOUNT_FOLDER_UNSUPPORTED_OPERATION;
}
ExchangeHierarchy *source_hier, *dest_hier;
const char *name;
- g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
+ g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR);
if (!get_folder (account, source_path, &source, &source_hier) ||
E2kGlobalCatalogStatus status;
E2kGlobalCatalogEntry *entry;
- g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
+ g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR);
if (!account->priv->gc)
ExchangeHierarchy *hier;
EFolder *folder;
- g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
+ g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR);
if (!get_folder (account, path, &folder, &hier))
EFolder *folder;
int mode;
- g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
+ g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account),
EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR);
d(g_print ("exchange_account_remove_folder: path=[%s]\n", path));
* anyway. So just ignore the request for now.
*/
return EXCHANGE_ACCOUNT_FOLDER_DOES_NOT_EXIST;
- }
-
+ }
+
return exchange_hierarchy_scan_subtree (hier, folder, mode);
}
prompt = g_strdup_printf (_("Enter password for %s"),
account->account_name);
- oldremember = remember =
+ oldremember = remember =
account->priv->account->source->save_passwd;
password = e_passwords_ask_password (
_("Enter password"),
- "Exchange",
+ "Exchange",
account->priv->password_key,
- prompt,
+ prompt,
E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET,
- &remember,
+ &remember,
NULL);
if (remember != oldremember) {
account->priv->account->source->save_passwd = remember;
}
g_free (prompt);
- }
+ }
else if (!account->priv->account->source->save_passwd) {
- /* get_password returns the password cached but user has not
- * selected remember password option, forget this password
- * whis is stored temporarily by e2k_validate_user()
+ /* get_password returns the password cached but user has not
+ * selected remember password option, forget this password
+ * whis is stored temporarily by e2k_validate_user()
*/
e_passwords_forget_password ("Exchange", account->priv->password_key);
}
if (!password) {
}
else if (!account->priv->account->source->save_passwd) {
- /* get_password returns the password cached but user has not
- * selected remember password option, forget this password
- * whis is stored temporarily by e2k_validate_user()
+ /* get_password returns the password cached but user has not
+ * selected remember password option, forget this password
+ * whis is stored temporarily by e2k_validate_user()
*/
e_passwords_forget_password ("Exchange", account->priv->password_key);
}
result = e2k_kerberos_check_password (ac->username, domain,
ac->password);
- if (result != E2K_KERBEROS_OK &&
+ if (result != E2K_KERBEROS_OK &&
result != E2K_KERBEROS_PASSWORD_EXPIRED) {
/* try again with nt domain */
domain = ac->nt_domain;
if (domain)
- result = e2k_kerberos_check_password (ac->username,
+ result = e2k_kerberos_check_password (ac->username,
domain,
ac->password);
- }
+ }
return (result == E2K_KERBEROS_PASSWORD_EXPIRED);
}
if (account->priv->passwd_exp_warn_period == -1)
return -1;
- /* Check for password expiry period */
- /* This needs to be invoked after is_password_expired(), i.e.,
+ /* Check for password expiry period */
+ /* This needs to be invoked after is_password_expired(), i.e.,
only if password is not expired */
/* Check for account control value for a user */
e2k_operation_init (&gcop);
- gcstatus = e2k_global_catalog_lookup (account->priv->gc,
- &gcop,
- E2K_GLOBAL_CATALOG_LOOKUP_BY_EMAIL,
- account->priv->identity_email,
- E2K_GLOBAL_CATALOG_LOOKUP_ACCOUNT_CONTROL,
- &entry);
+ gcstatus = e2k_global_catalog_lookup (account->priv->gc,
+ &gcop,
+ E2K_GLOBAL_CATALOG_LOOKUP_BY_EMAIL,
+ account->priv->identity_email,
+ E2K_GLOBAL_CATALOG_LOOKUP_ACCOUNT_CONTROL,
+ &entry);
e2k_operation_free (&gcop);
- if (gcstatus != E2K_GLOBAL_CATALOG_OK)
+ if (gcstatus != E2K_GLOBAL_CATALOG_OK)
return -1;
-
+
if (entry->user_account_control & ADS_UF_DONT_EXPIRE_PASSWORD) {
return -1; /* Password is not set to expire */
}
- /* Here we don't check not setting the password and expired password */
+ /* Here we don't check not setting the password and expired password */
/* Check for the maximum password age set */
- e2k_operation_init (&gcop);
- max_pwd_age = lookup_passwd_max_age (account->priv->gc, &gcop);
+ e2k_operation_init (&gcop);
+ max_pwd_age = lookup_passwd_max_age (account->priv->gc, &gcop);
e2k_operation_free (&gcop);
if (max_pwd_age > 0) {
/* Calculate password expiry period */
- max_pwd_age_days =
+ max_pwd_age_days =
( max_pwd_age * ONE_HUNDRED_NANOSECOND ) / SECONDS_IN_DAY;
if (max_pwd_age_days <= account->priv->passwd_exp_warn_period) {
return max_pwd_age_days;
}
- }
+ }
return -1;
}
/* try with nt_domain */
domain = account->priv->nt_domain;
if (domain)
- result = e2k_kerberos_change_password (account->priv->username,
+ result = e2k_kerberos_change_password (account->priv->username,
domain, old_pass,
new_pass);
}
default:
return EXCHANGE_ACCOUNT_PASSWORD_CHANGE_FAILED;
}
-
+
return EXCHANGE_ACCOUNT_PASSWORD_CHANGE_SUCCESS;
#else
g_warning ("exchange_account_set_password: Not implemented (no KRB5)");
#endif
}
-void
+void
exchange_account_set_save_password (ExchangeAccount *account, gboolean save_password)
{
account->priv->account->source->save_passwd = save_password;
}
-gboolean
+gboolean
exchange_account_is_save_password (ExchangeAccount *account)
{
return account->priv->account->source->save_passwd;
gboolean
exchange_account_set_offline (ExchangeAccount *account)
{
-
+
g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account), FALSE);
g_mutex_lock (account->priv->connect_lock);
g_mutex_lock (account->priv->connect_lock);
account->priv->account_online = ONLINE_MODE;
g_mutex_unlock (account->priv->connect_lock);
-
+
return TRUE;
}
exchange_account_is_offline (ExchangeAccount *account, int *state)
{
g_return_if_fail (EXCHANGE_IS_ACCOUNT (account));
-
+
*state = account->priv->account_online;
}
}
hierarchies_created:
-
+
/* Scan the personal and favorite folders so we can resolve references
* to the Calendar, Contacts, etc even if the tree isn't
* opened.
/* Assuming the first element being personal hierarchy. */
personal_hier = account->priv->hierarchies->pdata[0];
-
+
fresult = exchange_hierarchy_scan_subtree (personal_hier,
personal_hier->toplevel,
mode);
account->priv->favorites_hierarchy,
account->priv->favorites_hierarchy->toplevel,
mode);
- if (fresult != EXCHANGE_ACCOUNT_FOLDER_OK &&
+ if (fresult != EXCHANGE_ACCOUNT_FOLDER_OK &&
fresult != EXCHANGE_ACCOUNT_FOLDER_DOES_NOT_EXIST) {
account->priv->connecting = FALSE;
return FALSE;
* failed.
**/
E2kContext *
-exchange_account_connect (ExchangeAccount *account, const char *pword,
+exchange_account_connect (ExchangeAccount *account, const char *pword,
ExchangeAccountResult *info_result)
{
E2kAutoconfig *ac;
E2kOperation gcop;
char *user_name = NULL;
- *info_result = EXCHANGE_ACCOUNT_UNKNOWN_ERROR;
+ *info_result = EXCHANGE_ACCOUNT_UNKNOWN_ERROR;
g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account), NULL);
*info_result = EXCHANGE_ACCOUNT_CONNECT_SUCCESS;
exchange_account_is_offline (account, &mode);
-
+
g_mutex_lock (account->priv->connect_lock);
if (mode == UNSUPPORTED_MODE) {
g_mutex_unlock (account->priv->connect_lock);
return NULL;
}
-
+
if (account->priv->connecting || mode == OFFLINE_MODE) {
g_mutex_unlock (account->priv->connect_lock);
if (mode == OFFLINE_MODE) {
E2K_GLOBAL_CATALOG_LOOKUP_BY_EMAIL,
account->priv->identity_email,
E2K_GLOBAL_CATALOG_LOOKUP_QUOTA,
- &entry);
+ &entry);
e2k_operation_free (&gcop);
- /* FIXME: warning message should have quota limit value
+ /* FIXME: warning message should have quota limit value
*/
if (gcstatus == E2K_GLOBAL_CATALOG_OK) {
- if (entry->quota_norecv &&
+ if (entry->quota_norecv &&
account->mbox_size >= entry->quota_norecv) {
*info_result = EXCHANGE_ACCOUNT_QUOTA_RECIEVE_ERROR;
account->priv->quota_limit = entry->quota_norecv;
- } else if (entry->quota_nosend &&
+ } else if (entry->quota_nosend &&
account->mbox_size >= entry->quota_nosend) {
*info_result = EXCHANGE_ACCOUNT_QUOTA_SEND_ERROR;
account->priv->quota_limit = entry->quota_nosend;
- } else if (entry->quota_warn &&
+ } else if (entry->quota_warn &&
account->mbox_size >= entry->quota_warn) {
*info_result = EXCHANGE_ACCOUNT_QUOTA_WARN;
account->priv->quota_limit = entry->quota_warn;
exchange_account_get_global_catalog (ExchangeAccount *account)
{
g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account), NULL);
-
+
return account->priv->gc;
}
*
* Return value: @account's #EAccount, if it is connected and
* online, or %NULL if not.
- **/
+ **/
EAccount *
exchange_account_fetch (ExchangeAccount *acct)
{
/* Scans the subscribed users folders. */
/*FIXME This function is not really required if the syncronization
- problem between exchange and evolution is fixed. Exchange does not get to know
+ problem between exchange and evolution is fixed. Exchange does not get to know
if an user's folder is subscribed from evolution */
void
exchange_account_scan_foreign_hierarchy (ExchangeAccount *account, const char *user_email)
char *dir;
ExchangeHierarchy *hier;
int mode;
-
+
hier = g_hash_table_lookup (account->priv->foreign_hierarchies, user_email);
if (hier) {
exchange_hierarchy_rescan (hier);
* @email: email id of the foreign user
*
* If the hierarchy is present just return it back. Else try to get it
- * from the filesystem and return it.
+ * from the filesystem and return it.
*
* Return value: Returns the ExchangeHierarchy of the foreign user's folder.
**/
{
EFolder *folder = value;
- d(g_print ("%s(%d):%s: key=[%s]\t folder-path=[%s]\n", __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION,
+ d(g_print ("%s(%d):%s: key=[%s]\t folder-path=[%s]\n", __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION,
key, e_folder_exchange_get_path (folder)));
/* Each folder appears under three different keys, but
* we only want to add it to the results array once. So
* we only add when we see the "path" key.
*/
- if (!strcmp (key, e_folder_exchange_get_path (folder)))
+ if (!strcmp (key, e_folder_exchange_get_path (folder)))
g_ptr_array_add (folders, folder);
}
sizeof (EFolder *), folder_comparator);
return folders;
-}
+}
/**
* exchange_account_get_folder_tree:
g_free (fld_tree);
return folders;
-}
+}
/**
* exchange_account_get_quota_limit:
exchange_account_get_username (ExchangeAccount *account)
{
g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account), NULL);
-
+
return account->priv->username;
}
* exchange_account_get_email_id :
* @account : #ExchangeAccount
*
- * Retunrs user's e-mail id.
+ * Retunrs user's e-mail id.
*
* Return value : e-mail id string.
**/
g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account), NULL);
return account->priv->identity_email;
-}
+}
/**
* exchange_account_folder_size_add :
* @account : #ExchangeAccount
- * @folder_name :
+ * @folder_name :
* @size : Size of @folder_name
*
* Updates the #ExchangeFolderSize object with the @size of @folder_name
/**
* exchange_account_folder_size_remove :
* @account : #ExchangeAccount
- * @folder_name :
+ * @folder_name :
*
* Removes the entry for @folder_name in #ExchangeFolderSize object
*
*
* Return value : void
**/
-void
+void
exchange_account_folder_size_rename (ExchangeAccount *account,
const char *old_name,
const char *new_name)
if (cached_size >= 0) {
exchange_folder_size_remove (account->priv->fsize, old_name);
exchange_folder_size_update (account->priv->fsize,
- new_name, cached_size);
+ new_name, cached_size);
}
}
{
ExchangeAccount *account;
char *enc_user, *mailbox;
- const char *param, *proto="http", *owa_path, *pf_server, *owa_url;
+ const char *param, *proto="http", *owa_path, *pf_server, *owa_url;
const char *passwd_exp_warn_period, *offline_sync;
E2kUri *uri;
* password from this to source_uri.
* old_uri_authority = g_strdup_printf ("%s@%s", enc_user,
* uri->host);
- * old_uri_authority needs to be used in the key for migrating
+ * old_uri_authority needs to be used in the key for migrating
* passwords remembered.
*/
- account->priv->password_key = g_strdup_printf ("exchange://%s/",
+ account->priv->password_key = g_strdup_printf ("exchange://%s/",
account->priv->uri_authority);
account->priv->username = g_strdup (uri->user);
if (param)
account->priv->ad_limit = atoi (param);
}
-
+
passwd_exp_warn_period = e2k_uri_get_param (uri, "passwd_exp_warn_period");
if (!passwd_exp_warn_period || !*passwd_exp_warn_period)
account->priv->passwd_exp_warn_period = -1;
account->priv->passwd_exp_warn_period = atoi (passwd_exp_warn_period);
offline_sync = e2k_uri_get_param (uri, "offline_sync");
- if (!offline_sync)
+ if (!offline_sync)
account->priv->offline_sync = FALSE;
- else
+ else
account->priv->offline_sync = TRUE;
owa_path = e2k_uri_get_param (uri, "owa_path");
if (!pf_server || !*pf_server)
pf_server = uri->host;
- /* We set protocol reading owa_url, instead of having use_ssl parameter
+ /* We set protocol reading owa_url, instead of having use_ssl parameter
* because we don't have SSL section anymore in the account creation
* druid and account editor
*/
owa_url = e2k_uri_get_param (uri, "owa_url");
if (owa_url) {
- account->priv->owa_url = g_strdup (owa_url);
+ account->priv->owa_url = g_strdup (owa_url);
if (!strncmp (owa_url, "https:", 6))
proto = "https";
}
* @account: an #ExchangeAccount
* @type: Hierarchy type
*
- * Returns the non-foreign hierarchy pointer for the requested type
+ * Returns the non-foreign hierarchy pointer for the requested type
*
* Return value: Returns the hierarchy pointer for the requested type
**/
ExchangeHierarchy*
-exchange_account_get_hierarchy_by_type (ExchangeAccount* acct,
+exchange_account_get_hierarchy_by_type (ExchangeAccount* acct,
ExchangeHierarchyType type)
{
int i;
-
+
g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (acct), NULL);
g_return_val_if_fail (type != EXCHANGE_HIERARCHY_FOREIGN, NULL);
void exchange_account_forget_password (ExchangeAccount *acct);
-void exchange_account_set_save_password (ExchangeAccount *account,
+void exchange_account_set_save_password (ExchangeAccount *account,
gboolean save_password);
gboolean exchange_account_is_save_password (ExchangeAccount *account);
const char *old_name,
const char *new_name);
GtkListStore *exchange_account_folder_size_get_model (ExchangeAccount *account);
-void exchange_account_scan_foreign_hierarchy (ExchangeAccount *account,
+void exchange_account_scan_foreign_hierarchy (ExchangeAccount *account,
const char *user_email);
static gboolean is_offline (void);
void
-add_folder_esource (ExchangeAccount *account,
- FolderType folder_type,
- const char *folder_name,
+add_folder_esource (ExchangeAccount *account,
+ FolderType folder_type,
+ const char *folder_name,
const char *physical_uri)
{
ESource *source = NULL;
/* Unset the flag */
folder_type = folder_type & ~FORIEGN_FOLDER_FLAG;
-
+
if (folder_type == EXCHANGE_CONTACTS_FOLDER) {
- source_list = e_source_list_new_for_gconf ( client,
+ source_list = e_source_list_new_for_gconf ( client,
CONF_KEY_CONTACTS);
/* Modify the URI handling of Contacts to the same way as calendar and tasks */
if (!g_str_has_prefix (physical_uri, "gal://")) {
}
}
else if (folder_type == EXCHANGE_CALENDAR_FOLDER) {
- source_list = e_source_list_new_for_gconf ( client,
+ source_list = e_source_list_new_for_gconf ( client,
CONF_KEY_CAL);
relative_uri = g_strdup (physical_uri + strlen (EXCHANGE_URI_PREFIX));
is_contacts_folder = FALSE;
useremail = exchange_account_get_email_id (account);
authtype = exchange_account_get_authtype (account);
- if ((source_group = e_source_list_peek_group_by_name (source_list,
+ if ((source_group = e_source_list_peek_group_by_name (source_list,
account->account_name)) == NULL) {
- source_group = e_source_group_new (account->account_name,
+ source_group = e_source_group_new (account->account_name,
EXCHANGE_URI_PREFIX);
if (!e_source_list_add_group (source_list, source_group, -1)) {
g_object_unref (source_list);
if (mode == OFFLINE_MODE) {
/* If account is marked for offline sync during account
- * creation, mark all the folders for offline sync
+ * creation, mark all the folders for offline sync
*/
e_source_set_property (source, "offline_sync", "1");
}
-
+
if (foriegn_folder && (folder_type != EXCHANGE_CONTACTS_FOLDER)) {
e_source_set_property (source, "alarm", "never");
e_source_set_property (source, "foreign", "1");
}
else {
/* source group already exists*/
- if((source = e_source_group_peek_source_by_name (source_group,
+ if((source = e_source_group_peek_source_by_name (source_group,
folder_name)) == NULL) {
printf("old group, new source\n");
if (is_contacts_folder && g_str_has_prefix (physical_uri, "gal://")) {
/* Select the folder created */
if (folder_type == EXCHANGE_CALENDAR_FOLDER && !offline_flag) {
ids = gconf_client_get_list (client,
- CONF_KEY_SELECTED_CAL_SOURCES,
+ CONF_KEY_SELECTED_CAL_SOURCES,
GCONF_VALUE_STRING, NULL);
- ids = g_slist_append (ids,
+ ids = g_slist_append (ids,
g_strdup (e_source_peek_uid (source)));
gconf_client_set_list (client,
- CONF_KEY_SELECTED_CAL_SOURCES,
+ CONF_KEY_SELECTED_CAL_SOURCES,
GCONF_VALUE_STRING, ids, NULL);
g_slist_foreach (ids, (GFunc) g_free, NULL);
g_slist_free (ids);
}
else if (folder_type == EXCHANGE_TASKS_FOLDER && !offline_flag) {
- ids = gconf_client_get_list (client,
- CONF_KEY_SELECTED_TASKS_SOURCES,
+ ids = gconf_client_get_list (client,
+ CONF_KEY_SELECTED_TASKS_SOURCES,
GCONF_VALUE_STRING, NULL);
- ids = g_slist_append (ids,
+ ids = g_slist_append (ids,
g_strdup (e_source_peek_uid (source)));
- gconf_client_set_list (client,
- CONF_KEY_SELECTED_TASKS_SOURCES,
+ gconf_client_set_list (client,
+ CONF_KEY_SELECTED_TASKS_SOURCES,
GCONF_VALUE_STRING, ids, NULL);
g_slist_foreach (ids, (GFunc) g_free, NULL);
g_slist_free (ids);
g_free (relative_uri);
g_free (authtype);
- if (source_new)
+ if (source_new)
g_object_unref (source);
if (group_new)
g_object_unref (source_group);
g_object_unref (client);
}
-void
-remove_folder_esource (ExchangeAccount *account,
- FolderType folder_type,
+void
+remove_folder_esource (ExchangeAccount *account,
+ FolderType folder_type,
const char *physical_uri)
{
ESourceGroup *group;
/* Remove ESource for a given folder */
if (folder_type == EXCHANGE_CONTACTS_FOLDER) {
- source_list = e_source_list_new_for_gconf ( client,
+ source_list = e_source_list_new_for_gconf ( client,
CONF_KEY_CONTACTS);
}
else if (folder_type == EXCHANGE_CALENDAR_FOLDER) {
- source_list = e_source_list_new_for_gconf ( client,
+ source_list = e_source_list_new_for_gconf ( client,
CONF_KEY_CAL);
is_contacts_folder = FALSE;
}
CONF_KEY_TASKS);
is_contacts_folder = FALSE;
}
-
+
groups = e_source_list_peek_groups (source_list);
found_group = FALSE;
sources = e_source_group_peek_sources (group);
for( ; sources != NULL; sources = g_slist_next (sources)) {
-
+
source = E_SOURCE (sources->data);
read_uri = e_source_get_uri (source);
- if (strcmp (read_uri, physical_uri) == 0) {
+ if (strcmp (read_uri, physical_uri) == 0) {
source_uid = e_source_peek_uid (source);
/* Folder Deleted - Remove only the source */
/*
e_source_group_remove_source_by_uid (
- group,
+ group,
source_uid);
*/
e_source_group_remove_source (
/* Remove from the selected folders */
if (folder_type == EXCHANGE_CALENDAR_FOLDER) {
ids = gconf_client_get_list (
- client,
- CONF_KEY_SELECTED_CAL_SOURCES,
+ client,
+ CONF_KEY_SELECTED_CAL_SOURCES,
GCONF_VALUE_STRING, NULL);
if (ids) {
- node_to_be_deleted = g_slist_find_custom (ids,
- source_uid,
+ node_to_be_deleted = g_slist_find_custom (ids,
+ source_uid,
(GCompareFunc) strcmp);
if (node_to_be_deleted) {
g_free (node_to_be_deleted->data);
- ids = g_slist_delete_link (ids,
+ ids = g_slist_delete_link (ids,
node_to_be_deleted);
}
}
g_slist_free (ids);
}
else if (folder_type == EXCHANGE_TASKS_FOLDER) {
- ids = gconf_client_get_list (client,
- CONF_KEY_SELECTED_TASKS_SOURCES,
+ ids = gconf_client_get_list (client,
+ CONF_KEY_SELECTED_TASKS_SOURCES,
GCONF_VALUE_STRING, NULL);
if (ids) {
- node_to_be_deleted = g_slist_find_custom (ids,
- source_uid,
+ node_to_be_deleted = g_slist_find_custom (ids,
+ source_uid,
(GCompareFunc) strcmp);
if (node_to_be_deleted) {
g_free (node_to_be_deleted->data);
- ids = g_slist_delete_link (ids,
+ ids = g_slist_delete_link (ids,
node_to_be_deleted);
}
}
g_object_unref (client);
}
-static gboolean
-is_offline (void)
+static gboolean
+is_offline (void)
{
GConfClient *client;
GConfValue *value;
struct _ExchangeFolderSizePrivate {
-
+
GHashTable *table;
GtkListStore *model;
GHashTable *row_refs;
}
void
-exchange_folder_size_update (ExchangeFolderSize *fsize,
+exchange_folder_size_update (ExchangeFolderSize *fsize,
const char *folder_name,
gdouble folder_size)
{
f_info = g_new0(folder_info, 1);
f_info->folder_name = g_strdup (folder_name);
f_info->folder_size = folder_size;
- g_hash_table_insert (folder_size_table, f_info->folder_name, f_info);
+ g_hash_table_insert (folder_size_table, f_info->folder_name, f_info);
gtk_list_store_append (fsize->priv->model, &iter);
gtk_list_store_set (fsize->priv->model, &iter,
COLUMN_NAME, f_info->folder_name,
COLUMN_SIZE, f_info->folder_size,
-1);
-
+
path = gtk_tree_model_get_path (GTK_TREE_MODEL (fsize->priv->model), &iter);
row = gtk_tree_row_reference_new (GTK_TREE_MODEL (fsize->priv->model), path);
gtk_tree_path_free (path);
}
void
-exchange_folder_size_remove (ExchangeFolderSize *fsize,
+exchange_folder_size_remove (ExchangeFolderSize *fsize,
const char *folder_name)
{
ExchangeFolderSizePrivate *priv;
folder_info *cached_info;
g_return_val_if_fail (EXCHANGE_IS_FOLDER_SIZE (fsize), -1);
-
+
priv = fsize->priv;
folder_size_table = priv->table;
* permanent_urls. Unfortunately it doesn't seem to be possible
* to BPROPFIND a group of permanent_urls.
*/
- iter = e2k_context_search_start (ctx, NULL, hfav->priv->shortcuts_uri,
+ iter = e2k_context_search_start (ctx, NULL, hfav->priv->shortcuts_uri,
shortcuts_props, n_shortcuts_props,
NULL, NULL, TRUE);
while ((result = e2k_result_iter_next (iter))) {
}
return hrefs;
-}
+}
/**
* exchange_hierarchy_favorites_is_added:
* @hier: the hierarchy
folder_uri = e_folder_exchange_get_internal_uri (folder);
shortcut_uri = g_hash_table_lookup (hfav->priv->shortcuts, folder_uri);
-
+
return shortcut_uri ? TRUE : FALSE;
}
physical_uri);
}
}
-
+
return exchange_hierarchy_webdav_status_to_folder_result (status);
}
props = e2k_properties_new ();
e2k_properties_set_string (props, PR_FAV_DISPLAY_NAME,
g_strdup (e_folder_get_name (folder)));
- if (permanent_uri)
+ if (permanent_uri)
e2k_properties_set_binary (props, PR_FAV_PUBLIC_SOURCE_KEY,
e2k_permanenturl_to_entryid (permanent_uri));
e2k_properties_set_int (props, PR_FAV_LEVEL_MASK, 1);
/* Add the esources */
folder_type = e_folder_get_type_string (*folder);
physical_uri = e_folder_get_physical_uri (*folder);
- new_folder_name = g_strdup_printf("%s's %s",
+ new_folder_name = g_strdup_printf("%s's %s",
hier->owner_name, folder_name);
if (!(strcmp (folder_type, "calendar")) ||
xmlDoc *doc;
g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account), NULL);
-
+
hier = hierarchy_foreign_new (account, hierarchy_name,
physical_uri_prefix,
internal_uri_prefix,
EXCHANGE_HIERARCHY_GAL, toplevel,
NULL, NULL, NULL);
/* Add ESource */
- add_folder_esource (hier->account, EXCHANGE_CONTACTS_FOLDER,
+ add_folder_esource (hier->account, EXCHANGE_CONTACTS_FOLDER,
hierarchy_name, physical_uri_prefix);
-
+
g_object_unref (toplevel);
return hier;
EFolder *iter_folder = NULL;
/* FIXME : Temporarily allow a rescan of the hierarchy. The proper fix
- is to handle the folder list either in ExchangeAccount or in the
+ is to handle the folder list either in ExchangeAccount or in the
plugins/exchange backend separately by listening to signals.
if (hsd->priv->scanned || folder != hier->toplevel) */
if (folder != hier->toplevel)
EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR);
g_return_val_if_fail (uri != NULL,
EXCHANGE_ACCOUNT_FOLDER_GENERIC_ERROR);
-
+
hwd = EXCHANGE_HIERARCHY_WEBDAV (hsd);
hier = EXCHANGE_HIERARCHY (hsd);
ctx = exchange_account_get_context (hier->account);
{
const char *internal_uri ;
char *mf_path;
-
+
g_return_if_fail (E_IS_FOLDER (folder));
internal_uri = e_folder_exchange_get_internal_uri (folder);
real_type = g_strdup ("calendar/public"); /* Hack */
else
real_type = g_strdup (type);
-
+
fixed_name = e2k_uri_encode (name, FALSE, URI_ENCODE_CHARS);
physical_uri = e2k_uri_concat (e_folder_get_physical_uri (parent), fixed_name);
g_free (fixed_name);
d(g_print ("exchange-hierarchy-webdave.c:e_folder_webdave_new: http_uri=[%s], new_internal_uri=[%s], temp_name=[%s], name[%s]\n",
http_uri, new_internal_uri, temp_name, name));
g_free (temp_name);
-
+
folder = e_folder_exchange_new (hier, name,
real_type, outlook_class,
physical_uri, http_uri);
exchange_hierarchy_new_folder (hier, dest);
g_object_unref (dest);
- /* update the folder size table, new folder, initialize the size to 0 */
+ /* update the folder size table, new folder, initialize the size to 0 */
exchange_account_folder_size_add (hier->account, name, 0);
return EXCHANGE_ACCOUNT_FOLDER_OK;
}
exchange_account_is_offline (hier->account, &mode);
if (mode != ONLINE_MODE)
- return EXCHANGE_ACCOUNT_FOLDER_OFFLINE;
+ return EXCHANGE_ACCOUNT_FOLDER_OFFLINE;
if (folder == hier->toplevel)
return EXCHANGE_ACCOUNT_FOLDER_PERMISSION_DENIED;
exchange_hierarchy_removed_folder (hier, folder);
/* update the folder size info */
- exchange_account_folder_size_remove (hier->account,
+ exchange_account_folder_size_remove (hier->account,
e_folder_get_name(folder));
return EXCHANGE_ACCOUNT_FOLDER_OK;
} else
g_object_unref (dest);
ret_code = EXCHANGE_ACCOUNT_FOLDER_OK;
- /* Find if folder movement or rename.
+ /* Find if folder movement or rename.
* update folder size in case of rename.
*/
source_folder_name = strrchr (physical_uri, '/') + 1;
- source_parent = g_strndup (physical_uri,
- source_folder_name - physical_uri);
+ source_parent = g_strndup (physical_uri,
+ source_folder_name - physical_uri);
if (!strcmp (e_folder_get_physical_uri (dest_parent), source_parent)) {
- /* rename - remove folder entry from hash, and
- * update the hash table with new name
+ /* rename - remove folder entry from hash, and
+ * update the hash table with new name
*/
- exchange_account_folder_size_rename (hier->account,
+ exchange_account_folder_size_rename (hier->account,
source_folder_name+1, dest_name);
}
g_free (source_parent);
} else {
physical_uri = e2k_uri_concat (
- e_folder_get_physical_uri (dest_parent),
+ e_folder_get_physical_uri (dest_parent),
dest_name);
g_object_unref (dest);
if (status == E2K_HTTP_FORBIDDEN ||
}
/* Remove the ESource of the source folder, in case of rename/move */
- if ((hier->type == EXCHANGE_HIERARCHY_PERSONAL ||
- hier->type == EXCHANGE_HIERARCHY_FAVORITES) && remove_source &&
+ if ((hier->type == EXCHANGE_HIERARCHY_PERSONAL ||
+ hier->type == EXCHANGE_HIERARCHY_FAVORITES) && remove_source &&
ret_code == EXCHANGE_ACCOUNT_FOLDER_OK) {
-
+
if ((strcmp (folder_type, "calendar") == 0) ||
(strcmp (folder_type, "calendar/public") == 0)) {
- remove_folder_esource (hier->account,
+ remove_folder_esource (hier->account,
EXCHANGE_CALENDAR_FOLDER,
physical_uri);
}
else if ((strcmp (folder_type, "tasks") == 0) ||
(strcmp (folder_type, "tasks/public") == 0)){
- remove_folder_esource (hier->account,
+ remove_folder_esource (hier->account,
EXCHANGE_TASKS_FOLDER,
physical_uri);
}
else if ((strcmp (folder_type, "contacts") == 0) ||
(strcmp (folder_type, "contacts/public") == 0)) {
- remove_folder_esource (hier->account,
+ remove_folder_esource (hier->account,
EXCHANGE_CONTACTS_FOLDER,
physical_uri);
}
add_href (gpointer path, gpointer folder, gpointer hrefs)
{
const char *folder_type;
-
+
folder_type = e_folder_get_type_string (folder);
if (!folder_type)
return;
-
+
if (!strcmp (folder_type, "noselect"))
return;
if (folder_size) {
folder_name = e_folder_get_name (folder);
fsize_d = g_ascii_strtod (folder_size, NULL)/1024;
- exchange_account_folder_size_add (hier->account,
+ exchange_account_folder_size_add (hier->account,
folder_name, fsize_d);
if (personal)
- hwd->priv->total_folder_size =
+ hwd->priv->total_folder_size =
hwd->priv->total_folder_size + fsize_d;
}
}
g_return_val_if_fail (EXCHANGE_IS_HIERARCHY_WEBDAV (hwd), NULL);
g_return_val_if_fail (E_IS_FOLDER (parent), NULL);
-
+
/* It's possible to have a localized inbox folder named, eg,
* "Innboks", with children whose URIs go through "Inbox"
* instead. (See bugzilla 27065.) This is probably related to
outlook_class = folder_type->contentclass;
/*
- * The permanenturl Field provides a unique identifier for an item
- * across the *store* and will not change as long as the item remains
- * in the same folder. The permanenturl Field contains the ID of the
- * parent folder of the item, which changes when the item is moved to a
- * different folder or deleted. Changing a field on an item will not
+ * The permanenturl Field provides a unique identifier for an item
+ * across the *store* and will not change as long as the item remains
+ * in the same folder. The permanenturl Field contains the ID of the
+ * parent folder of the item, which changes when the item is moved to a
+ * different folder or deleted. Changing a field on an item will not
* change the permanenturl Field and neither will adding more items to
* the folder with the same display name or message subject.
*/
if (hassubs)
e_folder_exchange_set_has_subfolders (folder, TRUE);
if (permanenturl) {
- /* Favorite folders and subscribed folders will not have
- * permanenturl
+ /* Favorite folders and subscribed folders will not have
+ * permanenturl
*/
e_folder_exchange_set_permanent_uri (folder, permanenturl);
}
return EXCHANGE_ACCOUNT_FOLDER_OK;
}
-
+
if (!folders_rn) {
folders_rn =
e2k_restriction_andv (
NULL);
}
- if (hier->type == EXCHANGE_HIERARCHY_PUBLIC)
+ if (hier->type == EXCHANGE_HIERARCHY_PUBLIC)
iter = e_folder_exchange_search_start (parent, NULL,
- pub_folder_props,
+ pub_folder_props,
n_pub_folder_props,
folders_rn, NULL, TRUE);
else
if (personal) {
/* calculate mail box size only for personal folders */
- hwd->priv->total_folder_size =
+ hwd->priv->total_folder_size =
hwd->priv->total_folder_size + fsize_d;
}
struct scan_offline_data *sod = data;
EFolder *folder;
char *mf_name;
-
+
mf_name = g_build_filename (physical_path, "connector-metadata.xml", NULL);
folder = e_folder_exchange_new_from_file (sod->hier, mf_name);
dir = e_path_to_physical (hier->account->storage_dir, prefix);
g_free (prefix);
e_path_find_folders (dir, scan_offline_cb, &sod);
-
+
if (sod.badpaths) {
for (i = 0; i < sod.badpaths->len; i++) {
e_path_rmdir (dir, sod.badpaths->pdata[i]);
toplevel = e_folder_exchange_new (EXCHANGE_HIERARCHY (hwd),
hierarchy_name,
- "noselect", NULL,
+ "noselect", NULL,
physical_uri_prefix,
internal_uri_prefix);
e_folder_set_custom_icon (toplevel, "stock_folder");
{
g_return_if_fail (EXCHANGE_IS_HIERARCHY (hier));
g_return_if_fail (E_IS_FOLDER (folder));
-
+
g_signal_emit (hier, signals[NEW_FOLDER], 0, folder);
}
*message = g_strndup (ta_start, ta_end - ta_start);
/* FIXME: HTML decode */
-
+
}
return TRUE;
xntlm_des(XNTLM_DES_KS ks, unsigned char block[8])
{
guint32 left,right,work;
-
+
/* Read input block and place in left/right in big-endian order */
left = ((guint32)block[0] << 24)
| ((guint32)block[1] << 16)
| (guint32)block[7];
/* Hoey's clever initial permutation algorithm, from Outerbridge
- * (see Schneier p 478)
+ * (see Schneier p 478)
*
* The convention here is the same as Outerbridge: rotate each
* register left by 1 bit, i.e., so that "left" contains permuted
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
* Jason Willis <zenbrother@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
static const gchar *GOOGLE_CLIENT_LOGIN = "https://www.google.com/accounts/ClientLogin";
static const gchar *GOOGLE_CLIENT_LOGIN_MSG = "Email=%s&Passwd=%s&service=%s&source=%s";
-void
+void
gdata_google_service_set_credentials (GDataService *service, const gchar *username, const gchar *password)
{
GDataGoogleServicePrivate *priv;
auth->password = g_strdup(password);
}
-static gboolean
+static gboolean
service_is_authenticated (GDataGoogleService *service)
{
GDataGoogleServicePrivate *priv;
auth->token = token;
if (!token)
return "FAILURE";
-
+
g_free(request_body);
g_free(request_body_encoded);
/**
*
- * gdata_google_service_get_feed:
+ * gdata_google_service_get_feed:
* @service A GDataService Object
* @feed_url Feed Url , the private url to send request to , needs authentication
* @entry A GDataFeed Object
- * returns the newly inserted entry
- *
+ * returns the newly inserted entry
+ *
**/
-GDataFeed *
+GDataFeed *
gdata_google_service_get_feed (GDataService *service, const gchar *feed_url)
{
GDataFeed *feed = NULL;
SoupSession *soup_session;
SoupMessage *msg;
gchar *status;
-
+
g_return_val_if_fail(service != NULL, NULL);
g_return_val_if_fail(GDATA_IS_GOOGLE_SERVICE(service),NULL);
msg = NULL;
msg = soup_message_new(SOUP_METHOD_GET, feed_url);
- soup_message_add_header(msg->request_headers,
+ soup_message_add_header(msg->request_headers,
"Authorization", (gchar *)g_strdup_printf("GoogleLogin auth=%s", auth->token));
- soup_session_send_message(soup_session, msg);
+ soup_session_send_message(soup_session, msg);
if (msg->response.length) {
feed = gdata_feed_new_from_xml(msg->response.body, msg->response.length);
}
-
+
if (SOUP_IS_MESSAGE(msg))
- g_object_unref(msg);
+ g_object_unref(msg);
return feed;
}
/**
*
- * gdata_google_service_insert_entry:
+ * gdata_google_service_insert_entry:
* @service A #GDataService Object
* @feed_url Feed Url , this is the private url of the author which requires authentication
* @entry A #GDataEntry Object
- * returns the newly inserted entry
- *
+ * returns the newly inserted entry
+ *
**/
GDataEntry *
gdata_google_service_insert_entry (GDataService *service, const gchar *feed_url, GDataEntry *entry)
msg = soup_message_new(SOUP_METHOD_POST, feed_url);
soup_message_set_http_version (msg, SOUP_HTTP_1_0);
- soup_message_add_header(msg->request_headers,
- "Authorization",
- (gchar *)g_strdup_printf("GoogleLogin auth=%s",
+ soup_message_add_header(msg->request_headers,
+ "Authorization",
+ (gchar *)g_strdup_printf("GoogleLogin auth=%s",
auth->token));
- soup_message_set_request (msg,
- "application/atom+xml",
- SOUP_BUFFER_USER_OWNED,
- entry_xml,
- strlen(entry_xml));
+ soup_message_set_request (msg,
+ "application/atom+xml",
+ SOUP_BUFFER_USER_OWNED,
+ entry_xml,
+ strlen(entry_xml));
soup_session_send_message(soup_session, msg);
}
if (SOUP_IS_MESSAGE(msg))
- g_object_unref (msg);
-
+ g_object_unref (msg);
+
if (entry_xml)
g_free (entry_xml);
/**
*
- * gdata_google_service_delete_entry:
+ * gdata_google_service_delete_entry:
* @service A #GDataService Object
* @feed_url Feed Url , this is the private url of the author which requires authentication
* @entry A #GDataEntry Object
- * Removes the entry
- *
+ * Removes the entry
+ *
**/
-void
+void
gdata_google_service_delete_entry (GDataService *service, GDataEntry *entry)
{
GDataGoogleServiceAuth *auth;
SoupMessage *msg;
const gchar *entry_edit_url;
xmlChar *status;
-
+
g_return_if_fail (service !=NULL);
g_return_if_fail (GDATA_IS_GOOGLE_SERVICE(service));
if (!service_is_authenticated (GDATA_GOOGLE_SERVICE(service))) {
status = (xmlChar *)service_authenticate (GDATA_GOOGLE_SERVICE(service));
- if (g_ascii_strcasecmp((gchar *)status, "SUCCESS"))
+ if (g_ascii_strcasecmp((gchar *)status, "SUCCESS"))
return ;
}
-
+
entry_edit_url = gdata_entry_get_edit_link (entry);
priv = GDATA_GOOGLE_SERVICE_GET_PRIVATE (GDATA_GOOGLE_SERVICE (service));
auth = (GDataGoogleServiceAuth *) priv->auth;
if (SOUP_IS_MESSAGE(msg))
g_object_unref (msg);
-}
+}
/**
*
- * gdata_google_service_update_entry:
+ * gdata_google_service_update_entry:
* @service A GDataService Object
* @feed_url Feed Url , this is the private url of the author which requires authentication
* @entry A GDataEntry Object
- * updates the entry
- *
+ * updates the entry
+ *
**/
-void
+void
gdata_google_service_update_entry (GDataService *service, GDataEntry *entry)
{
GDataGoogleServiceAuth *auth;
gchar *status;
gchar *entry_xml;
const gchar *entry_edit_url;
-
+
g_return_if_fail (service !=NULL);
g_return_if_fail (GDATA_IS_GOOGLE_SERVICE (service));
-
+
if (!service_is_authenticated (GDATA_GOOGLE_SERVICE (service))) {
status = service_authenticate (GDATA_GOOGLE_SERVICE (service));
if (g_ascii_strcasecmp (status, "SUCCESS"))
"Authorization",
(gchar *)g_strdup_printf ("GoogleLogin auth=%s",
auth->token));
- soup_message_set_request (msg,
- "application/atom+xml",
- SOUP_BUFFER_USER_OWNED,
- entry_xml,
- strlen(entry_xml));
+ soup_message_set_request (msg,
+ "application/atom+xml",
+ SOUP_BUFFER_USER_OWNED,
+ entry_xml,
+ strlen(entry_xml));
soup_session_send_message (soup_session, msg);
-
+
if (SOUP_IS_MESSAGE(msg))
g_object_unref (msg);
if (entry_xml)
/**
*
- * gdata_google_update_entry_with_link:
+ * gdata_google_update_entry_with_link:
* @service A #GDataService Object
- * @edit_link url of the edit link of the entry
+ * @edit_link url of the edit link of the entry
* @entry A #GDataEntry Object
- * Updates the entry
- *
+ * Updates the entry
+ *
**/
-void
+void
gdata_google_service_update_entry_with_link (GDataService *service, GDataEntry *entry, gchar *edit_link)
{
GDataGoogleServiceAuth *auth;
SoupMessage *msg;
gchar *status;
gchar *entry_xml;
-
+
g_return_if_fail (service !=NULL);
g_return_if_fail (GDATA_IS_GOOGLE_SERVICE (service));
-
+
if (!service_is_authenticated (GDATA_GOOGLE_SERVICE(service))) {
status = service_authenticate (GDATA_GOOGLE_SERVICE(service));
if (g_ascii_strcasecmp (status, "SUCCESS"))
(gchar *)g_strdup_printf ("GoogleLogin auth=%s",
auth->token));
- soup_message_set_request (msg,
- "application/atom+xml",
- SOUP_BUFFER_USER_OWNED,
- entry_xml,
- strlen(entry_xml));
+ soup_message_set_request (msg,
+ "application/atom+xml",
+ SOUP_BUFFER_USER_OWNED,
+ entry_xml,
+ strlen(entry_xml));
soup_session_send_message (soup_session, msg);
- if (SOUP_IS_MESSAGE(msg))
- g_object_unref (msg);
+ if (SOUP_IS_MESSAGE(msg))
+ g_object_unref (msg);
if (entry_xml)
g_free (entry_xml);
}
priv = GDATA_GOOGLE_SERVICE_GET_PRIVATE(obj);
switch (property_id) {
- case PROP_NAME:
+ case PROP_NAME:
g_value_set_string(value, priv->name);
break;
case PROP_AGENT:
if (G_UNLIKELY(type == 0))
{
- static const GTypeInfo info =
+ static const GTypeInfo info =
{
sizeof (GDataGoogleServiceClass),
NULL, /* base_init */
gdata_google_service_instance_init /* instance_init */
};
- static const GInterfaceInfo gdata_google_service_iface_info =
+ static const GInterfaceInfo gdata_google_service_iface_info =
{
(GInterfaceInitFunc) gdata_google_service_iface_init, /* interface_init */
NULL, /* interface_finalize */
/**
*
- * gdata_google_service_new:
- * @service_name
- * @agent
+ * gdata_google_service_new:
+ * @service_name
+ * @agent
* Returns a new #GDataGoogleService Object
- *
+ *
**/
GDataGoogleService *
gdata_google_service_new(const gchar *service_name, const gchar *agent)
{
- return g_object_new(GDATA_TYPE_GOOGLE_SERVICE,
+ return g_object_new(GDATA_TYPE_GOOGLE_SERVICE,
"name", service_name,
"agent",agent,
NULL);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
* Jason Willis <zenbrother@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
GObject parent;
/* private */
-
+
};
struct _GDataGoogleServiceClass {
GObjectClass parent_class;
-
+
/* Public Methods - Inherited from GDATA_SERVICE_IFACE */
};
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
* Jason Willis <zenbrother@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
/* LibXML2 includes */
#include <libxml/parser.h>
#include <libxml/tree.h>
-#include <libxml/xpath.h>
+#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <string.h>
/*** API ***/
static GDataEntryAuthor *
-xmlnode_to_author (xmlDocPtr doc, xmlNodePtr cur)
+xmlnode_to_author (xmlDocPtr doc, xmlNodePtr cur)
{
GDataEntryAuthor *author;
xmlChar *value;
}
static GDataEntryLink *
-xmlnode_to_link (xmlDocPtr doc, xmlNodePtr cur)
+xmlnode_to_link (xmlDocPtr doc, xmlNodePtr cur)
{
GDataEntryLink *link;
xmlChar *value;
}
static GDataEntryCategory *
-xmlnode_to_category (xmlDocPtr doc, xmlNodePtr cur)
+xmlnode_to_category (xmlDocPtr doc, xmlNodePtr cur)
{
GDataEntryCategory *category;
xmlChar *value;
xmlChar *value;
attendee = g_new0 (Attendee, 1);
-
- while (cur != NULL) {
+
+ while (cur != NULL) {
value = xmlGetProp(cur, (xmlChar *)"email");
if (value) {
attendee->attendee_email = g_strdup((gchar *)value);
xmlFree(value);
- }
-
+ }
+
value = xmlGetProp(cur, (xmlChar *)"rel");
-
+
if (value) {
attendee->attendee_rel = g_strdup((gchar *)value);
xmlFree (value);
attendee->attendee_value = g_strdup((gchar *)value);
xmlFree (value);
}
-
+
cur = cur->next;
- }
+ }
return attendee;
}
-static xmlNodePtr
+static xmlNodePtr
entry_to_xmlnode (GDataEntry *entry)
{
xmlDocPtr doc;
/* FIXME 3rd argument could carry a better name */
doc = xmlReadMemory (xmlEntry, strlen(xmlEntry), "feeds.xml", NULL, 0);
cur = xmlDocGetRootElement (doc);
-
+
return cur;
}
-static xmlNodePtr
-author_to_xmlnode (GDataEntryAuthor *author)
+static xmlNodePtr
+author_to_xmlnode (GDataEntryAuthor *author)
{
xmlNodePtr author_node;
return author_node;
}
-static xmlNodePtr
+static xmlNodePtr
link_to_xmlnode (GDataEntryLink *link)
{
xmlNodePtr link_node;
return link_node;
}
-static xmlNodePtr
+static xmlNodePtr
category_to_xmlnode (GDataEntryCategory *category)
{
xmlNodePtr category_node;
* gdata_entry_new:
* Creates a new #GDataEntry.
**/
-GDataEntry *
+GDataEntry *
gdata_entry_new (void)
{
return g_object_new(GDATA_TYPE_ENTRY, NULL);
* gdata_entry_get_private:
* @entry: A #GDataEntry object
* Returns a #GDataEntryPrivate object
- **/
-GDataEntryPrivate *
+ **/
+GDataEntryPrivate *
gdata_entry_get_private (GDataEntry *entry)
{
GDataEntryPrivate *priv;
priv = GDATA_ENTRY_GET_PRIVATE (entry);
- return priv;
+ return priv;
}
/**
- * gdata_entry_new_from_xmlptr:
+ * gdata_entry_new_from_xmlptr:
* @doc: A xml document pointer
* @ptr: A xml Node pointer
**/
-GDataEntry *
+GDataEntry *
gdata_entry_new_from_xmlptr (xmlDocPtr doc, xmlNodePtr cur)
{
GDataEntry *entry;
return NULL;
}
- entry = gdata_entry_new ();
+ entry = gdata_entry_new ();
priv = GDATA_ENTRY_GET_PRIVATE(entry);
buf = xmlAllocOutputBuffer (NULL);
- if (buf == NULL) {
+ if (buf == NULL) {
xmlString = NULL;
}
else {
if (buf->conv == NULL)
xmlString = g_strdup ((gchar *)buf->buffer->content);
- else
+ else
xmlString = g_strdup ((gchar *)buf->conv->content);
xmlOutputBufferClose (buf);
}
if (!xmlStrcmp(cur->name, (xmlChar *)"author")) {
priv->authors = g_slist_prepend(priv->authors, xmlnode_to_author(doc, cur));
- }
+ }
else if (!xmlStrcmp(cur->name, (xmlChar *)"link")) {
priv->links = g_slist_prepend(priv->links, xmlnode_to_link(doc, cur));
}
priv->categories = g_slist_prepend(priv->categories, xmlnode_to_category(doc, cur));
}
else if (!xmlStrcmp (cur->name, (xmlChar *)"where")) {
- priv->location = (gchar *)xmlGetProp (cur, (xmlChar *)"valueString");
+ priv->location = (gchar *)xmlGetProp (cur, (xmlChar *)"valueString");
}
else if (!xmlStrcmp (cur->name, (xmlChar *)"eventStatus")) {
priv->status = (gchar *)xmlGetProp (cur, (xmlChar *)"value");
else if (!xmlStrcmp (cur->name, (xmlChar *)"recurrence")) {
priv->is_recurrent = TRUE;
}
-
+
else if (!xmlStrcmp (cur->name, (xmlChar *)"who")) {
- priv->attendees = g_slist_prepend (priv->attendees, xmlnode_to_attendee (doc, cur));
+ priv->attendees = g_slist_prepend (priv->attendees, xmlnode_to_attendee (doc, cur));
priv->has_attendees = TRUE;
}
else if (!xmlStrcmp (cur->name, (xmlChar *)"sendEventNotifications")) {
else {
value = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
- g_hash_table_insert(priv->field_table, g_strdup((gchar *)cur->name),
+ g_hash_table_insert(priv->field_table, g_strdup((gchar *)cur->name),
g_strdup((gchar *)value));
xmlFree(value);
}
cur = cur->next;
}
-
+
xmlFree(value);
return entry;
}
/**
- * gdata_entries_new_from_xml:
+ * gdata_entries_new_from_xml:
* @feed_xml: A xml tree.
* @length: length of feed_xml
* Returns the list of all the entries in a feed.
**/
/*Returns all the entries from the feed */
-GSList *
+GSList *
gdata_entries_new_from_xml (const gchar *feed_xml, const gint length)
{
GSList *list;
g_return_val_if_fail(feed_xml != NULL && *feed_xml != '\0', NULL);
doc = xmlReadMemory (feed_xml, strlen(feed_xml), "feed.xml", NULL, 0);
- if (doc == NULL)
+ if (doc == NULL)
return NULL;
cur = xmlDocGetRootElement (doc);
if (cur == NULL) {
xmlFree (doc);
}
-
+
cur = cur->xmlChildrenNode;
- while (cur != NULL)
+ while (cur != NULL)
{
if (!xmlStrcmp (cur->name, (xmlChar *)"entry")) {
list = g_slist_prepend (list, gdata_entry_new_from_xmlptr (doc, cur));
return list;
}
-/**
- * gdata_entry_new_from_xml:
+/**
+ * gdata_entry_new_from_xml:
* @entry_xml: the xml tree
* Returns a GDataEntry object:
**/
xmlDocPtr doc;
xmlNodePtr cur;
- g_return_val_if_fail (entry_xml != NULL && *entry_xml != '\0', NULL);
+ g_return_val_if_fail (entry_xml != NULL && *entry_xml != '\0', NULL);
doc = xmlReadMemory (entry_xml, strlen(entry_xml), "feed.xml", NULL, 0);
if (doc == NULL)
return NULL;
cur = xmlDocGetRootElement (doc);
- if (cur == NULL)
+ if (cur == NULL)
xmlFree (doc);
while (cur != NULL) {
- if (!xmlStrcmp (cur->name,(xmlChar *)"entry"))
+ if (!xmlStrcmp (cur->name,(xmlChar *)"entry"))
entry = gdata_entry_new_from_xmlptr (doc, cur);
cur = cur->next;
}
/**
*gdata_entry_generate_xml:
- *@entry: A GDataEntry Object
+ *@entry: A GDataEntry Object
*Returns the xml content:
**/
-gchar *
+gchar *
gdata_entry_generate_xml (GDataEntry *entry)
{
GDataEntryPrivate *priv;
cur_child = xmlNewChild(root, NULL, (xmlChar *)"when", NULL);
xmlSetNs (cur_child, xmlNewNs (cur_child, NULL, (xmlChar *)"gd"));
xmlSetProp (cur_child, (xmlChar *)"startTime", (xmlChar *)priv->start_time);
- xmlSetProp (cur_child, (xmlChar *)"endTime", (xmlChar *)priv->end_time);
+ xmlSetProp (cur_child, (xmlChar *)"endTime", (xmlChar *)priv->end_time);
- if (priv->reminder) {
+ if (priv->reminder) {
cur = cur_child;
cur_child = xmlNewChild(cur, NULL, (xmlChar *)"reminder", (xmlChar *)"");
- xmlSetNs (cur_child, xmlNewNs (cur_child, NULL, (xmlChar *)"gd"));
+ xmlSetNs (cur_child, xmlNewNs (cur_child, NULL, (xmlChar *)"gd"));
xmlSetProp (cur_child->xmlChildrenNode, (xmlChar *)"minutes", (xmlChar *)priv->reminder);
- }
+ }
}
if (priv->location ) {
xmlFree(xmlString);
xmlFreeDoc(doc);
-
- return priv->entry_xml;
+
+ return priv->entry_xml;
}
/* Builds the DOM tree for the entries stored in hash table */
(value) ? xmlNodeSetContent (ptr->next, (xmlChar *)value) : xmlNodeSetContent (ptr->next, (xmlChar *)"");
break;
}
- else
+ else
ptr = ptr->next;
}
}
-/**
+/**
* gdata_entry_get_id:
* @entry: A GDataEntry object
- * Returns the id of the Entry:
+ * Returns the id of the Entry:
**/
-gchar *
+gchar *
gdata_entry_get_id (GDataEntry *entry)
{
GDataEntryPrivate *priv;
g_return_val_if_fail (GDATA_IS_ENTRY (entry), NULL);
priv = GDATA_ENTRY_GET_PRIVATE (entry);
- return g_hash_table_lookup (priv->field_table, "id");
+ return g_hash_table_lookup (priv->field_table, "id");
}
-/**
+/**
* gdata_entry_get_visibility:
* @entry: A GDataEntry object
- * Returns the visibility of the Entry:
+ * Returns the visibility of the Entry:
**/
-gchar *
+gchar *
gdata_entry_get_visibility (GDataEntry *entry)
{
GDataEntryPrivate *priv;
return priv->visibility;
}
-/**
+/**
* gdata_entry_get_content:
* @entry: A #GDataEntry object
- * Returns the content of the Entry/Event.
+ * Returns the content of the Entry/Event.
**/
-gchar *
+gchar *
gdata_entry_get_content (GDataEntry *entry)
{
GDataEntryPrivate *priv;
g_return_val_if_fail (entry !=NULL, NULL);
g_return_val_if_fail (GDATA_IS_ENTRY (entry), NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE (entry);
return g_hash_table_lookup (priv->field_table, "content");
}
-/**
+/**
* gdata_entry_get_description:
* @entry: A #GDataEntry object
- * Returns the description of the Entry.
+ * Returns the description of the Entry.
**/
/* Returns the description of the entry */
-gchar *
+gchar *
gdata_entry_get_description (GDataEntry *entry)
{
GDataEntryPrivate *priv;
g_return_val_if_fail (entry !=NULL, NULL);
g_return_val_if_fail (GDATA_IS_ENTRY (entry), NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE (entry);
return NULL;
}
-/**
+/**
* gdata_entry_get_copyright:
* @entry: A #GDataEntry object
* Returns the copyright of the Entry
**/
-gchar *
+gchar *
gdata_entry_get_copyright (GDataEntry *entry)
{
GDataEntryPrivate *priv;
g_return_val_if_fail (entry !=NULL, NULL);
g_return_val_if_fail (GDATA_IS_ENTRY (entry), NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE (entry);
return g_hash_table_lookup (priv->field_table, "copyright");
}
-/**
+/**
* gdata_entry_get_title:
* @entry: A #GDataEntry object.
- * Returns the title of the Entry.
+ * Returns the title of the Entry.
**/
-gchar *
+gchar *
gdata_entry_get_title (GDataEntry *entry)
{
GDataEntryPrivate *priv;
g_return_val_if_fail (entry !=NULL, NULL);
g_return_val_if_fail (GDATA_IS_ENTRY (entry), NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE (entry);
return g_hash_table_lookup (priv->field_table, "title");
}
-/**
+/**
* gdata_entry_get_authors:
* @entry: A #GDataEntry object.
- * Returns the list of authors of entry.
+ * Returns the list of authors of entry.
**/
-GSList *
+GSList *
gdata_entry_get_authors (GDataEntry *entry)
{
GDataEntryPrivate *priv;
g_return_val_if_fail (entry != NULL, NULL);
g_return_val_if_fail (GDATA_IS_ENTRY (entry), NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE (entry);
return priv->authors;
}
gdata_entry_get_links (GDataEntry *entry)
{
GDataEntryPrivate *priv;
-
+
g_return_val_if_fail (entry !=NULL, NULL);
g_return_val_if_fail (GDATA_IS_ENTRY (entry), NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE (entry);
return priv->links;
}
-/**
+/**
* gdata_entry_get_start_time:
* @entry: A #GDataEntry object.
- * Returns the starting time of the Event.
+ * Returns the starting time of the Event.
**/
-gchar *
+gchar *
gdata_entry_get_start_time (GDataEntry *entry)
{
GDataEntryPrivate *priv;
g_return_val_if_fail (entry!=NULL, NULL);
g_return_val_if_fail (GDATA_IS_ENTRY(entry), NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
return priv->start_time;
}
-/**
+/**
* gdata_entry_get_transparency:
* @entry: A #GDataEntry object.
- * Returns the transparency of the Event.
+ * Returns the transparency of the Event.
**/
-gchar *
+gchar *
gdata_entry_get_transparency (GDataEntry *entry)
{
GDataEntryPrivate *priv;
g_return_val_if_fail (entry!=NULL, NULL);
g_return_val_if_fail (GDATA_IS_ENTRY(entry), NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
return priv->transparency;
}
-/**
+/**
* gdata_entry_get_end_time:
* @entry: A #GDataEntry object.
- * Returns the ending time of the Event.
+ * Returns the ending time of the Event.
**/
-gchar *
+gchar *
gdata_entry_get_end_time (GDataEntry *entry)
{
GDataEntryPrivate *priv;
g_return_val_if_fail (entry != NULL, NULL);
g_return_val_if_fail (GDATA_IS_ENTRY(entry), NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
return priv->end_time;
}
-/**
+/**
* gdata_entry_get_location:
* @entry: A #GDataEntry object.
- * Returns the location of the Event.
+ * Returns the location of the Event.
**/
-gchar *
+gchar *
gdata_entry_get_location (GDataEntry *entry)
{
GDataEntryPrivate *priv;
g_return_val_if_fail (GDATA_IS_ENTRY (entry), NULL);
priv = GDATA_ENTRY_GET_PRIVATE(entry);
- return priv->location;
+ return priv->location;
}
-/**
+/**
* gdata_entry_get_status:
* @entry: A #GDataEntry object.
- * Returns the status of the Event.
+ * Returns the status of the Event.
**/
-gchar *
+gchar *
gdata_entry_get_status (GDataEntry *entry)
{
GDataEntryPrivate *priv;
g_return_val_if_fail(entry !=NULL, NULL);
g_return_val_if_fail(GDATA_IS_ENTRY (entry), NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
return priv->status;
}
-/**
+/**
* gdata_entry_get_categories:
* @entry: A #GDataEntry object.
- * Returns the status of the Event.
+ * Returns the status of the Event.
**/
GSList *
gdata_entry_get_categories (GDataEntry *entry)
g_return_val_if_fail(entry !=NULL, NULL);
g_return_val_if_fail(GDATA_IS_ENTRY (entry), NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
return priv->categories;
}
return edit_link;
}
-/**
+/**
* gdata_entry_set_author:
* @entry: A #GDataEntry object.
* @author: A list of authors.
- * Sets the list of authors.
+ * Sets the list of authors.
**/
-void
+void
gdata_entry_set_author (GDataEntry *entry, GSList *author)
{
GDataEntryPrivate *priv;
priv->entry_needs_update = TRUE;
}
-/**
+/**
* gdata_entry_set_id:
* @entry: A #GDataEntry object.
* @id: Id of the entry.
- * Sets the list of authors.
+ * Sets the list of authors.
**/
-void
+void
gdata_entry_set_id (GDataEntry *entry, gchar *id)
{
GDataEntryPrivate *priv;
-/**
+/**
* gdata_entry_set_categories:
* @entry: A GDataEntry object.
* @categories: A list of categories.
- * Sets the list of categories of the Entry.
+ * Sets the list of categories of the Entry.
**/
-void
+void
gdata_entry_set_categories (GDataEntry *entry, GSList *categories)
{
GDataEntryPrivate *priv;
-
+
g_return_if_fail(categories !=NULL);
g_return_if_fail(GDATA_IS_ENTRY(entry));
priv = GDATA_ENTRY_GET_PRIVATE(entry);
priv->categories = categories;
- priv->entry_needs_update = TRUE;
+ priv->entry_needs_update = TRUE;
}
-/**
+/**
* gdata_entry_set_title:
* @entry: A GDataEntry object.
* @title: title of the event.
- * Sets the title of the Entry.
+ * Sets the title of the Entry.
**/
-void
+void
gdata_entry_set_title (GDataEntry *entry, const gchar *title)
{
GDataEntryPrivate *priv;
g_return_if_fail(title !=NULL);
g_return_if_fail(GDATA_IS_ENTRY (entry));
-
+
priv = GDATA_ENTRY_GET_PRIVATE (entry);
priv->title = g_strdup(title);
g_hash_table_insert (priv->field_table, g_strdup("title"), g_strdup(title));
priv->entry_needs_update = TRUE;
}
-/**
+/**
* gdata_entry_set_content:
* @entry: A GDataEntry object.
* @content: The content of the event.
- * Sets the content of the Entry.
+ * Sets the content of the Entry.
**/
void
gdata_entry_set_content (GDataEntry *entry, const gchar *content)
g_return_if_fail(content !=NULL);
g_return_if_fail(GDATA_IS_ENTRY(entry));
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
priv->content = g_strdup (content);
priv->entry_needs_update = TRUE;
g_hash_table_insert (priv->field_table, g_strdup("content"), g_strdup (content));
}
-/**
+/**
* gdata_entry_set_links:
* @entry: A GDataEntry object.
* @links: A list of links associated.
- * Sets the links of the Event.
+ * Sets the links of the Event.
**/
-void
+void
gdata_entry_set_links (GDataEntry *entry, GSList *links)
{
GDataEntryPrivate *priv;
priv->entry_needs_update = TRUE;
}
-/**
+/**
* gdata_entry_set_status:
* @entry: A GDataEntry object.
* @status: The status of the event.
- * Sets the status of the Event.
+ * Sets the status of the Event.
**/
-void
+void
gdata_entry_set_status (GDataEntry *entry, const gchar *status)
{
GDataEntryPrivate *priv;
g_return_if_fail(status!=NULL);
g_return_if_fail(GDATA_IS_ENTRY(entry));
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
- priv->status = g_strdup (status);
+ priv->status = g_strdup (status);
priv->entry_needs_update = TRUE;
}
-/**
+/**
* gdata_entry_set_sendNotification:
* @entry: A GDataEntry object.
- * @sendNotification: Whether notification is required.
- * Sets whether notification should be sent by the Event.
+ * @sendNotification: Whether notification is required.
+ * Sets whether notification should be sent by the Event.
**/
-void
+void
gdata_entry_set_send_notification (GDataEntry *entry, const gchar *send_notification)
{
- GDataEntryPrivate *priv;
+ GDataEntryPrivate *priv;
g_return_if_fail (send_notification!=NULL);
g_return_if_fail (GDATA_IS_ENTRY (entry));
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
priv->send_notification = g_strdup(send_notification);
priv->entry_needs_update = TRUE;
-}
+}
-/**
+/**
* gdata_entry_set_reminder:
* @entry: A GDataEntry object.
* @reminder: The reminder set.
* Sets the reminder of the Event.
**/
-void
+void
gdata_entry_set_reminder (GDataEntry *entry, const gchar *reminder)
{
GDataEntryPrivate *priv;
g_return_if_fail(reminder !=NULL);
g_return_if_fail(GDATA_IS_ENTRY (entry));
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
priv->reminder = g_strdup (reminder);
priv->entry_needs_update = TRUE;
}
-/**
+/**
* gdata_entry_set_start_time:
* @entry: A GDataEntry object.
* @start_time: The starting time of the event.
- * Sets the starting time of the Event.
+ * Sets the starting time of the Event.
**/
-void
+void
gdata_entry_set_start_time (GDataEntry *entry, const gchar *start_time)
{
GDataEntryPrivate *priv;
g_return_if_fail(start_time !=NULL);
g_return_if_fail(GDATA_IS_ENTRY(entry));
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
priv->start_time = g_strdup(start_time);
priv->entry_needs_update = TRUE;
-}
+}
-/**
+/**
* gdata_entry_set_end_time:
* @entry: A GDataEntry object.
* @end_time: The end time of the event.
* Sets the end time of the event.
**/
-void
+void
gdata_entry_set_end_time (GDataEntry *entry, const gchar *end_time)
{
GDataEntryPrivate *priv;
g_return_if_fail(end_time !=NULL);
g_return_if_fail(GDATA_IS_ENTRY (entry));
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
priv->end_time = g_strdup(end_time);
priv->entry_needs_update = TRUE;
/**
* gdata_entry_set_transparency:
- * @entry: A GDataEntry object.
+ * @entry: A GDataEntry object.
* @transparency: Transparency of the Entry.
- * Sets the transparency of the entry.
+ * Sets the transparency of the entry.
**/
-void
+void
gdata_entry_set_transparency (GDataEntry *entry, const gchar *transparency)
{
GDataEntryPrivate *priv;
* @location: Location of the event.
* Sets the location of the event.
**/
-void
+void
gdata_entry_set_location (GDataEntry *entry, const gchar *location)
{
GDataEntryPrivate *priv;
priv = GDATA_ENTRY_GET_PRIVATE(entry);
priv->entry_xml = g_strdup (xml);
priv->entry_needs_update = TRUE;
-
+
}
-/**
+/**
* gdata_entry_create_authors:
* @entry: A GDataEntry object.
* @name: The name of the author.
* @email: The email of the author.
* Sets the list of authors to the Entry.
**/
-void
+void
gdata_entry_create_authors (GDataEntry *entry,
- const gchar *name,
+ const gchar *name,
const gchar *email)
{
GDataEntryPrivate *priv;
g_return_if_fail(name !=NULL || email !=NULL);
g_return_if_fail(GDATA_IS_ENTRY(entry));
-
+
author = g_new0 (GDataEntryAuthor, 1);
priv = GDATA_ENTRY_GET_PRIVATE(entry);
- author->name = g_strdup(name);
+ author->name = g_strdup(name);
author->email = g_strdup(email);
-
+
priv->authors = g_slist_prepend(priv->authors, author);
priv->entry_needs_update = TRUE;
-
+
}
-/**
+/**
* gdata_entry_create_categories:
* @entry: A GDataEntry object.
* @scheme:Scheme.
* @term: Term.
* Sets the categories of the Event.
**/
-void
-gdata_entry_create_categories (GDataEntry *entry,
- const gchar *scheme,
- const gchar *label ,
+void
+gdata_entry_create_categories (GDataEntry *entry,
+ const gchar *scheme,
+ const gchar *label ,
const gchar *term)
{
GDataEntryPrivate *priv;
gdata_entry_is_recurrent (GDataEntry *entry)
{
GDataEntryPrivate *priv;
-
+
g_return_val_if_fail (entry != NULL, 0);
g_return_val_if_fail (GDATA_IS_ENTRY (entry), 0);
-
+
priv = GDATA_ENTRY_GET_PRIVATE (entry);
return priv->is_recurrent;
}
gdata_entry_get_attendee_list (GDataEntry *entry)
{
GDataEntryPrivate *priv;
-
- g_return_val_if_fail (entry != NULL, NULL);
+
+ g_return_val_if_fail (entry != NULL, NULL);
g_return_val_if_fail (GDATA_IS_ENTRY(entry), NULL);
priv = GDATA_ENTRY_GET_PRIVATE(entry);
g_return_if_fail (entry != NULL);
g_return_if_fail (GDATA_IS_ENTRY(entry));
g_return_if_fail (attendees != NULL);
-
+
priv = GDATA_ENTRY_GET_PRIVATE(entry);
priv->attendees = attendees;
priv->has_attendees = TRUE;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
* Jason Willis <zenbrother@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
/* LibXML2 includes */
#include <libxml/parser.h>
#include <libxml/tree.h>
-#include <libxml/xpath.h>
+#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
};
struct _GDataEntryClass {
-
+
GObjectClass parent_class;
/* class members */
gchar * gdata_entry_get_end_date (GDataEntry *entry);
-gchar *
+gchar *
gdata_entry_get_visibility (GDataEntry *entry);
-gchar *
+gchar *
gdata_entry_get_transparency (GDataEntry *entry);
GSList *
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
* Jason Willis <zenbrother@gmail.com>
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
/* LibXML2 includes */
#include <libxml/parser.h>
#include <libxml/tree.h>
-#include <libxml/xpath.h>
+#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <string.h>
};
-static void
+static void
gdata_feed_init(GTypeInstance *instance,
gpointer g_class)
{
priv->feedXML = NULL;
}
-static void
+static void
gdata_feed_dispose(GObject *obj)
{
GObjectClass *parent_class;
parent_class->dispose(obj);
}
-static void
+static void
gdata_feed_finalize(GObject *obj)
{
GDataFeedPrivate *priv;
parent_class->finalize(obj);
}
-static void
+static void
gdata_feed_get_property (GObject *obj,
guint property_id,
GValue *value,
}
-static void
+static void
gdata_feed_set_property (GObject *obj,
guint property_id,
const GValue *value,
}
-static GObject * gdata_feed_constructor(GType type,
+static GObject * gdata_feed_constructor(GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
return obj;
-}
+}
-static void
+static void
gdata_feed_class_init(gpointer g_class,
gpointer g_class_data)
{
gobject_class->dispose = gdata_feed_dispose;
gobject_class->finalize = gdata_feed_finalize;
- gobject_class->constructor = gdata_feed_constructor;
+ gobject_class->constructor = gdata_feed_constructor;
}
/*** API ***/
static GDataFeedAuthor *
-xmlnode_to_author(xmlDocPtr doc, xmlNodePtr cur)
+xmlnode_to_author(xmlDocPtr doc, xmlNodePtr cur)
{
GDataFeedAuthor *author;
xmlChar *value;
}
static GDataFeedLink *
-xmlnode_to_link(xmlDocPtr doc, xmlNodePtr cur)
+xmlnode_to_link(xmlDocPtr doc, xmlNodePtr cur)
{
GDataFeedLink *link;
xmlChar *value;
static GDataFeedCategory *
-xmlnode_to_category(xmlDocPtr doc, xmlNodePtr cur)
+xmlnode_to_category(xmlDocPtr doc, xmlNodePtr cur)
{
GDataFeedCategory *category;
xmlChar *value;
return category;
}
-static xmlNodePtr
+static xmlNodePtr
link_to_xmlnode (GDataFeedLink *link)
{
xmlNodePtr cur;
if (author->uri)
xmlNewChild (cur, NULL, (xmlChar *)"uri", (xmlChar *)author->uri);
-
+
return cur;
}
return cur;
}
-GDataFeed *
+GDataFeed *
gdata_feed_new(void)
{
return g_object_new(GDATA_TYPE_FEED, NULL);
}
-GDataFeed *
+GDataFeed *
gdata_feed_new_from_xml(const gchar* feedXML, const gint length)
{
GDataFeed *feed;
cur = cur->xmlChildrenNode;
while (cur != NULL) {
-
+
if (!xmlStrcmp(cur->name, (xmlChar *)"author")) {
priv->authors = g_slist_prepend(priv->authors, xmlnode_to_author(doc, cur));
- }
+ }
else if (!xmlStrcmp(cur->name, (xmlChar *)"link")) {
priv->links = g_slist_prepend(priv->links, xmlnode_to_link(doc, cur));
}
}
else {
value = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
- g_hash_table_insert(priv->field_table, g_strdup((gchar *)cur->name),
+ g_hash_table_insert(priv->field_table, g_strdup((gchar *)cur->name),
g_strdup((gchar *)value));
xmlFree(value);
}
xmlDocDumpFormatMemory(doc, &value, &value_size, 1);
priv->feedXML = g_strdup(feedXML);
-
+
xmlFree(value);
xmlFreeDoc(doc);
}
-gchar *
+gchar *
gdata_feed_generate_xml(GDataFeed *feed)
{
GDataFeedPrivate *priv;
if (!priv->feedXML) {
doc = xmlNewDoc ((xmlChar *)"1.0");
root = xmlNewDocNode (doc, NULL, (xmlChar *)"feed", NULL);
-
+
xmlSetProp (root, (xmlChar *)"xmlns", (xmlChar *)"http://www.w3.org/2005/Atom");
ns_os = xmlNewNs (root, (xmlChar *)"http://a9.com/-/spec/opensearchrss/1.0/", (xmlChar *)"openSearch");
ns_gd = xmlNewNs (root, (xmlChar *)"http://schemas.google.com/g/2005", (xmlChar *)"gd");
cur = xmlNewChild (root, NULL, (xmlChar *)"id", NULL);
xmlNodeSetContent (cur, (xmlChar *)priv->id);
}
-
+
list = priv->categories;
while (list) {
cur = category_to_xmlnode (list->data);
xmlAddChild (root, cur);
list = g_slist_next (list);
}
-
+
list = priv->links;
while (list) {
cur = link_to_xmlnode (list->data);
xmlAddChild (root, cur);
- list = g_slist_next (list);
+ list = g_slist_next (list);
}
-
+
list = priv->authors;
while (list) {
cur = author_to_xmlnode (list->data);
xmlAddChild (root, cur);
list = g_slist_next (list);
}
-
+
list = priv->entries;
while (list) {
cur = entry_to_xmlnode (list->data);
{
GDataFeedPrivate *priv;
priv = GDATA_FEED_GET_PRIVATE (feed);
-
+
g_return_val_if_fail (feed !=NULL, NULL);
g_return_val_if_fail (GDATA_IS_FEED(feed), NULL);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
* Jason Willis <zenbrother@gmail.com>
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
};
struct _GDataFeedClass {
-
+
GObjectClass parent_class;
/* class members */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
* Jason Willis <zenbrother@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include <config.h>
#include <gdata-service-iface.h>
-void
+void
gdata_service_set_credentials (GDataService *self, const char *username, const gchar *password)
{
GDATA_SERVICE_GET_IFACE(self)->set_credentials(self, username, password);
return;
}
-GDataFeed*
+GDataFeed*
gdata_service_get_feed (GDataService *self, const char* feedURL)
{
return GDATA_SERVICE_GET_IFACE(self)->get_feed(self, feedURL);
}
-GDataEntry*
+GDataEntry*
gdata_service_insert_entry (GDataService *self, const gchar *feed_postURL, GDataEntry *entry)
{
return GDATA_SERVICE_GET_IFACE(self)->insert_entry(self, g_strdup(feed_postURL), entry);
}
-GDataEntry*
+GDataEntry*
gdata_service_get_entry (GDataService *self, const gchar *entry_getURL)
{
return GDATA_SERVICE_GET_IFACE(self)->get_entry(self, entry_getURL);
}
-GDataEntry*
+GDataEntry*
gdata_service_update_entry (GDataService *self, GDataEntry *entry)
{
GDATA_SERVICE_GET_IFACE(self)->update_entry(self, entry);
return NULL;
}
-GDataEntry*
+GDataEntry*
gdata_service_update_entry_with_link (GDataService *self, GDataEntry *entry, gchar *link)
{
GDATA_SERVICE_GET_IFACE(self)->update_entry_with_link(self, entry, link);
return NULL;
}
-void
+void
gdata_service_delete_entry (GDataService *self, GDataEntry *entry)
{
GDATA_SERVICE_GET_IFACE(self)->delete_entry (self, entry);
return;
}
-static void
+static void
gdata_service_base_init (gpointer g_class)
{
static gboolean initialized = FALSE;
}
}
-GType
+GType
gdata_service_get_type (void)
{
static GType type = 0;
- if (G_UNLIKELY(type == 0))
+ if (G_UNLIKELY(type == 0))
{
- static const GTypeInfo info =
+ static const GTypeInfo info =
{
sizeof (GDataServiceIface),
gdata_service_base_init, /* base_init */
0, /* n_preallocs */
NULL /* instance_init */
};
- type = g_type_register_static (G_TYPE_INTERFACE,
+ type = g_type_register_static (G_TYPE_INTERFACE,
"GDataService", &info, 0);
- g_type_interface_add_prerequisite (type, G_TYPE_OBJECT );
+ g_type_interface_add_prerequisite (type, G_TYPE_OBJECT );
}
return type;
-}
+}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Ebby Wiselyn <ebbywiselyn@gmail.com>
* Jason Willis <zenbrother@gmail.com>
*
* Copyright 2007, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
*
* * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
GMutex *reauth_mutex;
};
-static EGwConnectionStatus
-reauthenticate (EGwConnection *cnc)
+static EGwConnectionStatus
+reauthenticate (EGwConnection *cnc)
{
EGwConnectionPrivate *priv;
SoupSoapMessage *msg;
SoupSoapParameter *param;
EGwConnectionStatus status = -1;
char *session = NULL;
-
+
priv = cnc->priv;
if (!priv)
return E_GW_CONNECTION_STATUS_INVALID_CONNECTION;
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getCategoryListRequest");
e_gw_message_write_footer (msg);
- /* just to make sure we still have invlaid session
- when multiple e_gw_connection apis see inavlid connection error
+ /* just to make sure we still have invlaid session
+ when multiple e_gw_connection apis see inavlid connection error
at the sma time this prevents this function sending login requests multiple times */
- response = e_gw_connection_send_message (cnc, msg);
+ response = e_gw_connection_send_message (cnc, msg);
if (!response) {
g_object_unref (msg);
g_mutex_unlock (priv->reauth_mutex);
/* send message to server */
response = e_gw_connection_send_message (cnc, msg);
- if (response)
+ if (response)
status = e_gw_connection_parse_response_status (response);
if (status == E_GW_CONNECTION_STATUS_OK) {
param = soup_soap_response_get_first_parameter_by_name (response, "session");
- if (param)
+ if (param)
session = soup_soap_parameter_get_string_value (param);
-
+
}
-
+
if (session) {
g_free (priv->session_id);
priv->session_id = session;
- }
+ }
g_object_unref (msg);
if (response)
g_object_unref (response);
g_mutex_unlock (priv->reauth_mutex);
return status;
-
+
}
EGwConnectionStatus
EGwConnection *cnc = (EGwConnection *) object;
EGwConnectionPrivate *priv;
char *hash_key;
-
+
g_return_if_fail (E_IS_GW_CONNECTION (cnc));
-
+
priv = cnc->priv;
printf ("gw connection dispose \n");
-
+
/* removed the connection from the hash table */
if (loaded_connections_permissions != NULL) {
hash_key = g_strdup_printf ("%s:%s@%s",
}
g_free (hash_key);
}
-
+
if (priv) {
if (priv->session_id) {
logout (cnc);
g_free (priv->user_uuid);
priv->user_uuid = NULL;
}
-
+
if (priv->reauth_mutex) {
g_mutex_free (priv->reauth_mutex);
priv->reauth_mutex = NULL;
}
-
+
if (priv->categories_by_id) {
g_hash_table_destroy (priv->categories_by_id);
priv->categories_by_id = NULL;
- }
-
+ }
+
if (priv->categories_by_name) {
g_hash_table_destroy (priv->categories_by_name);
priv->categories_by_name = NULL;
}
-
+
if (priv->book_list) {
g_list_foreach (priv->book_list, (GFunc) g_object_unref, NULL);
g_list_free (priv->book_list);
priv->book_list = NULL;
}
-
+
if (priv->opts) {
g_object_unref (priv->opts);
priv->opts = NULL;
}
-
+
if (priv->version) {
g_free (priv->version) ;
priv->opts = NULL ;
if (parent_class->dispose)
(* parent_class->dispose) (object);
-}
+}
static void
e_gw_connection_finalize (GObject *object)
cnc->priv = priv;
/* Set a default timeout value of 30 seconds.
- FIXME: Make timeout configurable
+ FIXME: Make timeout configurable
*/
if (g_getenv ("SOUP_SESSION_TIMEOUT"))
timeout = atoi (g_getenv ("SOUP_SESSION_TIMEOUT"));
-
+
/* create the SoupSession for this connection */
priv->soup_session = soup_session_sync_new_with_options (SOUP_SESSION_TIMEOUT, timeout, NULL);
priv->reauth_mutex = g_mutex_new ();
EGwConnectionStatus status;
char *hash_key;
char *redirected_uri = NULL;
-
- static GStaticMutex connecting = G_STATIC_MUTEX_INIT;
-
+
+ static GStaticMutex connecting = G_STATIC_MUTEX_INIT;
+
g_static_mutex_lock (&connecting);
/* search the connection in our hash table */
}
}
-
+
/* not found, so create a new connection */
cnc = g_object_new (E_TYPE_GW_CONNECTION, NULL);
msg = form_login_request (uri, username, password);
-
+
/* send message to server */
response = e_gw_connection_send_message (cnc, msg);
g_free (host);
g_free (port);
}
-
+
}
param = soup_soap_response_get_first_parameter_by_name (response, "session");
if (!param) {
g_static_mutex_unlock (&connecting);
return NULL;
}
-
+
cnc->priv->uri = g_strdup (uri);
cnc->priv->username = g_strdup (username);
cnc->priv->password = g_strdup (password);
/* retrieve user information */
param = soup_soap_response_get_first_parameter_by_name (response, "userinfo");
-
+
if (param) {
SoupSoapParameter *subparam;
char *param_value;
param_value = soup_soap_parameter_get_string_value (param);
cnc->priv->version = param_value;
} else
- cnc->priv->version = NULL;
+ cnc->priv->version = NULL;
param = soup_soap_response_get_first_parameter_by_name (response, "serverUTCTime");
- if (param)
+ if (param)
cnc->priv->server_time = soup_soap_parameter_get_string_value (param);
/* add the connection to the loaded_connections_permissions hash table */
/* when user cancels password dialog, then the cnc is NULL */
if (!cnc)
return E_GW_CONNECTION_STATUS_UNKNOWN;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
g_return_val_if_fail (container_list != NULL, E_GW_CONNECTION_STATUS_UNKNOWN);
return status;
}
- /* if status is OK - parse result. return the list */
- param = soup_soap_response_get_first_parameter_by_name (response, "folders");
+ /* if status is OK - parse result. return the list */
+ param = soup_soap_response_get_first_parameter_by_name (response, "folders");
if (param) {
SoupSoapParameter *subparam;
for (subparam = soup_soap_parameter_get_first_child_by_name (param, "folder");
EGwContainer *container;
container = e_gw_container_new_from_soap_parameter (subparam);
- if (container)
+ if (container)
*container_list = g_list_append (*container_list, container);
}
}
return container_id;
}
-EGwConnectionStatus
-e_gw_connection_get_items_delta_info (EGwConnection *cnc, const char *container, gdouble *first_sequence,
+EGwConnectionStatus
+e_gw_connection_get_items_delta_info (EGwConnection *cnc, const char *container, gdouble *first_sequence,
gdouble *last_sequence, gdouble *last_po_rebuild_time )
{
SoupSoapMessage *msg;
EGwConnectionStatus status;
SoupSoapParameter *param, *subparam;
char *tmp = NULL;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
+
/* build the SOAP message */
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getDeltaInfoRequest");
if (!msg) {
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
/* parse these parameters */
subparam = soup_soap_parameter_get_first_child_by_name (param, "firstSequence");
}
else
*last_sequence = -1;
-
+
subparam = soup_soap_parameter_get_first_child_by_name (param, "lastTimePORebuild");
if (subparam) {
SoupSoapResponse *response;
EGwConnectionStatus status;
SoupSoapParameter *param, *subparam, *subsubparam;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
+
/* build the SOAP message */
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getDeltasRequest");
if (!msg) {
e_gw_message_write_string_parameter (msg, "container", NULL, container);
if (view)
e_gw_message_write_string_parameter (msg, "view", NULL, view);
-
+
soup_soap_message_start_element (msg, "deltaInfo", NULL, NULL);
e_gw_message_write_string_parameter (msg, "firstSequence", NULL, start_sequence);
e_gw_message_write_string_parameter (msg, "count", NULL, count);
soup_soap_message_end_element(msg);
-
+
/* send message to server */
e_gw_message_write_footer (msg);
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "items");
if (!param) {
g_object_unref (response);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
/* parse these parameters */
for (subparam = soup_soap_parameter_get_first_child_by_name (param, "item");
subparam != NULL;
subparam = soup_soap_parameter_get_next_child_by_name (subparam, "item")) {
EGwItem *item;
-
+
item = e_gw_item_new_from_soap_parameter (cnc->priv->user_email, container, subparam);
-
+
subsubparam = soup_soap_parameter_get_first_child_by_name(subparam, "sync");
if (subsubparam) {
char *value;
*add_list = g_list_append (*add_list, item);
} else if (!strcmp (value, "delete")) {
*delete_list = g_list_append (*delete_list, item);
- }
+ }
g_free (value);
}
}
-
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
SoupSoapResponse *response;
EGwConnectionStatus status;
SoupSoapParameter *param, *subparam;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
+
/* build the SOAP message */
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getItemsRequest");
if (!msg) {
e_gw_message_write_string_parameter (msg, "container", NULL, container);
if (view)
e_gw_message_write_string_parameter (msg, "view", NULL, view);
-
- if (filter)
+
+ if (filter)
e_gw_filter_append_to_soap_message (filter, msg);
e_gw_message_write_footer (msg);
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "items");
if (!param) {
g_object_unref (response);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
/* parse these parameters into ecalcomponents*/
for (subparam = soup_soap_parameter_get_first_child_by_name (param, "item");
subparam != NULL;
if (item)
*list = g_list_append (*list, item);
}
-
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
SoupSoapParameter *param, *subparam;
int i;
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
+
/* build the SOAP message */
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getItemsRequest");
if (!msg) {
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "items");
if (!param) {
g_object_unref (response);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
/* parse these parameters into ecalcomponents*/
for (subparam = soup_soap_parameter_get_first_child_by_name (param, "item");
subparam != NULL;
if (item)
*list = g_list_append (*list, item);
}
-
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
EGwConnectionStatus
e_gw_connection_get_deltas ( EGwConnection *cnc, GSList **adds, GSList **deletes, GSList **updates)
{
- SoupSoapMessage *msg;
- SoupSoapResponse *response;
- EGwConnectionStatus status;
- SoupSoapParameter *param, *subparam;
-
- g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
- /* build the SOAP message */
- msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getDeltaRequest");
- if (!msg) {
- g_warning (G_STRLOC ": Could not build SOAP message");
- // g_object_unref (cnc);
- return E_GW_CONNECTION_STATUS_UNKNOWN;
- }
-
+ SoupSoapMessage *msg;
+ SoupSoapResponse *response;
+ EGwConnectionStatus status;
+ SoupSoapParameter *param, *subparam;
+
+ g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
+
+ /* build the SOAP message */
+ msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getDeltaRequest");
+ if (!msg) {
+ g_warning (G_STRLOC ": Could not build SOAP message");
+ // g_object_unref (cnc);
+ return E_GW_CONNECTION_STATUS_UNKNOWN;
+ }
+
/*FIXME make this generic */
- soup_soap_message_start_element (msg, "CalendarItem", NULL, NULL);
- soup_soap_message_end_element (msg);
- e_gw_message_write_footer (msg);
-
- /* send message to server */
- response = e_gw_connection_send_message (cnc, msg);
- if (!response) {
- g_object_unref (msg);
- // g_object_unref (cnc);
- return E_GW_CONNECTION_STATUS_NO_RESPONSE;
- }
-
- status = e_gw_connection_parse_response_status (response);
- if (status != E_GW_CONNECTION_STATUS_OK) {
- g_object_unref (response);
- g_object_unref (msg);
- // g_object_unref (cnc);
- return status;
- }
-
- /* if status is OK - parse result. return the list */
- param = soup_soap_response_get_first_parameter_by_name (response, "changed");
- if (!param) {
- g_object_unref (response);
- g_object_unref (msg);
- // g_object_unref (cnc);
- return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
- }
-
- if (!g_ascii_strcasecmp ( soup_soap_parameter_get_string_value (param), "0")) {
- g_message ("No deltas");
- // g_object_unref (cnc);
- return E_GW_CONNECTION_STATUS_OK;
- }
-
- param = soup_soap_response_get_first_parameter_by_name (response, "deltas");
- if (!param) {
- g_object_unref (response);
- g_object_unref (msg);
- // g_object_unref (cnc);
-// return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+ soup_soap_message_start_element (msg, "CalendarItem", NULL, NULL);
+ soup_soap_message_end_element (msg);
+ e_gw_message_write_footer (msg);
+
+ /* send message to server */
+ response = e_gw_connection_send_message (cnc, msg);
+ if (!response) {
+ g_object_unref (msg);
+ // g_object_unref (cnc);
+ return E_GW_CONNECTION_STATUS_NO_RESPONSE;
+ }
+
+ status = e_gw_connection_parse_response_status (response);
+ if (status != E_GW_CONNECTION_STATUS_OK) {
+ g_object_unref (response);
+ g_object_unref (msg);
+ // g_object_unref (cnc);
+ return status;
+ }
+
+ /* if status is OK - parse result. return the list */
+ param = soup_soap_response_get_first_parameter_by_name (response, "changed");
+ if (!param) {
+ g_object_unref (response);
+ g_object_unref (msg);
+ // g_object_unref (cnc);
+ return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+ }
+
+ if (!g_ascii_strcasecmp ( soup_soap_parameter_get_string_value (param), "0")) {
+ g_message ("No deltas");
+ // g_object_unref (cnc);
+ return E_GW_CONNECTION_STATUS_OK;
+ }
+
+ param = soup_soap_response_get_first_parameter_by_name (response, "deltas");
+ if (!param) {
+ g_object_unref (response);
+ g_object_unref (msg);
+ // g_object_unref (cnc);
+// return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
/* getting around the server behavior that deltas can be null
* though changes is true */
return E_GW_CONNECTION_STATUS_OK;
- }
-
- /* process all deletes first*/
- param = soup_soap_parameter_get_first_child_by_name (param, "delete");
- if (param) {
- for (subparam = soup_soap_parameter_get_first_child_by_name (param, "item");
- subparam != NULL;
- subparam = soup_soap_parameter_get_next_child_by_name (subparam, "item")) {
- /*process each item */
- char *uid;
- SoupSoapParameter *param_id;
-
- param_id = soup_soap_parameter_get_first_child_by_name (subparam, "id");
- if (!param_id) {
- g_object_unref (response);
- g_object_unref (msg);
- // g_object_unref (cnc);
- }
- uid = (char *)soup_soap_parameter_get_string_value (param_id);
- /*if (!e_cal_backend_cache_remove_component (cache, uid, NULL))
+ }
+
+ /* process all deletes first*/
+ param = soup_soap_parameter_get_first_child_by_name (param, "delete");
+ if (param) {
+ for (subparam = soup_soap_parameter_get_first_child_by_name (param, "item");
+ subparam != NULL;
+ subparam = soup_soap_parameter_get_next_child_by_name (subparam, "item")) {
+ /*process each item */
+ char *uid;
+ SoupSoapParameter *param_id;
+
+ param_id = soup_soap_parameter_get_first_child_by_name (subparam, "id");
+ if (!param_id) {
+ g_object_unref (response);
+ g_object_unref (msg);
+ // g_object_unref (cnc);
+ }
+ uid = (char *)soup_soap_parameter_get_string_value (param_id);
+ /*if (!e_cal_backend_cache_remove_component (cache, uid, NULL))
g_message ("Could not remove %s", uid); */
*deletes = g_slist_append (*deletes, uid);
- }
- }
-
- /* process adds*/
- param = soup_soap_parameter_get_first_child_by_name (param, "add");
- if (param) {
- for (subparam = soup_soap_parameter_get_first_child_by_name (param, "item");
- subparam != NULL;
- subparam = soup_soap_parameter_get_next_child_by_name (subparam, "item")) {
- /*process each item */
+ }
+ }
+
+ /* process adds*/
+ param = soup_soap_parameter_get_first_child_by_name (param, "add");
+ if (param) {
+ for (subparam = soup_soap_parameter_get_first_child_by_name (param, "item");
+ subparam != NULL;
+ subparam = soup_soap_parameter_get_next_child_by_name (subparam, "item")) {
+ /*process each item */
EGwItem *item;
/*FIXME pass the container id */
item = e_gw_item_new_from_soap_parameter (cnc->priv->user_email, "Calendar", subparam);
- if (!item) {
- g_object_unref (response);
- g_object_unref (msg);
- // g_object_unref (cnc);
- return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
- }
- /*if (!e_cal_backend_cache_put_component (cache, comp))
+ if (!item) {
+ g_object_unref (response);
+ g_object_unref (msg);
+ // g_object_unref (cnc);
+ return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+ }
+ /*if (!e_cal_backend_cache_put_component (cache, comp))
g_message ("Could not add the component"); */
*adds = g_slist_append (*adds, item);
- }
- }
-
- /* process updates*/
- param = soup_soap_parameter_get_first_child_by_name (param, "update");
- if (param) {
- for (subparam = soup_soap_parameter_get_first_child_by_name(param, "item");
- subparam != NULL;
- subparam = soup_soap_parameter_get_next_child (subparam)) {
+ }
+ }
+
+ /* process updates*/
+ param = soup_soap_parameter_get_first_child_by_name (param, "update");
+ if (param) {
+ for (subparam = soup_soap_parameter_get_first_child_by_name(param, "item");
+ subparam != NULL;
+ subparam = soup_soap_parameter_get_next_child (subparam)) {
EGwItem *item;
/*process each item */
/*item = get_item_from_updates (subparam);*/
item = e_gw_item_new_from_soap_parameter (cnc->priv->user_email, "Calendar", subparam);
if (item)
*updates = g_slist_append (*updates, item);
- }
+ }
}
-
- /* free memory */
- g_object_unref (response);
- g_object_unref (msg);
- return E_GW_CONNECTION_STATUS_OK;
+ /* free memory */
+ g_object_unref (response);
+ g_object_unref (msg);
+
+ return E_GW_CONNECTION_STATUS_OK;
}
EGwConnectionStatus
// for loop here to populate the list_ids.
for (param = soup_soap_response_get_first_parameter_by_name (response, "id");
param; param = soup_soap_response_get_next_parameter_by_name (response, param, "id")) {
-
+
*id_list = g_slist_append (*id_list, soup_soap_parameter_get_string_value (param));
}
}
SoupSoapResponse *response;
SoupSoapParameter *param;
EGwConnectionStatus status = E_GW_CONNECTION_STATUS_UNKNOWN;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_CONNECTION);
g_return_val_if_fail (E_IS_GW_ITEM (item), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
status = e_gw_connection_parse_response_status (response);
if (status == E_GW_CONNECTION_STATUS_OK) {
param = soup_soap_response_get_first_parameter_by_name (response, "id");
- if (param != NULL)
+ if (param != NULL)
*id = g_strdup (soup_soap_parameter_get_string_value (param));
} else if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
reauthenticate (cnc);
-
+
g_object_unref (msg);
g_object_unref (response);
return status;
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_modify_item (EGwConnection *cnc, const char *id , EGwItem *item)
{
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
/* build the SOAP message */
g_object_unref (response);
return status;
-
+
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_get_item (EGwConnection *cnc, const char *container, const char *id, const char *view, EGwItem **item)
{
g_warning (G_STRLOC ": Could not build SOAP message");
return E_GW_CONNECTION_STATUS_UNKNOWN;
}
-
+
e_gw_message_write_string_parameter (msg, "id", NULL, id);
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "item");
if (!param) {
g_object_unref (response);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
*item = e_gw_item_new_from_soap_parameter (cnc->priv->user_email, container, param);
-
-
+
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
e_gw_message_write_string_parameter (msg, "item", NULL, id);
soup_soap_message_end_element (msg);
e_gw_message_write_string_parameter (msg, "acceptLevel", NULL, accept_level);
-
+
if (recurrence_key)
e_gw_message_write_string_parameter (msg, "recurrenceAllInstances", NULL, recurrence_key);
soup_soap_message_start_element (msg, "items", NULL, NULL);
e_gw_message_write_string_parameter (msg, "item", NULL, id);
soup_soap_message_end_element (msg);
-
+
if (decline_comment)
e_gw_message_write_string_parameter (msg, "comment", NULL, decline_comment);
return status;
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_delegate_request (EGwConnection *cnc, EGwItem *item, const char *id, const char *comments_org, const char *comments_del, const char *recur_key)
{
SoupSoapMessage *msg;
SoupSoapResponse *response;
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "delegateRequest");
-
+
if (id)
e_gw_message_write_string_parameter (msg, "id", NULL, id);
e_gw_message_write_string_parameter (msg, "commentToDelegatee", NULL, comments_del);
if (recur_key)
e_gw_message_write_string_parameter (msg, "recurrenceAllInstances", NULL, recur_key);
-
+
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
status = e_gw_connection_parse_response_status (response);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
reauthenticate (cnc);
-
+
g_object_unref (response);
g_object_unref (msg);
-
+
return status;
}
return (const char *) cnc->priv->user_name;
}
-const char*
+const char*
e_gw_connection_get_user_email (EGwConnection *cnc)
{
g_return_val_if_fail (cnc != NULL, NULL);
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), NULL);
-
+
return (const char*) cnc->priv->user_email;
-
+
}
const char *
return (const char *) cnc->priv->user_uuid;
}
-const char *
+const char *
e_gw_connection_get_server_time (EGwConnection *cnc)
{
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), NULL) ;
{
struct tm date;
int len, i;
-
+
g_return_val_if_fail (str != NULL, -1);
/* yyyymmdd[Thhmmss[Z]] */
date.tm_min = digit_at (str, 11) * 10 + digit_at (str, 12);
date.tm_sec = digit_at (str, 13) * 10 + digit_at (str, 14);
} else
- date.tm_hour = date.tm_min = date.tm_sec = 0;
+ date.tm_hour = date.tm_min = date.tm_sec = 0;
return mktime (&date);
}
{
char *str2;
int i, j, len = strlen (dtstring);
-
+
str2 = g_malloc0 (len);
if (len <= 0)
return str2;
char *str2;
int i, j, len = strlen (dtstring);
time_t t;
-
+
str2 = g_malloc0 (len+1);
for (i = 0,j = 0; i < len; i++) {
if ((dtstring[i] != '-') && (dtstring[i] != ':')) {
return t;
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_create_book (EGwConnection *cnc, char *book_name, char**id)
{
SoupSoapMessage *msg;
if (value)
*id = value;
- status = E_GW_CONNECTION_STATUS_OK;
- return status;
-}
+ status = E_GW_CONNECTION_STATUS_OK;
+ return status;
+}
EGwConnectionStatus
e_gw_connection_get_address_book_list (EGwConnection *cnc, GList **container_list)
g_static_mutex_unlock (&connecting);
return status;
}
-
- /* if status is OK - parse result. return the list */
- param = soup_soap_response_get_first_parameter_by_name (response, "books");
+
+ /* if status is OK - parse result. return the list */
+ param = soup_soap_response_get_first_parameter_by_name (response, "books");
if (!param) {
g_object_unref (response);
g_static_mutex_unlock (&connecting);
subparam != NULL;
subparam = soup_soap_parameter_get_next_child_by_name (subparam, "book")) {
EGwContainer *container;
-
+
container = e_gw_container_new_from_soap_parameter (subparam);
if (container) {
priv->book_list = g_list_append (priv->book_list, container);
value = soup_soap_parameter_get_string_value (type_param);
if (value && g_str_equal(value , "1"))
e_gw_container_set_is_writable (container, TRUE);
- else
+ else
e_gw_container_set_is_writable (container, FALSE);
g_free (value);
value = NULL;
value = soup_soap_parameter_get_string_value (type_param);
if (value && g_str_equal(value , "1"))
e_gw_container_set_is_frequent_contacts (container, TRUE);
-
+
g_free (value);
-
+
}
-
+
}
}
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_get_address_book_id ( EGwConnection *cnc, char *book_name, char**id , gboolean *is_writable)
{
EGwConnectionStatus status;
for (l = container_list; l != NULL; l = l->next) {
EGwContainer *container = E_GW_CONTAINER (l->data);
if (strcmp (e_gw_container_get_name (container), book_name) == 0) {
-
+
*id = g_strdup (e_gw_container_get_id (container));
*is_writable = e_gw_container_get_is_writable (container);
break;
g_warning (G_STRLOC ": Could not build SOAP message");
return E_GW_CONNECTION_STATUS_UNKNOWN;
}
-
+
if (!e_gw_sendoptions_form_message_to_modify (msg, opts, priv->opts)) {
g_warning (G_STRLOC ": Could not append changes to SOAP message");
g_object_unref (msg);
}
e_gw_message_write_footer (msg);
-
+
/* send message to server */
response = e_gw_connection_send_message (cnc, msg);
if (!response) {
EGwConnectionStatus status;
SoupSoapParameter *param;
EGwConnectionPrivate *priv;
- static GStaticMutex connecting = G_STATIC_MUTEX_INIT;
+ static GStaticMutex connecting = G_STATIC_MUTEX_INIT;
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
g_object_ref (priv->opts);
*opts = priv->opts;
g_static_mutex_unlock (&connecting);
-
+
return E_GW_CONNECTION_STATUS_OK;
}
g_static_mutex_unlock (&connecting);
return status;
}
-
+
param = soup_soap_response_get_first_parameter_by_name (response, "settings");
if (!param) {
g_object_unref (response);
g_object_unref (msg);
g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
- } else
+ } else
priv->opts = e_gw_sendoptions_new_from_soap_parameter (param);
g_object_ref (priv->opts);
g_object_unref (response);
g_object_unref (msg);
g_static_mutex_unlock (&connecting);
-
+
return E_GW_CONNECTION_STATUS_OK;
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_get_categories (EGwConnection *cnc, GHashTable **categories_by_id, GHashTable **categories_by_name)
{
SoupSoapMessage *msg;
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "categories");
if (!param) {
g_object_unref (response);
g_static_mutex_unlock (&connecting);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
priv->categories_by_id = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
priv->categories_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
char **components = g_strsplit (id, "@", -1);
g_free (id);
id = components[0];
- if (categories_by_id)
+ if (categories_by_id)
g_hash_table_insert (priv->categories_by_id, g_strdup (id), g_strdup (name));
- if (categories_by_name)
+ if (categories_by_name)
g_hash_table_insert (priv->categories_by_name, g_strdup (name), g_strdup (id));
g_strfreev (components);
g_free (name);
}
-
+
}
-
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_OK;
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_add_members (EGwConnection *cnc, const char *group_id, GList *member_ids)
{
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
g_return_val_if_fail (member_ids != NULL, E_GW_CONNECTION_STATUS_UNKNOWN);
g_return_val_if_fail (group_id != NULL, E_GW_CONNECTION_STATUS_UNKNOWN);
-
+
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "addMembersRequest");
if (!msg) {
g_warning (G_STRLOC ": Could not build SOAP message");
e_gw_message_write_string_parameter (msg, "id", NULL, member_ids->data);
soup_soap_message_end_element(msg);
}
-
+
soup_soap_message_end_element(msg);
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
g_object_unref (response);
g_object_unref (msg);
return status;
-
+
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_remove_members (EGwConnection *cnc, const char *group_id, GList *member_ids)
{
-
+
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
g_return_val_if_fail (member_ids != NULL, E_GW_CONNECTION_STATUS_UNKNOWN);
g_return_val_if_fail (group_id != NULL, E_GW_CONNECTION_STATUS_UNKNOWN);
-
+
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "removeMembersRequest");
if (!msg) {
g_warning (G_STRLOC ": Could not build SOAP message");
e_gw_message_write_string_parameter (msg, "view", NULL, view);
if (E_IS_GW_FILTER(filter))
e_gw_filter_append_to_soap_message (filter, msg);
-
+
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
}
-
+
status = e_gw_connection_parse_response_status (response);
if (status != E_GW_CONNECTION_STATUS_OK) {
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
value = soup_soap_parameter_get_string_value(param);
-
+
if (!value) {
g_object_unref (response);
g_object_unref (msg);
}
*cursor =(int) g_ascii_strtod (value, NULL);
-
+
g_free (value);
g_object_unref (response);
g_object_unref (msg);
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
g_return_val_if_fail ((container != NULL), E_GW_CONNECTION_STATUS_UNKNOWN);
-
+
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "destroyCursorRequest");
e_gw_message_write_string_parameter (msg, "container", NULL, container);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
}
-
+
status = e_gw_connection_parse_response_status (response);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
reauthenticate (cnc);
g_object_unref (response);
g_object_unref (msg);
return status;
-
+
}
e_gw_message_write_string_parameter (msg, "container", NULL, container);
e_gw_message_write_string_parameter (msg, "seek", NULL, seek);
e_gw_message_write_int_parameter (msg, "offset", NULL, offset);
-
+
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
}
-
+
status = e_gw_connection_parse_response_status (response);
g_object_unref (response);
g_object_unref (msg);
SoupSoapResponse *response;
EGwConnectionStatus status;
SoupSoapParameter *param, *subparam;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
g_return_val_if_fail ((container != NULL), E_GW_CONNECTION_STATUS_UNKNOWN);
-
+
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "readCursorRequest");
e_gw_message_write_int_parameter (msg, "cursor", NULL, cursor);
- /* there is problem in read curosr if you set this, uncomment after the problem
+ /* there is problem in read curosr if you set this, uncomment after the problem
is fixed in server */
e_gw_message_write_string_parameter (msg, "position", NULL, cursor_seek);
e_gw_message_write_string_parameter (msg, "forward", NULL, forward ? "true": "false");
e_gw_message_write_string_parameter (msg, "container", NULL, container);
e_gw_message_write_int_parameter (msg, "count", NULL, count);
-
+
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
}
-
+
status = e_gw_connection_parse_response_status (response);
if (status != E_GW_CONNECTION_STATUS_OK) {
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "items");
if (!param) {
g_object_unref (response);
if (item)
*item_list = g_list_append (*item_list, item);
}
-
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
SoupSoapResponse *response;
EGwConnectionStatus status;
SoupSoapParameter *param, *subparam;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
g_return_val_if_fail (message_list != NULL, E_GW_CONNECTION_STATUS_UNKNOWN);
e_gw_message_write_string_parameter (msg, "startDate", NULL, *start_date);
if (container)
e_gw_message_write_string_parameter (msg, "container", NULL, container);
- if (item_types)
+ if (item_types)
e_gw_message_write_string_parameter (msg, "types", NULL, item_types);
if (item_sources)
e_gw_message_write_string_parameter (msg, "source", NULL, item_sources);
e_gw_message_write_string_parameter (msg, "view", NULL, view);
if (count > 0)
e_gw_message_write_int_parameter (msg, "count", NULL, count);
-
+
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
}
-
+
status = e_gw_connection_parse_response_status (response);
if (status != E_GW_CONNECTION_STATUS_OK) {
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
*item_list = NULL;
param = soup_soap_response_get_first_parameter_by_name (response, "items");
if (!param) {
date = soup_soap_parameter_get_string_value (subparam);
if (date)
g_free (*start_date), *start_date = NULL, *start_date = date;
- else
+ else
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
- } else
+ } else
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
- if (!strcmp (message_list, "All")) {
+
+ if (!strcmp (message_list, "All")) {
gboolean view_is_id = FALSE;
- if (!strcmp (view, "id"))
+ if (!strcmp (view, "id"))
view_is_id = TRUE;
/* We are interested only in getting the ids */
for (subparam = soup_soap_parameter_get_first_child_by_name (param, "item");
subparam = soup_soap_parameter_get_next_child_by_name (subparam, "item")) {
SoupSoapParameter *param_id;
char *id;
-
+
if (view_is_id) {
param_id = soup_soap_parameter_get_first_child_by_name (subparam, "id");
if (!param_id) {
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
}
-
+
id = g_strdup (soup_soap_parameter_get_string_value (param_id));
if (id)
*item_list = g_slist_append (*item_list, id);
}
-
+
g_object_unref (response);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_OK;
if (item)
*item_list = g_slist_append (*item_list, item);
}
-
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_OK;
-
+
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_create_folder(EGwConnection *cnc, const char *parent_name,const char *folder_name, char **container_id)
{
SoupSoapMessage *msg;
}
/*
- *
+ *
*/
EGwConnectionStatus
e_gw_connection_get_attachment (EGwConnection *cnc, const char *id, int offset, int length, const char **attachment, int *attach_length)
g_warning (G_STRLOC ": Could not build SOAP message");
return E_GW_CONNECTION_STATUS_UNKNOWN;
}
-
+
e_gw_message_write_string_parameter (msg, "id", NULL, id);
e_gw_message_write_int_parameter (msg, "offset", NULL, offset);
return status;
}
-
+
param = soup_soap_response_get_first_parameter_by_name (response, "part") ;
if (param) {
buf_length = soup_soap_parameter_get_property (param, "length") ;
buffer = soup_soap_parameter_get_string_value (param) ;
}
-
+
if (buffer && buf_length) {
int len = atoi (buf_length) ;
*attachment = g_base64_decode (buffer,&len) ;
}
/*
- *
+ *
*/
EGwConnectionStatus
e_gw_connection_get_attachment_base64 (EGwConnection *cnc, const char *id, int offset, int length, const char **attachment, int *attach_length, int *offset_r)
g_warning (G_STRLOC ": Could not build SOAP message");
return E_GW_CONNECTION_STATUS_UNKNOWN;
}
-
+
e_gw_message_write_string_parameter (msg, "id", NULL, id);
e_gw_message_write_int_parameter (msg, "offset", NULL, offset);
return status;
}
-
+
param = soup_soap_response_get_first_parameter_by_name (response, "part") ;
if (param) {
buf_length = soup_soap_parameter_get_property (param, "length") ;
o_return = soup_soap_parameter_get_property (param, "offset") ;
buffer = soup_soap_parameter_get_string_value (param) ;
}
-
+
if (buffer && buf_length) {
int len = atoi (buf_length) ;
*attachment = g_strdup (buffer);
if (container && *container)
e_gw_message_write_string_parameter (msg, "container", NULL, container);
-
+
soup_soap_message_start_element (msg, "items", NULL, NULL);
for (; item_ids != NULL; item_ids = g_list_next (item_ids))
e_gw_message_write_string_parameter (msg, "item", NULL, item_ids->data);
return status;
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_rename_folder (EGwConnection *cnc, const char *id ,const char *new_name)
{
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
/* build the SOAP message */
e_gw_message_write_string_parameter (msg, "name", NULL, new_name);
soup_soap_message_end_element (msg) ;
soup_soap_message_end_element (msg) ;
-
+
e_gw_message_write_footer (msg);
/* send message to server */
g_object_unref (response);
return status;
-
+
}
-EGwConnectionStatus
-e_gw_connection_share_folder(EGwConnection *cnc, gchar *id, GList *new_list, const char *sub, const char *mesg ,int flag)
+EGwConnectionStatus
+e_gw_connection_share_folder(EGwConnection *cnc, gchar *id, GList *new_list, const char *sub, const char *mesg ,int flag)
{
SoupSoapMessage *msg;
SoupSoapResponse *response;
e_gw_container_form_message (msg, id, new_list, sub, mesg, flag);
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
-
+
if (!response) {
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
g_return_val_if_fail (id != NULL, E_GW_CONNECTION_STATUS_INVALID_OBJECT);
g_return_val_if_fail (dest_container_id != NULL, E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
+
/* build the SOAP message */
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "moveItemRequest");
e_gw_message_write_string_parameter (msg, "id", NULL, id);
e_gw_message_write_string_parameter (msg, "container", NULL,dest_container_id);
if (from_container_id)
- e_gw_message_write_string_parameter (msg, "from", NULL,from_container_id);
+ e_gw_message_write_string_parameter (msg, "from", NULL,from_container_id);
e_gw_message_write_footer (msg);
/* send message to server */
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_purge_deleted_items (EGwConnection *cnc)
{
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status = E_GW_CONNECTION_STATUS_UNKNOWN;
-
+
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "purgeDeletedItemsRequest");
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_purge_selected_items (EGwConnection *cnc, GList *item_ids)
{
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status = E_GW_CONNECTION_STATUS_UNKNOWN;
-
+
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "purgeRequest");
/* Now write the elements that need to be deleted */
soup_soap_message_start_element (msg, "items", NULL, NULL);
SoupSoapResponse *response;
EGwConnectionStatus status;
SoupSoapParameter *param;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
+
/* build the SOAP message */
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "replyRequest");
if (!msg) {
g_warning (G_STRLOC ": Could not build SOAP message");
return E_GW_CONNECTION_STATUS_UNKNOWN;
}
-
+
e_gw_message_write_string_parameter (msg, "id", NULL, id);
if (view)
e_gw_message_write_string_parameter (msg, "view", NULL, view) ;
e_gw_message_write_footer (msg);
-
+
/* send message to server */
response = e_gw_connection_send_message (cnc, msg);
if (!response) {
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
}
-
+
status = e_gw_connection_parse_response_status (response);
if (status != E_GW_CONNECTION_STATUS_OK) {
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "item");
if (!param) {
g_object_unref (response);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
*item = e_gw_item_new_from_soap_parameter (cnc->priv->user_email, "", param);
-
-
+
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
SoupSoapParameter *param;
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
+
/* build the SOAP message */
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "forwardRequest");
if (!msg) {
g_warning (G_STRLOC ": Could not build SOAP message");
return E_GW_CONNECTION_STATUS_UNKNOWN;
}
-
+
e_gw_message_write_string_parameter (msg, "id", NULL, id);
if (view)
e_gw_message_write_string_parameter (msg, "view", NULL, view) ;
- if (embed)
+ if (embed)
e_gw_message_write_int_parameter (msg, "embed", NULL,1);
-
+
e_gw_message_write_footer (msg);
/* send message to server */
response = e_gw_connection_send_message (cnc, msg);
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "item");
if (!param) {
g_object_unref (response);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
*item = e_gw_item_new_from_soap_parameter (cnc->priv->user_email, "", param);
-
-
+
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
/* e_gw_connection_create_junk_entry :creates a junk entry in the list
* @cnc
- * @value : to be added in the list
+ * @value : to be added in the list
* @match_type : "email"/"domain" default: email
* @list_type : "junk"/"trust"/"block" default: junk
* */
EGwConnectionStatus
-e_gw_connection_create_junk_entry (EGwConnection *cnc, const char *value, const char *match_type, const char *list_type)
+e_gw_connection_create_junk_entry (EGwConnection *cnc, const char *value, const char *match_type, const char *list_type)
{
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
g_return_val_if_fail (value != NULL, E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
+
/* build the SOAP message */
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "createJunkEntryRequest");
if (!msg) {
soup_soap_message_end_element (msg);
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
-
+
if (!response) {
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
parse_junk_settings (SoupSoapParameter *param, int *use_junk, int *use_block, int *use_pab, int *persistence)
{
SoupSoapParameter *subparam, *field_param, *val_param;
-
+
if (param == NULL)
return ;
else {
val = soup_soap_parameter_get_int_value (val_param);
*use_pab = val;
g_free (field);
- } else if (!g_ascii_strcasecmp (field, "persistence")) {
+ } else if (!g_ascii_strcasecmp (field, "persistence")) {
if (val_param)
val = soup_soap_parameter_get_int_value (val_param);
*persistence = val;
* use_junk : returned value, whether junk list is being used
* use_block: use block list
* use_pab: returned value, whether personal addresbook is used
- * persistence:
+ * persistence:
* */
EGwConnectionStatus
e_gw_connection_get_junk_settings (EGwConnection *cnc, int *use_junk, int *use_block, int *use_pab, int *persistence)
SoupSoapResponse *response;
SoupSoapParameter *param;
EGwConnectionStatus status;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
+
/* build the SOAP message */
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getJunkMailSettingsRequest");
}
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
-
+
if (!response) {
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
}
-static void
+static void
msg_add_settings (SoupSoapMessage *msg, char *field, int value)
{
soup_soap_message_start_element (msg, "setting", NULL, NULL);
* use_pab 1: put messages except from personal add book in junk, 0 disable
* @persistence :delete after
* */
-
+
EGwConnectionStatus
e_gw_connection_modify_junk_settings (EGwConnection *cnc, int use_junk, int use_pab, int use_block, int persistence)
{
status = e_gw_connection_parse_response_status (response);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
reauthenticate (cnc);
-
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
junk_entry->matchType = soup_soap_parameter_get_string_value (subparam);
subparam = soup_soap_parameter_get_first_child_by_name (param, "lastUsed");
- if (subparam)
+ if (subparam)
junk_entry->lastUsed = soup_soap_parameter_get_string_value (subparam);
subparam = soup_soap_parameter_get_first_child_by_name (param, "version");
- if (subparam)
+ if (subparam)
junk_entry->version = soup_soap_parameter_get_int_value (subparam);
subparam = soup_soap_parameter_get_first_child_by_name (param, "modified");
- if (subparam)
+ if (subparam)
junk_entry->modified = soup_soap_parameter_get_string_value (subparam);
return junk_entry;
if (junk_entry)
*entries = g_list_append (*entries, junk_entry);
}
- }
+ }
param = soup_soap_response_get_first_parameter_by_name (response, "block");
if (param) {
for (subparam = soup_soap_parameter_get_first_child_by_name (param, "entry");
SoupSoapMessage *msg;
SoupSoapResponse *response;
EGwConnectionStatus status;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
-
+
/* build the SOAP message */
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getJunkEntriesRequest");
}
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
-
+
if (!response) {
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_NO_RESPONSE;
/* if status is OK - parse result. return the list */
if (status == E_GW_CONNECTION_STATUS_OK)
get_junk_list_from_soap_response (response, entries);
-
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
status = e_gw_connection_parse_response_status (response);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
reauthenticate (cnc);
-
+
/* free memory */
g_object_unref (response);
g_object_unref (msg);
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "readCursorRequest");
e_gw_message_write_int_parameter (msg, "cursor", NULL, cursor);
*list = NULL;
- /* there is problem in read curosr if you set this, uncomment after the problem
+ /* there is problem in read curosr if you set this, uncomment after the problem
is fixed in server */
e_gw_message_write_string_parameter (msg, "position", NULL, cursor_seek);
e_gw_message_write_string_parameter (msg, "forward", NULL, forward ? "true": "false");
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "items");
if (!param) {
g_object_unref (response);
EGwItemCalId *calid = g_new0 (EGwItemCalId, 1);
EGwItemType type;
char *id = NULL, *item_type = NULL;
-
+
item_type = soup_soap_parameter_get_property (subparam, "type");
-
+
if (g_str_equal (item_type, "Appointment"))
type = E_GW_ITEM_TYPE_APPOINTMENT;
else if (g_str_equal (item_type, "Task"))
type = E_GW_ITEM_TYPE_NOTE;
}
g_free (item_type);
-
+
param_id = soup_soap_parameter_get_first_child_by_name (subparam, "id");
if (param_id) {
id = soup_soap_parameter_get_string_value (param_id);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
id = NULL;
-
+
param_id = soup_soap_parameter_get_first_child_by_name (subparam, "recurrenceKey");
if (param_id) {
id = soup_soap_parameter_get_string_value (param_id);
}
-
+
if (id && !g_str_equal (id, "0")) {
guint allday = 0;
calid->recur_key = id;
-
+
if (type == E_GW_ITEM_TYPE_APPOINTMENT) {
param_id = soup_soap_parameter_get_first_child_by_name (subparam, "allDayEvent");
if (param_id) {
}
- if (allday)
+ if (allday)
param_id = soup_soap_parameter_get_first_child_by_name (subparam, "startDay");
else
param_id = soup_soap_parameter_get_first_child_by_name (subparam, "startDate");
id = soup_soap_parameter_get_string_value (param_id);
formatted_date = e_gw_connection_format_date_string (id);
/* store the date in calid for recurring events */
- calid->ical_id = formatted_date;
+ calid->ical_id = formatted_date;
g_free (id);
}
msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "readCursorRequest");
e_gw_message_write_int_parameter (msg, "cursor", NULL, cursor);
*list = NULL;
- /* there is problem in read curosr if you set this, uncomment after the problem
+ /* there is problem in read curosr if you set this, uncomment after the problem
is fixed in server */
e_gw_message_write_string_parameter (msg, "position", NULL, cursor_seek);
e_gw_message_write_string_parameter (msg, "forward", NULL, forward ? "true": "false");
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "items");
if (!param) {
g_object_unref (response);
subparam = soup_soap_parameter_get_next_child_by_name (subparam, "item")) {
SoupSoapParameter *param_id;
char *id = NULL;
-
+
param_id = soup_soap_parameter_get_first_child_by_name (subparam, "id");
if (!param_id) {
if (*list) {
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
id = soup_soap_parameter_get_string_value (param_id);
if (id)
*list = g_list_prepend (*list, id);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
reauthenticate (cnc);
- param = soup_soap_response_get_first_parameter_by_name (response, "accessRights");
+ param = soup_soap_response_get_first_parameter_by_name (response, "accessRights");
if (!param) {
g_object_unref (response);
return status;
return status;
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_add_proxy (EGwConnection *cnc, proxyHandler *new_proxy)
{
SoupSoapMessage *msg = NULL;
SoupSoapResponse *response = NULL;
EGwConnectionStatus status;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
msg = e_gw_message_new_with_header (e_gw_connection_get_uri (cnc), e_gw_connection_get_session_id (cnc), "createProxyAccessRequest");
e_gw_proxy_form_proxy_add_msg (msg, new_proxy);
-
+
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
if (!response) {
msg = e_gw_message_new_with_header (e_gw_connection_get_uri(cnc), e_gw_connection_get_session_id(cnc), "removeProxyAccessRequest");
e_gw_proxy_form_proxy_remove_msg (msg, removeProxy);
-
+
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
}
-EGwConnectionStatus
+EGwConnectionStatus
e_gw_connection_modify_proxy (EGwConnection *cnc, proxyHandler *new_proxy)
{
SoupSoapMessage *msg = NULL;
SoupSoapResponse *response = NULL;
EGwConnectionStatus status;
-
+
g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
msg = e_gw_message_new_with_header (e_gw_connection_get_uri (cnc), e_gw_connection_get_session_id (cnc), "modifyProxyAccessRequest");
e_gw_message_write_string_parameter (msg, "id", NULL, new_proxy->uniqueid);
-
+
e_gw_proxy_form_modify_proxy_msg (msg, new_proxy);
-
+
e_gw_message_write_footer (msg);
response = e_gw_connection_send_message (cnc, msg);
-
+
if (!response) {
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
g_warning (G_STRLOC ": Could not build SOAP message");
return E_GW_CONNECTION_STATUS_UNKNOWN;
}
-
+
e_gw_message_write_footer (msg);
-
+
/* send message to server */
response = e_gw_connection_send_message (cnc, msg);
if (!response) {
g_object_unref (msg);
return status;
}
- /* if status is OK - parse result. return the list */
+ /* if status is OK - parse result. return the list */
param = soup_soap_response_get_first_parameter_by_name (response, "proxies");
- e_gw_proxy_construct_proxy_list (param, proxy_info);
+ e_gw_proxy_construct_proxy_list (param, proxy_info);
if (!param) {
g_object_unref (response);
g_object_unref (msg);
return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
}
-
+
g_object_unref (response);
g_object_unref (msg);
int i;
char *permissions_key = NULL;
- static GStaticMutex connecting = G_STATIC_MUTEX_INIT;
+ static GStaticMutex connecting = G_STATIC_MUTEX_INIT;
g_static_mutex_lock (&connecting);
for (i=0; proxy[i]!='\0' && proxy[i]!='@'; i++);
if (proxy[i]=='@')
name = g_strndup(proxy, i);
- else
+ else
name = g_strdup (proxy);
/* search the connection in our hash table */
if (loaded_connections_permissions != NULL) {
param_value = soup_soap_parameter_get_string_value (param);
cnc->priv->version = param_value;
} else
- cnc->priv->version = NULL;
+ cnc->priv->version = NULL;
param = soup_soap_response_get_first_parameter_by_name (response, "serverUTCTime");
- if (param)
+ if (param)
cnc->priv->server_time = soup_soap_parameter_get_string_value (param);
/* add the connection to the loaded_connections_permissions hash table */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
EGwConnectionStatus e_gw_connection_modify_settings (EGwConnection *cnc, EGwSendOptions *opts);
EGwConnectionStatus e_gw_connection_add_items (EGwConnection *cnc, const char *container, GList *item_ids) ;
EGwConnectionStatus e_gw_connection_rename_folder (EGwConnection *cnc, const char *id ,const char *new_name) ;
-EGwConnectionStatus e_gw_connection_share_folder (EGwConnection *cnc, gchar *id, GList *new_list, const char *sub, const char *mesg ,int flag);
+EGwConnectionStatus e_gw_connection_share_folder (EGwConnection *cnc, gchar *id, GList *new_list, const char *sub, const char *mesg ,int flag);
EGwConnectionStatus e_gw_connection_accept_shared_folder (EGwConnection *cnc, gchar *folder_name, gchar *container_id, gchar *item_id, gchar *desc);
EGwConnectionStatus e_gw_connection_purge_deleted_items (EGwConnection *cnc);
EGwConnectionStatus e_gw_connection_purge_selected_items (EGwConnection *cnc, GList *item_ids);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
guint32 unread ;
guint32 total ;
int sequence;
- char *owner;
- GList *user_list;
+ char *owner;
+ GList *user_list;
char *modified;
EGwContainerType type ;
gboolean is_root ;
gboolean is_writable;
gboolean is_frequent_contacts; /*indicates whether this folder is frequent contacts or not */
- gboolean is_shared_by_me;
+ gboolean is_shared_by_me;
gboolean is_shared_to_me;
gboolean is_system_folder;
};
/*retrieve the folder type*/
subparam = soup_soap_parameter_get_first_child_by_name (param, "folderType") ;
- if (!subparam)
+ if (!subparam)
container->priv->type = E_GW_CONTAINER_TYPE_FOLDER ;
else {
value = soup_soap_parameter_get_string_value (subparam);
- if (!strcmp (value, "Root"))
+ if (!strcmp (value, "Root"))
container->priv->type = E_GW_CONTAINER_TYPE_ROOT ;
- else if (!strcmp (value, "Mailbox"))
+ else if (!strcmp (value, "Mailbox"))
container->priv->type = E_GW_CONTAINER_TYPE_INBOX ;
- else if (!strcmp (value, "SentItems"))
+ else if (!strcmp (value, "SentItems"))
container->priv->type = E_GW_CONTAINER_TYPE_SENT;
- else if (!strcmp (value, "Calendar"))
+ else if (!strcmp (value, "Calendar"))
container->priv->type = E_GW_CONTAINER_TYPE_CALENDAR ;
- else if (!strcmp (value, "Contacts"))
+ else if (!strcmp (value, "Contacts"))
container->priv->type = E_GW_CONTAINER_TYPE_CONTACTS ;
- else if (!strcmp (value, "Draft"))
+ else if (!strcmp (value, "Draft"))
container->priv->type = E_GW_CONTAINER_TYPE_DRAFT ;
- else if (!strcmp (value, "Trash"))
+ else if (!strcmp (value, "Trash"))
container->priv->type = E_GW_CONTAINER_TYPE_TRASH ;
- else if (!strcmp (value, "JunkMail"))
+ else if (!strcmp (value, "JunkMail"))
container->priv->type = E_GW_CONTAINER_TYPE_JUNK;
g_free (value) ;
}
}
/* is shared to me*/
subparam = soup_soap_parameter_get_first_child_by_name (param, "isSharedToMe");
-
+
if (!subparam) {
e_gw_container_set_is_shared_to_me (container, FALSE);
if (value) {
e_gw_container_set_is_shared_to_me (container, TRUE);
tome = TRUE;
- } else {
+ } else {
e_gw_container_set_is_shared_to_me (container, FALSE);
tome = FALSE;
}
-
+
g_free (value);
}
/*Retrieve email add of the sharing person*/
value = soup_soap_parameter_get_string_value (email_rt_subparam);
if (value) {
user->email = value;
- }
+ }
/* Retrieve Rights*/
email_rt_subparam = soup_soap_parameter_get_first_child_by_name (entry_subparam, "rights");
g_warning (G_STRLOC ": User without any Rights");
else {
rights = 0;
- rights_subparam = soup_soap_parameter_get_first_child_by_name (email_rt_subparam, "add");
- if (rights_subparam)
+ rights_subparam = soup_soap_parameter_get_first_child_by_name (email_rt_subparam, "add");
+ if (rights_subparam)
rights = rights | 0x1;
- rights_subparam = soup_soap_parameter_get_first_child_by_name (email_rt_subparam, "edit");
- if (rights_subparam)
+ rights_subparam = soup_soap_parameter_get_first_child_by_name (email_rt_subparam, "edit");
+ if (rights_subparam)
rights = rights | 0x2;
- rights_subparam = soup_soap_parameter_get_first_child_by_name (email_rt_subparam, "delete");
- if (rights_subparam)
+ rights_subparam = soup_soap_parameter_get_first_child_by_name (email_rt_subparam, "delete");
+ if (rights_subparam)
rights = rights | 0x4;
user->rights = rights;
container->priv->user_list = g_list_append (container->priv->user_list, user);
- }
+ }
}
e_gw_container_set_owner (container, value);
g_free (value);
}
- }
+ }
/* shared folder*/
/*Retrieve When Modified last*/
/*retrieve sequence*/
subparam = soup_soap_parameter_get_first_child_by_name (param, "sequence");
- if (subparam) {
+ if (subparam) {
int_value = soup_soap_parameter_get_int_value (subparam);
- e_gw_container_set_sequence (container, int_value);
+ e_gw_container_set_sequence (container, int_value);
}
return TRUE;
}
-void
+void
e_gw_container_get_user_list (EGwContainer *container, GList **user_list)
{
g_return_if_fail (E_GW_CONTAINER (container));
-
+
*user_list = container->priv->user_list;
}
e_gw_container_get_sequence (EGwContainer *container)
{
g_return_val_if_fail (E_IS_GW_CONTAINER (container), 0);
-
+
return (int)container->priv->sequence;
}
-static void
+static void
e_gw_container_set_sequence (EGwContainer *container, int sequence)
{
g_return_if_fail (E_IS_GW_CONTAINER (container));
priv->modified = g_strdup (modified);
}
-static void
+static void
e_gw_container_set_owner(EGwContainer *container, const char *owner)
{
EGwContainerPrivate *priv;
-
+
g_return_if_fail (E_IS_GW_CONTAINER(container));
g_return_if_fail (owner!=NULL);
-
+
priv = container->priv;
if (priv->owner)
g_free (container->priv->owner);
e_gw_container_get_owner (EGwContainer *container)
{
g_return_val_if_fail (E_GW_CONTAINER (container), NULL);
-
+
return (const char *) container->priv->owner;
}
g_return_val_if_fail (E_IS_GW_CONTAINER (container), 0);
user_list = container->priv->user_list;
-
+
for (node = user_list; node != NULL; node = node->next) {
user = node->data;
if( !strcmp (user->email, email))
e_gw_container_get_is_shared_by_me (EGwContainer *container)
{
g_return_val_if_fail (E_IS_GW_CONTAINER (container), FALSE);
-
+
return (gboolean) container->priv->is_shared_by_me;
}
e_gw_container_set_is_shared_by_me (EGwContainer *container, gboolean is_shared_by_me)
{
g_return_if_fail (E_IS_GW_CONTAINER (container));
-
+
container->priv->is_shared_by_me = is_shared_by_me;
}
e_gw_container_get_is_shared_to_me (EGwContainer *container)
{
g_return_val_if_fail (E_IS_GW_CONTAINER (container), FALSE);
-
+
return (gboolean) container->priv->is_shared_to_me;
}
e_gw_container_set_is_shared_to_me (EGwContainer *container, gboolean is_shared_to_me)
{
g_return_if_fail (E_IS_GW_CONTAINER (container));
-
+
container->priv->is_shared_to_me = is_shared_to_me;
}
e_gw_container_get_is_system_folder (EGwContainer *container)
{
g_return_val_if_fail (E_IS_GW_CONTAINER (container), FALSE);
-
+
return container->priv->is_system_folder;
}
e_gw_container_set_is_system_folder (EGwContainer *container, gboolean is_system_folder)
{
g_return_if_fail (E_IS_GW_CONTAINER (container));
-
+
container->priv->is_system_folder = is_system_folder;
}
}
const char *
-e_gw_container_get_parent_id (EGwContainer *container)
+e_gw_container_get_parent_id (EGwContainer *container)
{
g_return_val_if_fail (E_IS_GW_CONTAINER (container), NULL);
e_gw_container_set_parent_id (EGwContainer *container, const char *parent_id)
{
EGwContainerPrivate *priv ;
-
+
g_return_if_fail (E_IS_GW_CONTAINER (container));
g_return_if_fail (parent_id != NULL);
return container->priv->total ;
}
-
+
guint32
e_gw_container_get_unread_count (EGwContainer *container)
{
}
-gboolean
+gboolean
e_gw_container_get_is_writable (EGwContainer *container)
{
g_return_val_if_fail (E_IS_GW_CONTAINER (container), FALSE);
-
+
return container->priv->is_writable;
}
-void
+void
e_gw_container_set_is_writable (EGwContainer *container, gboolean is_writable)
{
g_return_if_fail (E_IS_GW_CONTAINER (container));
-
+
container->priv->is_writable = is_writable;
}
-gboolean
+gboolean
e_gw_container_get_is_frequent_contacts (EGwContainer *container)
{
g_return_val_if_fail (E_IS_GW_CONTAINER (container), FALSE);
-
+
return container->priv->is_frequent_contacts;
}
e_gw_container_set_is_frequent_contacts (EGwContainer *container, gboolean is_frequent_contacts)
{
g_return_if_fail (E_IS_GW_CONTAINER (container));
-
+
container->priv->is_frequent_contacts = is_frequent_contacts;
}
e_gw_container_is_root (EGwContainer *container)
{
g_return_val_if_fail (E_IS_GW_CONTAINER (container), FALSE) ;
-
+
return container->priv->is_root ;
}
* flag = 2 :update entry
* flag = 0 :add to acl
*/
-void
+void
e_gw_container_form_message (SoupSoapMessage *msg, gchar *id, GList *new_list, const char *sub, const char *mesg, int flag)
{
gboolean add, edit, del;
soup_soap_message_end_element (msg);
soup_soap_message_start_element (msg, "updates", NULL, NULL);
- if (flag == 0) {
+ if (flag == 0) {
soup_soap_message_start_element (msg, "add", NULL, NULL);
soup_soap_message_start_element (msg, "acl", NULL, NULL);
add=edit=del=FALSE;
soup_soap_message_start_element (msg, "entry", NULL, NULL);
e_gw_message_write_string_parameter (msg, "displayName", NULL,"");
- email = g_strdup (user->email);
+ email = g_strdup (user->email);
if (user->rights & 0x1)
add = TRUE;
if (user->rights & 0x2)
soup_soap_message_end_element (msg);
soup_soap_message_end_element (msg);
- }
+ }
soup_soap_message_end_element (msg);
soup_soap_message_end_element (msg);
add = edit = del = FALSE;
soup_soap_message_start_element (msg, "entry", NULL, NULL);
e_gw_message_write_string_parameter (msg, "displayName", NULL, "name");
- email = g_strdup (user->email);
+ email = g_strdup (user->email);
if(user->rights & 0x1)
add = TRUE;
soup_soap_message_end_element (msg);
soup_soap_message_end_element (msg);
- } else if (flag == 2) {
+ } else if (flag == 2) {
soup_soap_message_start_element (msg, "update", NULL, NULL);
soup_soap_message_start_element (msg, "acl", NULL, NULL);
add = edit = del = FALSE;
soup_soap_message_start_element (msg, "entry", NULL, NULL);
e_gw_message_write_string_parameter (msg, "displayName",NULL,"");
- email = g_strdup (user->email);
+ email = g_strdup (user->email);
if (user->rights & 0x1)
add = TRUE;
if (user->rights & 0x2)
}
- soup_soap_message_end_element (msg);
+ soup_soap_message_end_element (msg);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
E_GW_CONTAINER_TYPE_TRASH,
E_GW_CONTAINER_TYPE_JUNK,
E_GW_CONTAINER_TYPE_FOLDER
-
+
} EGwContainerType ;
GType e_gw_container_get_type (void);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
- * Sivaiah Nallagatla <snallagatla@novell.com>
- *
+/*
+ * Authors :
+ * Sivaiah Nallagatla <snallagatla@novell.com>
+ *
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
struct _EGwFilterPrivate {
GSList *component_list;
int filter_group_type; /* stores, whether all condtions are to be met or any one of them*/
-
+
};
e_gw_filter_add_filter_component (EGwFilter *filter, EGwFilterOpType operation, const char *field_name, const char *field_value)
{
FilterComponent *component;
-
+
g_return_if_fail (E_IS_GW_FILTER (filter));
g_return_if_fail (field_name != NULL);
g_return_if_fail (field_value != NULL);
-
+
component = g_new0 (FilterComponent, 1);
component->operation = operation;
component->field_name = g_strdup (field_name);
}
-void
+void
e_gw_filter_group_conditions (EGwFilter *filter, EGwFilterOpType operation, int num_of_condtions)
{
FilterComponent *component;
-
+
g_return_if_fail (E_IS_GW_FILTER (filter));
g_return_if_fail ( operation == E_GW_FILTER_OP_AND || operation == E_GW_FILTER_OP_OR ||
operation == E_GW_FILTER_OP_NOT);
filter->priv->component_list = g_slist_prepend (filter->priv->component_list, component);
}
-static void
+static void
append_child_component (FilterComponent* filter_component, SoupSoapMessage *msg)
{
g_return_if_fail (SOUP_IS_SOAP_MESSAGE (msg));
soup_soap_message_start_element (msg, "element", NULL, NULL);
operation_name = NULL;
-
+
switch (filter_component->operation) {
-
+
case E_GW_FILTER_OP_EQUAL :
operation_name = "eq";
break;
case E_GW_FILTER_OP_NOTEXISTS :
operation_name = "notExist";
break;
-
+
}
-
-
+
+
if (operation_name != NULL) {
-
+
e_gw_message_write_string_parameter (msg, "op", NULL, operation_name);
e_gw_message_write_string_parameter (msg, "field", NULL, filter_component->field_name);
e_gw_message_write_string_parameter (msg, "value", NULL, filter_component->field_value);
-static GSList*
+static GSList*
append_complex_component (GSList *component_list, SoupSoapMessage *msg)
{
FilterComponent *filter_component;
filter_component = (FilterComponent* )component_list->data;
if (filter_component->operation == E_GW_FILTER_OP_AND || filter_component->operation == E_GW_FILTER_OP_OR
|| filter_component->operation == E_GW_FILTER_OP_NOT ) {
-
+
soup_soap_message_start_element (msg, "group", NULL, NULL);
if (filter_component->operation == E_GW_FILTER_OP_AND)
e_gw_message_write_string_parameter (msg, "op", NULL, "and");
- else if (filter_component->operation == E_GW_FILTER_OP_OR)
+ else if (filter_component->operation == E_GW_FILTER_OP_OR)
e_gw_message_write_string_parameter (msg, "op", NULL, "or");
else
e_gw_message_write_string_parameter (msg, "op", NULL, "not");
|| filter_component->operation == E_GW_FILTER_OP_NOT ) {
component_list = append_complex_component (component_list, msg);
}
- else
+ else
append_child_component (filter_component, msg);
-
+
}
soup_soap_message_end_element (msg);
return component_list;
}
-void
+void
e_gw_filter_append_to_soap_message (EGwFilter *filter, SoupSoapMessage *msg)
{
EGwFilterPrivate *priv;
g_return_if_fail (E_IS_GW_FILTER (filter));
g_return_if_fail (SOUP_IS_SOAP_MESSAGE (msg));
-
+
priv = filter->priv;
component_list = priv->component_list;
|| filter_component->operation == E_GW_FILTER_OP_NOT) {
component_list = append_complex_component (component_list, msg);
}
- else
+ else
append_child_component (filter_component, msg);
soup_soap_message_end_element (msg); //end filter
-
+
}
}
(* parent_class->finalize) (object);
}
-static void
+static void
e_gw_filter_dispose (GObject *object)
{
-
+
if (parent_class->dispose)
(* parent_class->dispose) (object);
e_gw_filter_class_init (EGwFilterClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
+
parent_class = g_type_class_peek_parent (klass);
object_class->dispose = e_gw_filter_dispose;
object_class->finalize = e_gw_filter_finalize;
e_gw_filter_get_type (void)
{
static GType type = 0;
-
+
if (!type) {
static GTypeInfo info = {
sizeof (EGwFilterClass),
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
- * Sivaiah Nallagatla <snallagatla@novell.com>
- *
+/*
+ * Authors :
+ * Sivaiah Nallagatla <snallagatla@novell.com>
+ *
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
E_GW_FILTER_OP_BEGINS,
E_GW_FILTER_OP_EXISTS,
E_GW_FILTER_OP_NOTEXISTS
-
+
} EGwFilterOpType;
struct _EGwFilter {
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
* Harish Krishnaswamy <kharish@novell.com>
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
int recurrence_key;
int trigger; /* alarm */
/*message size*/
- int size;
+ int size;
EGwItemOrganizer *organizer;
/*properties for mail*/
int item_status;
/*Attachments*/
gboolean has_attachment;
- GSList *attach_list ;
+ GSList *attach_list ;
/*linkInfo for replies*/
- EGwItemLinkInfo *link_info;
+ EGwItemLinkInfo *link_info;
/* properties for tasks/calendars */
char *icalid;
- /* if the self is not the organizer of the item, the
+ /* if the self is not the organizer of the item, the
* status is not reflected in the recipientStatus.
* Hence it should be gleaned from the 'status' element
* of the Mail, the parent item.*/
GHashTable *addresses;
/***** Send Options *****/
-
+
gboolean set_sendoptions;
/* Reply Request */
char *reply_within;
gboolean reply_request_set;
-
+
/* Status Tracking through sent Item */
EGwItemTrack track_info;
gboolean autodelete;
/* changes */
GHashTable *additions;
GHashTable *updates;
- GHashTable *deletions;
+ GHashTable *deletions;
/*padding*/
unsigned int padding[10];
};
g_free (recipient);
}
-static void
+static void
free_postal_address (gpointer postal_address)
{
PostalAddress *address;
}
}
-static void
+static void
free_full_name (gpointer full_name)
{
FullName *name = (FullName *) full_name;
}
-static void
+static void
free_string (gpointer s, gpointer data)
{
if (s)
}
static void
-free_attach (gpointer s, gpointer data)
+free_attach (gpointer s, gpointer data)
{
EGwItemAttachment *attach = (EGwItemAttachment *) s ;
if (attach) {
- if (attach->id)
+ if (attach->id)
g_free (attach->id), attach->id = NULL ;
if (attach->name)
g_free (attach->name), attach->name = NULL ;
g_free (attach->date), attach->date = NULL ;
if (attach->data)
g_free (attach->data), attach->data = NULL ;
-
+
g_free(attach) ;
}
-
+
}
-static void
+static void
free_member (gpointer member, gpointer data)
{
EGroupMember *group_member = (EGroupMember *) member;
g_free (group_member);
}
-static void
+static void
free_im_address ( gpointer address, gpointer data)
{
IMAddress *im_address;
im_address = (IMAddress *) address;
-
+
if (im_address) {
if (im_address->service)
g_free (im_address->service);
}
}
-static void
+static void
free_changes ( GHashTable *changes)
{
gpointer value;
g_free (priv->priority);
priv->priority = NULL;
}
-
+
if (priv->task_priority) {
g_free (priv->task_priority);
priv->task_priority = NULL;
}
-
+
if (priv->place) {
g_free (priv->place);
priv->place = NULL;
g_free (priv->to) ;
priv->to = NULL ;
}
-
+
if (priv->content_type) {
g_free (priv->content_type) ;
priv->content_type = NULL ;
g_slist_foreach (priv->recipient_list, (GFunc) free_recipient, NULL);
g_slist_free (priv->recipient_list);
priv->recipient_list = NULL;
- }
-
+ }
+
if (priv->organizer) {
g_free (priv->organizer->display_name);
g_free (priv->organizer->email);
priv->organizer = NULL;
}
-
+
if (priv->recurrence_dates) {
g_slist_foreach (priv->recurrence_dates, free_string, NULL);
g_slist_free (priv->recurrence_dates);
free_full_name (priv->full_name);
priv->full_name = NULL;
}
-
+
if (priv->simple_fields)
g_hash_table_destroy (priv->simple_fields);
-
+
if (priv->addresses)
g_hash_table_destroy (priv->addresses);
-
+
if (priv->email_list) {
g_list_foreach (priv->email_list, free_string , NULL);
g_list_free (priv->email_list);
priv->email_list = NULL;
}
-
+
if (priv->member_list) {
g_list_foreach (priv->member_list, free_member, NULL);
g_list_free (priv->member_list);
g_list_free (priv->im_list);
priv->im_list = NULL;
}
-
+
if (priv->category_list) {
g_list_foreach (priv->category_list, free_string, NULL);
g_list_free (priv->category_list);
priv->category_list = NULL;
}
-
+
if(priv->attach_list) {
- g_slist_foreach (priv->attach_list, free_attach, NULL);
+ g_slist_foreach (priv->attach_list, free_attach, NULL);
g_slist_free (priv->attach_list) ;
priv->attach_list = NULL ;
}
-
+
if (priv->category_name) {
g_free (priv->category_name);
priv->category_name = NULL;
}
-
+
if (priv->source) {
g_free (priv->source);
priv->source = NULL;
}
-
+
if (priv->link_info) {
free_link_info (priv->link_info);
priv->link_info = NULL;
if (priv->end_date) {
g_free (priv->end_date);
priv->end_date = NULL;
- }
-
+ }
+
free_changes (priv->additions);
free_changes (priv->deletions);
free_changes (priv->updates);
-
+
}
if (parent_class->dispose)
priv->creation_date = NULL;
priv->delivered_date = NULL;
priv->start_date = NULL;
- priv->end_date = NULL;
- priv->due_date = NULL;
+ priv->end_date = NULL;
+ priv->due_date = NULL;
priv->completed_date = NULL;
priv->trigger = 0;
priv->recipient_list = NULL;
priv->msg_body_id = NULL;
priv->has_attachment = FALSE;
item->priv = priv;
-
-
+
+
}
GType
return type;
}
-void
+void
e_gw_item_free_cal_id (EGwItemCalId *calid)
{
if (calid->item_id) {
g_free (calid->item_id);
calid->item_id = NULL;
}
-
+
if (calid->ical_id) {
g_free (calid->ical_id);
calid->ical_id = NULL;
}
-
+
if (calid->recur_key) {
g_free (calid->recur_key);
calid->recur_key = NULL;
return g_object_new (E_TYPE_GW_ITEM, NULL);
}
-static void
+static void
set_recipient_list_from_soap_parameter (EGwItem *item, SoupSoapParameter *param)
{
SoupSoapParameter *param_recipient;
GList *email_list;
email_list = e_gw_item_get_email_list (item);
-
+
for (param_recipient = soup_soap_parameter_get_first_child_by_name (param, "recipient");
param_recipient != NULL;
param_recipient = soup_soap_parameter_get_next_child_by_name (param_recipient, "recipient")) {
SoupSoapParameter *subparam;
- recipient = g_new0 (EGwItemRecipient, 1);
+ recipient = g_new0 (EGwItemRecipient, 1);
subparam = soup_soap_parameter_get_first_child_by_name (param_recipient, "email");
if (subparam) {
email = soup_soap_parameter_get_string_value (subparam);
if (email)
recipient->email = email;
- }
+ }
subparam = soup_soap_parameter_get_first_child_by_name (param_recipient, "displayName");
if (subparam) {
cn = soup_soap_parameter_get_string_value (subparam);
if (cn)
recipient->display_name = cn;
}
-
+
subparam = soup_soap_parameter_get_first_child_by_name (param_recipient, "distType");
if (subparam) {
const char *dist_type;
dist_type = soup_soap_parameter_get_string_value (subparam);
- if (!strcmp (dist_type, "TO"))
+ if (!strcmp (dist_type, "TO"))
recipient->type = E_GW_ITEM_RECIPIENT_TO;
else if (!strcmp (dist_type, "CC"))
recipient->type = E_GW_ITEM_RECIPIENT_CC;
}
/*FIXME gw recipientTypes need to be added after the server is fixed. */
-
+
/* update Recipient Status
look for accepted/declined and update the item else set it
to none. */
subparam = soup_soap_parameter_get_first_child_by_name (param_recipient, "recipientStatus");
if (subparam) {
- char *formatted_date, *value;
+ char *formatted_date, *value;
SoupSoapParameter *temp_param ;
recipient->status_enabled = TRUE;
recipient->deleted_date = g_strdup (formatted_date);
g_free (value), value = NULL;
g_free (formatted_date), formatted_date = NULL;
- }
+ }
if ( (temp_param = soup_soap_parameter_get_first_child_by_name (subparam, "declined")) ) {
recipient->status = E_GW_ITEM_STAT_DECLINED;
value = soup_soap_parameter_get_string_value (temp_param);
recipient->accepted_date = g_strdup (formatted_date);
g_free (value), value = NULL;
g_free (formatted_date), formatted_date = NULL;
- } else
+ } else
recipient->status = E_GW_ITEM_STAT_NONE;
temp_param = soup_soap_parameter_get_first_child_by_name (subparam, "completed");
if (temp_param) {
else {
/* if recipientStatus is not provided, use the
* self_status, obtained from the mail properties. */
- if (!strcmp ((const char *)email_list->data, recipient->email))
- recipient->status = item->priv->self_status & (E_GW_ITEM_STAT_DECLINED |
+ if (!strcmp ((const char *)email_list->data, recipient->email))
+ recipient->status = item->priv->self_status & (E_GW_ITEM_STAT_DECLINED |
E_GW_ITEM_STAT_ACCEPTED);
else
recipient->status = E_GW_ITEM_STAT_NONE;
}
-
+
item->priv->recipient_list = g_slist_append (item->priv->recipient_list, recipient);
- }
+ }
}
static EGwItemReturnNotify
get_notification_value (SoupSoapParameter *param, const char *param_name)
{
SoupSoapParameter *subparam;
-
+
if ((subparam = soup_soap_parameter_get_first_child_by_name (param, param_name))) {
char *value = NULL;
-
+
subparam = soup_soap_parameter_get_first_child_by_name (subparam, "mail");
if (subparam)
value = soup_soap_parameter_get_string_value (subparam);
priv = item->priv;
- if ( (subparam = soup_soap_parameter_get_first_child_by_name (param, "requestReply")) ) {
+ if ( (subparam = soup_soap_parameter_get_first_child_by_name (param, "requestReply")) ) {
child = soup_soap_parameter_get_first_child_by_name (subparam, "whenConvenient");
if (child) {
value = soup_soap_parameter_get_string_value (child);
- if (value && !g_ascii_strcasecmp (value, "1"))
+ if (value && !g_ascii_strcasecmp (value, "1"))
priv->reply_request_set = TRUE;
- }
+ }
if (!priv->reply_request_set) {
child = soup_soap_parameter_get_first_child_by_name (subparam, "byDate");
-
+
if (child)
value = soup_soap_parameter_get_string_value (child);
if (value) {
}
g_free (value), value = NULL;
- }
+ }
if ( (subparam = soup_soap_parameter_get_first_child_by_name (param, "statusTracking"))) {
value = soup_soap_parameter_get_string_value (subparam);
if (value) {
- if (!g_ascii_strcasecmp (value, "Delivered"))
+ if (!g_ascii_strcasecmp (value, "Delivered"))
priv->track_info = E_GW_ITEM_DELIVERED;
- else if (!g_ascii_strcasecmp (value, "DeliveredAndOpened"))
+ else if (!g_ascii_strcasecmp (value, "DeliveredAndOpened"))
priv->track_info = E_GW_ITEM_DELIVERED_OPENED;
- else if (!g_ascii_strcasecmp (value, "All"))
+ else if (!g_ascii_strcasecmp (value, "All"))
priv->track_info = E_GW_ITEM_ALL;
-
+
g_free (value), value = NULL;
value = soup_soap_parameter_get_property (subparam, "autoDelete");
if (value && !g_ascii_strcasecmp (value, "1"))
- priv->autodelete = TRUE;
+ priv->autodelete = TRUE;
g_free (value), value = NULL;
- }
+ }
}
if ( (subparam = soup_soap_parameter_get_first_child_by_name (param, "notification"))) {
- priv->notify_opened = get_notification_value (subparam, "opened");
- priv->notify_deleted = get_notification_value (subparam, "deleted");
- priv->notify_accepted = get_notification_value (subparam, "accepted");
- priv->notify_declined = get_notification_value (subparam, "declined");
- priv->notify_completed = get_notification_value (subparam, "completed");
+ priv->notify_opened = get_notification_value (subparam, "opened");
+ priv->notify_deleted = get_notification_value (subparam, "deleted");
+ priv->notify_accepted = get_notification_value (subparam, "accepted");
+ priv->notify_declined = get_notification_value (subparam, "declined");
+ priv->notify_completed = get_notification_value (subparam, "completed");
}
}
g_return_val_if_fail (field_name != NULL, NULL);
g_return_val_if_fail (E_IS_GW_ITEM(item), NULL);
-
+
if (item->priv->simple_fields == NULL)
return NULL;
-
+
value = (char *) g_hash_table_lookup (item->priv->simple_fields, field_name);
if (value)
return value;
-
+
return NULL;
}
-void
+void
e_gw_item_set_field_value (EGwItem *item, char *field_name, char* field_value)
{
g_return_if_fail (field_name != NULL);
g_return_if_fail (field_name != NULL);
g_return_if_fail (E_IS_GW_ITEM(item));
-
+
if (item->priv->simple_fields != NULL)
g_hash_table_insert (item->priv->simple_fields, field_name, g_strdup (field_value));
}
-guint32
+guint32
e_gw_item_get_item_status (EGwItem *item)
{
return item->priv->self_status;
}
-GList *
+GList *
e_gw_item_get_email_list (EGwItem *item)
{
return item->priv->email_list;
}
-void
-e_gw_item_set_email_list (EGwItem *item, GList* email_list)
+void
+e_gw_item_set_email_list (EGwItem *item, GList* email_list)
{
item->priv->email_list = email_list;
}
-GList *
+GList *
e_gw_item_get_im_list (EGwItem *item)
{
return item->priv->im_list;
}
-void
+void
e_gw_item_set_im_list (EGwItem *item, GList *im_list)
{
item->priv->im_list = im_list;
return item->priv->full_name;
}
-void
+void
e_gw_item_set_full_name (EGwItem *item, FullName *full_name)
-{
+{
item->priv->full_name = full_name;
}
return item->priv->member_list;
}
-void
+void
e_gw_item_set_member_list (EGwItem *item, GList *list)
{
item->priv->member_list = list;
}
-void
+void
e_gw_item_set_address (EGwItem *item, char *address_type, PostalAddress *address)
{
if (address_type && address)
return (PostalAddress *) g_hash_table_lookup (item->priv->addresses, address_type);
}
-void
+void
e_gw_item_set_categories (EGwItem *item, GList *category_list)
{
item->priv->category_list = category_list;
return item->priv->category_list;
}
-void
+void
e_gw_item_set_category_name (EGwItem *item, char *category_name)
{
item->priv->category_name = category_name;
case E_GW_ITEM_CHNAGE_TYPE_UNKNOWN :
hash_table = NULL;
break;
-
+
}
if (hash_table)
g_hash_table_insert (hash_table, field_name, field_value);
-
+
}
-static void
+static void
set_common_addressbook_item_fields_from_soap_parameter (EGwItem *item, SoupSoapParameter *param)
{
SoupSoapParameter *subparam, *category_param;
value = components[0];
priv->category_list = g_list_append (priv->category_list, g_strdup (value));
g_strfreev(components);
-
+
}
-
+
}
}
}
-static void
+static void
set_postal_address_from_soap_parameter (PostalAddress *address, SoupSoapParameter *param)
{
SoupSoapParameter *subparam;
if (value)
address->street_address = value;
}
-
+
subparam = soup_soap_parameter_get_first_child_by_name (param, "location");
if (subparam) {
value = soup_soap_parameter_get_string_value (subparam);
-
+
if (value)
address->location = value;
}
-
+
subparam = soup_soap_parameter_get_first_child_by_name (param, "city");
if (subparam) {
value = soup_soap_parameter_get_string_value (subparam);
if (value)
address->city = value;
}
-
+
subparam = soup_soap_parameter_get_first_child_by_name (param, "state");
if (subparam) {
value = soup_soap_parameter_get_string_value (subparam);
if (value)
address->state = value;
}
-
+
subparam = soup_soap_parameter_get_first_child_by_name (param, "postalCode");
if (subparam) {
value = soup_soap_parameter_get_string_value (subparam);
if (value)
address->postal_code = value;
}
-
+
subparam = soup_soap_parameter_get_first_child_by_name (param, "country");
if (subparam) {
value = soup_soap_parameter_get_string_value (subparam);
if (value)
address->country = value;
}
-
+
}
-static void
+static void
set_contact_fields_from_soap_parameter (EGwItem *item, SoupSoapParameter *param)
{
char *value;
if (full_name) {
subparam = soup_soap_parameter_get_first_child_by_name (param, "fullName");
if (subparam) {
- temp = soup_soap_parameter_get_first_child_by_name(subparam, "namePrefix");
+ temp = soup_soap_parameter_get_first_child_by_name(subparam, "namePrefix");
if (temp) {
value = soup_soap_parameter_get_string_value (temp);
if (value)
full_name->name_prefix = value;
}
- temp = soup_soap_parameter_get_first_child_by_name(subparam, "firstName");
+ temp = soup_soap_parameter_get_first_child_by_name(subparam, "firstName");
if (temp) {
value = soup_soap_parameter_get_string_value (temp);
if (value)
full_name->first_name = value;
}
- temp = soup_soap_parameter_get_first_child_by_name(subparam, "middleName");
+ temp = soup_soap_parameter_get_first_child_by_name(subparam, "middleName");
if (temp) {
value = soup_soap_parameter_get_string_value (temp);
if (value)
full_name->middle_name = value;
}
- temp = soup_soap_parameter_get_first_child_by_name(subparam, "lastName");
+ temp = soup_soap_parameter_get_first_child_by_name(subparam, "lastName");
if (temp) {
value = soup_soap_parameter_get_string_value (temp);
if (value)
full_name->last_name = value;
}
- temp = soup_soap_parameter_get_first_child_by_name(subparam, "nameSuffix");
+ temp = soup_soap_parameter_get_first_child_by_name(subparam, "nameSuffix");
if (temp) {
value = soup_soap_parameter_get_string_value (temp);
if (value)
}
}
}
- subparam = soup_soap_parameter_get_first_child_by_name(param, "emailList");
+ subparam = soup_soap_parameter_get_first_child_by_name(param, "emailList");
if (subparam) {
primary_email = NULL;
value = soup_soap_parameter_get_property(subparam, "primary");
- if (value) {
+ if (value) {
primary_email = value;
item->priv->email_list = g_list_append (item->priv->email_list, g_strdup (primary_email));
}
}
if (im_address->service && im_address->address)
item->priv->im_list = g_list_append (item->priv->im_list, im_address);
- else
- free_im_address (im_address, NULL);
-
+ else
+ free_im_address (im_address, NULL);
+
}
}
-
-
+
+
subparam = soup_soap_parameter_get_first_child_by_name(param, "phoneList");
if(subparam) {
g_hash_table_insert (simple_fields, "default_phone", soup_soap_parameter_get_property(subparam, "default"));
type = soup_soap_parameter_get_property (temp, "type");
value = soup_soap_parameter_get_string_value (temp);
switch (*type) {
- case 'O' :
+ case 'O' :
key = "phone_Office";
break;
case 'H' :
value = soup_soap_parameter_get_string_value (temp);
if (value)
g_hash_table_insert (simple_fields, "birthday", value);
-
+
}
temp = soup_soap_parameter_get_first_child_by_name (subparam, "website");
if(temp) {
if(value)
g_hash_table_insert (simple_fields, "title", value);
}
-
+
}
subparam = soup_soap_parameter_get_first_child_by_name (param, "addressList");
address = g_new0 (PostalAddress, 1);
set_postal_address_from_soap_parameter (address, temp);
value = soup_soap_parameter_get_property(temp, "type");
-
+
if (value && value[0] == 'H')
add = "Home";
else if (value && value[0] == 'O')
add = "Office";
- else
+ else
add = "Other";
- if (value)
+ if (value)
g_hash_table_insert (item->priv->addresses, (char*)add, address);
else
free_postal_address (address);
g_free (value);
}
-
+
}
-
+
}
-static void
+static void
set_group_fields_from_soap_parameter (EGwItem *item, SoupSoapParameter *param)
{
char *value;
SoupSoapParameter *subparam, *temp, *second_level_child;
GHashTable *simple_fields;
-
+
if (strcmp (soup_soap_parameter_get_name (param), "item") != 0) {
g_warning (G_STRLOC ": Invalid SOAP parameter %s", soup_soap_parameter_get_name (param));
return;
/* set name as the ful name also , as it is needed for searching*/
value = g_hash_table_lookup (simple_fields, "name");
- if (value)
+ if (value)
item->priv->full_name->first_name = g_strdup (value);
subparam = soup_soap_parameter_get_first_child_by_name (param, "members");
char *id, *email;
for ( temp = soup_soap_parameter_get_first_child (subparam); temp != NULL; temp = soup_soap_parameter_get_next_child (temp)) {
id = email = NULL;
- second_level_child = soup_soap_parameter_get_first_child_by_name (temp, "email");
+ second_level_child = soup_soap_parameter_get_first_child_by_name (temp, "email");
if (second_level_child)
email = soup_soap_parameter_get_string_value (second_level_child);
second_level_child = soup_soap_parameter_get_first_child_by_name (temp, "id");
if (second_level_child)
id = soup_soap_parameter_get_string_value (second_level_child);
-
+
if (id && email) {
EGroupMember *member = g_new0 (EGroupMember, 1);
member->id = id;
member->email = email;
second_level_child = soup_soap_parameter_get_first_child_by_name (temp, "name");
- member->name = soup_soap_parameter_get_string_value (second_level_child);
+ member->name = soup_soap_parameter_get_string_value (second_level_child);
item->priv->member_list = g_list_append (item->priv->member_list, member);
}
-
-
+
+
}
}
-
-
+
+
}
-static void
+static void
set_resource_fields_from_soap_parameter (EGwItem *item, SoupSoapParameter *param)
{
char *value;
SoupSoapParameter *subparam;
GHashTable *simple_fields;
-
+
if (strcmp (soup_soap_parameter_get_name (param), "item") != 0) {
g_warning (G_STRLOC ": Invalid SOAP parameter %s", soup_soap_parameter_get_name (param));
return;
/* set name as the ful name also , as it is needed for searching*/
value = g_hash_table_lookup (simple_fields, "name");
- if (value)
+ if (value)
item->priv->full_name->first_name = g_strdup (value);
-
+
subparam = soup_soap_parameter_get_first_child_by_name (param, "phone");
if(subparam) {
value = soup_soap_parameter_get_string_value (subparam);
if(value)
item->priv->email_list = g_list_append (item->priv->email_list, value);
}
-
+
}
-static void
+static void
set_organization_fields_from_soap_parameter (EGwItem *item, SoupSoapParameter *param)
{
SoupSoapParameter *subparam;
PostalAddress *address;
GHashTable *simple_fields;
-
+
if (strcmp (soup_soap_parameter_get_name (param), "item") != 0) {
g_warning (G_STRLOC ": Invalid SOAP parameter %s", soup_soap_parameter_get_name (param));
return;
/* set name as the ful name also , as it is needed for searching*/
value = g_hash_table_lookup (simple_fields, "name");
- if (value)
+ if (value)
item->priv->full_name->first_name = g_strdup (value);
subparam = soup_soap_parameter_get_first_child_by_name (param, "phone");
address = g_new0 (PostalAddress, 1);
set_postal_address_from_soap_parameter (address, subparam);
g_hash_table_insert (item->priv->addresses, "Office", address);
-
+
}
subparam = soup_soap_parameter_get_first_child_by_name (param, "website");
}
-static void
+static void
append_postal_address_to_soap_message (SoupSoapMessage *msg, PostalAddress *address, char *address_type)
{
soup_soap_message_start_element (msg, "address", NULL, NULL);
append_common_addressbook_item_fields_to_soap_message (GHashTable *simple_fields, GList *category_list, SoupSoapMessage *msg)
{
char * value;
-
+
value = g_hash_table_lookup (simple_fields, "name");
if (value)
e_gw_message_write_string_parameter (msg, "name", NULL, value);
soup_soap_message_start_element (msg, "categories", NULL, NULL);
- if (category_list && category_list->data)
+ if (category_list && category_list->data)
soup_soap_message_add_attribute (msg, "types:primary", category_list->data, NULL, NULL);
- for (; category_list != NULL; category_list = g_list_next (category_list))
+ for (; category_list != NULL; category_list = g_list_next (category_list))
if (category_list->data) {
e_gw_message_write_string_parameter (msg, "category", NULL, category_list->data);
}
soup_soap_message_end_element (msg);
value = g_hash_table_lookup (simple_fields, "comment");
- if(value)
+ if(value)
e_gw_message_write_string_parameter (msg, "comment", NULL, value);
}
-static void
+static void
append_full_name_to_soap_message (FullName *full_name, char *display_name, SoupSoapMessage *msg)
{
g_return_if_fail (full_name != NULL);
}
-static void
+static void
append_email_list_soap_message (GList *email_list, SoupSoapMessage *msg)
{
g_return_if_fail (email_list != NULL);
soup_soap_message_start_element (msg, "emailList", NULL, NULL);
soup_soap_message_add_attribute (msg, "primary", email_list->data, NULL, NULL);
- for (; email_list != NULL; email_list = g_list_next (email_list))
- if(email_list->data)
+ for (; email_list != NULL; email_list = g_list_next (email_list))
+ if(email_list->data)
e_gw_message_write_string_parameter (msg, "email", NULL, email_list->data);
soup_soap_message_end_element (msg);
}
-static void
+static void
append_im_list_to_soap_message (GList *ims, SoupSoapMessage *msg)
{
IMAddress *address;
soup_soap_message_start_element (msg, "phoneList", NULL, NULL);
value = g_hash_table_lookup (simple_fields, "default_phone");
- if (value)
+ if (value)
soup_soap_message_add_attribute (msg, "default", value, NULL, NULL);
value = g_hash_table_lookup (simple_fields, "phone_Office");
- if (value)
+ if (value)
e_gw_message_write_string_parameter_with_attribute (msg, "phone", NULL, value, "type", "Office");
value = g_hash_table_lookup (simple_fields, "phone_Home");
- if (value)
+ if (value)
e_gw_message_write_string_parameter_with_attribute (msg, "phone", NULL, value, "type", "Home");
value = g_hash_table_lookup (simple_fields, "phone_Pager");
- if (value)
+ if (value)
e_gw_message_write_string_parameter_with_attribute (msg, "phone", NULL, value, "type", "Pager");
value = g_hash_table_lookup (simple_fields, "phone_Mobile");
- if (value)
+ if (value)
e_gw_message_write_string_parameter_with_attribute (msg, "phone", NULL, value, "type", "Mobile");
value = g_hash_table_lookup (simple_fields, "phone_Fax");
- if (value)
+ if (value)
e_gw_message_write_string_parameter_with_attribute (msg, "phone", NULL, value, "type", "Fax");
soup_soap_message_end_element (msg);
}
-static void
+static void
append_office_info_to_soap_message (GHashTable *simple_fields, SoupSoapMessage *msg)
{
char *value;
soup_soap_message_start_element (msg, "officeInfo", NULL, NULL);
value = g_hash_table_lookup (simple_fields, "organization_id");
org_name = g_hash_table_lookup (simple_fields, "organization");
- if (value && org_name)
+ if (value && org_name)
e_gw_message_write_string_parameter_with_attribute (msg, "organization", NULL, org_name, "uid", value);
else if(org_name)
e_gw_message_write_string_parameter (msg, "organization", NULL, org_name);
value = g_hash_table_lookup (simple_fields, "department");
if (value)
e_gw_message_write_string_parameter (msg, "department", NULL, value);
-
+
value = g_hash_table_lookup (simple_fields, "title");
if (value)
e_gw_message_write_string_parameter (msg, "title", NULL, value);
}
-static void
+static void
append_personal_info_to_soap_message (GHashTable *simple_fields, SoupSoapMessage *msg)
{
char *value;
g_return_if_fail (simple_fields != NULL);
-
+
soup_soap_message_start_element (msg, "personalInfo", NULL, NULL);
value = g_hash_table_lookup (simple_fields, "birthday");
if(value)
value = g_hash_table_lookup (simple_fields, "website");
if(value)
e_gw_message_write_string_parameter (msg, "website",NULL, value);
-
+
soup_soap_message_end_element (msg);
}
GHashTable *simple_fields;
FullName *full_name;
PostalAddress *postal_address;
-
+
simple_fields = item->priv->simple_fields;
value = g_hash_table_lookup (simple_fields, "id");
if (value)
e_gw_message_write_string_parameter (msg, "id", NULL, value);
-
+
if (item->priv->container)
e_gw_message_write_string_parameter (msg, "container", NULL, item->priv->container);
append_common_addressbook_item_fields_to_soap_message (simple_fields, item->priv->category_list, msg);
value = g_hash_table_lookup (simple_fields, "name");
-
+
full_name = item->priv->full_name;
-
+
if (full_name)
- append_full_name_to_soap_message (full_name, value, msg);
-
+ append_full_name_to_soap_message (full_name, value, msg);
+
if (item->priv->email_list)
append_email_list_soap_message (item->priv->email_list, msg);
-
+
if (item->priv->im_list)
append_im_list_to_soap_message (item->priv->im_list, msg);
-
+
if (simple_fields)
append_phone_list_to_soap_message (simple_fields, msg);
-
+
soup_soap_message_start_element (msg, "addressList", NULL, NULL);
postal_address = g_hash_table_lookup (item->priv->addresses, "Home");
if (postal_address)
}
-static void
+static void
append_group_fields_to_soap_message (EGwItem *item, SoupSoapMessage *msg)
{
GHashTable *simple_fields;
}
soup_soap_message_end_element (msg);
-
+
}
EGwItem *
SoupSoapParameter *subparameter, *child, *category_param, *attachment_param;
gboolean is_group_item = TRUE;
GList *user_email = NULL;
-
+
g_return_val_if_fail (param != NULL, NULL);
if (strcmp (soup_soap_parameter_get_name (param), "item") != 0) {
set_contact_fields_from_soap_parameter (item, param);
g_free (item_type);
return item;
- }
+ }
else if (!g_ascii_strcasecmp (item_type,"SharedNotification"))
item->priv->item_type = E_GW_ITEM_TYPE_NOTIFICATION ;
g_free (item_type);
return item;
}
-
+
else if (!g_ascii_strcasecmp (item_type, "Resource")) {
-
+
item->priv->item_type = E_GW_ITEM_TYPE_CONTACT;
set_resource_fields_from_soap_parameter (item, param);
g_free (item_type);
return item;
}
-
+
else if (!g_ascii_strcasecmp (item_type, "Group")) {
item->priv->item_type = E_GW_ITEM_TYPE_GROUP;
set_group_fields_from_soap_parameter (item, param);
g_free (item_type);
return item;
}
-
+
else {
g_free (item_type);
g_object_unref (item);
subparameter = soup_soap_parameter_get_first_child_by_name (changes, "update");
}
else subparameter = param; /* The item is a complete one, not a delta */
-
+
/* now add all properties to the private structure */
for (child = soup_soap_parameter_get_first_child (subparameter);
child != NULL;
item->priv->is_allday_event = TRUE;
else
item->priv->is_allday_event = FALSE;
- g_free (value);
+ g_free (value);
} else if (!g_ascii_strcasecmp (name, "status")) {
SoupSoapParameter *status_param;
item->priv->self_status |= E_GW_ITEM_STAT_DECLINED;
else if (!strcmp (status_name, "deleted"))
item->priv->self_status |= E_GW_ITEM_STAT_DELETED;
- else if (!strcmp (status_name, "read"))
+ else if (!strcmp (status_name, "read"))
item->priv->self_status |= E_GW_ITEM_STAT_READ;
else if (!strcmp (status_name, "opened"))
item->priv->self_status |= E_GW_ITEM_STAT_OPENED;
}
tp = soup_soap_parameter_get_first_child_by_name (child, "sendoptions");
- if (tp)
- set_sendoptions_from_soap_parameter (item, tp);
+ if (tp)
+ set_sendoptions_from_soap_parameter (item, tp);
tp = soup_soap_parameter_get_first_child_by_name (child, "from");
if (tp && is_group_item) {
EGwItemOrganizer *organizer = g_new0 (EGwItemOrganizer, 1);
subparam = soup_soap_parameter_get_first_child_by_name (tp, "displayName");
- if (subparam)
+ if (subparam)
organizer->display_name = soup_soap_parameter_get_string_value (subparam);
subparam = soup_soap_parameter_get_first_child_by_name (tp, "email");
- if (subparam)
+ if (subparam)
organizer->email = soup_soap_parameter_get_string_value (subparam);
e_gw_item_set_organizer (item, organizer);
}
if (subparam)
value = soup_soap_parameter_get_string_value (subparam);
if (value)
- item->priv->expires = g_strdup (value);
+ item->priv->expires = g_strdup (value);
g_free (value), value = NULL;
subparam = soup_soap_parameter_get_first_child_by_name (child, "delayDeliveryUntil");
g_free (value), value = NULL;
} else if (!g_ascii_strcasecmp (name, "dueDate")) {
- char *formatted_date;
+ char *formatted_date;
value = soup_soap_parameter_get_string_value (child);
formatted_date = e_gw_connection_format_date_string (value);
e_gw_item_set_due_date (item, formatted_date);
g_free (formatted_date);
} else if (!g_ascii_strcasecmp (name, "endDate") || !g_ascii_strcasecmp (name, "endDay")) {
- char *formatted_date;
+ char *formatted_date;
value = soup_soap_parameter_get_string_value (child);
formatted_date = e_gw_connection_format_date_string (value);
e_gw_item_set_end_date (item, formatted_date);
g_free (value);
- g_free (formatted_date);
+ g_free (formatted_date);
} else if (!g_ascii_strcasecmp (name, "to")) {
char *to ;
} else if (!g_ascii_strcasecmp (name, "iCalId"))
item->priv->icalid = soup_soap_parameter_get_string_value (child);
- else if (!g_ascii_strcasecmp (name, "categories")) {
+ else if (!g_ascii_strcasecmp (name, "categories")) {
for (category_param = soup_soap_parameter_get_first_child_by_name (child, "category");
category_param != NULL;
category_param = soup_soap_parameter_get_next_child_by_name (category_param, "category")) {
}
}
- } else if (!g_ascii_strcasecmp (name, "id"))
+ } else if (!g_ascii_strcasecmp (name, "id"))
item->priv->id = soup_soap_parameter_get_string_value (child);
else if (!g_ascii_strcasecmp (name, "recurrenceKey"))
item->priv->recurrence_key = soup_soap_parameter_get_int_value (child);
part = soup_soap_parameter_get_first_child_by_name (child, "part");
msg = soup_soap_parameter_get_string_value (part);
- length = soup_soap_parameter_get_property (part, "length");
+ length = soup_soap_parameter_get_property (part, "length");
if (msg && length) {
len = atoi (length);
item->priv->message = g_base64_decode (msg, &len);
if (!(item->priv->message)) {
item->priv->msg_body_id = soup_soap_parameter_get_property (part, "id") ;
- }
+ }
item->priv->content_type = soup_soap_parameter_get_property (part, "contentType") ;
- }
+ }
g_free (length);
g_free (msg);
else if (!g_ascii_strcasecmp (name, "source")) {
value = soup_soap_parameter_get_string_value (child);
if (!strcmp (value, "personal")) {
- if (item->priv->item_type == E_GW_ITEM_TYPE_TASK ||
+ if (item->priv->item_type == E_GW_ITEM_TYPE_TASK ||
item->priv->item_type == E_GW_ITEM_TYPE_APPOINTMENT)
is_group_item = FALSE;
}
return item->priv->completed_date;
}
-void
+void
e_gw_item_set_completed_date (EGwItem *item, const char *new_date)
{
g_return_if_fail (E_IS_GW_ITEM (item));
item->priv->completed = new_completed;
}
-gboolean
+gboolean
e_gw_item_get_is_allday_event (EGwItem *item)
{
g_return_val_if_fail (E_IS_GW_ITEM (item), FALSE);
return item->priv->is_allday_event;
}
-void
+void
e_gw_item_set_is_allday_event (EGwItem *item, gboolean allday_event)
{
g_return_if_fail (E_IS_GW_ITEM (item));
void
e_gw_item_set_organizer (EGwItem *item, EGwItemOrganizer *organizer)
{
- /* free organizer */
+ /* free organizer */
g_free (item->priv->organizer);
item->priv->organizer = organizer;
}
}
-void
+void
e_gw_item_set_to (EGwItem *item, const char *to)
{
g_return_if_fail (E_IS_GW_ITEM (item));
- item->priv->to = g_strdup (to) ;
+ item->priv->to = g_strdup (to) ;
}
const char *
return item->priv->autodelete;
}
-void
+void
e_gw_item_set_notify_completed (EGwItem *item, EGwItemReturnNotify notify)
{
g_return_if_fail (E_IS_GW_ITEM (item));
item->priv->notify_completed = notify;
}
-EGwItemReturnNotify
+EGwItemReturnNotify
e_gw_item_get_notify_completed (EGwItem *item)
{
g_return_val_if_fail (E_IS_GW_ITEM (item), FALSE);
return item->priv->notify_completed;
}
-void
+void
e_gw_item_set_notify_accepted (EGwItem *item, EGwItemReturnNotify notify)
{
g_return_if_fail (E_IS_GW_ITEM (item));
item->priv->notify_accepted = notify;
}
-EGwItemReturnNotify
+EGwItemReturnNotify
e_gw_item_get_notify_accepted (EGwItem *item)
{
g_return_val_if_fail (E_IS_GW_ITEM (item), FALSE);
return item->priv->notify_accepted;
}
-void
+void
e_gw_item_set_notify_declined (EGwItem *item, EGwItemReturnNotify notify)
{
g_return_if_fail (E_IS_GW_ITEM (item));
item->priv->notify_declined = notify;
}
-EGwItemReturnNotify
+EGwItemReturnNotify
e_gw_item_get_notify_declined (EGwItem *item)
{
g_return_val_if_fail (E_IS_GW_ITEM (item), FALSE);
return item->priv->notify_declined;
}
-void
+void
e_gw_item_set_notify_opened (EGwItem *item, EGwItemReturnNotify notify)
{
g_return_if_fail (E_IS_GW_ITEM (item));
item->priv->notify_opened = notify;
}
-EGwItemReturnNotify
+EGwItemReturnNotify
e_gw_item_get_notify_opened (EGwItem *item)
{
g_return_val_if_fail (E_IS_GW_ITEM (item), FALSE);
return item->priv->notify_opened;
}
-void
+void
e_gw_item_set_notify_deleted (EGwItem *item, EGwItemReturnNotify notify)
{
g_return_if_fail (E_IS_GW_ITEM (item));
item->priv->notify_deleted = notify;
}
-EGwItemReturnNotify
+EGwItemReturnNotify
e_gw_item_get_notify_deleted (EGwItem *item)
{
g_return_val_if_fail (E_IS_GW_ITEM (item), FALSE);
case E_GW_ITEM_NOTIFY_NONE:
e_gw_message_write_string_parameter (msg, "mail", NULL, "0");
}
-
- soup_soap_message_end_element (msg);
+
+ soup_soap_message_end_element (msg);
}
-static void
-append_gw_item_options (SoupSoapMessage *msg, EGwItem *item)
+static void
+append_gw_item_options (SoupSoapMessage *msg, EGwItem *item)
{
EGwItemPrivate *priv;
priv = item->priv;
-
+
soup_soap_message_start_element (msg, "options", NULL, NULL);
-
+
/* Priority */
e_gw_message_write_string_parameter (msg, "priority", NULL, priv->priority ? priv->priority : "0");
/* Expiration date */
e_gw_message_write_string_parameter (msg, "expires", NULL, priv->expires ? priv->expires : "0");
-
+
/* Delay delivery */
e_gw_message_write_string_parameter (msg, "delayDeliveryUntil", NULL, priv->delay_until ? priv->delay_until : "0");
priv = item->priv;
organizer = priv->organizer;
recipient_list = priv->recipient_list;
-
+
/* start distribution element */
soup_soap_message_start_element (msg, "distribution", NULL, NULL);
if (organizer) {
soup_soap_message_start_element (msg, "from", NULL, NULL);
e_gw_message_write_string_parameter (msg, "displayName", NULL,
organizer->display_name ? organizer->display_name : "");
- e_gw_message_write_string_parameter (msg, "email", NULL,
+ e_gw_message_write_string_parameter (msg, "email", NULL,
organizer->email ? organizer->email : "");
-
+
soup_soap_message_end_element (msg);
}
/* start recipients */
char *status = NULL;
EGwItemRecipient *recipient = (EGwItemRecipient *) rl->data;
-
+
soup_soap_message_start_element (msg, "recipient", NULL, NULL);
e_gw_message_write_string_parameter (msg, "displayName", NULL, recipient->display_name ? recipient->display_name : "");
e_gw_message_write_string_parameter (msg, "email", NULL, recipient->email ? recipient->email : "");
dist_type = "CC";
else if (recipient->type == E_GW_ITEM_RECIPIENT_BC)
dist_type = "BC";
- else
+ else
dist_type ="";
e_gw_message_write_string_parameter (msg, "distType", NULL, dist_type);
/* add recip_status */
status = "";
if (status && *status)
e_gw_message_write_string_parameter (msg, "recipientStatus", NULL, status);
-
- soup_soap_message_end_element (msg);
+
+ soup_soap_message_end_element (msg);
}
-
+
soup_soap_message_end_element (msg);
-
- if (priv->set_sendoptions) {
+
+ if (priv->set_sendoptions) {
soup_soap_message_start_element (msg, "sendoptions", NULL, NULL);
-
+
soup_soap_message_start_element (msg, "requestReply", NULL, NULL);
if (priv->reply_request_set) {
-
- if (priv->reply_within)
+
+ if (priv->reply_within)
e_gw_message_write_string_parameter (msg, "byDate", NULL, priv->reply_within);
- else
+ else
e_gw_message_write_string_parameter (msg, "whenConvenient", NULL, "1");
-
+
} else
soup_soap_message_write_string (msg, "0");
soup_soap_message_end_element (msg);
soup_soap_message_start_element (msg, "statusTracking", NULL, NULL);
-
+
soup_soap_message_add_attribute (msg, "autoDelete", priv->autodelete ? "1" : "0", NULL, NULL);
-
+
switch (priv->track_info) {
case E_GW_ITEM_DELIVERED : soup_soap_message_write_string (msg, "Delivered");
break;
break;
default: soup_soap_message_write_string (msg, "None");
}
-
+
soup_soap_message_end_element (msg);
-
+
soup_soap_message_start_element (msg, "notification", NULL, NULL);
switch (priv->item_type) {
-
+
case E_GW_ITEM_TYPE_TASK :
add_return_notification (msg, "completed", priv->notify_completed);
-
+
case E_GW_ITEM_TYPE_APPOINTMENT:
add_return_notification (msg, "accepted", priv->notify_accepted);
add_return_notification (msg, "declined", priv->notify_declined);
add_return_notification (msg, "opened", priv->notify_opened);
break;
-
+
default:
add_return_notification (msg, "opened", priv->notify_opened);
add_return_notification (msg, "deleted", priv->notify_deleted);
if (attachment->size > 0) {
size = g_strdup_printf ("%d", attachment->size) ;
e_gw_message_write_string_parameter (msg, "size", NULL, size) ;
- }
+ }
/*date*/
- if (attachment->date)
- e_gw_message_write_string_parameter (msg, "date", NULL, attachment->date) ;
+ if (attachment->date)
+ e_gw_message_write_string_parameter (msg, "date", NULL, attachment->date) ;
/*data*/
if (attachment->size > 0) {
soup_soap_message_write_string (msg, attachment->data) ;
soup_soap_message_end_element (msg) ;
}
-
+
soup_soap_message_end_element (msg) ;
g_free (size) ;
}
-static void
+static void
e_gw_item_set_calendar_item_elements (EGwItem *item, SoupSoapMessage *msg)
{
EGwItemPrivate *priv = item->priv;
soup_soap_message_start_element (msg, "message", NULL, NULL);
if (priv->message) {
char *str;
-
+
str = g_base64_encode (priv->message, strlen (priv->message));
dtstring = g_strdup_printf ("%d", (int)strlen (str));
soup_soap_message_add_attribute (msg, "length", dtstring, NULL, NULL);
soup_soap_message_end_element (msg);
if (priv->start_date) {
- e_gw_message_write_string_parameter (msg, "startDate", NULL,
+ e_gw_message_write_string_parameter (msg, "startDate", NULL,
priv->start_date);
}
if (priv->category_list) {
soup_soap_message_start_element (msg, "categories", NULL, NULL);
-
- if (priv->category_list && priv->category_list->data)
+
+ if (priv->category_list && priv->category_list->data)
soup_soap_message_add_attribute (msg, "types:primary", priv->category_list->data, NULL, NULL);
-
- for (; priv->category_list != NULL; priv->category_list = g_list_next (priv->category_list))
+
+ for (; priv->category_list != NULL; priv->category_list = g_list_next (priv->category_list))
if (priv->category_list->data) {
e_gw_message_write_string_parameter (msg, "category", NULL, priv->category_list->data);
}
soup_soap_message_end_element (msg);
}
-
+
/* handle recurrences */
if (item->priv->rrule) {
EGwItemRecurrenceRule *rrule = item->priv->rrule;
soup_soap_message_start_element (msg, "rrule", NULL, NULL);
-
- e_gw_message_write_string_parameter (msg, "frequency", NULL, rrule->frequency);
- e_gw_message_write_int_parameter (msg, "interval", NULL, rrule->interval);
+
+ e_gw_message_write_string_parameter (msg, "frequency", NULL, rrule->frequency);
+ e_gw_message_write_int_parameter (msg, "interval", NULL, rrule->interval);
if (rrule->until)
e_gw_message_write_string_parameter (msg, "until", NULL, rrule->until);
/* expand into a sequence of 'day' here */
for (i = 0; i < max_elements && rrule->by_day [i] != E_GW_ITEM_RECUR_END_MARKER; i++) {
/*TODO occurence attribute */
- e_gw_message_write_string_parameter (msg, "day", NULL,
+ e_gw_message_write_string_parameter (msg, "day", NULL,
e_gw_recur_get_day_of_week (rrule->by_day [i]));
}
soup_soap_message_end_element (msg);
if (rrule->by_month_day) {
int i, max_elements;
char month_day[3];
-
+
soup_soap_message_start_element (msg, "byMonthDay", NULL, NULL);
max_elements = sizeof (rrule->by_month_day) / sizeof (rrule->by_month_day [i]);
/* expand into a sequence of 'day' here */
/*TODO occurence attribute */
g_sprintf (month_day, "%d", rrule->by_month_day [i]);
e_gw_message_write_string_parameter (msg, "day", NULL, month_day);
-
+
}
soup_soap_message_end_element (msg);
}
/*TODO occurence attribute */
g_sprintf (year_day, "%d", rrule->by_year_day [i]);
e_gw_message_write_string_parameter (msg, "day", NULL, year_day);
-
+
}
soup_soap_message_end_element (msg);
}
/*TODO occurence attribute */
g_sprintf (month, "%d", rrule->by_month [i]);
e_gw_message_write_string_parameter (msg, "month", NULL, month);
-
+
}
soup_soap_message_end_element (msg);
}
soup_soap_message_end_element (msg);
-
+
} else if (item->priv->recurrence_dates) {
GSList *date;
soup_soap_message_start_element (msg, "rdate", NULL, NULL);
}
soup_soap_message_end_element (msg);
}
-
+
if (item->priv->exdate_list) {
GSList *date;
soup_soap_message_start_element (msg, "exdate", NULL, NULL);
}
soup_soap_message_end_element (msg);
}
- /*xxx - byday, bymonthday and byyearday not handled - FIXME */
+ /*xxx - byday, bymonthday and byyearday not handled - FIXME */
/*attachments*/
if (priv->attach_list) {
for (al = priv->attach_list ; al != NULL ; al = al->next) {
EGwItemAttachment *attachment = (EGwItemAttachment *)al->data ;
add_attachment_to_soap_message (attachment, msg) ;
-
+
}
soup_soap_message_end_element (msg) ;
}
if (priv->security)
e_gw_message_write_string_parameter (msg, "security", NULL, priv->security);
-
+
/*The subject*/
if (priv->subject)
e_gw_message_write_string_parameter (msg, "subject", NULL, priv->subject) ;
/*distribution*/
e_gw_item_add_distribution_to_soap_message(item, msg) ;
-
+
if (priv->set_sendoptions) {
/* item options */
append_gw_item_options (msg, item);
e_gw_message_write_string_parameter (msg, "container", NULL, item->priv->container);
if (item->priv->source)
e_gw_message_write_string_parameter (msg, "source", NULL, item->priv->source);
-
+
/*message*/
soup_soap_message_start_element (msg, "message", NULL, NULL);
if (priv->message) {
g_free (alarm);
}
e_gw_message_write_string_parameter (msg, "place", NULL, priv->place ? priv->place : "");
-
+
break;
case E_GW_ITEM_TYPE_TASK :
break;
case E_GW_ITEM_TYPE_NOTE:
soup_soap_message_add_attribute (msg, "type", "Note", "xsi", NULL);
-
+
e_gw_item_set_calendar_item_elements (item, msg);
break;
case E_GW_ITEM_TYPE_CONTACT :
case E_GW_ITEM_TYPE_GROUP :
soup_soap_message_add_attribute (msg, "type", "Group", "xsi", NULL);
append_group_fields_to_soap_message (item, msg);
- soup_soap_message_end_element(msg);
+ soup_soap_message_end_element(msg);
return TRUE;
case E_GW_ITEM_TYPE_ORGANISATION :
- soup_soap_message_add_attribute (msg, "type", "Organization", "xsi", NULL);
+ soup_soap_message_add_attribute (msg, "type", "Organization", "xsi", NULL);
append_contact_fields_to_soap_message (item, msg);
- soup_soap_message_end_element(msg);
+ soup_soap_message_end_element(msg);
return TRUE;
case E_GW_ITEM_TYPE_CATEGORY :
soup_soap_message_add_attribute (msg, "type", "Category", "xsi", NULL);
e_gw_message_write_string_parameter (msg, "name", NULL, item->priv->category_name);
- soup_soap_message_end_element(msg);
+ soup_soap_message_end_element(msg);
return TRUE;
default :
g_warning (G_STRLOC ": Unknown type for item");
soup_soap_message_start_element (msg, "delete", NULL, NULL);
changes = priv->deletions;
break;
-
+
}
if (!changes)
return;
append_common_addressbook_item_fields_to_soap_message (changes, list, msg);
full_name = g_hash_table_lookup (changes, "full_name");
value = g_hash_table_lookup (changes, "name");
- if (full_name)
+ if (full_name)
append_full_name_to_soap_message (full_name, value, msg);
list = g_hash_table_lookup (changes, "email");
if (list)
if (postal_address)
append_postal_address_to_soap_message (msg, postal_address, "Office");
soup_soap_message_end_element (msg);
-
+
append_office_info_to_soap_message (changes, msg);
append_personal_info_to_soap_message (changes, msg);
break;
}
if (g_hash_table_lookup (changes, "categories")){
- GList *list;
+ GList *list;
list = g_hash_table_lookup (changes, "categories");
soup_soap_message_start_element (msg, "categories", NULL, NULL);
- if (list != NULL && list->data)
+ if (list != NULL && list->data)
soup_soap_message_add_attribute (msg, "types:primary",list->data, NULL, NULL);
- for (; list != NULL; list = g_list_next (list))
+ for (; list != NULL; list = g_list_next (list))
if (list->data) {
e_gw_message_write_string_parameter (msg, "category", NULL, list->data);
}
e_gw_message_write_string_parameter (msg, "subject", NULL, priv->subject ? priv->subject : "");
if (g_hash_table_lookup (changes, "start_date")) {
if (priv->start_date) {
- e_gw_message_write_string_parameter (msg, "startDate", NULL, priv->start_date);
+ e_gw_message_write_string_parameter (msg, "startDate", NULL, priv->start_date);
}
}
if (g_hash_table_lookup (changes, "end_date")) {
}
-gboolean
+gboolean
e_gw_item_append_changes_to_soap_message (EGwItem *item, SoupSoapMessage *msg)
{
EGwItemPrivate *priv;
append_contact_changes_to_soap_message (item, msg, E_GW_ITEM_CHANGE_TYPE_ADD);
append_contact_changes_to_soap_message (item, msg, E_GW_ITEM_CHANGE_TYPE_UPDATE);
append_contact_changes_to_soap_message (item, msg, E_GW_ITEM_CHANGE_TYPE_DELETE);
- soup_soap_message_end_element(msg);
+ soup_soap_message_end_element(msg);
return TRUE;
case E_GW_ITEM_TYPE_GROUP :
soup_soap_message_start_element (msg, "update", NULL, NULL);
if (value)
e_gw_message_write_string_parameter (msg, "name", NULL, value);
soup_soap_message_end_element (msg);
- soup_soap_message_end_element(msg);
+ soup_soap_message_end_element(msg);
return TRUE;
case E_GW_ITEM_TYPE_APPOINTMENT:
case E_GW_ITEM_TYPE_TASK :
append_event_changes_to_soap_message (item, msg, E_GW_ITEM_CHANGE_TYPE_ADD);
append_event_changes_to_soap_message (item, msg, E_GW_ITEM_CHANGE_TYPE_UPDATE);
append_event_changes_to_soap_message (item, msg, E_GW_ITEM_CHANGE_TYPE_DELETE);
- soup_soap_message_end_element(msg);
+ soup_soap_message_end_element(msg);
return TRUE;
default :
g_warning (G_STRLOC ": Unknown type for item");
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
E_GW_ITEM_TYPE_ORGANISATION,
E_GW_ITEM_TYPE_RESOURCE,
E_GW_ITEM_TYPE_CATEGORY,
- E_GW_ITEM_TYPE_NOTIFICATION,
+ E_GW_ITEM_TYPE_NOTIFICATION,
E_GW_ITEM_TYPE_NOTE,
E_GW_ITEM_TYPE_UNKNOWN
gboolean e_gw_item_get_completed (EGwItem *item);
void e_gw_item_set_completed (EGwItem *item, gboolean new_completed);
gboolean e_gw_item_get_is_allday_event (EGwItem *item);
-void e_gw_item_set_is_allday_event (EGwItem *item, gboolean is_allday);
+void e_gw_item_set_is_allday_event (EGwItem *item, gboolean is_allday);
char* e_gw_item_get_field_value (EGwItem *item, char *field_name);
void e_gw_item_set_field_value (EGwItem *item, char *field_name, char* field_value);
GList* e_gw_item_get_email_list (EGwItem *item);
#define E_GW_ITEM_ACCEPT_LEVEL_BUSY "Busy"
#define E_GW_ITEM_ACCEPT_LEVEL_OUT_OF_OFFICE "OutOfOffice"
-#define E_GW_ITEM_ACCEPT_LEVEL_FREE "Free"
+#define E_GW_ITEM_ACCEPT_LEVEL_FREE "Free"
const char *e_gw_item_get_accept_level (EGwItem *item);
void e_gw_item_set_accept_level (EGwItem *item, const char *new_level);
void e_gw_item_set_rrule (EGwItem *item, EGwItemRecurrenceRule *rrule);
EGwItemRecurrenceRule *e_gw_item_get_rrule (EGwItem *item);
-
+
int e_gw_item_get_recurrence_key (EGwItem *item);
void e_gw_item_set_recurrence_key (EGwItem *item, int recurrence_key);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
soup_soap_message_end_element (msg);
}
-void
+void
e_gw_message_write_string_parameter_with_attribute (SoupSoapMessage *msg,
const char *name,
const char *prefix,
- const char *value,
+ const char *value,
const char *attribute_name,
const char *attribute_value)
{
gchar *body;
gchar *begin = NULL;
gchar *end = NULL;
-
+
body = g_strndup (SOUP_MESSAGE (msg)->request.body, SOUP_MESSAGE (msg)->request.length);
begin = g_strrstr (body, "<types:password>");
- if (begin)
+ if (begin)
begin = begin + strlen ("<types:password>");
end = g_strrstr (body , "</types:password>");
if (begin && end) {
gchar *tmp;
for (tmp = begin; tmp < end; tmp++)
*tmp='X';
-
+
}
fputc ('\n', stdout);
fwrite (body, 1, SOUP_MESSAGE (msg)->request.length, stdout);
- fputc ('\n', stdout);
+ fputc ('\n', stdout);
g_free (body);
}
- else {
-
+ else {
+
/* print request's body */
fputc ('\n', stdout);
fwrite (SOUP_MESSAGE (msg)->request.body, 1, SOUP_MESSAGE (msg)->request.length, stdout);
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
void e_gw_message_write_string_parameter_with_attribute (SoupSoapMessage *msg,
const char *name,
const char *prefix,
- const char *value,
+ const char *value,
const char *attrubute_name,
const char *attribute_value);
void e_gw_message_write_base64_parameter (SoupSoapMessage *msg,
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Sankar P <psankar@novell.com>
* Shreyas Srinivasan <sshreyas@novell.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#include "e-gw-proxy.h"
#include "e-gw-message.h"
-void
+void
e_gw_proxy_construct_proxy_access_list (SoupSoapParameter *param, GList **proxy_list)
{
/* parse the response and create the individual proxy accounts */
if (type_param) {
value = soup_soap_parameter_get_string_value (type_param);
aclInstance->uniqueid = g_strdup_printf ("%s", value);
- } else
+ } else
aclInstance->uniqueid = NULL;
type_param = soup_soap_parameter_get_first_child_by_name (subparam, "mail");
value = NULL;
if (type_param) {
- individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
aclInstance->permissions |= E_GW_PROXY_MAIL_READ;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
aclInstance->permissions |= E_GW_PROXY_MAIL_WRITE;
value = NULL;
type_param = soup_soap_parameter_get_first_child_by_name (subparam, "appointment");
if (type_param) {
- individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
aclInstance->permissions |= E_GW_PROXY_APPOINTMENT_READ;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
aclInstance->permissions |= E_GW_PROXY_APPOINTMENT_WRITE;
value = NULL;
type_param = soup_soap_parameter_get_first_child_by_name (subparam, "task");
if (type_param) {
- individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
aclInstance->permissions |= E_GW_PROXY_TASK_READ;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
aclInstance->permissions |= E_GW_PROXY_TASK_WRITE;
value = NULL;
type_param = soup_soap_parameter_get_first_child_by_name (subparam, "note");
if (type_param) {
- individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
aclInstance->permissions |= E_GW_PROXY_NOTES_READ;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
aclInstance->permissions |= E_GW_PROXY_NOTES_WRITE;
value = soup_soap_parameter_get_string_value (individual_rights);
aclInstance->permissions |= E_GW_PROXY_GET_NOTIFICATIONS;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"setup");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"setup");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
aclInstance->permissions |= E_GW_PROXY_MODIFY_FOLDERS;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"readHidden");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"readHidden");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
aclInstance->permissions |= E_GW_PROXY_READ_PRIVATE;
}
}
-void
+void
e_gw_proxy_construct_proxy_list (SoupSoapParameter *param, GList **proxy_info)
{
- SoupSoapParameter *subparam;
+ SoupSoapParameter *subparam;
SoupSoapParameter *type_param;
char *value;
for (subparam = soup_soap_parameter_get_first_child_by_name (param, "proxy");
subparam != NULL;
- subparam = soup_soap_parameter_get_next_child_by_name (subparam, "proxy"))
+ subparam = soup_soap_parameter_get_next_child_by_name (subparam, "proxy"))
{
type_param = soup_soap_parameter_get_first_child_by_name (subparam, "displayName");
{
gboolean added = FALSE;
e_gw_message_write_string_parameter (msg, "email", NULL, new_proxy->proxy_email);
- e_gw_message_write_string_parameter (msg, "displayName", NULL, new_proxy->proxy_name);
+ e_gw_message_write_string_parameter (msg, "displayName", NULL, new_proxy->proxy_name);
if (new_proxy->permissions & E_GW_PROXY_MAIL_READ){
added = TRUE;
e_gw_message_write_int_parameter (msg, "readHidden", NULL, 1);
}
if (added==TRUE)
- soup_soap_message_end_element(msg);
+ soup_soap_message_end_element(msg);
}
-void
+void
e_gw_proxy_form_proxy_add_msg (SoupSoapMessage *msg, proxyHandler *new_proxy)
{
soup_soap_message_start_element (msg, "entry", NULL, NULL);
-
+
e_gw_proxy_form_soap_request_from_proxyHandler (msg, new_proxy);
}
-
-void
+
+void
e_gw_proxy_form_proxy_remove_msg (SoupSoapMessage *msg, proxyHandler *removeProxy)
{
e_gw_message_write_string_parameter (msg, "id", NULL, removeProxy->uniqueid);
}
-void
+void
e_gw_proxy_form_modify_proxy_msg (SoupSoapMessage *msg, proxyHandler *new_proxy)
{
soup_soap_message_start_element (msg, "updates", NULL, NULL);
-
+
soup_soap_message_start_element (msg, "delete", NULL, NULL);
soup_soap_message_end_element (msg);
-
+
soup_soap_message_start_element (msg, "add", NULL, NULL);
e_gw_proxy_form_soap_request_from_proxyHandler (msg, new_proxy);
soup_soap_message_end_element (msg);
-
+
soup_soap_message_end_element (msg);
}
subparam = soup_soap_parameter_get_first_child_by_name (param, "mail");
value = NULL;
if (subparam) {
- individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
*permissions |= E_GW_PROXY_MAIL_READ;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
*permissions |= E_GW_PROXY_MAIL_WRITE;
value = NULL;
subparam = soup_soap_parameter_get_first_child_by_name (param, "appointment");
if (subparam) {
- individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
*permissions |= E_GW_PROXY_APPOINTMENT_READ;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
*permissions |= E_GW_PROXY_APPOINTMENT_WRITE;
value = NULL;
subparam = soup_soap_parameter_get_first_child_by_name (param, "task");
if (subparam) {
- individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
*permissions |= E_GW_PROXY_TASK_READ;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
*permissions |= E_GW_PROXY_TASK_WRITE;
value = NULL;
subparam = soup_soap_parameter_get_first_child_by_name (param, "note");
if (subparam) {
- individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
*permissions |= E_GW_PROXY_NOTES_READ;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
*permissions |= E_GW_PROXY_NOTES_WRITE;
value = soup_soap_parameter_get_string_value (individual_rights);
*permissions |= E_GW_PROXY_GET_NOTIFICATIONS;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"setup");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"setup");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
*permissions |= E_GW_PROXY_MODIFY_FOLDERS;
}
- individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"readHidden");
+ individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"readHidden");
if (individual_rights) {
value = soup_soap_parameter_get_string_value (individual_rights);
*permissions |= E_GW_PROXY_READ_PRIVATE;
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Shreyas Srinivasan <sshreyas@novell.com>
* Sankar P <psankar@novell.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
/*State of each proxy grant*/
-#define E_GW_PROXY_NEW (1 << 0)
+#define E_GW_PROXY_NEW (1 << 0)
#define E_GW_PROXY_DELETED (1 << 1)
#define E_GW_PROXY_EDITED (1 << 2)
/*Permissions associated with a proxy grant*/
-#define E_GW_PROXY_MAIL_READ (1 << 0)
+#define E_GW_PROXY_MAIL_READ (1 << 0)
#define E_GW_PROXY_MAIL_WRITE (1 << 1)
-#define E_GW_PROXY_APPOINTMENT_READ (1 << 2)
+#define E_GW_PROXY_APPOINTMENT_READ (1 << 2)
#define E_GW_PROXY_APPOINTMENT_WRITE (1 << 3)
#define E_GW_PROXY_NOTES_READ (1 << 4)
#define E_GW_PROXY_NOTES_WRITE (1 << 5)
struct _proxyHandler {
char *uniqueid;
char *proxy_name;
- char *proxy_email;
+ char *proxy_email;
guint32 flags;
guint32 permissions;
};
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* Harish Krishnaswamy <kharish@novell.com>
- *
+ *
* Copyright 2005, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
static const char *days_of_week[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const char *
-e_gw_recur_get_day_of_week (short day)
+e_gw_recur_get_day_of_week (short day)
{
if (day < 1 || day > 7)
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
+/*
* Authors :
* Harish Krishnaswamy <kharish@novell.com>
- *
+ *
* Copyright 2005, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
#define E_GW_ITEM_RECURRENCE_FREQUENCY_YEARLY "Yearly"
-#define E_GW_ITEM_RECUR_OCCURRENCE_TYPE_FIRST "First"
-#define E_GW_ITEM_RECUR_OCCURRENCE_TYPE_SECOND "Second"
-#define E_GW_ITEM_RECUR_OCCURRENCE_TYPE_THIRD "Third"
-#define E_GW_ITEM_RECUR_OCCURRENCE_TYPE_FOURTH "Fourth"
+#define E_GW_ITEM_RECUR_OCCURRENCE_TYPE_FIRST "First"
+#define E_GW_ITEM_RECUR_OCCURRENCE_TYPE_SECOND "Second"
+#define E_GW_ITEM_RECUR_OCCURRENCE_TYPE_THIRD "Third"
+#define E_GW_ITEM_RECUR_OCCURRENCE_TYPE_FOURTH "Fourth"
#define E_GW_ITEM_RECUR_OCCURRENCE_TYPE_FIFTH "Fifth"
#define E_GW_ITEM_RECUR_OCCURRENCE_TYPE_LAST "Last"
const char *e_gw_recur_get_day_of_week (short day);
-
+
#endif
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
static void e_gw_sendoptions_finalize (GObject *object);
EGwSendOptionsGeneral*
-e_gw_sendoptions_get_general_options (EGwSendOptions *opts)
+e_gw_sendoptions_get_general_options (EGwSendOptions *opts)
{
g_return_val_if_fail (opts != NULL || E_IS_GW_SENDOPTIONS (opts), NULL);
}
static void
-e_gw_sendoptions_finalize (GObject *object)
+e_gw_sendoptions_finalize (GObject *object)
{
EGwSendOptions *opts = (EGwSendOptions *) object;
EGwSendOptionsPrivate *priv;
g_return_if_fail (E_IS_GW_SENDOPTIONS (opts));
priv = opts->priv;
-
+
if (priv->gopts) {
g_free (priv->gopts);
priv->gopts = NULL;
static void
e_gw_sendoptions_init (GObject *object)
-{
+{
EGwSendOptions *opts;
EGwSendOptionsPrivate *priv;
char *field = NULL, *val = NULL;
field_param = soup_soap_parameter_get_first_child_by_name (subparam, "field");
val_param = soup_soap_parameter_get_first_child_by_name (subparam, "value");
-
+
if (field_param) {
field = soup_soap_parameter_get_string_value (field_param);
if (!field)
sopts->opened = E_GW_RETURN_NOTIFY_MAIL;
} else
sopts->opened = E_GW_RETURN_NOTIFY_NONE;
-
+
} else if (!g_ascii_strcasecmp (field + i, "ReturnDelete")) {
if (val_param)
val_param = soup_soap_parameter_get_first_child_by_name (val_param, "mail");
-
+
if (val_param)
val = soup_soap_parameter_get_string_value (val_param);
} else if (!g_ascii_strcasecmp (field + i, "ReturnAccept")) {
if (val_param)
val_param = soup_soap_parameter_get_first_child_by_name (val_param, "mail");
-
+
if (val_param)
val = soup_soap_parameter_get_string_value (val_param);
} else if (!g_ascii_strcasecmp (field + i, "ReturnCompleted")) {
if (val_param)
val_param = soup_soap_parameter_get_first_child_by_name (val_param, "mail");
-
+
if (val_param)
val = soup_soap_parameter_get_string_value (val_param);
} else
sopts->completed = E_GW_RETURN_NOTIFY_NONE;
- }
+ }
g_free (field);
- g_free (val);
- }
+ g_free (val);
+ }
}
/* These are not actually general Options. These can be configured seperatly for
- each component. Since win32 shows them as general options, we too do the same
+ each component. Since win32 shows them as general options, we too do the same
way. So the Options are take from the mail setttings */
-
-static void
-parse_general_options (SoupSoapParameter *group_param, EGwSendOptionsGeneral *gopts)
+
+static void
+parse_general_options (SoupSoapParameter *group_param, EGwSendOptionsGeneral *gopts)
{
SoupSoapParameter *subparam, *field_param, *val_param;
char *field = NULL, *val = NULL;
field_param = soup_soap_parameter_get_first_child_by_name (subparam, "field");
val_param = soup_soap_parameter_get_first_child_by_name (subparam, "value");
-
+
if (field_param) {
field = soup_soap_parameter_get_string_value (field_param);
if (!field)
gopts->priority = E_GW_PRIORITY_LOW;
else
gopts->priority = E_GW_PRIORITY_UNDEFINED;
-
+
} else
gopts->priority = E_GW_PRIORITY_UNDEFINED;
} else if (!g_ascii_strcasecmp (field, "mailReplyRequested")) {
} else {
char *temp;
int i = 0;
-
+
val_param = soup_soap_parameter_get_first_child_by_name (val_param, "WithinNDays");
- temp = soup_soap_parameter_get_string_value (val_param);
-
- if (temp)
- i = atoi (temp);
+ temp = soup_soap_parameter_get_string_value (val_param);
+
+ if (temp)
+ i = atoi (temp);
gopts->reply_within = i;
- gopts->reply_enabled = TRUE;
+ gopts->reply_enabled = TRUE;
g_free (temp);
}
}
int i = atoi (val);
if (i != 0)
gopts->expiration_enabled = TRUE;
- else
+ else
gopts->expiration_enabled = FALSE;
gopts->expire_after = i;
/* These settings are common to all components */
static void
-parse_advanced_settings (SoupSoapParameter *group_param, EGwSendOptionsGeneral *gopts)
+parse_advanced_settings (SoupSoapParameter *group_param, EGwSendOptionsGeneral *gopts)
{
SoupSoapParameter *subparam, *field_param, *val_param;
char *field = NULL, *val = NULL;
field_param = soup_soap_parameter_get_first_child_by_name (subparam, "field");
val_param = soup_soap_parameter_get_first_child_by_name (subparam, "value");
-
+
if (field_param) {
field = soup_soap_parameter_get_string_value (field_param);
if (!field)
if (i > 0 ) {
gopts->delay_enabled = TRUE;
gopts->delay_until = i;
- } else
+ } else
gopts->delay_enabled = FALSE;
} else
gopts->delay_enabled = FALSE;
EGwSendOptionsPrivate *priv;
priv = opts->priv;
-
+
for (group_param = soup_soap_parameter_get_first_child_by_name(param, "group") ;
group_param != NULL ;
group_param = soup_soap_parameter_get_next_child_by_name (group_param, "group")) {
char *temp = NULL;
temp = soup_soap_parameter_get_property (group_param, "type");
-
- if (!temp)
+
+ if (!temp)
continue;
if (!g_ascii_strcasecmp (temp, "MailMessageSettings")) {
parse_status_tracking_options (group_param, 4, priv->mopts);
parse_general_options (group_param, priv->gopts);
- }
-
- if (!g_ascii_strcasecmp (temp, "AppointmentMessageSettings")) {
+ }
+
+ if (!g_ascii_strcasecmp (temp, "AppointmentMessageSettings")) {
parse_status_tracking_options (group_param, 11, priv->copts);
}
- if (!g_ascii_strcasecmp (temp, "TaskMessageSettings"))
+ if (!g_ascii_strcasecmp (temp, "TaskMessageSettings"))
parse_status_tracking_options (group_param, 4, priv->topts);
- if (!g_ascii_strcasecmp (temp, "AdvancedSettings"))
+ if (!g_ascii_strcasecmp (temp, "AdvancedSettings"))
parse_advanced_settings (group_param, priv->gopts);
g_free (temp);
}
-
+
return TRUE;
}
e_gw_sendoptions_write_settings (SoupSoapMessage *msg, char *field_name, char *value, char *value_name, gboolean value_direct)
{
soup_soap_message_start_element (msg, "setting", NULL, NULL);
-
+
soup_soap_message_start_element (msg, "field", NULL, NULL);
soup_soap_message_write_string (msg, field_name);
soup_soap_message_end_element (msg);
soup_soap_message_start_element (msg, "value", NULL, NULL);
-
+
if (!value_direct)
e_gw_message_write_string_parameter (msg, value_name, NULL, value);
else
soup_soap_message_write_string (msg, value);
soup_soap_message_end_element (msg);
-
- soup_soap_message_end_element (msg);
-}
+
+ soup_soap_message_end_element (msg);
+}
static void
set_status_tracking_changes (SoupSoapMessage *msg, EGwSendOptionsStatusTracking *n_sopts, EGwSendOptionsStatusTracking *o_sopts, char *comp)
g_free (comp_name), comp_name = NULL;
g_free (value), value = NULL;
}
-
+
if (!strcmp (comp, "mail")) {
if (n_sopts->autodelete != o_sopts->autodelete) {
if (n_sopts->autodelete)
g_free (comp_name), comp_name = NULL;
g_free (value), value = NULL;
}
-
+
if (n_sopts->declined != o_sopts->declined) {
comp_name = g_strconcat (comp, "ReturnDelete", NULL);
if (n_sopts->declined == E_GW_RETURN_NOTIFY_MAIL) {
g_free (comp_name), comp_name = NULL;
g_free (value), value = NULL;
}
-
+
if (!strcmp (comp, "appointment") || !strcmp (comp, "task")) {
if (n_sopts->accepted != o_sopts->accepted) {
comp_name = g_strconcat (comp, "ReturnAccept", NULL);
value = g_strdup ("None");
e_gw_sendoptions_write_settings (msg, comp_name, value, NULL, TRUE);
}
-
+
g_free (comp_name), comp_name = NULL;
g_free (value), value = NULL;
}
}
-
+
if (!strcmp (comp, "task")) {
if (n_sopts->completed != o_sopts->completed) {
comp_name = g_strconcat (comp, "ReturnCompleted", NULL);
value = g_strdup ("None");
e_gw_sendoptions_write_settings (msg, comp_name, value, NULL, TRUE);
}
-
+
g_free (comp_name), comp_name = NULL;
g_free (value), value = NULL;
}
value = g_strdup ("Standard");
else if (n_gopts->priority == E_GW_PRIORITY_LOW)
value = g_strdup ("Low");
- else
+ else
value = NULL;
e_gw_sendoptions_write_settings (msg, "mailPriority", value, NULL, TRUE);
e_gw_sendoptions_write_settings (msg, "appointmentPriority", value, NULL, TRUE);
if (n_gopts->reply_enabled != o_gopts->reply_enabled || n_gopts->reply_convenient != o_gopts->reply_convenient ||
n_gopts->reply_within != o_gopts->reply_within) {
-
+
if (n_gopts->reply_enabled) {
if (n_gopts->reply_convenient)
value = g_strdup ("WhenConvenient");
- else
- value = g_strdup_printf ("%d", n_gopts->reply_within);
- } else
+ else
+ value = g_strdup_printf ("%d", n_gopts->reply_within);
+ } else
value = g_strdup ("None");
-
+
if (n_gopts->reply_enabled && !n_gopts->reply_convenient)
e_gw_sendoptions_write_settings (msg, "mailReplyRequested", value, "WithinNDays" , FALSE);
else
value = g_strdup_printf ("%d", n_gopts->expire_after);
} else
value = g_strdup ("0");
-
+
e_gw_sendoptions_write_settings (msg, "mailExpireDays", value, NULL, TRUE);
g_free (value), value = NULL;
}
value = g_strdup_printf ("%d", n_gopts->delay_until);
} else
value = g_strdup ("-1");
-
+
e_gw_sendoptions_write_settings (msg, "delayDelivery", value, NULL, TRUE);
g_free (value), value = NULL;
}
}
/* n_opts has the new options, o_opts has the old options settings */
-gboolean
+gboolean
e_gw_sendoptions_form_message_to_modify (SoupSoapMessage *msg, EGwSendOptions *n_opts, EGwSendOptions *o_opts)
{
g_return_val_if_fail (n_opts != NULL || o_opts != NULL, FALSE);
set_status_tracking_changes (msg, n_opts->priv->mopts, o_opts->priv->mopts, "mail");
set_status_tracking_changes (msg, n_opts->priv->copts, o_opts->priv->copts, "appointment");
set_status_tracking_changes (msg, n_opts->priv->topts, o_opts->priv->topts, "task");
-
+
soup_soap_message_end_element (msg);
return TRUE;
}
EGwSendOptions *
-e_gw_sendoptions_new_from_soap_parameter (SoupSoapParameter *param)
+e_gw_sendoptions_new_from_soap_parameter (SoupSoapParameter *param)
{
EGwSendOptions *opts;
-
+
g_return_val_if_fail (param != NULL, NULL);
opts = g_object_new (E_TYPE_GW_SENDOPTIONS, NULL);
g_object_unref (opts);
return NULL;
}
-
+
return opts;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors :
+/*
+ * Authors :
* JP Rosevear <jpr@ximian.com>
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU Lesser General Public
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
static GObjectClass *parent_class = NULL;
-struct _OfflineListenerPrivate
+struct _OfflineListenerPrivate
{
GConfClient *default_client;
};
-static void
+static void
set_online_status (OfflineListener *offline_listener, gboolean is_offline)
{
OfflineListenerPrivate *priv;
-
+
priv = offline_listener->priv;
#if ENABLE_CALENDAR
(priv->book_factory, is_offline ? OFFLINE_MODE : ONLINE_MODE);
}
-static void
+static void
online_status_changed (GConfClient *client, int cnxn_id, GConfEntry *entry, gpointer data)
{
GConfValue *value;
priv->is_offline_now = offline;
set_online_status (offline_listener ,offline);
}
-
+
}
-static void
+static void
setup_offline_listener (OfflineListener *offline_listener)
{
OfflineListenerPrivate *priv = offline_listener->priv;
-
+
priv->default_client = gconf_client_get_default ();
gconf_client_add_dir (priv->default_client, "/apps/evolution/shell", GCONF_CLIENT_PRELOAD_RECURSIVE,NULL);
gconf_client_notify_add (priv->default_client, "/apps/evolution/shell/start_offline", (GConfClientNotifyFunc)online_status_changed, offline_listener, NULL, NULL);
priv->is_offline_now = gconf_client_get_bool (priv->default_client, "/apps/evolution/shell/start_offline", NULL);
- set_online_status (offline_listener, priv->is_offline_now);
+ set_online_status (offline_listener, priv->is_offline_now);
}
#if ENABLE_CALENDAR
{
OfflineListener *offline_listener = g_object_new (OFFLINE_TYPE_LISTENER, NULL);
OfflineListenerPrivate *priv = offline_listener->priv;
-
+
priv->book_factory = book_factory;
#if ENABLE_CALENDAR
priv->cal_factory = cal_factory;
offline_listener = OFFLINE_LISTENER (object);
priv = offline_listener->priv;
-
+
g_free (priv);
offline_listener->priv = NULL;
-
+
parent_class->finalize (object);
}
offline_listener_init (OfflineListener *listener)
{
OfflineListenerPrivate *priv;
-
+
priv =g_new0 (OfflineListenerPrivate, 1);
listener->priv = priv;
-
+
}
object_class = G_OBJECT_CLASS (klass);
object_class->dispose = offline_listener_dispose;
object_class->finalize = offline_listener_finalize;
-
-
+
+
}
struct _OfflineListener {
GObject parent;
OfflineListenerPrivate *priv;
-
+
};
struct _OfflineListenerClass {
ServerLogging *logging = SERVER_LOGGING (object);
ServerLoggingPrivate *priv;
GSList *l;
-
+
priv = logging->priv;
-
+
for (l = priv->handlers; l; l = l->next) {
ServerLoggingHandler *handler = l->data;
-
+
g_log_remove_handler (handler->domain, handler->id);
g_free (handler->domain);
g_free (handler);
server_logging_init (ServerLogging *logging)
{
ServerLoggingPrivate *priv;
-
+
priv = g_new0 (ServerLoggingPrivate, 1);
logging->priv = priv;
if (bonobo_event_source_has_listener (es, "log_event")) {
CORBA_exception_init (&ev);
- bonobo_event_source_notify_listeners (es, "log_event", &value, &ev);
+ bonobo_event_source_notify_listeners (es, "log_event", &value, &ev);
CORBA_exception_free (&ev);
}
guint handler_id;
priv = logging->priv;
-
+
handler_id = g_log_set_handler(domain, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
server_log_handler, logging);
handler = g_new0 (ServerLoggingHandler, 1);
handler->domain = g_strdup (domain);
handler->id = handler_id;
-
+
priv->handlers = g_slist_prepend (priv->handlers, handler);
}
}
fprintf (stderr, _("Multiple segmentation faults occurred; cannot display error dialog\n"));
_exit (1);
}
-
+
gnome_segv_path = GNOMEUI_SERVERDIR "/gnome_segv2";
-
+
exec = g_strdup_printf ("%s \"" PACKAGE "-" BASE_VERSION "\" %d \"" VERSION "\"",
gnome_segv_path, signo);
system (exec);
setup_segv_handler (void)
{
struct sigaction sa;
-
+
sa.sa_flags = 0;
sigemptyset (&sa.sa_mask);
sa.sa_handler = gnome_segv_handler;
{
gboolean did_books=FALSE, did_cals=FALSE;
OfflineListener *offline_listener = NULL;
-
+
bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#else
offline_listener = offline_listener_new (e_data_book_factory);
#endif
-
+
if ( setup_logging ()) {
if ( setup_interface_check ()) {
g_message ("Server up and running");
-
+
bonobo_main ();
} else
g_error (G_STRLOC "Cannot register DataServer::InterfaceCheck object");
bonobo_object_unref (BONOBO_OBJECT (interface_check_iface));
interface_check_iface = NULL;
-
+
gnome_vfs_shutdown ();
return 0;