diff options
Diffstat (limited to 'vmime/messaging')
29 files changed, 182 insertions, 162 deletions
diff --git a/vmime/messaging/authenticationInfos.hpp b/vmime/messaging/authenticationInfos.hpp index 2ae35ad4..3682056b 100644 --- a/vmime/messaging/authenticationInfos.hpp +++ b/vmime/messaging/authenticationInfos.hpp @@ -31,7 +31,7 @@ namespace messaging { /** This class encapsulates user credentials. */ -class authenticationInfos +class authenticationInfos : public object { public: diff --git a/vmime/messaging/authenticator.hpp b/vmime/messaging/authenticator.hpp index 374a48e7..3aa4b9ad 100644 --- a/vmime/messaging/authenticator.hpp +++ b/vmime/messaging/authenticator.hpp @@ -21,6 +21,7 @@ #define VMIME_MESSAGING_AUTHENTICATOR_HPP_INCLUDED +#include "vmime/types.hpp" #include "vmime/messaging/authenticationInfos.hpp" @@ -31,7 +32,7 @@ namespace messaging { /** This class is used to obtain user credentials. */ -class authenticator +class authenticator : public object { public: diff --git a/vmime/messaging/defaultAuthenticator.hpp b/vmime/messaging/defaultAuthenticator.hpp index b3f5b811..55d1af42 100644 --- a/vmime/messaging/defaultAuthenticator.hpp +++ b/vmime/messaging/defaultAuthenticator.hpp @@ -29,6 +29,9 @@ namespace vmime { namespace messaging { +class session; + + /** Default implementation for authenticator. It simply returns * the credentials set in the session properties (named 'username' * and 'password'). This is the default implementation used if @@ -39,11 +42,11 @@ class defaultAuthenticator : public authenticator { public: - defaultAuthenticator(const propertySet& props, const string& prefix); + defaultAuthenticator(weak_ref <session> session, const string& prefix); private: - const propertySet& m_props; + weak_ref <session> m_session; const string m_prefix; const authenticationInfos requestAuthInfos() const; diff --git a/vmime/messaging/events.hpp b/vmime/messaging/events.hpp index 93dc9b36..a74d6459 100644 --- a/vmime/messaging/events.hpp +++ b/vmime/messaging/events.hpp @@ -48,13 +48,13 @@ public: }; - messageCountEvent(folder* folder, const Types type, const std::vector <int>& nums); + messageCountEvent(ref <folder> folder, const Types type, const std::vector <int>& nums); /** Return the folder in which messages have been added/removed. * * @return folder in which message count changed */ - const folder* getFolder() const; + ref <const folder> getFolder() const; /** Return the event type. * @@ -76,7 +76,7 @@ public: private: - folder* m_folder; + ref <folder> m_folder; const Types m_type; std::vector <int> m_nums; }; @@ -111,13 +111,13 @@ public: }; - messageChangedEvent(folder* folder, const Types type, const std::vector <int>& nums); + messageChangedEvent(ref <folder> folder, const Types type, const std::vector <int>& nums); /** Return the folder in which messages have changed. * * @return folder in which message count changed */ - const folder* getFolder() const; + ref <const folder> getFolder() const; /** Return the event type. * @@ -139,7 +139,7 @@ public: private: - folder* m_folder; + ref <folder> m_folder; const Types m_type; std::vector <int> m_nums; }; @@ -175,13 +175,13 @@ public: }; - folderEvent(folder* folder, const Types type, const utility::path& oldPath, const utility::path& newPath); + folderEvent(ref <folder> folder, const Types type, const utility::path& oldPath, const utility::path& newPath); /** Return the folder on which the event occured. * * @return folder on which the event occured */ - const folder* getFolder() const; + ref <const folder> getFolder() const; /** Return the event type. * @@ -197,7 +197,7 @@ public: private: - folder* m_folder; + ref <folder> m_folder; const Types m_type; const utility::path m_oldPath; const utility::path m_newPath; diff --git a/vmime/messaging/folder.hpp b/vmime/messaging/folder.hpp index 945c862b..246a0e06 100644 --- a/vmime/messaging/folder.hpp +++ b/vmime/messaging/folder.hpp @@ -45,11 +45,11 @@ class store; /** Abstract representation of a folder in a message store. */ -class folder +class folder : public object { protected: - folder(const folder&) { } + folder(const folder&) : object() { } folder() { } public: @@ -160,7 +160,7 @@ public: * @param num message sequence number * @return a new object referencing the specified message */ - virtual message* getMessage(const int num) = 0; + virtual ref <message> getMessage(const int num) = 0; /** Get new references to messages in this folder. * @@ -168,14 +168,14 @@ public: * @param to sequence number of the last message to get * @return new objects referencing the specified messages */ - virtual std::vector <message*> getMessages(const int from = 1, const int to = -1) = 0; + virtual std::vector <ref <message> > getMessages(const int from = 1, const int to = -1) = 0; /** Get new references to messages in this folder. * * @param nums sequence numbers of the messages to delete * @return new objects referencing the specified messages */ - virtual std::vector <message*> getMessages(const std::vector <int>& nums) = 0; + virtual std::vector <ref <message> > getMessages(const std::vector <int>& nums) = 0; /** Return the number of messages in this folder. * @@ -188,7 +188,7 @@ public: * @param name sub-folder name * @return a new object referencing the specified folder */ - virtual folder* getFolder(const folder::path::component& name) = 0; + virtual ref <folder> getFolder(const folder::path::component& name) = 0; /** Get the list of all sub-folders in this folder. * @@ -196,7 +196,7 @@ public: * If set to false, only the direct children are returned. * @return list of sub-folders */ - virtual std::vector <folder*> getFolders(const bool recursive = false) = 0; + virtual std::vector <ref <folder> > getFolders(const bool recursive = false) = 0; /** Rename (move) this folder to another location. * @@ -247,7 +247,7 @@ public: * @param date date/time for the new message (if NULL, the current time is used) * @param progress progression listener, or NULL if not used */ - virtual void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL) = 0; + virtual void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL) = 0; /** Add a message to this folder. * @@ -296,19 +296,19 @@ public: * * @return parent folder object */ - virtual folder* getParent() = 0; + virtual ref <folder> getParent() = 0; /** Return a reference to the store to which this folder belongs. * * @return the store object to which this folder is attached */ - virtual const store* getStore() const = 0; + virtual weak_ref <const store> getStore() const = 0; /** Return a reference to the store to which this folder belongs. * * @return the store object to which this folder is attached */ - virtual store* getStore() = 0; + virtual weak_ref <store> getStore() = 0; /** Fetchable objects. */ @@ -331,14 +331,14 @@ public: * @param options objects to fetch (combination of folder::FetchOptions flags) * @param progress progression listener, or NULL if not used */ - virtual void fetchMessages(std::vector <message*>& msg, const int options, utility::progressionListener* progress = NULL) = 0; + virtual void fetchMessages(std::vector <ref <message> >& msg, const int options, utility::progressionListener* progress = NULL) = 0; /** Fetch objects for the specified message. * * @param msg the message * @param options objects to fetch (combination of folder::FetchOptions flags) */ - virtual void fetchMessage(message* msg, const int options) = 0; + virtual void fetchMessage(ref <message> msg, const int options) = 0; /** Return the list of fetchable objects supported by * the underlying protocol (see folder::FetchOptions). diff --git a/vmime/messaging/imap/IMAPConnection.hpp b/vmime/messaging/imap/IMAPConnection.hpp index 8cf37933..5ceca567 100644 --- a/vmime/messaging/imap/IMAPConnection.hpp +++ b/vmime/messaging/imap/IMAPConnection.hpp @@ -40,11 +40,11 @@ class IMAPTag; class IMAPStore; -class IMAPConnection +class IMAPConnection : public object { public: - IMAPConnection(IMAPStore* store, authenticator* auth); + IMAPConnection(weak_ref <IMAPStore> store, ref <authenticator> auth); ~IMAPConnection(); @@ -75,31 +75,31 @@ public: IMAPParser::response* readResponse(IMAPParser::literalHandler* lh = NULL); - const IMAPTag* getTag() const; - const IMAPParser* getParser() const; + ref <const IMAPTag> getTag() const; + ref <const IMAPParser> getParser() const; - const IMAPStore* getStore() const; - IMAPStore* getStore(); + weak_ref <const IMAPStore> getStore() const; + weak_ref <IMAPStore> getStore(); - session* getSession(); + ref <session> getSession(); private: - IMAPStore* m_store; + weak_ref <IMAPStore> m_store; - authenticator* m_auth; + ref <authenticator> m_auth; - socket* m_socket; + ref <socket> m_socket; - IMAPParser* m_parser; + ref <IMAPParser> m_parser; - IMAPTag* m_tag; + ref <IMAPTag> m_tag; char m_hierarchySeparator; ProtocolStates m_state; - timeoutHandler* m_timeoutHandler; + ref <timeoutHandler> m_timeoutHandler; void internalDisconnect(); diff --git a/vmime/messaging/imap/IMAPFolder.hpp b/vmime/messaging/imap/IMAPFolder.hpp index 128fea3c..0d803a7f 100644 --- a/vmime/messaging/imap/IMAPFolder.hpp +++ b/vmime/messaging/imap/IMAPFolder.hpp @@ -48,6 +48,7 @@ private: friend class IMAPStore; friend class IMAPMessage; + friend class vmime::creator; // vmime::create <IMAPFolder> IMAPFolder(const folder::path& path, IMAPStore* store, const int type = TYPE_UNDEFINED, const int flags = FLAG_UNDEFINED); @@ -74,13 +75,13 @@ public: const bool isOpen() const; - message* getMessage(const int num); - std::vector <message*> getMessages(const int from = 1, const int to = -1); - std::vector <message*> getMessages(const std::vector <int>& nums); + ref <message> getMessage(const int num); + std::vector <ref <message> > getMessages(const int from = 1, const int to = -1); + std::vector <ref <message> > getMessages(const std::vector <int>& nums); const int getMessageCount(); - folder* getFolder(const folder::path::component& name); - std::vector <folder*> getFolders(const bool recursive = false); + ref <folder> getFolder(const folder::path::component& name); + std::vector <ref <folder> > getFolders(const bool recursive = false); void rename(const folder::path& newPath); @@ -91,7 +92,7 @@ public: void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET); void setMessageFlags(const std::vector <int>& nums, const int flags, const int mode = message::FLAG_MODE_SET); - void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); + void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); void copyMessage(const folder::path& dest, const int num); @@ -102,14 +103,14 @@ public: void expunge(); - folder* getParent(); + ref <folder> getParent(); - const store* getStore() const; - store* getStore(); + weak_ref <const store> getStore() const; + weak_ref <store> getStore(); - void fetchMessages(std::vector <message*>& msg, const int options, utility::progressionListener* progress = NULL); - void fetchMessage(message* msg, const int options); + void fetchMessages(std::vector <ref <message> >& msg, const int options, utility::progressionListener* progress = NULL); + void fetchMessage(ref <message> msg, const int options); const int getFetchCapabilities() const; @@ -130,7 +131,7 @@ private: IMAPStore* m_store; - IMAPConnection* m_connection; + ref <IMAPConnection> m_connection; folder::path m_path; folder::path::component m_name; diff --git a/vmime/messaging/imap/IMAPMessage.hpp b/vmime/messaging/imap/IMAPMessage.hpp index 43199110..33e43fec 100644 --- a/vmime/messaging/imap/IMAPMessage.hpp +++ b/vmime/messaging/imap/IMAPMessage.hpp @@ -43,6 +43,7 @@ class IMAPMessage : public message private: friend class IMAPFolder; + friend class vmime::creator; // vmime::create <IMAPMessage> IMAPMessage(IMAPFolder* folder, const int num); IMAPMessage(const IMAPMessage&) : message() { } @@ -97,8 +98,8 @@ private: bool m_expunged; uid m_uid; - header* m_header; - structure* m_structure; + ref <header> m_header; + ref <structure> m_structure; }; diff --git a/vmime/messaging/imap/IMAPParser.hpp b/vmime/messaging/imap/IMAPParser.hpp index 98deac3a..205644de 100644 --- a/vmime/messaging/imap/IMAPParser.hpp +++ b/vmime/messaging/imap/IMAPParser.hpp @@ -74,18 +74,18 @@ namespace imap { #endif -class IMAPParser +class IMAPParser : public object { public: - IMAPParser(IMAPTag* tag, socket* sok, timeoutHandler* _timeoutHandler) + IMAPParser(weak_ref <IMAPTag> tag, weak_ref <socket> sok, weak_ref <timeoutHandler> _timeoutHandler) : m_tag(tag), m_socket(sok), m_progress(NULL), m_literalHandler(NULL), m_timeoutHandler(_timeoutHandler) { } - const IMAPTag* tag() const + weak_ref <const IMAPTag> tag() const { return (m_tag); } @@ -4914,14 +4914,14 @@ public: private: - IMAPTag* m_tag; - socket* m_socket; + weak_ref <IMAPTag> m_tag; + weak_ref <socket> m_socket; utility::progressionListener* m_progress; literalHandler* m_literalHandler; - timeoutHandler* m_timeoutHandler; + weak_ref <timeoutHandler> m_timeoutHandler; string m_buffer; diff --git a/vmime/messaging/imap/IMAPStore.hpp b/vmime/messaging/imap/IMAPStore.hpp index 59689b87..227a0f27 100644 --- a/vmime/messaging/imap/IMAPStore.hpp +++ b/vmime/messaging/imap/IMAPStore.hpp @@ -52,14 +52,14 @@ class IMAPStore : public store public: - IMAPStore(session* sess, authenticator* auth); + IMAPStore(ref <session> sess, ref <authenticator> auth); ~IMAPStore(); const string getProtocolName() const; - folder* getDefaultFolder(); - folder* getRootFolder(); - folder* getFolder(const folder::path& path); + ref <folder> getDefaultFolder(); + ref <folder> getRootFolder(); + ref <folder> getFolder(const folder::path& path); const bool isValidFolderName(const folder::path::component& name) const; @@ -77,18 +77,18 @@ public: private: // Connection - IMAPConnection* m_connection; + ref <IMAPConnection> m_connection; // Used to request the authentication informations only the // first time, and reuse these informations the next time. - class authenticator* m_oneTimeAuth; + ref <class authenticator> m_oneTimeAuth; - class authenticator* oneTimeAuthenticator(); + ref <class authenticator> oneTimeAuthenticator(); - IMAPConnection* connection(); + ref <IMAPConnection> connection(); void registerFolder(IMAPFolder* folder); diff --git a/vmime/messaging/imap/IMAPTag.hpp b/vmime/messaging/imap/IMAPTag.hpp index da9569ac..526efb74 100644 --- a/vmime/messaging/imap/IMAPTag.hpp +++ b/vmime/messaging/imap/IMAPTag.hpp @@ -29,7 +29,7 @@ namespace messaging { namespace imap { -class IMAPTag +class IMAPTag : public object { private: diff --git a/vmime/messaging/maildir/maildirFolder.hpp b/vmime/messaging/maildir/maildirFolder.hpp index 106337c1..e7702673 100644 --- a/vmime/messaging/maildir/maildirFolder.hpp +++ b/vmime/messaging/maildir/maildirFolder.hpp @@ -49,9 +49,10 @@ private: friend class maildirStore; friend class maildirMessage; + friend class vmime::creator; // vmime::create <maildirFolder> - maildirFolder(const folder::path& path, maildirStore* store); + maildirFolder(const folder::path& path, weak_ref <maildirStore> store); maildirFolder(const maildirFolder&) : folder() { } ~maildirFolder(); @@ -75,13 +76,13 @@ public: const bool isOpen() const; - message* getMessage(const int num); - std::vector <message*> getMessages(const int from = 1, const int to = -1); - std::vector <message*> getMessages(const std::vector <int>& nums); + ref <message> getMessage(const int num); + std::vector <ref <message> > getMessages(const int from = 1, const int to = -1); + std::vector <ref <message> > getMessages(const std::vector <int>& nums); const int getMessageCount(); - folder* getFolder(const folder::path::component& name); - std::vector <folder*> getFolders(const bool recursive = false); + ref <folder> getFolder(const folder::path::component& name); + std::vector <ref <folder> > getFolders(const bool recursive = false); void rename(const folder::path& newPath); @@ -92,7 +93,7 @@ public: void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET); void setMessageFlags(const std::vector <int>& nums, const int flags, const int mode = message::FLAG_MODE_SET); - void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); + void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); void copyMessage(const folder::path& dest, const int num); @@ -103,14 +104,14 @@ public: void expunge(); - folder* getParent(); + ref <folder> getParent(); - const store* getStore() const; - store* getStore(); + weak_ref <const store> getStore() const; + weak_ref <store> getStore(); - void fetchMessages(std::vector <message*>& msg, const int options, utility::progressionListener* progress = NULL); - void fetchMessage(message* msg, const int options); + void fetchMessages(std::vector <ref <message> >& msg, const int options, utility::progressionListener* progress = NULL); + void fetchMessage(ref <message> msg, const int options); const int getFetchCapabilities() const; @@ -118,12 +119,12 @@ private: void scanFolder(); - void listFolders(std::vector <folder*>& list, const bool recursive); + void listFolders(std::vector <ref <folder> >& list, const bool recursive); void registerMessage(maildirMessage* msg); void unregisterMessage(maildirMessage* msg); - const utility::file::path getMessageFSPath(const int number); + const utility::file::path getMessageFSPath(const int number) const; void onStoreDisconnected(); @@ -138,7 +139,7 @@ private: void notifyMessagesCopied(const folder::path& dest); - maildirStore* m_store; + weak_ref <maildirStore> m_store; folder::path m_path; folder::path::component m_name; diff --git a/vmime/messaging/maildir/maildirMessage.hpp b/vmime/messaging/maildir/maildirMessage.hpp index 6eb8a7d2..c3e2e377 100644 --- a/vmime/messaging/maildir/maildirMessage.hpp +++ b/vmime/messaging/maildir/maildirMessage.hpp @@ -39,10 +39,11 @@ class maildirFolder; class maildirMessage : public message { friend class maildirFolder; + friend class vmime::creator; // vmime::create <maildirMessage> private: - maildirMessage(maildirFolder* folder, const int num); + maildirMessage(weak_ref <maildirFolder> folder, const int num); maildirMessage(const maildirMessage&) : message() { } ~maildirMessage(); @@ -72,7 +73,7 @@ public: private: - void fetch(maildirFolder* folder, const int options); + void fetch(weak_ref <maildirFolder> folder, const int options); void onFolderClosed(); @@ -81,7 +82,7 @@ private: void extractImpl(utility::outputStream& os, utility::progressionListener* progress, const int start, const int length, const int partialStart, const int partialLength, const bool peek) const; - maildirFolder* m_folder; + weak_ref <maildirFolder> m_folder; int m_num; int m_size; @@ -89,8 +90,8 @@ private: bool m_expunged; uid m_uid; - header* m_header; - structure* m_structure; + ref <header> m_header; + ref <structure> m_structure; }; diff --git a/vmime/messaging/maildir/maildirStore.hpp b/vmime/messaging/maildir/maildirStore.hpp index 25007e09..23c667a4 100644 --- a/vmime/messaging/maildir/maildirStore.hpp +++ b/vmime/messaging/maildir/maildirStore.hpp @@ -49,14 +49,14 @@ class maildirStore : public store public: - maildirStore(session* sess, authenticator* auth); + maildirStore(ref <session> sess, ref <authenticator> auth); ~maildirStore(); const string getProtocolName() const; - folder* getDefaultFolder(); - folder* getRootFolder(); - folder* getFolder(const folder::path& path); + ref <folder> getDefaultFolder(); + ref <folder> getRootFolder(); + ref <folder> getFolder(const folder::path& path); const bool isValidFolderName(const folder::path::component& name) const; diff --git a/vmime/messaging/maildir/maildirUtils.hpp b/vmime/messaging/maildir/maildirUtils.hpp index 583cdc6b..8f322d92 100644 --- a/vmime/messaging/maildir/maildirUtils.hpp +++ b/vmime/messaging/maildir/maildirUtils.hpp @@ -73,7 +73,8 @@ public: * @param mode type of path to return (see FolderFSPathMode) * @return filesystem path for the specified folder */ - static const utility::file::path getFolderFSPath(maildirStore* store, const utility::path& folderPath, const FolderFSPathMode mode); + static const utility::file::path getFolderFSPath(weak_ref <maildirStore> store, + const utility::path& folderPath, const FolderFSPathMode mode); /** Test whether the specified file-system directory corresponds to * a maildir sub-folder. The name of the directory should not start diff --git a/vmime/messaging/message.hpp b/vmime/messaging/message.hpp index b423e039..3f87f8f5 100644 --- a/vmime/messaging/message.hpp +++ b/vmime/messaging/message.hpp @@ -37,12 +37,12 @@ class structure; /** A MIME part in a message. */ -class part +class part : public object { protected: part() { } - part(const part&) { } + part(const part&) : object() { } virtual ~part() { } @@ -114,12 +114,12 @@ public: /** Structure of a MIME part/message. */ -class structure +class structure : public object { protected: structure() { } - structure(const structure&) { } + structure(const structure&) : object() { } public: @@ -152,12 +152,12 @@ public: /** Abstract representation of a message in a store/transport service. */ -class message +class message : public object { protected: message() { } - message(const message&) { } + message(const message&) : object() { } public: diff --git a/vmime/messaging/pop3/POP3Folder.hpp b/vmime/messaging/pop3/POP3Folder.hpp index 8cfe12db..bb29f858 100644 --- a/vmime/messaging/pop3/POP3Folder.hpp +++ b/vmime/messaging/pop3/POP3Folder.hpp @@ -48,6 +48,7 @@ private: friend class POP3Store; friend class POP3Message; + friend class vmime::creator; // vmime::create <POP3Folder> POP3Folder(const folder::path& path, POP3Store* store); POP3Folder(const POP3Folder&) : folder() { } @@ -73,13 +74,13 @@ public: const bool isOpen() const; - message* getMessage(const int num); - std::vector <message*> getMessages(const int from = 1, const int to = -1); - std::vector <message*> getMessages(const std::vector <int>& nums); + ref <message> getMessage(const int num); + std::vector <ref <message> > getMessages(const int from = 1, const int to = -1); + std::vector <ref <message> > getMessages(const std::vector <int>& nums); const int getMessageCount(); - folder* getFolder(const folder::path::component& name); - std::vector <folder*> getFolders(const bool recursive = false); + ref <folder> getFolder(const folder::path::component& name); + std::vector <ref <folder> > getFolders(const bool recursive = false); void rename(const folder::path& newPath); @@ -90,7 +91,7 @@ public: void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET); void setMessageFlags(const std::vector <int>& nums, const int flags, const int mode = message::FLAG_MODE_SET); - void addMessage(vmime::message* msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); + void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressionListener* progress = NULL); void copyMessage(const folder::path& dest, const int num); @@ -101,14 +102,14 @@ public: void expunge(); - folder* getParent(); + ref <folder> getParent(); - const store* getStore() const; - store* getStore(); + weak_ref <const store> getStore() const; + weak_ref <store> getStore(); - void fetchMessages(std::vector <message*>& msg, const int options, utility::progressionListener* progress = NULL); - void fetchMessage(message* msg, const int options); + void fetchMessages(std::vector <ref <message> >& msg, const int options, utility::progressionListener* progress = NULL); + void fetchMessage(ref <message> msg, const int options); const int getFetchCapabilities() const; diff --git a/vmime/messaging/pop3/POP3Message.hpp b/vmime/messaging/pop3/POP3Message.hpp index 55475cc1..499f3427 100644 --- a/vmime/messaging/pop3/POP3Message.hpp +++ b/vmime/messaging/pop3/POP3Message.hpp @@ -43,6 +43,7 @@ class POP3Message : public message private: friend class POP3Folder; + friend class vmime::creator; // vmime::create <POP3Message> POP3Message(POP3Folder* folder, const int num); POP3Message(const POP3Message&) : message() { } diff --git a/vmime/messaging/pop3/POP3Store.hpp b/vmime/messaging/pop3/POP3Store.hpp index 2de892cc..3ff291ea 100644 --- a/vmime/messaging/pop3/POP3Store.hpp +++ b/vmime/messaging/pop3/POP3Store.hpp @@ -46,18 +46,16 @@ class POP3Store : public store friend class POP3Folder; friend class POP3Message; -private: - public: - POP3Store(session* sess, authenticator* auth); + POP3Store(ref <session> sess, ref <authenticator> auth); ~POP3Store(); const string getProtocolName() const; - folder* getDefaultFolder(); - folder* getRootFolder(); - folder* getFolder(const folder::path& path); + ref <folder> getDefaultFolder(); + ref <folder> getRootFolder(); + ref <folder> getFolder(const folder::path& path); const bool isValidFolderName(const folder::path::component& name) const; @@ -94,10 +92,10 @@ private: std::list <POP3Folder*> m_folders; - socket* m_socket; + ref <socket> m_socket; bool m_authentified; - timeoutHandler* m_timeoutHandler; + ref <timeoutHandler> m_timeoutHandler; // Service infos diff --git a/vmime/messaging/sendmail/sendmailTransport.hpp b/vmime/messaging/sendmail/sendmailTransport.hpp index accf45b9..c63a6fac 100644 --- a/vmime/messaging/sendmail/sendmailTransport.hpp +++ b/vmime/messaging/sendmail/sendmailTransport.hpp @@ -43,7 +43,7 @@ class sendmailTransport : public transport { public: - sendmailTransport(session* sess, authenticator* auth); + sendmailTransport(ref <session> sess, ref <authenticator> auth); ~sendmailTransport(); const string getProtocolName() const; diff --git a/vmime/messaging/service.hpp b/vmime/messaging/service.hpp index d0b710d7..9d2e76d9 100644 --- a/vmime/messaging/service.hpp +++ b/vmime/messaging/service.hpp @@ -39,11 +39,11 @@ namespace messaging { /** Base class for messaging services. */ -class service +class service : public object { protected: - service(session* sess, const serviceInfos& infos, authenticator* auth); + service(ref <session> sess, const serviceInfos& infos, ref <authenticator> auth); public: @@ -72,13 +72,13 @@ public: * * @return session object */ - const session* getSession() const; + ref <const session> getSession() const; /** Return the session object associated with this service instance. * * @return session object */ - session* getSession(); + ref <session> getSession(); /** Return information about this service. * @@ -110,13 +110,13 @@ public: * * @return authenticator object */ - const authenticator* getAuthenticator() const; + ref <const authenticator> getAuthenticator() const; /** Return the authenticator object used with this service instance. * * @return authenticator object */ - authenticator* getAuthenticator(); + ref <authenticator> getAuthenticator(); /** Set a property for this service (service prefix is added automatically). * @@ -149,10 +149,8 @@ public: private: - bool m_deleteAuth; - - session* m_session; - authenticator* m_auth; + ref <session> m_session; + ref <authenticator> m_auth; }; diff --git a/vmime/messaging/serviceFactory.hpp b/vmime/messaging/serviceFactory.hpp index 782e4c75..c7eff565 100644 --- a/vmime/messaging/serviceFactory.hpp +++ b/vmime/messaging/serviceFactory.hpp @@ -59,7 +59,7 @@ public: static serviceFactory* getInstance(); /** Information about a registered service. */ - class registeredService + class registeredService : public object { friend class serviceFactory; @@ -69,7 +69,7 @@ public: public: - virtual service* create(session* sess, authenticator* auth) const = 0; + virtual ref <service> create(ref <session> sess, ref <authenticator> auth) const = 0; virtual const string& getName() const = 0; virtual const serviceInfos& getInfos() const = 0; @@ -81,6 +81,7 @@ private: class registeredServiceImpl : public registeredService { friend class serviceFactory; + friend class vmime::creator; protected: @@ -91,9 +92,9 @@ private: public: - service* create(session* sess, authenticator* auth) const + ref <service> create(ref <session> sess, ref <authenticator> auth) const { - return new S(sess, auth); + return vmime::create <S>(sess, auth); } const serviceInfos& getInfos() const @@ -112,7 +113,7 @@ private: const serviceInfos& m_servInfos; }; - std::vector <registeredService*> m_services; + std::vector <ref <registeredService> > m_services; public: @@ -124,7 +125,7 @@ public: void registerServiceByProtocol(const string& protocol) { const string name = utility::stringUtils::toLower(protocol); - m_services.push_back(new registeredServiceImpl <S>(name)); + m_services.push_back(vmime::create <registeredServiceImpl <S> >(name)); } /** Create a new service instance from a protocol name. @@ -136,7 +137,7 @@ public: * @throw exceptions::no_service_available if no service is registered * for this protocol */ - service* create(session* sess, const string& protocol, authenticator* auth = NULL); + ref <service> create(ref <session> sess, const string& protocol, ref <authenticator> auth = NULL); /** Create a new service instance from a URL. * @@ -148,7 +149,7 @@ public: * @throw exceptions::no_service_available if no service is registered * for this protocol */ - service* create(session* sess, const utility::url& u, authenticator* auth = NULL); + ref <service> create(ref <session> sess, const utility::url& u, ref <authenticator> auth = NULL); /** Return information about a registered protocol. * @@ -157,7 +158,7 @@ public: * @throw exceptions::no_service_available if no service is registered * for this protocol */ - const registeredService* getServiceByProtocol(const string& protocol) const; + ref <const registeredService> getServiceByProtocol(const string& protocol) const; /** Return the number of registered services. * @@ -170,13 +171,13 @@ public: * @param pos position of the registered service to return * @return registered service at the specified position */ - const registeredService* getServiceAt(const int pos) const; + ref <const registeredService> getServiceAt(const int pos) const; /** Return a list of all registered services. * * @return list of registered services */ - const std::vector <const registeredService*> getServiceList() const; + const std::vector <ref <const registeredService> > getServiceList() const; }; diff --git a/vmime/messaging/serviceInfos.hpp b/vmime/messaging/serviceInfos.hpp index d812512e..bdfcd887 100644 --- a/vmime/messaging/serviceInfos.hpp +++ b/vmime/messaging/serviceInfos.hpp @@ -201,7 +201,7 @@ public: * @return value of the property */ template <typename TYPE> - const TYPE getPropertyValue(session* s, const property& p) const + const TYPE getPropertyValue(ref <session> s, const property& p) const { if (p.getFlags() & property::FLAG_REQUIRED) return s->getProperties()[getPropertyPrefix() + p.getName()].template getValue <TYPE>(); @@ -217,7 +217,7 @@ public: * @param p property to test * @return true if the property is set, false otherwise */ - const bool hasProperty(session* s, const property& p) const; + const bool hasProperty(ref <session> s, const property& p) const; }; diff --git a/vmime/messaging/session.hpp b/vmime/messaging/session.hpp index bce4a2c0..e2b92634 100644 --- a/vmime/messaging/session.hpp +++ b/vmime/messaging/session.hpp @@ -40,11 +40,12 @@ class transport; * for connection to a service. */ -class session +class session : public object { public: session(); + session(const session& sess); session(const propertySet& props); virtual ~session(); @@ -59,7 +60,7 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new transport service */ - transport* getTransport(authenticator* auth = NULL); + ref <transport> getTransport(ref <authenticator> auth = NULL); /** Return a transport service instance for the specified protocol. * @@ -69,7 +70,7 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new transport service */ - transport* getTransport(const string& protocol, authenticator* auth = NULL); + ref <transport> getTransport(const string& protocol, ref <authenticator> auth = NULL); /** Return a transport service instance for the specified URL. * @@ -79,7 +80,7 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new transport service */ - transport* getTransport(const utility::url& url, authenticator* auth = NULL); + ref <transport> getTransport(const utility::url& url, ref <authenticator> auth = NULL); /** Return a transport service instance for the protocol specified * in the session properties. @@ -91,7 +92,7 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new store service */ - store* getStore(authenticator* auth = NULL); + ref <store> getStore(ref <authenticator> auth = NULL); /** Return a store service instance for the specified protocol. * @@ -101,7 +102,7 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new store service */ - store* getStore(const string& protocol, authenticator* auth = NULL); + ref <store> getStore(const string& protocol, ref <authenticator> auth = NULL); /** Return a store service instance for the specified URL. * @@ -111,7 +112,7 @@ public: * credentials by reading the session properties "auth.username" and "auth.password". * @return a new store service */ - store* getStore(const utility::url& url, authenticator* auth = NULL); + ref <store> getStore(const utility::url& url, ref <authenticator> auth = NULL); /** Properties for the session and for the services. */ diff --git a/vmime/messaging/smtp/SMTPTransport.hpp b/vmime/messaging/smtp/SMTPTransport.hpp index 61a5a7fe..191d134c 100644 --- a/vmime/messaging/smtp/SMTPTransport.hpp +++ b/vmime/messaging/smtp/SMTPTransport.hpp @@ -40,7 +40,7 @@ class SMTPTransport : public transport { public: - SMTPTransport(session* sess, authenticator* auth); + SMTPTransport(ref <session> sess, ref <authenticator> auth); ~SMTPTransport(); const string getProtocolName() const; @@ -67,11 +67,11 @@ private: void internalDisconnect(); - socket* m_socket; + ref <socket> m_socket; bool m_authentified; bool m_extendedSMTP; - timeoutHandler* m_timeoutHandler; + ref <timeoutHandler> m_timeoutHandler; // Service infos diff --git a/vmime/messaging/socket.hpp b/vmime/messaging/socket.hpp index dbbed819..dc5cdad9 100644 --- a/vmime/messaging/socket.hpp +++ b/vmime/messaging/socket.hpp @@ -31,7 +31,7 @@ namespace messaging { /** Interface for connecting to servers. */ -class socket +class socket : public object { public: @@ -81,6 +81,14 @@ public: * @param count number of bytes to send (size of buffer) */ virtual void sendRaw(const char* buffer, const int count) = 0; + +protected: + + socket() { } + +private: + + socket(const socket&) : object() { } }; @@ -93,7 +101,7 @@ public: virtual ~socketFactory() { } - virtual socket* create() = 0; + virtual ref <socket> create() = 0; }; diff --git a/vmime/messaging/store.hpp b/vmime/messaging/store.hpp index 6b5d8be7..68dfaf98 100644 --- a/vmime/messaging/store.hpp +++ b/vmime/messaging/store.hpp @@ -37,7 +37,7 @@ class store : public service { protected: - store(session* sess, const serviceInfos& infos, authenticator* auth) + store(ref <session> sess, const serviceInfos& infos, ref <authenticator> auth) : service(sess, infos, auth) { } public: @@ -47,21 +47,21 @@ public: * * @return default folder */ - virtual folder* getDefaultFolder() = 0; + virtual ref <folder> getDefaultFolder() = 0; /** Return the root folder. This is protocol dependant * and usually is the user's mail drop root folder. * * @return root folder */ - virtual folder* getRootFolder() = 0; + virtual ref <folder> getRootFolder() = 0; /** Return the folder specified by the path. * * @param path absolute folder path * @return folder at the specified path */ - virtual folder* getFolder(const folder::path& path) = 0; + virtual ref <folder> getFolder(const folder::path& path) = 0; /** Test whether the specified folder name is a syntactically * a valid name. diff --git a/vmime/messaging/timeoutHandler.hpp b/vmime/messaging/timeoutHandler.hpp index 79af504e..75d333e0 100644 --- a/vmime/messaging/timeoutHandler.hpp +++ b/vmime/messaging/timeoutHandler.hpp @@ -21,6 +21,9 @@ #define VMIME_MESSAGING_TIMEOUTHANDLER_HPP_INCLUDED +#include "vmime/types.hpp" + + namespace vmime { namespace messaging { @@ -28,7 +31,7 @@ namespace messaging { /** A class to manage time-out in messaging services. */ -class timeoutHandler +class timeoutHandler : public object { public: @@ -63,7 +66,7 @@ public: virtual ~timeoutHandlerFactory() { } - virtual timeoutHandler* create() = 0; + virtual ref <timeoutHandler> create() = 0; }; diff --git a/vmime/messaging/transport.hpp b/vmime/messaging/transport.hpp index 272fdb32..8f499154 100644 --- a/vmime/messaging/transport.hpp +++ b/vmime/messaging/transport.hpp @@ -42,7 +42,7 @@ class transport : public service { protected: - transport(session* sess, const serviceInfos& infos, authenticator* auth); + transport(ref <session> sess, const serviceInfos& infos, ref <authenticator> auth); public: @@ -51,7 +51,7 @@ public: * @param msg message to send * @param progress progression listener, or NULL if not used */ - virtual void send(vmime::message* msg, utility::progressionListener* progress = NULL); + virtual void send(ref <vmime::message> msg, utility::progressionListener* progress = NULL); /** Send a message over this transport service. * |
