|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
KMail opening by message serial number abailityHello Everyone.
I'm working with Trueg on adding Nepomuk features into some parts of KDE. One of this feature It's mostly a proof of concept, and something else cleaner and more powerful will be done once akonadi will be ready, but for now we need it to work with KMail. What I need is kmail messages uniques Id which I can retrieve from message and especially with which I can open kmail with. For retrieving, I use KMMsgBase::getMsgSerNum(), no problem on this this side. For opening KMail with the serial Number as argument, I hade to patch KMail following McGuire intructions, and following the --view option implementation. It works well, but It crashes when closing the kmail mail window .Tom has no idea of what could cause it, I searched a lot, and I cannot understand why it crashes ; so here am I soliciting kde-pim mailing-list help. Here is join my patch ; I had an --viewid (yes id is not well choosen but it's shorter than --viewByMsgSerNum) option following the --view one ; the code is short & simple. Tom suggests that it crashes because kmfolder remain open ; but I can't close it currently (I made a slot for closing it on KMReaderWindow deletion, but it crashes before the slot could be called) Here is a crash gdb core dump : http://myfreefilehosting.com/f/b582ff3324_3.89MB and the backtrace : #0 0x0e000028 in ?? () #1 0xb6c20788 in KMMsgBase::syncIndexString (this=0x9536c78) at /home/mdupuy/dev/kmail-patch/kdepim/kmail/kmmsgbase.cpp:1209 #2 0xb6dadf8b in KMFolderIndex::updateIndex (this=0x94e4140, aboutToClose=true) at /home/mdupuy/dev/kmail-patch/kdepim/kmail/kmfolderindex.cpp:57 #3 0xb6c94818 in KMFolderMaildir::reallyDoClose (this=0x94e4140) at /home/mdupuy/dev/kmail-patch/kdepim/kmail/kmfoldermaildir.cpp:199 #4 0xb6bacb6d in FolderStorage::close (this=0x954ef80, aForced=128) at /home/mdupuy/dev/kmail-patch/kdepim/kmail/folderstorage.cpp:110 #5 0xb6b7a216 in KMFolder::close (this=0x94de960, owner=0xb706a416 "kmkernel", force=<value optimized out>) at /home/mdupuy/dev/kmail-patch/kdepim/kmail/kmfolder.cpp:543 #6 0xb6cb35a3 in KMKernel::cleanup (this=0xbfb44a84) at /home/mdupuy/dev/kmail-patch/kdepim/kmail/kmkernel.cpp:1733 #7 0x0804a63c in main (argc=4, argv=0xbfb44cf4) at /home/mdupuy/dev/kmail-patch/kdepim/kmail/main.cpp:148 Thanks in advance. -- Dupuy Mathieu Mandriva Intern R&D Department diff -rupN --exclude=.svn --exclude=TAGS kmail.ori/CMakeLists.txt kmail/CMakeLists.txt --- kmail.ori/CMakeLists.txt 2009-10-22 12:52:43.000000000 +0200 +++ kmail/CMakeLists.txt 2009-10-23 17:45:01.000000000 +0200 @@ -238,6 +238,7 @@ set(kmailprivate_LIB_SRCS messageactions.cpp statusbarlabel.cpp groupware_types.cpp + proxyobject.cpp kleojobexecutor.cpp messagetree.cpp procmailparser.cpp diff -rupN --exclude=.svn --exclude=TAGS kmail.ori/kmail_options.h kmail/kmail_options.h --- kmail.ori/kmail_options.h 2009-10-22 12:52:43.000000000 +0200 +++ kmail/kmail_options.h 2009-10-23 17:05:42.000000000 +0200 @@ -22,6 +22,7 @@ static KCmdLineOptions kmail_options () options.add("check", ki18n("Only check for new mail")); options.add("composer", ki18n("Only open composer window")); options.add("view <url>", ki18n("View the given message file" )); + options.add("viewid <msg id>", ki18n("View the given message corresponding to the kmail id" )); options.add("+[address|URL]", ki18n("Send message to 'address' resp. " "attach the file the 'URL' points " "to")); diff -rupN --exclude=.svn --exclude=TAGS kmail.ori/kmcommands.cpp kmail/kmcommands.cpp --- kmail.ori/kmcommands.cpp 2009-10-22 12:52:43.000000000 +0200 +++ kmail/kmcommands.cpp 2009-10-23 17:28:00.000000000 +0200 @@ -135,6 +135,7 @@ using namespace KMime; #include <QList> #include <QTextCodec> #include <QProgressBar> +#include <QDBusInterface> #include <memory> @@ -244,8 +245,8 @@ void KMCommand::slotStart() if ( mMsgList.size() > 0 ) mb = *(mMsgList.begin()); - if ( ( mb ) && ( mMsgList.count() == 1 ) && ( mb->isMessage() ) && - ( mb->parent() == 0 ) ) + if ( ( mb ) && ( mMsgList.count() == 1 ) + && ( mb->isMessage() ) && ( mb->parent() == 0 ) ) { // Special case of operating on message that isn't in a folder mRetrievedMsgs.append((KMMessage*)mMsgList.takeFirst()); @@ -989,6 +990,16 @@ KMOpenMsgCommand::KMOpenMsgCommand( QWid setDeletesItself( true ); } +KMOpenMsgCommand2::KMOpenMsgCommand2( QWidget *parent, KMMsgBase* message, + const QString & encoding ) + : KMCommand( parent, message ), + mMsgBase( message ), + mEncoding( encoding ) +{ + Q_ASSERT(message != NULL ); + setDeletesItself( false ); +} + KMCommand::Result KMOpenMsgCommand::execute() { if ( mUrl.isEmpty() ) { @@ -1009,6 +1020,31 @@ KMCommand::Result KMOpenMsgCommand::exec return OK; } +KMCommand::Result KMOpenMsgCommand2::execute() +{ + KMReaderMainWin *win = new KMReaderMainWin(); + KMMessage* msg = retrievedMessage(); + msg->setReadyToShow( true ); + Q_ASSERT( msg != NULL ); + win->showMsg( mEncoding, msg); + win->show(); + + setResult( OK ); + emit completed( this ); + // deleteLater(); + + connect(win, SIGNAL( destroyed() ), + this, SLOT(closeFolder() )); + mMsgBase = msg; + return OK; +} + +void KMOpenMsgCommand2::closeFolder() +{ + kDebug() << "destruction called"; + mMsgBase->parent()->close("viewid", true); +} + void KMOpenMsgCommand::slotDataArrived( KIO::Job *, const QByteArray & data ) { if ( data.isEmpty() ) @@ -2122,6 +2158,7 @@ KMCommand::Result KMMoveCommand::execute undoId = kmkernel->undoStack()->newUndoAction( srcFolder, mDestFolder ); kmkernel->undoStack()->addMsgToAction( undoId, mb->getMsgSerNum() ); } + } else if (rc != 0) { // Something went wrong. Stop processing here, it is likely that the // other moves would fail as well. diff -rupN --exclude=.svn --exclude=TAGS kmail.ori/kmcommands.h kmail/kmcommands.h --- kmail.ori/kmcommands.h 2009-10-22 12:52:43.000000000 +0200 +++ kmail/kmcommands.h 2009-10-23 17:05:20.000000000 +0200 @@ -373,6 +373,26 @@ private: const QString mEncoding; }; +class KMAIL_EXPORT KMOpenMsgCommand2 : public KMCommand +{ + Q_OBJECT +public: + explicit KMOpenMsgCommand2( QWidget *parent, KMMsgBase* msgbase, + const QString & encoding = QString() ); +private: + virtual KMCommand::Result execute(); + +private slots: + void closeFolder(); + + // private slots: + // void slotResult(); + + private: + KMMsgBase* mMsgBase; + const QString mEncoding; +}; + class KMAIL_EXPORT KMSaveAttachmentsCommand : public KMCommand { Q_OBJECT diff -rupN --exclude=.svn --exclude=TAGS kmail.ori/kmkernel.cpp kmail/kmkernel.cpp --- kmail.ori/kmkernel.cpp 2009-10-22 12:52:43.000000000 +0200 +++ kmail/kmkernel.cpp 2009-10-23 17:05:05.000000000 +0200 @@ -2,6 +2,8 @@ #include "kmkernel.h" +#include "proxyobject.h" + #include <config-kmail.h> #include "globalsettings.h" @@ -214,10 +216,12 @@ bool KMKernel::handleCommandLine( bool n QString to, cc, bcc, subj, body; QStringList customHeaders; KUrl messageFile; + unsigned long msgSerNum = 0; KUrl::List attachURLs; bool mailto = false; bool checkMail = false; bool viewOnly = false; + bool viewOnlyId = false; bool calledWithSession = false; // for ignoring '-session foo' // process args: @@ -301,6 +305,15 @@ bool KMKernel::handleCommandLine( bool n } } + if (args->isSet( "viewid" ) ) { + viewOnlyId = true; + const QString MsgSerNum = args->getOption( "viewid" ); + bool conv_ok; + msgSerNum = MsgSerNum.toInt(&conv_ok); + Q_ASSERT(conv_ok != false); + //kDebug() << "MESSAGE SERIAL NUM:" << MsgSerNum; + } + if ( !calledWithSession ) { // only read additional command line arguments if kmail/kontact is // not called with "-session foo" @@ -340,7 +353,9 @@ bool KMKernel::handleCommandLine( bool n if ( !noArgsOpensReader && !mailto && !checkMail && !viewOnly ) return false; - if ( viewOnly ) + if ( viewOnlyId ) + viewMessage( msgSerNum ); + else if ( viewOnly ) viewMessage( messageFile ); else action( mailto, checkMail, to, cc, bcc, subj, body, messageFile, @@ -706,6 +721,14 @@ int KMKernel::viewMessage( const KUrl & return 1; } +int KMKernel::viewMessage( unsigned long msgSerNum ) +{ + proxyObject* prox = new proxyObject(msgSerNum, this); + QTimer::singleShot(2000, prox, SLOT( Proxy() )); + + return 1; +} + int KMKernel::sendCertificate( const QString& to, const QByteArray& certData ) { KMMessage *msg = new KMMessage; diff -rupN --exclude=.svn --exclude=TAGS kmail.ori/kmkernel.h kmail/kmkernel.h --- kmail.ori/kmkernel.h 2009-10-22 12:52:43.000000000 +0200 +++ kmail/kmkernel.h 2009-10-23 17:05:05.000000000 +0200 @@ -14,6 +14,7 @@ #include <kconfig.h> #include <kurl.h> +#include "kmmsgbase.h" #include "kmail_export.h" #include "kmmsgbase.h" #include "kmmessagetag.h" @@ -229,6 +230,7 @@ public Q_SLOTS: Q_SCRIPTABLE QString debugSernum( quint32 serialNumber ); Q_SCRIPTABLE int viewMessage( const KUrl & messageFile ); + Q_SCRIPTABLE int viewMessage( unsigned long msgSerNum ); Q_SIGNALS: diff -rupN --exclude=.svn --exclude=TAGS kmail.ori/proxyobject.cpp kmail/proxyobject.cpp --- kmail.ori/proxyobject.cpp 1970-01-01 01:00:00.000000000 +0100 +++ kmail/proxyobject.cpp 2009-10-23 17:21:06.000000000 +0200 @@ -0,0 +1,25 @@ +#include "proxyobject.h" +#include "kmmsgbase.h" +#include "kmmsgdict.h" +#include "kmcommands.h" +#include "kmfolder.h" + +void proxyObject::Proxy() +{ + KMFolder* folder; + KMMsgBase* msgbase; + int index; + + KMMsgDict::instance()->getLocation( msgSerNum, &folder, &index ); + if ( folder != NULL && index != -1 ) { + kFatal("msg serial number not found ; the serial number provided may incorrect"); + } + folder->open("viewid"); + msgbase = folder->getMsgBase( index ); + Q_ASSERT( msgbase != NULL ); + + KMOpenMsgCommand2 *openCommand = new KMOpenMsgCommand2( 0, msgbase ); + openCommand->start(); +} + +#include "proxyobject.moc" diff -rupN --exclude=.svn --exclude=TAGS kmail.ori/proxyobject.h kmail/proxyobject.h --- kmail.ori/proxyobject.h 1970-01-01 01:00:00.000000000 +0100 +++ kmail/proxyobject.h 2009-10-23 17:21:06.000000000 +0200 @@ -0,0 +1,21 @@ +#ifndef _PROXYOBJECT_H_ +#define _PROXYOBJECT_H_ + +#include <QObject> + +class proxyObject : public QObject +{ + Q_OBJECT + unsigned long msgSerNum; + +public: + proxyObject( unsigned long serNum, QObject* parent = 0 ) : + QObject( parent ), msgSerNum( serNum) + { + } + +public slots: + void Proxy(); +}; + +#endif _______________________________________________ KDE PIM mailing list kde-pim@... https://mail.kde.org/mailman/listinfo/kde-pim KDE PIM home page at http://pim.kde.org/ |
|
|
Re: KMail opening by message serial number abailityMathieu Dupuy a écrit :
> Hello Everyone. > I'm working with Trueg on adding Nepomuk features into some parts of > KDE. One of this feature > It's mostly a proof of concept, and something else cleaner and more > powerful will be done once akonadi will be ready, but for now we need > it to work with KMail. > > What I need is kmail messages uniques Id which I can retrieve from > message and especially with which I can open kmail with. For > retrieving, I use KMMsgBase::getMsgSerNum(), no problem on this this > side. > For opening KMail with the serial Number as argument, I hade to patch > KMail following McGuire intructions, and following the --view option > implementation. It works well, but It crashes when closing the kmail > mail window .Tom has no idea of what could cause it, I searched a lot, > and I cannot understand why it crashes ; so here am I soliciting > kde-pim mailing-list help. > > Here is join my patch ; I had an --viewid (yes id is not well choosen > but it's shorter than --viewByMsgSerNum) option following the --view > one ; the code is short & simple. > > Tom suggests that it crashes because kmfolder remain open ; but I > can't close it currently (I made a slot for closing it on > KMReaderWindow deletion, but it crashes before the slot could be called) > > Here is a crash gdb core dump : > http://myfreefilehosting.com/f/b582ff3324_3.89MB > and the backtrace : > > #0 0x0e000028 in ?? () > #1 0xb6c20788 in KMMsgBase::syncIndexString (this=0x9536c78) > at /home/mdupuy/dev/kmail-patch/kdepim/kmail/kmmsgbase.cpp:1209 > #2 0xb6dadf8b in KMFolderIndex::updateIndex (this=0x94e4140, > aboutToClose=true) > at /home/mdupuy/dev/kmail-patch/kdepim/kmail/kmfolderindex.cpp:57 > #3 0xb6c94818 in KMFolderMaildir::reallyDoClose (this=0x94e4140) > at /home/mdupuy/dev/kmail-patch/kdepim/kmail/kmfoldermaildir.cpp:199 > #4 0xb6bacb6d in FolderStorage::close (this=0x954ef80, aForced=128) > at /home/mdupuy/dev/kmail-patch/kdepim/kmail/folderstorage.cpp:110 > #5 0xb6b7a216 in KMFolder::close (this=0x94de960, owner=0xb706a416 > "kmkernel", force=<value optimized out>) > at /home/mdupuy/dev/kmail-patch/kdepim/kmail/kmfolder.cpp:543 > #6 0xb6cb35a3 in KMKernel::cleanup (this=0xbfb44a84) at > /home/mdupuy/dev/kmail-patch/kdepim/kmail/kmkernel.cpp:1733 > #7 0x0804a63c in main (argc=4, argv=0xbfb44cf4) at > /home/mdupuy/dev/kmail-patch/kdepim/kmail/main.cpp:148 > > > Thanks in advance. > ------------------------------------------------------------------------ > > _______________________________________________ > KDE PIM mailing list kde-pim@... > https://mail.kde.org/mailman/listinfo/kde-pim > KDE PIM home page at http://pim.kde.org/ -- Dupuy Mathieu Mandriva Intern R&D Department _______________________________________________ KDE PIM mailing list kde-pim@... https://mail.kde.org/mailman/listinfo/kde-pim KDE PIM home page at http://pim.kde.org/ |
| Free embeddable forum powered by Nabble | Forum Help |