Lines 139-157
Link Here
|
139 |
transfer_done_targz_idle_cb (gpointer data) |
139 |
transfer_done_targz_idle_cb (gpointer data) |
140 |
{ |
140 |
{ |
141 |
int status; |
141 |
int status; |
142 |
gchar *command, *filename; |
142 |
gchar *command, *filename, *gzip, *tar; |
143 |
theme_properties *theme_props = data; |
143 |
theme_properties *theme_props = data; |
144 |
|
144 |
|
|
|
145 |
if (!(gzip = g_find_program_in_path("gzip"))) { |
146 |
return FALSE; |
147 |
} |
148 |
if (!(tar = g_find_program_in_path("tar"))) { |
149 |
g_free(gzip); |
150 |
return FALSE; |
151 |
} |
145 |
/* this should be something more clever and nonblocking */ |
152 |
/* this should be something more clever and nonblocking */ |
146 |
filename = g_shell_quote(theme_props->filename); |
153 |
filename = g_shell_quote(theme_props->filename); |
147 |
command = g_strdup_printf ("sh -c 'cd \"%s\"; /bin/gzip -d -c < \"%s\" | /bin/tar xf - '", |
154 |
command = g_strdup_printf ("sh -c 'cd \"%s\"; %s -d -c < \"%s\" | %s xf - '", |
148 |
theme_props->target_tmp_dir, filename); |
155 |
theme_props->target_tmp_dir, gzip, filename, tar); |
149 |
g_free(filename); |
156 |
g_free(filename); |
150 |
if (g_spawn_command_line_sync (command, NULL, NULL, &status, NULL) && status == 0) { |
157 |
if (g_spawn_command_line_sync (command, NULL, NULL, &status, NULL) && status == 0) { |
151 |
g_free (command); |
158 |
g_free (command); |
|
|
159 |
g_free(gzip); |
160 |
g_free(tar); |
152 |
return TRUE; |
161 |
return TRUE; |
153 |
} else { |
162 |
} else { |
154 |
g_free (command); |
163 |
g_free (command); |
|
|
164 |
g_free(gzip); |
165 |
g_free(tar); |
155 |
return FALSE; |
166 |
return FALSE; |
156 |
} |
167 |
} |
157 |
} |
168 |
} |
Lines 171-188
Link Here
|
171 |
transfer_done_tarbz2_idle_cb (gpointer data) |
182 |
transfer_done_tarbz2_idle_cb (gpointer data) |
172 |
{ |
183 |
{ |
173 |
int status; |
184 |
int status; |
174 |
gchar *command, *filename; |
185 |
gchar *command, *filename, *bzip2, *tar; |
175 |
theme_properties *theme_props = data; |
186 |
theme_properties *theme_props = data; |
176 |
|
187 |
|
|
|
188 |
if (!(bzip2 = g_find_program_in_path("bzip2"))) { |
189 |
return FALSE; |
190 |
} |
191 |
if (!(tar = g_find_program_in_path("tar"))) { |
192 |
g_free(bzip2); |
193 |
return FALSE; |
194 |
} |
177 |
filename = g_shell_quote(theme_props->filename); |
195 |
filename = g_shell_quote(theme_props->filename); |
178 |
/* this should be something more clever and nonblocking */ |
196 |
/* this should be something more clever and nonblocking */ |
179 |
command = g_strdup_printf ("sh -c 'cd \"%s\"; /usr/bin/bzip2 -d -c < \"%s\" | /bin/tar xf - '", |
197 |
command = g_strdup_printf ("sh -c 'cd \"%s\"; %s -d -c < \"%s\" | %s xf - '", |
180 |
theme_props->target_tmp_dir, filename); |
198 |
theme_props->target_tmp_dir, bzip2, filename, tar); |
181 |
g_free (filename); |
199 |
g_free (filename); |
182 |
if (g_spawn_command_line_sync (command, NULL, NULL, &status, NULL) && status == 0) { |
200 |
if (g_spawn_command_line_sync (command, NULL, NULL, &status, NULL) && status == 0) { |
|
|
201 |
g_free(bzip2); |
202 |
g_free(tar); |
183 |
g_free (command); |
203 |
g_free (command); |
184 |
return TRUE; |
204 |
return TRUE; |
185 |
} else { |
205 |
} else { |
|
|
206 |
g_free(bzip2); |
207 |
g_free(tar); |
186 |
g_free (command); |
208 |
g_free (command); |
187 |
return FALSE; |
209 |
return FALSE; |
188 |
} |
210 |
} |
Lines 193-199
Link Here
|
193 |
{ |
215 |
{ |
194 |
GtkWidget *dialog; |
216 |
GtkWidget *dialog; |
195 |
int len = strlen (path); |
217 |
int len = strlen (path); |
196 |
gchar *command,**dir, *first_line, *filename; |
218 |
gchar *command,**dir, *first_line, *filename, *gzip, *bzip2, *tar; |
197 |
int status,theme_type; |
219 |
int status,theme_type; |
198 |
theme_properties *theme_props; |
220 |
theme_properties *theme_props; |
199 |
GnomeVFSURI *theme_source_dir, *theme_dest_dir; |
221 |
GnomeVFSURI *theme_source_dir, *theme_dest_dir; |
Lines 206-222
Link Here
|
206 |
g_get_home_dir(), |
228 |
g_get_home_dir(), |
207 |
g_random_int()); |
229 |
g_random_int()); |
208 |
|
230 |
|
|
|
231 |
gzip = g_find_program_in_path("gzip"); |
232 |
bzip2 = g_find_program_in_path("bzip2"); |
233 |
tar = g_find_program_in_path("tar"); |
209 |
|
234 |
|
210 |
if (path && len > 7 && ( (!strcmp (path + len - 7, ".tar.gz")) || (!strcmp (path + len - 4, ".tgz")) )) { |
235 |
if (tar && gzip && path && len > 7 && ( (!strcmp (path + len - 7, ".tar.gz")) || (!strcmp (path + len - 4, ".tgz")) )) { |
211 |
filename = g_shell_quote (path); |
236 |
filename = g_shell_quote (path); |
212 |
command = g_strdup_printf ("sh -c '/bin/gzip -d -c < \"%s\" | /bin/tar ft - | head -1'", |
237 |
command = g_strdup_printf ("sh -c '%s -d -c < \"%s\" | %s ft - | head -1'", |
213 |
filename); |
238 |
gzip, filename, tar); |
214 |
theme_props->filetype=TARGZ; |
239 |
theme_props->filetype=TARGZ; |
215 |
g_free (filename); |
240 |
g_free (filename); |
216 |
} else if (path && len > 8 && !strcmp (path + len - 8, ".tar.bz2")) { |
241 |
} else if (tar && bzip2 && path && len > 8 && !strcmp (path + len - 8, ".tar.bz2")) { |
217 |
filename = g_shell_quote (path); |
242 |
filename = g_shell_quote (path); |
218 |
command = g_strdup_printf ("sh -c '/usr/bin/bzip2 -d -c < \"%s\" | /bin/tar ft - | head -1'", |
243 |
command = g_strdup_printf ("sh -c '%s -d -c < \"%s\" | %s ft - | head -1'", |
219 |
filename); |
244 |
bzip2, filename, tar); |
220 |
theme_props->filetype=TARBZ; |
245 |
theme_props->filetype=TARBZ; |
221 |
g_free (filename); |
246 |
g_free (filename); |
222 |
} else { |
247 |
} else { |
Lines 230-235
Link Here
|
230 |
gnome_vfs_unlink(path); |
255 |
gnome_vfs_unlink(path); |
231 |
g_free (theme_props->target_tmp_dir); |
256 |
g_free (theme_props->target_tmp_dir); |
232 |
g_free (theme_props); |
257 |
g_free (theme_props); |
|
|
258 |
if (gzip) |
259 |
g_free(gzip); |
260 |
if (bzip2) |
261 |
g_free(bzip2); |
262 |
if (tar) |
263 |
g_free(tar); |
233 |
return; |
264 |
return; |
234 |
} |
265 |
} |
235 |
|
266 |
|
Lines 247-252
Link Here
|
247 |
g_free (command); |
278 |
g_free (command); |
248 |
g_free (theme_props->target_tmp_dir); |
279 |
g_free (theme_props->target_tmp_dir); |
249 |
g_free (theme_props); |
280 |
g_free (theme_props); |
|
|
281 |
if (gzip) |
282 |
g_free(gzip); |
283 |
if (bzip2) |
284 |
g_free(bzip2); |
285 |
if (tar) |
286 |
g_free(tar); |
250 |
return; |
287 |
return; |
251 |
} |
288 |
} |
252 |
|
289 |
|
Lines 254-260
Link Here
|
254 |
theme_props->filename=g_strdup(path); |
291 |
theme_props->filename=g_strdup(path); |
255 |
|
292 |
|
256 |
if (theme_props->filetype == TARBZ ) { |
293 |
if (theme_props->filetype == TARBZ ) { |
257 |
if (!g_file_test ("/usr/bin/bzip2", G_FILE_TEST_EXISTS)) { |
294 |
if (!bzip2) { |
258 |
GtkWidget *dialog; |
295 |
GtkWidget *dialog; |
259 |
|
296 |
|
260 |
dialog = gtk_message_dialog_new (NULL, |
297 |
dialog = gtk_message_dialog_new (NULL, |
Lines 269-274
Link Here
|
269 |
g_free (theme_props->target_tmp_dir); |
306 |
g_free (theme_props->target_tmp_dir); |
270 |
g_free (theme_props->filename); |
307 |
g_free (theme_props->filename); |
271 |
g_free (theme_props); |
308 |
g_free (theme_props); |
|
|
309 |
if (gzip) |
310 |
g_free(gzip); |
311 |
if (bzip2) |
312 |
g_free(bzip2); |
313 |
if (tar) |
314 |
g_free(tar); |
272 |
return; |
315 |
return; |
273 |
} |
316 |
} |
274 |
|
317 |
|
Lines 287-298
Link Here
|
287 |
g_free (theme_props->filename); |
330 |
g_free (theme_props->filename); |
288 |
g_free (theme_props); |
331 |
g_free (theme_props); |
289 |
g_free (command); |
332 |
g_free (command); |
|
|
333 |
if (gzip) |
334 |
g_free(gzip); |
335 |
if (bzip2) |
336 |
g_free(bzip2); |
337 |
if (tar) |
338 |
g_free(tar); |
290 |
return; |
339 |
return; |
291 |
} |
340 |
} |
292 |
} |
341 |
} |
293 |
|
342 |
|
294 |
if (theme_props->filetype == TARGZ ) { |
343 |
if (theme_props->filetype == TARGZ ) { |
295 |
if (!g_file_test ("/bin/gzip", G_FILE_TEST_EXISTS)) { |
344 |
if (!gzip) { |
296 |
GtkWidget *dialog; |
345 |
GtkWidget *dialog; |
297 |
|
346 |
|
298 |
dialog = gtk_message_dialog_new (NULL, |
347 |
dialog = gtk_message_dialog_new (NULL, |
Lines 307-312
Link Here
|
307 |
g_free (theme_props->target_tmp_dir); |
356 |
g_free (theme_props->target_tmp_dir); |
308 |
g_free (theme_props->filename); |
357 |
g_free (theme_props->filename); |
309 |
g_free (theme_props); |
358 |
g_free (theme_props); |
|
|
359 |
if (gzip) |
360 |
g_free(gzip); |
361 |
if (bzip2) |
362 |
g_free(bzip2); |
363 |
if (tar) |
364 |
g_free(tar); |
310 |
return; |
365 |
return; |
311 |
} |
366 |
} |
312 |
if (!transfer_done_targz_idle_cb(theme_props)) { |
367 |
if (!transfer_done_targz_idle_cb(theme_props)) { |
Lines 324-329
Link Here
|
324 |
g_free (theme_props->filename); |
379 |
g_free (theme_props->filename); |
325 |
g_free (theme_props); |
380 |
g_free (theme_props); |
326 |
g_free (command); |
381 |
g_free (command); |
|
|
382 |
if (gzip) |
383 |
g_free(gzip); |
384 |
if (bzip2) |
385 |
g_free(bzip2); |
386 |
if (tar) |
387 |
g_free(tar); |
327 |
return; |
388 |
return; |
328 |
} |
389 |
} |
329 |
} |
390 |
} |
Lines 363-368
Link Here
|
363 |
g_free (theme_props->theme_tmp_dir); |
424 |
g_free (theme_props->theme_tmp_dir); |
364 |
g_free (theme_props); |
425 |
g_free (theme_props); |
365 |
g_free (command); |
426 |
g_free (command); |
|
|
427 |
if (gzip) |
428 |
g_free(gzip); |
429 |
if (bzip2) |
430 |
g_free(bzip2); |
431 |
if (tar) |
432 |
g_free(tar); |
366 |
return; |
433 |
return; |
367 |
} else { |
434 |
} else { |
368 |
GtkWidget *dialog; |
435 |
GtkWidget *dialog; |
Lines 379-384
Link Here
|
379 |
g_free (theme_props->theme_tmp_dir); |
446 |
g_free (theme_props->theme_tmp_dir); |
380 |
g_free (theme_props); |
447 |
g_free (theme_props); |
381 |
g_free (command); |
448 |
g_free (command); |
|
|
449 |
if (gzip) |
450 |
g_free(gzip); |
451 |
if (bzip2) |
452 |
g_free(bzip2); |
453 |
if (tar) |
454 |
g_free(tar); |
382 |
return; |
455 |
return; |
383 |
} |
456 |
} |
384 |
/* Move the Dir to the target dir */ |
457 |
/* Move the Dir to the target dir */ |
Lines 407-412
Link Here
|
407 |
g_free (theme_props->user_message); |
480 |
g_free (theme_props->user_message); |
408 |
g_free (theme_props); |
481 |
g_free (theme_props); |
409 |
g_free (command); |
482 |
g_free (command); |
|
|
483 |
if (gzip) |
484 |
g_free(gzip); |
485 |
if (bzip2) |
486 |
g_free(bzip2); |
487 |
if (tar) |
488 |
g_free(tar); |
410 |
return; |
489 |
return; |
411 |
} else { |
490 |
} else { |
412 |
GtkWidget *dialog; |
491 |
GtkWidget *dialog; |
Lines 426-431
Link Here
|
426 |
g_free (theme_props->user_message); |
505 |
g_free (theme_props->user_message); |
427 |
g_free (theme_props); |
506 |
g_free (theme_props); |
428 |
g_free (command); |
507 |
g_free (command); |
|
|
508 |
if (gzip) |
509 |
g_free(gzip); |
510 |
if (bzip2) |
511 |
g_free(bzip2); |
512 |
if (tar) |
513 |
g_free(tar); |
429 |
return; |
514 |
return; |
430 |
} |
515 |
} |
431 |
|
516 |
|
Lines 434-439
Link Here
|
434 |
g_free (theme_props->target_tmp_dir); |
519 |
g_free (theme_props->target_tmp_dir); |
435 |
g_free (theme_props->filename); |
520 |
g_free (theme_props->filename); |
436 |
g_free (theme_props); |
521 |
g_free (theme_props); |
|
|
522 |
if (gzip) |
523 |
g_free(gzip); |
524 |
if (bzip2) |
525 |
g_free(bzip2); |
526 |
if (tar) |
527 |
g_free(tar); |
437 |
} |
528 |
} |
438 |
|
529 |
|
439 |
static void |
530 |
static void |