Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21010/src/gui
Modified Files:
wxHeadersDialogs.cpp wxComposeView.cpp wxMenuDefs.cpp
Log Message:
added a possibility to configure what message (if any) we're replying to (part
of bug 761)
Index: wxHeadersDialogs.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxHeadersDialogs.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -b -u -2 -r1.47 -r1.48
--- wxHeadersDialogs.cpp 26 Feb 2005 23:26:16 -0000 1.47
+++ wxHeadersDialogs.cpp 27 Feb 2005 00:31:39 -0000 1.48
@@ -1281,2 +1281,24 @@
}
+bool ConfigureInReplyToHeader(String *messageid, wxWindow *parent)
+{
+ CHECK( messageid, false, _T("NULL messageid") );
+
+ wxTextEntryDialog dlg
+ (
+ parent,
+ _("Message is a reply to (empty string means that this\n"
+ "message is a start of new thread and not a reply at "
+ "all):"),
+ _("Is this message a reply?"),
+ *messageid
+ );
+
+ if ( dlg.ShowModal() != wxID_OK )
+ return false;
+
+ *messageid = dlg.GetValue();
+
+ return true;
+}
+
Index: wxComposeView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxComposeView.cpp,v
retrieving revision 1.380
retrieving revision 1.381
diff -b -u -2 -r1.380 -r1.381
--- wxComposeView.cpp 16 Nov 2004 10:07:29 -0000 1.380
+++ wxComposeView.cpp 27 Feb 2005 00:31:39 -0000 1.381
@@ -3209,4 +3209,8 @@
break;
+ case WXMENU_COMPOSE_IN_REPLY_TO:
+ ConfigureInReplyTo();
+ break;
+
case WXMENU_COMPOSE_CUSTOM_HEADERS:
{
@@ -4162,9 +4166,9 @@
// add any additional header lines: first for this time only and then also
// the headers stored in the profile
- kbStringList::iterator i = m_ExtraHeaderLinesNames.begin();
- kbStringList::iterator i2 = m_ExtraHeaderLinesValues.begin();
- for ( ; i != m_ExtraHeaderLinesNames.end(); i++, i2++ )
+ kbStringList::iterator i = m_extraHeadersNames.begin();
+ kbStringList::iterator j = m_extraHeadersValues.begin();
+ for ( ; i != m_extraHeadersNames.end(); ++i, ++j )
{
- msg->AddHeaderEntry(**i, **i2);
+ msg->AddHeaderEntry(**i, **j);
}
@@ -4301,13 +4305,146 @@
void
-wxComposeView::AddHeaderEntry(const String &entry,
- const String &ivalue)
+wxComposeView::AddHeaderEntry(const String& name, const String& value)
+{
+ // first check if we don't already have a header with this name
+ const kbStringList::iterator end = m_extraHeadersNames.end();
+ kbStringList::iterator i, j;
+ for ( i = m_extraHeadersNames.begin(),
+ j = m_extraHeadersValues.begin(); i != end; ++i, ++j )
+ {
+ if ( **i == name )
+ {
+ if ( value.empty() )
+ {
+ // remove the existing header
+ m_extraHeadersNames.erase(i);
+ m_extraHeadersValues.erase(j);
+ }
+ else // modify the existing header
+ {
+ **j = value;
+ }
+ break;
+ }
+ }
+
+ // if we didn't find it, add a new one
+ if ( i == end )
+ {
+ m_extraHeadersNames.push_back(new String(name));
+ m_extraHeadersValues.push_back(new String(value));
+ }
+}
+
+void wxComposeView::ConfigureInReplyTo()
{
- String
- *name = new String(entry),
- *value = new String(ivalue);
+ kbStringList::iterator end = m_extraHeadersNames.end();
+ kbStringList::iterator i, j;
+ for ( i = m_extraHeadersNames.begin(),
+ j = m_extraHeadersValues.begin(); i != end; ++i, ++j )
+ {
+ if ( **i == _T("In-Reply-To") )
+ break;
+ }
+
+ String messageId;
+ if ( i != end )
+ messageId = **j;
+
+ String messageIdNew = messageId;
+ if ( ConfigureInReplyToHeader(&messageIdNew, this) &&
+ messageIdNew != messageId )
+ {
+ if ( messageIdNew.empty() )
+ {
+ m_extraHeadersNames.erase(i);
+ m_extraHeadersValues.erase(j);
+
+ // also update references header
+ for ( i = m_extraHeadersNames.begin(),
+ end = m_extraHeadersNames.end(),
+ j = m_extraHeadersValues.begin() ; i != end; ++i, ++j )
+ {
+ if ( **i == _T("References") )
+ {
+ String ref = **j;
+ ref.Trim(true).Trim(false);
+
+ if ( ref == messageId )
+ {
+ // just remove the header completely
+ m_extraHeadersNames.erase(i);
+ m_extraHeadersValues.erase(j);
+ }
+ else // need to edit it
+ {
+ size_t pos = ref.find(messageId);
+ if ( pos != String::npos )
+ {
+ // no need to check for "pos > 0" as the string can't
+ // start with spaces: we've trimmed it above
+ size_t n;
+ for ( n = 1; isspace(ref[pos - n]); n++ )
+ ;
- m_ExtraHeaderLinesNames.push_back(name);
- m_ExtraHeaderLinesValues.push_back(value);
+ n--; // took one too many: this one is not a space
+
+ // remove this message id with all preceding space
+ ref.erase(pos - n, n + messageId.length());
+
+ **j = ref;
+ }
+ }
+ break;
+ }
+ }
+ }
+ else // should be a reply
+ {
+ if ( i == end )
+ {
+ AddHeaderEntry(_T("In-Reply-To"), messageIdNew);
+ }
+ else // just modify existing value
+ {
+ **j = messageIdNew;
+ }
+
+ // and add to references
+ for ( i = m_extraHeadersNames.begin(),
+ end = m_extraHeadersNames.begin(),
+ j = m_extraHeadersValues.begin(); i != end; ++i, ++j )
+ {
+ if ( **i == _T("References") )
+ {
+ String ref = **j;
+
+ // if we had a message id already, replace the old one with the
+ // new one
+ if ( messageId.empty() || !ref.Replace(messageId, messageIdNew)
)
+ {
+ // if replacement failed (or if we had nothing to replace),
+ // just add new message id
+ if ( !ref.empty() )
+ {
+ // continue "References" header on the next line
+ ref += _T("\015\012 ");
+ }
+
+ ref += messageIdNew;
+ }
+
+ **j = ref;
+
+ break;
+ }
+ }
+
+ if ( i == end )
+ {
+ AddHeaderEntry(_T("References"), messageIdNew);
+ }
+ }
+ }
}
Index: wxMenuDefs.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMenuDefs.cpp,v
retrieving revision 1.225
retrieving revision 1.226
diff -b -u -2 -r1.225 -r1.226
--- wxMenuDefs.cpp 12 Sep 2004 22:57:46 -0000 1.225
+++ wxMenuDefs.cpp 27 Feb 2005 00:31:40 -0000 1.226
@@ -464,5 +464,5 @@
// the available accelerators for this menu:
- // ABFGJMQRUXYZ
+ // ABFGJMQUXYZ
{ WXMENU_COMPOSE_INSERTFILE, gettext_noop("&Insert file...\tCtrl-I"),
gettext_noop("Attach a file to the
message") , wxITEM_NORMAL },
@@ -489,4 +489,5 @@
{ WXMENU_COMPOSE_EXTEDIT, gettext_noop("&External
editor\tCtrl-E"),gettext_noop("Invoke alternative editor"), wxITEM_NORMAL },
{ WXMENU_SEPARATOR, wxEmptyString, wxEmptyString
, wxITEM_NORMAL },
+ { WXMENU_COMPOSE_IN_REPLY_TO, gettext_noop("Set if this is a &reply..."),
gettext_noop("Set whether this message is a start of new thread or a reply to
another message"), wxITEM_NORMAL },
{ WXMENU_COMPOSE_CUSTOM_HEADERS, gettext_noop("Custom &header...\tCtrl-H"),
gettext_noop("Add/edit header fields not shown on the screen"), wxITEM_NORMAL },
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates