diff options
-rw-r--r-- | camel/ChangeLog | 11 | ||||
-rw-r--r-- | camel/camel-data-wrapper.c | 11 | ||||
-rw-r--r-- | camel/camel-data-wrapper.h | 3 | ||||
-rw-r--r-- | camel/camel-medium.c | 17 | ||||
-rw-r--r-- | camel/camel-multipart.c | 20 |
5 files changed, 56 insertions, 6 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index ba7c9ecec3..18bf3b6dac 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,14 @@ +2001-09-18 Dan Winship <danw@ximian.com> + + * camel-data-wrapper.c (camel_data_wrapper_is_offline): Virtualize + this. + + * camel-medium.c (is_offline): A medium is offline if its content + object is offline. + + * camel-multipart.c (is_offline): A multipart is offline if any of + its subparts are offline. + 2001-09-18 Jeffrey Stedfast <fejj@ximian.com> * camel-charset-map.c: Added korean charset conversion. diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c index 3a618ead6f..a549f6bed9 100644 --- a/camel/camel-data-wrapper.c +++ b/camel/camel-data-wrapper.c @@ -48,6 +48,7 @@ static void set_mime_type (CamelDataWrapper *data_wrapper, const gchar *mime_typ static gchar *get_mime_type (CamelDataWrapper *data_wrapper); static CamelContentType *get_mime_type_field (CamelDataWrapper *data_wrapper); static void set_mime_type_field (CamelDataWrapper *data_wrapper, CamelContentType *mime_type); +static gboolean is_offline (CamelDataWrapper *data_wrapper); static void camel_data_wrapper_class_init (CamelDataWrapperClass *camel_data_wrapper_class) @@ -60,8 +61,8 @@ camel_data_wrapper_class_init (CamelDataWrapperClass *camel_data_wrapper_class) camel_data_wrapper_class->get_mime_type = get_mime_type; camel_data_wrapper_class->get_mime_type_field = get_mime_type_field; camel_data_wrapper_class->set_mime_type_field = set_mime_type_field; - camel_data_wrapper_class->construct_from_stream = construct_from_stream; + camel_data_wrapper_class->is_offline = is_offline; } static void @@ -280,6 +281,12 @@ camel_data_wrapper_set_mime_type_field (CamelDataWrapper *data_wrapper, } +static gboolean +is_offline (CamelDataWrapper *data_wrapper) +{ + return data_wrapper->offline; +} + /** * camel_data_wrapper_is_offline: * @data_wrapper: a data wrapper @@ -291,5 +298,5 @@ camel_data_wrapper_set_mime_type_field (CamelDataWrapper *data_wrapper, gboolean camel_data_wrapper_is_offline (CamelDataWrapper *data_wrapper) { - return data_wrapper->offline; + return CDW_CLASS (data_wrapper)->is_offline (data_wrapper); } diff --git a/camel/camel-data-wrapper.h b/camel/camel-data-wrapper.h index 9d7b62dd0c..2d1e44c1fd 100644 --- a/camel/camel-data-wrapper.h +++ b/camel/camel-data-wrapper.h @@ -69,6 +69,9 @@ typedef struct { int (*construct_from_stream) (CamelDataWrapper *data_wrapper, CamelStream *); + + gboolean (*is_offline) (CamelDataWrapper *data_wrapper); + } CamelDataWrapperClass; /* Standard Camel function */ diff --git a/camel/camel-medium.c b/camel/camel-medium.c index 818df69493..95480754a0 100644 --- a/camel/camel-medium.c +++ b/camel/camel-medium.c @@ -40,6 +40,7 @@ static CamelDataWrapperClass *parent_class = NULL; /* Returns the class for a CamelMedium */ #define CM_CLASS(so) CAMEL_MEDIUM_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +static gboolean is_offline (CamelDataWrapper *data_wrapper); static void add_header (CamelMedium *medium, const gchar *header_name, const void *header_value); static void set_header (CamelMedium *medium, const gchar *header_name, const void *header_value); @@ -56,13 +57,14 @@ static void set_content_object (CamelMedium *medium, static void camel_medium_class_init (CamelMediumClass *camel_medium_class) { - /* - * CamelDataWrapperClass *camel_data_wrapper_class = - * CAMEL_DATA_WRAPPER_CLASS (camel_medium_class); - */ + CamelDataWrapperClass *camel_data_wrapper_class = + CAMEL_DATA_WRAPPER_CLASS (camel_medium_class); parent_class = CAMEL_DATA_WRAPPER_CLASS (camel_type_get_global_classfuncs (camel_data_wrapper_get_type ())); + /* virtual method overload */ + camel_data_wrapper_class->is_offline = is_offline; + /* virtual method definition */ camel_medium_class->add_header = add_header; camel_medium_class->set_header = set_header; @@ -112,6 +114,13 @@ camel_medium_get_type (void) return camel_medium_type; } +static gboolean +is_offline (CamelDataWrapper *data_wrapper) +{ + return parent_class->is_offline (data_wrapper) || + camel_data_wrapper_is_offline (CAMEL_MEDIUM (data_wrapper)->content); +} + static void add_header (CamelMedium *medium, const gchar *header_name, const void *header_value) diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c index 836297a1c8..076ec3af76 100644 --- a/camel/camel-multipart.c +++ b/camel/camel-multipart.c @@ -44,6 +44,7 @@ #define d(x) +static gboolean is_offline (CamelDataWrapper *data_wrapper); static void add_part (CamelMultipart *multipart, CamelMimePart *part); static void add_part_at (CamelMultipart *multipart, @@ -94,6 +95,7 @@ camel_multipart_class_init (CamelMultipartClass *camel_multipart_class) /* virtual method overload */ camel_data_wrapper_class->write_to_stream = write_to_stream; + camel_data_wrapper_class->is_offline = is_offline; } static void @@ -414,6 +416,24 @@ camel_multipart_get_boundary (CamelMultipart *multipart) return CMP_CLASS (multipart)->get_boundary (multipart); } +static gboolean +is_offline (CamelDataWrapper *data_wrapper) +{ + CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper); + GList *node; + CamelDataWrapper *part; + + if (parent_class->is_offline (data_wrapper)) + return TRUE; + for (node = multipart->parts; node; node = node->next) { + part = node->data; + if (camel_data_wrapper_is_offline (part)) + return TRUE; + } + + return FALSE; +} + /* this is MIME specific, doesn't belong here really */ static int write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) |