[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: Re: [PATCH] Use folder identity when composing from kontact/dcop
From: Paul Sprakes <paul () sprakes ! co ! uk>
Date: 2005-04-12 17:00:18
Message-ID: 200504121800.19485.paul () sprakes ! co ! uk
[Download RAW message or body]
On Saturday 09 Apr 2005 00:00, Ingo Klöcker wrote:
> On Saturday 09 April 2005 00:48, Paul Sprakes wrote:
> > On Friday 08 Apr 2005 23:23, Ingo Klöcker wrote:
> > > On Friday 08 April 2005 13:14, Paul Sprakes wrote:
> > > > Currently, the folder identity is not used when composing a new
> > > > mail from Kontact. The attached patch fixes that.
> > > >
> > > > There are a few bug reports about this but they all seem to be
> > > > fixed?
> > > >
> > > > Is it OK to commit?
> > >
> > > No. Your patch doesn't only address the problem with Kontact but it
> > > makes KMail always use the folder identity if a new message window
> > > is opened via DCOP. I don't think this is always desired. In
> > > particular, if I click on an email address on a web page or if I
> > > select "Send Message To" from KAddressBook/Contacts then the
> > > default identity should be used. Using the folder identity really
> > > only makes sense when the user clicks on the New Message icon in
> > > Kontact. Otherwise it doesn't make sense.
> > >
> > > What this boils down to is that we either need special DCOP calls
> > > for Kontact or that we need to add another option to the DCOP
> > > calls. Since both requires the introduction of new DCOP calls
> > > (because the DCOP API has to stay backwards compatible) we should
> > > simply add special hidden DCOP calls for Kontact.
> >
> > Right, I see. I haven't really looked at DCOP before so not sure how
> > to go about creating hidden ones. Could you point out some example I
> > could look at?
>
> See kmailIface.h and look for k_dcop_hidden.
>
> > Looking at newInstance() in KMailPlugin the first thing it does is:
> >
> > DCOPReply reply = kmail.call( "handleCommandLine", false );
> >
> > Would adding something like:
> >
> > DCOPReply reply = kmail.call( "useFolderIdentities", true );
> >
> > Not be sufficient?
>
> I don't think so because it could interfere with other DCOP calls coming
> from other applications.
>
> > The other option seems to me to duplicate loads of
> > calls with an extra option.
>
> We probably don't need to duplicate all of those calls for Kontact.
>
> Regards,
> Ingo
Thanks for the pointers Ingo. I have come up with the attached patch. Is this
one OK to commit?
I have changed the method signature of newMessage() to try and make it a bit
future proof and because it's hidden it shouldn't effect compatibility (I
hope). But if that's not the case I can add the no-args version back.
Thanks, Paul.
["kmail-kontact_folder-ident.patch" (text/x-diff)]
Index: kmail/kmailIface.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmailIface.h,v
retrieving revision 1.38
diff -U3 -r1.38 kmailIface.h
--- kmail/kmailIface.h 31 Jan 2005 23:13:47 -0000 1.38
+++ kmail/kmailIface.h 12 Apr 2005 11:15:07 -0000
@@ -112,7 +112,13 @@
k_dcop_hidden:
/** DCOP call which is used by the Kontact plugin to create a new message. */
- virtual DCOPRef newMessage() = 0;
+ virtual DCOPRef newMessage(const QString &to,
+ const QString &cc,
+ const QString& bcc,
+ bool hidden,
+ bool useFolderId,
+ const KURL &messageFile,
+ const KURL &attachURL) = 0;
virtual bool showMail( Q_UINT32 serialNumber, QString messageId ) = 0;
/**
Index: kmail/kmkernel.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmkernel.cpp,v
retrieving revision 1.331
diff -U3 -r1.331 kmkernel.cpp
--- kmail/kmkernel.cpp 5 Apr 2005 18:15:03 -0000 1.331
+++ kmail/kmkernel.cpp 12 Apr 2005 11:15:09 -0000
@@ -537,25 +537,41 @@
return DCOPRef(cWin);
}
-DCOPRef KMKernel::newMessage()
+DCOPRef KMKernel::newMessage(const QString &to,
+ const QString &cc,
+ const QString &bcc,
+ bool hidden,
+ bool useFolderId,
+ const KURL &messageFile,
+ const KURL &attachURL)
{
- KMFolder *folder = 0;
- KMMainWidget *widget = getKMMainWidget();
- if ( widget && widget->folderTree() )
- folder = widget->folderTree()->currentFolder();
-
- // the following code is basically the same as in KMMainWidget::slotCompose()
KMComposeWin *win;
KMMessage *msg = new KMMessage;
- if ( folder ) {
- msg->initHeader( folder->identity() );
- win = new KMComposeWin( msg, folder->identity() );
+
+ if ( useFolderId ) {
+ //create message with required folder identity
+ KMFolder *folder = currentFolder();
+ uint id = folder ? folder->identity() : 0;
+ msg->initHeader( id );
+ win = new KMComposeWin( msg, id );
} else {
msg->initHeader();
win = new KMComposeWin( msg );
}
- win->show();
+ msg->setCharset("utf-8");
+ //set basic headers
+ if (!to.isEmpty()) msg->setTo(to);
+ if (!cc.isEmpty()) msg->setCc(cc);
+ if (!bcc.isEmpty()) msg->setBcc(bcc);
+ //Add the attachment if we have one
+ if(!attachURL.isEmpty() && attachURL.isValid()) {
+ win->addAttach(attachURL);
+ }
+ //only show window when required
+ if(!hidden) {
+ win->show();
+ }
return DCOPRef( win );
}
@@ -2054,4 +2070,13 @@
return folders;
}
+KMFolder *KMKernel::currentFolder() {
+ KMMainWidget *widget = getKMMainWidget();
+ KMFolder *folder = 0;
+ if ( widget && widget->folderTree() ) {
+ folder = widget->folderTree()->currentFolder();
+ }
+ return folder;
+}
+
#include "kmkernel.moc"
Index: kmail/kmkernel.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmkernel.h,v
retrieving revision 1.134
diff -U3 -r1.134 kmkernel.h
--- kmail/kmkernel.h 5 Apr 2005 20:38:21 -0000 1.134
+++ kmail/kmkernel.h 12 Apr 2005 11:15:10 -0000
@@ -127,7 +127,13 @@
const QString &body,bool hidden);
/** DCOP call used by the Kontact plugin to create a new message. */
- DCOPRef newMessage();
+ DCOPRef newMessage(const QString &to,
+ const QString &cc,
+ const QString &bcc,
+ bool hidden,
+ bool useFolderId,
+ const KURL &messageFile,
+ const KURL &attachURL);
int sendCertificate( const QString& to, const QByteArray& certData );
@@ -332,6 +338,7 @@
private:
void openReader( bool onlyCheck );
+ KMFolder *currentFolder();
KMFolder *the_inboxFolder;
KMFolder *the_outboxFolder;
Index: kontact/plugins/kmail/kmail_plugin.cpp
===================================================================
RCS file: /home/kde/kdepim/kontact/plugins/kmail/kmail_plugin.cpp,v
retrieving revision 1.49
diff -U3 -r1.49 kmail_plugin.cpp
--- kontact/plugins/kmail/kmail_plugin.cpp 25 Mar 2005 21:23:59 -0000 1.49
+++ kontact/plugins/kmail/kmail_plugin.cpp 12 Apr 2005 11:15:12 -0000
@@ -104,9 +104,9 @@
Q_ASSERT( mStub );
if ( mStub ) {
if ( attach.isValid() )
- mStub->openComposer( "", "", "", "", "", false, KURL(), attach );
+ mStub->newMessage( "", "", "", false, true, KURL(), attach );
else
- mStub->newMessage();
+ mStub->newMessage( "", "", "", false, true, KURL(), KURL() );
}
}
@@ -115,7 +115,7 @@
(void) part(); // ensure part is loaded
Q_ASSERT( mStub );
if ( mStub ) {
- mStub->openComposer( to, "", "", "", "", 0 );
+ mStub->newMessage( to, "", "", false, true, KURL(), KURL() );
}
}
_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic