diff options
Diffstat (limited to 'libhomescreen')
-rw-r--r-- | libhomescreen/include/libhomescreen.hpp | 22 | ||||
-rw-r--r-- | libhomescreen/libhomescreen.pro | 53 | ||||
-rw-r--r-- | libhomescreen/src/libhomescreen.cpp | 59 |
3 files changed, 134 insertions, 0 deletions
diff --git a/libhomescreen/include/libhomescreen.hpp b/libhomescreen/include/libhomescreen.hpp new file mode 100644 index 0000000..f92e190 --- /dev/null +++ b/libhomescreen/include/libhomescreen.hpp @@ -0,0 +1,22 @@ +#ifndef LIBHOMESCREEN_HPP +#define LIBHOMESCREEN_HPP + +// forward declarations +struct _LibHomeScreenHomescreen; +typedef struct _LibHomeScreenHomescreen LibHomeScreenHomescreen; + +class LibHomeScreen +{ +public: + LibHomeScreen(); + ~LibHomeScreen(); + + // these are representing the D-Bus methods: + void hardKeyPressed(int key); + void toggleFullScreen(); + +private: + LibHomeScreenHomescreen *mp_libHomeScreenHomescreen_Proxy; +}; + +#endif // LIBHOMESCREEN_HPP diff --git a/libhomescreen/libhomescreen.pro b/libhomescreen/libhomescreen.pro new file mode 100644 index 0000000..b488e90 --- /dev/null +++ b/libhomescreen/libhomescreen.pro @@ -0,0 +1,53 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2016-10-28T11:05:51 +# +#------------------------------------------------- + +QT -= core gui + +TARGET = homescreen +TEMPLATE = lib + +SOURCES += \ + src/libhomescreen.cpp + +HEADERS += \ + include/libhomescreen.hpp + +CONFIG += link_pkgconfig +PKGCONFIG += glib-2.0 gio-unix-2.0 + +XMLSOURCES = \ + ../interfaces/homescreen.xml + +gen_proxy_skeleton_h.input = XMLSOURCES +gen_proxy_skeleton_h.commands = \ + gdbus-codegen --generate-c-code ${QMAKE_FILE_IN_BASE} --c-namespace LibHomeScreen --interface-prefix org.agl. ${QMAKE_FILE_IN} +gen_proxy_skeleton_h.output = ${QMAKE_FILE_IN_BASE}.h +gen_proxy_skeleton_h.variable_out = HEADERS +gen_proxy_skeleton_h.clean = ${QMAKE_FILE_IN_BASE}.h + +gen_proxy_skeleton_c.input = XMLSOURCES +gen_proxy_skeleton_c.commands = \ + gdbus-codegen --generate-c-code ${QMAKE_FILE_IN_BASE} --c-namespace LibHomeScreen --interface-prefix org.agl. ${QMAKE_FILE_IN} +gen_proxy_skeleton_c.output = ${QMAKE_FILE_IN_BASE}.c +gen_proxy_skeleton_c.variable_out = SOURCES +gen_proxy_skeleton_c.clean = ${QMAKE_FILE_IN_BASE}.c + + +QMAKE_EXTRA_COMPILERS += gen_proxy_skeleton_h gen_proxy_skeleton_c + +# remove generated files +QMAKE_CLEAN += -r \ + $$OUT_PWD/* + + +# ../interfaces/appframework.xml \ +# ../interfaces/daynightmode.xml \ +# ../interfaces/homescreen.xml \ +# ../interfaces/inputevent.xml \ +# ../interfaces/popup.xml \ +# ../interfaces/proximity.xml \ +# ../interfaces/statusbar.xml \ +# ../interfaces/windowmanager.xml diff --git a/libhomescreen/src/libhomescreen.cpp b/libhomescreen/src/libhomescreen.cpp new file mode 100644 index 0000000..978a42c --- /dev/null +++ b/libhomescreen/src/libhomescreen.cpp @@ -0,0 +1,59 @@ +#include "homescreen.h" // generated from xml +#include "include/libhomescreen.hpp" + +#include <stdio.h> +#include <stdlib.h> + +LibHomeScreen::LibHomeScreen() +{ + GError *err = NULL; + + mp_libHomeScreenHomescreen_Proxy = lib_home_screen_homescreen_proxy_new_for_bus_sync( + G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + "org.agl.homescreen", + "/HomeScreen", + NULL, + &err); + + if (NULL != err) + { + fprintf(stderr, "Unable to create proxy: %s\n", err->message); + } +} + +LibHomeScreen::~LibHomeScreen() +{ + g_object_unref(mp_libHomeScreenHomescreen_Proxy); +} + +void LibHomeScreen::hardKeyPressed(int key) +{ + GError *err = NULL; + + lib_home_screen_homescreen_call_hard_key_pressed_sync( + mp_libHomeScreenHomescreen_Proxy, + key, + NULL, + &err); + + if (NULL != err) + { + fprintf(stderr, "Unable to call hardKeyPressed: %s\n", err->message); + } +} + +void LibHomeScreen::toggleFullScreen() +{ + GError *err = NULL; + + lib_home_screen_homescreen_call_toggle_full_screen_sync( + mp_libHomeScreenHomescreen_Proxy, + NULL, + &err); + + if (NULL != err) + { + fprintf(stderr, "Unable to call toggleFullScreen: %s\n", err->message); + } +} |