Back to index

courier  0.68.2
Classes | Functions
storeinfo.h File Reference
#include "imaptoken.h"
#include "numlib/numlib.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  storeinfo
struct  do_copy_info
struct  copyquotainfo

Functions

int storeinfo_init (struct storeinfo *)
int do_store (unsigned long, int, void *)
int do_copy_message (unsigned long, int, void *)
int do_copy_quota_calc (unsigned long, int, void *)

Class Documentation

struct storeinfo

Definition at line 13 of file storeinfo.h.

Collaboration diagram for storeinfo:
Class Members
struct libmail_kwMessage * keywords
int plusminus
int silent
struct do_copy_info

Definition at line 28 of file storeinfo.h.

Collaboration diagram for do_copy_info:
Class Members
const char * acls
const char * mailbox
struct uidplus_info * uidplus_list
struct uidplus_info ** uidplus_tail
struct copyquotainfo

Definition at line 40 of file storeinfo.h.

Class Members
const char * acls
char * destmailbox
int64_t nbytes
int nfiles

Function Documentation

int do_copy_message ( unsigned  long,
int  ,
void *   
)

Definition at line 429 of file storeinfo.c.

{
       struct do_copy_info *cpy_info=(struct do_copy_info *)voidptr;
       int    fd;
       struct imapflags new_flags;

       --n;
       fd=imapscan_openfile(current_mailbox, &current_maildir_info, n);
       if (fd < 0)   return (0);
       get_message_flags(current_maildir_info.msgs+n, 0, &new_flags);

       if (copy_message(fd, cpy_info, &new_flags,

                      acl_flags_adjust(cpy_info->acls,
                                     &new_flags) ? NULL
                      : current_maildir_info.msgs[n].keywordMsg,
                      current_maildir_info.msgs[n].uid))
       {
              close(fd);
              return (-1);
       }
       close(fd);
       current_maildir_info.msgs[n].copiedflag=1;
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int do_copy_quota_calc ( unsigned  long,
int  ,
void *   
)

Definition at line 455 of file storeinfo.c.

{
struct copyquotainfo *info=(struct copyquotainfo *)voidptr;
const char *filename;
unsigned long nbytes;
struct stat   stat_buf;
int    fd;
struct imapflags flags;
char *ff;

       --n;

       fd=imapscan_openfile(current_mailbox, &current_maildir_info, n);
       if (fd < 0)   return (0);
       filename=current_maildir_info.msgs[n].filename;

       get_message_flags(&current_maildir_info.msgs[n], NULL, &flags);

       (void)acl_flags_adjust(info->acls, &flags);

       ff=get_reflagged_filename(filename, &flags);

       if (maildirquota_countfile(ff))
       {
              if (maildir_parsequota(ff, &nbytes))
              {
                     if (fstat(fd, &stat_buf) < 0)
                     {
                            close(fd);
                            free(ff);
                            return (0);
                     }
                     nbytes=stat_buf.st_size;
              }
              info->nbytes += nbytes;
              info->nfiles += 1;
       }
       close(fd);
       free(ff);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int do_store ( unsigned  long,
int  ,
void *   
)

Definition at line 119 of file storeinfo.c.

{
struct storeinfo *si=(struct storeinfo *)voidptr;
int    fd;
 struct imapflags new_flags, old_flags;
int changedKeywords;
struct libmail_kwMessageEntry *kme;
int kwAllowed=1;

       --n;
       fd=imapscan_openfile(current_mailbox, &current_maildir_info, n);
       if (fd < 0)   return (0);

       changedKeywords=0;
       get_message_flags(current_maildir_info.msgs+n, 0, &new_flags);

       old_flags=new_flags;

       if (current_mailbox_acl)
       {
              if (strchr(current_mailbox_acl, ACL_WRITE[0]) == NULL)
                     kwAllowed=0;
       }


       if (si->plusminus == '+')
       {
              if (si->flags.drafts)       new_flags.drafts=1;
              if (si->flags.seen)  new_flags.seen=1;
              if (si->flags.answered)     new_flags.answered=1;
              if (si->flags.deleted)      new_flags.deleted=1;
              if (si->flags.flagged)      new_flags.flagged=1;

              for (kme=si->keywords ? si->keywords->firstEntry:NULL;
                   kme; kme=kme->next)
              {
                     int rc;

                     if (!kwAllowed)
                     {
                            current_maildir_info.msgs[n].changedflags=1;
                            continue;
                     }

                     imapscan_createKeyword(&current_maildir_info, n);

                     if ((rc=libmail_kwmSet(current_maildir_info.msgs[n]
                                          .keywordMsg,
                                          kme->libmail_keywordEntryPtr))
                         < 0)
                     {
                            write_error_exit(0);
                            return 0;
                     }

                     if (rc == 0)
                     {
                            if (fastkeywords())
                                   changedKeywords=1;
                            current_maildir_info.msgs[n].changedflags=1;
                     }
              }
       }
       else if (si->plusminus == '-')
       {
              if (si->flags.drafts)       new_flags.drafts=0;
              if (si->flags.seen)  new_flags.seen=0;
              if (si->flags.answered)     new_flags.answered=0;
              if (si->flags.deleted)      new_flags.deleted=0;
              if (si->flags.flagged)      new_flags.flagged=0;

              if (current_maildir_info.msgs[n].keywordMsg && kwAllowed)
                     for (kme=si->keywords ?
                                 si->keywords->firstEntry:NULL;
                          kme; kme=kme->next)
                     {
                            if (!kwAllowed)
                            {
                                   current_maildir_info.msgs[n]
                                          .changedflags=1;
                                   continue;
                            }

                            if (libmail_kwmClear(current_maildir_info.msgs[n]
                                           .keywordMsg,
                                           kme->libmail_keywordEntryPtr)==0)
                            {
                                   if (fastkeywords())
                                          changedKeywords=1;
                                   current_maildir_info.msgs[n]
                                          .changedflags=1;
                            }
                     }

              if (current_maildir_info.msgs[n].keywordMsg &&
                  !current_maildir_info.msgs[n].keywordMsg->firstEntry)
              {
                     libmail_kwmDestroy(current_maildir_info.msgs[n]
                                         .keywordMsg);
                     current_maildir_info.msgs[n].keywordMsg=NULL;
              }
       }
       else
       {
              struct libmail_kwMessage *kw;

              new_flags=si->flags;

              kw=current_maildir_info.msgs[n].keywordMsg;

              if (kw && kw->firstEntry == NULL)
                     kw=NULL;

              if (si->keywords && si->keywords->firstEntry == NULL)
                     si->keywords=NULL;

              if ((si->keywords && !kw) ||
                  (!si->keywords && kw) ||
                  (si->keywords && kw && libmail_kwmCmp(si->keywords, kw)))
              {
                     if (kwAllowed)
                     {
                            kw=current_maildir_info.msgs[n].keywordMsg;

                            if (kw)
                                   libmail_kwmDestroy(kw);

                            current_maildir_info.msgs[n].keywordMsg=NULL;

                            if (si->keywords && si->keywords->firstEntry)
                            {
                                   struct libmail_kwMessageEntry *kme;

                                   kw=imapscan_createKeyword(&current_maildir_info,
                                                          n);

                                   for (kme=si->keywords->lastEntry; kme;
                                        kme=kme->prev)
                                          if (libmail_kwmSet(kw,
                                                           kme->libmail_keywordEntryPtr)
                                              < 0)
                                                 write_error_exit(0);
                                   current_maildir_info.msgs[n].keywordMsg=kw;
                            }
                     }

                     changedKeywords=1;
              }
       }

       if (current_mailbox_acl)
       {
              if (strchr(current_mailbox_acl, ACL_WRITE[0]) == NULL)
              {
                     new_flags.drafts=old_flags.drafts;
                     new_flags.answered=old_flags.answered;
                     new_flags.flagged=old_flags.flagged;
              }

              if (strchr(current_mailbox_acl, ACL_SEEN[0]) == NULL)
              {
                     new_flags.seen=old_flags.seen;
              }

              if (strchr(current_mailbox_acl, ACL_DELETEMSGS[0])
                  == NULL)
              {
                     new_flags.deleted=old_flags.deleted;
              }
       }

       if (changedKeywords)
       {
              current_maildir_info.msgs[n].changedflags=1;
              if (imapscan_updateKeywords(current_maildir_info.msgs[n]
                                       .filename,
                                       current_maildir_info.msgs[n]
                                       .keywordMsg))
              {
                     close(fd);
                     return -1;
              }
       }

       if (reflag_filename(current_maildir_info.msgs+n, &new_flags, fd))
       {
              close(fd);
              return (-1);
       }
       close(fd);
       if (si->silent)
              current_maildir_info.msgs[n].changedflags=0;
       else
       {
#if SMAP
              /* SMAP flag notification is handled elsewhere */

              if (!smapflag)
#endif
              {
                     if (byuid)
                            fetchflags_byuid(n);
                     else
                            fetchflags(n);
              }
       }

       return (0);
}

Here is the call graph for this function:

int storeinfo_init ( struct storeinfo )

Definition at line 69 of file storeinfo.c.

{
struct imaptoken *t=currenttoken();
const char *p;

       if (t->tokentype != IT_ATOM)       return (-1);
       si->plusminus=0;
       si->silent=0;

       p=t->tokenbuf;
       if (*p == '+' || *p == '-')
              si->plusminus= *p++;
       if (strncmp(p, "FLAGS", 5)) return (-1);
       p += 5;
       if (*p)
       {
              if (strcmp(p, ".SILENT"))   return (-1);
              si->silent=1;
       }

       memset(&si->flags, 0, sizeof(si->flags));

       if ((si->keywords=libmail_kwmCreate()) == NULL)
              write_error_exit(0);

       t=nexttoken_noparseliteral();
       if (t->tokentype == IT_LPAREN)
       {
              if (get_flagsAndKeywords(&si->flags, &si->keywords))
              {
                     libmail_kwmDestroy(si->keywords);
                     si->keywords=NULL;
                     return (-1);
              }
              nexttoken();
       }
       else if (t->tokentype == IT_NIL)
              nexttoken();
       else if (t->tokentype == IT_ATOM)
       {
              if (get_flagname(t->tokenbuf, &si->flags))
                     libmail_kwmSetName(current_maildir_info
                                   .keywordList,
                                   si->keywords,
                                   t->tokenbuf);
              nexttoken();
       }
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function: