[-]
[+]
|
Changed |
_service:tar_git:harbour-callflasher.spec
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -6,7 +6,7 @@
<service name="tar_git">
<param name="url">https://github.com/kimmoli/callflasher.git</param>
<param name="branch">master</param>
- <param name="revision">135b34edbba01ff8f166fcddbdfe83d11722c0a8</param>
+ <param name="revision">3a2bf9fa363c4320450e78e86f063aad9bb332c8</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-callflasher-0.0.5.tar.bz2/callflasher.pro
^
|
@@ -11,7 +11,7 @@
DEFINES += "APPVERSION=\\\"$${SPECVERSION}\\\""
-target.path = /usr/bin/
+target.path = /usr/bin
dbusService.files = config/com.kimmoli.callflasher.service
dbusService.path = /usr/share/dbus-1/services/
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-callflasher-0.0.5.tar.bz2/config/com.kimmoli.callflasher.xml
^
|
@@ -3,6 +3,7 @@
<interface name="com.kimmoli.callflasher">
<method name="enable" />
<method name="toggle" />
+ <method name="test" />
<method name="quit" />
</interface>
</node>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-callflasher-0.0.5.tar.bz2/src/callflasher.cpp
^
|
@@ -24,7 +24,60 @@
Flasher flasher;
new CallflasherAdaptor(&flasher);
- flasher.registerDBus();
+ if (!QDBusConnection::systemBus().isConnected())
+ {
+ printf("callflasher: Cannot connect to the D-Bus systemBus\n%s\n", qPrintable(QDBusConnection::systemBus().lastError().message()));
+ return EXIT_FAILURE;
+ }
+
+ QDBusInterface ssuCall("org.nemo.ssu", "/org/nemo/ssu", "org.nemo.ssu", QDBusConnection::systemBus());
+ ssuCall.setTimeout(1000);
+
+ QList<QVariant> args;
+ args.append(2);
+
+ QDBusMessage ssuCallReply = ssuCall.callWithArgumentList(QDBus::Block, "displayName", args);
+
+ if (ssuCallReply.type() == QDBusMessage::ErrorMessage)
+ {
+ printf("callflasher: Error: %s\n", qPrintable(ssuCallReply.errorMessage()));
+ return EXIT_FAILURE;
+ }
+
+ QList<QVariant> outArgs = ssuCallReply.arguments();
+ if (outArgs.count() == 0)
+ {
+ printf("callflasher: ssu reply is epmty\n");
+ return EXIT_FAILURE;
+ }
+
+ QString deviceName = outArgs.at(0).toString();
+
+ printf("callflasher: device name is %s\n", qPrintable(deviceName));
+
+ if (outArgs.at(0).toString() == "JP-1301") /* The one and only original Jolla phone */
+ {
+ flasher.setPath("/sys/kernel/debug/flash_adp1650/mode", "1", "0");
+ }
+ else if (outArgs.at(0).toString() == "onyx") /* OneplusX */
+ {
+ flasher.setPath("/sys/class/leds/led:flash_torch/brightness", "50", "0");
+ }
+ else if (outArgs.at(0).toString() == "fp2-sibon")
+ {
+ flasher.setPath("/sys/class/leds/led:flash_torch/brightness", "50", "0");
+ }
+ else
+ {
+ printf("callflasher: device not supported\n");
+ return EXIT_FAILURE;
+ }
+
+ if (!flasher.registerDBus())
+ {
+ printf("callflasher: failed to reqister to dbus\n");
+ return EXIT_FAILURE;
+ }
static QDBusConnection mceCallStateconn = QDBusConnection::systemBus();
mceCallStateconn.connect("com.nokia.mce", "/com/nokia/mce/signal", "com.nokia.mce.signal", "sig_call_state_ind",
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-callflasher-0.0.5.tar.bz2/src/flasher.cpp
^
|
@@ -33,7 +33,14 @@
}
}
-void Flasher::registerDBus()
+void Flasher::setPath(QString path, QString on, QString off)
+{
+ m_path = path;
+ m_on = on;
+ m_off = off;
+}
+
+bool Flasher::registerDBus()
{
if (!m_dbusRegistered)
{
@@ -42,18 +49,19 @@
if (!connection.registerService(SERVICE))
{
QCoreApplication::quit();
- return;
+ return false;
}
if (!connection.registerObject(PATH, this))
{
QCoreApplication::quit();
- return;
+ return false;
}
m_dbusRegistered = true;
printf("callflasher: succesfully registered to dbus sessionBus \"%s\"\n", SERVICE);
}
+ return true;
}
void Flasher::quit()
@@ -86,6 +94,18 @@
}
}
+void Flasher::test()
+{
+ if (m_blinkTimer->isActive())
+ {
+ m_blinkTimer->stop();
+ return;
+ }
+
+ if (m_enabled)
+ m_blinkTimer->start();
+}
+
void Flasher::handleCall(const QDBusMessage & msg)
{
QList<QVariant> args = msg.arguments();
@@ -128,23 +148,23 @@
return;
}
- int fd = open("/sys/kernel/debug/flash_adp1650/mode", O_WRONLY);
+ int fd = open(m_path.toLatin1().constData(), O_WRONLY);
int tmp;
Q_UNUSED(tmp);
if (!(fd < 0))
{
- tmp = write (fd, "1", 1);
+ tmp = write (fd, m_on.toLatin1().constData(), m_on.length());
close(fd);
}
QThread::msleep(10);
- fd = open("/sys/kernel/debug/flash_adp1650/mode", O_WRONLY);
+ fd = open(m_path.toLatin1().constData(), O_WRONLY);
if (!(fd < 0))
{
- tmp = write (fd, "0", 1);
+ tmp = write (fd, m_off.toLatin1().constData(), m_off.length());
close(fd);
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-callflasher-0.0.5.tar.bz2/src/flasher.h
^
|
@@ -19,12 +19,14 @@
public:
explicit Flasher(QObject *parent = 0);
virtual ~Flasher();
- void registerDBus();
+ bool registerDBus();
void showNotification(QString text);
+ void setPath(QString path, QString on, QString off);
public slots:
void enable();
void toggle();
+ void test();
void quit();
void handleCall(const QDBusMessage&);
@@ -34,6 +36,9 @@
bool m_dbusRegistered;
bool m_enabled;
bool m_incomingCall;
+ QString m_path;
+ QString m_on;
+ QString m_off;
QTimer *m_blinkTimer;
};
|