<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -60,6 +60,9 @@ set (AQPM_CONFIGURATION_FILE &quot;/etc/aqpm.conf&quot; CACHE STRING &quot;The configuration fi
 set (AUR_JSON_URL &quot;http://aur.archlinux.org/rpc.php?&quot; CACHE STRING &quot;The URL that will be used by aqpmaur to access the
                                                                    aur. Change if you want to use your own installation. 
                                                                    It needs to end with an '?'&quot;)
+set (AUR_BASE_URL &quot;http://aur.archlinux.org&quot; CACHE STRING &quot;The URL that will be used by aqpmaur to download pkgbuilds from
+                                                           aur. Change if you want to use your own installation. It should not
+                                                           end with an '/'&quot;)
 
 configure_file(
        &quot;${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake_uninstall.cmake.in&quot;</diff>
      <filename>CMakeLists.txt</filename>
    </modified>
    <modified>
      <diff>@@ -33,6 +33,7 @@
 #define AQPM_CONFIGURATION_FILE &quot;${AQPM_CONFIGURATION_FILE}&quot;
 
 #define AQPM_AUR_REQUEST_URL &quot;${AUR_JSON_URL}&quot;
+#define AQPM_AUR_BASE_URL &quot;${AUR_BASE_URL}&quot;
 
 /* KDE4 Integration */
 #cmakedefine KDE4_INTEGRATION 1</diff>
      <filename>config-aqpm.h.cmake</filename>
    </modified>
    <modified>
      <diff>@@ -27,6 +27,10 @@
 #include &lt;QtNetwork/QNetworkRequest&gt;
 #include &lt;QtNetwork/QNetworkReply&gt;
 
+#include &lt;QTemporaryFile&gt;
+#include &lt;QDir&gt;
+#include &lt;QProcess&gt;
+
 #include &lt;qjson/parser.h&gt;
 
 #ifndef KDE4_INTEGRATION
@@ -47,6 +51,7 @@ class Backend::Private
         Private() : manager(new AqpmNetworkAccessManager) {}
 
         QNetworkRequest createNetworkRequest(const QString &amp;type, const QString &amp;arg) const;
+        QNetworkRequest createDownloadRequest(const Package &amp;package) const;
         Package packageFromMap(const QVariantMap &amp;map) const;
 
         // Private slots
@@ -65,8 +70,36 @@ QNetworkRequest Backend::Private::createNetworkRequest(const QString&amp; type, cons
     return request;
 }
 
+QNetworkRequest Backend::Private::createDownloadRequest(const Aqpm::Aur::Package&amp; package) const
+{
+    QNetworkRequest request;
+    QUrl url(AQPM_AUR_BASE_URL + package.path);
+    request.setUrl(url);
+    request.setRawHeader(&quot;User-Agent&quot;, (&quot;Aqpm/&quot; + QString(AQPM_VERSION)).toUtf8());
+    return request;
+}
+
 void Backend::Private::__k__replyFinished(QNetworkReply* reply)
 {
+    if (reply-&gt;property(&quot;aqpm_AUR_is_archive_Download&quot;).toBool()) {
+        // We got an archive. Let's save and extract it where requested
+        QTemporaryFile file;
+        file.open();
+        file.write(reply-&gt;readAll());
+        file.flush();
+
+        QString filepath = QDir::tempPath() + '/' + file.fileName();
+        QProcess process;
+        process.setWorkingDirectory(reply-&gt;property(&quot;aqpm_AUR_extract_path&quot;).toString());
+        process.start(QString(&quot;tar -zxf %1&quot;).arg(filepath));
+        process.waitForFinished();
+        file.close();
+
+        // Stream the success
+        emit q-&gt;buildEnvironmentReady(reply-&gt;property(&quot;aqpm_AUR_ID&quot;).toInt(), reply-&gt;property(&quot;aqpm_AUR_pkg_name&quot;).toString());
+        return;
+    }
+
     // Parse it!
     QJson::Parser parser;
     bool ok;
@@ -87,7 +120,18 @@ void Backend::Private::__k__replyFinished(QNetworkReply* reply)
 
         emit q-&gt;searchCompleted(reply-&gt;property(&quot;aqpm_AUR_Subject&quot;).toString(), retlist);
     } else if (reply-&gt;property(&quot;aqpm_AUR_Request_Type&quot;).toString() == &quot;info&quot;) {
-        emit q-&gt;infoCompleted(reply-&gt;property(&quot;aqpm_AUR_ID&quot;).toInt(), packageFromMap(result[&quot;results&quot;].toMap()));
+        if (reply-&gt;property(&quot;aqpm_AUR_is_Download&quot;).toBool()) {
+            // We are not really looking for info, we actually need to download the package we got.
+            Package p = packageFromMap(result[&quot;results&quot;].toMap());
+            QNetworkReply *nreply = manager-&gt;get(createDownloadRequest(p));
+            nreply-&gt;setProperty(&quot;aqpm_AUR_is_archive_Download&quot;, true);
+            nreply-&gt;setProperty(&quot;aqpm_AUR_extract_path&quot;, reply-&gt;property(&quot;aqpm_AUR_extract_path&quot;).toString());
+            nreply-&gt;setProperty(&quot;aqpm_AUR_ID&quot;, reply-&gt;property(&quot;aqpm_AUR_ID&quot;).toInt());
+            nreply-&gt;setProperty(&quot;aqpm_AUR_pkg_name&quot;, p.name);
+        } else {
+            // A simple info request, just notify and pass by
+            emit q-&gt;infoCompleted(reply-&gt;property(&quot;aqpm_AUR_ID&quot;).toInt(), packageFromMap(result[&quot;results&quot;].toMap()));
+        }
     }
 }
 
@@ -181,6 +225,16 @@ Package Backend::infoSync(int id) const
     return e.package();
 }
 
+void Backend::prepareBuildEnvironment(int id, const QString&amp; envpath) const
+{
+    // First we have to do an info request to get the URL. We will add an additional property
+    QNetworkReply *reply = d-&gt;manager-&gt;get(d-&gt;createNetworkRequest(&quot;info&quot;, QString::number(id)));
+    reply-&gt;setProperty(&quot;aqpm_AUR_Request_Type&quot;, &quot;info&quot;);
+    reply-&gt;setProperty(&quot;aqpm_AUR_ID&quot;, id);
+    reply-&gt;setProperty(&quot;aqpm_AUR_is_Download&quot;, true);
+    reply-&gt;setProperty(&quot;aqpm_AUR_extract_path&quot;, envpath);
+}
+
 }
 }
 </diff>
      <filename>libaqpmaur/AurBackend.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -56,14 +56,17 @@ public:
     virtual ~Backend();
 
     void search(const QString &amp;subject) const;
-    void info(int id) const;
-
     Package::List searchSync(const QString &amp;subject) const;
+
+    void info(int id) const;
     Package infoSync(int id) const;
 
+    void prepareBuildEnvironment(int id, const QString &amp;envpath) const;
+
 Q_SIGNALS:
     void searchCompleted(const QString &amp;searchSubject, const Aqpm::Aur::Package::List &amp;results);
     void infoCompleted(int id, const Aqpm::Aur::Package &amp;result);
+    void buildEnvironmentReady(int id, const QString &amp;envpath);
 
 private:
     Backend(QObject* parent = 0);</diff>
      <filename>libaqpmaur/AurBackend.h</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2b49a472ff2afada7e4541aa09118c4beeaa8c0b</id>
    </parent>
  </parents>
  <author>
    <name>Dario Freddi</name>
    <email>drf@kde.org</email>
  </author>
  <url>http://github.com/drf/aqpm/commit/5d1579beced6bc91f4e21f0bf6523a432f08bc48</url>
  <id>5d1579beced6bc91f4e21f0bf6523a432f08bc48</id>
  <committed-date>2009-10-19T15:45:20-07:00</committed-date>
  <authored-date>2009-10-19T15:45:20-07:00</authored-date>
  <message>Get a prepare environment function

Signed-off-by: Dario Freddi &lt;drf@kde.org&gt;</message>
  <tree>8fdad88a6fa6526f884a59835885a02de0e07c71</tree>
  <committer>
    <name>Dario Freddi</name>
    <email>drf@kde.org</email>
  </committer>
</commit>
