Skip to content

Commit

Permalink
Added helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
vijs committed May 14, 2020
1 parent 224dc67 commit 83d181d
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ include(CmakeHelperFunctions)

get_directory_property(SEVICES_DEFINES COMPILE_DEFINITIONS)

if(PLUGIN_BLUETOOTH)
add_subdirectory(Bluetooth)
endif()

if(PLUGIN_DISPLAYSETTINGS)
add_subdirectory(DisplaySettings)
endif()
Expand Down
46 changes: 45 additions & 1 deletion helpers/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,53 @@
*/

#include <string.h>
#include <sys/stat.h>
#include <sstream>
#include "utils.h"
#include "libIBus.h"

using namespace WPEFramework;
using namespace std;

bool Utils::IARM::init()
{
string memberName = "Thunder_Plugins";
LOGINFO("%s", memberName.c_str());

IARM_Result_t res;
int isRegistered = 0;
IARM_CHECK(IARM_Bus_IsConnected(memberName.c_str(), &isRegistered));

m_connected = false;
if (isRegistered > 0)
{
LOGINFO("%s has already connected with IARM", memberName.c_str());
m_connected = true;
return true;
}

IARM_CHECK( IARM_Bus_Init(memberName.c_str()));
if (res == IARM_RESULT_SUCCESS)
{
IARM_CHECK(IARM_Bus_Connect());
if (res != IARM_RESULT_SUCCESS)
{
LOGERR("IARM_Bus_Connect failure");
IARM_CHECK(IARM_Bus_Term());
return false;
}
}
else
{
LOGERR("IARM_Bus_Init failure");
return false;
}

LOGINFO("%s inited and connected with IARM", memberName.c_str());
m_connected = true;
return true;
}

bool Utils::IARM::m_connected = false;

std::string Utils::formatIARMResult(IARM_Result_t result)
{
Expand Down
9 changes: 9 additions & 0 deletions helpers/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@

namespace Utils
{
struct IARM
{
static bool init();
static bool isConnected() { return m_connected; }

private:
static bool m_connected;
};

namespace String
{
// locale-wise comparison
Expand Down

0 comments on commit 83d181d

Please sign in to comment.