• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

mailcommon

  • sources
  • kde-4.14
  • kdepim
  • mailcommon
  • filter
  • filteractions
filteractionplaysound.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  */
19 
20 #include "filteractionplaysound.h"
21 
22 #include "dialog/filteractionmissingargumentdialog.h"
23 
24 #include <phonon/mediaobject.h>
25 
26 #include <KDE/KLocale>
27 
28 #include <QtCore/QFile>
29 #include <QPointer>
30 
31 using namespace MailCommon;
32 
33 FilterActionPlaySound::FilterActionPlaySound( )
34  : FilterActionWithTest( QLatin1String("play sound"), i18n( "Play Sound" ) )
35  , mPlayer( 0 )
36 {
37 }
38 
39 FilterActionPlaySound::~FilterActionPlaySound()
40 {
41  delete mPlayer;
42 }
43 
44 FilterAction* FilterActionPlaySound::newAction()
45 {
46  return new FilterActionPlaySound();
47 }
48 
49 
50 bool FilterActionPlaySound::isEmpty() const
51 {
52  return (mParameter.isEmpty());
53 }
54 
55 FilterAction::ReturnCode FilterActionPlaySound::process(ItemContext& , bool) const
56 {
57  if ( isEmpty() )
58  return ErrorButGoOn;
59 
60  if ( !mPlayer )
61  mPlayer = Phonon::createPlayer( Phonon::NotificationCategory );
62 
63  mPlayer->setCurrentSource( mParameter );
64  mPlayer->play();
65 
66  return GoOn;
67 }
68 
69 SearchRule::RequiredPart FilterActionPlaySound::requiredPart() const
70 {
71  return SearchRule::Envelope;
72 }
73 
74 
75 bool FilterActionPlaySound::argsFromStringInteractive( const QString &argsStr, const QString &filterName )
76 {
77  bool needUpdate = false;
78  argsFromString( argsStr );
79  if (!QFile(mParameter).exists()){
80  QPointer<FilterActionMissingSoundUrlDialog> dlg = new FilterActionMissingSoundUrlDialog( filterName, argsStr );
81  if ( dlg->exec() ) {
82  mParameter = dlg->soundUrl();
83  needUpdate = true;
84  }
85  delete dlg;
86  }
87  return needUpdate;
88 }
89 
90 QString FilterActionPlaySound::informationAboutNotValidAction() const
91 {
92  //KF5 add i18n
93  return QLatin1String("Sound file was not defined.");
94 }
MailCommon::FilterActionPlaySound::process
ReturnCode process(ItemContext &context, bool applyOnOutbound) const
Execute action on given message (inside the item context).
Definition: filteractionplaysound.cpp:55
MailCommon::FilterAction::GoOn
Go on with applying filter actions.
Definition: filteraction.h:62
MailCommon::FilterActionPlaySound::informationAboutNotValidAction
QString informationAboutNotValidAction() const
Definition: filteractionplaysound.cpp:90
MailCommon::FilterActionWithTest::argsFromString
virtual void argsFromString(const QString &argsStr)
Read extra arguments from given string.
Definition: filteractionwithtest.cpp:69
Phonon::MediaObject::play
void play()
QPointer
filteractionmissingargumentdialog.h
Phonon::createPlayer
MediaObject * createPlayer(Phonon::Category category, const MediaSource &source)
QFile
MailCommon::FilterActionWithTest
Definition: filteractionwithtest.h:27
MailCommon::FilterAction
Abstract base class for mail filter actions.
Definition: filteraction.h:52
MailCommon::FilterAction::ErrorButGoOn
A non-critical error occurred.
Definition: filteraction.h:63
MailCommon::FilterActionPlaySound::newAction
static FilterAction * newAction()
Definition: filteractionplaysound.cpp:44
FilterActionMissingSoundUrlDialog
Definition: filteractionmissingargumentdialog.h:171
QString::isEmpty
bool isEmpty() const
MailCommon::SearchRule::RequiredPart
RequiredPart
Definition: searchrule.h:79
QString
Phonon::MediaObject::setCurrentSource
void setCurrentSource(const MediaSource &source)
MailCommon::SearchRule::Envelope
Definition: searchrule.h:80
MailCommon::FilterAction::ReturnCode
ReturnCode
Describes the possible return codes of filter processing:
Definition: filteraction.h:60
QLatin1String
MailCommon::FilterActionPlaySound::FilterActionPlaySound
FilterActionPlaySound()
Definition: filteractionplaysound.cpp:33
filteractionplaysound.h
MailCommon::FilterActionPlaySound::isEmpty
bool isEmpty() const
Determines whether this action is valid.
Definition: filteractionplaysound.cpp:50
MailCommon::FilterActionPlaySound::~FilterActionPlaySound
~FilterActionPlaySound()
Definition: filteractionplaysound.cpp:39
MailCommon::FilterActionPlaySound::argsFromStringInteractive
bool argsFromStringInteractive(const QString &argsStr, const QString &filterName)
Read extra arguments from given string.
Definition: filteractionplaysound.cpp:75
MailCommon::ItemContext
A helper class for the filtering process.
Definition: itemcontext.h:39
MailCommon::FilterActionPlaySound::requiredPart
SearchRule::RequiredPart requiredPart() const
Returns the required part from the item that is needed for the action to operate. ...
Definition: filteractionplaysound.cpp:69
MailCommon::FilterActionWithTest::mParameter
QString mParameter
Definition: filteractionwithtest.h:82
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:31:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

Skip menu "mailcommon"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal