Index: server/trunk/web/lib/Sophie/Controller/Analysis.pm
===================================================================
--- server/trunk/web/lib/Sophie/Controller/Analysis.pm	(revision 206)
+++ server/trunk/web/lib/Sophie/Controller/Analysis.pm	(revision 207)
@@ -25,5 +25,53 @@
     my ( $self, $c ) = @_;
 
-    $c->response->body('Matched Sophie::Controller::Analysis in Analysis.');
+    if (my $upload = $c->req->upload('file')) {
+        if ($upload->size < 5 * 1024 * 1024) { # 5Mo
+            $c->forward('/user/folder/load_rpm', [ $upload->slurp ]);
+        }
+    }
+    $c->forward('analyse_folder');
+}
+
+sub analyse_folder : Local {
+    my ($self, $c) = @_;
+
+    $c->session->{analyse_dist} = {
+        distribution => $c->req->param('distribution') || undef,
+        release => $c->req->param('release') || undef,
+        arch => $c->req->param('arch') || undef,
+    };
+
+}
+
+sub required_by :Local {
+    my ($self, $c, $id) = @_;
+    $id ||= $c->req->param('id');
+
+    my @deplist;
+    foreach my $dep ($c->model('Base::UsersDeps')->search(
+        {
+            pid => [ $id ],
+            deptype => 'R',
+        },
+        {
+            select => [ 'rpmsenseflag("flags")',
+                qw(depname flags evr deptype) ],
+            as => [ qw'sense depname flags evr deptype' ],
+        }
+        )->all) {
+        $dep->get_column('depname') =~ /^rpmlib\(/ and next;
+        push(@deplist, [
+                $dep->get_column('depname'),
+                $dep->get_column('sense'),
+                $dep->get_column('evr') ]);
+    }
+
+    my @folderid = map { $_->{id} } @{ $c->forward('/user/folder/list') };
+    
+    $c->stash->{xmlrpc} = $c->forward(
+        '/analysis/solver/find_requirements',
+        [ $c->session->{analyse_dist},
+            'P', \@deplist, \@folderid ]
+    );
 }
 
Index: server/trunk/web/lib/Sophie/Controller/Analysis/Solver.pm
===================================================================
--- server/trunk/web/lib/Sophie/Controller/Analysis/Solver.pm	(revision 206)
+++ server/trunk/web/lib/Sophie/Controller/Analysis/Solver.pm	(revision 207)
@@ -34,4 +34,5 @@
     my %need_pkgid;
     my %need_pool;
+    my %bydep;
     my @unresolved;
     foreach my $dep (@{ $deplist || []}) {
@@ -43,4 +44,7 @@
 
         $depname =~ /^rpmlib\(/ and next;
+        my $depdisplay = $depname . ($sense ? " $sense $evr" : '');
+        $bydep{$depdisplay} and next; # same already searched
+        $bydep{$depdisplay} = {};
         my $found = 0;
         if ($depname =~ /^\//) {
@@ -48,6 +52,7 @@
             if (@{$res}) {
                 $found = 1;
-                foreach (@{$res->{results}}) {
+                foreach (@{$res}) {
                     $need_pkgid{$_} = 1;
+                    $bydep{$depdisplay}{pkg}{$_} = 1;
                 }
             } 
@@ -58,4 +63,6 @@
                     foreach (@{$res}) {
                         $need_pool{$_} = 1;
+                        $bydep{$depdisplay}{pool}{$_} = 1;
+
                     }
                 }
@@ -70,4 +77,5 @@
                 foreach (@{$res}) {
                     $need_pkgid{$_} = 1;
+                    $bydep{$depdisplay}{pkg}{$_} = 1;
                 }
             } 
@@ -82,4 +90,5 @@
                     foreach (@{$res}) {
                         $need_pool{$_} = 1;
+                        $bydep{$depdisplay}{pool}{$_} = 1;
                     }
                 }
@@ -97,8 +106,16 @@
     }
 
+    foreach my $d (keys %bydep) {
+        foreach my $t (keys %{ $bydep{$d} || {} }) {
+            $bydep{$d}{$t} = [ keys %{ $bydep{$d}{$t} } ];
+        }
+    }
+
+
     $c->stash->{xmlrpc} = {
         unresolved => \@unresolved,
         pkg => [ keys %need_pkgid ],
         pool => [ keys %need_pool ],
+        bydep => \%bydep,
     };
 }
Index: server/trunk/web/lib/Sophie/Controller/User/Folder.pm
===================================================================
--- server/trunk/web/lib/Sophie/Controller/User/Folder.pm	(revision 206)
+++ server/trunk/web/lib/Sophie/Controller/User/Folder.pm	(revision 207)
@@ -28,4 +28,63 @@
 
     $c->response->body('Matched Sophie::Controller::User::folder in User::folder.');
+}
+
+sub list :XMLRPC :Local {
+    my ($self, $c ) = @_;
+
+    $c->stash->{xmlrpc} = [
+        map { { $_->get_columns } }
+        $c->model('Base::UsersRpms')->search(
+        {
+            ($c->user_exists
+            ? ( user_fkey => $c->model('Base::Users')->find({ mail =>
+                        $c->user->mail })->ukey )
+            : ( sessions_fkey => 'session:' . $c->sessionid ) ),
+        }
+    )->all ]
+}
+
+sub delete :XMLRPC :Local {
+    my ($self, $c, $pid ) = @_;
+    $pid ||= $c->req->param('delete');
+
+    my $pkg = $c->model('Base::UsersRpms')->search(
+        {
+            -and => [ {
+            ($c->user_exists
+            ? ( user_fkey => $c->model('Base::Users')->find({ mail =>
+                        $c->user->mail })->ukey )
+            : ( sessions_fkey => 'session:' . $c->sessionid ) ),
+            },
+            { id => $pid },
+            ]
+        }
+    )->first;
+    if ($pkg) {
+        $pkg->delete;
+        $c->model('Base')->storage->dbh->commit;
+        $c->stash->{xmlrpc} = 'Delete';
+    } else {
+        $c->stash->{xmlrpc} = 'No package found';
+    }
+}
+
+sub clear : XMLRPC : Local {
+    my ($self, $c, $pid ) = @_;
+    $pid ||= $c->req->param('delete');
+
+    my $pkg = $c->model('Base::UsersRpms')->search(
+        {
+            -and => [ {
+            ($c->user_exists
+            ? ( user_fkey => $c->model('Base::Users')->find({ mail =>
+                        $c->user->mail })->ukey )
+            : ( sessions_fkey => 'session:' . $c->sessionid ) ),
+            },
+            ]
+        }
+    )->delete;
+    $c->model('Base')->storage->dbh->commit;
+    $c->stash->{xmlrpc} = 'Empty';
 }
 
Index: server/trunk/web/root/static/sophie.css
===================================================================
--- server/trunk/web/root/static/sophie.css	(revision 206)
+++ server/trunk/web/root/static/sophie.css	(revision 207)
@@ -248,4 +248,8 @@
 }
 
+.alert {
+    color: red;
+}
+
 #w3c {
     float: right;
Index: server/trunk/web/root/templates/html/analysis/analyse_folder.html
===================================================================
--- server/trunk/web/root/templates/html/analysis/analyse_folder.html	(revision 207)
+++ server/trunk/web/root/templates/html/analysis/analyse_folder.html	(revision 207)
@@ -0,0 +1,3 @@
+<!-- $Id$ -->
+
+[% INCLUDE 'analysis/analyse_folder.tt' %]
Index: server/trunk/web/root/templates/html/analysis/analyse_folder.tt
===================================================================
--- server/trunk/web/root/templates/html/analysis/analyse_folder.tt	(revision 207)
+++ server/trunk/web/root/templates/html/analysis/analyse_folder.tt	(revision 207)
@@ -0,0 +1,18 @@
+<!-- $Id$ -->
+
+[% FOREACH pkg = c.forward('/user/folder/list') %]
+<h2>[% pkg.name | html %]</h2>
+<div id="req[% pkg.id %]">
+Loading...
+</div>
+[% END %] 
+
+<script>
+[% FOREACH pkg = c.forward('/user/folder/list') %]
+
+new Ajax.Updater('req[% pkg.id %]',
+        '[% c.uri_for('/analysis/required_by', pkg.id, { ajax => 1 }) %]',
+        { asynchronous: 1 } );
+
+[% END %]
+</script> 
Index: server/trunk/web/root/templates/html/analysis/index.html
===================================================================
--- server/trunk/web/root/templates/html/analysis/index.html	(revision 207)
+++ server/trunk/web/root/templates/html/analysis/index.html	(revision 207)
@@ -0,0 +1,3 @@
+<!-- $Id$ -->
+
+[% INCLUDE 'analysis/index.tt' %]
Index: server/trunk/web/root/templates/html/analysis/index.tt
===================================================================
--- server/trunk/web/root/templates/html/analysis/index.tt	(revision 207)
+++ server/trunk/web/root/templates/html/analysis/index.tt	(revision 207)
@@ -0,0 +1,35 @@
+<!-- $Id$ -->
+
+<div style="float: right">
+[% INCLUDE 'user/folder/list.tt' xmlrpc = c.forward('/user/folder/list') %]
+</div>
+
+<div id="upload_rpm">
+<p>Upload an XML header dump:</p>
+<form action="[% c.uri_for('/', c.req.path) %]" method="POST"
+    enctype="multipart/form-data">
+
+<input type="file" name="file">
+<input type="submit">
+<p>Such file can be obtain by using command <code>rpm --qf '[\%{*:xml}\n]'</code></p>
+</form>
+</div>
+
+
+<form action="[% c.uri_for('/', c.req.path) %]" id="analysis_form" method="POST">
+    <span id="distribselect">
+    [% INCLUDE 'ajax/forms/distribselect.tt' %]
+    </span>
+[% c.prototype.observe_form('analysis_form',
+    {
+    url => c.uri_for('/ajax/forms/distribselect', { 'ajax' => 1 }),
+    frequency => 2,
+    update => 'distribselect',
+    }
+) %]
+<input type="submit" name="analyse">
+</form>
+
+[% IF c.req.param('analyse') %]
+[% INCLUDE 'analysis/analyse_folder.tt' %]
+[% END %]
Index: server/trunk/web/root/templates/html/analysis/required_by.tt
===================================================================
--- server/trunk/web/root/templates/html/analysis/required_by.tt	(revision 207)
+++ server/trunk/web/root/templates/html/analysis/required_by.tt	(revision 207)
@@ -0,0 +1,24 @@
+[% IF xmlrpc.unresolved.size %]
+<p class="alert">Unresolved dependencies:</p>
+<ul class="alert">
+[% FOREACH dep = xmlrpc.unresolved %]
+<li>[% dep | html %]</li>
+[% END %]
+</ul>
+[% END %]
+
+[% FOREACH dep = xmlrpc.bydep.keys %]
+
+<p>[% dep | html %]</p>
+[% FOREACH pkg = xmlrpc.bydep.$dep.pkg %]
+[% IF loop.first %]
+<ul>
+[% END %]
+[% info = c.forward('/rpms/basicinfo', [ pkg ]) %]
+<li>[% info.name | html %]-[% info.evr %]</li>
+[% IF loop.last %]
+</ul>
+[% END %]
+[% END %]
+
+[% END %]
Index: server/trunk/web/root/templates/html/user/folder/clear.tt
===================================================================
--- server/trunk/web/root/templates/html/user/folder/clear.tt	(revision 207)
+++ server/trunk/web/root/templates/html/user/folder/clear.tt	(revision 207)
@@ -0,0 +1,4 @@
+<!-- $Id$ -->
+
+<p>[% xmlrpc %]</p>
+
Index: server/trunk/web/root/templates/html/user/folder/delete.tt
===================================================================
--- server/trunk/web/root/templates/html/user/folder/delete.tt	(revision 207)
+++ server/trunk/web/root/templates/html/user/folder/delete.tt	(revision 207)
@@ -0,0 +1,4 @@
+<!-- $Id$ -->
+
+<p>[% xmlrpc %]</p>
+
Index: server/trunk/web/root/templates/html/user/folder/list.tt
===================================================================
--- server/trunk/web/root/templates/html/user/folder/list.tt	(revision 207)
+++ server/trunk/web/root/templates/html/user/folder/list.tt	(revision 207)
@@ -0,0 +1,35 @@
+<!-- $Id$ -->
+[% folder = xmlrpc %]
+[% FOREACH pkg = folder %]
+[% IF loop.first %]
+<div id="sophie_rpm_basket">
+[% c.prototype.link_to_remote(
+    'delete all stored rpms:', {
+    url    => c.uri_for('/user/folder/clear', { ajax => 1, delete => pkg.id }),
+    complete => 'new Ajax.Updater(
+        \'sophie_rpm_basket\',
+        \'' _ c.uri_for('/user/folder/list', { ajax => 1 }) _ '\', { asynchronous: 1 } ); false'
+    },
+) %]
+<ul class="rpm_basket">
+[% END %]
+<li id="li[% pkg.id %]">[% pkg.name %]-[% pkg.evr %]
+[% c.prototype.link_to_remote(
+    '<img 
+        src="' _ c.uri_for('/static', 'images', 'draw-eraser.png') _ '" 
+        alt="delete" title="Delete">', 
+    {
+    url    => c.uri_for('/user/folder/delete', { ajax => 1, delete => pkg.id }),
+    complete => 'new Ajax.Updater(
+        \'sophie_rpm_basket\',
+        \'' _ c.uri_for('/user/folder/list', { ajax => 1 }) _ '\', { asynchronous: 1 } ); false'
+    },
+    { entities => '' },
+) %]
+
+</li>
+[% IF loop.last %]
+</ul>
+</div>
+[% END %]
+[% END %]
Index: server/trunk/web/t/controller_User-Folder.t
===================================================================
--- server/trunk/web/t/controller_User-Folder.t	(revision 206)
+++ server/trunk/web/t/controller_User-Folder.t	(revision 207)
@@ -2,4 +2,6 @@
 use warnings;
 use Test::More;
+use FindBin;
+require "$FindBin::Bin/xml.pl";
 
 BEGIN { use_ok 'Catalyst::Test', 'Sophie' }
@@ -7,3 +9,4 @@
 
 ok( request('/user/folder')->is_success, 'Request should succeed' );
+ok( xmlrequest_ok('user.folder.list'), 'RPC user.folder.list');
 done_testing();
