Fix prematurely rejected outbound call reply

:Release Notes:
Fix LS*Reply delivery if it was issued right before the LSUnregister.

:Detailed Notes:
Two connection are maintained between peers: outbound and inbound.
LSUnregister causes shutdown notifications to be sent over both
channels. The pending reply receptors, which are associated with
outbound connections only, are then closed with the status "service
isn't running".
This change fixes the callmap cleanup upon reception of shutdown
notification via the inbound channel.

:Testing Performed:
Build succeeded. Unit tests. Smoke test in emulator and on device.

:QA Notes:

:Issues Addressed:
[GF-55356] luna-service2: Pending messages not delivered on LSUnregister

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

Change-Id: Iafcf3b62f88cd7a3b12a4e41b6f2992f74722d67
Reviewed-on: https://g2g.palm.com/4251
Reviewed-by: DCO Verification
Reviewed-by: Anatoliy Klymenko <anatoliy.klimenko@lge.com>
Tested-by: Anatoliy Klymenko <anatoliy.klimenko@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Fix EINTR handling in _LSTransportRecvFd

:Release Notes:
Fix EINTR error handling while trying to get file
descriptor after corresponding incoming message.

:Detailed Notes:
Client can get 'interrupted system call' (EINTR) error
during 'recvmsg' call. This is not a critical error, so
we can try to recieve the message again.

:Testing Performed:
Unit tests, miniBAT.

:QA Notes:

:Issues Addressed:
[GF-43064] LS2 client side does not handle EINTR correctly outside GMainLoop

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

Change-Id: I37b19cbbd6f60479b083a1ac03259ee7aa058fc4
Reviewed-on: https://g2g.palm.com/4336
Reviewed-by: DCO Verification
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Tested-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Reviewed-by: Anatoliy Klymenko <anatoliy.klimenko@lge.com>
Tested-by: Anatoliy Klymenko <anatoliy.klimenko@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Cleanup trailing whitespaces

:Release Notes:
Cleanup all trailing whitespaces from c sources and header files.

:Detailed Notes:

:Testing Performed:
Build test only

:QA Notes:

:Issues Addressed:
[ANG-225] Improve ls-monitor log readability

Open-webOS-DCO-1.0-Signed-off-by: SangWook Han <sangwook.han@lge.com>

Change-Id: I772f7ea052a35ceb293eb23cc01ec945d1b3edce
Reviewed-on: https://g2g.palm.com/4372
Reviewed-by: DCO Verification
Reviewed-by: SangWook Han <sangwook.han@lge.com>
Tested-by: SangWook Han <sangwook.han@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Fix test for LSTransportMessageGetMonitorSerial()

:Release Notes:
test_LSTransportMessageGetMonitorSerial was failed because
miscalculation of message offset. With this patch,
test_transport_message is passed.

:Detailed Notes:
MonitorSerial is set by LSTransportSend() at the end of message with
padding to put 8bytes integer (_LSTransportMonitorSerial) with 8bytes
alignment.
MonitorSerial is get by _LSTransportMessageGetMonitorSerial().
Calculation of _LSTransportMessageGetMonitorSerial() is correct. Exact
same offset and padding size with LSTransportSend(). But,
test_LSTransportMessageGetMonitorSerial() did calculate without header
size(_LSTransportHeader) which is 12(on 32bit system). As a result,
there are 4 byte difference in padding size which in turn cause test
failure.

:Testing Performed:
test_transport_message all passed

:QA Notes:

:Issues Addressed:
[ANG-481] luna-service2 test suite
          LSTransportMessageGetMonitorSerial failed

Open-webOS-DCO-1.0-Signed-off-by: SangWook Han <sangwook.han@lge.com>

Change-Id: I8437bd79f9d978cdc1ba89a9210e43f878c26cb1
Reviewed-on: https://g2g.palm.com/4436
Reviewed-by: DCO Verification
Reviewed-by: SangWook Han <sangwook.han@lge.com>
Tested-by: SangWook Han <sangwook.han@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Tested-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Add compact print mode to ls-monitor

:Release Notes:
Add compact print mode to ls-monitor for better monitoring on terminal.
With full log, it is hard to find call-reply pair and hard to monitor
flow of messages. Compact mode help these requirement by providing less
information on less terminal space.

:Detailed Notes:
Compact print mode output are enabled by commandline option '-c'
- Always pair up callee the original sender and token so that we can
  easily search call-reply pair in terminal and text editor.
- Use short service name: use only one character except last two nodes.
  com.webos.audio                -> c.webos.audio
  com.webos.app.vioce            -> c.w.app.voice
  com.webos.service.tv.broadcast -> c.w.s.tv.broadcast
- Eliminate unique name
- Fit terminal width if possible by dropping tail of payload
  Two line output on terminal with less than 100 columns
  One line output on others

:Testing Performed:
Function test on 80 column terminal
57816.795 prv c.w.surfacemanager.audio.32  >      c.webos.audio//volumeUp
              {}
57816.805 prv c.w.surfacemanager.audio.6 <        c.webos.audio
              {"changed":["volume"],"returnValue":true,"cause":"volumeUp","scen
57816.805 prv c.w.s.ime.stt.4         <           c.webos.audio
              {"changed":["volume"],"returnValue":true,"cause":"volumeUp","scen
57816.805 prv c.webos.audio.160        >         c.w.s.tv.sound/private/setVolum
eUp
              {"tvSoundOutput":"tv_speaker"}
57816.805 prv c.webos.audio.160       <          c.w.s.tv.sound
              { "returnValue": true, "tvSoundOutput": "tv_speaker" }
57816.805 prv c.w.surfacemanager.audio.32 <       c.webos.audio
              {"returnValue":true}

Function test on 100 column terminal
57623.935 prv c.w.surfacemanager.audio.29  >      c.webos.audio//volumeUp {}
57623.935 prv c.w.surfacemanager.audio.6 <        c.webos.audio {"changed":["volume"],"returnValue"
57623.935 prv c.w.s.ime.stt.4         <           c.webos.audio {"changed":["volume"],"returnValue"
57623.935 prv c.webos.audio.147        >         c.w.s.tv.sound/private/setVolumeUp {"tvSoundOutput
57623.935 prv c.w.surfacemanager.audio.29 <       c.webos.audio {"returnValue":true}

:QA Notes:

:Issues Addressed:
[ANG-225] Improve ls-monitor log readability

Open-webOS-DCO-1.0-Signed-off-by: SangWook Han <sangwook.han@lge.com>

Change-Id: Idedbcb6ce20cb4945539194ea88d6b21a72c9240
Reviewed-on: https://g2g.palm.com/4373
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
Log using new pmloglib API

:Release Notes:
Libluna and luna hub were changed to use new pmloglib logging convention.

:Detailed Notes:

:Testing Performed:
miniBAT

:QA Notes:
Unit tests, miniBAT.

:Issues Addressed:
[ANG-1203] Log using new pmloglib API

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

Change-Id: Ia33196ab243fc956bdab532705d4fde40c964b65
Reviewed-on: https://g2g.palm.com/4598
Reviewed-by: DCO Verification
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Tested-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Fix some issues detected by cppcheck

:Release Notes:
Fix too wide scope for local variables, useless initialization, useless
check for unsigned variables.

:Detailed Notes:

:Testing Performed:
Unit tests

:QA Notes:

:Issues Addressed:
[ANG-850] LS2: Investigate and fix issues detected by cppcheck

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

Change-Id: I3e4e90fb1a301cb4b4a755f366f44f13f050e17c
Reviewed-on: https://g2g.palm.com/4665
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Andrii Zora <andrii.zora@lge.com>
Reviewed-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Modify algorithmic operations with timespec

:Release Notes:
Modify algorithmic operations with timespec
Modify unit tests

:Detailed Notes:
A test "test_clock" depended on overflow result of numeric operations

:Testing Performed:
Unit tests on different platforms

:QA Notes:

:Issues Addressed:
[ANG-482] luna-service2 test suite : test_clock failed

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

Change-Id: Ifaf6b4b085a175db1e75402e7a325d874f1dd1b1
Reviewed-on: https://g2g.palm.com/4551
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>
Add -w option to luna-send

:Release Notes:
Add a command line option to luna-send to allow scripts to control the
length of time it waits for a command to complete.

:Detailed Notes:
The delay was hard-coded at 300ms. During shutdown, with multiple
invocations, this can add over 1 second to the total shutdown time.

The -w option allows a different delay value to be specified (in
milliseconds).

:Testing Performed:
Checked to ensure that luna-send still functioned correctly, then used
the time command with various values of -w to ensure that it had the
expected results.

:QA Notes:

:Issues Addressed:
[GF-60639] Speed up shutdown by limiting luna-send's timeout

Open-webOS-DCO-1.0-Signed-off-by: Keith Derrick <keith.derrick@lge.com>

Change-Id: I97d5a88563536a79deabfe16539eb24b139b4cdb
Reviewed-on: https://g2g.palm.com/4678
Reviewed-by: DCO Verification
Reviewed-by: Herb Kuta <herb.kuta@lge.com>
Tested-by: Herb Kuta <herb.kuta@lge.com>
Reviewed-by: Keith Derrick <keith.derrick@lge.com>
Tested-by: Keith Derrick <keith.derrick@lge.com>
Flush output of ls-monitor promptly

:Release Notes:
Make ls-monitor more real time by flushing its output after every
packet printed.

:Detailed Notes:

:Testing Performed:
Build and manual testing.

:QA Notes:

:Issues Addressed:
[ANG-1449] ls-monitor should flush its output

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

Change-Id: I3ba6f22f3d09376c9ecf83c6f15a60876a6d8f2d
Reviewed-on: https://g2g.palm.com/4681
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Alekseyev Oleksandr <alekseyev.oleksandr@lge.com>
luna-service2.pc.in: Fix Requires.private format

:Release Notes:
Newer pkgconfig 0.28 is more strict than 0.25 and detecting
luna-service2 fails.

:Detailed Notes:
Space as separator is required in version specifier:
"PmLogLib >= 3.0.0"

PmLogLib was added in https://g2g.palm.com/4598

pkg-config-0.25 from dylan just ignores invalid line:
pkg-config --print-requires-private luna-service2

pkg-config-0.28 from dora shows error:
pkg-config --print-requires-private luna-service2
Package PmLogLib>=3.0.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `PmLogLib>=3.0.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'PmLogLib>=3.0.0', required by 'luna-service2', not found

And --exists call fails in 0.28 while it was ok in 0.25
pkg-config-0.25 from dylan:
pkg-config --exists luna-service2; echo $?
0

pkg-config-0.28 from dora:
pkg-config --exists luna-service2; echo $?
1

After adding space it works correctly in both:
pkg-config-0.25 from dylan:
pkg-config --print-requires-private luna-service2
glib-2.0
gthread-2.0
cjson
PmLogLib >= 3.0.0

pkg-config-0.28 from dora:
pkg-config --print-requires-private luna-service2
glib-2.0
gthread-2.0
cjson
PmLogLib >= 3.0.0

:Testing Performed:
Only build tested.

:QA Notes:
No change to image.

:Issues Addressed:
[ANG-329] Ongoing metadata improvement/cleanup work

Open-webOS-DCO-1.0-Signed-off-by: Martin Jansa <martin.jansa@lge.com>
Change-Id: I9c59dd73d9a3fefe85c6f7a76c697413045aed28
Reviewed-on: https://g2g.palm.com/4709
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Martin Jansa <Martin.Jansa@lge.com>
Tested-by: Martin Jansa <Martin.Jansa@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>