Skip to content

Commit

Permalink
7412: add an option to restore the support for volume counter
Browse files Browse the repository at this point in the history
removed by AVM for some (probably marketing) reasons

WORK-IN-PROGRESS: so far compile-tested only

inspired by and based on [1]/[2]

[1] https://www.ip-phone-forum.de/threads/fritzbox-7412-datenvolumen-anzeigen.296708/
[2] https://www.ip-phone-forum.de/threads/modfs-squashfs-image-avm-firmware-%C3%A4ndern-f%C3%BCr-nand-basierte-fritz-boxen.273304/page-53#post-2208385


git-svn-id: http://svn.freetz.org/trunk@14817 f5190166-0702-4917-9039-51ec32eddaf5
  • Loading branch information
er13 committed Aug 14, 2018
1 parent 7ee670c commit 8878d14
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config/ui/patches.in
Expand Up @@ -1163,6 +1163,14 @@ config FREETZ_PATCH_ALARMCLOCK
help
Adds a third alarm-clock to AVM-Webinterface

config FREETZ_PATCH_VOL_COUNTER
bool "Restore volume counter support"
depends on FREETZ_TYPE_7412 && FREETZ_AVM_VERSION_06_8X
default n
help
Adds volume counter support removed by AVM
for some (probably marketing) reasons.

config FREETZ_PATCH_SIGNED
bool "Patch web menu signed message"
default n
Expand Down
@@ -0,0 +1,23 @@
141:156 Geben Sie hier das enthaltene Datenvolumen oder die Freistunden Ihres Tarifs an.
141:178 Volumentarif
141:657 MB Datenvolumen pro Monat inklusive
141:931 Beispiel: 5000 MB (entsprechen 5 Gigabyte)
141:246 Runden des Übertragungsvolumens pro Verbindung auf
141:145 volle kB
141:359 volle MB
141:676 Zeittarif
141:869 Stunden pro Monat inklusive
141:407 Beispiel: 50 Stunden
815:780 Online-Zeit
815:401 Datenvolumen (MB)
815:377 Verbindungen
815:351 (hh:mm)
815:151 gesamt
815:605 gesendet
815:915 empfangen
815:466 Datenvolumen gesamt(MB)
815:493 Datenvolumen gesendet(MB)
815:744 Datenvolumen empfangen(MB)
815:993 Die FRITZ!Box erfasst die Online-Zeit und das verbrauchte Datenvolumen. In der Zählung wird jedoch nur das Datenvolumen der Internetverbindung berücksichtigt. Wenn Sie weitere Verbindungen nutzen, beispielsweise für Internettelefonie oder IPTV, wird deren Datenvolumen im Online-Zähler nicht mitgezählt. Beachten Sie, dass der Online-Zähler von der exakten Abrechnung Ihres Internetanbieters abweichen kann.
815:122 Nach dem Wechsel des Internetanbieters oder der Verbindungsart (z.B. von DSL zu Mobilfunk) sollten Sie den Online-Zähler zurücksetzen, um später das Datenvolumen und die Online-Zeit eindeutig zuordnen zu können.
815:491 Wenn Sie einen Zeit- oder Volumentarif haben, können Sie sich hier den Verbrauch im aktuellen Abrechnungszeitraum anzeigen lassen.
117 changes: 117 additions & 0 deletions patches/cond/241-vol-counter/7412-06_8X-vol-counter.patch
@@ -0,0 +1,117 @@
Created by diff'ing the files from 7412.06.83 and 7490.06.83

--- usr/www/avm/internet/inetstat_budget.lua
+++ usr/www/avm/internet/inetstat_budget.lua
@@ -280,17 +280,44 @@
</h4>
<div>
<p>
-{?141:619?}
+{?141:156?}
</p>
<input type="checkbox" name="budget_enabled" id="uiBudgetEnabled"
onclick="OnToggleBudget(this.checked)" <?lua write_budget_enabled()?>><label for="uiBudgetEnabled">
{?141:990?}
</label>
<div id="uiBudgetBlock" class="formular reverse">
+<input type="radio" name="budget_type" id="uiVolBudget" value="vol"
+onclick="OnToggleBudgetType('vol')" <?lua write_budget_checked('vol')?>><label for="uiVolBudget">
+{?141:178?}
+</label>
+<div id="uiVolBlock" class="formular">
+<input type="text" size="7" maxlength="6" id="uiVolValue" name="budget_vol" value="<?lua write_budget_value('vol')?>"><label for="uiVolValue">
+{?141:657?}
+</label>
+<p>{?141:931?}</p>
+<input type="checkbox" id="uiViewRoundUpOn" name="budget_roundup" onclick="OnToggleRoundUp(this.checked)" <?lua write_roundup()?>><label for="uiViewRoundUpOn">
+{?141:246?}
+</label>
+<select id="uiViewRoundUpBytes" name="budget_roundup_bytes">
+<option value="1000" <?lua write_roundup_sel("1000")?>>
+{?141:145?}
+</option>
+<option value="1000000" <?lua write_roundup_sel("1000000")?>>
+{?141:359?}
+</option>
+</select>
+</div>
+<input type="radio" name="budget_type" id="uiTimeBudget" value="time"
+onclick="OnToggleBudgetType('time')" <?lua write_budget_checked('time')?>><label for="uiTimeBudget">
+{?141:676?}
+</label>
+<div id="uiTimeBlock" class="formular">
<input type="text" size="6" maxlength="3" name="budget_time" id="uiTimeValue"
value="<?lua write_budget_value('time')?>">
-<label for="uiTimeValue">{?141:904?}</label>
-<p>{?141:179?}</p>
+<label for="uiTimeValue">{?141:869?}</label>
+<p>{?141:407?}</p>
+</div>
<div class="noBreakGroup">
<label for="uiViewStartOfMonth" style="width:auto">
{?141:313?}
--- usr/www/avm/internet/inetstat_counter.lua
+++ usr/www/avm/internet/inetstat_counter.lua
@@ -20,9 +20,18 @@
function get_data_table_header()
local str = [[
<tr class="first_row">
-<th class="first_col">&nbsp;</th>
-<th>{?815:715?}</th>
-<th>{?815:765?}</th>
+<th class="first_col"></th>
+<th>{?815:780?}</th>
+<th style="text-align:center;" colspan="3">{?815:401?}</th>
+<th>{?815:377?}</th>
+</tr>
+<tr class="first_row">
+<th class="first_col"></th>
+<th>{?815:351?}</th>
+<th>{?815:151?}</th>
+<th>{?815:605?}</th>
+<th>{?815:915?}</th>
+<th></th>
</tr>
]]
return str
@@ -50,6 +59,13 @@
local outgoingcalls = box.query("inetstat:status/"..request.."/OutgoingCalls")
local time = box.query("inetstat:status/"..request.."/PhyConnTimeOutgoing")
str = [[<td datalabel="{?815:922?}" class="time">]] .. general.convert_to_str(time) .. [[</td>]]
+local inh, inl, outh, outl = query_send_receive(request)
+str = str .. core.sprintf([[
+<td datalabel="{?815:466?}" class="vol">%1</td><td datalabel="{?815:493?}" class="vol">%2</td><td datalabel="{?815:744?}" class="vol">%3</td>]],
+box.tohtml(get_vol_str(inh, inl, outh, outl)),
+box.tohtml(get_vol_str(outh, outl)),
+box.tohtml(get_vol_str(inh, inl))
+)
str = str .. [[<td datalabel="{?815:560?}" class="conn">]] .. outgoingcalls .. [[</td>]]
return str
end
@@ -403,7 +419,7 @@
<form method="POST" action="<?lua box.html(box.glob.script) ?>" name="main_form">
<div class="formular small_indent">
<p>
-{?815:459?}
+{?815:993?}
</p>
<div id="uiNoTime" <?lua hideif(g_timeknown) ?>>
<p>
@@ -417,7 +433,7 @@
</div>
<div>
<p>
-{?815:95?}
+{?815:122?}
</p>
<div class="btn_form">
<button type="button" onclick="onResetCounter();" name="reset">
@@ -452,7 +468,7 @@
</div>
<div <?lua hideif(g_budget_enabled) ?>>
<p>
-{?815:65?}
+{?815:491?}
</p>
<div class="btn_form">
<button type="submit" name="editbudget">
39 changes: 39 additions & 0 deletions patches/scripts/241-restore_vol_counter.sh
@@ -0,0 +1,39 @@
[ "$FREETZ_PATCH_VOL_COUNTER" == "y" ] || return 0

echo1 "adding volume counter support to the web-ui"

vol_counter_sed=$(mktemp -q -t "${FREETZ_TYPE_PREFIX}-${FREETZ_TYPE_PREFIX_SERIES_SUBDIR}-vol-counter-XXXXXX.sed")
vol_counter_patch=$(mktemp -q -t "${FREETZ_TYPE_PREFIX}-${FREETZ_TYPE_PREFIX_SERIES_SUBDIR}-vol-counter-XXXXXX.patch")

# generate sed-script for text messages missing in the htmltext_de.db of the target box, for that
# 1. replace German umlauts and ß with their html counterparts
# 2. escape regexp backreference symbol (&) and the separator symbol (#) we use in our sed script
# 3. convert vol-counter-htmltext_de.db.txt to sed script
cat "${PATCHES_COND_DIR}/241-vol-counter/${FREETZ_TYPE_PREFIX}-${FREETZ_TYPE_PREFIX_SERIES_SUBDIR}-vol-counter-htmltext_de.db.txt" \
| sed -e '
s#'$'\xc3\x84''#\&Auml;#g
s#'$'\xc3\xa4''#\&auml;#g
s#'$'\xc3\x96''#\&Ouml;#g
s#'$'\xc3\xb6''#\&ouml;#g
s#'$'\xc3\x9c''#\&Uuml;#g
s#'$'\xc3\xbc''#\&uuml;#g
s#'$'\xc3\x9f''#\&szlig;#g
' \
| sed -r -e 's,([&#]),\\\1,g' \
| sed -r -e 's,^([0-9]+:[0-9]+)\t(.*)$,s#[{][?]\1[?][}]#\2#g,' \
> "${vol_counter_sed}"

# replace htmltext_de.db references {?XXX:XXX?} in the patch with their text values
cat "${PATCHES_COND_DIR}/241-vol-counter/${FREETZ_TYPE_PREFIX}-${FREETZ_TYPE_PREFIX_SERIES_SUBDIR}-vol-counter.patch" \
| sed -f "${vol_counter_sed}" \
> "${vol_counter_patch}"

# apply generated patch
modpatch "$FILESYSTEM_MOD_DIR" "${vol_counter_patch}"

# remove temporary files
rm -f "${vol_counter_sed}" "${vol_counter_patch}"

# set CONFIG_VOL_COUNTER to "y"
echo1 "enabling volume counter support in /etc/init.d/rc.conf"
modsed 's,CONFIG_VOL_COUNTER=.*$,CONFIG_VOL_COUNTER="y",' "${FILESYSTEM_MOD_DIR}/etc/init.d/rc.conf" 'CONFIG_VOL_COUNTER="y"$'

0 comments on commit 8878d14

Please sign in to comment.