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/smapcreate.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/smapcreate.C')
| -rw-r--r-- | libmail/smapcreate.C | 153 | 
1 files changed, 153 insertions, 0 deletions
| diff --git a/libmail/smapcreate.C b/libmail/smapcreate.C new file mode 100644 index 0000000..98058a2 --- /dev/null +++ b/libmail/smapcreate.C @@ -0,0 +1,153 @@ +/* +** Copyright 2003-2004, Double Precision Inc. +** +** See COPYING for distribution information. +*/ +#include "smap.H" +#include "misc.H" +#include "smapcreate.H" +#include <errno.h> +#include <stdio.h> + +using namespace std; + +//////////////////////////////////////////////////////////////////////// +// +// CREATE + +const char *mail::smapCREATE::getName() +{ +	return "CREATE"; +} + +mail::smapCREATE::smapCREATE(string pathArg, +			     string name, +			     bool createDirectoryArg, +			     mail::callback::folderList &listCallbackArg, +			     mail::callback &callbackArg) +	 +	: path(pathArg), +	  createDirectory(createDirectoryArg), +	  renameFolder(false), +	  listCallback(&listCallbackArg) +{ +	defaultCB= &callbackArg; +	if (path.size() > 0) +		path += "/"; + +	name=toutf8(name); + +	vector<const char *> w; + +	w.push_back(name.c_str()); + +	path += words2path(w); +} + +mail::smapCREATE::smapCREATE(string oldPathArg, +			     string pathArg, +			     string name, +			     mail::callback::folderList &listCallbackArg, +			     mail::callback &callbackArg) +	: oldPath(oldPathArg), +	  path(pathArg), +	  createDirectory(false), +	  renameFolder(true), +	  listCallback(&listCallbackArg) +{ +	defaultCB= &callbackArg; +	if (path.size() > 0) +		path += "/"; + +	name=toutf8(name); + +	vector<const char *> w; + +	w.push_back(name.c_str()); + +	path += words2path(w); +} + +mail::smapCREATE::smapCREATE(string pathArg, +			     bool createDirectoryArg, +			     mail::callback &callbackArg) +	 +	: path(pathArg), +	  createDirectory(createDirectoryArg), +	  renameFolder(false), +	  listCallback(NULL) +{ +	defaultCB= &callbackArg; +} + +mail::smapCREATE::~smapCREATE() +{ +} + +void mail::smapCREATE::installed(imap &imapAccount) +{ +	vector<string> oldPathWords; +	vector<string> words; + +	path2words(oldPath, oldPathWords); + +	path2words(path, words); + +	vector<string>::iterator b, e; + +	string pstr=""; + +	if (renameFolder) +	{ +		b=oldPathWords.begin(); +		e=oldPathWords.end(); + +		while (b != e) +		{ +			pstr += " "; +			pstr += imapAccount.quoteSMAP( *b ); +			b++; +		} + +		pstr += " \"\""; +	} + +	b=words.begin(); +	e=words.end(); + +	while (b != e) +	{ +		pstr += " "; +		pstr += imapAccount.quoteSMAP( *b ); +		b++; +	} + +	imapAccount.imapcmd("", (renameFolder ? "RENAME": +				 createDirectory ? "MKDIR":"CREATE") +			    + pstr + "\n"); +} + +bool mail::smapCREATE::ok(std::string okMsg) +{ +	if (listCallback) +	{ +		size_t n=path.rfind('/'); + +		string name= n == std::string::npos ? path:path.substr(n+1); + +		vector<string> words; + +		path2words(name, words); + +		mail::imapFolder f( *myimap, path, "", fromutf8(words[0]), 0); + +		f.hasMessages(!createDirectory); +		f.hasSubFolders(createDirectory); + +		vector<const mail::folder *> a; + +		a.push_back(&f); +		listCallback->success(a); +	} +	return smapHandler::ok(okMsg); +} | 
