32#include "attachment.h" 
   37#include <tdeapplication.h> 
   38#include <tdefiledialog.h> 
   40#include <tdemessagebox.h> 
   43#include <tdetempfile.h> 
   44#include <tdeio/netaccess.h> 
   60  if ( as.count() > 0 ) {
 
   61    Attachment::List::ConstIterator it;
 
   62    for ( it = as.begin(); it != as.end(); ++it ) {
 
   63      if ( (*it)->label() == attachmentName ) {
 
   73      i18n( 
"No attachment named \"%1\" found in the incidence." ).arg( attachmentName ) );
 
   78    if ( !TDEIO::NetAccess::exists( a->uri(), 
true, parent ) ) {
 
   81        i18n( 
"The attachment \"%1\" is a web link that is inaccessible from this computer. " ).
 
   82        arg( KURL::decode_string( a->uri() ) ) );
 
   90                                     const TQString &attachmentName, 
const TQString &uid )
 
   92  if ( uid.isEmpty() ) {
 
  103      i18n( 
"The incidence that owns the attachment named \"%1\" could not be found. " 
  104            "Perhaps it was removed from your calendar?" ).arg( attachmentName ) );
 
  108  return find( parent, attachmentName, incidence );
 
  122      i18n( 
"The calendar invitation stored in this email message is broken in some way. " 
  123            "Unable to continue." ) );
 
  127  return find( parent, attachmentName, incidence );
 
  130static KTempFile *s_tempFile = 0;
 
  132static KURL tempFileForAttachment( 
Attachment *attachment )
 
  135  TQStringList patterns = KMimeType::mimeType( attachment->mimeType() )->patterns();
 
  136  if ( !patterns.empty() ) {
 
  137    s_tempFile = 
new KTempFile( TQString(),
 
  138                                TQString( patterns.first() ).remove( 
'*' ), 0600 );
 
  140    s_tempFile = 
new KTempFile( TQString(), TQString(), 0600 );
 
  143  TQFile *qfile = s_tempFile->file();
 
  144  qfile->open( IO_WriteOnly );
 
  145  TQTextStream stream( qfile );
 
  146  stream.writeRawBytes( attachment->decodedData().data(), attachment->size() );
 
  148  TQFile tf( s_tempFile->name() );
 
  149  if ( tf.size() != attachment->size() ) {
 
  156  url.setPath( s_tempFile->name() );
 
  167  if ( attachment->isUri() ) {
 
  168    tdeApp->invokeBrowser( attachment->uri() );
 
  171    KURL tempUrl = tempFileForAttachment( attachment );
 
  172    if ( tempUrl.isValid() ) {
 
  173      stat = KRun::runURL( tempUrl, attachment->mimeType(), 
false, 
true );
 
  178        i18n( 
"Unable to create a temporary file for the attachment." ) );
 
  188  return view( parent, 
find( parent, attachmentName, incidence ) );
 
  193  return view( parent, 
find( parent, attachmentName, uid ) );
 
  199  return view( parent, 
find( parent, attachmentName, message ) );
 
  205  TQString saveAsFile = KFileDialog::getSaveFileName( attachment->label(), TQString(), parent,
 
  206                                                     i18n( 
"Save Attachment" ) );
 
  207  if ( saveAsFile.isEmpty() ||
 
  208       ( TQFile( saveAsFile ).exists() &&
 
  209         ( KMessageBox::warningYesNo(
 
  211             i18n( 
"%1 already exists. Do you want to overwrite it?").
 
  212             arg( saveAsFile ) ) == KMessageBox::No ) ) ) {
 
  217  if ( attachment->isUri() ) {
 
  219    stat = TDEIO::NetAccess::file_copy( attachment->uri(), KURL( saveAsFile ), -1, 
true );
 
  222    KURL tempUrl = tempFileForAttachment( attachment );
 
  223    if ( tempUrl.isValid() ) {
 
  224      stat = TDEIO::NetAccess::file_copy( tempUrl, KURL( saveAsFile ), -1, 
true );
 
  225      if ( !stat && TDEIO::NetAccess::lastError() ) {
 
  226        KMessageBox::error( parent, TDEIO::NetAccess::lastErrorString() );
 
  232        i18n( 
"Unable to create a temporary file for the attachment." ) );
 
  243  return saveAs( parent, 
find( parent, attachmentName, incidence ) );
 
  248  return saveAs( parent, 
find( parent, attachmentName, uid ) );
 
  254  return saveAs( parent, 
find( parent, attachmentName, message ) );
 
This file is part of the API for handling calendar data and provides static functions for dealing wit...
 
Provides a Calendar composed of several Calendar Resources.
 
This class represents information related to an attachment.
 
This class provides a Calendar which is composed of other Calendars known as "Resources".
 
void load()
Loads all Incidences from the Resources.
 
void readConfig(TDEConfig *config=0)
Read the Resources settings from a config file.
 
Incidence * incidence(const TQString &uid)
Returns the Incidence associated with the given unique identifier.
 
This class provides the base class common to all calendar components.
 
Attachment::List attachments() const
Return list of all associated attachments.
 
This class provides an encapsulation of a scheduling message.
 
IncidenceBase * event()
Return event associated with this message.
 
bool view(TQWidget *parent, Attachment *attachment)
Launches a viewer on the specified attachment.
 
bool saveAs(TQWidget *parent, Attachment *attachment)
Saves the specified attachment to a file of the user's choice.
 
Attachment * find(TQWidget *parent, const TQString &attachmentName, Incidence *incidence)
Finds the attachment in the user's calendar, by attachmentName and incidence.
 
Namespace KCal is for global classes, objects and/or functions in libkcal.