diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-05-09 05:58:37 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-05-09 05:58:37 +0800 |
commit | 4554c20766d386909b765446af93418292293a7c (patch) | |
tree | 0bc57a8bdeb9901bd0dd929ca911ef53e9d4e81c /camel/camel-service.c | |
parent | 06bd4d2a16b4b39f485363f10dd272d529e3f16a (diff) | |
download | gsoc2013-evolution-4554c20766d386909b765446af93418292293a7c.tar.gz gsoc2013-evolution-4554c20766d386909b765446af93418292293a7c.tar.zst gsoc2013-evolution-4554c20766d386909b765446af93418292293a7c.zip |
Implemented. (digest_getv): Implemented.
2002-05-08 Jeffrey Stedfast <fejj@ximian.com>
* camel-digest-store.c (digest_setv): Implemented.
(digest_getv): Implemented.
* camel-disco-store.c (disco_setv): Implemented.
(disco_getv): Implemented.
* camel-remote-store.c (remote_store_setv): Implemented.
(remote_store_getv): Implemented.
* camel-transport.c (camel_transport_class_init): Implemented.
(transport_setv): Implemented.
(transport_getv): Implemented.
* camel-store.c (store_setv): Implemented.
(store_getv): Implemented.
* camel-service.c (service_setv): Implemented.
(service_getv): Implemented.
svn path=/trunk/; revision=16729
Diffstat (limited to 'camel/camel-service.c')
-rw-r--r-- | camel/camel-service.c | 131 |
1 files changed, 127 insertions, 4 deletions
diff --git a/camel/camel-service.c b/camel/camel-service.c index 19c058f970..f83c3fe612 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -60,16 +60,25 @@ static gboolean service_connect(CamelService *service, CamelException *ex); static gboolean service_disconnect(CamelService *service, gboolean clean, CamelException *ex); static void cancel_connect (CamelService *service); -static GList * query_auth_types (CamelService *service, CamelException *ex); -static char * get_name (CamelService *service, gboolean brief); -static char * get_path (CamelService *service); +static GList *query_auth_types (CamelService *service, CamelException *ex); +static char *get_name (CamelService *service, gboolean brief); +static char *get_path (CamelService *service); + +static int service_setv (CamelObject *object, CamelException *ex, CamelArgV *args); +static int service_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args); static void 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; @@ -144,6 +153,120 @@ camel_service_get_type (void) } +static int +service_setv (CamelObject *object, CamelException *ex, CamelArgV *args) +{ + CamelService *service = (CamelService *) object; + CamelURL *url = service->url; + gboolean reconnect = FALSE; + guint32 tag; + int i; + + for (i = 0; i < args->argc; i++) { + tag = args->argv[i].tag; + + /* make sure this arg wasn't already handled */ + if (tag & CAMEL_ARG_IGNORE) + continue; + + /* 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) { + camel_url_set_user (url, args->argv[i].ca_str); + reconnect = TRUE; + } + } else if (tag == CAMEL_SERVICE_AUTH) { + /* set the auth mechanism */ + if (strcmp (url->authmech, args->argv[i].ca_str) != 0) { + camel_url_set_authmech (url, args->argv[i].ca_str); + reconnect = TRUE; + } + } else if (tag == CAMEL_SERVICE_HOSTNAME) { + /* set the hostname */ + if (strcmp (url->host, args->argv[i].ca_str) != 0) { + camel_url_set_host (url, args->argv[i].ca_str); + reconnect = TRUE; + } + } else if (tag == CAMEL_SERVICE_PORT) { + /* set the port */ + if (url->port != args->argv[i].ca_int) { + camel_url_set_port (url, args->argv[i].ca_int); + reconnect = TRUE; + } + } else if (tag == CAMEL_SERVICE_PATH) { + /* set the path */ + if (strcmp (url->path, args->argv[i].ca_str) != 0) { + camel_url_set_host (url, args->argv[i].ca_str); + reconnect = TRUE; + } + } else { + /* error? */ + continue; + } + + /* let our parent know that we've handled this arg */ + camel_argv_ignore (args, i); + } + + if (reconnect) { + /* 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); +} + +static int +service_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args) +{ + CamelService *service = (CamelService *) object; + 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 */ + *args->argv[i].ca_str = url->user; + break; + case CAMEL_SERVICE_AUTH: + /* get the auth mechanism */ + *args->argv[i].ca_str = url->authmech; + break; + case CAMEL_SERVICE_HOSTNAME: + /* get the hostname */ + *args->argv[i].ca_str = url->host; + break; + case CAMEL_SERVICE_PORT: + /* get the port */ + *args->argv[i].ca_int = url->port; + break; + case CAMEL_SERVICE_PATH: + /* get the path */ + *args->argv[i].ca_str = url->path; + break; + default: + /* error? */ + } + } + + return CAMEL_OBJECT_CLASS (parent_class)->getv (object, ex, args); +} + static void construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex) |