• Skip to content
  • Skip to link menu
KDE 4.5 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

kabc

  • KABC
  • KABC::Sound
Public Member Functions | Friends

KABC::Sound Class Reference

Class that holds a Sound clip for a contact. More...

#include <sound.h>

List of all members.

Public Member Functions

 Sound ()
 Sound (const QString &url)
 Sound (const Sound &other)
 Sound (const QByteArray &data)
 ~Sound ()
QByteArray data () const
bool isEmpty () const
bool isIntern () const
bool operator!= (const Sound &other) const
Sound & operator= (const Sound &other)
bool operator== (const Sound &other) const
void setData (const QByteArray &data)
void setUrl (const QString &url)
QString toString () const
QString url () const

Friends

QDataStream & operator<< (QDataStream &, const Sound &)
QDataStream & operator>> (QDataStream &, Sound &)

Detailed Description

Class that holds a Sound clip for a contact.

The sound can be played doing something like this:

    KTempFile tmp;
    if ( sound.isIntern() ) {
      tmp.file()->write( sound.data() );
      tmp.close();
      KAudioPlayer::play( tmp.name() );
    } else if( !sound.url().isEmpty() ) {
      QString tmpFile;
      if ( !KIO::NetAccess::download( KUrl( themeURL.url() ), tmpFile, 0 ) ) {
        KMessageBox::error( 0,
                            KIO::NetAccess::lastErrorString(),
                            i18n( "Failed to download sound file" ),
                            KMessageBox::Notify
                          );
        return;
      }
      KAudioPlayer::play( tmpFile );
    }

Unfortunately, KAudioPlayer::play is ASync, so to delete the temporary file the best you can really do is set a timer.

Definition at line 58 of file sound.h.


Constructor & Destructor Documentation

Sound::Sound (  ) 

Creates an empty sound object.

Definition at line 50 of file sound.cpp.

Sound::Sound ( const QString &  url  ) 

Creates a sound object for the given url.

Parameters:
url A url that describes the position of the sound file.

Definition at line 55 of file sound.cpp.

Sound::Sound ( const QByteArray &  data  ) 

Creates a sound object for the given data.

Parameters:
data The raw data of the sound.

Definition at line 61 of file sound.cpp.

Sound::Sound ( const Sound &  other  ) 

Copy constructor.

Definition at line 68 of file sound.cpp.

Sound::~Sound (  ) 

Destroys the sound object.

Definition at line 73 of file sound.cpp.


Member Function Documentation

QByteArray Sound::data (  )  const

Returns the raw data of this sound.

Definition at line 138 of file sound.cpp.

bool Sound::isEmpty (  )  const

Returns true, if the sound object is empty.

Definition at line 127 of file sound.cpp.

bool Sound::isIntern (  )  const

Returns whether the sound is described by a URL (extern) or by the raw data (intern).

When this method returns 'true' you can use data() to get the raw data. Otherwise you can request the URL of this sound by url() and load the raw data from that location.

Definition at line 122 of file sound.cpp.

bool Sound::operator!= ( const Sound &  other  )  const

Not-Equal operator.

Parameters:
other The object to compare with
Returns:
true if the two objects are not equal, otherwise false

Definition at line 105 of file sound.cpp.

Sound & Sound::operator= ( const Sound &  other  ) 

Assignment operator.

Parameters:
other The sound object to assign to this

Definition at line 77 of file sound.cpp.

bool Sound::operator== ( const Sound &  other  )  const

Equality operator.

Parameters:
other The object to compare with
Returns:
true if the two objects are equal, otherwise false

Definition at line 86 of file sound.cpp.

void Sound::setData ( const QByteArray &  data  ) 

Sets the raw data of the sound.

When using this function, isIntern() will return 'true' until you use setUrl().

Parameters:
data The raw data of the sound.

Definition at line 116 of file sound.cpp.

void Sound::setUrl ( const QString &  url  ) 

Sets a URL for the location of the sound file.

When using this function, isIntern() will return 'false' until you use setData().

Parameters:
url The location URL of the sound file.

Definition at line 110 of file sound.cpp.

QString Sound::toString (  )  const

Returns string representation of the sound.

Definition at line 143 of file sound.cpp.

QString Sound::url (  )  const

Returns the location URL of this sound.

Definition at line 133 of file sound.cpp.


Friends And Related Function Documentation

QDataStream& operator<< ( QDataStream &  ,
const Sound &   
) [friend]

Serializes the sound object into the stream.

QDataStream& operator>> ( QDataStream &  ,
Sound &   
) [friend]

Initializes the sound object from the stream.


The documentation for this class was generated from the following files:
  • sound.h
  • sound.cpp

kabc

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal