added tftp-support (bnc#803316)
authorMatthias Grießmeier <mgriessmeier@suse.de>
Wed, 27 Mar 2013 11:24:56 +0000 (12:24 +0100)
committerMatthias Grießmeier <mgriessmeier@suse.de>
Wed, 27 Mar 2013 11:24:56 +0000 (12:24 +0100)
zypp/Url.cc
zypp/Url.h
zypp/media/MediaAccess.cc
zypp/media/MediaCurl.cc
zypp/media/MediaManager.h
zypp/media/MediaMultiCurl.cc
zypp/media/MediaPriority.cc
zypp/media/ZsyncParser.cc

index d81508c..1eede89 100644 (file)
@@ -215,6 +215,7 @@ namespace zypp
         ref->config("path_encode_slash2", "y"); // always encode 2. slash
         addUrlByScheme("ftp",    ref);
         addUrlByScheme("sftp",   ref);
+        addUrlByScheme("tftp",   ref);
       }
 
       bool
@@ -460,7 +461,7 @@ namespace zypp
 
   bool Url::schemeIsRemote( const std::string & scheme_r )
   {
-    static const char * val[] = { "http", "https", "nfs", "nfs4", "smb", "cifs", "ftp", "sftp" };
+    static const char * val[] = { "http", "https", "nfs", "nfs4", "smb", "cifs", "ftp", "sftp", "tftp" };
     return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
   }
 
@@ -472,7 +473,7 @@ namespace zypp
 
   bool Url::schemeIsDownloading( const std::string & scheme_r )
   {
-    static const char * val[] = { "http", "https", "ftp", "sftp" };
+    static const char * val[] = { "http", "https", "ftp", "sftp", "tftp" };
     return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
   }
   ///////////////////////////////////////////////////////////////////
index e99dada..277b879 100644 (file)
@@ -256,7 +256,7 @@ namespace zypp
     /** \overload nonstatic version */
     bool schemeIsLocal() const { return schemeIsLocal( getScheme() ); }
 
-    /** nfs nfs4 smb cifs http https ftp sftp */
+    /** nfs nfs4 smb cifs http https ftp sftp tftp */
     static bool schemeIsRemote( const std::string & scheme_r );
     /** \overload nonstatic version */
     bool schemeIsRemote() const { return schemeIsRemote( getScheme() ); }
@@ -266,7 +266,7 @@ namespace zypp
     /** \overload nonstatic version */
     bool schemeIsVolatile() const { return schemeIsVolatile( getScheme() ); }
 
-    /** http https ftp sftp */
+    /** http https ftp sftp tftp */
     static bool schemeIsDownloading( const std::string & scheme_r );
     /** \overload nonstatic version */
     bool schemeIsDownloading() const { return schemeIsDownloading( getScheme() ); }
index 4cca043..2bc7c9a 100644 (file)
@@ -133,7 +133,7 @@ MediaAccess::open (const Url& o_url, const Pathname & preferred_attach_point)
         _handler = new MediaDISK (url,preferred_attach_point);
     else if (scheme == "cifs" || scheme == "smb")
        _handler = new MediaCIFS (url,preferred_attach_point);
-    else if (scheme == "ftp" || scheme == "http" || scheme == "https")
+    else if (scheme == "ftp" || scheme == "tftp" || scheme == "http" || scheme == "https")
     {
         // Another good idea would be activate MediaAria2c handler via external var
         bool use_aria = false;
@@ -182,7 +182,7 @@ MediaAccess::open (const Url& o_url, const Pathname & preferred_attach_point)
           else if ( !use_aria && ariaenv && ( strcmp(ariaenv, "1" ) == 0 ) )
           {
               // no aria for ftp - no advantage in that over curl
-              if ( url.getScheme() == "ftp" )
+              if ( url.getScheme() == "ftp" || url.getScheme() == "tftp" )
                   WAR << "no aria2c for FTP, despite ZYPP_ARIA2C=1" << endl;
               else
               {
index 3e23c9f..6257fe2 100644 (file)
@@ -240,7 +240,7 @@ void fillSettingsFromUrl( const Url &url, TransferSettings &s )
     else
     {
         // if there is no username, set anonymous auth
-        if ( url.getScheme() == "ftp" && s.username().empty() )
+        if ( ( url.getScheme() == "ftp" || url.getScheme() == "tftp" ) && s.username().empty() )
             s.setAnonymousAuth();
     }
 
@@ -1317,7 +1317,7 @@ void MediaCurl::doGetFileCopy( const Pathname & filename , const Pathname & targ
     {
       DBG << "HTTP response: " + str::numstring(httpReturnCode);
       if ( httpReturnCode == 304
-           || ( httpReturnCode == 213 && _url.getScheme() == "ftp" ) ) // not modified
+           || ( httpReturnCode == 213 && (_url.getScheme() == "ftp" || _url.getScheme() == "tftp") ) ) // not modified
       {
         DBG << " Not modified.";
         modified = false;
index c3a3155..2490983 100644 (file)
@@ -342,10 +342,11 @@ namespace zypp
      *     Mandatory URL component, that specifies the share name with
      *     optional subdirectory, where the desired files are located.
      *
-     * \subsection MediaCurl_Url MediaCurl - FTP/HTTP directory tree (ftp, http, https)
+     * \subsection MediaCurl_Url MediaCurl - FTP/HTTP directory tree (ftp, tftp, http, https)
      * The access handler to media directory tree on a ftp/http server.
      *   - Scheme:
      *     - <b>ftp</b>
+     *     - <b>tftp</b>
      *     - <b>http</b>
      *     - <b>https</b>
      *   - Examples:
index 15a167c..9f2f072 100644 (file)
@@ -1511,7 +1511,7 @@ void MediaMultiCurl::multifetch(const Pathname & filename, FILE *fp, std::vector
       try
        {
          string scheme = urliter->getScheme();
-         if (scheme == "http" || scheme == "https" || scheme == "ftp")
+         if (scheme == "http" || scheme == "https" || scheme == "ftp" || scheme == "tftp")
            {
              checkProtocol(*urliter);
              myurllist.push_back(*urliter);
index b063661..082d83f 100644 (file)
@@ -33,7 +33,7 @@ namespace zypp
       /**
        * 4: local:     file,dir,hd
        * 3: remote:    nfs,cifs,smb
-       * ?: download:  http,https,ftp,sftp
+       * ?: download:  http,https,ftp,sftp, tftp
        * ?: volatile:  cd,dvd
        * 0:            the rest
       */
@@ -57,6 +57,10 @@ namespace zypp
            RETURN_IF( "file",  4 );
            RETURN_IF( "ftp",   ZConfig::instance().download_media_prefer_download() ? 2 : 1);
            break;
+         
+         case 't':
+           RETURN_IF( "tftp",  ZConfig::instance().download_media_prefer_download() ? 2 : 1);
+           break;
 
          case 'h':
            RETURN_IF( "http",  ZConfig::instance().download_media_prefer_download() ? 2 : 1 );
index 55c02a8..5e7ac7e 100644 (file)
@@ -81,7 +81,7 @@ ZsyncParser::parse(string filename)
         (void)sscanf(buf + 14, "%d,%d,%d", &sql, &rsl, &csl);
       else if (!strncmp(buf, "Blocksize: ", 11))
         blksize = atoi(buf + 11);
-      else if (!strncmp(buf, "URL: http://", 12) || !strncmp(buf, "URL: https://", 13) || !strncmp(buf, "URL: ftp://", 11))
+      else if (!strncmp(buf, "URL: http://", 12) || !strncmp(buf, "URL: https://", 13) || !strncmp(buf, "URL: ftp://", 11) || !strncmp(buf, "URL: tftp://", 12) ) 
        urls.push_back(buf + 5);
       else if (!strncmp(buf, "SHA-1: ", 7))
        {