Update of /cvsroot/mahogany/M/src/gui
In directory usw-pr-cvs1:/tmp/cvs-serv809/src/gui

Modified Files:
        wxComposeView.cpp 
Added Files:
        wxAttachDialog.cpp 
Log Message:
edited a dialog for editing the attachment properties (closes the bug 679)

***** Error reading new file: [Errno 2] No such file or directory: 'wxAttachDialog.cpp'
Index: wxComposeView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxComposeView.cpp,v
retrieving revision 1.297
retrieving revision 1.298
diff -b -u -2 -r1.297 -r1.298
--- wxComposeView.cpp   2 Sep 2002 00:44:07 -0000       1.297
+++ wxComposeView.cpp   2 Sep 2002 18:40:35 -0000       1.298
@@ -93,4 +93,5 @@
 #include "MessageTemplate.h"
 #include "TemplateDialog.h"
+#include "AttachDialog.h"
 
 #include "MModule.h"
@@ -673,5 +674,10 @@
 
    if ( filename )
+   {
+      m_Name =
       m_FileName = filename;
+   }
+
+   SetDisposition("INLINE");
 }
 
@@ -680,6 +686,20 @@
    ASSERT_MSG( !filename.empty(), "a file attachment must have a valid file" );
 
+   m_Name =
    m_FileName = filename;
    m_Type = Type_File;
+
+   if ( m_Disposition.empty() )
+      SetDisposition("ATTACHMENT");
+}
+
+void EditorContentPart::SetName(const String& name)
+{
+   m_Name = name;
+}
+
+void EditorContentPart::SetDisposition(const String& disposition)
+{
+   m_Disposition = disposition;
 }
 
@@ -690,4 +710,6 @@
    m_Type = Type_Text;
    m_Text = text;
+
+   SetDisposition("INLINE");
 }
 
@@ -2952,25 +2974,31 @@
    }
 
-   String msg;
-   msg.Printf(_("File '%s' seems to contain data of MIME type '%s'.\n"
-                "\n"
-                "Is this correct?"),
-              filename.c_str(), strMimeType.c_str());
-   if ( !MDialog_YesNoDialog( msg, this, _("Content MIME type"),
-                              M_DLG_YES_DEFAULT,
-                              M_MSGBOX_MIME_TYPE_CORRECT) )
+   // create the new attachment
+   EditorContentPart *mc = new EditorContentPart();
+
+   AttachmentProperties props;
+   props.filename = filename;
+   props.name = filename;
+   props.disposition = AttachmentProperties::Disposition_Inline;
+   props.mimetype = strMimeType;
+
+   // show the attachment properties dialog automatically?
+   String configPath = GetPersMsgBoxName(M_MSGBOX_MIME_TYPE_CORRECT);
+   if ( !wxPMessageBoxIsDisabled(configPath) )
    {
-      wxString newtype = strMimeType;
-      if(MInputBox(&newtype, _("MIME type"),
-                   _("Please enter new MIME type:"),
-                   this))
+      bool dontShowAgain = false;
+      if ( ShowAttachmentDialog(m_editor->GetWindow(), &props, &dontShowAgain) )
       {
-         strMimeType = newtype;
+         mc->SetName(props.name);
+         mc->SetDisposition(props.GetDisposition());
       }
+
+      if ( dontShowAgain )
+         wxPMessageBoxDisable(configPath, wxNO);
    }
 
-   EditorContentPart *mc = new EditorContentPart();
-   mc->SetFile(filename);
+   mc->SetFile(props.filename);
 
+   strMimeType = props.mimetype.GetFull();
    DoInsertAttachment(mc, strMimeType);
 
@@ -3266,5 +3294,11 @@
                      buffer[size] = '\0';
 
-                     String basename = wxFileNameFromPath(filename);
+                     // use the user provided name instead of local filename if
+                     // it was given
+                     String name = part->GetName();
+                     if ( name.empty() )
+                     {
+                        name = filename;
+                     }
 
                      MessageParameterList plist, dlist;
@@ -3272,17 +3306,22 @@
 
                      // some mailers want "FILENAME" in disposition parameters
-                     p = new MessageParameter("FILENAME", basename);
+                     // (where only file name, i.e. without path, should be
+                     // used for obvious security reasons)
+                     p = new MessageParameter("FILENAME",
+                                              wxFileNameFromPath(name));
                      dlist.push_back(p);
 
-                     // and some mailers want "NAME" in parameters:
-                     p = new MessageParameter("NAME", basename);
+                     // and some mailers want "NAME" in parameters (we can use
+                     // the full name here)
+                     p = new MessageParameter("NAME", name);
                      plist.push_back(p);
 
+                     const MimeType& mt = part->GetMimeType();
                      msg->AddPart
                           (
-                            part->GetMimeCategory(),
+                            mt.GetPrimary(),
                             buffer, size,
-                            strutil_after(part->GetMimeType(),'/'), //subtype
-                            "INLINE",
+                            mt.GetSubType(),
+                            part->GetDisposition(),
                             &dlist, &plist
                           );
@@ -3321,11 +3360,12 @@
                }
 
+               const MimeType& mt = part->GetMimeType();
                msg->AddPart
                     (
-                      part->GetMimeCategory(),
+                      mt.GetPrimary(),
                       (char *)part->GetData(),
                       part->GetSize(),
-                      strutil_after(part->GetMimeType(),'/'),  //subtype
-                      "INLINE",
+                      mt.GetSubType(),
+                      part->GetDisposition(),
                       &dlist,
                       &plist
@@ -3992,6 +4032,18 @@
    CHECK_RET( part, "no attachment to edit in EditAttachmentProperties" );
 
-   wxLogMessage("Attachment '%s' of type '%s' clicked",
-                part->GetFileName().c_str(), part->GetMimeType().c_str());
+   AttachmentProperties props;
+   props.filename = part->GetFileName();
+   props.name = part->GetName();
+   props.SetDisposition(part->GetDisposition());
+   props.mimetype = part->GetMimeType();
+
+   if ( ShowAttachmentDialog(GetWindow(), &props) )
+   {
+      part->SetFile(props.filename);
+      part->SetName(props.name);
+      part->SetMimeType(props.mimetype.GetFull());
+      part->SetDisposition(props.GetDisposition());
+   }
+   //else: cancelled by user or nothing changed
 }
 



-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to