Changeset 5027:e9451c4c0092

Show
Ignore:
Timestamp:
2007-03-30 19:22:55 (22 months ago)
Author:
Brendan Cully <brendan@…>
Branch:
default
Message:

Add function pointer for close hook in Context.
Slowly inch towards function pointers instead of switch statements.

Files:
4 modified

Legend:

Unmodified
Added
Removed
  • imap/imap.c

    r5026 r5027  
    570570  /* once again the context is new */ 
    571571  ctx->data = idata; 
     572  ctx->mx_close = imap_close_mailbox; 
    572573 
    573574  /* Clean up path and replace the one in the ctx */ 
  • mutt.h

    r5011 r5027  
    857857}; 
    858858 
    859 typedef struct 
     859typedef struct _context 
    860860{ 
    861861  char *path; 
     
    883883  int flagged;                  /* how many flagged messages */ 
    884884  int msgnotreadyet;            /* which msg "new" in pager, -1 if none */ 
    885 #if defined USE_POP || defined USE_IMAP 
    886   void *data;                   /* driver specific data */ 
    887 #endif /* USE_IMAP */ 
    888885 
    889886  short magic;                  /* mailbox type */ 
     
    899896  unsigned int collapsed : 1;   /* are all threads collapsed? */ 
    900897  unsigned int closing : 1;     /* mailbox is being closed */ 
     898 
     899  /* driver hooks */ 
     900  void *data;                   /* driver specific data */ 
     901  int (*mx_close)(struct _context *); 
    901902} CONTEXT; 
    902903 
  • mx.c

    r5016 r5027  
    741741  if(!ctx)  
    742742    return; 
    743    
    744 #ifdef USE_IMAP 
    745   if (ctx->magic == M_IMAP) 
    746     imap_close_mailbox (ctx); 
    747 #endif /* USE_IMAP */ 
    748 #ifdef USE_POP 
    749   if (ctx->magic == M_POP) 
    750     pop_close_mailbox (ctx); 
    751 #endif /* USE_POP */ 
     743 
     744  if (ctx->mx_close) 
     745    ctx->mx_close (ctx); 
     746 
    752747  if (ctx->subj_hash) 
    753748    hash_destroy (&ctx->subj_hash, NULL); 
  • pop.c

    r4886 r5027  
    373373  pop_data->conn = conn; 
    374374  ctx->data = pop_data; 
     375  ctx->mx_close = pop_close_mailbox; 
    375376 
    376377  if (pop_open_connection (pop_data) < 0)