diff options
| author | Sam Varshavchik | 2013-08-19 16:39:41 -0400 |
|---|---|---|
| committer | Sam Varshavchik | 2013-08-25 14:43:51 -0400 |
| commit | 9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch) | |
| tree | 7a81a04cb51efb078ee350859a64be2ebc6b8813 /libmail/smapacl.C | |
| parent | a9520698b770168d1f33d6301463bb70a19655ec (diff) | |
| download | courier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2 | |
Initial checkin
Imported from subversion report, converted to git. Updated all paths in
scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'libmail/smapacl.C')
| -rw-r--r-- | libmail/smapacl.C | 211 |
1 files changed, 211 insertions, 0 deletions
diff --git a/libmail/smapacl.C b/libmail/smapacl.C new file mode 100644 index 0000000..0dd59c9 --- /dev/null +++ b/libmail/smapacl.C @@ -0,0 +1,211 @@ +/* +** Copyright 2004, Double Precision Inc. +** +** See COPYING for distribution information. +*/ +#include "smap.H" +#include "smapacl.H" +#include <errno.h> +#include <stdio.h> + +using namespace std; + +//////////////////////////////////////////////////////////////////////// +// +// ACL + +const char *mail::smapACL::getName() +{ + return "ACL"; +} + +mail::smapACL::smapACL(string folderNameArg, + string &rightsArg, + mail::callback &getCallbackArg) + : folderName(folderNameArg), + rights(rightsArg) +{ + defaultCB= &getCallbackArg; +} + +mail::smapACL::~smapACL() +{ +} + +void mail::smapACL::installed(imap &imapAccount) +{ + vector<string> folderPathWords; + vector<string>::iterator b, e; + + string pstr=""; + + path2words(folderName, folderPathWords); + + b=folderPathWords.begin(); + e=folderPathWords.end(); + + while (b != e) + { + pstr += " "; + pstr += imapAccount.quoteSMAP( *b ); + b++; + } + + + imapAccount.imapcmd("", "ACL" + pstr + "\n"); +} + +bool mail::smapACL::processLine(imap &imapAccount, + vector<const char *> &words) +{ + if (words.size() >= 3 && strcmp(words[0], "*") == 0 && + strcasecmp(words[1], "ACL") == 0) + { + rights=words[2]; + return true; + } + + return smapHandler::processLine(imapAccount, words); +} + +//////////////////////////////////////////////////////////////////////// +// +// GETACL + +const char *mail::smapGETACL::getName() +{ + return "GETACL"; +} + +mail::smapGETACL::smapGETACL(string folderNameArg, + list<pair<string, string> > &rightsArg, + mail::callback &getCallbackArg) + : folderName(folderNameArg), + rights(rightsArg) +{ + defaultCB= &getCallbackArg; +} + +mail::smapGETACL::~smapGETACL() +{ +} + +void mail::smapGETACL::installed(imap &imapAccount) +{ + vector<string> folderPathWords; + vector<string>::iterator b, e; + + string pstr=""; + + path2words(folderName, folderPathWords); + + b=folderPathWords.begin(); + e=folderPathWords.end(); + + while (b != e) + { + pstr += " "; + pstr += imapAccount.quoteSMAP( *b ); + b++; + } + + + imapAccount.imapcmd("", "GETACL" + pstr + "\n"); +} + +bool mail::smapGETACL::processLine(imap &imapAccount, + vector<const char *> &words) +{ + if (words.size() >= 2 && strcmp(words[0], "*") == 0 && + strcasecmp(words[1], "GETACL") == 0) + { + vector<const char *>::iterator + b=words.begin()+2, e=words.end(); + + while (b != e) + { + string identifier= *b++; + + if (b != e) + { + string rightsW= *b++; + + rights.push_back(make_pair(identifier, + rightsW)); + } + } + return true; + } + + return smapHandler::processLine(imapAccount, words); +} + +//////////////////////////////////////////////////////////////////////// +// +// SETACL + +const char *mail::smapSETACL::getName() +{ + return "SETACL"; +} + +mail::smapSETACL::smapSETACL(string folderNameArg, + string identifierArg, + string rightsArg, + bool delIdentifierArg, + string &errorIdentifierArg, + vector<string> &errorRightsArg, + mail::callback &callbackArg) + : folderName(folderNameArg), + identifier(identifierArg), + rights(rightsArg), + delIdentifier(delIdentifierArg), + errorIdentifier(errorIdentifierArg), + errorRights(errorRightsArg) +{ + defaultCB= &callbackArg; +} + +mail::smapSETACL::~smapSETACL() +{ +} + +void mail::smapSETACL::installed(imap &imapAccount) +{ + vector<string> folderPathWords; + vector<string>::iterator b, e; + + string pstr=""; + + path2words(folderName, folderPathWords); + + b=folderPathWords.begin(); + e=folderPathWords.end(); + + while (b != e) + { + pstr += " "; + pstr += imapAccount.quoteSMAP( *b ); + b++; + } + + + imapAccount.imapcmd("", + (delIdentifier ? + "DELETEACL" + pstr + " \"\" " + + imapAccount.quoteSMAP(identifier): + "SETACL" + pstr + " \"\" " + + imapAccount.quoteSMAP(identifier) + + " " + + imapAccount.quoteSMAP(rights)) + "\n"); +} + +bool mail::smapSETACL::processLine(imap &imapAccount, + vector<const char *> &words) +{ + if (words.size() >= 2 && strcmp(words[0], "*") == 0 && + strcasecmp(words[1], "GETACL") == 0) + return true; // Don't care + + return smapHandler::processLine(imapAccount, words); +} |
