Remove not reachable OOM checking

:Release Notes:
Remove all not reachable zero pointer checkings.
Add some minor mutex inititalization checking.

:Detailed Notes:
Some GLib functions terminate application in case of
memory allocation fail, so there is no need to check if
calls succeeded.
Some mutex initialization checkings were added instead of
removed OOM errors.

:Testing Performed:
Unit-tests. MiniBAT.

:QA Notes:

:Issues Addressed:
[BHV-809] LS2: Remove not reachable OOM branches

Open-webOS-DCO-1.0-Signed-off-by: Alexandr Smoktal <alexandr.smoktal@lge.com>

Change-Id: I681577ec58c0401169f3c08c5589e7df16672cb7
Reviewed-on: https://g2g.palm.com/4637
Reviewed-by: DCO Verification
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Tested-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Reviewed-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Use pbnjson for reading role files

:Release Notes:
Security configuration files now are read using pbnjson json library
instead of cjson.

:Detailed Notes:
- Replaced cjson parsing library with pbnjson for reading role files
- Marked with static-linkage symbols that are local to security.c file
- Added SetLSErrorCallbacks function to forward error reporting from
  pbnjson to LSError container
- Added handling of WEBOS_USE_WERROR cmake option to treat warnings more
  strictly
- Adjusted dependencies to be in sync with actual code

:Testing Performed:
unit-tests on desktop build

:QA Notes:

:Issues Addressed:
[BHV-6] luna-service2: replace cjson use with pbnjson

Open-webOS-DCO-1.0-Signed-off-by: Nikolay Orliuk <nikolay.orliuk@lge.com>

Change-Id: I51d2d91340083a3e9fbfc012c1eb102b75bd0113
Reviewed-on: https://g2g.palm.com/4869
Reviewed-by: DCO Verification
Reviewed-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Tested-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Enable extra errors

:Release Notes:
Switch compiler into a more sceptic mode.

:Detailed Notes:
This change required for more careful migration.

:Testing Performed:
unit-tests on desktop build

:QA Notes:

:Issues Addressed:
[BHV-6] luna-service2: replace cjson use with pbnjson

Open-webOS-DCO-1.0-Signed-off-by: Nikolay Orliuk <nikolay.orliuk@lge.com>

Change-Id: I299de7415bc09bfdfcce2003d337c886ddbccffd
Reviewed-on: https://g2g.palm.com/4870
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
use pbnjson in debug_methods and subscription

:Release Notes:
Use pbnjson library to process debug methods and subscription

:Detailed Notes:
- replace cjson with pbnjson in debug_methods and subscription
- re-order, space strip in tests that expects exact string output of
  JSON generation.
- in unit-test /luna-service2/LSSubscriptionGetJson solidus slash
  escaping were removed because yajl refers to fact that it is optional
  and doesn't put back-slash escape before that character during JSON
  generation.

:Testing Performed:
unit-tests on desktop build

:QA Notes:

:Issues Addressed:
[BHV-6] luna-service2: replace cjson use with pbnjson

Open-webOS-DCO-1.0-Signed-off-by: Nikolay Orliuk <nikolay.orliuk@lge.com>

Change-Id: Ifbc861827e6fa0ec544ce55424481044bc7ad40e
Reviewed-on: https://g2g.palm.com/4871
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
use pbnjson in luna-helper

:Release Notes:
luna-helper now uses libpbnjson instead of cjson

:Detailed Notes:
- replace cjson code inside of luna-helper with equivalent in terms of
  libpbnjson API

:Testing Performed:
unit-tests on desktop build

:QA Notes:

:Issues Addressed:
[BHV-6] luna-service2: replace cjson use with pbnjson

Open-webOS-DCO-1.0-Signed-off-by: Nikolay Orliuk <nikolay.orliuk@lge.com>

Change-Id: I574de4ab4c91ed7ae97e79c8e5ff7500531de174
Reviewed-on: https://g2g.palm.com/4872
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
use pbnjson in luna-send

:Release Notes:
Use libpbnjson instead of cjson in luna-send

:Detailed Notes:
- replace cjson based code with libpbnjson one

:Testing Performed:
unit-tests on desktop build

:QA Notes:

:Issues Addressed:
[BHV-6] luna-service2: replace cjson use with pbnjson

Open-webOS-DCO-1.0-Signed-off-by: Nikolay Orliuk <nikolay.orliuk@lge.com>

Change-Id: If168c18212c17253bc48ef628f9aceec8b7d57af
Reviewed-on: https://g2g.palm.com/4873
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
use pbnjson in libluna-service2/message.c

:Release Notes:
Use pbnjson for message managing code

:Detailed Notes:
- replaced cjson code with pbnjson in message.c
- fixed test_message.c to avoid SIGTRAP on LSErrors

:Testing Performed:
unit-tests on desktop build

:QA Notes:

:Issues Addressed:
[BHV-6] luna-service2: replace cjson use with pbnjson

Open-webOS-DCO-1.0-Signed-off-by: Nikolay Orliuk <nikolay.orliuk@lge.com>

Change-Id: Ifdf11c79a13c872e7ba13be344f74a4274fbc32b
Reviewed-on: https://g2g.palm.com/4874
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
use pbnjson in transport

:Release Notes:
Use pbnjson in transport code

:Detailed Notes:
- replaced cjson sinppets of code inside of transport with a pbnjson
  ones

:Testing Performed:
unit-tests on desktop build

:QA Notes:

:Issues Addressed:
[BHV-6] luna-service2: replace cjson use with pbnjson

Open-webOS-DCO-1.0-Signed-off-by: Nikolay Orliuk <nikolay.orliuk@lge.com>

Change-Id: I86ac77626e940d1df8db73139e396383d457a107
Reviewed-on: https://g2g.palm.com/4875
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
use pbnjson in callmap

:Release Notes:
Now callmap uses pbnjson

:Detailed Notes:
- replace cjson code with pbnjson inside of callmap

:Testing Performed:
unit-tests on desktop build

:QA Notes:

:Issues Addressed:
[BHV-6] luna-service2: replace cjson use with pbnjson

Open-webOS-DCO-1.0-Signed-off-by: Nikolay Orliuk <nikolay.orliuk@lge.com>

Change-Id: I45559d03d1cd2772cc448b609d3709e72cb5a2e0
Reviewed-on: https://g2g.palm.com/4876
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
re-factor to prefer LOCAL_CSTR_FROM_BUF

:Release Notes:
Improve perfomance by using stack allocated strings

:Detailed Notes:
- slight re-factor to prefer stack allocated strings
  (LOCAL_CSTR_FROM_BUF) rather than heap (g_strndup)
- TODO: consider cases with (.m_str == NULL)

:Testing Performed:
unit-tests on desktop build

:QA Notes:

:Issues Addressed:
[BHV-6] luna-service2: replace cjson use with pbnjson

Open-webOS-DCO-1.0-Signed-off-by: Nikolay Orliuk <nikolay.orliuk@lge.com>

Change-Id: I980f3da0c4bd7747ba66909a1c1320d15d6c5864
Reviewed-on: https://g2g.palm.com/4877
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Implement timeout for method calls

:Release Notes:
A call may be bound, and canceled automatically if LSReply() isn't
called after given time.

:Detailed Notes:
Implement new function LSCallSetTimeout(), which arms a timer. Each
LSReply() resets the timer, and timeout cancels the call.

:Testing Performed:
Automatic test suite.

:QA Notes:

:Issues Addressed:
[BHV-7] LS2: Implement timeout for method calls

Open-webOS-DCO-1.0-Signed-off-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>

Change-Id: I2736998b3461dd642bc2bc5eb2b3b15c9e60e305
Reviewed-on: https://g2g.palm.com/4730
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Increase minor version for API

:Release Notes:
Starting with version 3.7.0 luna-service2 supports LSCallSetTimeout.

:Detailed Notes:
- bumped minor version for making dependencies on new API extension

:Testing Performed:
change is build-only

:QA Notes:

:Issues Addressed:
[BHV-7] LS2: Implement timeout for method calls

Open-webOS-DCO-1.0-Signed-off-by: Nikolay Orliuk <nikolay.orliuk@lge.com>

Change-Id: I324d3c7b055d578396a4cc8d80df534085bcbb64
Reviewed-on: https://g2g.palm.com/4926
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Tested-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Prevent loss of calls

:Release Notes:
Prevent loss of calls
Prevent usage of already released object

:Detailed Notes:
The first issue.
When server is shutting down, it can be a situation when the last message
"shutdown message" is not transmitted completely and a client receives
SIG_PIPE. As a result, already sent messages become lost and the client does
not receive reply.
The second issue. An object of _LSTransportClient was used without increasing
of a reference counter. As a result the object was released but still was
used in another thread.

:Testing Performed:
Unit tests.
Smoke on the target.

:QA Notes:

:Issues Addressed
[GF-61218] LSCallOneReply sometimes doesn't reply

Open-webOS-DCO-1.0-Signed-off-by: Alekseyev Oleksandr<alekseyev.oleksandr@lge.com>

Change-Id: I474b305423524d639134d192f7c55fd8f4b8e7af
Reviewed-on: https://g2g.palm.com/4880
Reviewed-by: DCO Verification
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Tested-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Instead of relying on existing service/role directories create them on startup

It makes the service start a lot easier when the hub daemon takes care about creating the
service/role directories on its own instead of doing this job as part of the init script
(which is very close to the daemon anyway).

Upstream-Status: pending (http://github.com/openwebos/luna-service2)

Open-webOS-DCO-1.0-Signed-off-by: Simon Busch <morphis@gravedo.de>
Add support for systemd

In order to synchronize our service launch on boot we need to add explicit support for
systemd to notify systemd when we're really set up and other depending services can be
launched. As ls-hubd is a critical component of the system it has to be really up before
anyone can use it in order not to fail.

Upstream-Status: pending (http://github.com/openwebos/luna-service2)

Open-webOS-DCO-1.0-Signed-off-by: Simon Busch <morphis@gravedo.de>
Add additional search path to pkgconfig configuration

Some components include luna-service.h instead of luna-service2/luna-service.h so
it's usefull to have both include paths supported in our pkgconfig configuration.

Upstream-Status: pending (http://github.com/openwebos/luna-service2)

Open-webOS-DCO-1.0-Signed-off-by: Simon Busch <morphis@gravedo.de>
Change path to QtWebProcess executable in pub/prv hub configuration

Upstream-Status: Inappropiate [configuration]

Signed-off-by: Simon Busch <morphis@gravedo.de>
Make it possible to retrieve the process id for the sender of a message

Upstream-Status: pending (http://github.com/openwebos/luna-service2)

Open-webOS-DCO-1.0-Signed-off-by: Simon Busch <morphis@gravedo.de>
CMakeLists.txt: Use WEBOS_LS2_SECURE conditional instead of WEBOS_TARGET_MACHINE_IMPL

* we don't want to make whole luna-service2 and all recipes depending on it MACHINE_ARCH
  just because of this

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
CMakeLists: Remove webos_machine_impl_dep call

* we're not interested in different behavior for emulator or desktop build
  calling this causes WEBOS_TARGET_MACHINE_IMPL to be set to simulator
  and webOS/LegacyDefines.cmake to define TARGET_DESKTOP

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Simon Busch <morphis@gravedo.de>