root/trunk/third/nautilus/components/services/install/nautilus-view/nautilus-service-install.c @ 15547

Revision 15547, 8.1 KB (checked in by ghudson, 9 years ago)

This commit was generated by cvs2svn to compensate for changes in r15546,
which included commits to RCS files with non-trunk default branches.

Line 
1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2/*
3 * Copyright (C) 2000 Eazel, Inc
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 *
20 * Authors: Eskil Heyn Olsen <eskil@eazel.com>
21 */
22
23#include "nautilus-service-install.h"
24#include <libeazelinstall.h>
25
26#define OAF_ID "OAFIID:trilobite_eazel_install_service:8ff6e815-1992-437c-9771-d932db3b4a17"
27
28static void
29xnautilus_service_install_download_failed (EazelInstallCallback *service, 
30                                           const char *name,
31                                           NautilusServiceInstallView *view)
32{
33        fprintf (stdout, "Download of %s FAILED\n", name);
34}
35
36/*
37  This dumps the entire tree for the failed package.
38 */
39static void
40xnautilus_service_install_failed_helper (EazelInstallCallback *service,
41                                         const PackageData *pd,
42                                         gchar *indent,
43                                         NautilusServiceInstallView *view)
44{
45        GList *iterator;
46
47        if (pd->toplevel) {
48                fprintf (stdout, "\n***The package %s failed. Here's the dep tree\n", pd->name);
49        }
50        switch (pd->status) {
51        case PACKAGE_DEPENDENCY_FAIL:
52                fprintf (stdout, "%s-%s FAILED\n", indent, rpmfilename_from_packagedata (pd));
53                break;
54        case PACKAGE_CANNOT_OPEN:
55                fprintf (stdout, "%s-%s NOT FOUND\n", indent, rpmfilename_from_packagedata (pd));
56                break;         
57        case PACKAGE_SOURCE_NOT_SUPPORTED:
58                fprintf (stdout, "%s-%s is a source package\n", indent, rpmfilename_from_packagedata (pd));
59                break;
60        case PACKAGE_BREAKS_DEPENDENCY:
61                fprintf (stdout, "%s-%s breaks\n", indent, rpmfilename_from_packagedata (pd));
62                break;
63        default:
64                fprintf (stdout, "%s-%s\n", indent, rpmfilename_from_packagedata (pd));
65                break;
66        }
67        for (iterator = pd->soft_depends; iterator; iterator = iterator->next) {                       
68                PackageData *pack;
69                char *indent2;
70                indent2 = g_strconcat (indent, iterator->next ? " |" : "  " , NULL);
71                pack = (PackageData*)iterator->data;
72                xnautilus_service_install_failed_helper (service, pack, indent2, view);
73                g_free (indent2);
74        }
75        for (iterator = pd->breaks; iterator; iterator = iterator->next) {                     
76                PackageData *pack;
77                char *indent2;
78                indent2 = g_strconcat (indent, iterator->next ? " |" : "  " , NULL);
79                pack = (PackageData*)iterator->data;
80                xnautilus_service_install_failed_helper (service, pack, indent2, view);
81                g_free (indent2);
82        }
83}
84
85static void
86xnautilus_service_install_failed (EazelInstallCallback *service,
87                                  const PackageData *pd,
88                                  NautilusServiceInstallView *view)
89{
90        nautilus_service_install_failed_helper (service, pd, "", view);
91}
92
93
94static void
95xnautilus_service_install_dependency_check (EazelInstallCallback *service,
96                                            const PackageData *package,
97                                            const PackageData *needs,
98                                            NautilusServiceInstallView *view) 
99{
100        g_message ("Doing dependency check for %s - need %s\n", package->name, needs->name);
101}
102
103static void
104xnautilus_service_install_done (EazelInstallCallback *service,
105                                gboolean result,
106                                NautilusServiceInstallView *view)
107{
108        char *tmp;
109        eazel_install_callback_unref (GTK_OBJECT (service));
110       
111        tmp = g_strdup (view->details->uri);
112        nautilus_service_install_view_load_uri (view, tmp);
113        g_free (tmp);
114}
115
116void 
117xnautilus_service_install_view_install_package_callback (GtkWidget *widget,
118                                                         NautilusServiceInstallView *view)
119{
120        GList *packages;
121        GList *categories;
122        CORBA_Environment ev;
123        EazelInstallCallback *cb;               
124
125        CORBA_exception_init (&ev);
126
127        packages = NULL;
128        categories = NULL;
129
130        {
131                char *ptr;
132                CategoryData *category;
133                PackageData *pack;
134
135                /* Find the :// of the url and skip to after it */
136                ptr = strstr (view->details->uri, "file://");
137                ptr += strlen ("file://");
138
139                /* make a package and add to it to a categorylist */
140                pack = packagedata_new ();
141                pack->filename = g_strdup (ptr);
142               
143                category = categorydata_new ();
144                category->packages = g_list_prepend (NULL, pack);
145                categories = g_list_prepend (NULL, category);
146        }
147
148        /* Check that we're on a redhat system */
149        if (!check_for_redhat ()) {
150                fprintf (stderr, "*** This tool can only be used on RedHat.\n");
151        }
152
153        cb = eazel_install_callback_new ();
154       
155        Trilobite_Eazel_Install__set_protocol (eazel_install_callback_corba_objref (cb), Trilobite_Eazel_PROTOCOL_HTTP, &ev);
156        if (!check_for_root_user()) {
157                fprintf (stderr, "*** This tool requires root access, switching to test mode\n");
158                Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), TRUE, &ev); 
159        } else {
160                Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), FALSE, &ev); 
161        }
162        Trilobite_Eazel_Install__set_tmp_dir (eazel_install_callback_corba_objref (cb), "/tmp/eazel-install", &ev);
163        Trilobite_Eazel_Install__set_server (eazel_install_callback_corba_objref (cb), "testmachine.eazel.com", &ev);
164        Trilobite_Eazel_Install__set_server_port (eazel_install_callback_corba_objref (cb), 80, &ev);
165
166        gtk_signal_connect (GTK_OBJECT (cb), "download_progress", nautilus_service_install_download_progress_signal, view);
167        gtk_signal_connect (GTK_OBJECT (cb), "install_progress", nautilus_service_install_progress_signal, view);
168        gtk_signal_connect (GTK_OBJECT (cb), "install_failed", nautilus_service_install_failed, view);
169        gtk_signal_connect (GTK_OBJECT (cb), "download_failed", nautilus_service_install_download_failed, view);
170        gtk_signal_connect (GTK_OBJECT (cb), "dependency_check", nautilus_service_install_dependency_check, view);
171        gtk_signal_connect (GTK_OBJECT (cb), "done", nautilus_service_install_done, view);
172       
173        eazel_install_callback_install_packages (cb, categories, NULL, &ev);
174       
175        CORBA_exception_free (&ev);               
176}
177
178void 
179xnautilus_service_install_view_uninstall_package_callback (GtkWidget *widget,
180                                                           NautilusServiceInstallView *view)
181{
182        GList *packages;
183        GList *categories;
184        CORBA_Environment ev;
185        EazelInstallCallback *cb;               
186
187        CORBA_exception_init (&ev);
188
189        packages = NULL;
190        categories = NULL;
191
192        {
193                CategoryData *category;
194                PackageData *pack;
195                pack = gtk_object_get_data (GTK_OBJECT (view), "packagedata");
196               
197                category = categorydata_new ();
198                category->packages = g_list_prepend (NULL, pack);
199                categories = g_list_prepend (NULL, category);
200        }
201
202        /* Check that we're on a redhat system */
203        if (!check_for_redhat ()) {
204                fprintf (stderr, "*** This tool can only be used on RedHat.\n");
205        }
206
207        cb = eazel_install_callback_new ();
208       
209        Trilobite_Eazel_Install__set_protocol (eazel_install_callback_corba_objref (cb), Trilobite_Eazel_PROTOCOL_HTTP, &ev);
210        if (!check_for_root_user ()) {
211                fprintf (stderr, "*** This tool requires root access, switching to test mode\n");
212                Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), TRUE, &ev); 
213        } else {
214                Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), FALSE, &ev); 
215        }
216        Trilobite_Eazel_Install__set_tmp_dir (eazel_install_callback_corba_objref (cb), "/tmp/eazel-install", &ev);
217        Trilobite_Eazel_Install__set_server (eazel_install_callback_corba_objref (cb), "testmachine.eazel.com", &ev);
218        Trilobite_Eazel_Install__set_server_port (eazel_install_callback_corba_objref (cb), 80, &ev);
219
220        gtk_signal_connect (GTK_OBJECT (cb), "download_progress", nautilus_service_install_download_progress_signal, view);
221        gtk_signal_connect (GTK_OBJECT (cb), "uninstall_progress", nautilus_service_install_progress_signal, view);
222        gtk_signal_connect (GTK_OBJECT (cb), "uninstall_failed", nautilus_service_install_failed, view);
223        gtk_signal_connect (GTK_OBJECT (cb), "dependency_check", nautilus_service_install_dependency_check, view);
224        gtk_signal_connect (GTK_OBJECT (cb), "done", nautilus_service_install_done, view);
225       
226        eazel_install_callback_uninstall_packages (cb, categories, NULL, &ev);
227       
228        CORBA_exception_free (&ev);               
229}
Note: See TracBrowser for help on using the browser.