/*
* config - zavai configuration
*
- * Copyright (C) 2009 Enrico Zini <enrico@enricozini.org>
+ * Copyright (C) 2009--2010 Enrico Zini <enrico@enricozini.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
set { _min_button_height = set_int("min_button_height", value); }
}
+ private string _gpsd_host;
+ public string gpsd_host
+ {
+ get { return _gpsd_host; }
+ set { _gpsd_host = set_string("gpsd_host", value); }
+ }
+
+ private string _gpsd_port;
+ public string gpsd_port
+ {
+ get { return _gpsd_port; }
+ set { _gpsd_port = set_string("gpsd_port", value); }
+ }
+
private string _gprs_apn;
public string gprs_apn
{
set { _gprs_pass = set_string("gprs_pass", value); }
}
+ private string _sim_pin;
+ public string sim_pin
+ {
+ get { return _sim_pin; }
+ set { _sim_pin = set_string("sim_pin", value); }
+ }
+
private int _power_button_keycode;
public int power_button_keycode
{
set { _aux_button_keycode = set_int("aux_button_keycode", value); }
}
+ private string _ringtone_alarm;
+ public string ringtone_alarm
+ {
+ get { return _ringtone_alarm; }
+ set { _ringtone_alarm = set_string("ringtone_alarm", value); }
+ }
+
+ private string _ringtone_call;
+ public string ringtone_call
+ {
+ get { return _ringtone_call; }
+ set { _ringtone_call = set_string("ringtone_call", value); }
+ }
+
+ private string _ringtone_sms;
+ public string ringtone_sms
+ {
+ get { return _ringtone_sms; }
+ set { _ringtone_sms = set_string("ringtone_sms", value); }
+ }
+
public int backlight_max
{
get;
_homedir = get_string("homedir");
_icondir = get_string("icondir");
_min_button_height = get_int("min_button_height");
+ _gpsd_host = get_string("gpsd_host");
+ _gpsd_port = get_string("gpsd_port");
_gprs_apn = get_string("gprs_apn");
_gprs_user = get_string("gprs_user");
_gprs_pass = get_string("gprs_pass");
+ _sim_pin = get_string("sim_pin");
_power_button_keycode = get_int("power_button_keycode");
_aux_button_keycode = get_int("aux_button_keycode");
+ _ringtone_alarm = get_string("ringtone_alarm");
+ _ringtone_call = get_string("ringtone_call");
+ _ringtone_sms = get_string("ringtone_sms");
}
public Config()
if (icondir == null)
icondir = "/usr/share/zavai/icons";
min_button_height = 80;
+ gpsd_host = "localhost";
+ gpsd_port = "gpsd";
gprs_apn = "general.t-mobile.uk";
gprs_user = "x";
gprs_pass = "x";
+ sim_pin = "1234";
backlight_max = 15;
power_button_keycode = 124;
aux_button_keycode = 177;
+ ringtone_alarm = "file:///usr/share/sounds/yue-fso/lec1.ogg";
+ ringtone_call = "file:///usr/share/sounds/yue-fso/jmf1.ogg";
+ ringtone_sms = "file:///usr/share/sounds/yue-fso/nothing4.ogg";
// Read config
if (lua.do_file(homedir + "/config"))
}
refresh_from_lua();
}
+
+ /**
+ * Find a zavai script.
+ *
+ * ~/.zavai/NAME is searched first, then /usr/share/zavai/hooks/
+ *
+ * If the script is not found, NULL is returned
+ */
+ public string? find_script(string name)
+ {
+ string candidate = homedir + "/" + name;
+ if (FileUtils.test(candidate, FileTest.EXISTS))
+ return candidate;
+ candidate = "/usr/share/zavai/hooks/" + name;
+ if (FileUtils.test(candidate, FileTest.EXISTS))
+ return candidate;
+ return null;
+ }
+
+ public void find_and_run_script(string script, string args) throws SpawnError
+ {
+ string cmd = find_script(script);
+ if (cmd == null)
+ throw new SpawnError.NOENT("hook '" + cmd + "' not found");
+ run_script(cmd + " " + args);
+ }
+
+ public void run_script(string command) throws SpawnError
+ {
+ zavai.log.info("Run program: " + command);
+ string[] args = command.split(" ");
+ Pid pid;
+ Process.spawn_async(
+ Environment.get_home_dir(),
+ args,
+ null,
+ SpawnFlags.SEARCH_PATH,
+ null,
+ out pid);
+ }
+
+ public int run_script_sync(string command, out string std_out, out string std_err) throws SpawnError
+ {
+ int status = -1;
+ zavai.log.info("Run program: " + command);
+ string[] args = command.split(" ");
+ bool res = Process.spawn_sync(Environment.get_home_dir(), args, null, SpawnFlags.SEARCH_PATH, null, out std_out, out std_err, out status);
+ return status;
+ }
}
public Config config = null;