diff options
Diffstat (limited to 'camel/providers')
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 46 | ||||
-rw-r--r-- | camel/providers/local/camel-local-folder.c | 63 |
2 files changed, 108 insertions, 1 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 076066782f..1855ce2e8b 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -76,6 +76,8 @@ static CamelDiscoFolderClass *disco_folder_class = NULL; static void imap_finalize (CamelObject *object); +static int imap_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args); + static void imap_rescan (CamelFolder *folder, int exists, CamelException *ex); static void imap_refresh_info (CamelFolder *folder, CamelException *ex); static void imap_sync_online (CamelFolder *folder, CamelException *ex); @@ -119,6 +121,8 @@ static void imap_search_free (CamelFolder *folder, GPtrArray *uid static void imap_thaw (CamelFolder *folder); +static CamelObjectClass *parent_class; + GData *parse_fetch_response (CamelImapFolder *imap_folder, char *msg_att); static void @@ -130,6 +134,8 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class) disco_folder_class = CAMEL_DISCO_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_disco_folder_get_type ())); /* virtual method overload */ + ((CamelObjectClass *)camel_imap_folder_class)->getv = imap_getv; + camel_folder_class->get_message = imap_get_message; camel_folder_class->rename = imap_rename; camel_folder_class->search_by_expression = imap_search_by_expression; @@ -180,8 +186,9 @@ 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 = - camel_type_register (CAMEL_DISCO_FOLDER_TYPE, "CamelImapFolder", + camel_type_register (parent_class, "CamelImapFolder", sizeof (CamelImapFolder), sizeof (CamelImapFolderClass), (CamelObjectClassInitFunc) camel_imap_folder_class_init, @@ -387,6 +394,43 @@ imap_finalize (CamelObject *object) g_free(imap_folder->priv); } +static int +imap_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args) +{ + CamelFolder *folder = (CamelFolder *)object; + int i, count=args->argc; + guint32 tag; + + for (i=0;i<args->argc;i++) { + CamelArgGet *arg = &args->argv[i]; + + tag = arg->tag; + + switch (tag & CAMEL_ARG_TAG) { + /* CamelObject args */ + case CAMEL_OBJECT_ARG_DESCRIPTION: + if (folder->description == NULL) { + CamelURL *uri = ((CamelService *)folder->parent_store)->url; + + /* what if the full name doesn't incclude /'s? does it matter? */ + folder->description = g_strdup_printf("%s@%s:%s", uri->user, uri->host, folder->full_name); + } + *arg->ca_str = folder->description; + break; + default: + count--; + continue; + } + + arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE; + } + + if (count) + return ((CamelObjectClass *)parent_class)->getv(object, ex, args); + + return 0; +} + static void imap_rename (CamelFolder *folder, const char *new) { diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c index 3ae6c74873..c12e9d5da7 100644 --- a/camel/providers/local/camel-local-folder.c +++ b/camel/providers/local/camel-local-folder.c @@ -65,6 +65,8 @@ static CamelFolderClass *parent_class = NULL; #define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) #define CLOCALS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +static int local_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args); + static int local_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex); static void local_unlock(CamelLocalFolder *lf); @@ -83,12 +85,15 @@ static void camel_local_folder_class_init(CamelLocalFolderClass * camel_local_folder_class) { CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS(camel_local_folder_class); + CamelObjectClass *oklass = (CamelObjectClass *)camel_local_folder_class; parent_class = CAMEL_FOLDER_CLASS(camel_type_get_global_classfuncs(camel_folder_get_type())); /* virtual method definition */ /* virtual method overload */ + oklass->getv = local_getv; + camel_folder_class->sync = local_sync; camel_folder_class->expunge = local_expunge; @@ -297,6 +302,64 @@ int camel_local_folder_unlock(CamelLocalFolder *lf) } static int +local_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args) +{ + CamelFolder *folder = (CamelFolder *)object; + int i, count=args->argc; + guint32 tag; + + for (i=0;i<args->argc;i++) { + CamelArgGet *arg = &args->argv[i]; + + tag = arg->tag; + + switch (tag & CAMEL_ARG_TAG) { + /* CamelObject args */ + case CAMEL_OBJECT_ARG_DESCRIPTION: + if (folder->description == NULL) { + char *tmp, *path; + + /* check some common prefixes to shorten the name */ + tmp = ((CamelService *)folder->parent_store)->url->path; + if (tmp == NULL) + goto skip; + + path = alloca(strlen(tmp)+strlen(folder->full_name)+1); + sprintf(path, "%s/%s", tmp, folder->full_name); + + if ((tmp = getenv("HOME")) && strncmp(tmp, path, strlen(tmp)) == 0) + /* $HOME relative path + protocol string */ + folder->description = g_strdup_printf(_("~%s (%s)"), path+strlen(tmp), + ((CamelService *)folder->parent_store)->url->protocol); + else if ((tmp = "/var/spool/mail") && strncmp(tmp, path, strlen(tmp)) == 0) + /* /var/spool/mail relative path + protocol */ + folder->description = g_strdup_printf(_("mailbox:%s (%s)"), path+strlen(tmp), + ((CamelService *)folder->parent_store)->url->protocol); + else if ((tmp = "/var/mail") && strncmp(tmp, path, strlen(tmp)) == 0) + folder->description = g_strdup_printf(_("mailbox:%s (%s)"), path+strlen(tmp), + ((CamelService *)folder->parent_store)->url->protocol); + else + /* a full path + protocol */ + folder->description = g_strdup_printf(_("%s (%s)"), path, + ((CamelService *)folder->parent_store)->url->protocol); + } + *arg->ca_str = folder->description; + break; + default: skip: + count--; + continue; + } + + arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE; + } + + if (count) + return ((CamelObjectClass *)parent_class)->getv(object, ex, args); + + return 0; +} + +static int local_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex) { return 0; |