1/* 2 Copyright 2012 Julien Lavergne <gilir@ubuntu.com> 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18namespace Lxsession 19{ 20 public class DBDefaultApps: GLib.Object 21 { 22 public List<string> webbrowser_installed = new List<string> (); 23 public List<string> webbrowser_available = new List<string> (); 24 public string webbrowser_installed_blacklist; 25 26 public List<string> email_installed = new List<string> (); 27 public List<string> email_available = new List<string> (); 28 public string email_installed_blacklist; 29 30 public List<string> file_manager_installed = new List<string> (); 31 public List<string> file_manager_available = new List<string> (); 32 public string file_manager_blacklist; 33 34 public string screensaver_blacklist; 35 public List<string> screensaver_installed = new List<string> (); 36 public List<string> screensaver_available = new List<string> (); 37 38 public string composite_manager_blacklist; 39 public List<string> composite_manager_installed = new List<string> (); 40 public List<string> composite_manager_available = new List<string> (); 41 42 public string desktop_manager_blacklist; 43 public List<string> desktop_manager_installed = new List<string> (); 44 public List<string> desktop_manager_available = new List<string> (); 45 46 public string power_manager_blacklist; 47 public List<string> power_manager_installed = new List<string> (); 48 public List<string> power_manager_available = new List<string> (); 49 50 public string polkit_blacklist; 51 public List<string> polkit_installed = new List<string> (); 52 public List<string> polkit_available = new List<string> (); 53 54 public string im_blacklist; 55 public List<string> im_installed = new List<string> (); 56 public List<string> im_available = new List<string> (); 57 58 public string widget_blacklist; 59 public List<string> widget_installed = new List<string> (); 60 public List<string> widget_available = new List<string> (); 61 62 public string terminal_manager_blacklist; 63 public List<string> terminal_manager_installed = new List<string> (); 64 public List<string> terminal_manager_available = new List<string> (); 65 66 public string audio_blacklist; 67 public List<string> audio_installed = new List<string> (); 68 public List<string> audio_available = new List<string> (); 69 70 public string video_blacklist; 71 public List<string> video_installed = new List<string> (); 72 public List<string> video_available = new List<string> (); 73 74 public string audio_video_blacklist; 75 76 public string viewer_blacklist; 77 78 public List<string> image_display_installed = new List<string> (); 79 public List<string> pdf_reader_installed = new List<string> (); 80 81 public List<string> image_display_available = new List<string> (); 82 public List<string> pdf_reader_available = new List<string> (); 83 84 public string text_editor_blacklist; 85 public List<string> text_editor_installed = new List<string> (); 86 public List<string> text_editor_available = new List<string> (); 87 88 public string archive_blacklist; 89 public List<string> archive_installed = new List<string> (); 90 public List<string> archive_available = new List<string> (); 91 92 public string spreadsheet_blacklist; 93 public List<string> spreadsheet_installed = new List<string> (); 94 public List<string> spreadsheet_available = new List<string> (); 95 96 public string bittorent_blacklist; 97 public List<string> bittorent_installed = new List<string> (); 98 public List<string> bittorent_available = new List<string> (); 99 100 public string document_blacklist; 101 public List<string> document_installed = new List<string> (); 102 public List<string> document_available = new List<string> (); 103 104 public string burn_blacklist; 105 public List<string> burn_installed = new List<string> (); 106 public List<string> burn_available = new List<string> (); 107 108 public string tasks_blacklist; 109 public List<string> tasks_installed = new List<string> (); 110 public List<string> tasks_available = new List<string> (); 111 112 public signal void finish_scanning_installed(); 113 public signal void finish_scanning_available(); 114 public signal void exit_now(); 115 116 public bool state_installed = false; 117 public bool state_available = false; 118 119 /* For now, hardcoding the values */ 120 string[] MimeFoldersInstalledGet = {"/usr/local/share/applications"}; 121 string[] MimeFoldersAvailableGet = {"/usr/local/share/app-install/desktop"}; 122 123 string mode; 124 125 /* Configuration file */ 126 KeyFile kf; 127 string config_path ; 128 129 public DBDefaultApps(string mode_argument) 130 { 131 init(); 132 if (mode_argument == null) 133 { 134 this.mode = "display"; 135 } 136 else 137 { 138 this.mode = mode_argument; 139 } 140 } 141 142 public void init() 143 { 144 webbrowser_installed_blacklist = "lxde-x-www-browser.desktop;"; 145 email_installed_blacklist = ""; 146 file_manager_blacklist = ""; 147 screensaver_blacklist = ""; 148 composite_manager_blacklist = ""; 149 desktop_manager_blacklist = ""; 150 power_manager_blacklist = ""; 151 polkit_blacklist = ""; 152 im_blacklist = ""; 153 widget_blacklist = ""; 154 terminal_manager_blacklist = ""; 155 audio_blacklist = ""; 156 video_blacklist = ""; 157 audio_video_blacklist = ""; 158 viewer_blacklist = ""; 159 text_editor_blacklist = ""; 160 archive_blacklist = ""; 161 spreadsheet_blacklist = ""; 162 bittorent_blacklist = ""; 163 document_blacklist = ""; 164 burn_blacklist = ""; 165 tasks_blacklist = ""; 166 167 config_path = Path.build_filename(Environment.get_user_config_dir (),"lxsession-default-apps","settings.conf"); 168 169 kf = new KeyFile(); 170 171 message("test config_path: %s", config_path); 172 173 try 174 { 175 kf.load_from_file(config_path, KeyFileFlags.NONE); 176 } 177 catch (KeyFileError err) 178 { 179 warning (err.message); 180 } 181 catch (FileError err) 182 { 183 warning (err.message); 184 } 185 } 186 187 public void on_finish_scanning_installed() 188 { 189 message("Signal finish scanning installed with mode: %s",this.mode); 190 if (this.mode == "display") 191 { 192 print_values_installed (); 193 } 194 else if (this.mode == "write") 195 { 196 save_values_installed(); 197 } 198 199 this.state_installed = true; 200 201 if (this.state_available == true) 202 { 203 exit_now(); 204 } 205 } 206 207 public void on_finish_scanning_available() 208 { 209 message("Signal finish scanning available with mode: %s",this.mode); 210 if (this.mode == "display") 211 { 212 global_db.print_values_available (); 213 } 214 else if (this.mode == "write") 215 { 216 global_db.save_values_available(); 217 } 218 219 this.state_available = true; 220 221 if (this.state_installed == true) 222 { 223 exit_now(); 224 } 225 } 226 227 public void update_installed () 228 { 229 string[] default_install = null; 230 231 default_install = MimeFoldersInstalledGet; 232 233 if (default_install != null) 234 { 235 foreach (string folder in default_install) 236 { 237 message ("Scanning folder: %s", folder); 238 list_desktop_files.begin (folder, "installed"); 239 } 240 } 241 else 242 { 243 message ("No folders installed set. Abort"); 244 } 245 } 246 247 public void update_available () 248 { 249 string[] default_available = null; 250 251 default_available = MimeFoldersAvailableGet; 252 253 if (default_available != null) 254 { 255 foreach (string folder in default_available) 256 { 257 var dir_log = File.new_for_path (folder); 258 if (dir_log.query_exists ()) 259 { 260 message ("Scanning folder: %s", folder); 261 list_desktop_files.begin (folder, "available"); 262 } 263 else 264 { 265 message ("%s doesn't exist. Pass", folder); 266 finish_scanning_available(); 267 } 268 } 269 } 270 else 271 { 272 message ("No folders available set. Abort"); 273 } 274 } 275 276 public void update () 277 { 278 finish_scanning_installed.connect(on_finish_scanning_installed); 279 finish_scanning_available.connect(on_finish_scanning_available); 280 281 update_installed(); 282 update_available(); 283 } 284 285 private async void list_desktop_files (string path, string mode) 286 { 287 message ("Start scanning\n"); 288 var dir = File.new_for_path (path); 289 try 290 { 291 KeyFile kf = new KeyFile(); 292 /* asynchronous call, to get directory entries */ 293 var e = yield dir.enumerate_children_async (FileAttribute.STANDARD_NAME, 294 0, Priority.DEFAULT); 295 while (true) 296 { 297 /* asynchronous call, to get entries so far */ 298 var files = yield e.next_files_async (10, Priority.DEFAULT); 299 if (files == null) 300 { 301 break; 302 } 303 /* append the files found so far to the list */ 304 foreach (var info in files) 305 { 306 try 307 { 308 string desktop_path = Path.build_filename(path, info.get_name()); 309 kf.load_from_file(desktop_path, KeyFileFlags.NONE); 310 311 if (kf.has_key("Desktop Entry", "Categories") == true) 312 { 313 /* Sorting the results */ 314 find_list(kf, desktop_path, info.get_name(), mode); 315 } 316 } 317 catch (KeyFileError err) 318 { 319 /* No entry, just pass */; 320 } 321 catch (FileError err) 322 { 323 warning (err.message); 324 } 325 } 326 } 327 328 if (mode == "installed") 329 { 330 finish_scanning_installed(); 331 } 332 else if (mode == "available") 333 { 334 finish_scanning_available(); 335 } 336 337 } 338 catch (Error err) 339 { 340 stderr.printf ("Error: list_files failed: %s\n", err.message); 341 } 342 message ("Finishing scanning\n"); 343 } 344 345 public string create_entry(KeyFile kf, string desktop_path) 346 { 347 /* Create the entry in the list : 348 Name,exec,icon_name,desktop_path,install_package 349 */ 350 351 string entry = ""; 352 string tmp_name = ""; 353 string tmp_icon = ""; 354 string tmp_install_package = ""; 355 356 try 357 { 358 tmp_name = kf.get_locale_string ("Desktop Entry", "Name"); 359 } 360 catch (GLib.KeyFileError e) 361 { 362 /* Incomplete desktop file, just pass */ 363 } 364 365 try 366 { 367 tmp_icon = kf.get_value ("Desktop Entry", "Icon"); 368 } 369 catch (GLib.KeyFileError e) 370 { 371 /* Incomplete desktop file, just pass */ 372 } 373 374 try 375 { 376 tmp_install_package = kf.get_value ("Desktop Entry", "X-AppInstall-Package"); 377 } 378 catch (GLib.KeyFileError e) 379 { 380 /* Not a available desktop file, just pass */ 381 } 382 383 entry = tmp_name + "," + create_exec_string(kf) + "," + tmp_icon + "," + desktop_path + "," + tmp_install_package; 384 385 return entry; 386 387 } 388 389 public string create_exec_string (KeyFile kf) 390 { 391 string tmp_string = ""; 392 try 393 { 394 tmp_string = kf.get_value ("Desktop Entry", "Exec"); 395 } 396 catch (GLib.KeyFileError e) 397 { 398 /* Not a available desktop file, just pass */ 399 } 400 string[] tmp_value = tmp_string.split_set(" ",0); 401 return tmp_value[0]; 402 } 403 404 public void find_list(KeyFile kf, string desktop_path, string name, string mode) 405 { 406 try 407 { 408 string categories = kf.get_value ("Desktop Entry", "Categories"); 409 if (categories != null) 410 { 411 if ("WebBrowser" in categories) 412 { 413 if (name in webbrowser_installed_blacklist) 414 { 415 /* Blacklisted, pass */ 416 } 417 else 418 { 419 string new_entry = create_entry(kf, desktop_path); 420 if (mode == "installed") 421 { 422 webbrowser_installed.append(new_entry); 423 } 424 else if (mode == "available") 425 { 426 webbrowser_available.append(new_entry); 427 } 428 } 429 } 430 431 if ("Email" in categories) 432 { 433 if (name in email_installed_blacklist) 434 { 435 /* Blacklisted, pass */ 436 } 437 else 438 { 439 string new_entry = create_entry(kf, desktop_path); 440 if (mode == "installed") 441 { 442 email_installed.append(new_entry); 443 } 444 else if (mode == "available") 445 { 446 email_available.append(new_entry); 447 } 448 } 449 } 450 451 if ("FileManager" in categories) 452 { 453 if (name in file_manager_blacklist) 454 { 455 /* Blacklisted, pass */ 456 } 457 else 458 { 459 string new_entry = create_entry(kf, desktop_path); 460 if (mode == "installed") 461 { 462 file_manager_installed.append(new_entry); 463 } 464 else if (mode == "available") 465 { 466 file_manager_available.append(new_entry); 467 } 468 } 469 } 470 471 if ("Screensaver" in categories) 472 { 473 if (name in screensaver_blacklist) 474 { 475 /* Blacklisted, pass */ 476 } 477 else 478 { 479 string new_entry = create_entry(kf, desktop_path); 480 if (mode == "installed") 481 { 482 screensaver_installed.append(new_entry); 483 } 484 else if (mode == "available") 485 { 486 screensaver_available.append(new_entry); 487 } 488 } 489 } 490 491 if ("Composite" in categories) 492 { 493 if (name in composite_manager_blacklist) 494 { 495 /* Blacklisted, pass */ 496 } 497 else 498 { 499 string new_entry = create_entry(kf, desktop_path); 500 if (mode == "installed") 501 { 502 composite_manager_installed.append(new_entry); 503 } 504 else if (mode == "available") 505 { 506 composite_manager_available.append(new_entry); 507 } 508 } 509 } 510 511 if ("Desktop" in categories) 512 { 513 if (name in desktop_manager_blacklist) 514 { 515 /* Blacklisted, pass */ 516 } 517 else 518 { 519 string new_entry = create_entry(kf, desktop_path); 520 if (mode == "installed") 521 { 522 desktop_manager_installed.append(new_entry); 523 } 524 else if (mode == "available") 525 { 526 desktop_manager_available.append(new_entry); 527 } 528 } 529 } 530 531 if ("Power" in categories) 532 { 533 if (name in power_manager_blacklist) 534 { 535 /* Blacklisted, pass */ 536 } 537 else 538 { 539 string new_entry = create_entry(kf, desktop_path); 540 if (mode == "installed") 541 { 542 power_manager_installed.append(new_entry); 543 } 544 else if (mode == "available") 545 { 546 power_manager_available.append(new_entry); 547 } 548 } 549 } 550 551 if ("Polkit" in categories) 552 { 553 if (name in polkit_blacklist) 554 { 555 /* Blacklisted, pass */ 556 } 557 else 558 { 559 string new_entry = create_entry(kf, desktop_path); 560 if (mode == "installed") 561 { 562 polkit_installed.append(new_entry); 563 } 564 else if (mode == "available") 565 { 566 polkit_available.append(new_entry); 567 } 568 } 569 } 570 if ("InstantMessaging" in categories) 571 { 572 if (name in im_blacklist) 573 { 574 /* Blacklisted, pass */ 575 } 576 else 577 { 578 string new_entry = create_entry(kf, desktop_path); 579 if (mode == "installed") 580 { 581 im_installed.append(new_entry); 582 } 583 else if (mode == "available") 584 { 585 im_available.append(new_entry); 586 } 587 } 588 } 589 590 if ("Widget" in categories) 591 { 592 if (name in widget_blacklist) 593 { 594 /* Blacklisted, pass */ 595 } 596 else 597 { 598 string new_entry = create_entry(kf, desktop_path); 599 if (mode == "installed") 600 { 601 widget_installed.append(new_entry); 602 } 603 else if (mode == "available") 604 { 605 widget_available.append(new_entry); 606 } 607 } 608 } 609 610 if ("Terminal" in categories) 611 { 612 if (name in terminal_manager_blacklist) 613 { 614 /* Blacklisted, pass */ 615 } 616 else 617 { 618 string new_entry = create_entry(kf, desktop_path); 619 if (mode == "installed") 620 { 621 terminal_manager_installed.append(new_entry); 622 } 623 else if (mode == "available") 624 { 625 terminal_manager_available.append(new_entry); 626 } 627 } 628 } 629 if ("AudioVideo" in categories) 630 { 631 if (name in audio_video_blacklist) 632 { 633 /* Blacklisted, pass */ 634 } 635 else 636 { 637 string new_entry = create_entry(kf, desktop_path); 638 if (mode == "installed") 639 { 640 audio_installed.append(new_entry); 641 video_installed.append(new_entry); 642 } 643 else if (mode == "available") 644 { 645 audio_installed.append(new_entry); 646 video_available.append(new_entry); 647 } 648 } 649 } 650 else if ("Audio" in categories) 651 { 652 if (name in audio_blacklist) 653 { 654 /* Blacklisted, pass */ 655 } 656 else 657 { 658 string new_entry = create_entry(kf, desktop_path); 659 if (mode == "installed") 660 { 661 audio_installed.append(new_entry); 662 } 663 else if (mode == "available") 664 { 665 audio_available.append(new_entry); 666 } 667 } 668 } 669 else if ("Video" in categories) 670 { 671 if (name in video_blacklist) 672 { 673 /* Blacklisted, pass */ 674 } 675 else 676 { 677 string new_entry = create_entry(kf, desktop_path); 678 if (mode == "installed") 679 { 680 video_installed.append(new_entry); 681 } 682 else if (mode == "available") 683 { 684 video_available.append(new_entry); 685 } 686 } 687 } 688 689 if ("Viewer" in categories) 690 { 691 if (name in viewer_blacklist) 692 { 693 /* Blacklisted, pass */ 694 } 695 else 696 { 697 string new_entry = create_entry(kf, desktop_path); 698 if (mode == "installed") 699 { 700 image_display_installed.append(new_entry); 701 pdf_reader_installed.append(new_entry); 702 } 703 else if (mode == "available") 704 { 705 image_display_available.append(new_entry); 706 pdf_reader_available.append(new_entry); 707 } 708 } 709 } 710 711 if ("TextEditor" in categories) 712 { 713 if (name in text_editor_blacklist) 714 { 715 /* Blacklisted, pass */ 716 } 717 else 718 { 719 string new_entry = create_entry(kf, desktop_path); 720 if (mode == "installed") 721 { 722 text_editor_installed.append(new_entry); 723 } 724 else if (mode == "available") 725 { 726 text_editor_available.append(new_entry); 727 } 728 } 729 } 730 731 if ("Archiving" in categories) 732 { 733 if (name in archive_blacklist) 734 { 735 /* Blacklisted, pass */ 736 } 737 else 738 { 739 string new_entry = create_entry(kf, desktop_path); 740 if (mode == "installed") 741 { 742 archive_installed.append(new_entry); 743 } 744 else if (mode == "available") 745 { 746 archive_available.append(new_entry); 747 } 748 } 749 } 750 751 if ("Spreadsheet" in categories) 752 { 753 if (name in spreadsheet_blacklist) 754 { 755 /* Blacklisted, pass */ 756 } 757 else 758 { 759 string new_entry = create_entry(kf, desktop_path); 760 if (mode == "installed") 761 { 762 spreadsheet_installed.append(new_entry); 763 } 764 else if (mode == "available") 765 { 766 spreadsheet_available.append(new_entry); 767 } 768 } 769 } 770 771 if ("P2P" in categories) 772 { 773 if (name in bittorent_blacklist) 774 { 775 /* Blacklisted, pass */ 776 } 777 else 778 { 779 string new_entry = create_entry(kf, desktop_path); 780 if (mode == "installed") 781 { 782 bittorent_installed.append(new_entry); 783 } 784 else if (mode == "available") 785 { 786 bittorent_available.append(new_entry); 787 } 788 } 789 } 790 791 if ("WordProcessor" in categories) 792 { 793 if (name in document_blacklist) 794 { 795 /* Blacklisted, pass */ 796 } 797 else 798 { 799 string new_entry = create_entry(kf, desktop_path); 800 if (mode == "installed") 801 { 802 document_installed.append(new_entry); 803 } 804 else if (mode == "available") 805 { 806 document_available.append(new_entry); 807 } 808 } 809 } 810 811 if ("DiscBurning" in categories) 812 { 813 if (name in burn_blacklist) 814 { 815 /* Blacklisted, pass */ 816 } 817 else 818 { 819 string new_entry = create_entry(kf, desktop_path); 820 if (mode == "installed") 821 { 822 burn_installed.append(new_entry); 823 } 824 else if (mode == "available") 825 { 826 burn_available.append(new_entry); 827 } 828 } 829 } 830 831 if ("Monitor" in categories) 832 { 833 if (name in tasks_blacklist) 834 { 835 /* Blacklisted, pass */ 836 } 837 else 838 { 839 string new_entry = create_entry(kf, desktop_path); 840 if (mode == "installed") 841 { 842 tasks_installed.append(new_entry); 843 } 844 else if (mode == "available") 845 { 846 tasks_available.append(new_entry); 847 } 848 } 849 } 850 851 } 852 } 853 catch (KeyFileError err) 854 { 855 /* No entry, just pass */; 856 } 857 } 858 859 /* Debug */ 860 861 public void print_values_available () 862 { 863 message ("Printing available webbrowser"); 864 foreach (string entry in webbrowser_available) 865 { 866 message(entry); 867 } 868 869 message ("Printing available email"); 870 foreach (string entry in email_available) 871 { 872 message(entry); 873 } 874 } 875 876 public void print_values_installed () 877 { 878 message ("Printing installed webbrowser"); 879 foreach (string entry in webbrowser_installed) 880 { 881 message(entry); 882 } 883 884 message ("Printing installed email"); 885 foreach (string entry in email_installed) 886 { 887 message(entry); 888 } 889 } 890 891 public void save_values_installed () 892 { 893 keyfile_set_list_string(kf, "Mime", "webbrowser/installed", webbrowser_installed); 894 keyfile_set_list_string(kf, "Mime", "email/installed", email_installed); 895 keyfile_set_list_string(kf, "Mime", "file_manager/installed", file_manager_installed); 896 keyfile_set_list_string(kf, "Mime", "screensaver/installed", screensaver_installed); 897 keyfile_set_list_string(kf, "Mime", "composite_manager/installed", composite_manager_installed); 898 keyfile_set_list_string(kf, "Mime", "desktop_manager/installed", desktop_manager_installed); 899 keyfile_set_list_string(kf, "Mime", "power_manager/installed", power_manager_installed); 900 keyfile_set_list_string(kf, "Mime", "polkit/installed", polkit_installed); 901 keyfile_set_list_string(kf, "Mime", "im/installed", im_installed); 902 keyfile_set_list_string(kf, "Mime", "widget/installed", widget_installed); 903 keyfile_set_list_string(kf, "Mime", "terminal_manager/installed", terminal_manager_installed); 904 keyfile_set_list_string(kf, "Mime", "audio_player/installed", audio_installed); 905 keyfile_set_list_string(kf, "Mime", "video_player/installed", video_installed); 906 keyfile_set_list_string(kf, "Mime", "pdf_reader/installed", pdf_reader_installed); 907 keyfile_set_list_string(kf, "Mime", "image_display/installed", image_display_installed); 908 keyfile_set_list_string(kf, "Mime", "text_editor/installed", text_editor_installed); 909 keyfile_set_list_string(kf, "Mime", "archive/installed", archive_installed); 910 keyfile_set_list_string(kf, "Mime", "spreadsheet/installed", spreadsheet_installed); 911 keyfile_set_list_string(kf, "Mime", "bittorent/installed", bittorent_installed); 912 keyfile_set_list_string(kf, "Mime", "document/installed", document_installed); 913 keyfile_set_list_string(kf, "Mime", "burn/installed", burn_installed); 914 keyfile_set_list_string(kf, "Mime", "tasks/installed", tasks_installed); 915 916 save_keyfile(); 917 } 918 919 public void save_values_available () 920 { 921 keyfile_set_list_string(kf, "Mime", "webbrowser/available", webbrowser_available); 922 keyfile_set_list_string(kf, "Mime", "email/available", email_available); 923 keyfile_set_list_string(kf, "Mime", "file_manager/available", file_manager_available); 924 keyfile_set_list_string(kf, "Mime", "screensaver/available", screensaver_available); 925 keyfile_set_list_string(kf, "Mime", "composite_manager/available", composite_manager_available); 926 keyfile_set_list_string(kf, "Mime", "desktop_manager/available", desktop_manager_available); 927 keyfile_set_list_string(kf, "Mime", "power_manager/available", power_manager_available); 928 keyfile_set_list_string(kf, "Mime", "polkit/available", polkit_available); 929 keyfile_set_list_string(kf, "Mime", "im/available", im_available); 930 keyfile_set_list_string(kf, "Mime", "widget/available", widget_available); 931 keyfile_set_list_string(kf, "Mime", "terminal_manager/available", terminal_manager_available); 932 keyfile_set_list_string(kf, "Mime", "audio_player/available", audio_available); 933 keyfile_set_list_string(kf, "Mime", "video_player/available", video_available); 934 keyfile_set_list_string(kf, "Mime", "pdf_reader/available", pdf_reader_available); 935 keyfile_set_list_string(kf, "Mime", "image_display/available", image_display_available); 936 keyfile_set_list_string(kf, "Mime", "text_editor/available", text_editor_available); 937 keyfile_set_list_string(kf, "Mime", "archive/available", archive_available); 938 keyfile_set_list_string(kf, "Mime", "spreadsheet/available", spreadsheet_available); 939 keyfile_set_list_string(kf, "Mime", "bittorent/available", bittorent_available); 940 keyfile_set_list_string(kf, "Mime", "document/available", document_available); 941 keyfile_set_list_string(kf, "Mime", "burn/available", burn_available); 942 keyfile_set_list_string(kf, "Mime", "tasks/available", tasks_available); 943 944 save_keyfile(); 945 } 946 947 public void save_keyfile () 948 { 949 var str = kf.to_data (null); 950 try 951 { 952 FileUtils.set_contents (config_path, str, str.length); 953 } 954 catch (FileError err) 955 { 956 warning (err.message); 957 } 958 } 959 960 public void keyfile_set_list_string (KeyFile kf, string categorie, string key1, List<string> list) 961 { 962 string[] tmp_array = {}; 963 foreach(string entry in list) 964 { 965 if (entry != null) 966 { 967 tmp_array += entry; 968 } 969 } 970 971 kf.set_string_list(categorie, key1, tmp_array); 972 } 973 } 974} 975