Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17524/src/gui

Modified Files:
        wxComposeView.cpp 
Log Message:
added possibility to optionally reuse an existing composer when replying to the 
same message second time

Index: wxComposeView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxComposeView.cpp,v
retrieving revision 1.399
retrieving revision 1.400
diff -b -u -2 -r1.399 -r1.400
--- wxComposeView.cpp   12 Feb 2006 17:33:31 -0000      1.399
+++ wxComposeView.cpp   12 Feb 2006 19:09:00 -0000      1.400
@@ -150,4 +150,5 @@
 
 extern const MPersMsgBox *M_MSGBOX_ASK_FOR_EXT_EDIT;
+extern const MPersMsgBox *M_MSGBOX_ASK_SAVE_HEADERS;
 extern const MPersMsgBox *M_MSGBOX_ASK_VCARD;
 extern const MPersMsgBox *M_MSGBOX_CONFIG_NET_FROM_COMPOSE;
@@ -155,8 +156,8 @@
 extern const MPersMsgBox *M_MSGBOX_DRAFT_SAVED;
 extern const MPersMsgBox *M_MSGBOX_FIX_TEMPLATE;
+extern const MPersMsgBox *M_MSGBOX_OPEN_ANOTHER_COMPOSER;
 extern const MPersMsgBox *M_MSGBOX_MIME_TYPE_CORRECT;
-extern const MPersMsgBox *M_MSGBOX_SEND_EMPTY_SUBJECT;
-extern const MPersMsgBox *M_MSGBOX_ASK_SAVE_HEADERS;
 extern const MPersMsgBox *M_MSGBOX_SEND_DIFF_ENCODING;
+extern const MPersMsgBox *M_MSGBOX_SEND_EMPTY_SUBJECT;
 
 // ----------------------------------------------------------------------------
@@ -1468,7 +1469,13 @@
                                 Message *original)
 {
-   wxComposeView *cv = CreateComposeView(profile, params,
+   wxComposeView *cv = CreateComposeView
+                       (
+                        profile,
+                        params,
                                          wxComposeView::Mode_News,
-                                         wxComposeView::Message_Reply);
+                        wxComposeView::Message_Reply
+                       );
+
+   CHECK( cv, NULL, _T("failed to create composer for a followup article") );
 
    cv->SetOriginal(original);
@@ -1496,7 +1503,13 @@
                              Message *original)
 {
-   wxComposeView *cv = CreateComposeView(profile, params,
+   wxComposeView *cv = CreateComposeView
+                       (
+                        profile,
+                        params,
                                          wxComposeView::Mode_Mail,
-                                         wxComposeView::Message_Reply);
+                        wxComposeView::Message_Reply
+                       );
+
+   CHECK( cv, NULL, _T("failed to create composer for a reply message") );
 
    cv->SetOriginal(original);
@@ -1510,7 +1523,13 @@
                            Message *original)
 {
-   wxComposeView *cv = CreateComposeView(profile, params,
+   wxComposeView *cv = CreateComposeView
+                       (
+                        profile,
+                        params,
                                          wxComposeView::Mode_Mail,
-                                         wxComposeView::Message_Forward);
+                        wxComposeView::Message_Forward
+                       );
+
+   CHECK( cv, NULL, _T("failed to create composer for a forward message") );
 
    cv->SetOriginal(original);
@@ -1649,4 +1668,40 @@
 }
 
+/* static */
+Composer *Composer::CheckForExistingReply(Message *original)
+{
+   CHECK( original, NULL, _T("original message is NULL") );
+
+   for ( ComposerList::iterator i = gs_listOfAllComposers.begin(),
+                              end = gs_listOfAllComposers.end(); i!= end ; ++i 
)
+   {
+      wxComposeView *cv = *i;
+      if ( cv->IsReplyTo(*original) )
+      {
+         if ( !MDialog_YesNoDialog
+               (
+                  _("Thee is already an existing composer window for this\n"
+                    "message, do you want to reuse it?"),
+                  cv->GetFrame(),
+                  MDIALOG_YESNOTITLE,
+                  M_DLG_YES_DEFAULT | M_DLG_DISABLE,
+                  M_MSGBOX_OPEN_ANOTHER_COMPOSER
+               ) )
+         {
+            // if the user doesn't want to reuse this one, he probably really
+            // wants a new composer so do open it without asking again
+            break;
+         }
+
+         // show the existing composer window
+         cv->GetFrame()->Raise();
+
+         return cv;
+      }
+   }
+
+   return NULL;
+}
+
 // ----------------------------------------------------------------------------
 // wxComposeView ctor/dtor
@@ -1681,4 +1736,24 @@
 }
 
+bool wxComposeView::IsReplyTo(const Message& original) const
+{
+   if ( !m_OriginalMessage )
+      return false;
+
+   // can't compose the messages by pointer, so do a "deep comparison" instead
+
+   // first do quick UIDs comparison
+   if ( m_OriginalMessage->GetUId() != original.GetUId() )
+      return false;
+
+   // for them to be really the same messages, UIDs must belong to the same
+   // folder
+   MailFolder *mf1 = original.GetFolder(),
+              *mf2 = m_OriginalMessage->GetFolder();
+   CHECK( mf1 && mf2, false, _T("messages without mail folder?") );
+
+   return mf1->GetName() == mf2->GetName();
+}
+
 void wxComposeView::SetOriginal(Message *original)
 {



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to