[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/3.5/kdesdk/kbabel
From:       Nicolas Goutte <nicolasg () snafu ! de>
Date:       2006-02-25 17:33:38
Message-ID: 1140888818.558088.7786.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 513583 by goutte:

Fix sending a remote file as email from the KBabel editor


 M  +38 -0     common/kbmailer.cpp  
 M  +9 -0      common/kbmailer.h  
 M  +1 -1      kbabel/kbabel.cpp  


--- branches/KDE/3.5/kdesdk/kbabel/common/kbmailer.cpp #513582:513583
@@ -88,6 +88,44 @@
   }
 }
 
+void KBabelMailer::sendOneFile( const KURL& url)
+{
+#if KDE_IS_VERSION( 3, 5, 0)
+  const KURL localUrl( KIO::NetAccess::mostLocalURL( url, m_parent ) );
+#else
+  const KURL localUrl( url );
+#endif
+  if ( localUrl.isLocalFile() )
+  {
+    sendOneFile( localUrl.path() );
+    return;
+  }
+
+  if (!singleFileCompression) {
+    QString fileName( url.filename() );
+    if ( fileName.isEmpty() )
+    {
+      fileName = "attachment";
+    }
+    // ### TODO: the current implementation has the default to possibly overwrite an \
already existing temporary file +    QString tempName( m_tempDir.name() );
+    tempName += fileName;
+    if ( KIO::NetAccess::download( url, tempName, m_parent ) )
+      kapp->invokeMailer("", "", "", "", "", "", fileName);
+    else
+    {
+      KMessageBox::error( m_parent, i18n("Error while trying to download file \
%1.").arg( url.prettyURL() ) ); +    }
+  }
+  else
+  {
+    const QString archive ( createArchive( QStringList( url.url() ), url.filename() \
) ); +    if ( !archive.isEmpty() ) {
+      kapp->invokeMailer("", "", "", "", "", "", archive);
+    }
+  }
+}
+
 void KBabelMailer::sendFiles(QStringList fileList, const QString& initialName)
 {
   const QString archive ( createArchive( fileList, initialName ) );
--- branches/KDE/3.5/kdesdk/kbabel/common/kbmailer.h #513582:513583
@@ -47,6 +47,7 @@
 class KCompletion;
 class KConfig;
 class KLineEditDlg;
+class KURL;
 
 namespace KBabel
 {
@@ -81,6 +82,14 @@
      */
     void sendOneFile(const QString& fileName);
     /**
+     * Send only one file as a mail attachment. The file can either be sent
+     * as a compressed or an uncompressed file.
+     *
+     * @param url the URL of the file to be sent.
+     * @since 1.11.2 (KDE 3.5.2)
+     */
+    void sendOneFile(const KURL& url);
+    /**
      * Send several files as a mail attachment. The files will be included in
      * an archive.
      *
--- branches/KDE/3.5/kdesdk/kbabel/kbabel/kbabel.cpp #513582:513583
@@ -1127,7 +1127,7 @@
 void KBabelMW::fileMail()
 {
     if( m_view->isModified() ) fileSave();
-    mailer->sendOneFile(m_view->currentURL().prettyURL());
+    mailer->sendOneFile( m_view->currentURL() );
 }
 
 void KBabelMW::fileNewView()


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic