void KCMKMailSummary::initFolders() { DCOPRef kmail( "kmail", "KMailIface" ); QStringList folderList; kmail.call( "folderList" ).get( folderList ); mFolderView->clear(); mFolderMap.clear(); QStringList::Iterator it; for ( it = folderList.begin(); it != folderList.end(); ++it ) { QString displayName; if ( (*it) == "/Local" ) displayName = i18n( "prefix for local folders", "Local" ); else { DCOPRef folderRef = kmail.call( "getFolder(QString)", *it ); folderRef.call( "displayName()" ).get( displayName ); } if ( (*it).contains( '/' ) == 1 ) { if ( mFolderMap.find( *it ) == mFolderMap.end() ) mFolderMap.insert( *it, new QListViewItem( mFolderView, displayName ) ); } else { const int pos = (*it).findRev( '/' ); const QString parentFolder = (*it).left( pos ); mFolderMap.insert( *it, new QCheckListItem( mFolderMap[ parentFolder ], displayName, QCheckListItem::CheckBox ) ); } } }
void KMailCVT::endImport() { QDBusConnectionInterface * sessionBus = 0; sessionBus = QDBusConnection::sessionBus().interface(); if ( sessionBus && !sessionBus->isServiceRegistered( "org.kde.kmail" ) ) KToolInvocation::startServiceByDesktopName( "kmail", QString() ); // Will wait until kmail is started org::kde::kmail::kmail kmail("org.kde.kmail", "/KMail", QDBusConnection::sessionBus()); QDBusReply<int> reply = kmail.dbusAddMessage(QString(), QString(),QString()); if ( !reply.isValid() ) return; QDBusReply<void> reply2 = kmail.dbusResetAddMessage(); if ( !reply2.isValid() ) return; }
void NewMailNotifierShowMessageJob::start() { if (mId < 0) { Q_EMIT emitResult(); return; } const QString kmailInterface = QStringLiteral("org.kde.kmail"); QDBusReply<bool> reply = QDBusConnection::sessionBus().interface()->isServiceRegistered(kmailInterface); if (!reply.isValid() || !reply.value()) { // Program is not already running, so start it QString errmsg; if (KToolInvocation::startServiceByDesktopName(QStringLiteral("org.kde.kmail"), QString(), &errmsg)) { qCDebug(NEWMAILNOTIFIER_LOG) << " Can not start kmail" << errmsg; setError(UserDefinedError); Q_EMIT emitResult(); return; } } QDBusInterface kmail(kmailInterface, QStringLiteral("/KMail"), QStringLiteral("org.kde.kmail.kmail")); if (kmail.isValid()) { kmail.call(QStringLiteral("showMail"), mId); } Q_EMIT emitResult(); }
bool KOMailClient::send( const Identity &identity, const QString &from, const QString &_to, const QString &cc, const QString &subject, const QString &body, bool hidden, bool bccMe, const QString &attachment, bool useSendmail ) { // We must have a recipients list for most MUAs. Thus, if the 'to' list // is empty simply use the 'from' address as the recipient. QString to = _to; if ( to.isEmpty() ) { to = from; } kDebug() << "\nFrom:" << from << "\nTo:" << to << "\nCC:" << cc << "\nSubject:" << subject << "\nBody: \n" << body << "\nAttachment:\n" << attachment; if ( useSendmail ) { bool needHeaders = true; QString command = KStandardDirs::findExe( QString::fromLatin1( "sendmail" ), QString::fromLatin1( "/sbin:/usr/sbin:/usr/lib" ) ); if ( !command.isEmpty() ) { command += QString::fromLatin1( " -oi -t" ); } else { command = KStandardDirs::findExe( QString::fromLatin1( "mail" ) ); if ( command.isEmpty() ) { return false; // give up } command.append( QString::fromLatin1( " -s " ) ); command.append( KShell::quoteArg( subject ) ); if ( bccMe ) { command.append( QString::fromLatin1( " -b " ) ); command.append( KShell::quoteArg( from ) ); } if ( !cc.isEmpty() ) { command.append( " -c " ); command.append( KShell::quoteArg( cc ) ); } command.append( " " ); command.append( KShell::quoteArg( to ) ); needHeaders = false; } FILE *fd = popen( command.toLocal8Bit(), "w" ); if ( !fd ) { kError() << "Unable to open a pipe to" << command; return false; } QString textComplete; if ( needHeaders ) { textComplete += QString::fromLatin1( "From: " ) + from + '\n'; textComplete += QString::fromLatin1( "To: " ) + to + '\n'; if ( !cc.isEmpty() ) { textComplete += QString::fromLatin1( "Cc: " ) + cc + '\n'; } if ( bccMe ) { textComplete += QString::fromLatin1( "Bcc: " ) + from + '\n'; } textComplete += QString::fromLatin1( "Subject: " ) + subject + '\n'; textComplete += QString::fromLatin1( "X-Mailer: KOrganizer" ) + korgVersion + '\n'; } textComplete += '\n'; // end of headers textComplete += body; textComplete += '\n'; textComplete += attachment; fwrite( textComplete.toLocal8Bit(), textComplete.length(), 1, fd ); pclose( fd ); } else { if ( !QDBusConnection::sessionBus().interface()->isServiceRegistered( "org.kde.kmail" ) ) { if ( KToolInvocation::startServiceByDesktopName( "kmail" ) ) { KMessageBox::error( 0, i18n( "No running instance of KMail found." ) ); return false; } } org::kde::kmail::kmail kmail( "org.kde.kmail", "/KMail", QDBusConnection::sessionBus() ); kapp->updateRemoteUserTimestamp( "org.kde.kmail" ); if ( attachment.isEmpty() ) { return kmail.openComposer( to, cc, bccMe ? from : QString(), subject, body, hidden ).isValid(); } else { QString meth; int idx = attachment.indexOf( "METHOD" ); if ( idx >= 0 ) { idx = attachment.indexOf( ':', idx ) + 1; const int newline = attachment.indexOf( '\n', idx ); meth = attachment.mid( idx, newline - idx - 1 ); meth = meth.toLower().trimmed(); } else { meth = "publish"; } return kmail.openComposer( to, cc, bccMe ? from : QString(), subject, body, hidden, "cal.ics", "7bit", attachment.toUtf8(), "text", "calendar", "method", meth, "attachment", "utf-8", identity.uoid() ).isValid(); } } return true; }