diff options
author | Dan Winship <danw@src.gnome.org> | 2000-11-04 02:22:34 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-11-04 02:22:34 +0800 |
commit | 5a4fa8505d6a81836da77e2cc07e5fbd0cd21b7c (patch) | |
tree | 74b9a226512a2e46391933c1f6a2fd05e1bb4811 /camel | |
parent | d428113c3aadafa3a23d27ed05954c49c0af84b0 (diff) | |
download | gsoc2013-evolution-5a4fa8505d6a81836da77e2cc07e5fbd0cd21b7c.tar.gz gsoc2013-evolution-5a4fa8505d6a81836da77e2cc07e5fbd0cd21b7c.tar.zst gsoc2013-evolution-5a4fa8505d6a81836da77e2cc07e5fbd0cd21b7c.zip |
Add an "url_flags" field to CamelProvider. Move the CAMEL_SERVICE_URL_*
* camel-provider.h: Add an "url_flags" field to CamelProvider.
Move the CAMEL_SERVICE_URL_* defines here and remove the SERVICE_
part of the name.
* camel-service.h: Remove CAMEL_SERVICE_URL_* flags and
service->url_flags field.
* camel-service.c (check_url, get_path): Get URL flags from
service->provider, update for changed flag names.
* providers/*/camel-*-provider.c: Add URL flags to provider
structures.
* providers/*/camel-*-{store,transport}.c, camel-remote-store.c:
Remove service->url_flags initialization.
svn path=/trunk/; revision=6370
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 18 | ||||
-rw-r--r-- | camel/camel-provider.h | 24 | ||||
-rw-r--r-- | camel/camel-remote-store.c | 3 | ||||
-rw-r--r-- | camel/camel-service.c | 43 | ||||
-rw-r--r-- | camel/camel-service.h | 23 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-provider.c | 6 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 6 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-provider.c | 2 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-store.c | 3 | ||||
-rw-r--r-- | camel/providers/mh/camel-mh-provider.c | 2 | ||||
-rw-r--r-- | camel/providers/mh/camel-mh-store.c | 3 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-provider.c | 3 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-store.c | 5 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-provider.c | 2 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-store.c | 4 | ||||
-rw-r--r-- | camel/providers/sendmail/camel-sendmail-provider.c | 2 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-provider.c | 4 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 3 | ||||
-rw-r--r-- | camel/providers/vee/camel-vee-provider.c | 2 |
19 files changed, 79 insertions, 79 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 80d6cdb807..026ee4605a 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,21 @@ +2000-11-03 Dan Winship <danw@helixcode.com> + + * camel-provider.h: Add an "url_flags" field to CamelProvider. + Move the CAMEL_SERVICE_URL_* defines here and remove the SERVICE_ + part of the name. + + * camel-service.h: Remove CAMEL_SERVICE_URL_* flags and + service->url_flags field. + + * camel-service.c (check_url, get_path): Get URL flags from + service->provider, update for changed flag names. + + * providers/*/camel-*-provider.c: Add URL flags to provider + structures. + + * providers/*/camel-*-{store,transport}.c, camel-remote-store.c: + Remove service->url_flags initialization. + 2000-11-02 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-store.c (get_folder_info): Quote diff --git a/camel/camel-provider.h b/camel/camel-provider.h index 00375029db..f5a434cde5 100644 --- a/camel/camel-provider.h +++ b/camel/camel-provider.h @@ -55,6 +55,28 @@ extern char *camel_provider_type_name[CAMEL_NUM_PROVIDER_TYPES]; #define CAMEL_PROVIDER_IS_SOURCE (1 << 1) #define CAMEL_PROVIDER_IS_STORAGE (1 << 2) + +/* Flags for url_flags. "ALLOW" means the config dialog will let + * the user configure it. "NEED" implies "ALLOW" but means the user + * must configure it. Service code can assume that any url part + * for which it has set the NEED flag will be set when the service + * is created. + */ +#define CAMEL_URL_ALLOW_USER (1 << 0) +#define CAMEL_URL_ALLOW_AUTH (1 << 1) +#define CAMEL_URL_ALLOW_PASSWORD (1 << 2) +#define CAMEL_URL_ALLOW_HOST (1 << 3) +#define CAMEL_URL_ALLOW_PORT (1 << 4) +#define CAMEL_URL_ALLOW_PATH (1 << 5) + +#define CAMEL_URL_NEED_USER (1 << 6 | 1 << 0) +#define CAMEL_URL_NEED_AUTH (1 << 7 | 1 << 1) +#define CAMEL_URL_NEED_PASSWORD (1 << 8 | 1 << 2) +#define CAMEL_URL_NEED_HOST (1 << 9 | 1 << 3) +#define CAMEL_URL_NEED_PORT (1 << 10 | 1 << 4) +#define CAMEL_URL_NEED_PATH (1 << 11 | 1 << 5) + + typedef struct { /* Provider name used in CamelURLs. */ char *protocol; @@ -76,7 +98,7 @@ typedef struct { */ char *domain; - int flags; + int flags, url_flags; CamelType object_types [CAMEL_NUM_PROVIDER_TYPES]; diff --git a/camel/camel-remote-store.c b/camel/camel-remote-store.c index a0129763a0..eeca0d4080 100644 --- a/camel/camel-remote-store.c +++ b/camel/camel-remote-store.c @@ -104,12 +104,9 @@ camel_remote_store_class_init (CamelRemoteStoreClass *camel_remote_store_class) static void camel_remote_store_init (CamelObject *object) { - CamelService *service = CAMEL_SERVICE (object); CamelStore *store = CAMEL_STORE (object); CamelRemoteStore *remote_store = CAMEL_REMOTE_STORE (object); - service->url_flags |= CAMEL_SERVICE_URL_NEED_HOST; - store->folders = g_hash_table_new (g_str_hash, g_str_equal); remote_store->istream = NULL; diff --git a/camel/camel-service.c b/camel/camel-service.c index 5eb78dcaa6..06b1d09625 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -112,8 +112,8 @@ check_url (CamelService *service, CamelException *ex) { char *url_string; - if (((service->url_flags & CAMEL_SERVICE_URL_NEED_USER) - == CAMEL_SERVICE_URL_NEED_USER) && + if (((service->provider->url_flags & CAMEL_URL_NEED_USER) + == CAMEL_URL_NEED_USER) && (service->url->user == NULL || service->url->user[0] == '\0')) { url_string = camel_url_to_string (service->url, FALSE); camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID, @@ -121,8 +121,8 @@ check_url (CamelService *service, CamelException *ex) url_string); g_free (url_string); return FALSE; - } else if (((service->url_flags & CAMEL_SERVICE_URL_NEED_HOST) - == CAMEL_SERVICE_URL_NEED_HOST) && + } else if (((service->provider->url_flags & CAMEL_URL_NEED_HOST) + == CAMEL_URL_NEED_HOST) && (service->url->host == NULL || service->url->host[0] == '\0')) { url_string = camel_url_to_string (service->url, FALSE); camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID, @@ -130,8 +130,8 @@ check_url (CamelService *service, CamelException *ex) url_string); g_free (url_string); return FALSE; - } else if (((service->url_flags & CAMEL_SERVICE_URL_NEED_PATH) - == CAMEL_SERVICE_URL_NEED_PATH) && + } else if (((service->provider->url_flags & CAMEL_URL_NEED_PATH) + == CAMEL_URL_NEED_PATH) && (service->url->path == NULL || service->url->path[0] == '\0')) { url_string = camel_url_to_string (service->url, FALSE); camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID, @@ -148,6 +148,7 @@ check_url (CamelService *service, CamelException *ex) * camel_service_new: create a new CamelService or subtype * @type: the CamelType of the class to create * @session: the session for the service + * @provider: the service's provider * @url: the default URL for the service (may be NULL) * @ex: a CamelException * @@ -157,8 +158,9 @@ check_url (CamelService *service, CamelException *ex) * Return value: the CamelService, or NULL. **/ CamelService * -camel_service_new (CamelType type, CamelSession *session, CamelProvider *provider, - CamelURL *url, CamelException *ex) +camel_service_new (CamelType type, CamelSession *session, + CamelProvider *provider, CamelURL *url, + CamelException *ex) { CamelService *service; @@ -181,17 +183,6 @@ camel_service_new (CamelType type, CamelSession *session, CamelProvider *provide /* don't ref -- providers are not CamelObjects */ service->connected = FALSE; - -#if 0 - if (!url->empty) { - if (CSERV_CLASS (service)->connect (service, ex) == FALSE) { - camel_object_unref (CAMEL_OBJECT (service)); - return NULL; - } - - service->connected = TRUE; - } -#endif return service; } @@ -329,29 +320,29 @@ get_path (CamelService *service) GString *gpath; char *path; CamelURL *url = service->url; - int flags = service->url_flags; + int flags = service->provider->url_flags; /* A sort of ad-hoc default implementation that works for our * current set of services. */ gpath = g_string_new (service->provider->protocol); - if (flags & CAMEL_SERVICE_URL_ALLOW_USER) { - if (flags & CAMEL_SERVICE_URL_ALLOW_HOST) { + if (flags & CAMEL_URL_ALLOW_USER) { + if (flags & CAMEL_URL_ALLOW_HOST) { g_string_sprintfa (gpath, "/%s@%s", url->user ? url->user : "", url->host ? url->host : ""); } else { g_string_sprintfa (gpath, "/%s%s", url->user ? url->user : "", - ((flags & CAMEL_SERVICE_URL_NEED_USER) == CAMEL_SERVICE_URL_NEED_USER) ? "" : "@"); + ((flags & CAMEL_URL_NEED_USER) == CAMEL_URL_NEED_USER) ? "" : "@"); } - } else if (flags & CAMEL_SERVICE_URL_ALLOW_HOST) { + } else if (flags & CAMEL_URL_ALLOW_HOST) { g_string_sprintfa (gpath, "/%s%s", - ((flags & CAMEL_SERVICE_URL_NEED_HOST) == CAMEL_SERVICE_URL_NEED_HOST) ? "" : "@", + ((flags & CAMEL_URL_NEED_HOST) == CAMEL_URL_NEED_HOST) ? "" : "@", url->host ? url->host : ""); } - if ((flags & CAMEL_SERVICE_URL_NEED_PATH) == CAMEL_SERVICE_URL_NEED_PATH) { + if ((flags & CAMEL_URL_NEED_PATH) == CAMEL_URL_NEED_PATH) { g_string_sprintfa (gpath, "%s%s", *url->path == '/' ? "" : "/", url->path); diff --git a/camel/camel-service.h b/camel/camel-service.h index 3666ab71bc..3f5acabbb5 100644 --- a/camel/camel-service.h +++ b/camel/camel-service.h @@ -52,7 +52,6 @@ struct _CamelService { CamelProvider *provider; gboolean connected; CamelURL *url; - int url_flags; }; @@ -81,28 +80,6 @@ typedef struct { } CamelServiceClass; - -/* Flags for url_flags. "ALLOW" means the config dialog will let - * the user configure it. "NEED" implies "ALLOW" but means the user - * must configure it. Service code can assume that any url part - * for which it has set the NEED flag will be set when the service - * is created. - */ -#define CAMEL_SERVICE_URL_ALLOW_USER (1 << 0) -#define CAMEL_SERVICE_URL_ALLOW_AUTH (1 << 1) -#define CAMEL_SERVICE_URL_ALLOW_PASSWORD (1 << 2) -#define CAMEL_SERVICE_URL_ALLOW_HOST (1 << 3) -#define CAMEL_SERVICE_URL_ALLOW_PORT (1 << 4) -#define CAMEL_SERVICE_URL_ALLOW_PATH (1 << 5) - -#define CAMEL_SERVICE_URL_NEED_USER (1 << 6 | 1 << 0) -#define CAMEL_SERVICE_URL_NEED_AUTH (1 << 7 | 1 << 1) -#define CAMEL_SERVICE_URL_NEED_PASSWORD (1 << 8 | 1 << 2) -#define CAMEL_SERVICE_URL_NEED_HOST (1 << 9 | 1 << 3) -#define CAMEL_SERVICE_URL_NEED_PORT (1 << 10 | 1 << 4) -#define CAMEL_SERVICE_URL_NEED_PATH (1 << 11 | 1 << 5) - - /* query_auth_types returns a GList of these */ typedef struct { char *name, *description, *authproto; diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c index a94daa3e19..9b962df5f4 100644 --- a/camel/providers/imap/camel-imap-provider.c +++ b/camel/providers/imap/camel-imap-provider.c @@ -42,7 +42,11 @@ static CamelProvider imap_provider = { "mail", - CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE | CAMEL_PROVIDER_IS_STORAGE, + CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE | + CAMEL_PROVIDER_IS_STORAGE, + + CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | + CAMEL_URL_ALLOW_PATH | CAMEL_URL_ALLOW_AUTH, { 0, 0 }, diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 904bd6bc37..0a8618ff90 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -126,16 +126,10 @@ camel_imap_store_finalize (CamelObject *object) static void camel_imap_store_init (gpointer object, gpointer klass) { - CamelService *service = CAMEL_SERVICE (object); CamelRemoteStore *remote_store = CAMEL_REMOTE_STORE (object); CamelImapStore *imap_store = CAMEL_IMAP_STORE (object); CamelStore *store = CAMEL_STORE (object); - service->url_flags |= (CAMEL_SERVICE_URL_NEED_USER | - CAMEL_SERVICE_URL_NEED_HOST | - CAMEL_SERVICE_URL_ALLOW_PATH | - CAMEL_SERVICE_URL_ALLOW_AUTH); - remote_store->default_port = 143; imap_store->dir_sep = '\0'; diff --git a/camel/providers/mbox/camel-mbox-provider.c b/camel/providers/mbox/camel-mbox-provider.c index 3130a3ffd9..bfce8b5ada 100644 --- a/camel/providers/mbox/camel-mbox-provider.c +++ b/camel/providers/mbox/camel-mbox-provider.c @@ -40,6 +40,8 @@ static CamelProvider mbox_provider = { CAMEL_PROVIDER_IS_SOURCE | CAMEL_PROVIDER_IS_STORAGE, + CAMEL_URL_NEED_PATH, + { 0, 0 }, NULL diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c index 68ecfd229e..e3110ef3d3 100644 --- a/camel/providers/mbox/camel-mbox-store.c +++ b/camel/providers/mbox/camel-mbox-store.c @@ -69,11 +69,8 @@ camel_mbox_store_class_init (CamelMboxStoreClass *camel_mbox_store_class) static void camel_mbox_store_init (gpointer object, gpointer klass) { - CamelService *service = CAMEL_SERVICE (object); CamelStore *store = CAMEL_STORE (object); - service->url_flags = CAMEL_SERVICE_URL_NEED_PATH; - /* mbox names are filenames, so they are case-sensitive. */ store->folders = g_hash_table_new (g_str_hash, g_str_equal); } diff --git a/camel/providers/mh/camel-mh-provider.c b/camel/providers/mh/camel-mh-provider.c index 25a3522678..74329a3203 100644 --- a/camel/providers/mh/camel-mh-provider.c +++ b/camel/providers/mh/camel-mh-provider.c @@ -39,6 +39,8 @@ static CamelProvider mh_provider = { CAMEL_PROVIDER_IS_STORAGE, + CAMEL_URL_NEED_PATH, + {0, 0}, NULL diff --git a/camel/providers/mh/camel-mh-store.c b/camel/providers/mh/camel-mh-store.c index 65b1005b85..0a6da11162 100644 --- a/camel/providers/mh/camel-mh-store.c +++ b/camel/providers/mh/camel-mh-store.c @@ -68,11 +68,8 @@ static void camel_mh_store_class_init(CamelObjectClass * camel_mh_store_class) static void camel_mh_store_init(CamelObject * object) { - CamelService *service = CAMEL_SERVICE(object); CamelStore *store = CAMEL_STORE(object); - service->url_flags = CAMEL_SERVICE_URL_NEED_PATH; - /* mh names are filenames, so they are case-sensitive. */ store->folders = g_hash_table_new(g_str_hash, g_str_equal); } diff --git a/camel/providers/nntp/camel-nntp-provider.c b/camel/providers/nntp/camel-nntp-provider.c index 59a251a795..76ac521ec6 100644 --- a/camel/providers/nntp/camel-nntp-provider.c +++ b/camel/providers/nntp/camel-nntp-provider.c @@ -44,6 +44,9 @@ static CamelProvider news_provider = { CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_STORAGE, + CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_USER | + CAMEL_URL_ALLOW_PASSWORD | CAMEL_URL_ALLOW_AUTH, + { 0, 0 }, NULL diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c index 41466fe06c..ff9e7a989a 100644 --- a/camel/providers/nntp/camel-nntp-store.c +++ b/camel/providers/nntp/camel-nntp-store.c @@ -626,14 +626,9 @@ camel_nntp_store_class_init (CamelNNTPStoreClass *camel_nntp_store_class) static void camel_nntp_store_init (gpointer object, gpointer klass) { - CamelService *service = CAMEL_SERVICE (object); CamelRemoteStore *remote_store = CAMEL_REMOTE_STORE (object); CamelStore *store = CAMEL_STORE (object); - service->url_flags = (CAMEL_SERVICE_URL_NEED_HOST - | CAMEL_SERVICE_URL_ALLOW_USER - | CAMEL_SERVICE_URL_ALLOW_PASSWORD - | CAMEL_SERVICE_URL_ALLOW_AUTH); remote_store->default_port = NNTP_PORT; store->flags = CAMEL_STORE_SUBSCRIPTIONS; diff --git a/camel/providers/pop3/camel-pop3-provider.c b/camel/providers/pop3/camel-pop3-provider.c index 2884cf6238..5af0dad73c 100644 --- a/camel/providers/pop3/camel-pop3-provider.c +++ b/camel/providers/pop3/camel-pop3-provider.c @@ -41,6 +41,8 @@ static CamelProvider pop3_provider = { CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE, + CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH, + { 0, 0 }, NULL diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index 67d32da796..d572cc0a98 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -112,12 +112,8 @@ camel_pop3_store_class_init (CamelPop3StoreClass *camel_pop3_store_class) static void camel_pop3_store_init (gpointer object, gpointer klass) { - CamelService *service = CAMEL_SERVICE (object); CamelRemoteStore *remote_store = CAMEL_REMOTE_STORE (object); - service->url_flags |= (CAMEL_SERVICE_URL_NEED_USER | - CAMEL_SERVICE_URL_NEED_HOST | - CAMEL_SERVICE_URL_ALLOW_AUTH); remote_store->default_port = 110; } diff --git a/camel/providers/sendmail/camel-sendmail-provider.c b/camel/providers/sendmail/camel-sendmail-provider.c index 5fbac10434..d0e40b4cf8 100644 --- a/camel/providers/sendmail/camel-sendmail-provider.c +++ b/camel/providers/sendmail/camel-sendmail-provider.c @@ -40,6 +40,8 @@ static CamelProvider sendmail_provider = { 0, + 0, + { 0, 0 }, NULL diff --git a/camel/providers/smtp/camel-smtp-provider.c b/camel/providers/smtp/camel-smtp-provider.c index ca6116042c..6d94536937 100644 --- a/camel/providers/smtp/camel-smtp-provider.c +++ b/camel/providers/smtp/camel-smtp-provider.c @@ -38,7 +38,9 @@ static CamelProvider smtp_provider = { "mail", - 0, + CAMEL_PROVIDER_IS_REMOTE, + + CAMEL_URL_NEED_HOST, { 0, 0 }, diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 62cd0b7525..6fa39bb930 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -107,11 +107,8 @@ static void camel_smtp_transport_init (gpointer object) { CamelTransport *transport = CAMEL_TRANSPORT (object); - CamelService *service = CAMEL_SERVICE (transport); transport->supports_8bit = FALSE; - - service->url_flags = CAMEL_SERVICE_URL_NEED_HOST; } CamelType diff --git a/camel/providers/vee/camel-vee-provider.c b/camel/providers/vee/camel-vee-provider.c index 335a5de097..4588fb77d3 100644 --- a/camel/providers/vee/camel-vee-provider.c +++ b/camel/providers/vee/camel-vee-provider.c @@ -35,6 +35,8 @@ static CamelProvider vee_provider = { 0, + 0, + { 0, 0 }, NULL |