Skip to content

Commit 5f3e394

Browse files
committed
store sundtek lirc config
1 parent a716172 commit 5f3e394

File tree

5 files changed

+105
-35
lines changed

5 files changed

+105
-35
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.o
2-
*.cpp
2+
*.cpp
3+
*.so

Diff for: yavdrweb-ng/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ testdeploy: all
1212
@cp -pfr static /tmp/yavdrweb
1313
@cp -pfr ../templates /tmp/yavdrweb
1414

15-
sundtek.so: get_dvb.o set_dvb.o rescan.o remove_dvb.o get_keymaps.o
15+
sundtek.so: get_dvb.o set_dvb.o rescan.o remove_dvb.o get_keymaps.o set_lirc.o
1616
${CXX} -o $@ $^ ${LDFLAGS}
1717

1818
.SUFFIXES: .ecpp .gif .jpg .css .js .cpp .png

Diff for: yavdrweb-ng/get_keymaps.ecpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ using namespace std;
3333
}
3434

3535
Json::Value list;
36-
list[0u]["key"] = "map_none";
36+
list[0u]["key"] = "none";
3737
list[0u]["name"] = "none";
38-
list[0u]["dir"] = "";
38+
list[0u]["file"] = "";
3939

4040
DIR *dp;
4141
struct dirent *dirp;
@@ -49,8 +49,8 @@ using namespace std;
4949
while ((dirp = readdir(dp)) != NULL) {
5050
if ((strlen(dirp->d_name) > 7) &&
5151
std::string(dirp->d_name).find(PREFIX) == 0) {
52-
list[index]["key"] = "map_"+string(dirp->d_name);
53-
list[index]["dir"] = directories[i];
52+
list[index]["key"] = directories[i]+string(dirp->d_name);
53+
list[index]["file"] = directories[i];
5454
list[index]["name"] = string(dirp->d_name);
5555
index++;
5656
}

Diff for: yavdrweb-ng/set_lirc.ecpp

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<%pre>
2+
#include <stdlib.h>
3+
#include <string>
4+
#include <ctype.h>
5+
6+
7+
extern "C" {
8+
#include <yavdr/db-utils/dbset.h>
9+
#include <yavdr/db-utils/dbget.h>
10+
#include <yavdr/db-utils/dbremove.h>
11+
};
12+
13+
#include <yavdr/common.h>
14+
#include <jsoncpp/json.hpp>
15+
16+
using namespace std;
17+
</%pre><& authenticate@yavdrweb ><%args>
18+
string serials[];
19+
</%args><%cpp>
20+
21+
string success = "false";
22+
23+
24+
for (serials_type::const_iterator it = serials.begin(); it != serials.end(); ++it) {
25+
string serial = (*it);
26+
27+
string isRemote = dbget((char *)("system.hardware.sundtek.stick." + serial + ".info.capabilities.remote").c_str(), (char *)"0");
28+
29+
if ("1" == isRemote) {
30+
string enabled = qparam[serial + "|enable"];
31+
32+
if ("1" == enabled) {
33+
dbset(("system.hardware.sundtek.stick." + serial + ".config.remote.enabled=1").c_str());
34+
dbset(("system.hardware.sundtek.stick." + serial + ".config.remote.protocol=" + qparam[serial + "|protocol"]).c_str());
35+
dbset(("system.hardware.sundtek.stick." + serial + ".config.remote.map=" + qparam[serial + "|map"]).c_str());
36+
} else {
37+
dbremove(("system.hardware.sundtek.stick." + serial + ".config.remote").c_str());
38+
dbset(("system.hardware.sundtek.stick." + serial + ".config.remote.enabled=0").c_str());
39+
}
40+
}
41+
}
42+
43+
44+
string cmd = "/usr/bin/signal-event update-sundtek-remote";
45+
int ret = system( cmd.c_str() );
46+
47+
success = "true"; //TODO: use ret to find out if we were successful.
48+
49+
</%cpp>{
50+
success: <$success$>
51+
}

Diff for: yavdrweb-ng/static/javascripts/component/settings/hw_sundtek.js

+47-29
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ YaVDR.Component.Settings.HwSundtek.LIRC = Ext.extend(YaVDR.Default.Form, {
360360
}, {
361361
key : 'RC6',
362362
title : 'RC6'
363+
}, {
364+
key : 'none',
365+
title : 'none'
363366
}]
364367
});
365368

@@ -374,17 +377,17 @@ YaVDR.Component.Settings.HwSundtek.LIRC = Ext.extend(YaVDR.Default.Form, {
374377
autoLoad : true
375378
});
376379
this.mapStore.load();
377-
380+
378381
YaVDR.Component.Settings.HwSundtek.LIRC.superclass.initComponent.call(this);
379382
},
380383
renderSundtek : function(item, serial, found) {
381384
// handle missing values
382385
item.config = item.config || {};
383386
item.config.remote = item.config.remote || {
384-
enabled : 0,
385-
protocol : 'RC5',
386-
map : 'map_none'
387+
enabled : 0
387388
};
389+
item.config.remote.protocol = item.config.remote.protocol|| 'none';
390+
item.config.remote.map = item.config.remote.map || 'none';
388391

389392
var items = [];
390393
try {
@@ -399,10 +402,11 @@ YaVDR.Component.Settings.HwSundtek.LIRC = Ext.extend(YaVDR.Default.Form, {
399402
}
400403

401404
if (item.info.capabilities.remote == "1" && typeof item.info.ip == "undefined") {
402-
var combo = new Ext.form.ComboBox({
405+
406+
var combo = new Ext.form.ComboBox({
403407
itemId : serial + '|mapId',
404408
name : serial + '|mapId',
405-
//tpl : this.mapTpl,
409+
// tpl : this.mapTpl,
406410
hiddenName : serial + '|map',
407411
valueField : 'key',
408412
anchor : '100%',
@@ -414,11 +418,16 @@ YaVDR.Component.Settings.HwSundtek.LIRC = Ext.extend(YaVDR.Default.Form, {
414418
triggerAction : 'all',
415419
fieldLabel : _('Key Map'),
416420
selectOnFocus : true,
417-
value: item.config.remote.map,
418-
disabled : !found || item.config.remote.enabled == 0
421+
value : item.config.remote.map,
422+
disabled : !found || item.config.remote.enabled == 0,
423+
listeners : {
424+
afterrender : function(combobox) {
425+
var rec = combobox.store.getById(item.config.remote.map);
426+
combobox.setValue(rec.id);
427+
}
428+
}
419429
});
420-
421-
430+
422431
var selectionHidden = new Ext.form.Hidden({
423432
name : serial + '|protocol',
424433
disabled : !found
@@ -439,34 +448,33 @@ YaVDR.Component.Settings.HwSundtek.LIRC = Ext.extend(YaVDR.Default.Form, {
439448
afterrender : function(list) {
440449
var rec = list.store.getById(protocolValue);
441450
list.select(rec);
442-
443451
}
444452
}
445453
});
446-
454+
447455
items.push({
448456
xtype : 'checkbox',
449457
fieldLabel : _('remote enabled'),
450-
name : serial + '|remote',
451-
itemId : serial + '|remote',
452-
id : serial + '|remote',
458+
name : serial + '|enable',
459+
itemId : serial + '|enable',
460+
id : serial + '|enable',
453461
inputValue : 1,
454462
checked : (item.config.remote.enabled == 1),
455463
disabled : !found,
456-
combo: combo,
457-
list: list,
458-
listeners: {
459-
scope: this,
460-
check: function(cb, checked) {
461-
var parent = this.findParentByType('form');
462-
if (checked) {
463-
cb.combo.enable();
464-
cb.list.enable();
465-
} else {
466-
cb.combo.disable();
467-
cb.list.disable();
468-
}
469-
}
464+
combo : combo,
465+
list : list,
466+
listeners : {
467+
scope : this,
468+
check : function(cb, checked) {
469+
var parent = this.findParentByType('form');
470+
if (checked) {
471+
cb.combo.enable();
472+
cb.list.enable();
473+
} else {
474+
cb.combo.disable();
475+
cb.list.disable();
476+
}
477+
}
470478
}
471479
});
472480

@@ -523,5 +531,15 @@ YaVDR.Component.Settings.HwSundtek.LIRC = Ext.extend(YaVDR.Default.Form, {
523531
this.doLayout();
524532
}
525533
});
534+
},
535+
doSave : function() {
536+
this.getForm().submit({
537+
url : '/sundtek/set_lirc',
538+
scope : this,
539+
success : function(form, action) {
540+
this.doLoad();
541+
}
542+
})
526543
}
544+
,
527545
});

0 commit comments

Comments
 (0)