Prevent loss of calls. Additional changes

:Release Notes:

:Detailed Notes:

:Testing Performed:
Internal unit-tests. MiniBAT

:QA Notes:

:Issues Addressed:
[BHV-2475] LSCallOneReply sometimes doesn't reply.

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

Change-Id: I06d807dd84d6397d552d669f567af6f75f64fa1a
Reviewed-on: https://g2g.palm.com/5027
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>
Implement C++ wrapper for LSError

:Release Notes:
Create directory structure for C++ wrapper.

:Detailed Notes:
Implement LS::Error.
Implement unit tests for LS::Error.

:Testing Performed:
Build + unit tests

:QA Notes:

:Issues Addressed:
[BHV-1535] Investigate existing wrappers

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

Change-Id: I9172a9a3400be1fc3ac7e00c9dfe44b8709a67f6
Reviewed-on: https://g2g.palm.com/5030
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>
Allow sending on behalf of other services

:Release Notes:
Fix luna-send to be able to mock other services with -m.

:Detailed Notes:
LS2 security prohibited luna-send to LSRegister() with arbitrary name.

:QA Notes:

:Testing Performed:
Tested on TV with NFS
killall eim && luna-send -m com.webos.service.eim -n 1 -f \
luna://com.webos.surfacemanager.inputpopup/createInputPopup \
'{"appId":"com.webos.app.tvuserguide", \
"portType": "HDMI", \
"portName": "HDMI-1", \
"portIcon": "/usr/palm/applications/com.webos.app.hdmi1/assets/icon_HDMI_1_130.png", \
"timeout": 10}'
>>
{
    "subscribed": false,
    "errorCode": 0,
    "inputPopupId": "com.webos.app.tvuserguide-1:51:31.302",
    "returnValue": true
}

:Issues Addressed:
[BHV-2211] luna-service2: add luna-send exception for service name registration

Open-webOS-DCO-1.0-Signed-off-by: Olexandr Solomakha <oleksander.solomakha@lge.com>

Change-Id: I9128700e28689938bbaafd8d44664def73bc1259
Reviewed-on: https://g2g.palm.com/5013
Reviewed-by: DCO Verification
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Tested-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Olexandr Solomakha <oleksander.solomakha@lge.com>
Tested-by: Olexandr Solomakha <oleksander.solomakha@lge.com>
add schema for meta-data JSONs

:Release Notes:
Introduced service meta-data description json schema.

:Detailed Notes:
schemas for:
- category
- map of category name to category format
- generic reply (to be referenced by library clients)

:Testing Performed:
jsonlint

:QA Notes:

:Issues Addressed:
[BHV-1587] Design category description format
[BHV-1588] Create JSON schema for category description

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

Change-Id: I4f2dfbd7428315dd035d26eadbefa6dcc89a6b6a
Reviewed-on: https://g2g.palm.com/5003
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>
Fix unreliable test_timersource

:Release Notes:

:Detailed Notes:
The test fails on Arch supposedly due to unreliability of
g_test_trap_fork(). This fix tests the timer source in a single
process.

:Testing Performed:
make test

:QA Notes:

:Issues Addressed:
[BHV-1535] Investigate existing wrappers

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

Change-Id: Id07582f13826156cc6a702c6c3d5aec614c4e04c
Reviewed-on: https://g2g.palm.com/5090
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>
Implement hub runner for integration tests

:Release Notes:
Implement test runner to launch the hub for integration tests.

:Detailed Notes:

:Testing Performed:
make check && make test

:QA Notes:

:Issues Addressed:
[BHV-1535] Investigate existing wrappers

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

Change-Id: I6c0a4cd7f75735765419562998df89bda6de3ba3
Reviewed-on: https://g2g.palm.com/5089
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>
Fix use of unsafe string functions in LS2

:Release Notes:
Replace unsafe string comparison function with analogue function which
handles NULL arguments appropriately.

:Detailed Notes:
String comparison function strcmp does not check passed arguments for
NULL values.
All occurences of strcmp call replaced with call to g_strcmp0 except
cases when passed arguments checked for valid values in code before
function call

:Testing Performed:
Unit tests on desktop build (make check, make test).

:QA Notes:

:Issues Addressed:
[BHV-71] Fix: LS2 uses unsafe string functions

Open-webOS-DCO-1.0-Signed-off-by: Oleksii Rudenko <oleksii.rudenko@lge.com>

Change-Id: I70c6483b943c6127d53a9e1650e9777bb723fdf2
Reviewed-on: https://g2g.palm.com/5098
Reviewed-by: DCO Verification
Tested-by: Oleksii Rudenko <oleksii.rudenko@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Reviewed-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Fix build against gtest in webOS environment

:Release Notes:
The source code of gtest should be referred via cmake module.

:Detailed Notes:

:Testing Performed:
Build and unit tests.

:QA Notes:

:Issues Addressed:
[BHV-1535] Investigate existing wrappers

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

Change-Id: I76ba048af1e200cde13c23d5dd8bc13c47ad09fe
Reviewed-on: https://g2g.palm.com/5142
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>
Revert change to public API to fix SAM build

:Release Notes:
Revert LSError* signatures, as they're mocked up by SAM.

:Detailed Notes:

:Testing Performed:
Build and unit tests.

:QA Notes:

:Issues Addressed:
[BHV-1535] Investigate existing wrappers

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

Change-Id: I875d522023f78a039e6b02bbdf3d430ecb80f46f
Reviewed-on: https://g2g.palm.com/5151
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>
Fix ls-monitor -c not catch call w/o service name

:Release Notes:
Fix ls-monitor compact mode which does not catch method call/signal
/cancel without service name. Call without service name is generated
by luna-send.

:Detailed Notes:
Original ls-monitor print "(null)" implicitly if service name is null.
In compact mode service name must not null to make compact name.
This patch supply "(null)" explicitly if service name is null.

:Testing Performed:
ls-monitor -c print save number of log when luna-send is used.
Tested on g2 phone.

luna-send -n 1 -f palm://com.lge.service.music/getAudioFiles
'{"select":["_id"]}'

:QA Notes:

:Issues Addressed:
[ANG-5035] ls-monitor compact mode does not catch method call from
           luna-send

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

Change-Id: I6bb948a4e4df876a7fac6ad8da1d766eb4b2caba
Reviewed-on: https://g2g.palm.com/5159
Reviewed-by: DCO Verification
Reviewed-by: SangWook Han <sangwook.han@lge.com>
Tested-by: SangWook Han <sangwook.han@lge.com>
Reviewed-by: Nikolay Orliuk <nikolay.orliuk@lge.com>
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Reviewed-by: Anatolii Sakhnik <anatolii.sakhnik@lge.com>
Fix unit-test

:Release Notes:
Fix 'test_transport_message' to check for '(null)'
service name instead of empty string.

:Detailed Notes:

:Testing Performed:
Unit-tests.

:QA Notes:

:Issues Addressed:
[ANG-5035] ls-monitor compact mode does not catch method call from luna-send

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

Change-Id: I32e0e8116934c89813b62ce7bfb0386f584be30b
Reviewed-on: https://g2g.palm.com/5173
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 logging to use library context

:Release Notes:
Fix logging functions to use PmLogLib library contexts.

:Detailed Notes:

:Testing Performed:
Unit-tests.

:QA Notes:

:Issues Addressed:
[BHV-3077] luna-service2: rework logging to use new pmloglib library-context feature

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

Change-Id: I3853485feee000b473d8efaa434820932e3684e7
Reviewed-on: https://g2g.palm.com/5135
Reviewed-by: DCO Verification
Reviewed-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Tested-by: Alexandr Smoktal <alexandr.smoktal@lge.com>
Reviewed-by: Sergiy Kryvonos <sergiy.kryvonos@lge.com>
Fix crash in LSUnregister() with dynamic peer

:Release Notes:
Fix crash in LSUnregister() when connecting to a dynamic service.

:Detailed Notes:
Enhance hub runner to launch dynamic services.  When LSUnregister() is
called, transport and callmap are deinitialized.  If pending messages
to a dynamic service are still in the queue, failure notification is
sent back to the client. The callmap must outlive the transport for
this reason.

:Testing Performed:
make check && make test

:QA Notes:

:Issues Addressed:
[BHV-3965] luna-send crashes at location /lib/libc.so.6(gsignal+0x3c)

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

Change-Id: I460262fa3c383e9755b3e74853eb5de006249387
Reviewed-on: https://g2g.palm.com/5212
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>
Fix bhv-3965-crash-svc unit-test

:Release Notes:

:Detailed Notes:
- add missing <memory> header

:Testing Performed:
make check && make test

:QA Notes:

:Issues Addressed:
[BHV-3965] luna-send crashes at location /lib/libc.so.6(gsignal+0x3c)

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

Change-Id: I674166968fd134616b20bb92c09d41321e5d3098
Reviewed-on: https://g2g.palm.com/5223
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>
split away category.c from base.c

:Release Notes:

:Detailed Notes:
- introduced category.c and category.h to handle all category related
  stuff

:Testing Performed:
unit-tests on desktop

:QA Notes:

:Issues Addressed:
[BHV-4021] Re-factor LS2 to keep its own copy of LSMethod info

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

Change-Id: I5467f83ac79632b965eb8ef3b450340ab9e0380b
Reviewed-on: https://g2g.palm.com/5217
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>
factor out LSCategoryMethodCall

:Release Notes:

:Detailed Notes:
- extracted LSCategoryMethodCall from _LSHandleMethodCall

:Testing Performed:
unit-tests on desktop

:QA Notes:

:Issues Addressed:
[BHV-4021] Re-factor LS2 to keep its own copy of LSMethod info

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

Change-Id: Ib702e652991b508e8ffc6ea2381be3b9fadc4c17
Reviewed-on: https://g2g.palm.com/5219
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>
make LS2 to keep its own copy of LSMethod

:Release Notes:
LS2 now keeps own copy of passed LSMethod. Thus easing life for
dynamically registered methods.

:Detailed Notes:
- introduced LSMethodEntry for storing callback info
- copy method name for callback

:Testing Performed:
unit-tests on desktop

:QA Notes:

:Issues Addressed:
[BHV-4021] Re-factor LS2 to keep its own copy of LSMethod info

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

Change-Id: I66381c83e754f63df707342e5ee4934bdf8c17da
Reviewed-on: https://g2g.palm.com/5228
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>
Revert "Prevent loss of calls"

This reverts commit a40836da0875b8304a4625c23d05f860ecc11ebf.
This reverts commit 557a6311948bfe224247cfeb5d954464815c1431.
This reverts commit f10a89cc12fe0910d82ca8b638b429330236bbe6.

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

Change-Id: I6f715fa0f6a7baf926ac1c7bd5f0c31c0eb9d48d
make test_timersource to work on slower systems

:Release Notes:
Now test_timersource doesn't fail under valgrind (when running
ExperimentalMemCheck) on Intel Core i7-3770 CPU 3.40GHz

:Detailed Notes:
- ensured that timer fire may vary in range -50 .. +50 ms

:Testing Performed:
unit-tests on desktop

:QA Notes:

:Issues Addressed:
[BHV-1589] Implement category registration with its description

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

Change-Id: Ifadfe8770e10cf11924e22fba232dbfa53e43208
Reviewed-on: https://g2g.palm.com/5253
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>
Create wrappers for registration

:Release Notes:
Create C++ wrappers for registration

:Detailed Notes:

:Testing Performed:
Unit-tests.

:QA Notes:

:Issues Addressed:
[BHV-1540] Create wrappers for registration

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

Change-Id: I3673afe68ce924851f65581ce7f7f442001ca162
Reviewed-on: https://g2g.palm.com/5225
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>