int cBoblight::sendOptions() { if (m_boblight == 0) return fail; char buf[32]; sprintf(buf, "%s %1f", "value", cfg.value * 0.1f); boblight_setoption(m_boblight, -1, buf); sprintf(buf, "%s %d", "threshold", cfg.threshold); boblight_setoption(m_boblight, -1, buf); sprintf(buf, "%s %.1f", "gamma", cfg.gamma * 0.1f); boblight_setoption(m_boblight, -1, buf); sprintf(buf, "%s %1f", "saturation", cfg.saturation * 0.1f); boblight_setoption(m_boblight, -1, buf); sprintf(buf, "%s %d", "speed", cfg.speed); boblight_setoption(m_boblight, -1, buf); sprintf(buf, "%s %d", "autospeed", cfg.autospeed); boblight_setoption(m_boblight, -1, buf); sprintf(buf, "%s %s", "interpolation", cfg.interpolation ? "true" : "false"); boblight_setoption(m_boblight, -1, buf); boblight_setpriority(m_boblight, cfg.priority); return success; }
int cBoblight::open() { //init boblight m_boblight = boblight_init(); tell(1, "Successfully loaded and initalized libboblight"); if (!boblight_connect(m_boblight, cfg.host, cfg.port, 1000000) || !boblight_setpriority(m_boblight, cfg.priority)) { tell(0, "Error connecting to boblight %s", boblight_geterror(m_boblight)); close(); return fail; } tell(0, "Connected to boblight"); sendOptions(); return success; }
bool BobClient::connect(const QString &hostname, int port) { qCDebug(dcBoblight) << "Connecting to boblightd\n"; m_boblight = boblight_init(); //try to connect, if we can't then bitch to stderr and destroy boblight if (!boblight_connect(m_boblight, hostname.toLatin1().data(), port, 5000000) || !boblight_setpriority(m_boblight, 1)) { qCWarning(dcBoblight) << "Failed to connect:" << boblight_geterror(m_boblight); boblight_destroy(m_boblight); m_connected = false; return false; } qCDebug(dcBoblight) << "Connection to boblightd opened\n"; m_hostname = hostname; m_port = port; m_connected = true; return true; }
void BobClient::setPriority(int priority) { qCDebug(dcBoblight) << "setting new priority:" << priority; qCDebug(dcBoblight) << "setting priority to" << priority << boblight_setpriority(m_boblight, priority); }