Sisyphus
: 1 2023 | : 18631 | : 37704617
en ru br
ALT
S:0.10-alt1
5.1: 0.9-alt1
4.1: 0.6.1-alt2.M41.3
4.0: 0.4.4-alt3
+updates:0.4.3-alt1
www.altlinux.org/Changes

:: //
: alterator-net-pppoe

                   Gear   Bugs and FR  Repocop 

alterator-net-pppoe-0.4.3/000075500000000000000000000000001072621346500154245ustar00rootroot00000000000000alterator-net-pppoe-0.4.3/Makefile000064400000000000000000000006611072621346500170670ustar00rootroot00000000000000NAME=net-pppoe
DESCRIPTION="PPPOE connections"

INSTALL=/usr/bin/install

all:
clean: clean-po
install: install-backend install-ui install-po install-html

include /usr/share/alterator/build/po.mak
include /usr/share/alterator/build/ui2.mak
include /usr/share/alterator/build/backend.mak
include /usr/share/alterator/build/fbi.mak
include /usr/share/alterator/build/html-messages.mak

HTML_PO_TEMPLATE=ui/net-pppoe/html-messages.scm
alterator-net-pppoe-0.4.3/applications/000075500000000000000000000000001072621346500201125ustar00rootroot00000000000000alterator-net-pppoe-0.4.3/applications/net-pppoe.desktop000064400000000000000000000004001072621346500234060ustar00rootroot00000000000000[Desktop Entry]
Encoding=UTF-8
Type=Application
Categories=X-Alterator-Network
Icon=net-pppoe
Terminal=false
Name=PPPoE connections
Name[ru_RU]=PPPoE-соединения
Name[uk_UA]=PPPoE-з'єднання
X-Alterator-URI=/net-pppoe
X-Alterator-Weight=20
alterator-net-pppoe-0.4.3/backend3/000075500000000000000000000000001072621346500170765ustar00rootroot00000000000000alterator-net-pppoe-0.4.3/backend3/net-pppoe000075500000000000000000000111521072621346500207330ustar00rootroot00000000000000#!/bin/sh -ef

PATH=/usr/lib/alterator-net-common:$PATH
chapfile=/etc/ppp/chap-secrets

################### shell file helpers

shell_add_or_subst()
{
local name="$1" && shift
local value="$1" && shift
local file="$1" && shift

[ -f "$file" ] || touch "$file"
if grep -qs "^$name" "$file"; then
/bin/sed -r -i "s,^$name.*,$name$value," -- "$file"
return 0
fi
printf %s\\n "$name$value" >> "$file"
}

################### interface modificators

first_available()
{
local path="/etc/net/ifaces/ppp"
local i=0
while true; do
[ -d "$path$i" ] || { echo "ppp$i" && break; }
i=$(($i + 1))
done
}

list_iface()
{
echo '('
for i in `find /etc/net/ifaces -type d -name 'ppp*'`
do
[ -f $i/options ] &&
grep -qs 'PPPTYPE=pppoe' $i/options &&
echo "(\"`basename $i`\")"
done
echo ')'
}

list_eth()
{
echo '('
iflist|
while read name mac;do
printf '("%s")' "$name"
done
echo ')'
}

read_iface()
{
local name="/etc/net/ifaces/$1"
local MPPE="#f" # mppe is off by default with pppd
grep -q '^require-mppe' "$name/pppoptions" && MPPE="#t"

echo '('

local info=
ifcheckup "$1" && info="`_ "connection established"`" || info="`_ "connection failed"`"
printf 'info "%s"' "$info"

printf 'iface "%s"' "$(grep '^HOST=' "$name/options"|sed -r 's,HOST=,,')"
printf 'login "%s"' "$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
printf 'mppe %s' "$MPPE"

echo ')'
}

write_iface()
{
[ "$1" = "/" ] && return
local name="/etc/net/ifaces/$1"
local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"
[ -d "$name" ] || mkdir "$name"
[ -n "$in_iface" ] && shell_add_or_subst "HOST=" "$in_iface" "$name/options"

if [ -n "$in_login" ] ;then
sed -r "s,^user[[:space:]].*,user $in_login," -i "$name/pppoptions"
sed -r "s,^$prev_login[[:space:]]*,$in_login ," -i "$chapfile"
prev_login="$in_login"
fi
if [ -n "$in_password" ]; then
in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g')
sed -r "s,^$prev_login[[:space:]].*,$prev_login * \"$in_password\" *," -i "$chapfile"
fi

set_mppe

ifdown "$1" && ifup "$1"
}

new_iface()
{
grep -qs "^$in_login[[:space:]]" "$chapfile" && return 1

local name="/etc/net/ifaces/$1"
in_password=$(echo "$in_password"|sed -e 's/["]/\\\\&/g')

[ -d "$name" ] || mkdir "$name"
shell_add_or_subst "ONBOOT=" "yes" "$name/options"
shell_add_or_subst "PPPTYPE=" "pppoe" "$name/options"
shell_add_or_subst "HOST=" "$in_iface" "$name/options"
shell_add_or_subst "PPPPERSIST=" "on" "$name/options"
shell_add_or_subst "PPPMAXFAIL=" "0" "$name/options"

shell_add_or_subst "user " "$in_login" "$name/pppoptions"
shell_add_or_subst "defaultroute" "" "$name/pppoptions"
shell_add_or_subst "mtu " "1476" "$name/pppoptions"

set_mppe

echo "$in_login * \"$in_password\" *" >>"$chapfile"

ifup "$1"
return 0
}


delete_iface()
{
[ "$1" = "/" ] && return
local name="/etc/net/ifaces/$1"
local prev_login="$(grep '^user' "$name/pppoptions"|sed -r 's,user[[:space:]]*,,')"

sed -r "/^$prev_login[[:space:]]/ d" -i "$chapfile"
rm -rf "$name"

ifdown "$1"
}

set_mppe()
{
if [ -n "$in_mppe" ]; then
if [ "$in_mppe" = "#t" ]; then
MPPE_ADD="require-mppe"
MPPE_DEL="nomppe"
else
MPPE_ADD="nomppe"
MPPE_DEL="require-mppe"
fi
sed "/^$MPPE_ADD/d" -i "$name/pppoptions" ||:
if grep -q "^$MPPE_DEL" "$name/pppoptions"; then
sed "s,^$MPPE_DEL,$MPPE_ADD," -i "$name/pppoptions" ||:
else
echo "$MPPE_ADD" >> "$name/pppoptions"
fi
fi
}

_()
{
LANG=${in_language%%;*}.utf8 gettext "alterator-net-pppoe" "$1"
}


. /usr/share/alterator/build/backend3.sh

on_message()
{
case "$in_action" in
##information
constraints)
local required="$([ "$in_orig_action" = "new" ] && echo "#t" || echo "#f")"
echo '('
printf 'iface (required #t label "%s")' \
"`_ "Interface"`"
printf 'login (required #t label "%s")' \
"`_ "Login"`"
printf 'name (required %s match ("^ppp[0-9]+$" "%s" ) default "%s" label "%s")' \
"$required" \
"`_ "should be ppp[number]"`" \
"$(first_available)" \
"`_ "Connection"`"
printf 'password (required %s label "%s")' \
"$required" \
"`_ "Password"`"
echo ')'
;;
##actions
list)
if [ "$in__objects" = "/" ];then
list_iface
else
list_eth
fi
;;
read)
if [ "$in__objects" = "/" ];then
echo '()'
else
read_iface "$in__objects"
fi
;;
write)
write_iface "$in__objects"
echo '()'
;;
new)
if new_iface "$in_name"; then
echo '()'
else
printf '(error "%s")' "`_ "same login name already in use"`"
fi
;;
delete)
delete_iface "$in__objects"
echo '()'
;;
*)
echo '#f'
;;
esac
}

message_loop
alterator-net-pppoe-0.4.3/backend3/template-net-pppoe000075500000000000000000000012711072621346500225450ustar00rootroot00000000000000#!/bin/sh

#turn off auto expansion
set -f

_()
{
LANG=${in_language%%;*}.utf8 gettext "alterator-net-pppoe" "$1"
}

. /usr/share/alterator/build/backend3.sh

on_message()
{
case "$in_action" in
#information for renderer
template)
if [ "$in__objects" = "/" ];then
echo '('
echo 'template "card-index" '
echo 'url "net-pppoe.html"'
echo 'help "net-pppoe.html"'
echo ')'
else
echo '#f'
fi
;;
info)
echo '('
printf ' title "%s"' "`_ "PPPoE connections"`"
printf ' description "%s"' "`_ "PPPoE connections administration"`"
printf ' group "%s"' "`_ "Network"`"
printf ' weight 88'
echo ')'
;;
*)
echo '#f'
esac
}


message_loop

alterator-net-pppoe-0.4.3/html/000075500000000000000000000000001072621346500163705ustar00rootroot00000000000000alterator-net-pppoe-0.4.3/html/fbi/000075500000000000000000000000001072621346500171305ustar00rootroot00000000000000alterator-net-pppoe-0.4.3/html/fbi/help/000075500000000000000000000000001072621346500200605ustar00rootroot00000000000000alterator-net-pppoe-0.4.3/html/fbi/help/ru_RU/000075500000000000000000000000001072621346500211145ustar00rootroot00000000000000alterator-net-pppoe-0.4.3/html/fbi/help/ru_RU/net-pppoe.html000064400000000000000000000017711072621346500237170ustar00rootroot00000000000000<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title>Help - ALT Linux Console</title>
</head>
<body>
<h2>PPPoE-соединения</h2>
<p><em>PPPoE</em> (Point-to-point protocol over Ethernet)&nbsp;&mdash; протокол
для организации прямого соединения между двумя машинами в
сети. В основном используется xDSL-сетями.
Для создания нового соединения необходимо указать
<em>Ethernet-интерфейс</em>,
через который будет производиться соединение, а
также системное имя и пароль пользователя на PPPoE-сервере.
</p>
<p>Имена для PPPoE-соединений принято назначать в формате <em>ppp[номер]</em>.</p>
</body>
</html>
alterator-net-pppoe-0.4.3/html/fbi/help/uk_UA/000075500000000000000000000000001072621346500210645ustar00rootroot00000000000000alterator-net-pppoe-0.4.3/html/fbi/help/uk_UA/net-pppoe.html000064400000000000000000000017641072621346500236710ustar00rootroot00000000000000 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title>Help - ALT Linux Console</title>
</head>
<body>
<h2>PPPoE-з'єднання</h2>
<p><em>PPPoE</em> (Point-to-point protocol over
Ethernet)&nbsp;&mdash; протокол для організації прямого
з'єднання між двома комп'ютерами в мережі. В основному
використовується xDSL-мережами. Для створення нового з'єднання
необхідно вказати <em>Ethernet-інтерфейс</em>, через який буде
виконуватися з'єднання, а також системне ім'я та пароль
користувача на PPPoE-сервері.
</p>
<p>Імена для PPPoE-з'єднань прийнято назначати у форматі <em>ppp[номер]</em>.</p>
</body>
</html>
alterator-net-pppoe-0.4.3/html/fbi/net-pppoe.html000064400000000000000000000035321072621346500217300ustar00rootroot00000000000000<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<!--pppoe connections module -->
<html>
<head>
<title>PPPoE connections - ALT Linux Console</title>
<link type="text/css" rel="stylesheet" href="/fbi/styles/card-index.css"/>
<script src="/fbi/selector.js"/>
<!-- ajax selector -->
<script src="/fbi/scripts/submit.js"/>
<script src="/fbi/scripts/card-index.js"/>
</head>
<body>
<h1><span translate="_">PPPoE connections</span></h1>
<form method="POST" class="selector-chooser" id="ajax-selector">
<label for="name">name</label>
<span class="selector">
<select name="name"/>
<input type="submit" name="card-index-select" value="Select" class="btn"/>
</span>
<span class="selector-actions">
<input type="submit" name="card-index-new" value="New connection" class="btn"/>
<input type="submit" name="card-index-delete" value="Delete connection" class="btn"/>
</span>
</form>
<hr/>
<form method="POST" class="selector-data">
<div class="selector-name">
<label for="name">name</label>
<input type="text" name="name" class="text"/>
</div>
<span class="alterator-label" name="info"/>
<br/>
<br/>
<table>
<tbody>
<tr>
<td><label for="iface">iface</label></td>
<td><select name="iface" optionlist="avail_ifaces"></select></td>
</tr>
<tr>
<td><label for="login">login</label></td>
<td><input type="text" name="login" class="text"/></td>
</tr>
<tr>
<td><label for="password">password</label></td>
<td><input type="password" name="password" class="text"/></td>
</tr>
</tbody>
</table>
<input type="submit" name="card-index-apply" value="Apply" class="btn"/>
<input type="reset" name="card-index-reset" value="Reset" class="btn"/>
</form>
</body>
</html>
alterator-net-pppoe-0.4.3/po/000075500000000000000000000000001072621346500160425ustar00rootroot00000000000000alterator-net-pppoe-0.4.3/po/alterator-net-pppoe.pot000064400000000000000000000041111072621346500224650ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-12-06 14:51+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: ui/net-pppoe/html-messages.scm:1 backend3/template-net-pppoe:30
msgid "PPPoE connections"
msgstr ""

#: ui/net-pppoe/html-messages.scm:2
msgid "Select"
msgstr ""

#: ui/net-pppoe/html-messages.scm:3
msgid "New connection"
msgstr ""

#: ui/net-pppoe/html-messages.scm:4
msgid "Delete connection"
msgstr ""

#: ui/net-pppoe/html-messages.scm:5 ui/net-pppoe/index.scm:55
msgid "Apply"
msgstr ""

#: ui/net-pppoe/html-messages.scm:6 ui/net-pppoe/index.scm:56
msgid "Reset"
msgstr ""

#: ui/net-pppoe/index.scm:11 backend3/net-pppoe:178
msgid "Connection"
msgstr ""

#: ui/net-pppoe/index.scm:17
msgid "Delete..."
msgstr ""

#: ui/net-pppoe/index.scm:18
msgid "Create new..."
msgstr ""

#: ui/net-pppoe/index.scm:34 backend3/net-pppoe:171
msgid "Interface"
msgstr ""

#: ui/net-pppoe/index.scm:39 backend3/net-pppoe:173
msgid "Login"
msgstr ""

#: ui/net-pppoe/index.scm:44 backend3/net-pppoe:181
msgid "Password"
msgstr ""

#: ui/net-pppoe/index.scm:49
msgid "MPPE Encryption"
msgstr ""

#: ui/net-pppoe/index.scm:57
msgid "Quit"
msgstr ""

#: backend3/net-pppoe:65
msgid "connection established"
msgstr ""

#: backend3/net-pppoe:65
msgid "connection failed"
msgstr ""

#: backend3/net-pppoe:157 backend3/template-net-pppoe:8
msgid "alterator-net-pppoe"
msgstr ""

#: backend3/net-pppoe:176
msgid "should be ppp[number]"
msgstr ""

#: backend3/net-pppoe:207
msgid "same login name already in use"
msgstr ""

#: backend3/template-net-pppoe:31
msgid "PPPoE connections administration"
msgstr ""

#: backend3/template-net-pppoe:32
msgid "Network"
msgstr ""
alterator-net-pppoe-0.4.3/po/ru.po000064400000000000000000000051421072621346500170320ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-12-06 14:51+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: ui/net-pppoe/html-messages.scm:1 backend3/template-net-pppoe:30
msgid "PPPoE connections"
msgstr "PPPoE-соединения"

#: ui/net-pppoe/html-messages.scm:2
msgid "Select"
msgstr "Выбрать"

#: ui/net-pppoe/html-messages.scm:3
msgid "New connection"
msgstr "Новое соединение"

#: ui/net-pppoe/html-messages.scm:4
msgid "Delete connection"
msgstr "Удалить соединение"

#: ui/net-pppoe/html-messages.scm:5 ui/net-pppoe/index.scm:55
msgid "Apply"
msgstr "Применить"

#: ui/net-pppoe/html-messages.scm:6 ui/net-pppoe/index.scm:56
msgid "Reset"
msgstr "Сброс"

#: ui/net-pppoe/index.scm:11 backend3/net-pppoe:178
msgid "Connection"
msgstr "Соединение"

#: ui/net-pppoe/index.scm:17
msgid "Delete..."
msgstr "Удалить"

#: ui/net-pppoe/index.scm:18
msgid "Create new..."
msgstr "Создать соединение..."

#: ui/net-pppoe/index.scm:34 backend3/net-pppoe:171
msgid "Interface"
msgstr "Интерфейс"

#: ui/net-pppoe/index.scm:39 backend3/net-pppoe:173
msgid "Login"
msgstr "Имя пользователя"

#: ui/net-pppoe/index.scm:44 backend3/net-pppoe:181
msgid "Password"
msgstr "Пароль"

#: ui/net-pppoe/index.scm:49
msgid "MPPE Encryption"
msgstr "Шифрование MPPE"

#: ui/net-pppoe/index.scm:57
msgid "Quit"
msgstr "Выход"

#: backend3/net-pppoe:65
msgid "connection established"
msgstr "соединение установлено"

#: backend3/net-pppoe:65
msgid "connection failed"
msgstr "нет соединения"

#: backend3/net-pppoe:157 backend3/template-net-pppoe:8
msgid "alterator-net-pppoe"
msgstr ""

#: backend3/net-pppoe:176
msgid "should be ppp[number]"
msgstr "должно быть ppp[номер]"

#: backend3/net-pppoe:207
msgid "same login name already in use"
msgstr "подобное имя пользователя уже используется"

#: backend3/template-net-pppoe:31
msgid "PPPoE connections administration"
msgstr "Управление PPPoE-соединениями"

#: backend3/template-net-pppoe:32
msgid "Network"
msgstr "Сеть"
alterator-net-pppoe-0.4.3/po/uk.po000064400000000000000000000051471072621346500170300ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-12-06 14:51+0200\n"
"PO-Revision-Date: 2007-12-06 14:53+0300\n"
"Last-Translator: Michael Shigorin <mike@altlinux.org>\n"
"Language-Team: Ukrainian <uk@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: ui/net-pppoe/html-messages.scm:1 backend3/template-net-pppoe:30
msgid "PPPoE connections"
msgstr "PPPoE-з'єднання"

#: ui/net-pppoe/html-messages.scm:2
msgid "Select"
msgstr "Вибрати"

#: ui/net-pppoe/html-messages.scm:3
msgid "New connection"
msgstr "Нове з'єднання"

#: ui/net-pppoe/html-messages.scm:4
msgid "Delete connection"
msgstr "Видалити з'єднання"

#: ui/net-pppoe/html-messages.scm:5 ui/net-pppoe/index.scm:55
msgid "Apply"
msgstr "Застосувати"

#: ui/net-pppoe/html-messages.scm:6 ui/net-pppoe/index.scm:56
msgid "Reset"
msgstr "Скинути"

#: ui/net-pppoe/index.scm:11 backend3/net-pppoe:178
msgid "Connection"
msgstr "З'єднання"

#: ui/net-pppoe/index.scm:17
msgid "Delete..."
msgstr "Видалити..."

#: ui/net-pppoe/index.scm:18
msgid "Create new..."
msgstr "Створити з'єднання..."

#: ui/net-pppoe/index.scm:34 backend3/net-pppoe:171
msgid "Interface"
msgstr "Інтерфейс"

#: ui/net-pppoe/index.scm:39 backend3/net-pppoe:173
msgid "Login"
msgstr "Ім'я користувача"

#: ui/net-pppoe/index.scm:44 backend3/net-pppoe:181
msgid "Password"
msgstr "Пароль"

#: ui/net-pppoe/index.scm:49
msgid "MPPE Encryption"
msgstr "Шифрування MPPE"

#: ui/net-pppoe/index.scm:57
msgid "Quit"
msgstr "Вихід"

#: backend3/net-pppoe:65
msgid "connection established"
msgstr "з'єднання встановлене"

#: backend3/net-pppoe:65
msgid "connection failed"
msgstr "з'єднання невдале"

#: backend3/net-pppoe:157 backend3/template-net-pppoe:8
msgid "alterator-net-pppoe"
msgstr ""

#: backend3/net-pppoe:176
msgid "should be ppp[number]"
msgstr "має бути ppp[номер]"

#: backend3/net-pppoe:207
msgid "same login name already in use"
msgstr "дане ім'я користувача вже використовується"

#: backend3/template-net-pppoe:31
msgid "PPPoE connections administration"
msgstr "Керування PPPoE-з'єднаннями"

#: backend3/template-net-pppoe:32
msgid "Network"
msgstr "Мережа"
alterator-net-pppoe-0.4.3/simple.layout000064400000000000000000000004421072621346500201540ustar00rootroot00000000000000(use-modules (alterator transport server-socket)
(alterator transport pipe-channel)
(alterator transport std-channel))

(telegraph
(pipe-in "/usr/bin/qtbrowser")
; (server-socket)
; (std-in)
(lookout)
(ensign))

(with-atlas (load-atlas "simple.smap")
(go))

alterator-net-pppoe-0.4.3/simple.smap000064400000000000000000000000501072621346500175720ustar00rootroot00000000000000(include "*.map")

(/ view /net-pppoe)

alterator-net-pppoe-0.4.3/ui/000075500000000000000000000000001072621346500160415ustar00rootroot00000000000000alterator-net-pppoe-0.4.3/ui/net-pppoe/000075500000000000000000000000001072621346500177505ustar00rootroot00000000000000alterator-net-pppoe-0.4.3/ui/net-pppoe/html-messages.scm000064400000000000000000000001521072621346500232230ustar00rootroot00000000000000(_ "PPPoE connections")
(_ "Select")
(_ "New connection")
(_ "Delete connection")
(_ "Apply")
(_ "Reset")
alterator-net-pppoe-0.4.3/ui/net-pppoe/index.scm000064400000000000000000000112651072621346500215700ustar00rootroot00000000000000(document:surround "/std/base")
(document:insert "/std/functions")

(document:envelop with-translation _ "alterator-net-pppoe")

;;;;;;;;;;;;;;;;;;;;;;

(gridbox columns "20;40;60;20"
;;
(spacer)
(label (_ "Connection"))
(hbox (document:id connections (combobox))
(document:id name (edit "" invisible widget-name "name")))
(spacer)
;;
(spacer)
(document:id del-button (button (_ "Delete...")))
(document:id new-button (button (_ "Create new...")))
(spacer)
;;
(spacer)
(separator)
(separator)
(spacer)

;;
(spacer)
(document:id info (label ""))
(spacer)
(spacer)

;;
(spacer)
(label (bold (_ "Interface")) align "right")
(document:id iface (combobox widget-name "iface"))
(spacer)
;;
(spacer)
(label (bold (_ "Login")) align "right")
(document:id login (edit "" widget-name "login"))
(spacer)
;;
(spacer)
(label (bold (_ "Password")) align "right")
(document:id password (edit "" echo stars widget-name "password"))
(spacer)
;;
(spacer)
(label (bold (_ "MPPE Encryption")) align "right")
(document:id mppe (checkbox "" widget-name "mppe"))
(spacer))

(hbox
align "center"
(document:id apply-button (button (_ "Apply")))
(document:id reset-button (button (_ "Reset")))
(document:id quit-button (button (_ "Quit"))))

;;;;;;;;;;;;;;;;;;;;;;
(define (go-new)
(cell-set! new-mode #t)
(name visibility #t)
(connections invisible)
(update-constraints "new" "/net-pppoe"))

(define (go-edit)
(cell-set! new-mode #f)
(name invisible)
(connections visibility #t)
(update-constraints "write" "/net-pppoe"))

;;;;;;;;;;;;;;;;;;;;;;
(define gates (woo-list-names "/net-pppoe/pppXX/avail_ifaces"))
(define new-mode (make-cell #f))

(define (update-connection name)
(let ((data (woo-read-first (string-append "/net-pppoe/" name))))
(info text (string-append "<small>(" (woo-get-option data 'info) ")</small>"))
(login text (woo-get-option data 'login))
(password text "")
(mppe state (woo-get-option data 'mppe))
(iface current (or (string-list-index (woo-get-option data 'iface) gates) 0))))

(define (call-update-connection)
(and (> (connections count) 0)
(connections current 0 selected)))

(define (write-connection name)
(woo-catch/message
(thunk
(let ((pwd (password text)))
(apply woo-write/constraints
(string-append "/net-pppoe/" name)
'iface (iface text)
'mppe (mppe state)
'login (login text)
(if (not-empty-string? pwd) (list 'password pwd) '()))))
))

(define (new-connection name)
(and
(woo-catch/message
(thunk
(woo-new/constraints "/net-pppoe"
'name name
'iface (iface text)
'mppe (mppe state)
'login (login text)
'password (password text))
(connections append-row name
current (connections count))
#t))
(go-edit)))

(define (delete-connection name)
(woo-delete (string-append "/net-pppoe/" name))
(connections remove (connections current)))

(define (get-number x)
(string->number (substring x 3 (string-length x))))

(define (first-available)
(cond-plistq
'name
(process-defaults (read-constraints "new" "/net-pppoe" '()) '())
""))

(define (clear-connection)
;;clear fields
((widgets name login password info)
text "")
(iface current 0)
(mppe state #f)
(name text (first-available)))

;;;;;;;;;;;;;;;;;;;;;;;
(connections (when selected
(update-connection (connections text))))

(apply-button (when clicked
(if (cell-ref new-mode)
(new-connection (name text))
(write-connection (connections text)))))

(quit-button (when clicked
(document:end)))

(reset-button (when clicked
(if (cell-ref new-mode)
(clear-connection)
(and (>= (connections current) 0)
(connections selected)))))

(new-button (when clicked
(go-new)
(clear-connection)))

(del-button (when clicked
(if (cell-ref new-mode)
(go-edit)
(delete-connection (connections text)))
(clear-connection)
(call-update-connection)))

;;;;;;;;;;;;;;;;;;;;;;;
(iface rows gates current 0)
(connections rows (woo-list-names "/net-pppoe"))
(call-update-connection)

(document:root
(when loaded
(update-constraints "write" "/net-pppoe")))
 
: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
: Michael Shigorin