summaryrefslogtreecommitdiff
path: root/libmu_cpp
diff options
context:
space:
mode:
authorWojciech Polak <polak@gnu.org>2004-11-17 21:24:50 +0000
committerWojciech Polak <polak@gnu.org>2004-11-17 21:24:50 +0000
commit7e90b785792197188501d8dfc78f8e3057634796 (patch)
tree31fc41a727db9c26807b85a6e3e0da9dd357dc60 /libmu_cpp
parent346f0be99bca5c7e2d2264ed404a47499129d53e (diff)
downloadmailutils-7e90b785792197188501d8dfc78f8e3057634796.tar.gz
mailutils-7e90b785792197188501d8dfc78f8e3057634796.tar.bz2
Initial version of libmu_cpp.
Diffstat (limited to 'libmu_cpp')
-rw-r--r--libmu_cpp/Makefile.am45
-rw-r--r--libmu_cpp/address.cc142
-rw-r--r--libmu_cpp/filter.cc57
-rw-r--r--libmu_cpp/header.cc61
-rw-r--r--libmu_cpp/iterator.cc117
-rw-r--r--libmu_cpp/list.cc171
-rw-r--r--libmu_cpp/mailbox.cc120
-rw-r--r--libmu_cpp/mailcap.cc125
-rw-r--r--libmu_cpp/mailer.cc74
-rw-r--r--libmu_cpp/message.cc54
-rw-r--r--libmu_cpp/pop3.cc264
-rw-r--r--libmu_cpp/stream.cc250
-rw-r--r--libmu_cpp/url.cc137
13 files changed, 1617 insertions, 0 deletions
diff --git a/libmu_cpp/Makefile.am b/libmu_cpp/Makefile.am
new file mode 100644
index 000000000..690511410
--- /dev/null
+++ b/libmu_cpp/Makefile.am
@@ -0,0 +1,45 @@
+## Process this file with GNU Automake to create Makefile.in
+##
+## Copyright (C) 2004 Free Software Foundation, Inc.
+##
+## GNU Mailutils is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License as
+## published by the Free Software Foundation; either version 2, or (at
+## your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+INCLUDES = -I${top_srcdir}/include -I${top_srcdir}/mailbox\
+ -I${top_srcdir}/mailbox/include\
+ -I${top_builddir}/include/mailutils/gnu \
+ @INTLINCS@
+
+MU_CXX_LIBS = libmu_cpp.la
+lib_LTLIBRARIES = @MU_CXX_LIBS@
+EXTRA_LTLIBRARIES = $(MU_CXX_LIBS)
+
+libmu_cpp_la_SOURCES = \
+ address.cc\
+ filter.cc\
+ header.cc\
+ iterator.cc\
+ list.cc\
+ mailbox.cc\
+ mailcap.cc\
+ mailer.cc\
+ message.cc\
+ pop3.cc\
+ stream.cc\
+ url.cc
+
+libmu_cpp_la_DEPENDENCIES = @MU_LTLIBOBJS@
+libmu_cpp_la_LIBADD = @MU_LTLIBOBJS@ @MU_COMMON_LIBRARIES@
+libmu_cpp_la_LDFLAGS = -version-info 0:0:0
+
diff --git a/libmu_cpp/address.cc b/libmu_cpp/address.cc
new file mode 100644
index 000000000..6612be7e3
--- /dev/null
+++ b/libmu_cpp/address.cc
@@ -0,0 +1,142 @@
+/*
+ GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <mailutils/cpp/address.h>
+#include <mailutils/cpp/error.h>
+#include <errno.h>
+
+using namespace mailutils;
+
+//
+// Address
+//
+
+Address :: Address (const std::string& str)
+{
+ int status = address_create (&addr, str.c_str ());
+ if (status)
+ throw Exception ("Address::Address", status);
+}
+
+Address :: Address (const address_t addr)
+{
+ if (addr == 0)
+ throw Exception ("Address::Address", EINVAL);
+
+ this->addr = addr;
+}
+
+Address :: ~Address ()
+{
+ address_destroy (&addr);
+}
+
+bool
+Address :: IsGroup (size_t n)
+{
+ int isgroup;
+ int status = address_is_group (addr, n, &isgroup);
+ if (status == EINVAL)
+ throw Address::EInval ("Address::IsGroup", status);
+ else if (status == ENOENT)
+ throw Address::ENoent ("Address::IsGroup", status);
+
+ return (bool) isgroup;
+}
+
+size_t
+Address :: GetCount ()
+{
+ size_t count;
+ address_get_count (addr, &count);
+ return count;
+}
+
+std::string
+Address :: GetEmail (size_t n)
+{
+ int status = address_get_email (addr, n, buf, sizeof (buf), 0);
+ if (status == EINVAL)
+ throw Address::EInval ("Address::GetEmail", status);
+ else if (status == ENOENT)
+ throw Address::ENoent ("Address::GetEmail", status);
+
+ return std::string (buf);
+}
+
+std::string
+Address :: GetLocalPart (size_t n)
+{
+ int status = address_get_local_part (addr, n, buf, sizeof (buf), 0);
+ if (status == EINVAL)
+ throw Address::EInval ("Address::GetLocalPart", status);
+ else if (status == ENOENT)
+ throw Address::ENoent ("Address::GetLocalPart", status);
+
+ return std::string (buf);
+}
+
+std::string
+Address :: GetDomain (size_t n)
+{
+ int status = address_get_domain (addr, n, buf, sizeof (buf), 0);
+ if (status == EINVAL)
+ throw Address::EInval ("Address::GetDomain", status);
+ else if (status == ENOENT)
+ throw Address::ENoent ("Address::GetDomain", status);
+
+ return std::string (buf);
+}
+
+std::string
+Address :: GetPersonal (size_t n)
+{
+ int status = address_get_personal (addr, n, buf, sizeof (buf), 0);
+ if (status == EINVAL)
+ throw Address::EInval ("Address::GetPersonal", status);
+ else if (status == ENOENT)
+ throw Address::ENoent ("Address::GetPersonal", status);
+
+ return std::string (buf);
+}
+
+std::string
+Address :: GetComments (size_t n)
+{
+ int status = address_get_comments (addr, n, buf, sizeof (buf), 0);
+ if (status == EINVAL)
+ throw Address::EInval ("Address::GetComments", status);
+ else if (status == ENOENT)
+ throw Address::ENoent ("Address::GetComments", status);
+
+ return std::string (buf);
+}
+
+std::string
+Address :: GetRoute (size_t n)
+{
+ int status = address_get_route (addr, n, buf, sizeof (buf), 0);
+ if (status == EINVAL)
+ throw Address::EInval ("Address::GetRoute", status);
+ else if (status == ENOENT)
+ throw Address::ENoent ("Address::GetRoute", status);
+
+ return std::string (buf);
+}
+
diff --git a/libmu_cpp/filter.cc b/libmu_cpp/filter.cc
new file mode 100644
index 000000000..d0700d138
--- /dev/null
+++ b/libmu_cpp/filter.cc
@@ -0,0 +1,57 @@
+/*
+ GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <mailutils/cpp/filter.h>
+
+using namespace mailutils;
+
+//
+// FilterStream
+//
+
+void
+FilterStream :: Create (Stream& transport,
+ const std::string& code,
+ int mode, int flag)
+{
+ int status = filter_create (&this->stm,
+ transport.stm,
+ code.c_str (),
+ mode, flag);
+ if (status)
+ throw Exception ("FilterStream::Create", status);
+ this->input = new Stream (transport);
+}
+
+void
+FilterStream :: IconvCreate (Stream& transport,
+ const std::string& fromcode,
+ const std::string& tocode,
+ int flags,
+ enum mu_iconv_fallback_mode fallback_mode)
+{
+ int status = filter_iconv_create (&this->stm, transport.stm,
+ fromcode.c_str (),
+ tocode.c_str (),
+ flags, fallback_mode);
+ if (status)
+ throw Exception ("FilterStream::IconvCreate", status);
+ this->input = new Stream (transport);
+}
+
diff --git a/libmu_cpp/header.cc b/libmu_cpp/header.cc
new file mode 100644
index 000000000..adcb41dc6
--- /dev/null
+++ b/libmu_cpp/header.cc
@@ -0,0 +1,61 @@
+/*
+ GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <mailutils/cpp/header.h>
+#include <mailutils/cpp/error.h>
+#include <errno.h>
+
+using namespace mailutils;
+
+//
+// Header
+//
+
+Header :: Header ()
+{
+}
+
+Header :: Header (const header_t hdr)
+{
+ if (hdr == 0)
+ throw Exception ("Header::Header", EINVAL);
+
+ this->hdr = hdr;
+}
+
+std::string
+Header :: GetValue (const std::string& name)
+{
+ char* c_val;
+
+ int status = header_aget_value (hdr, name.c_str (), &c_val);
+ if (status)
+ throw Exception ("Header::GetValue", status);
+
+ std::string val (c_val);
+ free (c_val);
+ return val;
+}
+
+std::string
+Header :: operator [] (const std::string& name)
+{
+ return this->GetValue (name);
+}
+
diff --git a/libmu_cpp/iterator.cc b/libmu_cpp/iterator.cc
new file mode 100644
index 000000000..6cb355610
--- /dev/null
+++ b/libmu_cpp/iterator.cc
@@ -0,0 +1,117 @@
+/*
+ GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <mailutils/cpp/iterator.h>
+#include <mailutils/cpp/error.h>
+#include <errno.h>
+
+using namespace mailutils;
+
+//
+// Iterator
+//
+
+Iterator :: Iterator (const List& lst)
+{
+ int status = list_get_iterator (lst.mu_list, &mu_iter);
+ if (status)
+ throw Exception ("Iterator::Iterator", status);
+
+ this->pList = (List*) &lst;
+}
+
+Iterator :: Iterator (const iterator_t iter)
+{
+ if (iter == 0)
+ throw Exception ("Iterator::Iterator", EINVAL);
+
+ this->mu_iter = iter;
+ this->pList = 0;
+}
+
+Iterator :: ~Iterator ()
+{
+ iterator_destroy (&mu_iter);
+}
+
+void
+Iterator :: First ()
+{
+ iterator_first (mu_iter);
+}
+
+void
+Iterator :: Next ()
+{
+ iterator_next (mu_iter);
+}
+
+Iterator&
+Iterator :: operator ++ (int)
+{
+ iterator_next (mu_iter);
+ return *this;
+}
+
+void
+Iterator :: Current (void** pitem)
+{
+ int status = iterator_current (mu_iter, pitem);
+ if (status)
+ throw Exception ("Iterator::Current", status);
+}
+
+void*
+Iterator :: Current ()
+{
+ void* pitem;
+
+ int status = iterator_current (mu_iter, &pitem);
+ if (status)
+ throw Exception ("Iterator::Current", status);
+
+ return pitem;
+}
+
+bool
+Iterator :: IsDone ()
+{
+ return (bool) iterator_is_done (mu_iter);
+}
+
+List&
+Iterator :: GetList ()
+{
+ if (!pList)
+ throw Exception ("Iterator::GetList", ENOTSUP);
+ return *pList;
+}
+
+void
+Iterator :: Dup (Iterator*& piter, const Iterator& orig)
+{
+ iterator_t iter;
+
+ int status = iterator_dup (&iter, orig.mu_iter);
+ if (status)
+ throw Exception ("Iterator::Dup", status);
+
+ piter->mu_iter = iter;
+}
+
diff --git a/libmu_cpp/list.cc b/libmu_cpp/list.cc
new file mode 100644
index 000000000..df82c6b18
--- /dev/null
+++ b/libmu_cpp/list.cc
@@ -0,0 +1,171 @@
+/*
+ GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <mailutils/cpp/list.h>
+#include <mailutils/cpp/error.h>
+#include <errno.h>
+
+using namespace mailutils;
+
+//
+// List
+//
+
+List :: List ()
+{
+ int status = list_create (&mu_list);
+ if (status)
+ throw Exception ("List::List", status);
+}
+
+List :: List (const list_t lst)
+{
+ if (lst == 0)
+ throw Exception ("List::List", EINVAL);
+
+ this->mu_list = lst;
+}
+
+List :: ~List ()
+{
+ list_destroy (&mu_list);
+}
+
+void
+List :: Append (void* item)
+{
+ int status = list_append (mu_list, item);
+ if (status)
+ throw Exception ("List::Append", status);
+}
+
+void
+List :: Prepend (void* item)
+{
+ int status = list_prepend (mu_list, item);
+ if (status)
+ throw Exception ("List::Prepend", status);
+}
+
+void
+List :: Insert (void* item, void* new_item)
+{
+ int status = list_insert (mu_list, item, new_item);
+ if (status)
+ throw Exception ("List::Insert", status);
+}
+
+void
+List :: Remove (void* item)
+{
+ int status = list_remove (mu_list, item);
+ if (status)
+ throw Exception ("List::Remove", status);
+}
+
+void
+List :: Replace (void* old_item, void* new_item)
+{
+ int status = list_replace (mu_list, old_item, new_item);
+ if (status)
+ throw Exception ("List::Replace", status);
+}
+
+void
+List :: Get (size_t index, void** pitem)
+{
+ int status = list_get (mu_list, index, pitem);
+ if (status)
+ throw Exception ("List::Get", status);
+}
+
+void*
+List :: Get (size_t index)
+{
+ void* pitem;
+
+ int status = list_get (mu_list, index, &pitem);
+ if (status)
+ throw Exception ("List::Get", status);
+
+ return pitem;
+}
+
+void*
+List :: operator [] (size_t index)
+{
+ return this->Get (index);
+}
+
+void
+List :: ToArray (void** array, size_t count, size_t* pcount)
+{
+ int status = list_to_array (mu_list, array, count, pcount);
+ if (status)
+ throw Exception ("List::ToArray", status);
+}
+
+void
+List :: Locate (void* item, void** ret_item)
+{
+ int status = list_locate (mu_list, item, ret_item);
+ if (status)
+ throw Exception ("List::Locate", status);
+}
+
+bool
+List :: IsEmpty ()
+{
+ return (bool) list_is_empty (mu_list);
+}
+
+size_t
+List :: Count ()
+{
+ size_t count = 0;
+
+ int status = list_count (mu_list, &count);
+ if (status)
+ throw Exception ("List::Count", status);
+
+ return count;
+}
+
+void
+List :: Do (list_action_t* action, void* cbdata)
+{
+ int status = list_do (mu_list, action, cbdata);
+ if (status)
+ throw Exception ("List::Do", status);
+}
+
+list_comparator_t
+List :: SetComparator (list_comparator_t comp)
+{
+ return list_set_comparator (mu_list, comp);
+}
+
+void
+List :: SetDestroyItem (void (*destroy_item) (void *item))
+{
+ int status = list_set_destroy_item (mu_list, destroy_item);
+ if (status)
+ throw Exception ("List::SetDestroyItem", status);
+}
+
diff --git a/libmu_cpp/mailbox.cc b/libmu_cpp/mailbox.cc
new file mode 100644
index 000000000..7d0cc7a22
--- /dev/null
+++ b/libmu_cpp/mailbox.cc
@@ -0,0 +1,120 @@
+/*
+ GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <mailutils/cpp/mailbox.h>
+#include <mailutils/cpp/message.h>
+#include <mailutils/cpp/error.h>
+#include <errno.h>
+
+using namespace mailutils;
+
+//
+// MailboxBase
+//
+
+void
+MailboxBase :: Open (int flag)
+{
+ int status = mailbox_open (mbox, flag);
+ if (status)
+ throw Exception ("MailboxBase::Open", status);
+}
+
+void
+MailboxBase :: Close ()
+{
+ int status = mailbox_close (mbox);
+ if (status)
+ throw Exception ("MailboxBase::Close", status);
+}
+
+size_t
+MailboxBase :: MessagesCount ()
+{
+ size_t total;
+ mailbox_messages_count (mbox, &total);
+ return total;
+}
+
+Message&
+MailboxBase :: GetMessage (size_t num)
+{
+ message_t c_msg;
+
+ int status = mailbox_get_message (mbox, num, &c_msg);
+ if (status)
+ throw Exception ("MailboxBase::GetMessage", status);
+
+ return *new Message (c_msg);
+}
+
+Message&
+MailboxBase :: operator [] (size_t num)
+{
+ return this->GetMessage (num);
+}
+
+//
+// Mailbox
+//
+
+Mailbox :: Mailbox (const std::string& name)
+{
+ int status = mailbox_create (&mbox, name.c_str ());
+ if (status)
+ throw Exception ("Mailbox::Mailbox", status);
+}
+
+Mailbox :: Mailbox (const mailbox_t mbox)
+{
+ if (mbox == 0)
+ throw Exception ("Mailbox::Mailbox", EINVAL);
+
+ this->mbox = mbox;
+}
+
+Mailbox :: ~Mailbox ()
+{
+ mailbox_destroy (&mbox);
+}
+
+//
+// MailboxDefault
+//
+
+MailboxDefault :: MailboxDefault (const std::string& name)
+{
+ int status = mailbox_create_default (&mbox, name.c_str ());
+ if (status)
+ throw Exception ("MailboxDefault::MailboxDefault", status);
+}
+
+MailboxDefault :: MailboxDefault (const mailbox_t mbox)
+{
+ if (mbox == 0)
+ throw Exception ("MailboxDefault::MailboxDefault", EINVAL);
+
+ this->mbox = mbox;
+}
+
+MailboxDefault :: ~MailboxDefault ()
+{
+ mailbox_destroy (&mbox);
+}
+
diff --git a/libmu_cpp/mailcap.cc b/libmu_cpp/mailcap.cc
new file mode 100644
index 000000000..2f81b6d97
--- /dev/null
+++ b/libmu_cpp/mailcap.cc
@@ -0,0 +1,125 @@
+/*
+ GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <mailutils/cpp/mailcap.h>
+#include <mailutils/cpp/stream.h>
+#include <mailutils/cpp/error.h>
+#include <errno.h>
+
+using namespace mailutils;
+
+//
+// Mailcap
+//
+
+Mailcap :: Mailcap (const Stream& stm)
+{
+ int status = mu_mailcap_create (&mailcap, stm.stm);
+ if (status)
+ throw Exception ("Mailcap::Mailcap", status);
+}
+
+Mailcap :: Mailcap (const mu_mailcap_t mailcap)
+{
+ if (mailcap == 0)
+ throw Exception ("Mailcap::Mailcap", EINVAL);
+
+ this->mailcap = mailcap;
+}
+
+Mailcap :: ~Mailcap ()
+{
+ mu_mailcap_destroy (&mailcap);
+}
+
+size_t
+Mailcap :: GetCount ()
+{
+ size_t count = 0;
+ int status = mu_mailcap_entries_count (mailcap, &count);
+ if (status)
+ throw Exception ("Mailcap::GetCount", status);
+ return count;
+}
+
+MailcapEntry&
+Mailcap :: GetEntry (size_t i)
+{
+ mu_mailcap_entry_t c_entry;
+
+ int status = mu_mailcap_get_entry (mailcap, i, &c_entry);
+ if (status)
+ throw Exception ("Mailcap::GetEntry", status);
+
+ MailcapEntry* entry = new MailcapEntry (c_entry);
+ return *entry;
+}
+
+//
+// MailcapEntry
+//
+
+MailcapEntry :: MailcapEntry (mu_mailcap_entry_t entry)
+{
+ if (entry == 0)
+ throw Exception ("MailcapEntry::MailcapEntry", EINVAL);
+
+ this->entry = entry;
+}
+
+size_t
+MailcapEntry :: FieldsCount ()
+{
+ size_t count = 0;
+ int status = mu_mailcap_entry_fields_count (entry, &count);
+ if (status)
+ throw Exception ("MailcapEntry::FieldsCount", status);
+ return count;
+}
+
+std::string
+MailcapEntry :: GetField (size_t i)
+{
+ int status = mu_mailcap_entry_get_field (entry, i, buf,
+ sizeof (buf), NULL);
+ if (status)
+ throw Exception ("MailcapEntry::GetField", status);
+ return std::string (buf);
+}
+
+std::string
+MailcapEntry :: GetTypeField ()
+{
+ int status = mu_mailcap_entry_get_typefield (entry, buf,
+ sizeof (buf), NULL);
+ if (status)
+ throw Exception ("MailcapEntry::GetTypeField", status);
+ return std::string (buf);
+}
+
+std::string
+MailcapEntry :: GetViewCommand ()
+{
+ int status = mu_mailcap_entry_get_viewcommand (entry, buf,
+ sizeof (buf), NULL);
+ if (status)
+ throw Exception ("MailcapEntry::GetViewCommand", status);
+ return std::string (buf);
+}
+
diff --git a/libmu_cpp/mailer.cc b/libmu_cpp/mailer.cc
new file mode 100644
index 000000000..acd14c24c
--- /dev/null
+++ b/libmu_cpp/mailer.cc
@@ -0,0 +1,74 @@
+/*
+ GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <mailutils/cpp/mailer.h>
+#include <errno.h>
+
+using namespace mailutils;
+
+//
+// Mailer
+//
+
+Mailer :: Mailer (const std::string& url)
+{
+ int status = mailer_create (&mailer, url.c_str ());
+ if (status)
+ throw Exception ("Mailer::Mailer", status);
+}
+
+Mailer :: Mailer (const mailer_t mailer)
+{
+ if (mailer == 0)
+ throw Exception ("Mailer::Mailer", EINVAL);
+
+ this->mailer = mailer;
+}
+
+Mailer :: ~Mailer ()
+{
+ mailer_destroy (&mailer);
+}
+
+void
+Mailer :: Open (int flags)
+{
+ int status = mailer_open (mailer, flags);
+ if (status)
+ throw Exception ("Mailer::Open", status);
+}
+
+void
+Mailer :: Close ()
+{
+ int status = mailer_close (mailer);
+ if (status)
+ throw Exception ("Mailer::Close", status);
+}
+
+void
+Mailer :: SendMessage (const Message& msg, const Address& from,
+ const Address& to)
+{
+ int status = mailer_send_message (mailer, msg.msg,
+ from.addr, to.addr);
+ if (status)
+ throw Exception ("Mailer::SendMessage", status);
+}
+
diff --git a/libmu_cpp/message.cc b/libmu_cpp/message.cc
new file mode 100644
index 000000000..a88217df0
--- /dev/null
+++ b/libmu_cpp/message.cc
@@ -0,0 +1,54 @@
+/*
+ GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <mailutils/cpp/message.h>
+#include <mailutils/cpp/header.h>
+#include <mailutils/cpp/error.h>
+#include <errno.h>
+
+using namespace mailutils;
+
+//
+// Message
+//
+
+Message :: Message ()
+{
+}
+
+Message :: Message (const message_t msg)
+{
+ if (msg == 0)
+ throw Exception ("Message::Message", EINVAL);
+
+ this->msg = msg;
+}
+
+Header&
+Message :: GetHeader ()
+{
+ header_t c_hdr;
+
+ int status = message_get_header (msg, &c_hdr);
+ if (status)
+ throw Exception ("Message::GetHeader", status);
+
+ return *new Header (c_hdr);
+}
+
diff --git a/libmu_cpp/pop3.cc b/libmu_cpp/pop3.cc
new file mode 100644
index 000000000..b691c23dd
--- /dev/null
+++ b/libmu_cpp/pop3.cc
@@ -0,0 +1,264 @@
+/*
+ GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <mailutils/cpp/pop3.h>
+#include <mailutils/cpp/iterator.h>
+#include <errno.h>
+
+using namespace mailutils;
+
+//
+// POP3
+//
+
+Pop3 :: Pop3 ()
+{
+ int status = mu_pop3_create (&pop3);
+ if (status)
+ throw Exception ("Pop3::Pop3", status);
+
+ this->pStream = 0;
+}
+
+Pop3 :: Pop3 (const mu_pop3_t pop3)
+{
+ if (pop3 == 0)
+ throw Exception ("Pop3::Pop3", EINVAL);
+
+ this->pop3 = pop3;
+ this->pStream = 0;
+}
+
+Pop3 :: ~Pop3 ()
+{
+ mu_pop3_destroy (&pop3);
+}
+
+void
+Pop3 :: SetCarrier (const Stream& carrier)
+{
+ int status = mu_pop3_set_carrier (pop3, carrier.stm);
+ if (status)
+ throw Exception ("Pop3::SetCarrier", status);
+
+ this->pStream = (Stream*) &carrier;
+}
+
+Stream&
+Pop3 :: GetCarrier ()
+{
+ return *pStream;
+}
+
+void
+Pop3 :: Connect ()
+{
+ int status = mu_pop3_connect (pop3);
+ if (status)
+ throw Exception ("Pop3::Connect", status);
+}
+
+void
+Pop3 :: Disconnect ()
+{
+ int status = mu_pop3_disconnect (pop3);
+ if (status)
+ throw Exception ("Pop3::Disconnect", status);
+}
+
+void
+Pop3 :: SetTimeout (int timeout)
+{
+ int status = mu_pop3_set_timeout (pop3, timeout);
+ if (status)
+ throw Exception ("Pop3::SetTimeout", status);
+}
+
+int
+Pop3 :: GetTimeout ()
+{
+ int timeout;
+
+ int status = mu_pop3_get_timeout (pop3, &timeout);
+ if (status)