[frame] add dbus handle class for frame.y

This commit is contained in:
lupeng 2019-01-25 14:41:34 +08:00
parent e2cbd676a6
commit a71239ae1c
6 changed files with 136 additions and 24 deletions

View File

@ -41,6 +41,7 @@ define Build/Prepare
$(CP) -r ./C1-windows/Frames/* $(PKG_BUILD_DIR)/
rm -rf $(PKG_BUILD_DIR)/main.cpp
$(CP) -r ./src/* $(PKG_BUILD_DIR)/
cat src/clockFrame.in >> $(PKG_BUILD_DIR)/$(1).pro
$(CP) clockFrame.sh $(PKG_BUILD_DIR)/clockFrame
endef

View File

@ -0,0 +1,5 @@
#在src下的文件添加进来会传入到Qt工程的.pro文件中。main文件已经存在.pro文件中不需要再传入
SOURCES += framelogic.cpp
HEADERS += framelogic.h

View File

@ -0,0 +1,48 @@
#include <string>
#include "framelogic.h"
void setMailBox(void)
{
extern MailBox *mailbox;
if(mailbox != nullptr)
{
delete mailbox;
mailbox = nullptr;
}
mailbox = new DbusMailBox();
}
int DbusMailBox::s_wifiConnect(QString ssid, QString passwd)
{
cJSON* pRoot = NULL;
char* msg = NULL;
int ret = FRAMER_OK;
CHECKR_QSTRING_NULL(ssid, FRAMER_ERR1);
CHECKR_QSTRING_NULL(passwd, FRAMER_ERR1);
pRoot=cJSON_CreateObject();
CHECKR_NULL(pRoot, FRAMER_ERR1);
cJSON_AddStringToObject(pRoot, "ssid", ssid.toStdString().c_str());
cJSON_AddStringToObject(pRoot, "pwd", passwd.toStdString().c_str());
msg = cJSON_Print(pRoot);
if(NULL == msg)
{
cJSON_Delete(pRoot);
return -1;
}
cJSON_Delete(pRoot);
ret = frameCmdSend(1<<MODULE_WIFI, CMD_WIFI_CONF, msg);
free(msg);
msg = NULL;
return ret;
}

View File

@ -0,0 +1,61 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/time.h>
#include <uv.h>
#include <dbus/dbus.h>
#include <errno.h>
#include <cjson/s2j.h>
#include <uvdbus/log.h>
#include <uvdbus/libuv_dbus.h>
#include <uvdbus/crypto.h>
#include <uvdbus/json_struct.h>
#include <uvdbus/config_engine.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "include/democlock.h"
#define FRAMER_OK (0)
#define FRAMER_ERR1 (-1)
#define FRAMER_ERR2 (-2)
#define CHECKR_NULL(a, ret) {do{if(a == NULL){ \
LOG_EX(LOG_Error ,"point is null!\n"); \
return ret; \
}}while(0); \
}
#define CHECKR_QSTRING_NULL(a, ret) {do{if(a.isNull() == TRUE){ \
LOG_EX(LOG_Error ,"qstring is NULL!\n"); \
return ret; \
}}while(0); \
}
#define CHECKR_QSTRING_EMPTY(a, ret) {do{if(a.isEmpty() == TRUE){ \
LOG_EX(LOG_Error ,"qstring is empty!\n"); \
return ret; \
}}while(0); \
}
extern int frameCmdSend(int mask, uint32_t cmd, const char* pContext);
extern void setMailBox(void);
class DbusMailBox : public MailBox
{
Q_OBJECT
public:
DbusMailBox(){}
~DbusMailBox(){}
Q_INVOKABLE int s_wifiConnect(QString ssid, QString passwd) override;
};

View File

@ -1,27 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/time.h>
#include <uv.h>
#include <dbus/dbus.h>
#include <errno.h>
#include <cjson/s2j.h>
#include <uvdbus/log.h>
#include <uvdbus/libuv_dbus.h>
#include <uvdbus/crypto.h>
#include <uvdbus/json_struct.h>
#include <uvdbus/config_engine.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <thread>
#include "include/democlock.h"
#include "framelogic.h"
static std::thread thdDbusLoop;
static const char* g_pDBusInterfaceName = NULL;
@ -44,6 +22,23 @@ PDBUS_MSG_PACK DBusOnMessage(uv_loop_t *pLoop, DBusConnection *pConn,PDBUS_MSG_P
}
int frameCmdSend(int mask, uint32_t cmd, const char* pContext)
{
int status = FRAMER_OK;
status = DBusBoardcastCommand(NULL,
mask,
cmd,
pContext);
if(0 != status )
{
LOG_EX(LOG_Info,"frame send module cmd err is %d\r\n",status);
}
return status;
}
int main(int argc, char *argv[])
{
int ret = 0;
@ -67,5 +62,7 @@ int main(int argc, char *argv[])
thdDbusLoop = std::thread(RunUVLoop, pLoop);
thdDbusLoop.detach();
setMailBox();
return frameShow(argc, argv);
}

View File

@ -5,7 +5,7 @@ export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/qt5/plugins
export QT_QPA_FONTDIR=/usr/lib/fonts
export QT_QPA_GENERIC_PLUGINS=tslib
#export QT_QPA_EGLFS_INTEGRATION=none
export XDG_RUNTIME_DIR=/dev/shm
#export XDG_RUNTIME_DIR=/dev/shm
#export QT_QPA_GENERIC_PLUGINS=evdevmouse:/dev/input/event1
export QT_QPA_GENERIC_PLUGINS=evdevkeyboard:/dev/input/event0
export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event4:rotate=90