7
#include <glib-object.h>
12
#include "update-notifier.h"
13
#define GDU_API_IS_SUBJECT_TO_CHANGE
17
#define CDROM_CHECKER PACKAGE_LIB_DIR"/update-notifier/apt-cdrom-check"
19
/* reposonses for the dialog */
27
/* Returnvalues from apt-cdrom-check:
29
# 1 - CD with packages
30
# 2 - dist-upgrader CD
42
void distro_cd_detected(UpgradeNotifier *un,
44
const char *mount_point)
46
GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
50
gchar *title, *markup;
52
case CD_WITH_PACKAGES:
53
title = _("Software Packages Volume Detected");
54
markup = _("<span weight=\"bold\" size=\"larger\">"
55
"A volume with software packages has "
56
"been detected.</span>\n\n"
57
"Would you like to open it with the "
59
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
62
_("Start Package Manager"),
65
gtk_dialog_set_default_response (GTK_DIALOG(dialog), RES_START_PM);
67
case CD_WITH_DISTUPGRADER:
68
title = _("Upgrade volume detected");
69
markup = _("<span weight=\"bold\" size=\"larger\">"
70
"A distribution volume with software packages has "
71
"been detected.</span>\n\n"
72
"Would you like to try to upgrade from it automatically? ");
73
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
76
_("Start package manager"),
81
gtk_dialog_set_default_response (GTK_DIALOG(dialog), RES_DIST_UPGRADER);
84
title = _("Addon volume detected");
85
markup = _("<span weight=\"bold\" size=\"larger\">"
86
"An addon volume with software applications has "
87
"been detected.</span>\n\n"
88
"Would you like to view/install the content? ");
89
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
92
_("Start package manager"),
94
_("Start addon installer"),
97
gtk_dialog_set_default_response (GTK_DIALOG(dialog), RES_ADDON_CD);
100
case CD_WITH_APTONCD:
101
title = _("APTonCD volume detected");
102
markup = _("<span weight=\"bold\" size=\"larger\">"
103
"A volume with unofficial software packages has "
104
"been detected.</span>\n\n"
105
"Would you like to open it with the "
107
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
110
_("Start package manager"),
113
gtk_dialog_set_default_response (GTK_DIALOG(dialog), RES_START_PM);
116
g_assert_not_reached();
119
gtk_window_set_title(GTK_WINDOW(dialog), title);
120
gtk_window_set_skip_taskbar_hint (GTK_WINDOW(dialog), FALSE);
121
gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dialog), markup);
123
int res = gtk_dialog_run (GTK_DIALOG (dialog));
128
cmd = g_strdup_printf("synaptic --add-cdrom '%s'",mount_point);
129
invoke_with_gksu(cmd, "/usr/share/applications/synaptic.desktop", FALSE);
131
case RES_DIST_UPGRADER:
132
argv[0] = "/usr/lib/update-notifier/cddistupgrader";
133
argv[1] = (gchar *)mount_point;
135
g_spawn_async (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL);
138
cmd = g_strdup_printf("gnome-app-install --addon-cd='%s'", mount_point);
139
invoke_with_gksu(cmd, "/usr/share/applications/gnome-app-install.desktop", FALSE);
146
gtk_widget_destroy (dialog);
150
up_check_mount_point_for_packages (const char *mount_point, gpointer data)
155
char *ubuntu_dir = g_strdup_printf("%s/ubuntu",mount_point);
156
char *aptoncd_file = g_strdup_printf("%s/aptoncd.info",mount_point);
157
if(! (g_file_test (ubuntu_dir, G_FILE_TEST_IS_SYMLINK) ||
158
g_file_test (aptoncd_file, G_FILE_TEST_IS_REGULAR) )) {
160
g_free(aptoncd_file);
164
g_free(aptoncd_file);
166
/* this looks like a ubuntu CD, run the checker script to verify
167
* this. We expect the following return codes:
169
# 1 - CD with packages
170
# 2 - dist-upgrader CD
173
* (see data/apt-cdrom-check)
175
//g_print("this looks like a ubuntu-cdrom\n");
176
char *cmd = g_strdup_printf(CDROM_CHECKER" '%s'",mount_point);
178
g_spawn_command_line_sync(cmd, NULL, NULL, &retval, NULL);
180
//g_print("retval: %i \n", WEXITSTATUS(retval));
181
int cdtype = WEXITSTATUS(retval);
183
distro_cd_detected(data, cdtype, mount_point);
190
up_device_changed (GduPool *pool, GduDevice *device, gpointer data)
192
//g_print("up_device_changed %s\n", gdu_device_get_device_file (device));
194
// check if that is a removable device
195
if (!gdu_device_is_removable(device))
198
// we only care about the first mount point
199
const gchar *p = gdu_device_get_mount_path (device);
200
//g_print("checking mount point %s\n", p);
201
up_check_mount_point_for_packages (p, data);
206
up_check_mounted_devices (GduPool *pool, gpointer data)
208
GList *devices = gdu_pool_get_devices (pool);
210
while(devices != NULL) {
211
up_device_changed (pool, devices->data, data);
212
devices = g_list_next(devices);
214
g_list_free(devices);
218
up_do_hal_init (UpgradeNotifier *un)
220
GduPool *pool = gdu_pool_new ();
224
g_signal_connect (pool, "device_changed", (GCallback)up_device_changed, un);
225
// now check what devices we have
226
up_check_mounted_devices(pool, un);
235
#include "update-notifier.h"
238
up_do_hal_init (UpgradeNotifier *un)
240
g_warning("Detection and monitoring of CD-ROMs disabled.");