CAMEL_EXCEPTION_SERVICE_INVALID,
CAMEL_EXCEPTION_SERVICE_URL_INVALID,
CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
-CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE
+CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED
\ No newline at end of file
static gboolean service_connect(CamelService *service, CamelException *ex);
static gboolean service_disconnect(CamelService *service, CamelException *ex);
-static gboolean is_connected (CamelService *service);
-static GList * query_auth_types (CamelService *service, CamelException *ex);
+/*static gboolean is_connected (CamelService *service);*/
+static GList * query_auth_types_func (CamelService *service, CamelException *ex);
static void free_auth_types (CamelService *service, GList *authtypes);
static char * get_name (CamelService *service, gboolean brief);
static gboolean check_url (CamelService *service, CamelException *ex);
/* virtual method definition */
camel_service_class->connect = service_connect;
camel_service_class->disconnect = service_disconnect;
- camel_service_class->is_connected = is_connected;
- camel_service_class->query_auth_types = query_auth_types;
+ /*camel_service_class->is_connected = is_connected;*/
+ camel_service_class->query_auth_types_connected = query_auth_types_func;
+ camel_service_class->query_auth_types_generic = query_auth_types_func;
camel_service_class->free_auth_types = free_auth_types;
camel_service_class->get_name = get_name;
}
{
CamelService *camel_service = CAMEL_SERVICE (object);
+ if (camel_service->connected) {
+ CamelException ex;
+
+ /*g_warning ("camel_service_finalize: finalizing while still connected!");*/
+ camel_exception_init (&ex);
+ CSERV_CLASS (camel_service)->disconnect (camel_service, &ex);
+ if (camel_exception_is_set (&ex)) {
+ g_warning ("camel_service_finalize: silent disconnect failure: %s",
+ camel_exception_get_description(&ex));
+ }
+ camel_exception_clear (&ex);
+ }
+
if (camel_service->url)
camel_url_free (camel_service->url);
if (camel_service->session)
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
service = CAMEL_SERVICE (camel_object_new (type));
+
+ /*service->connect_level = 0;*/
+
service->url = url;
if (!url->empty && !check_url (service, ex)) {
camel_object_unref (CAMEL_OBJECT (service));
service->session = session;
camel_object_ref (CAMEL_OBJECT (session));
+ service->connected = FALSE;
+
+ if (!url->empty) {
+ if (CSERV_CLASS (service)->connect (service, ex) == FALSE) {
+ camel_object_unref (CAMEL_OBJECT (service));
+ return NULL;
+ }
+
+ service->connected = TRUE;
+ }
+
return service;
}
static gboolean
service_connect (CamelService *service, CamelException *ex)
{
- service->connected = TRUE;
- return TRUE;
+ /* Things like the CamelMboxStore can validly
+ * not define a connect function.
+ */
+ return TRUE;
}
/**
*
* Return value: whether or not the connection succeeded
**/
-gboolean
-camel_service_connect (CamelService *service, CamelException *ex)
-{
- 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);
-
- return CSERV_CLASS (service)->connect (service, ex);
-}
-
+/**
+ *gboolean
+ *camel_service_connect (CamelService *service, CamelException *ex)
+ *{
+ * 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);
+ *
+ * if (service->connect_level > 0) {
+ * service->connect_level++;
+ * return TRUE;
+ * }
+ *
+ * return CSERV_CLASS (service)->connect (service, ex);
+ *}
+ **/
static gboolean
service_disconnect (CamelService *service, CamelException *ex)
{
- service->connected = FALSE;
+ /*service->connect_level--;*/
+
+ /* We let people get away with not having a disconnect
+ * function -- CamelMboxStore, for example.
+ */
return TRUE;
}
* Return value: whether or not the disconnection succeeded without
* errors. (Consult @ex if %FALSE.)
**/
-gboolean
-camel_service_disconnect (CamelService *service, CamelException *ex)
-{
- return CSERV_CLASS (service)->disconnect (service, ex);
-}
-
-
-static gboolean
-is_connected (CamelService *service)
-{
- return service->connected;
-}
+/**
+ *gboolean
+ *camel_service_disconnect (CamelService *service, CamelException *ex)
+ *{
+ * if (service->connect_level < 1) {
+ * camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
+ * "Trying to disconnect from a service that isn't connected");
+ * return FALSE;
+ * }
+ *
+ * return CSERV_CLASS (service)->disconnect (service, ex);
+ *}
+ **/
+/**
+ *static gboolean
+ *is_connected (CamelService *service)
+ *{
+ * return (service->connect_level > 0);
+ *}
+ **/
/**
* camel_service_is_connected:
*
* Return value: whether or not the service is connected
**/
-gboolean
-camel_service_is_connected (CamelService *service)
-{
- return CSERV_CLASS (service)->is_connected (service);
-}
-
+/**
+ *gboolean
+ *camel_service_is_connected (CamelService *service)
+ *{
+ * return CSERV_CLASS (service)->is_connected (service);
+ *}
+ **/
/**
* camel_service_get_url:
GList *
-query_auth_types (CamelService *service, CamelException *ex)
+query_auth_types_func (CamelService *service, CamelException *ex)
{
return NULL;
}
GList *
camel_service_query_auth_types (CamelService *service, CamelException *ex)
{
- return CSERV_CLASS (service)->query_auth_types (service, ex);
+ if (service->connected)
+ return CSERV_CLASS (service)->query_auth_types_connected (service, ex);
+ else
+ return CSERV_CLASS (service)->query_auth_types_generic (service, ex);
}
gboolean (*disconnect) (CamelService *service,
CamelException *ex);
- gboolean (*is_connected) (CamelService *service);
+ /*gboolean (*is_connected) (CamelService *service);*/
- GList * (*query_auth_types) (CamelService *service,
- CamelException *ex);
+ GList * (*query_auth_types_connected) (CamelService *service,
+ CamelException *ex);
+ GList * (*query_auth_types_generic) (CamelService *service,
+ CamelException *ex);
void (*free_auth_types) (CamelService *service,
GList *authtypes);
CamelURL *url,
CamelException *ex);
-gboolean camel_service_connect (CamelService *service,
- CamelException *ex);
-gboolean camel_service_disconnect (CamelService *service,
- CamelException *ex);
-gboolean camel_service_is_connected (CamelService *service);
-
char * camel_service_get_url (CamelService *service);
char * camel_service_get_name (CamelService *service,
gboolean brief);
char *name;
CamelFolder *folder = NULL;
- if (!camel_service_is_connected (CAMEL_SERVICE (store)))
- camel_service_connect (CAMEL_SERVICE (store), ex);
-
name = CS_CLASS (store)->get_folder_name (store, folder_name, ex);
if (name) {
folder = get_folder_internal (store, name, create, ex);
static gboolean imap_create (CamelFolder *folder, CamelException *ex);
static gboolean imap_connect (CamelService *service, CamelException *ex);
static gboolean imap_disconnect (CamelService *service, CamelException *ex);
-static GList *query_auth_types (CamelService *service, CamelException *ex);
+static GList *query_auth_types_generic (CamelService *service, CamelException *ex);
+static GList *query_auth_types_connected (CamelService *service, CamelException *ex);
static void free_auth_types (CamelService *service, GList *authtypes);
static char *get_name (CamelService *service, gboolean brief);
static CamelFolder *get_folder (CamelStore *store, const char *folder_name, gboolean create,
/* virtual method overload */
camel_service_class->connect = imap_connect;
camel_service_class->disconnect = imap_disconnect;
- camel_service_class->query_auth_types = query_auth_types;
+ camel_service_class->query_auth_types_generic = query_auth_types_generic;
+ camel_service_class->query_auth_types_connected = query_auth_types_connected;
camel_service_class->free_auth_types = free_auth_types;
camel_service_class->get_name = get_name;
static void
finalize (CamelObject *object)
{
- CamelException ex;
-
- camel_exception_init (&ex);
- imap_disconnect (CAMEL_SERVICE (object), &ex);
- camel_exception_clear (&ex);
+ /* Done for us now */
+ /*
+ *CamelException ex;
+ *
+ *camel_exception_init (&ex);
+ *imap_disconnect (CAMEL_SERVICE (object), &ex);
+ *camel_exception_clear (&ex);
+ */
}
static CamelServiceAuthType password_authtype = {
#endif
static GList *
-query_auth_types (CamelService *service, CamelException *ex)
+query_auth_types_connected (CamelService *service, CamelException *ex)
{
+#if 0
GList *ret = NULL;
gboolean passwd = TRUE;
-#if 0
+
if (service->url) {
passwd = try_connect (service, ex);
if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE)
return NULL;
}
-#endif
+
if (passwd)
ret = g_list_append (ret, &password_authtype);
}
return ret;
+#else
+ g_warning ("imap::query_auth_types_connected: not implemented. Defaulting.");
+ return query_auth_types_generic (service, ex);
+#endif
+}
+
+static GList *
+query_auth_types_generic (CamelService *service, CamelException *ex)
+{
+ return g_list_append (NULL, &password_authtype);
}
static void
char *result;
int status;
- if (!service->connected)
- return TRUE;
-
+
+ /*if (!service->connected)
+ * return TRUE;
+ */
+
/* send the logout command */
status = camel_imap_command_extended (CAMEL_IMAP_STORE (service), NULL, &result, "LOGOUT");
if (status != CAMEL_IMAP_OK) {
{
CamelNNTPStore *store = CAMEL_NNTP_STORE (service);
- if (!service->connected)
- return TRUE;
+ /*if (!service->connected)
+ * return TRUE;
+ */
camel_nntp_command (store, NULL, "QUIT");
static void
finalize (CamelObject *object)
{
- CamelException ex;
-
- camel_exception_init (&ex);
- nntp_store_disconnect (CAMEL_SERVICE (object), &ex);
- camel_exception_clear (&ex);
+ /* Done for us now */
+ /*CamelException ex;
+ *
+ *camel_exception_init (&ex);
+ *nntp_store_disconnect (CAMEL_SERVICE (object), &ex);
+ *camel_exception_clear (&ex);
+ */
}
static void
static gboolean pop3_connect (CamelService *service, CamelException *ex);
static gboolean pop3_disconnect (CamelService *service, CamelException *ex);
-static GList *query_auth_types (CamelService *service, CamelException *ex);
+static GList *query_auth_types_connected (CamelService *service, CamelException *ex);
+static GList *query_auth_types_generic (CamelService *service, CamelException *ex);
static void free_auth_types (CamelService *service, GList *authtypes);
static char *get_name (CamelService *service, gboolean brief);
/* virtual method overload */
camel_service_class->connect = pop3_connect;
camel_service_class->disconnect = pop3_disconnect;
- camel_service_class->query_auth_types = query_auth_types;
+ camel_service_class->query_auth_types_connected = query_auth_types_connected;
+ camel_service_class->query_auth_types_generic = query_auth_types_generic;
camel_service_class->free_auth_types = free_auth_types;
camel_service_class->get_name = get_name;
finalize (CamelObject *object)
{
CamelPop3Store *pop3_store = CAMEL_POP3_STORE (object);
- CamelException ex;
+ /*CamelException ex;*/
- camel_exception_init (&ex);
- pop3_disconnect (CAMEL_SERVICE (object), &ex);
- camel_exception_clear (&ex);
+ /*camel_exception_init (&ex);
+ *pop3_disconnect (CAMEL_SERVICE (object), &ex);
+ *camel_exception_clear (&ex);
+ */
if (pop3_store->apop_timestamp)
g_free (pop3_store->apop_timestamp);
}
static GList *
-query_auth_types (CamelService *service, CamelException *ex)
+query_auth_types_connected (CamelService *service, CamelException *ex)
{
CamelPop3Store *store = CAMEL_POP3_STORE (service);
GList *ret = NULL;
return ret;
}
+static GList *
+query_auth_types_generic (CamelService *service, CamelException *ex)
+{
+ GList *ret;
+
+ ret = g_list_append (NULL, &password_authtype);
+ ret = g_list_append (ret, &apop_authtype);
+#ifdef HAVE_KRB4
+ ret = g_list_append (ret, &kpop_authtype);
+#endif
+
+ return ret;
+}
+
static void
free_auth_types (CamelService *service, GList *authtypes)
{
{
CamelService *service = CAMEL_SERVICE (store);
- if (!camel_service_is_connected (service)) {
- if (!camel_service_connect (service, ex))
- return NULL;
- }
+ /* if (!camel_service_is_connected (service)) {
+ * if (!camel_service_connect (service, ex))
+ * return NULL;
+ *}
+ */
+
return camel_pop3_folder_new (store, ex);
}
va_list ap;
if (!store->ostream) {
- CamelException ex;
-
- camel_exception_init (&ex);
- if (!camel_service_connect (CAMEL_SERVICE (store), &ex)) {
- if (ret)
- *ret = g_strdup (camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
- return CAMEL_POP3_FAIL;
- }
+ /*CamelException ex;
+ *
+ *camel_exception_init (&ex);
+ *if (!camel_service_connect (CAMEL_SERVICE (store), &ex)) {
+ * if (ret)
+ * *ret = g_strdup (camel_exception_get_description (&ex));
+ * camel_exception_clear (&ex);
+ */
+
+ return CAMEL_POP3_FAIL;
+ /*}*/
}
va_start (ap, fmt);
static gboolean smtp_connect (CamelService *service, CamelException *ex);
static gboolean smtp_disconnect (CamelService *service, CamelException *ex);
static GList *esmtp_get_authtypes(gchar *buffer);
-static GList *query_auth_types (CamelService *service, CamelException *ex);
+static GList *query_auth_types_connected (CamelService *service, CamelException *ex);
+static GList *query_auth_types_generic (CamelService *service, CamelException *ex);
static void free_auth_types (CamelService *service, GList *authtypes);
static char *get_name (CamelService *service, gboolean brief);
static gchar *smtp_get_email_addr_from_text (gchar *text);
/* virtual method overload */
camel_service_class->connect = smtp_connect;
camel_service_class->disconnect = smtp_disconnect;
- camel_service_class->query_auth_types = query_auth_types;
+ camel_service_class->query_auth_types_generic = query_auth_types_generic;
+ camel_service_class->query_auth_types_connected = query_auth_types_connected;
camel_service_class->free_auth_types = free_auth_types;
camel_service_class->get_name = get_name;
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
- if (!service->connected)
- return TRUE;
+ /*if (!service->connected)
+ * return TRUE;
+ */
/* send the QUIT command to the SMTP server */
smtp_quit(transport, ex);
#endif
static GList *
-query_auth_types (CamelService *service, CamelException *ex)
+query_auth_types_connected (CamelService *service, CamelException *ex)
+{
+ /* FIXME: Re-enable this when auth types are actually
+ * implemented.
+ */
+
+ return NULL;
+}
+
+static GList *
+query_auth_types_generic (CamelService *service, CamelException *ex)
{
/* FIXME: Re-enable this when auth types are actually
* implemented.