summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/po/tg.po
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone/po/tg.po')
-rw-r--r--perl-install/standalone/po/tg.po276
1 files changed, 148 insertions, 128 deletions
diff --git a/perl-install/standalone/po/tg.po b/perl-install/standalone/po/tg.po
index 06ce73b39..092266633 100644
--- a/perl-install/standalone/po/tg.po
+++ b/perl-install/standalone/po/tg.po
@@ -16,7 +16,7 @@ msgid ""
msgstr ""
"Project-Id-Version: DrakX-tg\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-07-01 13:42+0200\n"
+"POT-Creation-Date: 2007-08-06 12:30+0200\n"
"PO-Revision-Date: 2005-09-17 16:03+0500\n"
"Last-Translator: Victor Ibragimov <youth_opportunities@tajikngo.org>\n"
"Language-Team: Tajik\n"
@@ -30,17 +30,17 @@ msgstr ""
msgid "No bootloader found, creating a new configuration"
msgstr ""
-#: drakboot:83 harddrake2:194 harddrake2:195 logdrake:70
+#: drakboot:83 harddrake2:194 harddrake2:195 logdrake:71
#, c-format
msgid "/_File"
msgstr "/_Файл"
-#: drakboot:84 logdrake:76
+#: drakboot:84 logdrake:77
#, c-format
msgid "/File/_Quit"
msgstr "/Файл/_Баромадан"
-#: drakboot:84 harddrake2:195 logdrake:76
+#: drakboot:84 harddrake2:195 logdrake:77
#, c-format
msgid "<control>Q"
msgstr "<control>Cyrillic_BE"
@@ -151,62 +151,62 @@ msgstr ""
"Боварӣ ҳосил намоед, ки видео корти шумо усули интхобкардаатонро пуштибонӣ "
"мекунад."
-#: drakbug:43
+#: drakbug:46
#, c-format
msgid "Mandriva Linux Bug Report Tool"
msgstr "Mandriva Linux Асбоби Сохтани Маърӯза оиди Хатогӣ"
-#: drakbug:48
+#: drakbug:51
#, c-format
msgid "Mandriva Linux Control Center"
msgstr "Маркази Идораи Mandriva Linux"
-#: drakbug:49
+#: drakbug:52
#, c-format
msgid "First Time Wizard"
msgstr "Устози Аввалин Маротиба"
-#: drakbug:50
+#: drakbug:53
#, c-format
msgid "Synchronization tool"
msgstr "Асбоби ҳангомашавӣ"
-#: drakbug:51 drakbug:145
+#: drakbug:54 drakbug:168
#, c-format
msgid "Standalone Tools"
msgstr "Асбобҳои Standalone"
-#: drakbug:53
+#: drakbug:56 drakbug:57
#, c-format
msgid "Mandriva Online"
msgstr "Mandriva Ғайрихудмухтор"
-#: drakbug:54
+#: drakbug:58
#, c-format
msgid "Remote Control"
msgstr "Идоракунии Дурдаст"
-#: drakbug:55
+#: drakbug:59
#, c-format
msgid "Software Manager"
msgstr "Мудири Нармафзор"
-#: drakbug:56
+#: drakbug:60
#, c-format
msgid "Windows Migration tool"
msgstr "Асбоби Миграсияи Windows"
-#: drakbug:57
+#: drakbug:61
#, c-format
msgid "Configuration Wizards"
msgstr "Устоди Танзимдарорӣ"
-#: drakbug:79
+#: drakbug:83
#, c-format
msgid "Select Mandriva Tool:"
msgstr ""
-#: drakbug:80
+#: drakbug:84
#, fuzzy, c-format
msgid ""
"or Application Name\n"
@@ -215,29 +215,39 @@ msgstr ""
"Номи замима\n"
"ё ин ки роҳи пур:"
-#: drakbug:83
+#: drakbug:87
#, c-format
msgid "Find Package"
msgstr "Дарёфтани Бастаи Барномаҳо"
-#: drakbug:85
+#: drakbug:89
#, c-format
msgid "Package: "
msgstr "Қуттӣ: "
-#: drakbug:86
+#: drakbug:90
#, c-format
msgid "Kernel:"
msgstr "Ҳаста:"
-#: drakbug:94
+#: drakbug:102
+#, c-format
+msgid "The \"%s\" program has crashed with the following error:"
+msgstr ""
+
+#: drakbug:104
+#, c-format
+msgid "The \"%s\" program has crashed."
+msgstr ""
+
+#: drakbug:106
#, fuzzy, c-format
msgid ""
"To submit a bug report, click on the report button. \n"
"This will open a web browser window on %s where you'll find a form to fill "
"in. The information displayed above will be transferred to that server. \n"
-"Things useful to include in your report are the output of lspcidrake -v, kernel "
-"version, and /proc/cpuinfo."
+"Things useful to include in your report are the output of lspcidrake -v, "
+"kernel version, and /proc/cpuinfo."
msgstr ""
"Барои пешниҳоди ҳисбот оиди хатогӣ тугмачаи Ҳисоботро пахш намоед.\n"
"Оинаи барномаи нозири веб дар %s кушода мешавад, ки дар он шаклеро барои "
@@ -245,17 +255,17 @@ msgstr ""
" намудан пайдо мекунед. Ахбороти дар боло пешниҳод шуда ба ин хизматрасон\n"
"фиристода хоҳад шуд."
-#: drakbug:100
+#: drakbug:112
#, c-format
msgid "Report"
msgstr "Маърӯза"
-#: drakbug:155
+#: drakbug:178
#, c-format
msgid "Not installed"
msgstr "Коргузорӣ нашудааст"
-#: drakbug:168
+#: drakbug:191
#, c-format
msgid "Package not installed"
msgstr "Бастаи барномаҳо коргузорӣ нашудааст"
@@ -396,8 +406,8 @@ msgstr "Ҳуруфҳо пайдо нашуданд"
msgid "parse all fonts"
msgstr "ҳамаи ҳуруфотро тақсим намудан"
-#: drakfont:222 drakfont:263 drakfont:332 drakfont:373 drakfont:381
-#: drakfont:407 drakfont:425 drakfont:439
+#: drakfont:222 drakfont:263 drakfont:332 drakfont:373 drakfont:380
+#: drakfont:406 drakfont:424 drakfont:438
#, c-format
msgid "done"
msgstr "шудагӣ"
@@ -462,17 +472,17 @@ msgstr "Муроҷиати Ghostscript"
msgid "Suppress Temporary Files"
msgstr "Файлҳои Муваққатиро хориҷ намудан"
-#: drakfont:377 drakfont:435
+#: drakfont:376 drakfont:434
#, c-format
msgid "Restart XFS"
msgstr "Бозоғозёбии XFS"
-#: drakfont:423 drakfont:433
+#: drakfont:422 drakfont:432
#, c-format
msgid "Suppress Fonts Files"
msgstr "Хориҷи Файлҳои Ҳуруфҳо"
-#: drakfont:443
+#: drakfont:442
#, c-format
msgid ""
"Before installing any fonts, be sure that you have the right to use and "
@@ -487,166 +497,166 @@ msgstr ""
"-Шумо ҳуруфҳоро бо роҳи муқаррарӣ коргузорӣ карда метавонед. Дар баъзе "
"ҳолатҳо ҳуруфҳои қалбакӣ X Хидматрасони шуморо нобуд карда метавонад."
-#: drakfont:483
+#: drakfont:482
#, fuzzy, c-format
msgid "Font Installation"
msgstr "Коргузорӣ ба итмом расид"
-#: drakfont:494
+#: drakfont:493
#, c-format
msgid "DrakFont"
msgstr "DrakҲуруф"
-#: drakfont:495 drakfont:647
+#: drakfont:494 drakfont:646
#, c-format
msgid "Font List"
msgstr "Рӯйхати Ҳуруф"
-#: drakfont:498
+#: drakfont:497
#, c-format
msgid "Get Windows Fonts"
msgstr ""
-#: drakfont:504
+#: drakfont:503
#, c-format
msgid "About"
msgstr "Дар бораи"
-#: drakfont:506 drakfont:726
+#: drakfont:505 drakfont:725
#, c-format
msgid "Uninstall"
msgstr "Хориҷ кардан"
-#: drakfont:507
+#: drakfont:506
#, c-format
msgid "Import"
msgstr "Воридот"
-#: drakfont:525
+#: drakfont:524
#, fuzzy, c-format
msgid "Drakfont"
msgstr "DrakҲуруф"
-#: drakfont:527
+#: drakfont:526
#, c-format
msgid "Copyright (C) 2001-2006 by Mandriva"
msgstr "Ҳуқуқи муаллифӣ (C) 2001-2006 Mandriva"
-#: drakfont:529
+#: drakfont:528
#, fuzzy, c-format
msgid "Font installer."
msgstr "Коргузорӣ нашудааст"
-#: drakfont:531 harddrake2:236
+#: drakfont:530 harddrake2:236
#, c-format
msgid "Mandriva Linux"
msgstr "Mandriva Linux"
#. -PO: put here name(s) and email(s) of translator(s) (eg: "John Smith <jsmith@nowhere.com>")
#. -PO: put here name(s) and email(s) of translator(s) (eg: "John Smith <jsmith@nowhere.com>")
-#: drakfont:538 harddrake2:241
+#: drakfont:537 harddrake2:241
#, c-format
msgid "_: Translator(s) name(s) & email(s)\n"
msgstr "Victor Ibragimov <youth_opportunities@tajikngo.org>\n"
-#: drakfont:548
+#: drakfont:547
#, c-format
msgid "Choose the applications that will support the fonts:"
msgstr "Замимаеро, ки ҳуруфҳоро пуштибонӣ мекунад, интихоб намоед:"
-#: drakfont:559
+#: drakfont:558
#, c-format
msgid "Ghostscript"
msgstr "Ghostscript"
-#: drakfont:560
+#: drakfont:559
#, c-format
msgid "OpenOffice.org"
msgstr ""
-#: drakfont:561
+#: drakfont:560
#, c-format
msgid "Abiword"
msgstr "Abiword"
-#: drakfont:562
+#: drakfont:561
#, c-format
msgid "Generic Printers"
msgstr "Чопгарҳои намунавӣ"
-#: drakfont:576
+#: drakfont:575
#, c-format
msgid "Select the font file or directory and click on 'Add'"
msgstr ""
"Файли ҳуруф ё ин ки феҳристро интихоб намоед ва ба 'Илова намудан' ангушт "
"занед"
-#: drakfont:577
+#: drakfont:576
#, c-format
msgid "File Selection"
msgstr "Интихоби Файл"
-#: drakfont:581
+#: drakfont:580
#, c-format
msgid "Fonts"
msgstr "Ҳуруфҳо"
-#: drakfont:645
+#: drakfont:644
#, c-format
msgid "Import fonts"
msgstr "Ҳуруфҳоро ворид кунед"
-#: drakfont:658
+#: drakfont:657
#, c-format
msgid "Install"
msgstr "Коргузорӣ"
-#: drakfont:689
+#: drakfont:688
#, c-format
msgid "Are you sure you want to uninstall the following fonts?"
msgstr ""
-#: drakfont:734
+#: drakfont:733
#, c-format
msgid "Unselected All"
msgstr "Ноинтихоби Ҳама"
-#: drakfont:737
+#: drakfont:736
#, c-format
msgid "Selected All"
msgstr "Интихоби Ҳама"
-#: drakfont:751 drakfont:770
+#: drakfont:750 drakfont:769
#, c-format
msgid "Importing fonts"
msgstr "Воридкунии ҳуруфҳо"
-#: drakfont:755 drakfont:775
+#: drakfont:754 drakfont:774
#, c-format
msgid "Initial tests"
msgstr "Санҷишҳои шиносоӣ"
-#: drakfont:756
+#: drakfont:755
#, c-format
msgid "Copy fonts on your system"
msgstr "Нусхабардории ҳуруфҳо ба системаи шумо"
-#: drakfont:757
+#: drakfont:756
#, c-format
msgid "Install & convert Fonts"
msgstr "Коргузорӣ ва тағироти ҳуруфот"
-#: drakfont:758
+#: drakfont:757
#, c-format
msgid "Post Install"
msgstr "Коргузорӣ ба итмом расид"
-#: drakfont:776
+#: drakfont:775
#, c-format
msgid "Remove fonts on your system"
msgstr "Хориҷкунии ҳуруфҳо ба системаи шумо"
-#: drakfont:777
+#: drakfont:776
#, c-format
msgid "Post Uninstall"
msgstr "Почтаро кор нагузоштан"
@@ -1406,7 +1416,7 @@ msgstr "Худмуайянкунӣ"
msgid "Detection in progress"
msgstr "Муаяйнкунӣ дар раванди иҷроиш қарор дорад"
-#: drakups:118 drakups:157 logdrake:449 logdrake:455
+#: drakups:118 drakups:157 logdrake:457 logdrake:463
#, c-format
msgid "Congratulations"
msgstr "Табрикот"
@@ -2255,12 +2265,12 @@ msgid "Features"
msgstr "Хусусиятҳо"
#. -PO: please keep all "/" characters !!!
-#: harddrake2:176 logdrake:77
+#: harddrake2:176 logdrake:78
#, c-format
msgid "/_Options"
msgstr "/_Хосиятҳо"
-#: harddrake2:177 harddrake2:206 logdrake:79
+#: harddrake2:177 harddrake2:206 logdrake:80
#, c-format
msgid "/_Help"
msgstr "/_Ёрӣ"
@@ -2402,173 +2412,173 @@ msgstr "сабткунанда"
msgid "DVD"
msgstr "DVD"
-#: localedrake:38
+#: localedrake:47
#, c-format
msgid "LocaleDrake"
msgstr "Маҳалли Drake"
-#: localedrake:44
+#: localedrake:53
#, c-format
msgid "You should install the following packages: %s"
msgstr "Шумо бояд бастаҳои зеринро коргузорӣ намоед: %s"
#. -PO: the following is used to combine packages names. eg: "initscripts, harddrake, yudit"
-#: localedrake:47
+#: localedrake:56
#, c-format
msgid ", "
msgstr ", "
-#: localedrake:55
+#: localedrake:64
#, c-format
msgid "The change is done, but to be effective you must logout"
msgstr ""
"Тағирот иҷро шудааст, лекин барои самаранок гардидани он шумо бояд аз систем "
"бароед"
-#: logdrake:50
+#: logdrake:51
#, c-format
msgid "Mandriva Linux Tools Logs"
msgstr "Шарҳдиҳандаҳои Асбобҳои Mandriva Linux"
-#: logdrake:51
+#: logdrake:52
#, c-format
msgid "Logs"
msgstr "Воридҳо"
-#: logdrake:64
+#: logdrake:65
#, c-format
msgid "Show only for the selected day"
msgstr "Танҳо барои рӯзи интихобшуда нишон диҳед"
-#: logdrake:71
+#: logdrake:72
#, c-format
msgid "/File/_New"
msgstr "/Файл/_Нав"
-#: logdrake:71
+#: logdrake:72
#, c-format
msgid "<control>N"
msgstr "<control>N"
-#: logdrake:72
+#: logdrake:73
#, c-format
msgid "/File/_Open"
msgstr "/Файл/_Кушодан"
-#: logdrake:72
+#: logdrake:73
#, c-format
msgid "<control>O"
msgstr "<control>O"
-#: logdrake:73
+#: logdrake:74
#, c-format
msgid "/File/_Save"
msgstr "/Файл/_Нигоҳ доштан"
-#: logdrake:73
+#: logdrake:74
#, c-format
msgid "<control>S"
msgstr "<control>S"
-#: logdrake:74
+#: logdrake:75
#, c-format
msgid "/File/Save _As"
msgstr "/Файл/нигоҳ доред _ҳамчун"
-#: logdrake:75
+#: logdrake:76
#, c-format
msgid "/File/-"
msgstr "/Файл/-"
-#: logdrake:78
+#: logdrake:79
#, c-format
msgid "/Options/Test"
msgstr "/Хосиятҳо/Санҷиш"
-#: logdrake:80
+#: logdrake:81
#, c-format
msgid "/Help/_About..."
msgstr "/Ёрӣ/_Дар бораи..."
-#: logdrake:109
+#: logdrake:110
#, c-format
msgid ""
"_:this is the auth.log log file\n"
"Authentication"
msgstr "Аслшиносӣ"
-#: logdrake:110
+#: logdrake:111
#, c-format
msgid ""
"_:this is the user.log log file\n"
"User"
msgstr "Корванд"
-#: logdrake:111
+#: logdrake:112
#, c-format
msgid ""
"_:this is the /var/log/messages log file\n"
"Messages"
msgstr "Паёмҳо"
-#: logdrake:112
+#: logdrake:113
#, c-format
msgid ""
"_:this is the /var/log/syslog log file\n"
"Syslog"
msgstr "Номнависи системавӣ"
-#: logdrake:116
+#: logdrake:117
#, c-format
msgid "search"
msgstr "ҷустуҷӯ"
-#: logdrake:128
+#: logdrake:129
#, c-format
msgid "A tool to monitor your logs"
msgstr "Асбоб барои назорати номнависии шумо"
-#: logdrake:130
+#: logdrake:131
#, c-format
msgid "Settings"
msgstr "Танзимдарориҳо"
-#: logdrake:133
+#: logdrake:134
#, c-format
msgid "Matching"
msgstr "Мувофиқкунӣ"
-#: logdrake:134
+#: logdrake:135
#, c-format
msgid "but not matching"
msgstr "лекин мувофиқат намекунад"
-#: logdrake:137
+#: logdrake:138
#, c-format
msgid "Choose file"
msgstr "Файл интихоб кунед"
-#: logdrake:149
+#: logdrake:150
#, c-format
msgid "Calendar"
msgstr "Тақвим"
-#: logdrake:158
+#: logdrake:159
#, c-format
msgid "Content of the file"
msgstr "Мундариҷаи файл"
-#: logdrake:162 logdrake:399
+#: logdrake:163 logdrake:407
#, c-format
msgid "Mail alert"
msgstr "Огоҳиномаи почтавӣ"
-#: logdrake:169
+#: logdrake:170
#, c-format
msgid "The alert wizard has failed unexpectedly:"
msgstr "Устоди огоҳонӣ ногаҳон хомӯш шуд:"
-#: logdrake:173
+#: logdrake:174
#, c-format
msgid "Save"
msgstr "Нигоҳ доштан"
@@ -2578,62 +2588,72 @@ msgstr "Нигоҳ доштан"
msgid "please wait, parsing file: %s"
msgstr "Лутфан мунтазир шавед, файл таҷзия мегардад: %s"
-#: logdrake:377
+#: logdrake:244
+#, c-format
+msgid "Sorry, log file isn't available!"
+msgstr ""
+
+#: logdrake:292
+#, c-format
+msgid "Error while opening \"%s\" log file: %s\n"
+msgstr ""
+
+#: logdrake:385
#, c-format
msgid "Apache World Wide Web Server"
msgstr "Хидматрасони WWW Apache"
-#: logdrake:378
+#: logdrake:386
#, c-format
msgid "Domain Name Resolver"
msgstr "Ҳалкунандаи Номи Соҳибӣ"
-#: logdrake:379
+#: logdrake:387
#, c-format
msgid "Ftp Server"
msgstr "Хидматгори Ftp"
-#: logdrake:380
+#: logdrake:388
#, c-format
msgid "Postfix Mail Server"
msgstr "Хизматрасони Почтавии Postfix"
-#: logdrake:381
+#: logdrake:389
#, c-format
msgid "Samba Server"
msgstr "Хидматгори Samba"
-#: logdrake:382
+#: logdrake:390
#, c-format
msgid "SSH Server"
msgstr "Хидматгори SSH"
-#: logdrake:383
+#: logdrake:391
#, c-format
msgid "Webmin Service"
msgstr "Хизматрасони Webmin"
-#: logdrake:384
+#: logdrake:392
#, c-format
msgid "Xinetd Service"
msgstr "Хадамоти Xinetd"
-#: logdrake:393
+#: logdrake:401
#, c-format
msgid "Configure the mail alert system"
msgstr "Танзими системаи огоҳонии постӣ"
-#: logdrake:394
+#: logdrake:402
#, c-format
msgid "Stop the mail alert system"
msgstr "Системаи огоҳкунии постиро боздоред"
-#: logdrake:402
+#: logdrake:410
#, c-format
msgid "Mail alert configuration"
msgstr "Танзимдарории огоҳиномаи пост"
-#: logdrake:403
+#: logdrake:411
#, c-format
msgid ""
"Welcome to the mail configuration utility.\n"
@@ -2644,17 +2664,17 @@ msgstr ""
"\n"
"Дар ин ҷо шумо метавонед системи огоҳиро барпо созед.\n"
-#: logdrake:406
+#: logdrake:414
#, c-format
msgid "What do you want to do?"
msgstr "Шумо чӣ кор кардан мехоҳед?"
-#: logdrake:413
+#: logdrake:421
#, c-format
msgid "Services settings"
msgstr "Гузоришҳои хизматрасониҳо"
-#: logdrake:414
+#: logdrake:422
#, c-format
msgid ""
"You will receive an alert if one of the selected services is no longer "
@@ -2663,49 +2683,49 @@ msgstr ""
"Агар яке аз хидматрасонҳои интихобшуда корандозӣ карда шуда набошад, онгоҳ "
"шумо огоҳномаеро хоҳед гирифт"
-#: logdrake:421
+#: logdrake:429
#, c-format
msgid "Load setting"
msgstr "Гузоришҳоро бор кунед"
-#: logdrake:422
+#: logdrake:430
#, c-format
msgid "You will receive an alert if the load is higher than this value"
msgstr ""
"Агар корандозӣ аз ин қимат баландтар бошад, онгоҳ шумо огоҳномаеро мегиред"
-#: logdrake:423
+#: logdrake:431
#, c-format
msgid ""
"_: load here is a noun, the load of the system\n"
"Load"
msgstr "Кор андохтан"
-#: logdrake:428
+#: logdrake:436
#, c-format
msgid "Alert configuration"
msgstr "Батанзимдарории огоҳкунӣ"
-#: logdrake:429
+#: logdrake:437
#, c-format
msgid "Please enter your email address below "
msgstr "Лутфан. дар поён суроғаи электронии худро дохил намоед "
-#: logdrake:430
+#: logdrake:438
#, c-format
msgid "and enter the name (or the IP) of the SMTP server you wish to use"
msgstr ""
"ва номро дохил кунед (ё Шиносаи) хидматрасони SMTP-ро, ки шумо истифода "
"бурдан мехоҳед"
-#: logdrake:437
+#: logdrake:445
#, c-format
msgid "\"%s\" neither is a valid email nor is an existing local user!"
msgstr ""
"\"%s\" на дигар суроғаи пости электронӣ ва на корванди маҳаллии мавҷуда "
"мебошад!"
-#: logdrake:442
+#: logdrake:450
#, c-format
msgid ""
"\"%s\" is a local user, but you did not select a local smtp, so you must use "
@@ -2714,17 +2734,17 @@ msgstr ""
"\"%s\" корванди маҳаллӣ аст, лекин шумо smtp-и маҳаллиро интихоб накардед, "
"бинобар ин шумо суроғаи пости электронии пурраро истифода баред!"
-#: logdrake:449
+#: logdrake:457
#, c-format
msgid "The wizard successfully configured the mail alert."
msgstr "Устод бо муваффақият огоҳонии постиро танзим кард."
-#: logdrake:455
+#: logdrake:463
#, c-format
msgid "The wizard successfully disabled the mail alert."
msgstr "Устод бо муваффақият огоҳонии постиро хомӯш кард."
-#: logdrake:514
+#: logdrake:522
#, c-format
msgid "Save as.."
msgstr "Нигоҳ доред ҳамчун..."
@@ -3249,27 +3269,27 @@ msgstr ""
msgid "Your scanner(s) will not be available on the network."
msgstr "Пуйишгар(ҳо)и шумо дар шабака мавҷуд нест."
-#: service_harddrake:137
+#: service_harddrake:131
#, c-format
msgid "Some devices in the \"%s\" hardware class were removed:\n"
msgstr "Якчанд дастгоҳ аз сахтафзори синфи \"%s\" хориҷ карда шуда буд:\n"
-#: service_harddrake:138
+#: service_harddrake:132
#, c-format
msgid "- %s was removed\n"
msgstr "- %s хориҷ карда шуд\n"
-#: service_harddrake:141
+#: service_harddrake:135
#, c-format
msgid "Some devices were added: %s\n"
msgstr "Даъзе дастгоҳҳо илова карда шуданд: %s\n"
-#: service_harddrake:142
+#: service_harddrake:136
#, c-format
msgid "- %s was added\n"
msgstr "- %s илова карда шуд\n"
-#: service_harddrake:265
+#: service_harddrake:259
#, c-format
msgid "Hardware probing in progress"
msgstr "Санҷиши сахтафзор иҷро шуда истодааст"
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505
package printer::main;

# $Id$

use strict;

use common;
use run_program;
use printer::data;
use printer::services;
use printer::default;
use printer::gimp;
use printer::cups;
use printer::office;
use printer::detect;
use handle_configs;
use services;

use vars qw(@ISA @EXPORT);

@ISA = qw(Exporter);
@EXPORT = qw(%printer_type %printer_type_inv);

#-Did we already read the subroutines of /usr/sbin/ptal-init?
my $ptalinitread = 0;

our %printer_type = (
    N("Local printer")                              => "LOCAL",
    N("Remote printer")                             => "REMOTE",
    N("Printer on remote CUPS server")              => "CUPS",
    N("Printer on remote lpd server")               => "LPD",
    N("Network printer (TCP/Socket)")               => "SOCKET",
    N("Printer on SMB/Windows 95/98/NT server")     => "SMB",
    N("Printer on NetWare server")                  => "NCP",
    N("Enter a printer device URI")                 => "URI",
    N("Pipe job into a command")                    => "POSTPIPE"
);

our %printer_type_inv = reverse %printer_type;

our %thedb;

#------------------------------------------------------------------------------

sub spooler() {
    # LPD is taken from the menu for the moment because the classic LPD is
    # highly unsecure. Depending on how the GNU lpr development is going on
    # LPD support can be reactivated by uncommenting the following line.

    #return @spooler_inv{qw(cups lpd lprng pdq)};

    # LPRng is not officially supported any more since Mandrake 9.0, so
    # show it only in the spooler menu when it was manually installed.

    # PDQ is not officially supported any more since Mandrake 9.1, so
    # show it only in the spooler menu when it was manually installed.

    return map { $spoolers{$_}{long_name} } qw(cups), 
    if_(files_exist(qw(/usr/bin/pdq)), 'pdq'),
    if_(files_exist(qw(/usr/lib/filters/lpf /usr/sbin/lpd)), 'lprng');
}

sub printer_type($) {
    my ($printer) = @_;
    for ($printer->{SPOOLER}) {
	/cups/  and return @printer_type_inv{qw(LOCAL LPD SOCKET SMB), if_($printer->{expert}, qw(URI))};
	/lpd/   and return @printer_type_inv{qw(LOCAL LPD SOCKET SMB NCP), if_($printer->{expert}, qw(POSTPIPE URI))};
	/lprng/ and return @printer_type_inv{qw(LOCAL LPD SOCKET SMB NCP), if_($printer->{expert}, qw(POSTPIPE URI))};
	/pdq/   and return @printer_type_inv{qw(LOCAL LPD SOCKET), if_($printer->{expert}, qw(URI))};
    }
}

sub SIGHUP_daemon {
    my ($service) = @_;
    if ($service eq "cupsd") { $service = "cups" };
    # PDQ has no daemon, exit.
    if ($service eq "pdq") { return 1 };
    # CUPS needs auto-correction for its configuration
    run_program::rooted($::prefix, "/usr/sbin/correctcupsconfig") if $service eq "cups";
    # Name of the daemon
    my %daemons = (
			    "lpr" => "lpd",
			    "lpd" => "lpd",
			    "lprng" => "lpd",
			    "cups" => "cupsd",
			    "devfs" => "devfsd",
			    );
    my $daemon = $daemons{$service};
    $daemon = $service unless defined $daemon;
#    if ($service eq "cups") {
#	# The current CUPS (1.1.13) dies on SIGHUP, do the normal restart.
#	printer::services::restart($service);
#	# CUPS needs some time to come up.
#	printer::services::wait_for_cups();
#    } else {

    # Send the SIGHUP
    run_program::rooted($::prefix, "/usr/bin/killall", "-HUP", $daemon);
    if ($service eq "cups") {
	# CUPS needs some time to come up.
	printer::services::wait_for_cups();
    }

    return 1;
}


sub assure_device_is_available_for_cups {
    # Checks whether CUPS already "knows" a certain port, it does not
    # know it usually when the appropriate kernel module is loaded
    # after CUPS was started or when the printer is turned on after
    # CUPS was started. CUPS 1.1.12 and newer refuses to set up queues
    # on devices which it does not know, it points these queues to
    # file:/dev/null instead. Restart CUPS if necessary to assure that
    # CUPS knows the device.
    my ($device) = @_;
    my $sdevice = handle_configs::searchstr($device);
    my ($result, $i);
    # USB printers get special model-dependent URLs in "lpinfo -v" here
    # checking is complicated, so we simply restart CUPS then and ready.
    if ($device =~ /usb/) {
	$result = printer::services::restart("cups");
	return 1;
    }
    my $maxattempts = 3;
    for ($i = 0; $i < $maxattempts; $i++) {
	local *F; 
	open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . 
	    "/bin/sh -c \"export LC_ALL=C; /usr/sbin/lpinfo -v\" |" or
	    die "Could not run \"lpinfo\"!";
	while (my $line = <F>) {
	    if ($line =~ /$sdevice/) { # Found a line containing the device
		                       # name, so CUPS knows it.
		close F;
		return 1;
	    }
	}
	close F;
	$result = printer::services::restart("cups");
    }
    return $result;
}


sub spooler_in_security_level {
    # Was the current spooler already added to the current security level?
    my ($spooler, $level) = @_;
    my $sp;
    $sp = $spooler eq "lpr" || $spooler eq "lprng" ? "lpd" : $spooler;
    my $file = "$::prefix/etc/security/msec/server.$level";
    if (-f $file) {
	local *F; 
	open F, "< $file" or return 0;
	while (my $line = <F>) {
	    if ($line =~ /^\s*$sp\s*$/) {
		close F;
		return 1;
	    }
	}
	close F;
    }
    return 0;
}

sub add_spooler_to_security_level {
    my ($spooler, $level) = @_;
    my $sp;
    $sp = $spooler eq "lpr" || $spooler eq "lprng" ? "lpd" : $spooler;
    my $file = "$::prefix/etc/security/msec/server.$level";
    if (-f $file) {
	   eval { append_to_file($file, "$sp\n") } or return 0;
    }
    return 1;
}

sub pdq_panic_button {
    my $setting = $_[0];
    if (-f "$::prefix/usr/sbin/pdqpanicbutton") {
        run_program::rooted($::prefix, "/usr/sbin/pdqpanicbutton", "--$setting")
	    or die "Could not $setting PDQ panic buttons!";
    }
}

sub copy_printer_params($$) {
    my ($from, $to) = @_;
    map { $to->{$_} = $from->{$_} } grep { $_ ne 'configured' } keys %$from; 
    #- avoid cycles-----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}

sub getinfo($) {
    my ($prefix) = @_;
    my $printer = {};

    $::prefix = $prefix;

    # Initialize $printer data structure
    resetinfo($printer);

    return $printer;
}

#------------------------------------------------------------------------------
sub resetinfo($) {
    my ($printer) = @_;
    $printer->{QUEUE} = "";
    $printer->{OLD_QUEUE} = "";
    $printer->{OLD_CHOICE} = "";
    $printer->{ARGS} = "";
    $printer->{DBENTRY} = "";
    $printer->{DEFAULT} = "";
    $printer->{currentqueue} = {};
    # -check which printing system was used previously and load the information
    # -about its queues
    read_configured_queues($printer);
}

sub read_configured_queues($) {
    my ($printer) = @_;
    my @QUEUES;
    # Get the default spooler choice from the config file
    $printer->{SPOOLER} ||= printer::default::get_spooler();
    if (!$printer->{SPOOLER}) {
	#- Find the first spooler where there are queues
	foreach my $spooler (qw(cups pdq lprng lpd)) {
	    #- Is the spooler's daemon running?
	    my $service = $spooler;
	    if ($service eq "lprng") {
		$service = "lpd";
	    }
	    if ($service ne "pdq") {
		next unless services::is_service_running($service);
		# daemon is running, spooler found
		$printer->{SPOOLER} = $spooler;
	    }
	    #- poll queue info 
	    local *F; 
	    open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . 
		"foomatic-configure -P -q -s $spooler |" or
		    die "Could not run foomatic-configure";
	    eval join('', <F>); 
	    close F;
	    if ($service eq "pdq") {
		#- Have we found queues? PDQ has no damon, so we consider
		#- it in use when there are defined printer queues
		if ($#QUEUES != -1) {
		    $printer->{SPOOLER} = $spooler;
		    last;
		}
	    } else {
		#- For other spoolers we have already found a running
		#- daemon when we have arrived here
		last;
	    }
	}
    } else {
	#- Poll the queues of the current default spooler
	local *F; 
	open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . 
	    "foomatic-configure -P -q -s $printer->{SPOOLER} -r |" or
		die "Could not run foomatic-configure";
	eval join('', <F>); 
	close F;
    }
    $printer->{configured} = {};
    my $i;
    my $N = $#QUEUES + 1;
    for ($i = 0;  $i < $N; $i++) {
	# Set the default printer
	$printer->{DEFAULT} = $QUEUES[$i]{queuedata}{queue} if
	    $QUEUES[$i]{queuedata}{default};
	# Advance to the next entry if the current is a remotely defined
	# printer
	next if $QUEUES[$i]{queuedata}{remote};
	# Add an entry for a locally defined queue
	$printer->{configured}{$QUEUES[$i]{queuedata}{queue}} = 
	    $QUEUES[$i];
	if (!$QUEUES[$i]{make} || !$QUEUES[$i]{model}) {
	    if ($printer->{SPOOLER} eq "cups") {
		$printer->{OLD_QUEUE} = $QUEUES[$i]{queuedata}{queue};
		my $descr = get_descr_from_ppd($printer);
		if ($descr =~ m/^([^\|]*)\|([^\|]*)(\|.*|)$/) {
		    $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{make} ||= $1;
		    $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{model} ||= $2;
	        }
		# Read out which PPD file was originally used to set up this
		# queue
		local *F;
		if (open F, "< $::prefix/etc/cups/ppd/$QUEUES[$i]{queuedata}{queue}.ppd") {
		    while (my $line = <F>) {
			if ($line =~ /^\*%MDKMODELCHOICE:(.+)$/) {
			    $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{ppd} = $1;
			}
		    }
		    close F;
		}
		# Mark that we have a CUPS queue but do not know the name
		# the PPD file in /usr/share/cups/model
		if (!$printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{ppd}) {
		    $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{ppd} = '1';
		}
		$printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{driver} = 'PPD';
		$printer->{OLD_QUEUE} = "";
	    }
	    $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{make} ||= "";
	    $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{model} ||= N("Unknown model");
	} else {
	    $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{make} = $QUEUES[$i]{make};
	    $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{model} = $QUEUES[$i]{model};
	}
	# Fill in "options" field
	if (my $args = $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{args}) {
	    my @options;
	    foreach my $arg (@$args) {
		push(@options, "-o");
		my $optstr = $arg->{name} . "=" . $arg->{default};
		push(@options, $optstr);
	    }
	    @{$printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{options}} = @options;
	}
	# Construct an entry line for tree view in main window of
	# printerdrake
	make_menuentry($printer, $QUEUES[$i]{queuedata}{queue});
    }
}

sub make_menuentry {
    my ($printer, $queue) = @_;
    my $spooler = $spoolers{$printer->{SPOOLER}}{short_name};
    my $connect = $printer->{configured}{$queue}{queuedata}{connect};
    my $localremote = N("Configured on this machine");
    my $make = $printer->{configured}{$queue}{queuedata}{make};
    my $model = $printer->{configured}{$queue}{queuedata}{model};
    my $connection;
    if ($connect =~ m!^(file|parallel):/dev/lp(\d+)$!) {
	my $number = $2;
	$connection = N(" on parallel port #%s", $number);
    } elsif ($connect =~ m!^(file|usb):/dev/usb/lp(\d+)$!) {
	my $number = $2;
	$connection = N(", USB printer #%s", $number);
    } elsif ($connect =~ m!^usb://!) {
	$connection = N(", USB printer");
    } elsif ($connect =~ m!^ptal://?(.+?)$!) {
	my $ptaldevice = $1;
	if ($ptaldevice =~ /^mlc:par:(\d+)$/) {
	    my $number = $1;
	    $connection = N(", multi-function device on parallel port #%s",
			    $number);
	} elsif ($ptaldevice =~ /^mlc:par:/) {
	    $connection = N(", multi-function device on a parallel port");
	} elsif ($ptaldevice =~ /^mlc:usb:/) {
	    $connection = N(", multi-function device on USB");
	} elsif ($ptaldevice =~ /^hpjd:/) {
	    $connection = N(", multi-function device on HP JetDirect");
	} else {
	    $connection = N(", multi-function device");
	}
    } elsif ($connect =~ m!^file:(.+)$!) {
	$connection = N(", printing to %s", $1);
    } elsif ($connect =~ m!^lpd://([^/]+)/([^/]+)/?$!) {
	$connection = N(" on LPD server \"%s\", printer \"%s\"", $2, $1);
    } elsif ($connect =~ m!^socket://([^/:]+):([^/:]+)/?$!) {
	$connection = N(", TCP/IP host \"%s\", port %s", $1, $2);
    } elsif ($connect =~ m!^smb://([^/\@]+)/([^/\@]+)/?$! ||
	     $connect =~ m!^smb://.*/([^/\@]+)/([^/\@]+)/?$! ||
	     $connect =~ m!^smb://.*\@([^/\@]+)/([^/\@]+)/?$!) {
	$connection = N(" on SMB/Windows server \"%s\", share \"%s\"", $1, $2);
    } elsif ($connect =~ m!^ncp://([^/\@]+)/([^/\@]+)/?$! ||
	     $connect =~ m!^ncp://.*/([^/\@]+)/([^/\@]+)/?$! ||
	     $connect =~ m!^ncp://.*\@([^/\@]+)/([^/\@]+)/?$!) {
	$connection = N(" on Novell server \"%s\", printer \"%s\"", $1, $2);
    } elsif ($connect =~ m!^postpipe:(.+)$!) {
	$connection = N(", using command %s", $1);
    } else {
	$connection = ($printer->{expert} ? ", URI: $connect" : "");
    }
    my $sep = "!";
    $printer->{configured}{$queue}{queuedata}{menuentry} = 
	($printer->{expert} ? "$spooler$sep" : "") .
	"$localremote$sep$queue: $make $model$connection";
}

sub connectionstr {
    my ($connect) = @_;
    my $connection;
    if ($connect =~ m!^(file|parallel):/dev/lp(\d+)$!) {
	my $number = $2;
	$connection = N("Parallel port #%s", $number);
    } elsif ($connect =~ m!^(file|usb):/dev/usb/lp(\d+)$!) {
	my $number = $2;
	$connection = N("USB printer #%s", $number);
    } elsif ($connect =~ m!^usb://!) {
	$connection = N("USB printer");
    } elsif ($connect =~ m!^ptal://?(.+?)$!) {
	my $ptaldevice = $1;
	if ($ptaldevice =~ /^mlc:par:(\d+)$/) {
	    my $number = $1;
	    $connection = N("Multi-function device on parallel port #%s",
			    $number);
	} elsif ($ptaldevice =~ /^mlc:par:/) {
	    $connection = N("Multi-function device on a parallel port");
	} elsif ($ptaldevice =~ /^mlc:usb:/) {
	    $connection = N("Multi-function device on USB");
	} elsif ($ptaldevice =~ /^hpjd:/) {
	    $connection = N("Multi-function device on HP JetDirect");
	} else {
	    $connection = N("Multi-function device");
	}
    } elsif ($connect =~ m!^file:(.+)$!) {
	$connection = N("Prints into %s", $1);
    } elsif ($connect =~ m!^lpd://([^/]+)/([^/]+)/?$!) {
	$connection = N("LPD server \"%s\", printer \"%s\"", $2, $1);
    } elsif ($connect =~ m!^socket://([^/:]+):([^/:]+)/?$!) {
	$connection = N("TCP/IP host \"%s\", port %s", $1, $2);
    } elsif ($connect =~ m!^smb://([^/\@]+)/([^/\@]+)/?$! ||
	     $connect =~ m!^smb://.*/([^/\@]+)/([^/\@]+)/?$! ||
	     $connect =~ m!^smb://.*\@([^/\@]+)/([^/\@]+)/?$!) {
	$connection = N("SMB/Windows server \"%s\", share \"%s\"", $1, $2);
    } elsif ($connect =~ m!^ncp://([^/\@]+)/([^/\@]+)/?$! ||
	     $connect =~ m!^ncp://.*/([^/\@]+)/([^/\@]+)/?$! ||
	     $connect =~ m!^ncp://.*\@([^/\@]+)/([^/\@]+)/?$!) {
	$connection = N("Novell server \"%s\", printer \"%s\"", $1, $2);
    } elsif ($connect =~ m!^postpipe:(.+)$!) {
	$connection = N("Uses command %s", $1);
    } else {
	$connection = N("URI: %s", $connect);
    }
    return $connection;
}

sub read_printer_db {

    my ($printer, $spooler) = @_;

    local *DBPATH; #- don't have to do close ... and don't modify globals at least
    # Generate the Foomatic printer/driver overview, read it from the
    # appropriate file when it is already generated
    open DBPATH, ($::testing ? $::prefix : "chroot $::prefix/ ") . #-#
	"foomatic-configure -O -q |" or
	die "Could not run foomatic-configure";

    my $entry = {};
    my $inentry = 0;
    my $indrivers = 0;
    my $inautodetect = 0;
    my $autodetecttype = "";
    local $_;
    while (<DBPATH>) {
	chomp;
	if ($inentry) {
	    # We are inside a printer entry
	    if ($indrivers) {
		# We are inside the drivers block of a printers entry
		if (m!^\s*</drivers>\s*$!) {
		    # End of drivers block
		    $indrivers = 0;
		} elsif (m!^\s*<driver>(.+)</driver>\s*$!) {
		    push @{$entry->{drivers}}, $1;
		}
	    } elsif ($inautodetect) {
		# We are inside the autodetect block of a printers entry
		# All entries inside this block will be ignored
		if ($autodetecttype) {
		    if (m!^.*</$autodetecttype>\s*$!) {
			# End of general, parallel, USB, or SNMP section
			$autodetecttype = "";
		    } elsif (m!^\s*<manufacturer>\s*([^<>]+)\s*</manufacturer>\s*$!) {
			# Manufacturer
			$entry->{devidmake} = $1;
		    } elsif (m!^\s*<model>\s*([^<>]+)\s*</model>\s*$!) {
			# Model
			$entry->{devidmodel} = $1;
		    } elsif (m!^\s*<description>\s*([^<>]+)\s*</description>\s*$!) {
			# Description
			$entry->{deviddesc} = $1;
		    } elsif (m!^\s*<commandset>\s*([^<>]+)\s*</commandset>\s*$!) {
			# Command set
			$entry->{devidcmdset} = $1;
		    } elsif (m!^\s*<ieee1284>\s*([^<>]+)\s*</ieee1284>\s*$!) {
			# Full ID string
			my $idstr = $1;
			$idstr =~ m!(MFG|MANUFACTURER):([^;]+);!i
			    and $entry->{devidmake} = $2;
			$idstr =~ m!(MDL|MODEL):([^;]+);!i
			    and $entry->{devidmodel} = $2;
			$idstr =~ m!(DES|DESCRIPTION):([^;]+);!i
			    and $entry->{deviddesc} = $2;
			$idstr =~ m!(CMD|COMMAND\s*SET):([^;]+);!i
			    and $entry->{devidcmdset} = $2;
		    }
		} else {
		    if (m!^.*</autodetect>\s*$!) {
			# End of autodetect block
			$inautodetect = 0;
		    } elsif (m!^\s*<(general|parallel|usb|snmp)>\s*$!) {
			# Beginning of parallel, USB, or SNMP section
			$autodetecttype = $1;
		    }
		}
	    } else {
		if (m!^\s*</printer>\s*$!) {
		    # entry completed
		    $inentry = 0;
		    # Expert mode:
		    # Make one database entry per driver with the entry name
		    # manufacturer|model|driver
		    if ($printer->{expert}) {
			foreach my $driver (@{$entry->{drivers}}) {
			    my $driverstr;
			    if ($driver eq "Postscript") {
				$driverstr = "PostScript";
			    } else {
				$driverstr = "GhostScript + $driver";
			    }
			    if ($driver eq $entry->{defaultdriver}) {
				$driverstr .= " (recommended)";
			    }
			    $entry->{ENTRY} = "$entry->{make}|$entry->{model}|$driverstr";
			    $entry->{ENTRY} =~ s/^CITOH/C.ITOH/i;
			    $entry->{ENTRY} =~ 
				s/^KYOCERA[\s\-]*MITA/KYOCERA/i;
			    $entry->{driver} = $driver;
			    # Duplicate contents of $entry because it is multiply entered to the database
			    map { $thedb{$entry->{ENTRY}}{$_} = $entry->{$_} } keys %$entry;
			}
		    } else {
			# Recommended mode
			# Make one entry per printer, with the recommended
			# driver (manufacturerer|model)
			$entry->{ENTRY} = "$entry->{make}|$entry->{model}";
			$entry->{ENTRY} =~ s/^CITOH/C.ITOH/i;
			$entry->{ENTRY} =~ 
			    s/^KYOCERA[\s\-]*MITA/KYOCERA/i;
			if ($entry->{defaultdriver}) {
			    $entry->{driver} = $entry->{defaultdriver};
			    map { $thedb{$entry->{ENTRY}}{$_} = $entry->{$_} } keys %$entry;
			}
		    }
		    $entry = {};
		} elsif (m!^\s*<id>\s*([^\s<>]+)\s*</id>\s*$!) {
		    # Foomatic printer ID
		    $entry->{printer} = $1;
		} elsif (m!^\s*<make>(.+)</make>\s*$!) {
		    # Printer manufacturer
		    $entry->{make} = uc($1);
		} elsif (m!^\s*<model>(.+)</model>\s*$!) {
		    # Printer model
		    $entry->{model} = $1;
		} elsif (m!<driver>(.+)</driver>!) {
		    # Printer default driver
		    $entry->{defaultdriver} = $1;
		} elsif (m!^\s*<drivers>\s*$!) {
		    # Drivers block
		    $indrivers = 1;
		    @{$entry->{drivers}} = (); 
		} elsif (m!^\s*<autodetect>\s*$!) {
		    # Autodetect block
		    $inautodetect = 1;
		}
	    }
	} else {
	    if (m!^\s*<printer>\s*$!) {
		# new entry
		$inentry = 1;
	    }
	}
    }
    close DBPATH;

    # Add raw queue
    $entry->{ENTRY} = N("Raw printer (No driver)");
    $entry->{driver} = "raw";
    $entry->{make} = "";
    $entry->{model} = N("Unknown model");
    $thedb{$entry->{ENTRY}}{$_} = $entry->{$_} foreach keys %$entry;

    #- Load CUPS driver database if CUPS is used as spooler
    if ($spooler && $spooler eq "cups") {
        poll_ppd_base($printer);
    }

    #my @entries_db_short     = sort keys %printer::thedb;
    #%descr_to_db          = map { $printer::thedb{$_}{DESCR}, $_ } @entries_db_short;
    #%descr_to_help        = map { $printer::thedb{$_}{DESCR}, $printer::thedb{$_}{ABOUT} } @entries_db_short;
    #@entry_db_description = keys %descr_to_db;
    #db_to_descr          = reverse %descr_to_db;

}

sub read_foomatic_options ($) {
    my ($printer) = @_;
    # Generate the option data for the chosen printer/driver combo
    my $COMBODATA;
    local *F;
    open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . 
	"foomatic-configure -P -q -p $printer->{currentqueue}{printer}" .
	" -d $printer->{currentqueue}{driver}" . 
	($printer->{OLD_QUEUE} ?
	 " -s $printer->{SPOOLER} -n $printer->{OLD_QUEUE}" : "") .
	 ($printer->{SPECIAL_OPTIONS} ?
	  " $printer->{SPECIAL_OPTIONS}" : "") 
	 . " |" or
	 die "Could not run foomatic-configure";
    eval join('', (<F>)); 
    close F;
    # Return the arguments field
    return $COMBODATA->{args};
}

sub read_ppd_options ($) {
    my ($printer) = @_;
    # Generate the option data for a given PPD file
    my $COMBODATA;
    local *F;
    open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . 
	"foomatic-configure -P -q" .
	" --ppd /usr/share/cups/model/$printer->{currentqueue}{ppd}" .
	($printer->{OLD_QUEUE} ?
	 " -s $printer->{SPOOLER} -n $printer->{OLD_QUEUE}" : "") .
	 ($printer->{SPECIAL_OPTIONS} ?
	  " $printer->{SPECIAL_OPTIONS}" : "") 
		    . " |" or
	    die "Could not run foomatic-configure";
    eval join('', (<F>)); 
    close F;
    # Return the arguments field
    return $COMBODATA->{args};
}

my %sysconfig = getVarsFromSh("$::prefix/etc/sysconfig/printing");

sub set_cups_special_options {
    my ($queue) = $_[0];
    # Set some special CUPS options
    my @lpoptions = chomp_(cat_("$::prefix/etc/cups/lpoptions"));
    # If nothing is already configured, set text file borders of half an inch
    # and decrease the font size a little bit, so nothing of the text gets
    # cut off by unprintable borders.
    if (!any { /$queue.*\s(page-(top|bottom|left|right)|lpi|cpi)=/ } @lpoptions) {
	run_program::rooted($::prefix, "lpoptions",
			    "-p", $queue,
			    "-o", "page-top=36", "-o", "page-bottom=36",
			    "-o", "page-left=36", "-o page-right=36",
			    "-o", "cpi=12", "-o", "lpi=7", "-o", "wrap");
    }
    # Let images fill the whole page by default
    if (!any { /$queue.*\s(scaling|natural-scaling|ppi)=/ } @lpoptions) {
	run_program::rooted($::prefix, "lpoptions",
			    "-p", $queue,
			    "-o", "scaling=100");
    }
    return 1;
}

sub set_cups_autoconf {
    my ($autoconf) = @_;
    $sysconfig{CUPS_CONFIG} = $autoconf ? "automatic" : "manual";
    setVarsInSh("$::prefix/etc/sysconfig/printing", \%sysconfig);
    # Restart CUPS
    printer::services::restart("cups") if $autoconf;
    return 1;
}

sub get_cups_autoconf() { $sysconfig{CUPS_CONFIG} ne 'manual' ? 1 : 0 }

sub set_usermode {
    my ($usermode) = @_;
    $sysconfig{USER_MODE} = $usermode ? "expert" : "recommended";
    setVarsInSh("$::prefix/etc/sysconfig/printing", \%sysconfig);
    return $usermode;
}

sub get_usermode() { $sysconfig{USER_MODE} eq 'expert' ? 1 : 0 }

sub set_jap_textmode {
    my $textmode = ($_[0] ? 'cjk' : '');
    substInFile {
        s!^(\s*text/plain\s+\S+\s+\d+\s+)\S+(\s*$)!$1${textmode}texttops$2!        
    } "$::prefix/etc/cups/mime.convs";
    return 1;
}

sub get_jap_textmode() {
    my @mimeconvs = cat_("$::prefix/etc/cups/mime.convs");
    (m!^\s*text/plain\s+\S+\s+\d+\s+(\S+)\s*$!m and
     $1 eq 'cjktexttops' and return 1) foreach @mimeconvs;
    return 0;
}

#----------------------------------------------------------------------
# Handling of /etc/cups/cupsd.conf

sub read_cupsd_conf() {
    cat_("$::prefix/etc/cups/cupsd.conf");
}
sub write_cupsd_conf {
    my (@cupsd_conf) = @_;

    output("$::prefix/etc/cups/cupsd.conf", @cupsd_conf);

    #- restart cups after updating configuration.
    printer::services::restart("cups");
}

sub read_location {

    # Return the lines inside the [path] location block
    #
    #   <Location [path]>
    #   ...
    #   </Location>

    my ($cupsd_conf_ptr, $path) = @_;

    my @result;
    if (any { m!^\s*<Location\s+$path\s*>! } @$cupsd_conf_ptr) {
	my $location_start = -1;
	my $location_end = -1;
	# Go through all the lines, bail out when start and end line found
	for (my $i = 0; 
	     $i <= $#{$cupsd_conf_ptr};
	     $i++) {
	    if ($cupsd_conf_ptr->[$i] =~ m!^\s*<\s*Location\s+$path\s*>!) {
		# Start line of block
		$location_start = $i;
	    } elsif ($cupsd_conf_ptr->[$i] =~ 
		      m!^\s*<\s*/Location\s*>! &&
		     $location_start != -1) {
		# End line of block
		$location_end = $i;
		last;
	    } elsif ($location_start >= 0 && $location_end < 0) {
		# Inside the location block
		push(@result, $cupsd_conf_ptr->[$i]);
	    }
	}
    } else {
	# If there is no root location block, set the result array to
	# "undef"
	@result = undef;
    }
    return (@result);
}

sub rip_location {

    # Cut out the [path]  location block
    #
    #   <Location [path]>
    #   ...
    #   </Location>
    #
    # so that it can be treated seperately without affecting the
    # rest of the file

    my ($cupsd_conf_ptr, $path) = @_;

    my @location;
    my $location_start = -1;
    my $location_end = -1;
    if (any { m!^\s*<Location\s+$path\s*>! } @$cupsd_conf_ptr) {
	# Go through all the lines, bail out when start and end line found
	for (my $i = 0; 
	     $i <= $#{$cupsd_conf_ptr} == -1;
	     $i++) {
	    if ($cupsd_conf_ptr->[$i] =~ m!^\s*<\s*Location\s+$path\s*>!) {
		# Start line of block
		$location_start = $i;
	    } elsif ($cupsd_conf_ptr->[$i] =~ 
		      m!^\s*<\s*/Location\s*>! &&
		     $location_start != -1) {
		# End line of block
		$location_end = $i;
		last;
	    }
	}
	# Rip out the block and store it seperately
	@location = 
	    splice(@$cupsd_conf_ptr, $location_start,
		   $location_end - $location_start + 1);
    } else {
	# If there is no location block, create one
	$location_start = $#{$cupsd_conf_ptr} + 1;
	@location = ("<Location $path>\n", "</Location>\n");
    }

    return ($location_start, @location);
}

sub insert_location {

    # Re-insert a location block ripped with "rip_location"

    my ($cupsd_conf_ptr, $location_start, @location) = @_;

    splice(@$cupsd_conf_ptr, $location_start,0,@location);
}

sub add_to_location {

    # Add a directive to a given location (only if it is not already there)

    my ($cupsd_conf_ptr, $path, $directive) = @_;

    my ($location_start, @location) = rip_location($cupsd_conf_ptr, $path);
    my $success = handle_configs::insert_directive(\@location, $directive);
    insert_location($cupsd_conf_ptr, $location_start, @location);
    return $success;
}

sub remove_from_location {

    # Remove a directive from a given location

    my ($cupsd_conf_ptr, $path, $directive) = @_;

    my ($location_start, @location) = rip_location($cupsd_conf_ptr, $path);
    my $success = handle_configs::remove_directive(\@location, $directive);
    insert_location($cupsd_conf_ptr, $location_start, @location);
    return $success;
}

sub replace_in_location {

    # Replace a directive in a given location

    my ($cupsd_conf_ptr, $path, $olddirective, $newdirective) = @_;

    my ($location_start, @location) = rip_location($cupsd_conf_ptr, $path);
    my $success = handle_configs::replace_directive(\@location, 
						    $olddirective, 
						    $newdirective);
    insert_location($cupsd_conf_ptr, $location_start, @location);
    return $success;
}

sub add_allowed_host {

    # Add a host or network which should get access to the local printer(s)
    my ($cupsd_conf_ptr, $host) = @_;
    
    return (handle_configs::insert_directive($cupsd_conf_ptr, 
					     "BrowseAddress $host") and
	    add_to_location($cupsd_conf_ptr, "/", "Allow From $host"));
}

sub remove_allowed_host {

    # Remove a host or network which should get access to the local 
    # printer(s)
    my ($cupsd_conf_ptr, $host) = @_;
    
    return (handle_configs::remove_directive($cupsd_conf_ptr, "BrowseAddress $host") and
	    remove_from_location($cupsd_conf_ptr, "/",
				 "Allow From $host"));
}

sub replace_allowed_host {

    # Remove a host or network which should get access to the local 
    # printer(s)
    my ($cupsd_conf_ptr, $oldhost, $newhost) = @_;
    
    return (handle_configs::replace_directive($cupsd_conf_ptr,
					      "BrowseAddress $oldhost",
					      "BrowseAddress $newhost") and
	    replace_in_location($cupsd_conf_ptr, "/", "Allow From $newhost",
				"Allow From $newhost"));
}

sub broadcastaddress {
    
    # Determines the broadcast address (for "BrowseAddress" line) for
    # a given network IP

    my ($address) = @_;

    if ($address =~ /^\d+\.\*$/) {
	$address =~ s/\*$/255.255.255/;
    } elsif ($address =~ /^\d+\.\d+\.\*$/) {
	$address =~ s/\*$/255.255/;
    } elsif ($address =~ /^\d+\.\d+\.\d+\.\*$/) {
	$address =~ s/\*$/255/;
    } elsif ($address =~ m!^(\d+)\.(\d+)\.(\d+)\.(\d+)/(\d+)$!) {
	my $numadr = ($1 << 24) + ($2 << 16) + ($3 << 8) + $4;
	my $mask = ((1 << $5) - 1) << (32 - $5);
	my $broadcast = $numadr | (~$mask);
	$address =
	    (($broadcast & (255 << 24)) >> 24) . '.' .
	    (($broadcast & (255 << 16)) >> 16) . '.' .
	    (($broadcast & (255 << 8)) >> 8) . '.' .
	    ($broadcast & 255);
    } elsif ($address =~
	     m!^(\d+)\.(\d+)\.(\d+)\.(\d+)/(\d+)\.(\d+)\.(\d+)\.(\d+)$!) {
	my $numadr = ($1 << 24) + ($2 << 16) + ($3 << 8) + $4;
	my $mask = ($5 << 24) + ($6 << 16) + ($7 << 8) + $8;
	my $broadcast = $numadr | (~$mask);
	$address =
	    (($broadcast & (255 << 24)) >> 24) . '.' .
	    (($broadcast & (255 << 16)) >> 16) . '.' .
	    (($broadcast & (255 << 8)) >> 8) . '.' .
	    ($broadcast & 255);
    }
    
    return $address;
}

sub networkaddress {
    
    # Guesses a network address for a given broadcast address
    
    my ($address) = @_;

    if ($address =~ /\.255$/) {
	while ($address =~ s/\.255$//) {};
	$address .= ".*";
    }
 
    return $address;
}

sub localprintersshared {

    # Do we broadcast our local printers

    my ($printer) = @_;

    return ($printer->{cupsconfig}{keys}{Browsing} !~ /off/i &&
	    $printer->{cupsconfig}{keys}{BrowseInterval} != 0 &&
	    $#{$printer->{cupsconfig}{keys}{BrowseAddress}} >= 0);
}

sub remotebroadcastsaccepted {
    
    # Do we accept broadcasts from remote CUPS servers?

    my ($printer) = @_;

    # Is browsing not turned on at all?
    if ($printer->{cupsconfig}{keys}{Browsing} =~ /off/i) {
	return 0;
    }

    # No "BrowseDeny" lines at all