Commit 4d3fe440 authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Initial commit

parents
build
android-shine.kdev4
Makefile
lib
src/Makefile
src/*_automoc.cpp*
src/moc_*.cpp
CMakeTmp
CMakeFiles
project(androidshine)
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
include_directories(${KDE4_INCLUDES})
add_subdirectory(src)
#!/bin/sh
. ~/.bashrc
KDE_BUILD_CONFIRMATION=false
cs android-connect
if kdebuild; then
killall kded4
while killall -9 kded4; do
true
done
#qdbus org.kde.kded /kded unloadModule androidshine
#qdbus org.kde.kded /kded loadModule androidshine
kded4 2>&1 | grep -v "^kded(" &
echo ""
fi
set(kded_androidshine_SRCS fakedevicelocator.cpp echodevicelink.cpp udpdevicelink.cpp bonjourdevicelocator.cpp pausemusicpackagereceiver.cpp notificationpackagereceiver.cpp networkpackage.cpp
daemon.cpp devicelink.cpp devicelocator.cpp packagereceiver.cpp
)
kde4_add_plugin(kded_androidshine
${kded_androidshine_SRCS}
)
target_link_libraries(kded_androidshine
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${QT_QTNETWORK_LIBRARY}
)
install(TARGETS kded_androidshine DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES androidshine.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded)
install(FILES androidshine.notifyrc DESTINATION ${DATA_INSTALL_DIR}/androidshine)
\ No newline at end of file
[Desktop Entry]
Type=Service
Icon=preferences-system-power-management
X-KDE-ServiceTypes=KDEDModule
X-KDE-Library=androidshine
X-KDE-DBus-ModuleName=androidshine
X-KDE-Kded-autoload=true
X-KDE-Kded-load-on-demand=false
X-KDE-Kded-phase=1
Name=Android shine
Comment=Android shiny backend
[Global]
IconName=pda
Name=Android Shine
Comment=Android Shine
[Event/callReceived]
Name=Calling
Comment=Someone is calling you
Action=Popup
[Event/missedCall]
Name=Missed
Comment=You have a missed call
Action=Popup
[Event/smsReceived]
Name=SMS
Comment=Someone sent you a SMS
Action=Popup
[Event/mmsReceived]
Name=MMS
Comment=Someone sent you a MMS
Action=Popup
[Event/batteryLow]
Name=Battery
Comment=Your battery is in low state (Discharging)
Action=Popup
[Event/batteryCaution]
Name=Battery
Comment=Your battery is in caution state (Discharging)
Action=Popup
[Event/battery040]
Name=Battery
Comment=Your battery is at 40% (Discharging)
Action=Popup
[Event/battery060]
Name=Battery
Comment=Your battery is at 60% (Discharging)
Action=Popup
[Event/battery080]
Name=Battery
Comment=Your battery is at 80% (Discharging)
Action=Popup
[Event/battery100]
Name=Battery
Comment=Your battery is at 100% (Discharging)
Action=Popup
[Event/batteryChargingLow]
Name=Battery
Comment=Your battery is in low state (Charging)
Action=Popup
[Event/batteryChargingCaution]
Name=Battery
Comment=Your battery is in caution state (Charging)
Action=Popup
[Event/batteryCharging040]
Name=Battery
Comment=Your battery is at 40% (Charging)
Action=Popup
[Event/batteryCharging060]
Name=Battery
Comment=Your battery is at 60% (Charging)
Action=Popup
[Event/batteryCharging080]
Name=Battery
Comment=Your battery is at 80% (Charging)
Action=Popup
[Event/batteryCharging100]
Name=Battery
Comment=Your battery is at 100% (Charging)
Action=Popup
[Event/pingReceived]
Name=Ping
Comment=Ping received
Action=Popup
[Event/unknownEvent]
Name=Unknown
Comment=Something unknown happened
Action=Popup
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "bonjourdevicelocator.h"
#include "udpdevicelink.h"
BonjourDeviceLocator::BonjourDeviceLocator()
{
/*
//http://api.kde.org/4.x-api/kdelibs-apidocs/dnssd/html/index.html
DNSSD::ServiceBrowser* browser = new DNSSD::ServiceBrowser("_http._tcp");
connect(browser, SIGNAL(serviceAdded(RemoteService::Ptr)),
this, SLOT(addService(RemoteService::Ptr)));
connect(browser, SIGNAL(serviceRemoved(RemoteService::Ptr)),
this, SLOT(delService(RemoteService::Ptr)));
browser->startBrowse();
In above example addService() will
*/
}
DeviceLink* BonjourDeviceLocator::link(Device* d) {
DeviceLink* dl = new UdpDeviceLink("192.168.1.48");
return dl;
}
bool BonjourDeviceLocator::pair(Device* d) {
return true;
}
QVector<Device*> BonjourDeviceLocator::discover() {
QVector<Device*> devices;
return devices;
}
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BONJOURDEVICELOCATOR_H
#define BONJOURDEVICELOCATOR_H
#include <QObject>
#include "devicelocator.h"
class BonjourDeviceLocator
: public DeviceLocator
{
Q_OBJECT
public:
BonjourDeviceLocator();
Priority getPriority() { return PRIORITY_HIGH; }
bool canLink(Device* d) { return true; }
DeviceLink* link(Device* d);
bool pair(Device* d);
QVector<Device*> discover();
};
#endif // BONJOURDEVICELOCATOR_H
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "daemon.h"
#include "networkpackage.h"
#include "notificationpackagereceiver.h"
#include "pausemusicpackagereceiver.h"
#include "bonjourdevicelocator.h"
#include "fakedevicelocator.h"
#include <QtNetwork/QUdpSocket>
#include <QFile>
#include <KDE/KIcon>
#include <iostream>
K_PLUGIN_FACTORY(AndroidShineFactory,
registerPlugin<Daemon>();)
K_EXPORT_PLUGIN(AndroidShineFactory("androidshine", "androidshine"))
Daemon::Daemon(QObject *parent, const QList<QVariant>&)
: KDEDModule(parent)
{
qDebug() << "GO GO GO!";
//TODO: Do not hardcode the load of the package receivers
packageReceivers.push_back(new NotificationPackageReceiver());
packageReceivers.push_back(new PauseMusicPackageReceiver());
//TODO: Do not hardcode the load of the device locators
deviceLocators.insert(new BonjourDeviceLocator());
deviceLocators.insert(new FakeDeviceLocator());
//TODO: Read paired devices from config
pairedDevices.push_back(new Device("MyAndroid","MyAndroid"));
//Try to link to all paired devices
foreach (Device* device, pairedDevices) {
DeviceLink* link = NULL;
foreach (DeviceLocator* locator, deviceLocators) {
if (locator->canLink(device)) {
link = locator->link(device);
if (link != NULL) break;
}
}
if (link != NULL) linkedDevices.append(link);
else qDebug() << "Could not link " + device->name();
}
foreach (DeviceLink* ld, linkedDevices) {
foreach (PackageReceiver* pr, packageReceivers) {
QObject::connect(ld,SIGNAL(receivedPackage(const NetworkPackage&)),
pr,SLOT(receivePackage(const NetworkPackage&)));
}
}
}
Daemon::~Daemon()
{
qDebug() << "SAYONARA BABY";
}
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DAEMON_H
#define DAEMON_H
#include <QObject>
#include <QRegExp>
#include <map>
#include <KDE/KDEDModule>
#include <KDE/KNotification>
#include "networkpackage.h"
#include <KDE/KPluginFactory>
#include <QFile>
#include <qtextstream.h>
#include <QSet>
#include "device.h"
#include "packagereceiver.h"
#include "devicelink.h"
#include "devicelocator.h"
class QUdpSocket;
class Daemon
: public KDEDModule
{
Q_OBJECT
public:
Daemon(QObject *parent, const QList<QVariant>&);
~Daemon();
private:
//All known devices (read from/stored to settings)
QVector<Device*> pairedDevices;
//Currently connected devices
QVector<DeviceLink*> linkedDevices;
//Different ways to find new devices and connect to them, ordered by priority
QSet<DeviceLocator*> deviceLocators;
//Everybody who wants to be notified about a new package
QVector<PackageReceiver*> packageReceivers;
};
#endif // UDP_WIRELESS_H
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEVICE_H
#define DEVICE_H
#include <QString>
class Device
{
public:
Device(QString id, QString name) {
mDeviceId = id;
mDeviceName = name;
}
QString id() { return mDeviceId; }
QString name() { return mDeviceName; }
bool paired() { return mPaired; }
void pair() { mPaired = true; }
private:
bool mPaired;
QString mDeviceId;
QString mDeviceName;
};
#endif // DEVICE_H
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "devicelink.h"
DeviceLink::DeviceLink() {
//gcc complains if we don't add something to compile on a class with virtual functions
}
\ No newline at end of file
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEVICELINK_H
#define DEVICELINK_H
#include <QObject>
#include "networkpackage.h"
class DeviceLink
: public QObject
{
Q_OBJECT
public:
DeviceLink();
virtual void sendPackage(const NetworkPackage& np) = 0;
signals:
void receivedPackage(const NetworkPackage& np);
};
#endif // DEVICELINK_H
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "devicelocator.h"
DeviceLocator::DeviceLocator() {
//gcc complains if we don't add something to compile on a class with virtual functions
}
\ No newline at end of file
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEVICELOCATOR_H
#define DEVICELOCATOR_H
#include <qvector.h>
#include <QObject>
#include "devicelink.h"
#include "device.h"
class DeviceLocator
: public QObject
{
Q_OBJECT
public:
DeviceLocator();
virtual ~DeviceLocator() { }
enum Priority {
PRIORITY_LOW = 0, //ie: 3g
PRIORITY_MEDIUM = 50, //ie: internet
PRIORITY_HIGH = 100 //ie: lan
};
virtual Priority getPriority() = 0;
virtual bool canLink(Device* d) = 0;
virtual DeviceLink* link(Device* d) = 0;
virtual bool pair(Device* d) = 0;
virtual QVector<Device*> discover() = 0;
};
#endif // DEVICELOCATOR_H
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "echodevicelink.h"
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ECHODEVICELINK_H
#define ECHODEVICELINK_H
#include "devicelink.h"
class EchoDeviceLink
: public DeviceLink
{
public:
void sendPackage(const NetworkPackage& np) {
emit receivedPackage(np);
}
};
#endif // ECHODEVICELINK_H
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "fakedevicelocator.h"
#include "echodevicelink.h"
bool FakeDeviceLocator::canLink(Device* d) {
return d->name() == "fake";
}
DeviceLink* FakeDeviceLocator::link(Device* d) {
if (d->name() == "fake") {
return new EchoDeviceLink();
} else {
return NULL;
}
}
bool FakeDeviceLocator::pair(Device* d) {
if (d->name() != "fake") {
return false;
} else {
d->pair();
return true;
}
}
QVector<Device*> FakeDeviceLocator::discover() {
QVector<Device*> devices;
devices.append(new Device("fake","Fake device"));
return devices;
}
/**
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* 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 the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/