Revision: 7437
          http://mahogany.svn.sourceforge.net/mahogany/?rev=7437&view=rev
Author:   vadz
Date:     2008-05-01 16:06:14 -0700 (Thu, 01 May 2008)

Log Message:
-----------
moved code for bouncing messages into SendMessage::Bounce()

Modified Paths:
--------------
    trunk/M/include/SendMessage.h
    trunk/M/include/SendMessageCC.h
    trunk/M/src/mail/SendMessageCC.cpp

Modified: trunk/M/include/SendMessage.h
===================================================================
--- trunk/M/include/SendMessage.h       2008-05-01 23:04:18 UTC (rev 7436)
+++ trunk/M/include/SendMessage.h       2008-05-01 23:06:14 UTC (rev 7437)
@@ -64,7 +64,7 @@
       @param protocol which protocol to use for sending
       @param frame the parent window for dialogs, may be NULL
    */
-   static SendMessage *Create(Profile *profile,
+   static SendMessage *Create(const Profile *profile,
                               Protocol protocol = Prot_Default,
                               wxFrame *frame = NULL);
 
@@ -79,7 +79,7 @@
       @param message the original message (can't be NULL)
       @param frame the parent window for dialogs, may be NULL
    */
-   static SendMessage *CreateResent(Profile *profile,
+   static SendMessage *CreateResent(const Profile *profile,
                                     const Message *message,
                                     wxFrame *frame = NULL);
 
@@ -95,7 +95,7 @@
                          the message (consistent with Message::GetMimePart()
                          interpretation) to not copy to the new one
     */
-   static SendMessage *CreateFromMsg(Profile *profile,
+   static SendMessage *CreateFromMsg(const Profile *profile,
                                      const Message *message,
                                      Protocol protocol = Prot_Default,
                                      wxFrame *frame = NULL,
@@ -103,6 +103,23 @@
 
    //@}
 
+
+   /**
+      @name Various static helper functions.
+    */
+   //@{
+
+   /**
+      Bounce (i.e. resend) a message to the given address.
+    */
+   static bool Bounce(const String& address,
+                      const Profile *profile,
+                      const Message& message,
+                      wxFrame *frame = NULL);
+
+   //@}
+
+
    /** @name Standard headers */
    //@{
 

Modified: trunk/M/include/SendMessageCC.h
===================================================================
--- trunk/M/include/SendMessageCC.h     2008-05-01 23:04:18 UTC (rev 7436)
+++ trunk/M/include/SendMessageCC.h     2008-05-01 23:06:14 UTC (rev 7437)
@@ -111,7 +111,7 @@
    /**
      Ctor for base class static Create()
    */
-   SendMessageCC(Profile *profile,
+   SendMessageCC(const Profile *profile,
                  Protocol protocol,
                  wxFrame *frame,
                  const Message *message = NULL);
@@ -194,7 +194,7 @@
    //@}
 
    /// the profile containing our settings
-   Profile *m_profile;
+   const Profile * const m_profile;
 
    /// server name to use
    String m_ServerHost;

Modified: trunk/M/src/mail/SendMessageCC.cpp
===================================================================
--- trunk/M/src/mail/SendMessageCC.cpp  2008-05-01 23:04:18 UTC (rev 7436)
+++ trunk/M/src/mail/SendMessageCC.cpp  2008-05-01 23:06:14 UTC (rev 7437)
@@ -207,14 +207,14 @@
 
 /* static */
 SendMessage *
-SendMessage::Create(Profile *profile, Protocol protocol, wxFrame *frame)
+SendMessage::Create(const Profile *profile, Protocol protocol, wxFrame *frame)
 {
    return new SendMessageCC(profile, protocol, frame);
 }
 
 /* static */
 SendMessage *
-SendMessage::CreateResent(Profile *profile,
+SendMessage::CreateResent(const Profile *profile,
                           const Message *message,
                           wxFrame *frame)
 {
@@ -228,7 +228,7 @@
 
 /* static */
 SendMessage *
-SendMessage::CreateFromMsg(Profile *profile,
+SendMessage::CreateFromMsg(const Profile *profile,
                            const Message *message,
                            Protocol protocol,
                            wxFrame *frame,
@@ -242,6 +242,35 @@
    return msg;
 }
 
+/* static */
+bool SendMessage::Bounce(const String& address,
+                         const Profile *profile,
+                         const Message& message,
+                         wxFrame *frame)
+{
+   SendMessage_obj sendMsg(SendMessage::CreateResent(profile, &message, 
frame));
+   if ( !sendMsg )
+   {
+      ERRORMESSAGE((_("Failed to create the message to bounce.")));
+      return false;
+   }
+
+   sendMsg->SetAddresses(address);
+
+   // there is no need to store bounced messages in "sent mail" folder
+   sendMsg->SetFcc("");
+
+   if ( !sendMsg->SendOrQueue() )
+   {
+      ERRORMESSAGE((_("Failed to bounce the message to \"%s\"."),
+                    address.c_str()));
+
+      return false;
+   }
+
+   return true;
+}
+
 SendMessage::~SendMessage()
 {
 }
@@ -250,10 +279,11 @@
 // SendMessageCC creation and destruction
 // ----------------------------------------------------------------------------
 
-SendMessageCC::SendMessageCC(Profile *profile,
+SendMessageCC::SendMessageCC(const Profile *profile,
                              Protocol protocol,
                              wxFrame *frame,
                              const Message *message)
+             : m_profile(profile)
 {
    m_frame = frame;
    m_encHeaders = wxFONTENCODING_SYSTEM;
@@ -278,8 +308,7 @@
       profile = mApplication->GetProfile();
    }
 
-   m_profile = profile;
-   m_profile->IncRef();
+   const_cast<Profile *>(m_profile)->IncRef();
 
    // choose the protocol: mail (and whether it is SMTP or sendmail) or news
    if ( protocol == Prot_Default )
@@ -602,7 +631,7 @@
       delete [] m_headerValues;
    }
 
-   m_profile->DecRef();
+   const_cast<Profile *>(m_profile)->DecRef();
 }
 
 // ----------------------------------------------------------------------------


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to