diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index 7d9d4c7084..0000000000
--- a/.gitattributes
+++ /dev/null
@@ -1,7 +0,0 @@
-*.txt text
-*.sh eol=lf
-*.py eol=lf
-*.py.template eol=lf
-*.sh.template eol=lf
-*.json text
-*.bat eol=crlf
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 9e6e5752a4..adc38dcad7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,69 +1,6 @@
-output/**
-*.class
-*.iml
-*/.idea/**
-.idea/**
-.idea
-*.log
-*.log.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]
-*/.classpath
-.classpath
-*/.project
-.project
-.cache/**
-target/
-tmp_deb_control/
-tmp_rpm_control/
-tmp_dao_resources/
-tmp_sh/
-.gwt/
-.settings/
-/bin
-bin/
-**/dependency-reduced-pom.xml
-server/common/server-shared/src/main/java/org/kaaproject/kaa/server/common/Version.java
-server/admin/src/main/java/org/kaaproject/kaa/server/admin/shared/Version.java
-sandbox/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java
-pom.xml.versionsBackup
-examples/*/source/lib/
-examples/*/source/java/lib/
-server/common/dao/src/main/resources/dao.properties
-server/common/dao/src/main/resources/sql-dao.properties
-server/node/src/main/resources/admin-dao.properties
-build/
-DerivedData
-Pods/
-
-**/Podfile.lock
-!Manifest.lock
-
-.DS_Store
-*~
-*.swp
-*.rbc
-
-*.pbxuser
-!default.pbxuser
-*.mode1v3
-!default.mode1v3
-*.mode2v3
-!default.mode2v3
-*.perspectivev3
-!default.perspectivev3
-!default.xcworkspace
-xcuserdata
-*.xccheckout
-!scripts/profile
-*.moved-aside
-*.hmap
-*.ipa
-Tests/Pods
-**/.toDelete
-/test-gh-pages-current/
-doc/Programming-guide/Server-REST-APIs/swagger.json
-/server/containers/docker/using-compose/kaa-nginx-config/kaa-nginx.conf
-/server/containers/docker/using-compose/kaa-nginx-config/kaa-default.conf
-/logs
-/server/containers/docker/using-compose/kaa-docker-compose.yml
-/server/containers/docker/kaa-node.deb
-/keys
\ No newline at end of file
+*pages-current/
+tmp/
+**/*.*~
+**/#*.*#
+.idea/
+.DS_store
diff --git a/.jekver.yml b/.jekver.yml
new file mode 100644
index 0000000000..4e24867906
--- /dev/null
+++ b/.jekver.yml
@@ -0,0 +1,10 @@
+
+project: kaabb
+latest: "current"
+
+jekdocs:
+ - md:
+ path: ""
+ target: ""
+ copy:
+ docs: doc
diff --git a/.jenkinsfile b/.jenkinsfile
new file mode 100644
index 0000000000..885189b983
--- /dev/null
+++ b/.jenkinsfile
@@ -0,0 +1,51 @@
+library 'kaaiot.shared-libraries@master'
+
+gitlabUtils.populateEnvVariables()
+
+pipeline {
+ environment {
+ TAG = gitlabUtils.getBuildTag()
+ SERVICE_NAME = "kaa"
+ SERVICE_NAME_UPPER = SERVICE_NAME.toUpperCase()
+ }
+
+ options {
+ disableConcurrentBuilds()
+ timeout(time: 30, unit: 'MINUTES')
+ }
+
+ agent none
+
+ stages {
+ stage ('Docs') {
+ agent { label "docs-builder_v1" }
+
+ steps {
+ // Workaround to prevent Jekver from building tags.
+ // Since doc generation flow will be changed really soon, I see no point
+ // in investing time in this right now
+ sh 'git tag | xargs git tag -d'
+
+ container ('builder') {
+ script {
+ docs.publish(env.SERVICE_NAME_UPPER, (env.BRANCH_NAME == "master") ? "current" : env.TAG)
+ }
+ }
+ }
+ }
+ }
+
+ post {
+ regression {
+ notification('regression', env.SERVICE_NAME)
+ }
+
+ fixed {
+ notification('fixed', env.SERVICE_NAME)
+ }
+
+ success {
+ notification('success', env.SERVICE_NAME)
+ }
+ }
+}
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index d532d4d73e..0000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Copyright 2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-language: python
-python: "3.4"
-sudo: required
-dist: trusty
-install:
- - ./scripts/setup_nix.sh
- - . $HOME/.nix-profile/etc/profile.d/nix.sh
-
- - cd client/client-multi/client-c/ && travis_retry nix-shell -Q --pure --run true --arg cc3200Support false && cd ../../..
- - cd client/client-multi/client-cpp/ && travis_retry nix-shell -Q --pure --run true && cd ../../..
- - travis_retry nix-shell -Q --packages pkgs.maven --pure --run true
-
-script:
- - nix-shell --pure --packages pkgs.maven --run 'mvn -q apache-rat:check'
-
- - cd client/client-multi/client-c
- - nix-shell --arg cc3200Support false --pure --run ./scripts/build.sh
- - cd ../../..
-
- - cd client/client-multi/client-cpp
- - nix-shell --pure --run './build.sh test'
- - cd ../../..
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index ad410e1130..0000000000
--- a/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
-Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
\ No newline at end of file
diff --git a/README.md b/README.md
index 3cab8fd290..4f1f2fa640 100644
--- a/README.md
+++ b/README.md
@@ -1,37 +1,3 @@
-
-
-
-
-
+# Kaa Enterprise documentation
-Kaa open-source IoT platform [![Build Status](https://travis-ci.org/kaaproject/kaa.svg?branch=master)](https://travis-ci.org/kaaproject/kaa)
-============================
-
-Kaa is a production-ready, multi-purpose middleware platform for building complete end-to-end IoT solutions, connected applications, and smart products. The Kaa platform provides an open, feature-rich toolkit for the IoT product development and thus dramatically reduces associated cost, risks, and time-to-market. For a quick start, Kaa offers a set of out-of-the-box enterprise-grade IoT features that can be easily plugged in and used to implement a large majority of the IoT use cases.
-
-# Getting started
-
-For the quick start with Kaa IoT platform check out [Getting started](http://www.kaaproject.org/getting-started/) guide.
-Alternatively, you can [deploy Kaa into your own environment](http://kaaproject.github.io/kaa/docs/v0.10.0/Administration-guide/System-installation/Single-node-installation/).
-
-# Getting help
-
-If you face some troubles with Kaa platform check out [Troubleshooting guide](http://kaaproject.github.io/kaa/docs/v0.10.0/Administration-guide/Troubleshooting/) and [Frequently asked questions](http://docs.kaaproject.org/display/KAA/Frequently+asked+questions) first and if you can't find the solution we welcome you to post your questions at the Kaa project [Google group](http://www.kaaproject.org/forum/).
-
-# Documentation
-
-Kaa documentation is a part of Kaa source code and is located in the [`doc/`](doc) folder. You can find the web version [here](http://kaaproject.github.io/kaa/).
-
-# How to contribute
-
-To contribute to Kaa IoT platform, please visit [How to contribute](http://kaaproject.github.io/kaa/docs/v0.10.0/Customization-guide/How-to-contribute/) guide.
-
-# Where to report issues
-
-You can report an issue by creating a corresponding ticket in [Kaa task tracker](http://jira.kaaproject.org/browse/KAA/), check out [Jira guide](http://kaaproject.github.io/kaa/docs/v0.10.0/Customization-guide/How-to-contribute/Jira-guide/) before submitting one.
-
-# License
-
-Kaa IoT platform is licensed under [Apache Software License 2.0](http://www.apache.org/licenses/LICENSE-2.0).
-
-See [`LICENSE`](LICENSE) and [`copyright.txt`](copyright.txt) for details.
+Documentation [site](https://docs.kaaiot.io).
diff --git a/avrogen/pom.xml b/avrogen/pom.xml
deleted file mode 100644
index bde419eb06..0000000000
--- a/avrogen/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
- 4.0.0
-
- org.kaaproject
- 0.10.0-SNAPSHOT
- kaa
-
-
- org.kaaproject.kaa.avrogen
- avrogen
- jar
-
- Kaa Avro Generator
- http://kaaproject.org
-
-
- UTF-8
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 2.5.1
-
- 1.7
- 1.7
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
- true
- lib/
- org.kaaproject.kaa.avro.avrogen.Main
-
-
-
-
-
- org.apache.rat
- apache-rat-plugin
- ${rat.version}
-
-
-
-
-
-
-
- junit
- junit
- test
-
-
- org.apache.velocity
- velocity
-
-
- org.apache.avro
- avro
-
-
-
diff --git a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/GenerationContext.java b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/GenerationContext.java
deleted file mode 100644
index f50f185efc..0000000000
--- a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/GenerationContext.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.kaaproject.kaa.avro.avrogen;
-
-/*
-* This feature never used, the value is always INOUT
-* */
-@Deprecated
-public class GenerationContext {
- private final String parentName;
- private final String fieldName;
- private DirectionType direction;
-
- /**
- * Instantiates a new GenerationContext.
- *
- * @param parentName the parent name
- * @param fieldName the field name
- * @param direction the direction
- */
- public GenerationContext(String parentName, String fieldName, String direction) {
- this.parentName = parentName;
- this.fieldName = fieldName;
-
- this.direction = DirectionType.INOUT;
-
- if (direction != null) {
- if (direction.equalsIgnoreCase("out")) {
- this.direction = DirectionType.OUT;
- } else if (direction.equalsIgnoreCase("in")) {
- this.direction = DirectionType.IN;
- }
-
- }
- }
-
- /**
- * Update direction type of GenerationContext.
- *
- * @param context the GenerationContext
- */
- public void updateDirection(GenerationContext context) {
- if (direction != DirectionType.INOUT && context != null && direction != context.direction) {
- direction = DirectionType.INOUT;
- }
- }
-
- public String getParentName() {
- return parentName;
- }
-
- public String getFieldName() {
- return fieldName;
- }
-
- public boolean isTypeOut() {
- return direction != DirectionType.IN;
- }
-
- public boolean isTypeIn() {
- return direction != DirectionType.OUT;
- }
-
- public boolean isTypeInOut() {
- return direction == DirectionType.INOUT;
- }
-
- private enum DirectionType {
- IN,
- OUT,
- INOUT
- }
-}
diff --git a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/KaaGeneratorException.java b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/KaaGeneratorException.java
deleted file mode 100644
index 318bdde285..0000000000
--- a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/KaaGeneratorException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.kaaproject.kaa.avro.avrogen;
-
-public class KaaGeneratorException extends Exception {
- public KaaGeneratorException() {
- super();
- }
-
- public KaaGeneratorException(String str) {
- super(str);
- }
-}
diff --git a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/Main.java b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/Main.java
deleted file mode 100644
index 126d794b86..0000000000
--- a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/Main.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.kaaproject.kaa.avro.avrogen;
-
-
-import org.kaaproject.kaa.avro.avrogen.compiler.Compiler;
-import org.kaaproject.kaa.avro.avrogen.compiler.ObjectiveCCompiler;
-
-public class Main {
-
- /**
- * The main method.
- *
- * @param args the input arguments
- */
- public static void main(String[] args) {
- try {
- if (args.length < 3) {
- throw new KaaGeneratorException("Not enough argument. "
- + "Need {FULL_PATH_TO_SCHEMA} {OUTPUT_PATH} {SOURCE_NAME}");
- }
-
- Compiler compiler = new ObjectiveCCompiler(args[0], args[1], args[2]);
- compiler.generate();
- } catch (Exception ex) {
- System.err.println("Compilation failure: " + ex.toString());
- }
- }
-}
diff --git a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/StyleUtils.java b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/StyleUtils.java
deleted file mode 100644
index a11be7bf77..0000000000
--- a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/StyleUtils.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.kaaproject.kaa.avro.avrogen;
-
-public class StyleUtils {
-
- private StyleUtils() {
- }
-
- /**
- * Convert to lower underscore format.
- *
- * @param camelCaseName the name in camel case format
- * @return the string in lower underscore format
- */
- public static String toLowerUnderScore(String camelCaseName) {
- StringBuilder convertedName = new StringBuilder();
-
- for (int i = 0; i < camelCaseName.length(); ++i) {
- char character = camelCaseName.charAt(i);
- if (Character.isUpperCase(character)) {
- character = Character.toLowerCase(character);
- if (convertedName.length() > 0 && ((i + 1) < camelCaseName.length())
- && (Character.isLowerCase(camelCaseName.charAt(i + 1))
- || Character.isLowerCase(camelCaseName.charAt(i - 1)))) {
- convertedName.append("_");
- }
- convertedName.append(character);
- } else {
- convertedName.append(character);
- }
- }
-
- return convertedName.toString();
- }
-
- /**
- * Convert to upper underscore format.
- *
- * @param camelCaseName the input name
- * @return the string in upper underscore format
- */
- public static String toUpperUnderScore(String camelCaseName) {
- StringBuilder convertedName = new StringBuilder();
-
- for (int i = 0; i < camelCaseName.length(); ++i) {
- char character = camelCaseName.charAt(i);
- if (Character.isUpperCase(character)) {
- if (convertedName.length() > 0 && ((i + 1) < camelCaseName.length())
- && (Character.isLowerCase(camelCaseName.charAt(i + 1))
- || Character.isLowerCase(camelCaseName.charAt(i - 1)))) {
- convertedName.append("_");
- }
- convertedName.append(character);
- } else {
- convertedName.append(Character.toUpperCase(character));
- }
- }
-
- return convertedName.toString();
- }
-
- /**
- * Fix camel humps.
- * @param name the input name
- * @return the string with fixed camel humps
- */
- public static String fixCamelHumps(String name) {
- if (name == null || name.isEmpty()) {
- throw new IllegalArgumentException("Name couldn't be null or empty");
- }
- if (Character.isLowerCase(name.charAt(0))) {
- return Character.toUpperCase(name.charAt(0)) + name.substring(1);
- }
- return name;
- }
-
- public static String removePackageName(String fullClassName) {
- int index = fullClassName.lastIndexOf('.');
- return index == -1 ? fullClassName : fullClassName.substring(index + 1);
- }
-}
diff --git a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/TypeConverter.java b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/TypeConverter.java
deleted file mode 100644
index 977190fde3..0000000000
--- a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/TypeConverter.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.kaaproject.kaa.avro.avrogen;
-
-import org.apache.avro.Schema;
-import org.apache.avro.Schema.Field;
-import org.apache.avro.Schema.Type;
-
-import java.util.List;
-
-public class TypeConverter {
- private static final String DIRECTION_FIELD = "direction";
-
- private TypeConverter() {
- }
-
- public static String convertToCType(Schema schema) {
- return convertToCType("kaa", schema);
- }
-
- /**
- * Convert schema type to the C type.
- *
- * @param namespace the namespace
- * @param schema the schema
- * @return the converted schema type
- */
- public static String convertToCType(String namespace, Schema schema) {
- String typeC = "";
- switch (schema.getType()) {
- case BOOLEAN:
- typeC = "int8_t";
- break;
- case INT:
- typeC = "int32_t";
- break;
- case LONG:
- typeC = "int64_t";
- break;
- case FLOAT:
- typeC = "float";
- break;
- case DOUBLE:
- typeC = "double";
- break;
- case STRING:
- typeC = "kaa_string_t *";
- break;
- case BYTES:
- case FIXED:
- typeC = "kaa_bytes_t *";
- break;
- case ARRAY:
- typeC = "kaa_list_t *";
- break;
- case UNION:
- typeC = "kaa_union_t *";
- break;
- case ENUM:
- typeC = namespace + "_" + StyleUtils.toLowerUnderScore(schema.getName()) + "_t";
- break;
- case RECORD:
- typeC = namespace + "_" + StyleUtils.toLowerUnderScore(schema.getName()) + "_t *";
- break;
- default:
- // TODO: add handling
- break;
- }
-
- return typeC;
- }
-
- /**
- * Convert schema type to the object C type.
- *
- * @param schema the schema
- * @return the converted schema type
- */
- public static String convertToObjCType(Schema schema) {
- String objCType = "";
- switch (schema.getType()) {
- case BOOLEAN:
- objCType = "BOOL";
- break;
- case INT:
- objCType = "int32_t";
- break;
- case LONG:
- objCType = "int64_t";
- break;
- case FLOAT:
- objCType = "float";
- break;
- case DOUBLE:
- objCType = "double";
- break;
- case STRING:
- objCType = "NSString *";
- break;
- case BYTES:
- case FIXED:
- objCType = "NSData *";
- break;
- case ARRAY:
- objCType = "NSArray *";
- break;
- case UNION:
- objCType = "KAAUnion *";
- break;
- case ENUM:
- objCType = schema.getName();
- break;
- case RECORD:
- objCType = schema.getName() + " *";
- break;
- default:
- // TODO: add handling
- break;
- }
-
- return objCType;
- }
-
- public static String generateUnionName(Schema schema) {
- return generateUnionName("", schema);
- }
-
- /**
- * Generate union name.
- *
- * @param prefix the prefix to union name
- * @param schema the schema
- * @return generated union name
- */
- public static String generateUnionName(String prefix, Schema schema) {
- StringBuilder builder = new StringBuilder(prefix + "_UNION_");
-
- List branches = schema.getTypes();
- int branchCounter = branches.size();
-
- for (Schema branchSchema : branches) {
- switch (branchSchema.getType()) {
- case RECORD:
- builder.append(StyleUtils.toUpperUnderScore(branchSchema.getName()));
- break;
- case ARRAY:
- builder.append(branchSchema.getType().toString());
- builder.append('_');
- builder.append(StyleUtils.toUpperUnderScore(branchSchema.getElementType().getName()));
- break;
- case ENUM:
- builder.append(StyleUtils.toUpperUnderScore(branchSchema.getName()));
- break;
- default:
- builder.append(branchSchema.getType().toString());
- break;
- }
-
- if (--branchCounter > 0) {
- builder.append("_OR_");
- }
- }
-
- return builder.toString();
- }
-
- /**
- * Check is record need deal locator.
- *
- * @param schema the input schema
- * @return boolean 'true' if record need deal locator
- */
- public static boolean isRecordNeedDeallocator(Schema schema) {
- if (schema.getType() == Type.RECORD) {
- for (Field f : schema.getFields()) {
- Type type = f.schema().getType();
- if (type == Type.ARRAY || type == Type.BYTES || type == Type.STRING
- || type == Type.FIXED || type == Type.RECORD || type == Type.UNION) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Check is schema an Avro primitive.
- *
- * @param schema the schema
- * @return boolean 'true' if schema is an Avro primitive
- */
- public static boolean isAvroPrimitive(Schema schema) {
- Type type = schema.getType();
- return type == Type.BOOLEAN || type == Type.INT || type == Type.LONG
- || type == Type.ENUM || type == Type.FLOAT || type == Type.DOUBLE;
- }
-
- public static boolean isAvroNull(Schema schema) {
- return schema.getType() == Type.NULL;
- }
-
- public static boolean isAvroFixed(Schema schema) {
- return schema.getType() == Type.FIXED;
- }
-
- public static boolean isAvroRecord(Schema schema) {
- return schema.getType() == Type.RECORD;
- }
-
- public static boolean isAvroUnion(Schema schema) {
- return schema.getType() == Type.UNION;
- }
-
- public static boolean isAvroArray(Schema schema) {
- return schema.getType() == Type.ARRAY;
- }
-
- public static boolean isAvroEnum(Schema schema) {
- return schema.getType() == Type.ENUM;
- }
-
- public static boolean isAvroString(Schema schema) {
- return schema.getType() == Type.STRING;
- }
-
- public static boolean isAvroBytes(Schema schema) {
- return schema.getType() == Type.BYTES;
- }
-
- public static boolean isAvroFloat(Schema schema) {
- return schema.getType() == Type.FLOAT;
- }
-
- public static boolean isAvroDouble(Schema schema) {
- return schema.getType() == Type.DOUBLE;
- }
-
- public static boolean isAvroInt(Schema schema) {
- return schema.getType() == Type.INT;
- }
-
- public static boolean isAvroLong(Schema schema) {
- return schema.getType() == Type.LONG;
- }
-
- public static boolean isAvroBoolean(Schema schema) {
- return schema.getType() == Type.BOOLEAN;
- }
-
- public static boolean isTypeOut(Schema schema) {
- String prop = schema.getProp(DIRECTION_FIELD);
- return prop == null || prop.equalsIgnoreCase("out");
- }
-
- public static boolean isTypeIn(Schema schema) {
- String prop = schema.getProp(DIRECTION_FIELD);
- return prop == null || prop.equalsIgnoreCase("in");
- }
-
- public static String getLastBranchNumber(Schema schema) {
- return "" + (schema.getTypes().size() - 1);
- }
-
- /**
- * Check if the schema contains union.
- *
- * @param schema the schema
- * @return boolean 'true' if the schema contains union
- */
- public static boolean containsUnion(Schema schema) {
- for (Field field : schema.getFields()) {
- if (isAvroUnion(field.schema())) {
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/CCompiler.java b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/CCompiler.java
deleted file mode 100644
index 248d42cb1d..0000000000
--- a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/CCompiler.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.kaaproject.kaa.avro.avrogen.compiler;
-
-import org.apache.avro.Schema;
-import org.apache.velocity.VelocityContext;
-import org.kaaproject.kaa.avro.avrogen.GenerationContext;
-import org.kaaproject.kaa.avro.avrogen.KaaGeneratorException;
-import org.kaaproject.kaa.avro.avrogen.StyleUtils;
-import org.kaaproject.kaa.avro.avrogen.TypeConverter;
-
-import java.io.OutputStream;
-import java.io.StringWriter;
-import java.util.List;
-import java.util.Map;
-
-public class CCompiler extends Compiler {
-
- public CCompiler(String schemaPath, String outputPath, String sourceName)
- throws KaaGeneratorException {
- super(schemaPath, outputPath, sourceName);
- }
-
- public CCompiler(Schema schema, String sourceName, OutputStream hdrS, OutputStream srcS)
- throws KaaGeneratorException {
- super(schema, sourceName, hdrS, srcS);
- }
-
- public CCompiler(List schemas, String sourceName, OutputStream hdrS, OutputStream srcS)
- throws KaaGeneratorException {
- super(schemas, sourceName, hdrS, srcS);
- }
-
- @Override
- protected String headerTemplateGen() {
- return "src/main/resources/header.tmpl.gen";
- }
-
- @Override
- protected String sourceTemplateGen() {
- return "src/main/resources/source.tmpl.gen";
- }
-
- @Override
- protected String headerTemplate() {
- return "header.tmpl";
- }
-
- @Override
- protected String sourceTemplate() {
- return "source.tmpl";
- }
-
- @Override
- protected String getSourceExtension() {
- return ".c";
- }
-
- @Override
- protected void doGenerate() {
- for (Map.Entry cursor : schemaGenerationQueue.entrySet()) {
- switch (cursor.getKey().getType()) {
- case RECORD:
- processRecord(cursor.getKey(), "record.h.vm", "record.c.vm");
- break;
- case UNION:
- processUnion(cursor.getKey(), cursor.getValue());
- break;
- case ENUM:
- processEnum(cursor.getKey(), "enum.h.vm");
- break;
- default:
- break;
- }
- }
- completeGeneration();
- }
-
- private void processUnion(Schema schema, GenerationContext genContext) {
- VelocityContext context = new VelocityContext();
-
- context.put("schema", schema);
- context.put("generationContext", genContext);
- context.put("StyleUtils", StyleUtils.class);
- context.put("TypeConverter", TypeConverter.class);
- context.put("namespacePrefix", namespacePrefix);
-
- StringWriter headerWriter = new StringWriter();
- engine.getTemplate("union.h.vm").merge(context, headerWriter);
- appendResult(headerWriter.toString(), true);
-
- StringWriter sourceWriter = new StringWriter();
- engine.getTemplate("union.c.vm").merge(context, sourceWriter);
- appendResult(sourceWriter.toString(), false);
- }
-
- private void completeGeneration() {
- headerWriter.write("#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n#endif");
- }
-}
diff --git a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/Compiler.java b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/Compiler.java
deleted file mode 100644
index 7cd3b9e630..0000000000
--- a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/Compiler.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.kaaproject.kaa.avro.avrogen.compiler;
-
-import static org.apache.commons.lang.StringUtils.join;
-
-import org.apache.avro.Schema;
-import org.apache.avro.Schema.Field;
-import org.apache.avro.Schema.Type;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.kaaproject.kaa.avro.avrogen.GenerationContext;
-import org.kaaproject.kaa.avro.avrogen.KaaGeneratorException;
-import org.kaaproject.kaa.avro.avrogen.StyleUtils;
-import org.kaaproject.kaa.avro.avrogen.TypeConverter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * The type Compiler.
- */
-public abstract class Compiler {
- private static final String DIRECTION_PROP = "direction";
-
-
- private static final Logger LOG = LoggerFactory.getLogger(Compiler.class);
- protected final Map schemaGenerationQueue;
- private final String generatedSourceName;
- protected VelocityEngine engine;
-
- protected PrintWriter headerWriter;
- protected PrintWriter sourceWriter;
-
- protected String namespacePrefix;
- // list of schemas that should be skipped during generation
- protected Set generatedSchemas = new HashSet<>();
- private List schemas = new ArrayList<>();
-
-
- private Compiler(String sourceName) throws KaaGeneratorException {
- this.namespacePrefix = "kaa";
- this.generatedSourceName = sourceName;
- this.schemaGenerationQueue = new LinkedHashMap<>();
- initVelocityEngine();
- }
-
-
- /**
- * Instantiates a new Compiler.
- *
- * @param schema the schema that used to generate source files
- * @param sourceName the name of source file
- * @param hdrS the stream of header file
- * @param srcS the stream of source file
- */
- public Compiler(Schema schema, String sourceName, OutputStream hdrS, OutputStream srcS)
- throws KaaGeneratorException {
- this(sourceName);
- this.schemas.add(schema);
- this.headerWriter = new PrintWriter(hdrS);
- this.sourceWriter = new PrintWriter(srcS);
- prepareTemplates(false);
- }
-
-
- /**
- * Instantiates a new Compiler.
- *
- * @param schemas list of schemas that used to generate source files
- * @param sourceName name of source files
- * @param hdrS stream of the header file
- * @param srcS stream of the source file
- */
- public Compiler(List schemas, String sourceName, OutputStream hdrS, OutputStream srcS)
- throws KaaGeneratorException {
- this(sourceName);
- this.schemas.addAll(schemas);
- this.headerWriter = new PrintWriter(hdrS);
- this.sourceWriter = new PrintWriter(srcS);
- prepareTemplates(false);
- }
-
-
- public Compiler(List schemas, String sourceName, OutputStream hdrS, OutputStream srcS,
- Set generatedSchemas) throws KaaGeneratorException {
- this(schemas, sourceName, hdrS, srcS);
- this.generatedSchemas = new HashSet<>(generatedSchemas);
- }
-
-
- /**
- * Instantiates a new Compiler.
- *
- * @param schemaPath path to file that contains schema
- * @param outputPath destination path for generated sources
- * @param sourceName name of source files
- */
- public Compiler(String schemaPath, String outputPath, String sourceName)
- throws KaaGeneratorException {
- this(sourceName);
- try {
- this.schemas.add(new Schema.Parser().parse(new File(schemaPath)));
-
- prepareTemplates(true);
-
- File outputDir = new File(outputPath);
- outputDir.mkdirs();
-
- String headerPath = outputPath + File.separator + generatedSourceName + ".h";
- String sourcePath = outputPath + File.separator + generatedSourceName + getSourceExtension();
-
- Files.move(new File(headerTemplateGen()).toPath(),
- new File(headerPath).toPath(), StandardCopyOption.REPLACE_EXISTING);
- Files.move(new File(sourceTemplateGen()).toPath(),
- new File(sourcePath).toPath(), StandardCopyOption.REPLACE_EXISTING);
-
- this.headerWriter = new PrintWriter(new BufferedWriter(new FileWriter(headerPath, true)));
- this.sourceWriter = new PrintWriter(new BufferedWriter(new FileWriter(sourcePath, true)));
- } catch (Exception ex) {
- LOG.error("Failed to create ouput path: ", ex);
- throw new KaaGeneratorException("Failed to create output path: " + ex.toString());
- }
- }
-
- private void initVelocityEngine() {
- engine = new VelocityEngine();
-
- engine.addProperty("resource.loader", "class, file");
- engine.addProperty("class.resource.loader.class",
- "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
- engine.addProperty("file.resource.loader.class",
- "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
- engine.addProperty("file.resource.loader.path", "/, .");
- engine.setProperty("runtime.references.strict", true);
- engine.setProperty("runtime.log.logsystem.class",
- "org.apache.velocity.runtime.log.NullLogSystem");
- }
-
- protected abstract String headerTemplateGen();
-
- protected abstract String sourceTemplateGen();
-
- protected abstract String headerTemplate();
-
- protected abstract String sourceTemplate();
-
- protected abstract String getSourceExtension();
-
- private void prepareTemplates(boolean toFile) throws KaaGeneratorException {
- try {
- VelocityContext context = new VelocityContext();
- context.put("headerName", generatedSourceName);
-
- StringWriter hdrWriter = new StringWriter();
- engine.getTemplate(headerTemplate()).merge(context, hdrWriter);
-
- StringWriter srcWriter = new StringWriter();
- engine.getTemplate(sourceTemplate()).merge(context, srcWriter);
-
- if (toFile) {
- writeToFile(hdrWriter, srcWriter);
- } else {
- writeToStream(hdrWriter, srcWriter);
- }
- } catch (Exception ex) {
- LOG.error("Failed to prepare source templates: ", ex);
- throw new KaaGeneratorException("Failed to prepare source templates: " + ex.toString());
- }
- }
-
- private void writeToStream(StringWriter hdrWriter, StringWriter srcWriter) {
- headerWriter.write(hdrWriter.toString());
- sourceWriter.write(srcWriter.toString());
- }
-
- private void writeToFile(StringWriter hdrWriter, StringWriter srcWriter) throws Exception {
- FileOutputStream hdrOs = new FileOutputStream(headerTemplateGen());
- hdrOs.write(hdrWriter.toString().getBytes());
- hdrOs.close();
-
- FileOutputStream srcOs = new FileOutputStream(sourceTemplateGen());
- srcOs.write(srcWriter.toString().getBytes());
- srcOs.close();
- }
-
-
- /**
- * Generate source files using the schemas and write them to specified source file.
- */
- public Set generate() throws KaaGeneratorException {
- try {
- LOG.debug("Processing schemas: [" + join(schemas, ", ") + "]");
- for (Schema schema : schemas) {
-
- if (schema.getType() == Type.UNION) {
- for (Schema s : schema.getTypes()) {
- addAllSchemasToQueue(s, null);
- }
- } else {
- addAllSchemasToQueue(schema, null);
- }
- }
-
-
- doGenerate();
-
- LOG.debug("Sources were successfully generated");
- return schemaGenerationQueue.keySet();
- } catch (Exception ex) {
- LOG.error("Failed to generate C sources: ", ex);
- throw new KaaGeneratorException("Failed to generate sources: " + ex.toString());
- } finally {
- headerWriter.close();
- sourceWriter.close();
- }
- }
-
- /**
- * Recursively add all unique dependencies of a passed schema and the one to generation queue,
- * that used to generate sources.
- */
- private void addAllSchemasToQueue(Schema schema, GenerationContext context) {
- GenerationContext existingContext = schemaGenerationQueue.get(schema);
-
- if (existingContext != null) {
- existingContext.updateDirection(context);
- return;
- }
-
- switch (schema.getType()) {
- case RECORD:
- for (Field f : schema.getFields()) {
- addAllSchemasToQueue(f.schema(), new GenerationContext(
- schema.getName(), f.name(), schema.getProp(DIRECTION_PROP)));
- }
- schemaGenerationQueue.put(schema, null);
- break;
- case UNION:
- for (Schema branchSchema : schema.getTypes()) {
- addAllSchemasToQueue(branchSchema, context);
- }
- schemaGenerationQueue.put(schema, context);
- break;
- case ARRAY:
- addAllSchemasToQueue(schema.getElementType(), context);
- break;
- case ENUM:
- schemaGenerationQueue.put(schema, null);
- break;
- default:
- break;
- }
- }
-
- protected abstract void doGenerate();
-
- protected void processRecord(Schema schema, String headerTemplate, String sourceTemplate) {
- VelocityContext context = new VelocityContext();
-
- context.put("schema", schema);
- context.put("StyleUtils", StyleUtils.class);
- context.put("TypeConverter", TypeConverter.class);
- context.put("namespacePrefix", namespacePrefix);
-
- StringWriter hdrWriter = new StringWriter();
- engine.getTemplate(headerTemplate).merge(context, hdrWriter);
- appendResult(hdrWriter.toString(), true);
-
- StringWriter srcWriter = new StringWriter();
- engine.getTemplate(sourceTemplate).merge(context, srcWriter);
- appendResult(srcWriter.toString(), false);
- }
-
- protected void processEnum(Schema schema, String template) {
- VelocityContext context = new VelocityContext();
-
- List symbols = schema.getEnumSymbols();
-
- context.put("schema", schema);
- context.put("symbols", symbols);
- context.put("StyleUtils", StyleUtils.class);
- context.put("namespacePrefix", namespacePrefix);
-
- StringWriter writer = new StringWriter();
- engine.getTemplate(template).merge(context, writer);
- appendResult(writer.toString(), true);
- }
-
- protected void appendResult(String str, boolean toHeader) {
- if (toHeader) {
- headerWriter.write(str);
- } else {
- sourceWriter.write(str);
- }
- }
-
- public void setNamespacePrefix(String namespacePrefix) {
- this.namespacePrefix = namespacePrefix;
- }
-
-}
\ No newline at end of file
diff --git a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/ObjectiveCCompiler.java b/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/ObjectiveCCompiler.java
deleted file mode 100644
index ed52e6374a..0000000000
--- a/avrogen/src/main/java/org/kaaproject/kaa/avro/avrogen/compiler/ObjectiveCCompiler.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.kaaproject.kaa.avro.avrogen.compiler;
-
-import org.apache.avro.Schema;
-import org.kaaproject.kaa.avro.avrogen.GenerationContext;
-import org.kaaproject.kaa.avro.avrogen.KaaGeneratorException;
-
-import java.io.OutputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class ObjectiveCCompiler extends Compiler {
-
- public ObjectiveCCompiler(Schema schema, String sourceName, OutputStream hdrS, OutputStream srcS)
- throws KaaGeneratorException {
- super(schema, sourceName, hdrS, srcS);
- setNamespacePrefix("");
- }
-
- public ObjectiveCCompiler(String schemaPath, String outputPath, String sourceName)
- throws KaaGeneratorException {
- super(schemaPath, outputPath, sourceName);
- setNamespacePrefix("");
- }
-
-
- public ObjectiveCCompiler(List schemas, String sourceName, OutputStream hdrS,
- OutputStream srcS) throws KaaGeneratorException {
- super(schemas, sourceName, hdrS, srcS);
- }
-
- public ObjectiveCCompiler(List schemas, String sourceName, OutputStream hdrS,
- OutputStream srcS, Set generatedSchemas)
- throws KaaGeneratorException {
- super(schemas, sourceName, hdrS, srcS, generatedSchemas);
- }
-
- @Override
- protected String headerTemplateGen() {
- return "src/main/resources/ObjC/headerObjC.tmpl.gen";
- }
-
- @Override
- protected String sourceTemplateGen() {
- return "src/main/resources/ObjC/sourceObjC.tmpl.gen";
- }
-
- @Override
- protected String headerTemplate() {
- return "ObjC/headerObjC.tmpl";
- }
-
- @Override
- protected String sourceTemplate() {
- return "ObjC/sourceObjC.tmpl";
- }
-
- @Override
- protected String getSourceExtension() {
- return ".m";
- }
-
- @Override
- protected void doGenerate() {
- for (Map.Entry cursor : schemaGenerationQueue.entrySet()) {
- if (!generatedSchemas.contains(cursor.getKey())) { // process only not generated schemas
- switch (cursor.getKey().getType()) {
- case RECORD:
- processRecord(cursor.getKey(), "ObjC/recordObjC.h.vm", "ObjC/recordObjC.m.vm");
- break;
- case ENUM:
- processEnum(cursor.getKey(), "ObjC/enumObjC.h.vm");
- break;
- default:
- break;
- }
- }
- }
- }
-}
diff --git a/avrogen/src/main/resources/ObjC/enumObjC.h.vm b/avrogen/src/main/resources/ObjC/enumObjC.h.vm
deleted file mode 100644
index 5953711559..0000000000
--- a/avrogen/src/main/resources/ObjC/enumObjC.h.vm
+++ /dev/null
@@ -1,24 +0,0 @@
-#*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *#
-
-#set ($ENUM_NAME = $StyleUtils.toUpperUnderScore($schema.getName()))
-#set ($enum_name = $schema.getName())
-
-typedef enum {
-#foreach ($symbol in $schema.getEnumSymbols())
- ${ENUM_NAME}_$symbol,
-#end
-} $namespacePrefix${enum_name};
diff --git a/avrogen/src/main/resources/ObjC/headerObjC.tmpl b/avrogen/src/main/resources/ObjC/headerObjC.tmpl
deleted file mode 100644
index 78b00b6a4d..0000000000
--- a/avrogen/src/main/resources/ObjC/headerObjC.tmpl
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * AUTO-GENERATED CODE
- */
-
-#import
-#import "AvroUtils.h"
-#import "AvroBased.h"
-#import "KAAUnion.h"
diff --git a/avrogen/src/main/resources/ObjC/recordObjC.h.vm b/avrogen/src/main/resources/ObjC/recordObjC.h.vm
deleted file mode 100644
index 552b9c755f..0000000000
--- a/avrogen/src/main/resources/ObjC/recordObjC.h.vm
+++ /dev/null
@@ -1,72 +0,0 @@
-#*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *#
-
-#set ($record_name = $schema.getName())
-
-@interface $namespacePrefix${record_name} : AvroBased
-
-#foreach ($field in $schema.getFields())
-#set ($field_type = $TypeConverter.convertToObjCType($field.schema()))
-#set ($field_name = $field.name())
-#if ($TypeConverter.isAvroEnum($field.schema()))
-@property(nonatomic) $namespacePrefix${field_type} ${field_name};
-#elseif ($TypeConverter.isAvroPrimitive($field.schema()))
-@property(nonatomic) ${field_type} ${field_name};
-#elseif ($TypeConverter.isAvroRecord($field.schema()))
-@property(nonatomic, strong) $namespacePrefix${field_type}${field_name};
-#else
-@property(nonatomic, strong) ${field_type}${field_name};
-#end
-#end
-
-#if ($schema.getFields().size() > 0)
-#set ($string = '- (instancetype)initWith')
-#set ($initstring = '')
-#foreach ($field in $schema.getFields())
-#if ($TypeConverter.isAvroEnum($field.schema()) || $TypeConverter.isAvroRecord($field.schema()))
-#set ($field_type = "$namespacePrefix$TypeConverter.convertToObjCType($field.schema())")
-#else
-#set ($field_type = $TypeConverter.convertToObjCType($field.schema()))
-#end
-#set ($field_name = $field.name())
-#if ($field == $schema.getFields().get(0))
-#set ($initstring = "$string$StyleUtils.fixCamelHumps($field_name):(${field_type})$field_name")
-#else
-#set ($initstring = "$initstring $field_name:(${field_type})$field_name")
-#end
-#end
-$initstring;
-#end
-
-#foreach ($field in $schema.getFields())
-#set ($field_name = $field.name())
-#if ($TypeConverter.isAvroUnion($field.schema()))
-
-#set ($UNION_NAME = $TypeConverter.generateUnionName("KAA", $field.schema()))
-#set ($branch_number = 0)
-# ifndef ${UNION_NAME}_H_
-# define ${UNION_NAME}_H_
-
-#foreach ($branch_schema in $field.schema().getTypes())
-# define ${UNION_NAME}_BRANCH_${branch_number} ${branch_number}
-#set ($branch_number = $branch_number + 1)
-#end
-
-# endif // ${UNION_NAME}_H_
-
-#end
-#end
-@end
diff --git a/avrogen/src/main/resources/ObjC/recordObjC.m.vm b/avrogen/src/main/resources/ObjC/recordObjC.m.vm
deleted file mode 100644
index a9ea5442a5..0000000000
--- a/avrogen/src/main/resources/ObjC/recordObjC.m.vm
+++ /dev/null
@@ -1,494 +0,0 @@
-#*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *#
-
-@implementation $namespacePrefix$schema.getName()
-
-#if ($TypeConverter.containsUnion($schema))
-- (instancetype)init {
- self = [super init];
- if (self) {
- #foreach ($field in $schema.getFields())
- #if ($TypeConverter.isAvroUnion($field.schema()))
- #set ($UNION_NAME = $TypeConverter.generateUnionName("KAA", $field.schema()))
- self.$field.name() = [KAAUnion unionWithBranch:${UNION_NAME}_BRANCH_$TypeConverter.getLastBranchNumber($field.schema())];
- #end
- #end
-}
- return self;
-}
-#end
-
-#if ($schema.getFields().size() > 0)
-#set ($string = '- (instancetype)initWith')
-#set ($initstring = '')
-#foreach ($field in $schema.getFields())
-#if ($TypeConverter.isAvroEnum($field.schema()) || $TypeConverter.isAvroRecord($field.schema()))
-#set ($field_type = "$namespacePrefix$TypeConverter.convertToObjCType($field.schema())")
-#else
-#set ($field_type = $TypeConverter.convertToObjCType($field.schema()))
-#end
-#set ($field_name = $field.name())
-#if ($field == $schema.getFields().get(0))
-#set ($initstring = "$string$StyleUtils.fixCamelHumps($field_name):(${field_type})$field_name")
-#else
-#set ($initstring = "$initstring $field_name:(${field_type})$field_name")
-#end
-#end
-$initstring {
- self = [super init];
- if (self) {
- #foreach ($field in $schema.getFields())
- self.$field.name() = $field.name();
- #end
-}
- return self;
-}
-#end
-
-+ (NSString *)FQN {
- return @"$schema.getFullName()";
-}
-
-###if ($TypeConverter.isTypeOut($schema))
-- (void)serialize:(avro_writer_t)writer {
-#foreach ($field in $schema.getFields())
-#set ($field_name = $field.name())
-#set ($field_schema = $field.schema())
-#if ($TypeConverter.isAvroRecord($field_schema) && $field_schema.getFields().size() > 0)
- [self.${field_name} serialize:writer];
-#elseif ($TypeConverter.isAvroUnion($field_schema))
-#set ($union_element_name = $StyleUtils.fixCamelHumps($field_name))
- [self serialize${union_element_name}:self.${field_name} to:writer];
-#elseif ($TypeConverter.isAvroBytes($field_schema))
- [self.utils serializeBytes:self.${field_name} to:writer];
-#elseif ($TypeConverter.isAvroFixed($field_schema))
- [self.utils serializeFixed:self.${field_name} to:writer];
-#elseif ($TypeConverter.isAvroString($field_schema))
- [self.utils serializeString:self.${field_name} to:writer];
-#elseif ($TypeConverter.isAvroBoolean($field_schema))
- [self.utils serializeBoolean:@(self.${field_name}) to:writer];
-#elseif ($TypeConverter.isAvroInt($field_schema))
- [self.utils serializeInt:@(self.${field_name}) to:writer];
-#elseif ($TypeConverter.isAvroLong($field_schema))
- [self.utils serializeLong:@(self.${field_name}) to:writer];
-#elseif ($TypeConverter.isAvroEnum($field_schema))
- [self.utils serializeEnum:@(self.${field_name}) to:writer];
-#elseif ($TypeConverter.isAvroFloat($field_schema))
- [self.utils serializeFloat:@((float)self.${field_name}) to:writer];
-#elseif ($TypeConverter.isAvroDouble($field_schema))
- [self.utils serializeDouble:@(self.${field_name}) to:writer];
-#elseif ($TypeConverter.isAvroArray($field_schema))
-#set ($array_element_schema = $field_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- [self.utils serializeArray:self.${field_name} to:writer withSelector:@selector(serializeRecord:to:) target:nil];
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- #set ($union_element_name = $StyleUtils.fixCamelHumps($field_name))
- [self serialize${union_element_name}:self.${field_name} to:writer];
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- [self.utils serializeArray:self.${field_name} to:writer withSelector:@selector(serializeBytes:to:) target:nil];
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- [self.utils serializeArray:self.${field_name} to:writer withSelector:@selector(serializeFixed:to:) target:nil];
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- [self.utils serializeArray:self.${field_name} to:writer withSelector:@selector(serializeString:to:) target:nil];
- #elseif ($TypeConverter.isAvroBoolean($array_element_schema))
- [self.utils serializeArray:self.${field_name} to:writer withSelector:@selector(serializeBoolean:to:) target:nil];
- #elseif ($TypeConverter.isAvroInt($array_element_schema))
- [self.utils serializeArray:self.${field_name} to:writer withSelector:@selector(serializeInt:to:) target:nil];
- #elseif ($TypeConverter.isAvroLong($array_element_schema))
- [self.utils serializeArray:self.${field_name} to:writer withSelector:@selector(serializeLong:to:) target:nil];
- #elseif ($TypeConverter.isAvroEnum($array_element_schema))
- [self.utils serializeArray:self.${field_name} to:writer withSelector:@selector(serializeEnum:to:) target:nil];
- #elseif ($TypeConverter.isAvroFloat($array_element_schema))
- [self.utils serializeArray:self.${field_name} to:writer withSelector:@selector(serializeFloat:to:) target:nil];
- #elseif ($TypeConverter.isAvroDouble($array_element_schema))
- [self.utils serializeArray:self.${field_name} to:writer withSelector:@selector(serializeDouble:to:) target:nil];
- #end
-#end
-#end
-#if ($schema.getFields().size() == 0)
- #pragma unused(writer)
-#end
-}
-
-- (size_t)getSize {
- size_t recordSize = 0;
-#foreach ($field in $schema.getFields())
-#set ($field_name = $field.name())
-#set ($field_schema = $field.schema())
-#if ($TypeConverter.isAvroRecord($field_schema) && $field_schema.getFields().size() > 0)
- recordSize += [self.${field_name} getSize];
-#elseif ($TypeConverter.isAvroUnion($field_schema))
-#set ($union_element_name = $StyleUtils.fixCamelHumps($field_name))
- recordSize += [self get${union_element_name}Size:self.${field_name}];
-#elseif ($TypeConverter.isAvroBytes($field_schema))
- recordSize += [self.utils getBytesSize:self.${field_name}];
-#elseif ($TypeConverter.isAvroFixed($field_schema))
- recordSize += [self.utils getFixedSize:self.${field_name}];
-#elseif ($TypeConverter.isAvroString($field_schema))
- recordSize += [self.utils getStringSize:self.${field_name}];
-#elseif ($TypeConverter.isAvroFloat($field_schema))
- recordSize += [self.utils getFloatSize];
-#elseif ($TypeConverter.isAvroDouble($field_schema))
- recordSize += [self.utils getDoubleSize];
-#elseif ($TypeConverter.isAvroBoolean($field_schema))
- recordSize += [self.utils getBooleanSize:@(self.${field_name})];
-#elseif ($TypeConverter.isAvroInt($field_schema))
- recordSize += [self.utils getIntSize:@(self.${field_name})];
-#elseif ($TypeConverter.isAvroLong($field_schema))
- recordSize += [self.utils getLongSize:@(self.${field_name})];
-#elseif ($TypeConverter.isAvroEnum($field_schema))
- recordSize += [self.utils getEnumSize:@(self.${field_name})];
-#elseif ($TypeConverter.isAvroArray($field_schema))
-#set ($array_element_schema = $field_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- recordSize += [self.utils getArraySize:self.${field_name} withSelector:@selector(getSize) parameterized:NO target:nil];
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- #set ($union_element_name = $StyleUtils.fixCamelHumps($field_name))
- recordSize += [self.utils getArraySize:self.${field_name} withSelector:@selector(get${union_element_name}Size:) parameterized:YES target:self];
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- recordSize += [self.utils getArraySize:self.${field_name} withSelector:@selector(getBytesSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- recordSize += [self.utils getArraySize:self.${field_name} withSelector:@selector(getFixedSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- recordSize += [self.utils getArraySize:self.${field_name} withSelector:@selector(getStringSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroFloat($array_element_schema))
- recordSize += [self.utils getArraySize:self.${field_name} withSelector:@selector(getFloatSize) parameterized:NO target:self.utils];
- #elseif ($TypeConverter.isAvroDouble($array_element_schema))
- recordSize += [self.utils getArraySize:self.${field_name} withSelector:@selector(getDoubleSize) parameterized:NO target:self.utils];
- #elseif ($TypeConverter.isAvroBoolean($array_element_schema))
- recordSize += [self.utils getArraySize:self.${field_name} withSelector:@selector(getBooleanSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroInt($array_element_schema))
- recordSize += [self.utils getArraySize:self.${field_name} withSelector:@selector(getIntSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroLong($array_element_schema))
- recordSize += [self.utils getArraySize:self.${field_name} withSelector:@selector(getLongSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroEnum($array_element_schema))
- recordSize += [self.utils getArraySize:self.${field_name} withSelector:@selector(getEnumSize:) parameterized:YES target:self.utils];
- #end
-#end
-#end
- return recordSize;
-}
-###end
-
-###if ($TypeConverter.isTypeIn($schema))
-- (void)deserialize:(avro_reader_t)reader {
-#foreach ($field in $schema.getFields())
-#set ($field_name = $field.name())
-#set ($field_schema = $field.schema())
-#if ($TypeConverter.isAvroRecord($field_schema))
-#set ($record_field_name = $field_schema.getName())
- self.${field_name} = ($namespacePrefix${record_field_name} *)[self.utils deserializeRecord:reader as:[$namespacePrefix${record_field_name} class]];
-#elseif ($TypeConverter.isAvroUnion($field_schema))
-#set ($union_element_name = $StyleUtils.fixCamelHumps($field_name))
- self.${field_name} = [self deserialize${union_element_name}:reader];
-#elseif ($TypeConverter.isAvroBytes($field_schema))
- self.${field_name} = [self.utils deserializeBytes:reader];
-#elseif ($TypeConverter.isAvroFixed($field_schema))
- NSNumber *size = @($field_schema.getFixedSize());
- self.${field_name} = [self.utils deserializeFixed:reader size:size];
-#elseif ($TypeConverter.isAvroString($field_schema))
- self.${field_name} = [self.utils deserializeString:reader];
-#elseif ($TypeConverter.isAvroEnum($field_schema))
- self.${field_name} = [[self.utils deserializeEnum:reader] intValue];
-#elseif ($TypeConverter.isAvroBoolean($field_schema))
- self.${field_name} = [[self.utils deserializeBoolean:reader] boolValue];
-#elseif ($TypeConverter.isAvroInt($field_schema))
- self.${field_name} = [[self.utils deserializeInt:reader] intValue];
-#elseif ($TypeConverter.isAvroLong($field_schema))
- self.${field_name} = [[self.utils deserializeLong:reader] longLongValue];
-#elseif ($TypeConverter.isAvroFloat($field_schema))
- self.${field_name} = [[self.utils deserializeFloat:reader] floatValue];
-#elseif ($TypeConverter.isAvroDouble($field_schema))
- self.${field_name} = [[self.utils deserializeDouble:reader] doubleValue];
-
-#elseif ($TypeConverter.isAvroArray($field_schema))
-#set ($array_element_schema = $field_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #set ($record_element_name = $array_element_schema.getName())
- Class recClass = [$namespacePrefix${record_element_name} class];
- self.${field_name} = [self.utils deserializeArray:reader withSelector:@selector(deserializeRecord:as:) andParam:recClass target:nil];
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- #set ($union_element_name = $StyleUtils.fixCamelHumps($field_name))
- self.${field_name} = [self deserialize${union_element_name}:reader];
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- self.${field_name} = [self.utils deserializeArray:reader withSelector:@selector(deserializeBytes:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- NSNumber *size = @($array_element_schema.getFixedSize());
- self.${field_name} = [self.utils deserializeArray:reader withSelector:@selector(deserializeFixed:size:) andParam:size target:nil];
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- self.${field_name} = [self.utils deserializeArray:reader withSelector:@selector(deserializeString:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroEnum($array_element_schema))
- self.${field_name} = [self.utils deserializeArray:reader withSelector:@selector(deserializeEnum:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroBoolean($array_element_schema))
- self.${field_name} = [self.utils deserializeArray:reader withSelector:@selector(deserializeBoolean:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroInt($array_element_schema))
- self.${field_name} = [self.utils deserializeArray:reader withSelector:@selector(deserializeInt:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroLong($array_element_schema))
- self.${field_name} = [self.utils deserializeArray:reader withSelector:@selector(deserializeLong:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroFloat($array_element_schema))
- self.${field_name} = [self.utils deserializeArray:reader withSelector:@selector(deserializeFloat:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroDouble($array_element_schema))
- self.${field_name} = [self.utils deserializeArray:reader withSelector:@selector(deserializeDouble:) andParam:nil target:nil];
- #end
-#end
-#end
-#if ($schema.getFields().size() == 0)
- #pragma unused(reader)
-#end
-}
-
-## Generating serialize/deserialize/getSize methods for Unions
-
-#if ($schema.getFields().size() > 0)
-#foreach ($field in $schema.getFields())
-#if ($TypeConverter.isAvroUnion($field.schema()))
-#set ($field_name = $StyleUtils.fixCamelHumps($field.name()))
-#set ($UNION_NAME = $TypeConverter.generateUnionName("KAA", $field.schema()))
-#set ($union_name = $UNION_NAME.toLowerCase())
-###if ($generationContext.isTypeOut())
-- (void)serialize${field_name}:(KAAUnion *)kaaUnion to:(avro_writer_t)writer {
-
- if (kaaUnion) {
- avro_binary_encoding.write_long(writer, kaaUnion.branch);
-
- switch (kaaUnion.branch) {
-#set ($branch_number = 0)
-#foreach ($branch_schema in $field.schema().getTypes())
-#if (!$TypeConverter.isAvroNull($branch_schema) && !($TypeConverter.isAvroRecord($branch_schema) && $branch_schema.getFields().size() == 0))
- case ${UNION_NAME}_BRANCH_${branch_number}:
- {
- if (kaaUnion.data) {
-#if ($TypeConverter.isAvroRecord($branch_schema))
- [self.utils serializeRecord:kaaUnion.data to:writer];
-#elseif ($TypeConverter.isAvroUnion($branch_schema))
- [self serialize${field_name}:kaaUnion.data to:writer];
-#elseif ($TypeConverter.isAvroBytes($branch_schema))
- [self.utils serializeBytes:kaaUnion.data to:writer];
-#elseif ($TypeConverter.isAvroFixed($branch_schema))
- [self.utils serializeFixed:kaaUnion.data to:writer];
-#elseif ($TypeConverter.isAvroString($branch_schema))
- [self.utils serializeString:kaaUnion.data to:writer];
-#elseif ($TypeConverter.isAvroBoolean($branch_schema))
- [self.utils serializeBoolean:kaaUnion.data to:writer];
-#elseif ($TypeConverter.isAvroInt($branch_schema))
- [self.utils serializeInt:kaaUnion.data to:writer];
-#elseif ($TypeConverter.isAvroLong($branch_schema))
- [self.utils serializeLong:kaaUnion.data to:writer];
-#elseif ($TypeConverter.isAvroEnum($branch_schema))
- [self.utils serializeEnum:kaaUnion.data to:writer];
-#elseif ($TypeConverter.isAvroFloat($branch_schema))
- [self.utils serializeFloat:kaaUnion.data to:writer];
-#elseif ($TypeConverter.isAvroDouble($branch_schema))
- [self.utils serializeDouble:kaaUnion.data to:writer];
-#elseif ($TypeConverter.isAvroArray($branch_schema))
-#set ($array_element_schema = $branch_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #if ($array_element_schema.getFields().size() > 0)
- [self.utils serializeArray:kaaUnion.data to:writer withSelector:@selector(serializeRecord:to:) target:nil];
- #end
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- [self.utils serializeArray:kaaUnion.data to:writer withSelector:@selector(serialize${field_name}:to:) target:self];
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- [self.utils serializeArray:kaaUnion.data to:writer withSelector:@selector(serializeBytes:to:) target:nil];
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- [self.utils serializeArray:kaaUnion.data to:writer withSelector:@selector(serializeFixed:to:) target:nil];
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- [self.utils serializeArray:kaaUnion.data to:writer withSelector:@selector(serializeString:to:) target:nil];
- #elseif ($TypeConverter.isAvroBoolean($array_element_schema))
- [self.utils serializeArray:kaaUnion.data to:writer withSelector:@selector(serializeBoolean:to:) target:nil];
- #elseif ($TypeConverter.isAvroInt($array_element_schema))
- [self.utils serializeArray:kaaUnion.data to:writer withSelector:@selector(serializeInt:to:) target:nil];
- #elseif ($TypeConverter.isAvroLong($array_element_schema))
- [self.utils serializeArray:kaaUnion.data to:writer withSelector:@selector(serializeLong:to:) target:nil];
- #elseif ($TypeConverter.isAvroEnum($array_element_schema))
- [self.utils serializeArray:kaaUnion.data to:writer withSelector:@selector(serializeEnum:to:) target:nil];
- #elseif ($TypeConverter.isAvroFloat($array_element_schema))
- [self.utils serializeArray:kaaUnion.data to:writer withSelector:@selector(serializeFloat:to:) target:nil];
- #elseif ($TypeConverter.isAvroDouble($array_element_schema))
- [self.utils serializeArray:kaaUnion.data to:writer withSelector:@selector(serializeDouble:to:) target:nil];
- #end
-#end
- }
- break;
- }
-#end
-#set ($branch_number = $branch_number + 1)
-#end
- default:
- break;
- }
- }
-}
-###end
-
-- (size_t)get${field_name}Size:(KAAUnion *)kaaUnion {
- size_t unionSize = [self.utils getLongSize:@(kaaUnion.branch)];
- if (kaaUnion) {
- switch (kaaUnion.branch) {
-#set ($branch_number = 0)
-#foreach ($branch_schema in $field.schema().getTypes())
-#if (!$TypeConverter.isAvroNull($branch_schema) && !($TypeConverter.isAvroRecord($branch_schema) && $branch_schema.getFields().size() == 0))
- case ${UNION_NAME}_BRANCH_${branch_number}:
- {
- if (kaaUnion.data) {
-#if ($TypeConverter.isAvroRecord($branch_schema))
- unionSize += [((id)kaaUnion.data) getSize];
-#elseif ($TypeConverter.isAvroUnion($branch_schema))
- unionSize += [self get${field_name}:kaaUnion.data];
-#elseif ($TypeConverter.isAvroBytes($branch_schema))
- unionSize += [self.utils getBytesSize:kaaUnion.data];
-#elseif ($TypeConverter.isAvroFixed($branch_schema))
- unionSize += [self.utils getFixedSize:kaaUnion.data];
-#elseif ($TypeConverter.isAvroString($branch_schema))
- unionSize += [self.utils getStringSize:kaaUnion.data];
-#elseif ($TypeConverter.isAvroBoolean($branch_schema))
- unionSize += [self.utils getBooleanSize:kaaUnion.data];
-#elseif ($TypeConverter.isAvroInt($branch_schema))
- unionSize += [self.utils getIntSize:kaaUnion.data];
-#elseif ($TypeConverter.isAvroLong($branch_schema))
- unionSize += [self.utils getLongSize:kaaUnion.data];
-#elseif ($TypeConverter.isAvroEnum($branch_schema))
- unionSize += [self.utils getEnumSize:kaaUnion.data];
-#elseif ($TypeConverter.isAvroFloat($branch_schema))
- unionSize += [self.utils getFloatSize];
-#elseif ($TypeConverter.isAvroDouble($branch_schema))
- unionSize += [self.utils getDoubleSize];
-#elseif ($TypeConverter.isAvroArray($branch_schema))
-#set ($array_element_schema = $branch_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #if ($array_element_schema.getFields().size() > 0)
- unionSize += [self.utils getArraySize:kaaUnion.data withSelector:@selector(getSize) parameterized:NO target:nil];
- #end
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- unionSize += [self.utils getArraySize:kaaUnion.data withSelector:@selector(get${field_name}Size:) parameterized:YES target:self];
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- unionSize += [self.utils getArraySize:kaaUnion.data withSelector:@selector(getBytesSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- unionSize += [self.utils getArraySize:kaaUnion.data withSelector:@selector(getFixedSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- unionSize += [self.utils getArraySize:kaaUnion.data withSelector:@selector(getStringSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroBoolean($array_element_schema))
- unionSize += [self.utils getArraySize:kaaUnion.data withSelector:@selector(getBooleanSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroInt($array_element_schema))
- unionSize += [self.utils getArraySize:kaaUnion.data withSelector:@selector(getIntSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroLong($array_element_schema))
- unionSize += [self.utils getArraySize:kaaUnion.data withSelector:@selector(getLongSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroEnum($array_element_schema))
- unionSize += [self.utils getArraySize:kaaUnion.data withSelector:@selector(getEnumSize:) parameterized:YES target:self.utils];
- #elseif ($TypeConverter.isAvroFloat($array_element_schema))
- unionSize += [self.utils getArraySize:kaaUnion.data withSelector:@selector(getFloatSize) parameterized:NO target:self.utils];
- #elseif ($TypeConverter.isAvroDouble($array_element_schema))
- unionSize += [self.utils getArraySize:kaaUnion.data withSelector:@selector(getDoubleSize) parameterized:NO target:self.utils];
- #end
-#end
- }
- break;
- }
-#end
-#set ($branch_number = $branch_number + 1)
-#end
- default:
- break;
- }
- }
- return unionSize;
-}
-
-###if ($generationContext.isTypeIn())
-- (KAAUnion *)deserialize${field_name}:(avro_reader_t)reader {
-
- KAAUnion *kaaUnion = [[KAAUnion alloc] init];
-
- int64_t branch;
- avro_binary_encoding.read_long(reader, &branch);
- kaaUnion.branch = (int)branch;
-
- switch (kaaUnion.branch) {
-#set ($branch_number = 0)
-#foreach ($branch_schema in $field.schema().getTypes())
-#if (!$TypeConverter.isAvroNull($branch_schema))
- case ${UNION_NAME}_BRANCH_${branch_number}: {
-#if ($TypeConverter.isAvroRecord($branch_schema))
-#set ($sub_record_name = $branch_schema.getName())
- kaaUnion.data = [self.utils deserializeRecord:reader as:[$namespacePrefix${sub_record_name} class]];
-#elseif ($TypeConverter.isAvroUnion($branch_schema))
- kaaUnion.data = [self deserialize${field_name}:reader];
-#elseif ($TypeConverter.isAvroBytes($branch_schema))
- kaaUnion.data = [self.utils deserializeBytes:reader];
-#elseif ($TypeConverter.isAvroFixed($branch_schema))
- NSNumber *size = @($branch_schema.getFixedSize());
- kaaUnion.data = [self.utils deserializeFixed:reader size:size];
-#elseif ($TypeConverter.isAvroString($branch_schema))
- kaaUnion.data = [self.utils deserializeString:reader];
-#elseif ($TypeConverter.isAvroEnum($branch_schema))
- kaaUnion.data = [self.utils deserializeEnum:reader];
-#elseif ($TypeConverter.isAvroBoolean($branch_schema))
- kaaUnion.data = [self.utils deserializeBoolean:reader];
-#elseif ($TypeConverter.isAvroInt($branch_schema))
- kaaUnion.data = [self.utils deserializeInt:reader];
-#elseif ($TypeConverter.isAvroLong($branch_schema))
- kaaUnion.data = [self.utils deserializeLong:reader];
-#elseif ($TypeConverter.isAvroFloat($branch_schema))
- kaaUnion.data = [self.utils deserializeFloat:reader];
-#elseif ($TypeConverter.isAvroDouble($branch_schema))
- kaaUnion.data = [self.utils deserializeDouble:reader];
-#elseif ($TypeConverter.isAvroArray($branch_schema))
-#set ($array_element_schema = $branch_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #set ($record_element_name = $array_element_schema.getName())
- Class dataClass = [$namespacePrefix${record_element_name} class];
- kaaUnion.data = [self.utils deserializeArray:reader withSelector:@selector(deserializeRecord:as:) andParam:dataClass target:nil];
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- kaaUnion.data = [self.utils deserializeArray:reader withSelector:@selector(deserialize${field_name}:) andParam:nil target:self];
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- kaaUnion.data = [self.utils deserializeArray:reader withSelector:@selector(deserializeBytes:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- NSNumber *size = @($branch_schema.getFixedSize());
- kaaUnion.data = [self.utils deserializeArray:reader withSelector:@selector(deserializeFixed:size:) andParam:size target:nil];
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- kaaUnion.data = [self.utils deserializeArray:reader withSelector:@selector(deserializeString:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroEnum($array_element_schema))
- kaaUnion.data = [self.utils deserializeArray:reader withSelector:@selector(deserializeEnum:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroBoolean($array_element_schema))
- kaaUnion.data = [self.utils deserializeArray:reader withSelector:@selector(deserializeBoolean:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroInt($array_element_schema))
- kaaUnion.data = [self.utils deserializeArray:reader withSelector:@selector(deserializeInt:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroLong($array_element_schema))
- kaaUnion.data = [self.utils deserializeArray:reader withSelector:@selector(deserializeLong:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroFloat($array_element_schema))
- kaaUnion.data = [self.utils deserializeArray:reader withSelector:@selector(deserializeFloat:) andParam:nil target:nil];
- #elseif ($TypeConverter.isAvroDouble($array_element_schema))
- kaaUnion.data = [self.utils deserializeArray:reader withSelector:@selector(deserializeDouble:) andParam:nil target:nil];
- #end
-#end
- break;
- }
-#end
-#set ($branch_number = $branch_number + 1)
-#end
- default:
- break;
- }
-
- return kaaUnion;
-}
-###end
-
-#end
-#end
-#end
-@end
-###end
\ No newline at end of file
diff --git a/avrogen/src/main/resources/ObjC/sourceObjC.tmpl b/avrogen/src/main/resources/ObjC/sourceObjC.tmpl
deleted file mode 100644
index e97dd775f6..0000000000
--- a/avrogen/src/main/resources/ObjC/sourceObjC.tmpl
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#import "${headerName}.h"
-
-/*
- * AUTO-GENERATED CODE
- */
\ No newline at end of file
diff --git a/avrogen/src/main/resources/enum.h.vm b/avrogen/src/main/resources/enum.h.vm
deleted file mode 100644
index bb32e4a286..0000000000
--- a/avrogen/src/main/resources/enum.h.vm
+++ /dev/null
@@ -1,43 +0,0 @@
-#*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *#
-
-#set ($ENUM_NAME = $StyleUtils.toUpperUnderScore($schema.getName()))
-#set ($enum_name = $StyleUtils.toLowerUnderScore($schema.getName()))
-
-#set ($PREFIX = $StyleUtils.toUpperUnderScore($namespacePrefix))
-#set ($prefix = $StyleUtils.toLowerUnderScore($namespacePrefix))
-typedef enum {
-#foreach ($symbol in $symbols)
- ENUM_${ENUM_NAME}_$symbol,
-#end
-} ${prefix}_${enum_name}_t;
-
-#ifdef GENC_ENUM_DEFINE_ALIASES
-#foreach ($symbol in $symbols)
-\#define $symbol ENUM_${ENUM_NAME}_$symbol
-#end
-# endif // GENC_ENUM_DEFINE_ALIASES
-
-#ifdef GENC_ENUM_STRING_LITERALS
-#set($sym_count = $symbols.size())
-const char* ${PREFIX}_${ENUM_NAME}_SYMBOLS[$sym_count] = {
-#foreach ($symbol in $symbols)
- "${symbol}"#set($sym_count = $sym_count - 1)#if ($sym_count > 0),
-#end
-#end
-};
-# endif // GENC_ENUM_STRING_LITERALS
-
diff --git a/avrogen/src/main/resources/header.tmpl b/avrogen/src/main/resources/header.tmpl
deleted file mode 100644
index 9042a6a655..0000000000
--- a/avrogen/src/main/resources/header.tmpl
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#set ($headerGuard = $headerName.toUpperCase())
-# ifndef ${headerGuard}_H_
-# define ${headerGuard}_H_
-
-# include "kaa_common_schema.h"
-# include "collections/kaa_list.h"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
diff --git a/avrogen/src/main/resources/record.c.vm b/avrogen/src/main/resources/record.c.vm
deleted file mode 100644
index ff4701196c..0000000000
--- a/avrogen/src/main/resources/record.c.vm
+++ /dev/null
@@ -1,271 +0,0 @@
-#*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *#
-
-#set ($PREFIX = $StyleUtils.toUpperUnderScore($namespacePrefix))
-#set ($prefix = $StyleUtils.toLowerUnderScore($namespacePrefix))
-#set ($record_name = $StyleUtils.toLowerUnderScore($schema.getName()))
-#set ($is_destructor_needed = $TypeConverter.isRecordNeedDeallocator($schema))
-#if ($is_destructor_needed)
-static void ${prefix}_${record_name}_destroy(void *data)
-{
- if (data) {
- ${prefix}_${record_name}_t *record = (${prefix}_${record_name}_t *)data;
-
-#foreach ($field in $schema.getFields())
-#set ($field_name = $StyleUtils.toLowerUnderScore($field.name()))
-#set ($field_schema = $field.schema())
-#if ($TypeConverter.isAvroRecord($field_schema) || $TypeConverter.isAvroUnion($field_schema))
- if (record->${field_name} && record->${field_name}->destroy) {
- record->${field_name}->destroy(record->${field_name});
- }
-#elseif ($TypeConverter.isAvroBytes($field_schema))
- kaa_bytes_destroy(record->${field_name});
-#elseif ($TypeConverter.isAvroFixed($field_schema))
- kaa_fixed_destroy(record->${field_name});
-#elseif ($TypeConverter.isAvroString($field_schema))
- kaa_string_destroy(record->${field_name});
-#elseif ($TypeConverter.isAvroArray($field_schema))
-#set ($array_element_schema = $field_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #if ($TypeConverter.isRecordNeedDeallocator($array_element_schema))
- #set ($array_record_name = $StyleUtils.toLowerUnderScore($array_element_schema.getName()))
- kaa_list_destroy(record->${field_name}, ${prefix}_${array_record_name}_destroy);
- #else
- kaa_list_destroy(record->${field_name}, kaa_data_destroy);
- #end
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- #set ($array_union_name = $TypeConverter.generateUnionName($PREFIX, $array_element_schema).toLowerCase())
- kaa_list_destroy(record->${field_name}, ${array_union_name}_destroy);
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- kaa_list_destroy(record->${field_name}, kaa_bytes_destroy);
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- kaa_list_destroy(record->${field_name}, kaa_fixed_destroy);
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- kaa_list_destroy(record->${field_name}, kaa_string_destroy);
- #elseif ($TypeConverter.isAvroPrimitive($array_element_schema))
- kaa_list_destroy(record->${field_name}, kaa_data_destroy);
- #end
-#end
-#end
- kaa_data_destroy(record);
- }
-}
-#end
-
-#if ($TypeConverter.isTypeOut($schema))
-#if ($schema.getFields().size() > 0)
-static void ${prefix}_${record_name}_serialize(avro_writer_t writer, void *data)
-{
- if (data) {
- ${prefix}_${record_name}_t *record = (${prefix}_${record_name}_t *)data;
-
-#foreach ($field in $schema.getFields())
-#set ($field_name = $StyleUtils.toLowerUnderScore($field.name()))
-#set ($field_schema = $field.schema())
-#if ($TypeConverter.isAvroRecord($field_schema) && $field_schema.getFields().size() > 0)
- record->${field_name}->serialize(writer, record->${field_name});
-#elseif ($TypeConverter.isAvroUnion($field_schema))
- record->${field_name}->serialize(writer, record->${field_name});
-#elseif ($TypeConverter.isAvroBytes($field_schema))
- kaa_bytes_serialize(writer, record->${field_name});
-#elseif ($TypeConverter.isAvroFixed($field_schema))
- kaa_fixed_serialize(writer, record->${field_name});
-#elseif ($TypeConverter.isAvroString($field_schema))
- kaa_string_serialize(writer, record->${field_name});
-#elseif ($TypeConverter.isAvroPrimitive($field_schema))
-#set ($primitive_type = $field_schema.getType().toString().toLowerCase())
- kaa_${primitive_type}_serialize(writer, &record->${field_name});
-#elseif ($TypeConverter.isAvroArray($field_schema))
-#set ($array_element_schema = $field_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #if ($array_element_schema.getFields().size() > 0)
- #set ($record_element_name = $StyleUtils.toLowerUnderScore($array_element_schema.getName()))
- kaa_array_serialize(writer, record->${field_name}, ${prefix}_${record_element_name}_serialize);
- #else
- kaa_array_serialize(writer, record->${field_name}, NULL);
- #end
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- #set ($union_element_name = $TypeConverter.generateUnionName($PREFIX, $array_element_schema).toLowerCase())
- kaa_array_serialize(writer, record->${field_name}, ${union_element_name}_serialize);
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- kaa_array_serialize(writer, record->${field_name}, kaa_bytes_serialize);
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- kaa_array_serialize(writer, record->${field_name}, kaa_fixed_serialize);
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- kaa_array_serialize(writer, record->${field_name}, kaa_string_serialize);
- #elseif ($TypeConverter.isAvroPrimitive($array_element_schema))
- #set ($primitive_type = $array_element_schema.getType().toString().toLowerCase())
- kaa_array_serialize(writer, record->${field_name}, kaa_${primitive_type}_serialize);
- #end
-#end
-#end
- }
-}
-
-static size_t ${prefix}_${record_name}_get_size(void *data)
-{
- if (data) {
- size_t record_size = 0;
- ${prefix}_${record_name}_t *record = (${prefix}_${record_name}_t *)data;
-
-#foreach ($field in $schema.getFields())
-#set ($field_name = $StyleUtils.toLowerUnderScore($field.name()))
-#set ($field_schema = $field.schema())
-#if ($TypeConverter.isAvroRecord($field_schema) && $field_schema.getFields().size() > 0)
- record_size += record->${field_name}->get_size(record->${field_name});
-#elseif ($TypeConverter.isAvroUnion($field_schema))
- record_size += record->${field_name}->get_size(record->${field_name});
-#elseif ($TypeConverter.isAvroBytes($field_schema))
- record_size += kaa_bytes_get_size(record->${field_name});
-#elseif ($TypeConverter.isAvroFixed($field_schema))
- record_size += kaa_fixed_get_size(record->${field_name});
-#elseif ($TypeConverter.isAvroString($field_schema))
- record_size += kaa_string_get_size(record->${field_name});
-#elseif ($TypeConverter.isAvroFloat($field_schema))
- record_size += AVRO_FLOAT_SIZE;
-#elseif ($TypeConverter.isAvroDouble($field_schema))
- record_size += AVRO_DOUBLE_SIZE;
-#elseif ($TypeConverter.isAvroPrimitive($field_schema))
-#set ($primitive_type = $field_schema.getType().toString().toLowerCase())
- record_size += kaa_${primitive_type}_get_size(&record->${field_name});
-#elseif ($TypeConverter.isAvroArray($field_schema))
-#set ($array_element_schema = $field_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #if ($array_element_schema.getFields().size() > 0)
- #set ($array_record_name = $StyleUtils.toLowerUnderScore($array_element_schema.getName()))
- record_size += kaa_array_get_size(record->${field_name}, ${prefix}_${array_record_name}_get_size);
- #else
- record_size += kaa_array_get_size(record->${field_name}, kaa_null_get_size);
- #end
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- #set ($array_union_name = $TypeConverter.generateUnionName($PREFIX, $array_element_schema).toLowerCase())
- record_size += kaa_array_get_size(record->${field_name}, ${array_union_name}_get_size);
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- record_size += kaa_array_get_size(record->${field_name}, kaa_bytes_get_size);
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- record_size += kaa_array_get_size(record->${field_name}, kaa_fixed_get_size);
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- record_size += kaa_array_get_size(record->${field_name}, kaa_string_get_size);
- #elseif ($TypeConverter.isAvroPrimitive($array_element_schema))
- #set ($primitive_type = $array_element_schema.getType().toString().toLowerCase())
- record_size += kaa_array_get_size(record->${field_name}, kaa_${primitive_type}_get_size);
- #end
-#end
-#end
-
- return record_size;
- }
-
- return 0;
-}
-#end
-
-${prefix}_${record_name}_t *${prefix}_${record_name}_create(void)
-{
- ${prefix}_${record_name}_t *record =
- (${prefix}_${record_name}_t *)KAA_CALLOC(1, sizeof(${prefix}_${record_name}_t));
-
- if (record) {
-#if ($schema.getFields().size() > 0)
- record->serialize = ${prefix}_${record_name}_serialize;
- record->get_size = ${prefix}_${record_name}_get_size;
-#else
- record->serialize = kaa_null_serialize;
- record->get_size = kaa_null_get_size;
-#end
-#if ($is_destructor_needed)
- record->destroy = ${prefix}_${record_name}_destroy;
-#else
- record->destroy = kaa_data_destroy;
-#end
- }
-
- return record;
-}
-#end
-#if ($TypeConverter.isTypeIn($schema))
-
-${prefix}_${record_name}_t *${prefix}_${record_name}_deserialize(avro_reader_t reader)
-{
- ${prefix}_${record_name}_t *record =
- (${prefix}_${record_name}_t *)KAA_MALLOC(sizeof(${prefix}_${record_name}_t));
-
- if (record) {
-#if ($TypeConverter.isTypeOut($schema))
-#if ($schema.getFields().size() > 0)
- record->serialize = ${prefix}_${record_name}_serialize;
- record->get_size = ${prefix}_${record_name}_get_size;
-#else
- record->serialize = kaa_null_serialize;
- record->get_size = kaa_null_get_size;
-#end
-#end
-#if ($is_destructor_needed)
- record->destroy = ${prefix}_${record_name}_destroy;
-#else
- record->destroy = kaa_data_destroy;
-#end
-
-#foreach ($field in $schema.getFields())
-#set ($field_name = $StyleUtils.toLowerUnderScore($field.name()))
-#set ($field_schema = $field.schema())
-#if ($TypeConverter.isAvroRecord($field_schema))
-#set ($record_field_name = $StyleUtils.toLowerUnderScore($field_schema.getName()))
- record->$field_name = ${prefix}_${record_field_name}_deserialize(reader);
-#elseif ($TypeConverter.isAvroUnion($field_schema))
-#set ($union_field_name = $TypeConverter.generateUnionName($PREFIX, $field_schema).toLowerCase())
- record->$field_name = ${union_field_name}_deserialize(reader);
-#elseif ($TypeConverter.isAvroBytes($field_schema))
- record->${field_name} = kaa_bytes_deserialize(reader);
-#elseif ($TypeConverter.isAvroFixed($field_schema))
- size_t ${field_name}_fixed_size = $field_schema.getFixedSize();
- record->${field_name} = kaa_fixed_deserialize(reader, &${field_name}_fixed_size);
-#elseif ($TypeConverter.isAvroString($field_schema))
- record->${field_name} = kaa_string_deserialize(reader);
-#elseif ($TypeConverter.isAvroEnum($field_schema))
- int64_t ${field_name}_value;
- avro_binary_encoding.read_long(reader, &${field_name}_value);
- record->$field_name = ${field_name}_value;
-#elseif ($TypeConverter.isAvroPrimitive($field_schema))
-#set ($primitive_type = $field_schema.getType().toString().toLowerCase())
- avro_binary_encoding.read_${primitive_type}(reader, &record->${field_name});
-#elseif ($TypeConverter.isAvroArray($field_schema))
-#set ($array_element_schema = $field_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #set ($record_element_name = $StyleUtils.toLowerUnderScore($array_element_schema.getName()))
- record->${field_name} = kaa_array_deserialize_wo_ctx(reader, (deserialize_wo_ctx_fn)${prefix}_${record_element_name}_deserialize);
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- #set ($union_element_name = $TypeConverter.generateUnionName($PREFIX, $array_element_schema).toLowerCase())
- record->${field_name} = kaa_array_deserialize_wo_ctx(reader, (deserialize_wo_ctx_fn)${union_element_name}_deserialize);
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- record->${field_name} = kaa_array_deserialize_wo_ctx(reader, (deserialize_wo_ctx_fn)kaa_bytes_deserialize);
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- size_t ${field_name}_fixed_size = $array_element_schema.getFixedSize();
- record->${field_name} = kaa_array_deserialize_w_ctx(reader, (deserialize_w_ctx_fn)kaa_fixed_deserialize, &${field_name}_fixed_size);
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- record->${field_name} = kaa_array_deserialize_wo_ctx(reader, (deserialize_wo_ctx_fn)kaa_string_deserialize);
- #elseif ($TypeConverter.isAvroPrimitive($array_element_schema))
- #set ($primitive_type = $array_element_schema.getType().toString().toLowerCase())
- record->${field_name} = kaa_array_deserialize_wo_ctx(reader, (deserialize_wo_ctx_fn)kaa_${primitive_type}_deserialize);
- #end
-#end
-#end
- }
-
- return record;
-}
-#end
-
diff --git a/avrogen/src/main/resources/record.h.vm b/avrogen/src/main/resources/record.h.vm
deleted file mode 100644
index fc9e8c97bd..0000000000
--- a/avrogen/src/main/resources/record.h.vm
+++ /dev/null
@@ -1,39 +0,0 @@
-#*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *#
-
-#set ($prefix = $StyleUtils.toLowerUnderScore($namespacePrefix))
-#set ($record_name = $StyleUtils.toLowerUnderScore($schema.getName()))
-typedef struct {
-#foreach ($field in $schema.getFields())
-#set ($field_type = $TypeConverter.convertToCType($prefix, $field.schema()))
-#set ($field_name = $StyleUtils.toLowerUnderScore($field.name()))
- ${field_type} ${field_name};
-#end
-
-#if ($TypeConverter.isTypeOut($schema))
- serialize_fn serialize;
- get_size_fn get_size;
-#end
- destroy_fn destroy;
-} ${prefix}_${record_name}_t;
-
-#if ($TypeConverter.isTypeOut($schema))
-${prefix}_${record_name}_t *${prefix}_${record_name}_create(void);
-#end
-#if ($TypeConverter.isTypeIn($schema))
-${prefix}_${record_name}_t *${prefix}_${record_name}_deserialize(avro_reader_t reader);
-#end
-
diff --git a/avrogen/src/main/resources/source.tmpl b/avrogen/src/main/resources/source.tmpl
deleted file mode 100644
index 5435d978e3..0000000000
--- a/avrogen/src/main/resources/source.tmpl
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# include
-# include
-# include "platform/stdio.h"
-# include "${headerName}.h"
-# include "avro_src/avro/io.h"
-# include "avro_src/encoding.h"
-# include "utilities/kaa_mem.h"
-
-/*
- * AUTO-GENERATED CODE
- */
-
diff --git a/avrogen/src/main/resources/union.c.vm b/avrogen/src/main/resources/union.c.vm
deleted file mode 100644
index bd3e787f89..0000000000
--- a/avrogen/src/main/resources/union.c.vm
+++ /dev/null
@@ -1,319 +0,0 @@
-#*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *#
-
-#set ($PREFIX = $StyleUtils.toUpperUnderScore($namespacePrefix))
-#set ($prefix = $StyleUtils.toLowerUnderScore($namespacePrefix))
-#set ($UNION_NAME = $TypeConverter.generateUnionName($PREFIX, $schema))
-#set ($union_name = $UNION_NAME.toLowerCase())
-# ifndef ${UNION_NAME}_C_
-# define ${UNION_NAME}_C_
-static void ${union_name}_destroy(void *data)
-{
- if (data) {
- kaa_union_t *kaa_union = (kaa_union_t *)data;
-
- switch (kaa_union->type) {
-#set ($branch_number = 0)
-#foreach ($branch_schema in $schema.getTypes())
-#if (!$TypeConverter.isAvroNull($branch_schema))
- case ${UNION_NAME}_BRANCH_${branch_number}:
- {
- if (kaa_union->data) {
-#if ($TypeConverter.isAvroRecord($branch_schema))
-#set ($sub_record_name = $StyleUtils.toLowerUnderScore($branch_schema.getName()))
- ${prefix}_${sub_record_name}_t *record = (${prefix}_${sub_record_name}_t *)kaa_union->data;
- record->destroy(record);
-#elseif ($TypeConverter.isAvroUnion($branch_schema))
-#set ($sub_union_name = $TypeConverter.generateUnionName($branch_schema).toLowerCase())
- ${prefix}_${sub_union_name}_t *kaa_sub_union = (${prefix}_${sub_union_name}_t *)kaa_union->data;
- kaa_sub_union->destroy(kaa_sub_union);
-#elseif ($TypeConverter.isAvroBytes($branch_schema))
- kaa_bytes_destroy(kaa_union->data);
-#elseif ($TypeConverter.isAvroFixed($branch_schema))
- kaa_fixed_destroy(kaa_union->data);
-#elseif ($TypeConverter.isAvroString($branch_schema))
- kaa_string_destroy(kaa_union->data);
-#elseif ($TypeConverter.isAvroPrimitive($branch_schema))
- kaa_data_destroy(kaa_union->data);
-#elseif ($TypeConverter.isAvroArray($branch_schema))
-#set ($array_element_schema = $branch_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #if ($TypeConverter.isRecordNeedDeallocator($array_element_schema))
- #set ($array_record_name = $StyleUtils.toLowerUnderScore($array_element_schema.getName()))
- kaa_list_destroy(kaa_union->data, ${prefix}_${array_record_name}_destroy);
- #else
- kaa_list_destroy(kaa_union->data, kaa_data_destroy);
- #end
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- #set ($array_union_name = $TypeConverter.generateUnionName($PREFIX, $array_element_schema).toLowerCase())
- kaa_list_destroy(kaa_union->data, ${array_union_name}_destroy);
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- kaa_list_destroy(kaa_union->data, kaa_bytes_destroy);
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- kaa_list_destroy(kaa_union->data, kaa_fixed_destroy);
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- kaa_list_destroy(kaa_union->data, kaa_string_destroy);
- #elseif ($TypeConverter.isAvroPrimitive($array_element_schema))
- kaa_list_destroy(kaa_union->data, kaa_data_destroy);
- #end
-#end
- }
- break;
- }
-#end
-#set ($branch_number = $branch_number + 1)
-#end
- default:
- break;
- }
-
- kaa_data_destroy(kaa_union);
- }
-}
-#if ($generationContext.isTypeOut())
-
-static size_t ${union_name}_get_size(void *data)
-{
- if (data) {
- kaa_union_t *kaa_union = (kaa_union_t *)data;
- size_t union_size = avro_long_get_size(kaa_union->type);
-
- switch (kaa_union->type) {
-#set ($branch_number = 0)
-#foreach ($branch_schema in $schema.getTypes())
-#if (!$TypeConverter.isAvroNull($branch_schema) && !($TypeConverter.isAvroRecord($branch_schema) && $branch_schema.getFields().size() == 0))
- case ${UNION_NAME}_BRANCH_${branch_number}:
- {
- if (kaa_union->data) {
-#if ($TypeConverter.isAvroRecord($branch_schema))
-#set ($record_type = $TypeConverter.convertToCType($prefix, $branch_schema))
- $record_type record = (${record_type})kaa_union->data;
- union_size += record->get_size(record);
-#elseif ($TypeConverter.isAvroUnion($branch_schema))
- kaa_union_t *kaa_union = (kaa_union_t *)kaa_union->data;
- union_size += kaa_union->get_size(kaa_union);
-#elseif ($TypeConverter.isAvroBytes($branch_schema))
- union_size += kaa_bytes_get_size(kaa_union->data);
-#elseif ($TypeConverter.isAvroFixed($branch_schema))
- union_size += kaa_fixed_get_size(kaa_union->data);
-#elseif ($TypeConverter.isAvroString($branch_schema))
- union_size += kaa_string_get_size(kaa_union->data);
-#elseif ($TypeConverter.isAvroFloat($branch_schema))
- union_size += AVRO_FLOAT_SIZE;
-#elseif ($TypeConverter.isAvroDouble($branch_schema))
- union_size += AVRO_DOUBLE_SIZE;
-#elseif ($TypeConverter.isAvroPrimitive($branch_schema))
-#set ($primitive_type = $branch_schema.getType().toString().toLowerCase())
- union_size += kaa_${primitive_type}_get_size(kaa_union->data);
-#elseif ($TypeConverter.isAvroArray($branch_schema))
-#set ($array_element_schema = $branch_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #if ($array_element_schema.getFields().size() > 0)
- #set ($array_record_name = $StyleUtils.toLowerUnderScore($array_element_schema.getName()))
- union_size += kaa_array_get_size(kaa_union->data, ${prefix}_${array_record_name}_get_size);
- #else
- union_size += kaa_array_get_size(kaa_union->data, kaa_null_get_size);
- #end
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- #set ($array_union_name = $TypeConverter.generateUnionName($PREFIX, $array_element_schema).toLowerCase())
- union_size += kaa_array_get_size(kaa_union->data, ${array_union_name}_get_size);
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- union_size += kaa_array_get_size(kaa_union->data, kaa_bytes_get_size);
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- union_size += kaa_array_get_size(kaa_union->data, kaa_fixed_get_size);
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- union_size += kaa_array_get_size(kaa_union->data, kaa_string_get_size);
- #elseif ($TypeConverter.isAvroPrimitive($array_element_schema))
- #set ($primitive_type = $array_element_schema.getType().toString().toLowerCase())
- union_size += kaa_array_get_size(kaa_union->data, kaa_${primitive_type}_get_size);
- #end
-#end
- }
- break;
- }
-#end
-#set ($branch_number = $branch_number + 1)
-#end
- default:
- break;
- }
-
- return union_size;
- }
-
- return 0;
-}
-
-static void ${union_name}_serialize(avro_writer_t writer, void *data)
-{
- if (data) {
- kaa_union_t *kaa_union = (kaa_union_t *)data;
- avro_binary_encoding.write_long(writer, kaa_union->type);
-
- switch (kaa_union->type) {
-#set ($branch_number = 0)
-#foreach ($branch_schema in $schema.getTypes())
-#if (!$TypeConverter.isAvroNull($branch_schema) && !($TypeConverter.isAvroRecord($branch_schema) && $branch_schema.getFields().size() == 0))
- case ${UNION_NAME}_BRANCH_${branch_number}:
- {
- if (kaa_union->data) {
-#if ($TypeConverter.isAvroRecord($branch_schema))
-#set ($record_type = $TypeConverter.convertToCType($prefix, $branch_schema))
- $record_type record = (${record_type})kaa_union->data;
- record->serialize(writer, record);
-#elseif ($TypeConverter.isAvroUnion($branch_schema))
- kaa_union_t *kaa_union = (kaa_union_t *)kaa_union->data;
- kaa_union->serialize(writer, kaa_union);
-#elseif ($TypeConverter.isAvroBytes($branch_schema))
- kaa_bytes_serialize(writer, kaa_union->data);
-#elseif ($TypeConverter.isAvroFixed($branch_schema))
- kaa_fixed_serialize(writer, kaa_union->data);
-#elseif ($TypeConverter.isAvroString($branch_schema))
- kaa_string_serialize(writer, kaa_union->data);
-#elseif ($TypeConverter.isAvroPrimitive($branch_schema))
-#set ($primitive_type = $branch_schema.getType().toString().toLowerCase())
- kaa_${primitive_type}_serialize(writer, kaa_union->data);
-#elseif ($TypeConverter.isAvroArray($branch_schema))
-#set ($array_element_schema = $branch_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #if ($array_element_schema.getFields().size() > 0)
- #set ($record_element_name = $StyleUtils.toLowerUnderScore($array_element_schema.getName()))
- kaa_array_serialize(writer, kaa_union->data, ${prefix}_${record_element_name}_serialize);
- #else
- kaa_array_serialize(writer, kaa_union->data, NULL);
- #end
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- #set ($union_element_name = $TypeConverter.generateUnionName($PREFIX, $array_element_schema).toLowerCase())
- kaa_array_serialize(writer, kaa_union->data, ${union_element_name}_serialize);
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- kaa_array_serialize(writer, kaa_union->data, kaa_bytes_serialize);
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- kaa_array_serialize(writer, kaa_union->data, kaa_fixed_serialize);
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- kaa_array_serialize(writer, kaa_union->data, kaa_string_serialize);
- #elseif ($TypeConverter.isAvroPrimitive($array_element_schema))
- #set ($primitive_type = $array_element_schema.getType().toString().toLowerCase())
- kaa_array_serialize(writer, kaa_union->data, kaa_${primitive_type}_serialize);
- #end
-#end
- }
- break;
- }
-#end
-#set ($branch_number = $branch_number + 1)
-#end
- default:
- break;
- }
- }
-}
-#end
-static kaa_union_t *${union_name}_create(void)
-{
- kaa_union_t *kaa_union = KAA_CALLOC(1, sizeof(kaa_union_t));
-
- if (kaa_union) {
-#if ($generationContext.isTypeOut())
- kaa_union->serialize = ${union_name}_serialize;
- kaa_union->get_size = ${union_name}_get_size;
-#end
- kaa_union->destroy = ${union_name}_destroy;
- }
-
- return kaa_union;
-}
-#if ($generationContext.isTypeOut())
-#set ($branch_number = 0)
-#foreach ($branch_schema in $schema.getTypes())
-
-kaa_union_t *${union_name}_branch_${branch_number}_create(void)
-{
- kaa_union_t *kaa_union = ${union_name}_create();
- if (kaa_union) {
- kaa_union->type = ${UNION_NAME}_BRANCH_${branch_number};
- }
- return kaa_union;
-}
-#set ($branch_number = $branch_number + 1)
-#end
-#end
-#if ($generationContext.isTypeIn())
-
-kaa_union_t *${union_name}_deserialize(avro_reader_t reader)
-{
- kaa_union_t *kaa_union = ${union_name}_create();
-
- if (kaa_union) {
- int64_t branch;
- avro_binary_encoding.read_long(reader, &branch);
- kaa_union->type = branch;
-
- switch (kaa_union->type) {
-#set ($branch_number = 0)
-#foreach ($branch_schema in $schema.getTypes())
-#if (!$TypeConverter.isAvroNull($branch_schema))
- case ${UNION_NAME}_BRANCH_${branch_number}: {
-#if ($TypeConverter.isAvroRecord($branch_schema))
-#set ($sub_record_name = $StyleUtils.toLowerUnderScore($branch_schema.getName()))
- kaa_union->data = ${prefix}_${sub_record_name}_deserialize(reader);
-#elseif ($TypeConverter.isAvroUnion($branch_schema))
-#set ($sub_union_name = $TypeConverter.generateUnionName($PREFIX, $branch_schema).toLowerCase())
- kaa_union->data = ${sub_union_name}_deserialize(reader);
-#elseif ($TypeConverter.isAvroBytes($branch_schema))
- kaa_union->data = kaa_bytes_deserialize(reader);
-#elseif ($TypeConverter.isAvroFixed($branch_schema))
- size_t fixed_size = $branch_schema.getFixedSize();
- kaa_union->data = kaa_fixed_deserialize(reader, &fixed_size);
-#elseif ($TypeConverter.isAvroString($branch_schema))
- kaa_union->data = kaa_string_deserialize(reader);
-#elseif ($TypeConverter.isAvroPrimitive($branch_schema))
-#set ($primitive_type = $branch_schema.getType().toString().toLowerCase())
- kaa_union->data = kaa_${primitive_type}_deserialize(reader);
-#elseif ($TypeConverter.isAvroArray($branch_schema))
-#set ($array_element_schema = $branch_schema.getElementType())
- #if ($TypeConverter.isAvroRecord($array_element_schema))
- #set ($record_element_name = $StyleUtils.toLowerUnderScore($array_element_schema.getName()))
- kaa_union->data = kaa_array_deserialize_wo_ctx(reader, (deserialize_wo_ctx_fn)${prefix}_${record_element_name}_deserialize);
- #elseif ($TypeConverter.isAvroUnion($array_element_schema))
- #set ($union_element_name = $TypeConverter.generateUnionName($PREFIX, $array_element_schema).toLowerCase())
- kaa_union->data = kaa_array_deserialize_wo_ctx(reader, (deserialize_wo_ctx_fn)${union_element_name}_deserialize);
- #elseif ($TypeConverter.isAvroBytes($array_element_schema))
- kaa_union->data = kaa_array_deserialize_wo_ctx(reader, (deserialize_wo_ctx_fn)kaa_bytes_deserialize);
- #elseif ($TypeConverter.isAvroFixed($array_element_schema))
- size_t fixed_size = $array_element_schema.getFixedSize();
- kaa_union->data = kaa_array_deserialize_wo_ctx_w_ctx(reader, (deserialize_w_ctx_fn)kaa_fixed_deserialize, &fixed_size);
- #elseif ($TypeConverter.isAvroString($array_element_schema))
- kaa_union->data = kaa_array_deserialize_wo_ctx(reader, (deserialize_wo_ctx_fn)kaa_string_deserialize);
- #elseif ($TypeConverter.isAvroPrimitive($array_element_schema))
- #set ($primitive_type = $array_element_schema.getType().toString().toLowerCase())
- kaa_union->data = kaa_array_deserialize_wo_ctx(reader, (deserialize_wo_ctx_fn)kaa_${primitive_type}_deserialize);
- #end
-#end
- break;
- }
-#end
-#set ($branch_number = $branch_number + 1)
-#end
- default:
- break;
- }
- }
-
- return kaa_union;
-}
-#end
-# endif // ${UNION_NAME}_C_
-
diff --git a/avrogen/src/main/resources/union.h.vm b/avrogen/src/main/resources/union.h.vm
deleted file mode 100644
index b9880376df..0000000000
--- a/avrogen/src/main/resources/union.h.vm
+++ /dev/null
@@ -1,43 +0,0 @@
-#*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *#
-
-#set ($PREFIX = $StyleUtils.toUpperUnderScore($namespacePrefix))
-#set ($prefix = $StyleUtils.toLowerUnderScore($namespacePrefix))
-#set ($UNION_NAME = $TypeConverter.generateUnionName($PREFIX, $schema))
-#set ($union_name = $UNION_NAME.toLowerCase())
-#set ($branch_number = 0)
-# ifndef ${UNION_NAME}_H_
-# define ${UNION_NAME}_H_
-
-#foreach ($branch_schema in $schema.getTypes())
-# define ${UNION_NAME}_BRANCH_${branch_number} ${branch_number}
-#set ($branch_number = $branch_number + 1)
-#end
-
-#set ($branch_number = 0)
-#if ($generationContext.isTypeOut())
-#foreach ($branch_schema in $schema.getTypes())
-kaa_union_t *${union_name}_branch_${branch_number}_create(void);
-#set ($branch_number = $branch_number + 1)
-#end
-
-#end
-#if ($generationContext.isTypeIn())
-kaa_union_t *${union_name}_deserialize(avro_reader_t reader);
-
-#end
-# endif // ${UNION_NAME}_H_
-
diff --git a/avrogen/src/test/java/org/kaaproject/kaa/avro/avrogen/StyleUtilsTest.java b/avrogen/src/test/java/org/kaaproject/kaa/avro/avrogen/StyleUtilsTest.java
deleted file mode 100644
index 96afbfe56b..0000000000
--- a/avrogen/src/test/java/org/kaaproject/kaa/avro/avrogen/StyleUtilsTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.kaaproject.kaa.avro.avrogen;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-
-public class StyleUtilsTest {
- @Test
- public void testToLowerUnderScore() {
- String pattern1 = "endpoint_key_hash";
- Assert.assertTrue(StyleUtils.toLowerUnderScore("endpointKeyHash").equals(pattern1));
-
- String pattern2 = "event_class_fqn";
- Assert.assertTrue(StyleUtils.toLowerUnderScore("eventClassFQN").equals(pattern2));
- }
-
- @Test
- public void testToUpperUnderScore() {
- String pattern1 = "ENDPOINT_KEY_HASH";
- Assert.assertTrue(StyleUtils.toUpperUnderScore("endpointKeyHash").equals(pattern1));
-
- String pattern2 = "EVENT_CLASS_FQN";
- Assert.assertTrue(StyleUtils.toUpperUnderScore("eventClassFQN").equals(pattern2));
- }
-
- @Test
- public void testRemovePackageName() {
- String longName = "org.kaaproject.kaa.common.endpoint.gen";
- Assert.assertTrue(StyleUtils.removePackageName(longName).equals("gen"));
- }
-}
diff --git a/avrogen/src/test/java/org/kaaproject/kaa/avro/avrogen/TypeConverterTest.java b/avrogen/src/test/java/org/kaaproject/kaa/avro/avrogen/TypeConverterTest.java
deleted file mode 100644
index f5fad9ae6c..0000000000
--- a/avrogen/src/test/java/org/kaaproject/kaa/avro/avrogen/TypeConverterTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.kaaproject.kaa.avro.avrogen;
-
-import org.apache.avro.Schema;
-import org.apache.avro.Schema.Type;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Arrays;
-
-public class TypeConverterTest {
- @Test
- public void testTypes() {
- Assert.assertTrue(TypeConverter.isAvroBytes(Schema.create(Type.BYTES)));
- Assert.assertFalse(TypeConverter.isAvroBytes(Schema.create(Type.STRING)));
-
- Assert.assertTrue(TypeConverter.isAvroArray(Schema.createArray(Schema.create(Type.BYTES))));
- Assert.assertFalse(TypeConverter.isAvroArray(Schema.create(Type.BYTES)));
-
- Assert.assertTrue(TypeConverter.isAvroString(Schema.create(Type.STRING)));
- Assert.assertFalse(TypeConverter.isAvroString(Schema.create(Type.BOOLEAN)));
-
- Assert.assertTrue(TypeConverter.isAvroEnum(Schema.createEnum("name", "doc", "namespace", Arrays.asList("node"))));
- Assert.assertFalse(TypeConverter.isAvroEnum(Schema.create(Type.BOOLEAN)));
-
- Assert.assertTrue(TypeConverter.isAvroNull(Schema.create(Type.NULL)));
- Assert.assertFalse(TypeConverter.isAvroNull(Schema.create(Type.BOOLEAN)));
-
- Assert.assertTrue(TypeConverter.isAvroPrimitive(Schema.create(Type.BOOLEAN)));
- Assert.assertTrue(TypeConverter.isAvroPrimitive(Schema.create(Type.INT)));
- Assert.assertTrue(TypeConverter.isAvroPrimitive(Schema.create(Type.LONG)));
- Assert.assertTrue(TypeConverter.isAvroPrimitive(Schema.createEnum("name", "doc", "namespace", Arrays.asList("node"))));
- Assert.assertFalse(TypeConverter.isAvroPrimitive(Schema.create(Type.STRING)));
- Assert.assertFalse(TypeConverter.isAvroPrimitive(Schema.create(Type.BYTES)));
-
- Assert.assertTrue(TypeConverter.isAvroUnion(Schema.createUnion(
- Arrays.asList(Schema.create(Type.BYTES), Schema.create(Type.STRING)))));
- Assert.assertFalse(TypeConverter.isAvroUnion(Schema.create(Type.STRING)));
-
- Assert.assertTrue(TypeConverter.isAvroRecord(Schema.createRecord("name", "doc", "namespace", false)));
- Assert.assertFalse(TypeConverter.isAvroRecord(Schema.create(Type.STRING)));
-
- Assert.assertTrue(TypeConverter.isAvroUnion(Schema.createUnion(
- Arrays.asList(Schema.create(Type.BYTES), Schema.create(Type.STRING)))));
- Assert.assertFalse(TypeConverter.isAvroUnion(Schema.create(Type.STRING)));
-
- Assert.assertTrue(TypeConverter.isAvroString(Schema.create(Type.STRING)));
- Assert.assertFalse(TypeConverter.isAvroString(Schema.create(Type.INT)));
- }
-
- @Test
- public void testDirection() {
- final String DIRECTION_FIELD = "direction";
-
- Schema inOutSchema = Schema.createEnum("test1", "doc", "namespace", Arrays.asList("node"));
- Assert.assertTrue(TypeConverter.isTypeOut(inOutSchema));
- Assert.assertTrue(TypeConverter.isTypeIn(inOutSchema));
-
- Schema outSchema = Schema.createRecord("test2", "doc", "namespace", false);
- outSchema.addProp(DIRECTION_FIELD, "out");
-
- Assert.assertTrue(TypeConverter.isTypeOut(outSchema));
- Assert.assertFalse(TypeConverter.isTypeIn(outSchema));
-
- Schema inSchema = Schema.createRecord("test13", "doc", "namespace", false);
- inSchema.addProp(DIRECTION_FIELD, "in");
-
- Assert.assertTrue(TypeConverter.isTypeIn(inSchema));
- Assert.assertFalse(TypeConverter.isTypeOut(inSchema));
-
- Schema invalidDirectionSchema = Schema.createRecord("test4", "doc", "namespace", false);
- invalidDirectionSchema.addProp(DIRECTION_FIELD, "inOut");
-
- Assert.assertFalse(TypeConverter.isTypeIn(invalidDirectionSchema));
- Assert.assertFalse(TypeConverter.isTypeOut(invalidDirectionSchema));
- }
-
- @Test
- public void testIsRecordNeedDeallocator() {
- Assert.assertFalse(TypeConverter.isRecordNeedDeallocator(Schema.create(Type.INT)));
- }
-}
diff --git a/checkstyle.xml b/checkstyle.xml
deleted file mode 100644
index 27d214a0a7..0000000000
--- a/checkstyle.xml
+++ /dev/null
@@ -1,226 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/client/client-multi/client-c/.gitignore b/client/client-multi/client-c/.gitignore
deleted file mode 100644
index 42e6983b63..0000000000
--- a/client/client-multi/client-c/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-Makefile
-.zshrc
-sonar-project.properties
-build-cc3200/
-build-clang/
-build-nologs/
-build-esp8266/
-build-posix/
-build-rpi/
diff --git a/client/client-multi/client-c/CMakeLists.txt b/client/client-multi/client-c/CMakeLists.txt
deleted file mode 100644
index 4b136cfdc2..0000000000
--- a/client/client-multi/client-c/CMakeLists.txt
+++ /dev/null
@@ -1,311 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# List of avaliable configuration parameters:
-#
-# - `KAA_MAX_LOG_LEVEL` - Maximum log level used by C SDK. The higher value, the more detailed logs.
-#
-# Values:
-#
-# - `0` - NONE (no logs)
-# - `1` - FATAL
-# - `2` - ERROR
-# - `3` - WARN
-# - `4` - INFO
-# - `5` - DEBUG
-# - `6` - TRACE
-#
-# Default: If build type is `Release`, `KAA_MAX_LOG_LEVEL=4`. If `Debug`, `KAA_MAX_LOG_LEVEL=6`.
-#
-# - `WITH_EXTENSION_[EXTENSION_NAME]` - specifies which extensions should be included to build.
-#
-# Extensions' names:
-#
-# - PROFILE
-# - CONFIGURATION
-# - EVENT
-# - LOGGING
-# - NOTIFICATION
-# - USER
-#
-# Values:
-#
-# - `ON` - enable extension
-# - `OFF` - disable extension
-#
-# Default: `ON` - all extensions are included in the build.
-#
-# - `KAA_PLATFORM` - build SDK for a particular target.
-#
-# Values:
-#
-# - `cc32xx`
-# - `esp8266`
-# - `posix`
-#
-# Default: `posix`
-#
-# - `KAA_UNITETESTS_COMPILE` - compile unit tests.
-#
-# Values:
-#
-# - `ON`
-# - `OFF`
-#
-# Default: `OFF`
-#
-# Note: requires [cmocka](https://cmocka.org/) test framework to be installed.
-
-cmake_minimum_required(VERSION 2.8.12)
-
-project(Kaa-c C)
-
-include(ExternalProject)
-
-option(WITH_EXTENSION_PROFILE "Enable profile extension" ON)
-option(WITH_EXTENSION_CONFIGURATION "Enable configuration extension" ON)
-option(WITH_EXTENSION_EVENT "Enable event extension" ON)
-option(WITH_EXTENSION_LOGGING "Enable logging extension" ON)
-option(WITH_EXTENSION_NOTIFICATION "Enable notification extension" ON)
-option(WITH_EXTENSION_USER "Enable user extension" ON)
-option(WITH_ENCRYPTION "Enable encryption" ON)
-option(KAA_RUNTIME_KEY_GENERATION "Enable RSA key generation at runtime" OFF)
-
-# Expose Kaa SDK directory to all modules
-set(KAA_SDK_DIR ${CMAKE_CURRENT_LIST_DIR})
-
-# Path to CMake's scripts.
-set(CMAKE_MODULE_PATH
- ${CMAKE_MODULE_PATH}
- ${CMAKE_CURRENT_SOURCE_DIR}/Modules
- )
-
-#
-# Sets common compilation flags.
-#
-# NOTE: Platform specific compilation flags should be set
-# in the corresponding platform CMake script(s).
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Wextra -pedantic -D_GNU_SOURCE")
-
-set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -Os")
-
-# Compiler specific flags.
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND APPLE)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup")
-endif ()
-
-if (CMAKE_COMPILER_IS_GNUCC)
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ggdb")
-
- if (KAA_COLLECT_COVERAGE)
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} --coverage")
- endif ()
-endif ()
-
-# Creates variable to specify thirdparty libraries.
-set(KAA_THIRDPARTY_LIBRARIES "")
-
-# Sets the default build platform to POSIX.
-if (NOT DEFINED KAA_PLATFORM)
- set(KAA_PLATFORM "posix")
-endif ()
-
-#
-# Sets maximum Kaa SDK log level.
-#
-# Logging constants:
-# NONE - 0
-# FATAL - 1
-# ERROR - 2
-# WARN - 3
-# INFO - 4
-# DEBUG - 5
-# TRACE - 6
-if (NOT DEFINED KAA_MAX_LOG_LEVEL)
- if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
- set(KAA_MAX_LOG_LEVEL 6)
- else ()
- set(KAA_MAX_LOG_LEVEL 4)
- endif ()
-endif ()
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DKAA_MAX_LOG_LEVEL=${KAA_MAX_LOG_LEVEL}")
-
-message("==================================")
-# Prints build parameters.
-if("${CMAKE_BUILD_TYPE}" STREQUAL "")
- message("BUILD_TYPE = (Default)")
-else()
- message("BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
-endif()
-message("KAA_PLATFORM = ${KAA_PLATFORM}")
-message("KAA_MAX_LOG_LEVEL = ${KAA_MAX_LOG_LEVEL}")
-message("==================================")
-
-# Sets path(s) to header files.
-set(KAA_SRC_FOLDER "${CMAKE_CURRENT_LIST_DIR}/src/kaa")
-
-#include platform-depended CMakeLists.txt
-include(${CMAKE_CURRENT_LIST_DIR}/listfiles/platform/${KAA_PLATFORM}/CMakeLists.txt)
-
-# Sets path(s) to source files.
-set(KAA_SOURCE_FILES
- ${KAA_SOURCE_FILES}
- ${KAA_SRC_FOLDER}/avro_src/io.c
- ${KAA_SRC_FOLDER}/avro_src/encoding_binary.c
- ${KAA_SRC_FOLDER}/collections/kaa_list.c
- ${KAA_SRC_FOLDER}/utilities/kaa_aes_rsa.c
- ${KAA_SRC_FOLDER}/utilities/kaa_log.c
- ${KAA_SRC_FOLDER}/utilities/kaa_mem.c
- ${KAA_SRC_FOLDER}/utilities/kaa_buffer.c
- ${KAA_SRC_FOLDER}/kaa_platform_utils.c
- ${KAA_SRC_FOLDER}/kaa_platform_protocol.c
- ${KAA_SRC_FOLDER}/kaa_channel_manager.c
- ${KAA_SRC_FOLDER}/kaa_common_schema.c
- ${KAA_SRC_FOLDER}/kaa_status.c
- ${KAA_SRC_FOLDER}/kaa.c
- ${KAA_SRC_FOLDER}/kaa_extension.c
- ${KAA_SRC_FOLDER}/platform-impl/common/kaa_htonll.c
-)
-
-if(WITH_ENCRYPTION)
- set(KAA_SOURCE_FILES
- ${KAA_SOURCE_FILES}
- ${KAA_SRC_FOLDER}/utilities/kaa_aes_rsa.c
- ${KAA_SRC_FOLDER}/platform-impl/common/encryption_utils.c)
-endif(WITH_ENCRYPTION)
-
-
-# Includes auto-generated Cmake's scripts.
-include(${CMAKE_CURRENT_LIST_DIR}/listfiles/CMakeGen.cmake)
-
-# Kaa include directories
-set(KAA_INCLUDE_DIRS
- ${KAA_INCLUDE_PATHS}
- ${CMAKE_CURRENT_LIST_DIR}/src
- ${CMAKE_CURRENT_LIST_DIR}/thirdparty/mbedtls
- ${CMAKE_CURRENT_LIST_DIR}/tools/kaa_encryption/rsa_key_gen/include
- ${KAA_SRC_FOLDER}
- ${KAA_THIRDPARTY_INCLUDE_DIR})
-
-# Build unit tests.
-include(${CMAKE_CURRENT_LIST_DIR}/listfiles/UnitTest.cmake)
-
-include_directories(SYSTEM ${KAA_INCLUDE_PATHS})
-
-# This already includes mbedtls
-add_subdirectory(tools/kaa_encryption/rsa_key_gen)
-
-# Build Kaa libraries.
-add_library(kaac ${KAA_SOURCE_FILES})
-target_include_directories(kaac PUBLIC ${KAA_INCLUDE_DIRS})
-target_link_libraries(kaac PRIVATE ${KAA_THIRDPARTY_LIBRARIES})
-
-message("BOOTSTRAP ENABLED")
-include(${CMAKE_CURRENT_LIST_DIR}/src/extensions/bootstrap/CMakeLists.txt)
-target_link_libraries(kaac PUBLIC extension_bootstrap)
-
-if(WITH_EXTENSION_PROFILE)
- message("PROFILE ENABLED")
-
- include(${CMAKE_CURRENT_LIST_DIR}/src/extensions/profile/CMakeLists.txt)
- target_link_libraries(kaac PUBLIC extension_profile)
-else()
- add_definitions(-DKAA_DISABLE_FEATURE_PROFILE)
-endif()
-
-if(WITH_EXTENSION_USER)
- message("USER EXTENSION ENABLED")
-
- include(${CMAKE_CURRENT_LIST_DIR}/src/extensions/user/CMakeLists.txt)
- target_link_libraries(kaac PUBLIC extension_user)
-else()
- add_definitions(-DKAA_DISABLE_FEATURE_USER)
-endif()
-
-if(WITH_EXTENSION_CONFIGURATION)
- message("CONFIGURATION ENABLED")
-
- include(${CMAKE_CURRENT_LIST_DIR}/src/extensions/configuration/CMakeLists.txt)
- target_link_libraries(kaac PUBLIC extension_configuration)
-else()
- add_definitions(-DKAA_DISABLE_FEATURE_CONFIGURATION)
-endif()
-
-if(WITH_EXTENSION_EVENT)
- message("EVENTS ENABLED")
-
- include(${CMAKE_CURRENT_LIST_DIR}/src/extensions/event/CMakeLists.txt)
- target_link_libraries(kaac PUBLIC extension_event)
-else()
- add_definitions(-DKAA_DISABLE_FEATURE_EVENTS)
-endif()
-
-if(WITH_EXTENSION_LOGGING)
- message("LOGGING ENABLED")
-
- include(${CMAKE_CURRENT_LIST_DIR}/src/extensions/logging/CMakeLists.txt)
- target_link_libraries(kaac PUBLIC extension_logging)
-else()
- add_definitions(-DKAA_DISABLE_FEATURE_LOGGING)
-endif()
-
-if(WITH_EXTENSION_NOTIFICATION)
- message("NOTIFICATION ENABLED")
-
- include(${CMAKE_CURRENT_LIST_DIR}/src/extensions/notification/CMakeLists.txt)
- target_link_libraries(kaac PUBLIC extension_notification)
-else()
- add_definitions(-DKAA_DISABLE_FEATURE_NOTIFICATION)
-endif()
-
-if(WITH_ENCRYPTION)
- message("ENCRYPTION ENABLED")
- target_link_libraries(kaac PUBLIC rsa_keygen)
- add_definitions(-DKAA_ENCRYPTION)
-endif()
-
-message("KAA WILL BE INSTALLED TO ${CMAKE_INSTALL_PREFIX}")
-install(DIRECTORY ${KAA_SRC_FOLDER}/ DESTINATION include/kaa
- FILES_MATCHING PATTERN *.h)
-
-install(TARGETS kaac DESTINATION lib)
-
-add_subdirectory(Modules/doxygen)
-
-add_subdirectory(Modules/cppcheck)
-
-#Set key pair generation parameter for posix platform
-#Use application for another platform
-if(KAA_RUNTIME_KEY_GENERATION)
- if(KAA_PLATFORM STREQUAL "posix")
- add_definitions(-DKAA_RUNTIME_KEY_GENERATION)
- target_link_libraries(kaac PUBLIC rsa_keygen)
- else()
- message(FATAL_ERROR "The runtime key generation option may be enabled only for POSIX platform")
- endif()
- target_link_libraries(kaac PUBLIC rsa_keygen)
-else()
- add_dependencies(kaac kaa_rsa_keygen)
- externalproject_add(kaa_rsa_keygen SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/tools/kaa_encryption"
- INSTALL_COMMAND "./generate_rsa_keys" COMMENT "Generating RSA headers"
- CMAKE_ARGS -DKAA_SDK_DIR=${KAA_SDK_DIR}
- BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/kaa_keys)
-
- externalproject_add_step(kaa_rsa_keygen "Copying generated files"
- COMMAND mv -f "${CMAKE_CURRENT_BINARY_DIR}/kaa_keys/kaa_keys_gen.h"
- "${KAA_SRC_FOLDER}/gen" DEPENDEES install)
-endif()
diff --git a/client/client-multi/client-c/Doxyfile b/client/client-multi/client-c/Doxyfile
deleted file mode 100644
index e623ee14e8..0000000000
--- a/client/client-multi/client-c/Doxyfile
+++ /dev/null
@@ -1,2408 +0,0 @@
-# Doxyfile 1.8.11
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project.
-#
-# All text after a double hash (##) is considered a comment and is placed in
-# front of the TAG it is preceding.
-#
-# All text after a single hash (#) is considered a comment and will be ignored.
-# The format is:
-# TAG = value [value, ...]
-# For lists, items can also be appended using:
-# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (\" \").
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# This tag specifies the encoding used for all characters in the config file
-# that follow. The default is UTF-8 which is also the encoding used for all text
-# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
-# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
-# for the list of possible encodings.
-# The default value is: UTF-8.
-
-DOXYFILE_ENCODING = UTF-8
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
-# double-quotes, unless you are using Doxywizard) that should identify the
-# project for which the documentation is generated. This name is used in the
-# title of most generated pages and in a few other places.
-# The default value is: My Project.
-
-PROJECT_NAME = "Kaa client C SDK"
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
-# could be handy for archiving the generated documentation or if some version
-# control system is used.
-
-PROJECT_NUMBER =
-
-# Using the PROJECT_BRIEF tag one can provide an optional one line description
-# for a project that appears at the top of each page and should give viewer a
-# quick idea about the purpose of the project. Keep the description short.
-
-PROJECT_BRIEF =
-
-# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
-# in the documentation. The maximum height of the logo should not exceed 55
-# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
-# the logo to the output directory.
-
-PROJECT_LOGO =
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
-# into which the generated documentation will be written. If a relative path is
-# entered, it will be relative to the location where doxygen was started. If
-# left blank the current directory will be used.
-
-OUTPUT_DIRECTORY = target/apidocs/doxygen
-
-# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
-# directories (in 2 levels) under the output directory of each output format and
-# will distribute the generated files over these directories. Enabling this
-# option can be useful when feeding doxygen a huge amount of source files, where
-# putting all generated files in the same directory would otherwise causes
-# performance problems for the file system.
-# The default value is: NO.
-
-CREATE_SUBDIRS = NO
-
-# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
-# characters to appear in the names of generated files. If set to NO, non-ASCII
-# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
-# U+3044.
-# The default value is: NO.
-
-ALLOW_UNICODE_NAMES = NO
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all
-# documentation generated by doxygen is written. Doxygen will use this
-# information to generate all constant output in the proper language.
-# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
-# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
-# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
-# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
-# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
-# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
-# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
-# Ukrainian and Vietnamese.
-# The default value is: English.
-
-OUTPUT_LANGUAGE = English
-
-# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
-# descriptions after the members that are listed in the file and class
-# documentation (similar to Javadoc). Set to NO to disable this.
-# The default value is: YES.
-
-BRIEF_MEMBER_DESC = YES
-
-# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
-# description of a member or function before the detailed description
-#
-# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
-# brief descriptions will be completely suppressed.
-# The default value is: YES.
-
-REPEAT_BRIEF = YES
-
-# This tag implements a quasi-intelligent brief description abbreviator that is
-# used to form the text in various listings. Each string in this list, if found
-# as the leading text of the brief description, will be stripped from the text
-# and the result, after processing the whole list, is used as the annotated
-# text. Otherwise, the brief description is used as-is. If left blank, the
-# following values are used ($name is automatically replaced with the name of
-# the entity):The $name class, The $name widget, The $name file, is, provides,
-# specifies, contains, represents, a, an and the.
-
-ABBREVIATE_BRIEF =
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# doxygen will generate a detailed section even if there is only a brief
-# description.
-# The default value is: NO.
-
-ALWAYS_DETAILED_SEC = NO
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
-# inherited members of a class in the documentation of that class as if those
-# members were ordinary class members. Constructors, destructors and assignment
-# operators of the base classes will not be shown.
-# The default value is: NO.
-
-INLINE_INHERITED_MEMB = NO
-
-# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
-# before files name in the file list and in the header files. If set to NO the
-# shortest path that makes the file name unique will be used
-# The default value is: YES.
-
-FULL_PATH_NAMES = YES
-
-# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
-# Stripping is only done if one of the specified strings matches the left-hand
-# part of the path. The tag can be used to show relative paths in the file list.
-# If left blank the directory from which doxygen is run is used as the path to
-# strip.
-#
-# Note that you can specify absolute paths here, but also relative paths, which
-# will be relative from the directory where doxygen is started.
-# This tag requires that the tag FULL_PATH_NAMES is set to YES.
-
-STRIP_FROM_PATH =
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
-# path mentioned in the documentation of a class, which tells the reader which
-# header file to include in order to use a class. If left blank only the name of
-# the header file containing the class definition is used. Otherwise one should
-# specify the list of include paths that are normally passed to the compiler
-# using the -I flag.
-
-STRIP_FROM_INC_PATH =
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
-# less readable) file names. This can be useful is your file systems doesn't
-# support long names like on DOS, Mac, or CD-ROM.
-# The default value is: NO.
-
-SHORT_NAMES = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
-# first line (until the first dot) of a Javadoc-style comment as the brief
-# description. If set to NO, the Javadoc-style will behave just like regular Qt-
-# style comments (thus requiring an explicit @brief command for a brief
-# description.)
-# The default value is: NO.
-
-JAVADOC_AUTOBRIEF = YES
-
-# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
-# line (until the first dot) of a Qt-style comment as the brief description. If
-# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
-# requiring an explicit \brief command for a brief description.)
-# The default value is: NO.
-
-QT_AUTOBRIEF = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
-# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
-# a brief description. This used to be the default behavior. The new default is
-# to treat a multi-line C++ comment block as a detailed description. Set this
-# tag to YES if you prefer the old behavior instead.
-#
-# Note that setting this tag to YES also means that rational rose comments are
-# not recognized any more.
-# The default value is: NO.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
-# documentation from any documented member that it re-implements.
-# The default value is: YES.
-
-INHERIT_DOCS = YES
-
-# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
-# page for each member. If set to NO, the documentation of a member will be part
-# of the file/class/namespace that contains it.
-# The default value is: NO.
-
-SEPARATE_MEMBER_PAGES = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
-# uses this value to replace tabs by spaces in code fragments.
-# Minimum value: 1, maximum value: 16, default value: 4.
-
-TAB_SIZE = 4
-
-# This tag can be used to specify a number of aliases that act as commands in
-# the documentation. An alias has the form:
-# name=value
-# For example adding
-# "sideeffect=@par Side Effects:\n"
-# will allow you to put the command \sideeffect (or @sideeffect) in the
-# documentation, which will result in a user-defined paragraph with heading
-# "Side Effects:". You can put \n's in the value part of an alias to insert
-# newlines.
-
-ALIASES =
-
-# This tag can be used to specify a number of word-keyword mappings (TCL only).
-# A mapping has the form "name=value". For example adding "class=itcl::class"
-# will allow you to use the command class in the itcl::class meaning.
-
-TCL_SUBST =
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
-# only. Doxygen will then generate output that is more tailored for C. For
-# instance, some of the names that are used will be different. The list of all
-# members will be omitted, etc.
-# The default value is: NO.
-
-OPTIMIZE_OUTPUT_FOR_C = YES
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
-# Python sources only. Doxygen will then generate output that is more tailored
-# for that language. For instance, namespaces will be presented as packages,
-# qualified scopes will look different, etc.
-# The default value is: NO.
-
-OPTIMIZE_OUTPUT_JAVA = NO
-
-# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
-# sources. Doxygen will then generate output that is tailored for Fortran.
-# The default value is: NO.
-
-OPTIMIZE_FOR_FORTRAN = NO
-
-# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
-# sources. Doxygen will then generate output that is tailored for VHDL.
-# The default value is: NO.
-
-OPTIMIZE_OUTPUT_VHDL = NO
-
-# Doxygen selects the parser to use depending on the extension of the files it
-# parses. With this tag you can assign which parser to use for a given
-# extension. Doxygen has a built-in mapping, but you can override or extend it
-# using this tag. The format is ext=language, where ext is a file extension, and
-# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
-# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
-# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
-# Fortran. In the later case the parser tries to guess whether the code is fixed
-# or free formatted code, this is the default for Fortran type files), VHDL. For
-# instance to make doxygen treat .inc files as Fortran files (default is PHP),
-# and .f files as C (default is Fortran), use: inc=Fortran f=C.
-#
-# Note: For files without extension you can use no_extension as a placeholder.
-#
-# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
-# the files are not read by doxygen.
-
-EXTENSION_MAPPING =
-
-# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
-# according to the Markdown format, which allows for more readable
-# documentation. See http://daringfireball.net/projects/markdown/ for details.
-# The output of markdown processing is further processed by doxygen, so you can
-# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
-# case of backward compatibilities issues.
-# The default value is: YES.
-
-MARKDOWN_SUPPORT = YES
-
-# When enabled doxygen tries to link words that correspond to documented
-# classes, or namespaces to their corresponding documentation. Such a link can
-# be prevented in individual cases by putting a % sign in front of the word or
-# globally by setting AUTOLINK_SUPPORT to NO.
-# The default value is: YES.
-
-AUTOLINK_SUPPORT = YES
-
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
-# to include (a tag file for) the STL sources as input, then you should set this
-# tag to YES in order to let doxygen match functions declarations and
-# definitions whose arguments contain STL classes (e.g. func(std::string);
-# versus func(std::string) {}). This also make the inheritance and collaboration
-# diagrams that involve STL classes more complete and accurate.
-# The default value is: NO.
-
-BUILTIN_STL_SUPPORT = NO
-
-# If you use Microsoft's C++/CLI language, you should set this option to YES to
-# enable parsing support.
-# The default value is: NO.
-
-CPP_CLI_SUPPORT = NO
-
-# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
-# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
-# will parse them like normal C++ but will assume all classes use public instead
-# of private inheritance when no explicit protection keyword is present.
-# The default value is: NO.
-
-SIP_SUPPORT = NO
-
-# For Microsoft's IDL there are propget and propput attributes to indicate
-# getter and setter methods for a property. Setting this option to YES will make
-# doxygen to replace the get and set methods by a property in the documentation.
-# This will only work if the methods are indeed getting or setting a simple
-# type. If this is not the case, or you want to show the methods anyway, you
-# should set this option to NO.
-# The default value is: YES.
-
-IDL_PROPERTY_SUPPORT = NO
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
-# The default value is: NO.
-
-DISTRIBUTE_GROUP_DOC = NO
-
-# If one adds a struct or class to a group and this option is enabled, then also
-# any nested class or struct is added to the same group. By default this option
-# is disabled and one has to add nested compounds explicitly via \ingroup.
-# The default value is: NO.
-
-GROUP_NESTED_COMPOUNDS = NO
-
-# Set the SUBGROUPING tag to YES to allow class member groups of the same type
-# (for instance a group of public functions) to be put as a subgroup of that
-# type (e.g. under the Public Functions section). Set it to NO to prevent
-# subgrouping. Alternatively, this can be done per class using the
-# \nosubgrouping command.
-# The default value is: YES.
-
-SUBGROUPING = YES
-
-# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
-# are shown inside the group in which they are included (e.g. using \ingroup)
-# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
-# and RTF).
-#
-# Note that this feature does not work in combination with
-# SEPARATE_MEMBER_PAGES.
-# The default value is: NO.
-
-INLINE_GROUPED_CLASSES = NO
-
-# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
-# with only public data fields or simple typedef fields will be shown inline in
-# the documentation of the scope in which they are defined (i.e. file,
-# namespace, or group documentation), provided this scope is documented. If set
-# to NO, structs, classes, and unions are shown on a separate page (for HTML and
-# Man pages) or section (for LaTeX and RTF).
-# The default value is: NO.
-
-INLINE_SIMPLE_STRUCTS = NO
-
-# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
-# enum is documented as struct, union, or enum with the name of the typedef. So
-# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
-# with name TypeT. When disabled the typedef will appear as a member of a file,
-# namespace, or class. And the struct will be named TypeS. This can typically be
-# useful for C code in case the coding convention dictates that all compound
-# types are typedef'ed and only the typedef is referenced, never the tag name.
-# The default value is: NO.
-
-TYPEDEF_HIDES_STRUCT = NO
-
-# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
-# cache is used to resolve symbols given their name and scope. Since this can be
-# an expensive process and often the same symbol appears multiple times in the
-# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
-# doxygen will become slower. If the cache is too large, memory is wasted. The
-# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
-# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
-# symbols. At the end of a run doxygen will report the cache usage and suggest
-# the optimal cache size from a speed point of view.
-# Minimum value: 0, maximum value: 9, default value: 0.
-
-LOOKUP_CACHE_SIZE = 0
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
-# documentation are documented, even if no documentation was available. Private
-# class members and static file members will be hidden unless the
-# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
-# Note: This will also disable the warnings about undocumented members that are
-# normally produced when WARNINGS is set to YES.
-# The default value is: NO.
-
-EXTRACT_ALL = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
-# be included in the documentation.
-# The default value is: NO.
-
-EXTRACT_PRIVATE = NO
-
-# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
-# scope will be included in the documentation.
-# The default value is: NO.
-
-EXTRACT_PACKAGE = NO
-
-# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
-# included in the documentation.
-# The default value is: NO.
-
-EXTRACT_STATIC = YES
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
-# locally in source files will be included in the documentation. If set to NO,
-# only classes defined in header files are included. Does not have any effect
-# for Java sources.
-# The default value is: YES.
-
-EXTRACT_LOCAL_CLASSES = YES
-
-# This flag is only useful for Objective-C code. If set to YES, local methods,
-# which are defined in the implementation section but not in the interface are
-# included in the documentation. If set to NO, only methods in the interface are
-# included.
-# The default value is: NO.
-
-EXTRACT_LOCAL_METHODS = NO
-
-# If this flag is set to YES, the members of anonymous namespaces will be
-# extracted and appear in the documentation as a namespace called
-# 'anonymous_namespace{file}', where file will be replaced with the base name of
-# the file that contains the anonymous namespace. By default anonymous namespace
-# are hidden.
-# The default value is: NO.
-
-EXTRACT_ANON_NSPACES = NO
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
-# undocumented members inside documented classes or files. If set to NO these
-# members will be included in the various overviews, but no documentation
-# section is generated. This option has no effect if EXTRACT_ALL is enabled.
-# The default value is: NO.
-
-HIDE_UNDOC_MEMBERS = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy. If set
-# to NO, these classes will be included in the various overviews. This option
-# has no effect if EXTRACT_ALL is enabled.
-# The default value is: NO.
-
-HIDE_UNDOC_CLASSES = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
-# (class|struct|union) declarations. If set to NO, these declarations will be
-# included in the documentation.
-# The default value is: NO.
-
-HIDE_FRIEND_COMPOUNDS = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
-# documentation blocks found inside the body of a function. If set to NO, these
-# blocks will be appended to the function's detailed documentation block.
-# The default value is: NO.
-
-HIDE_IN_BODY_DOCS = NO
-
-# The INTERNAL_DOCS tag determines if documentation that is typed after a
-# \internal command is included. If the tag is set to NO then the documentation
-# will be excluded. Set it to YES to include the internal documentation.
-# The default value is: NO.
-
-INTERNAL_DOCS = YES
-
-# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
-# names in lower-case letters. If set to YES, upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
-# The default value is: system dependent.
-
-CASE_SENSE_NAMES = YES
-
-# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
-# their full class and namespace scopes in the documentation. If set to YES, the
-# scope will be hidden.
-# The default value is: NO.
-
-HIDE_SCOPE_NAMES = NO
-
-# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
-# append additional text to a page's title, such as Class Reference. If set to
-# YES the compound reference will be hidden.
-# The default value is: NO.
-
-HIDE_COMPOUND_REFERENCE= NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
-# the files that are included by a file in the documentation of that file.
-# The default value is: YES.
-
-SHOW_INCLUDE_FILES = YES
-
-# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
-# grouped member an include statement to the documentation, telling the reader
-# which file to include in order to use the member.
-# The default value is: NO.
-
-SHOW_GROUPED_MEMB_INC = NO
-
-# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
-# files with double quotes in the documentation rather than with sharp brackets.
-# The default value is: NO.
-
-FORCE_LOCAL_INCLUDES = NO
-
-# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
-# documentation for inline members.
-# The default value is: YES.
-
-INLINE_INFO = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
-# (detailed) documentation of file and class members alphabetically by member
-# name. If set to NO, the members will appear in declaration order.
-# The default value is: YES.
-
-SORT_MEMBER_DOCS = YES
-
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
-# descriptions of file, namespace and class members alphabetically by member
-# name. If set to NO, the members will appear in declaration order. Note that
-# this will also influence the order of the classes in the class list.
-# The default value is: NO.
-
-SORT_BRIEF_DOCS = NO
-
-# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
-# (brief and detailed) documentation of class members so that constructors and
-# destructors are listed first. If set to NO the constructors will appear in the
-# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
-# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
-# member documentation.
-# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
-# detailed member documentation.
-# The default value is: NO.
-
-SORT_MEMBERS_CTORS_1ST = NO
-
-# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
-# of group names into alphabetical order. If set to NO the group names will
-# appear in their defined order.
-# The default value is: NO.
-
-SORT_GROUP_NAMES = NO
-
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
-# fully-qualified names, including namespaces. If set to NO, the class list will
-# be sorted only by class name, not including the namespace part.
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the alphabetical
-# list.
-# The default value is: NO.
-
-SORT_BY_SCOPE_NAME = NO
-
-# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
-# type resolution of all parameters of a function it will reject a match between
-# the prototype and the implementation of a member function even if there is
-# only one candidate or it is obvious which candidate to choose by doing a
-# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
-# accept a match between prototype and implementation in such cases.
-# The default value is: NO.
-
-STRICT_PROTO_MATCHING = NO
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
-# list. This list is created by putting \todo commands in the documentation.
-# The default value is: YES.
-
-GENERATE_TODOLIST = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
-# list. This list is created by putting \test commands in the documentation.
-# The default value is: YES.
-
-GENERATE_TESTLIST = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
-# list. This list is created by putting \bug commands in the documentation.
-# The default value is: YES.
-
-GENERATE_BUGLIST = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
-# the deprecated list. This list is created by putting \deprecated commands in
-# the documentation.
-# The default value is: YES.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional documentation
-# sections, marked by \if ... \endif and \cond
-# ... \endcond blocks.
-
-ENABLED_SECTIONS =
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
-# initial value of a variable or macro / define can have for it to appear in the
-# documentation. If the initializer consists of more lines than specified here
-# it will be hidden. Use a value of 0 to hide initializers completely. The
-# appearance of the value of individual variables and macros / defines can be
-# controlled using \showinitializer or \hideinitializer command in the
-# documentation regardless of this setting.
-# Minimum value: 0, maximum value: 10000, default value: 30.
-
-MAX_INITIALIZER_LINES = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
-# the bottom of the documentation of classes and structs. If set to YES, the
-# list will mention the files that were used to generate the documentation.
-# The default value is: YES.
-
-SHOW_USED_FILES = YES
-
-# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
-# will remove the Files entry from the Quick Index and from the Folder Tree View
-# (if specified).
-# The default value is: YES.
-
-SHOW_FILES = YES
-
-# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
-# page. This will remove the Namespaces entry from the Quick Index and from the
-# Folder Tree View (if specified).
-# The default value is: YES.
-
-SHOW_NAMESPACES = YES
-
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that
-# doxygen should invoke to get the current version for each file (typically from
-# the version control system). Doxygen will invoke the program by executing (via
-# popen()) the command command input-file, where command is the value of the
-# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
-# by doxygen. Whatever the program writes to standard output is used as the file
-# version. For an example see the documentation.
-
-FILE_VERSION_FILTER =
-
-# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
-# by doxygen. The layout file controls the global structure of the generated
-# output files in an output format independent way. To create the layout file
-# that represents doxygen's defaults, run doxygen with the -l option. You can
-# optionally specify a file name after the option, if omitted DoxygenLayout.xml
-# will be used as the name of the layout file.
-#
-# Note that if you run doxygen from a directory containing a file called
-# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
-# tag is left empty.
-
-LAYOUT_FILE =
-
-# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
-# the reference definitions. This must be a list of .bib files. The .bib
-# extension is automatically appended if omitted. This requires the bibtex tool
-# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
-# For LaTeX the style of the bibliography can be controlled using
-# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
-# search path. See also \cite for info how to create references.
-
-CITE_BIB_FILES =
-
-#---------------------------------------------------------------------------
-# Configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated to
-# standard output by doxygen. If QUIET is set to YES this implies that the
-# messages are off.
-# The default value is: NO.
-
-QUIET = YES
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
-# this implies that the warnings are on.
-#
-# Tip: Turn warnings on while writing the documentation.
-# The default value is: YES.
-
-WARNINGS = YES
-
-# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
-# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
-# will automatically be disabled.
-# The default value is: YES.
-
-WARN_IF_UNDOCUMENTED = NO
-
-# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some parameters
-# in a documented function, or documenting parameters that don't exist or using
-# markup commands wrongly.
-# The default value is: YES.
-
-WARN_IF_DOC_ERROR = YES
-
-# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
-# are documented, but have no documentation for their parameters or return
-# value. If set to NO, doxygen will only warn about wrong or incomplete
-# parameter documentation, but not about the absence of documentation.
-# The default value is: NO.
-
-WARN_NO_PARAMDOC = NO
-
-# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
-# a warning is encountered.
-# The default value is: NO.
-
-WARN_AS_ERROR = YES
-
-# The WARN_FORMAT tag determines the format of the warning messages that doxygen
-# can produce. The string should contain the $file, $line, and $text tags, which
-# will be replaced by the file and line number from which the warning originated
-# and the warning text. Optionally the format may contain $version, which will
-# be replaced by the version of the file (if it could be obtained via
-# FILE_VERSION_FILTER)
-# The default value is: $file:$line: $text.
-
-WARN_FORMAT = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning and error
-# messages should be written. If left blank the output is written to standard
-# error (stderr).
-
-WARN_LOGFILE =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag is used to specify the files and/or directories that contain
-# documented source files. You may enter file names like myfile.cpp or
-# directories like /usr/src/myproject. Separate the files or directories with
-# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
-# Note: If this tag is empty the current directory is searched.
-
-INPUT = src/
-
-# This tag can be used to specify the character encoding of the source files
-# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
-# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
-# documentation (see: http://www.gnu.org/software/libiconv) for the list of
-# possible encodings.
-# The default value is: UTF-8.
-
-INPUT_ENCODING = UTF-8
-
-# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
-# *.h) to filter out the source-files in the directories.
-#
-# Note that for custom extensions or not directly supported extensions you also
-# need to set EXTENSION_MAPPING for the extension otherwise the files are not
-# read by doxygen.
-#
-# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
-# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
-# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
-# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl,
-# *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js.
-
-FILE_PATTERNS = *.h \
- *.dox
-
-# The RECURSIVE tag can be used to specify whether or not subdirectories should
-# be searched for input files as well.
-# The default value is: NO.
-
-RECURSIVE = YES
-
-# The EXCLUDE tag can be used to specify files and/or directories that should be
-# excluded from the INPUT source files. This way you can easily exclude a
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-#
-# Note that relative paths are relative to the directory from which doxygen is
-# run.
-
-EXCLUDE = src/kaa/gen/ \
- src/avro_src/
-
-# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
-# directories that are symbolic links (a Unix file system feature) are excluded
-# from the input.
-# The default value is: NO.
-
-EXCLUDE_SYMLINKS = NO
-
-# If the value of the INPUT tag contains directories, you can use the
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories.
-#
-# Note that the wildcards are matched against the file with absolute path, so to
-# exclude all test directories for example use the pattern */test/*
-
-EXCLUDE_PATTERNS =
-
-# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
-# (namespaces, classes, functions, etc.) that should be excluded from the
-# output. The symbol name can be a fully qualified name, a word, or if the
-# wildcard * is used, a substring. Examples: ANamespace, AClass,
-# AClass::ANamespace, ANamespace::*Test
-#
-# Note that the wildcards are matched against the file with absolute path, so to
-# exclude all test directories use the pattern */test/*
-
-EXCLUDE_SYMBOLS =
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or directories
-# that contain example code fragments that are included (see the \include
-# command).
-
-EXAMPLE_PATH =
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
-# *.h) to filter out the source-files in the directories. If left blank all
-# files are included.
-
-EXAMPLE_PATTERNS =
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude commands
-# irrespective of the value of the RECURSIVE tag.
-# The default value is: NO.
-
-EXAMPLE_RECURSIVE = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or directories
-# that contain images that are to be included in the documentation (see the
-# \image command).
-
-IMAGE_PATH =
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should
-# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command:
-#
-#
-#
-# where is the value of the INPUT_FILTER tag, and is the
-# name of an input file. Doxygen will then use the output that the filter
-# program writes to standard output. If FILTER_PATTERNS is specified, this tag
-# will be ignored.
-#
-# Note that the filter must not add or remove lines; it is applied before the
-# code is scanned, but not when the output code is generated. If lines are added
-# or removed, the anchors will not be placed correctly.
-#
-# Note that for custom extensions or not directly supported extensions you also
-# need to set EXTENSION_MAPPING for the extension otherwise the files are not
-# properly processed by doxygen.
-
-INPUT_FILTER =
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis. Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match. The filters are a list of the form: pattern=filter
-# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
-# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
-# patterns match the file name, INPUT_FILTER is applied.
-#
-# Note that for custom extensions or not directly supported extensions you also
-# need to set EXTENSION_MAPPING for the extension otherwise the files are not
-# properly processed by doxygen.
-
-FILTER_PATTERNS =
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will also be used to filter the input files that are used for
-# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
-# The default value is: NO.
-
-FILTER_SOURCE_FILES = NO
-
-# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
-# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
-# it is also possible to disable source filtering for a specific pattern using
-# *.ext= (so without naming a filter).
-# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
-
-FILTER_SOURCE_PATTERNS =
-
-# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
-# is part of the input, its contents will be placed on the main page
-# (index.html). This can be useful if you have a project on for instance GitHub
-# and want to reuse the introduction page also for the doxygen output.
-
-USE_MDFILE_AS_MAINPAGE =
-
-#---------------------------------------------------------------------------
-# Configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
-# generated. Documented entities will be cross-referenced with these sources.
-#
-# Note: To get rid of all source code in the generated output, make sure that
-# also VERBATIM_HEADERS is set to NO.
-# The default value is: NO.
-
-SOURCE_BROWSER = NO
-
-# Setting the INLINE_SOURCES tag to YES will include the body of functions,
-# classes and enums directly into the documentation.
-# The default value is: NO.
-
-INLINE_SOURCES = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
-# special comment blocks from generated source code fragments. Normal C, C++ and
-# Fortran comments will always remain visible.
-# The default value is: YES.
-
-STRIP_CODE_COMMENTS = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
-# function all documented functions referencing it will be listed.
-# The default value is: NO.
-
-REFERENCED_BY_RELATION = NO
-
-# If the REFERENCES_RELATION tag is set to YES then for each documented function
-# all documented entities called/used by that function will be listed.
-# The default value is: NO.
-
-REFERENCES_RELATION = NO
-
-# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
-# to YES then the hyperlinks from functions in REFERENCES_RELATION and
-# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
-# link to the documentation.
-# The default value is: YES.
-
-REFERENCES_LINK_SOURCE = YES
-
-# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
-# source code will show a tooltip with additional information such as prototype,
-# brief description and links to the definition and documentation. Since this
-# will make the HTML file larger and loading of large files a bit slower, you
-# can opt to disable this feature.
-# The default value is: YES.
-# This tag requires that the tag SOURCE_BROWSER is set to YES.
-
-SOURCE_TOOLTIPS = YES
-
-# If the USE_HTAGS tag is set to YES then the references to source code will
-# point to the HTML generated by the htags(1) tool instead of doxygen built-in
-# source browser. The htags tool is part of GNU's global source tagging system
-# (see http://www.gnu.org/software/global/global.html). You will need version
-# 4.8.6 or higher.
-#
-# To use it do the following:
-# - Install the latest version of global
-# - Enable SOURCE_BROWSER and USE_HTAGS in the config file
-# - Make sure the INPUT points to the root of the source tree
-# - Run doxygen as normal
-#
-# Doxygen will invoke htags (and that will in turn invoke gtags), so these
-# tools must be available from the command line (i.e. in the search path).
-#
-# The result: instead of the source browser generated by doxygen, the links to
-# source code will now point to the output of htags.
-# The default value is: NO.
-# This tag requires that the tag SOURCE_BROWSER is set to YES.
-
-USE_HTAGS = NO
-
-# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
-# verbatim copy of the header file for each class for which an include is
-# specified. Set to NO to disable this.
-# See also: Section \class.
-# The default value is: YES.
-
-VERBATIM_HEADERS = YES
-
-#---------------------------------------------------------------------------
-# Configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
-# compounds will be generated. Enable this if the project contains a lot of
-# classes, structs, unions or interfaces.
-# The default value is: YES.
-
-ALPHABETICAL_INDEX = YES
-
-# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
-# which the alphabetical index list will be split.
-# Minimum value: 1, maximum value: 20, default value: 5.
-# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
-
-COLS_IN_ALPHA_INDEX = 5
-
-# In case all classes in a project start with a common prefix, all classes will
-# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
-# can be used to specify a prefix (or a list of prefixes) that should be ignored
-# while generating the index headers.
-# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
-
-IGNORE_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
-# The default value is: YES.
-
-GENERATE_HTML = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
-# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
-# it.
-# The default directory is: html.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_OUTPUT = .
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
-# generated HTML page (for example: .htm, .php, .asp).
-# The default value is: .html.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_FILE_EXTENSION = .html
-
-# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
-# each generated HTML page. If the tag is left blank doxygen will generate a
-# standard header.
-#
-# To get valid HTML the header file that includes any scripts and style sheets
-# that doxygen needs, which is dependent on the configuration options used (e.g.
-# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
-# default header using
-# doxygen -w html new_header.html new_footer.html new_stylesheet.css
-# YourConfigFile
-# and then modify the file new_header.html. See also section "Doxygen usage"
-# for information on how to generate the default header that doxygen normally
-# uses.
-# Note: The header is subject to change so you typically have to regenerate the
-# default header when upgrading to a newer version of doxygen. For a description
-# of the possible markers and block names see the documentation.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_HEADER =
-
-# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
-# generated HTML page. If the tag is left blank doxygen will generate a standard
-# footer. See HTML_HEADER for more information on how to generate a default
-# footer and what special commands can be used inside the footer. See also
-# section "Doxygen usage" for information on how to generate the default footer
-# that doxygen normally uses.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_FOOTER =
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
-# sheet that is used by each HTML page. It can be used to fine-tune the look of
-# the HTML output. If left blank doxygen will generate a default style sheet.
-# See also section "Doxygen usage" for information on how to generate the style
-# sheet that doxygen normally uses.
-# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
-# it is more robust and this tag (HTML_STYLESHEET) will in the future become
-# obsolete.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_STYLESHEET =
-
-# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
-# cascading style sheets that are included after the standard style sheets
-# created by doxygen. Using this option one can overrule certain style aspects.
-# This is preferred over using HTML_STYLESHEET since it does not replace the
-# standard style sheet and is therefore more robust against future updates.
-# Doxygen will copy the style sheet files to the output directory.
-# Note: The order of the extra style sheet files is of importance (e.g. the last
-# style sheet in the list overrules the setting of the previous ones in the
-# list). For an example see the documentation.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_EXTRA_STYLESHEET =
-
-# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
-# other source files which should be copied to the HTML output directory. Note
-# that these files will be copied to the base HTML output directory. Use the
-# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
-# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
-# files will be copied as-is; there are no commands or markers available.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_EXTRA_FILES = README
-
-# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
-# will adjust the colors in the style sheet and background images according to
-# this color. Hue is specified as an angle on a colorwheel, see
-# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
-# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
-# purple, and 360 is red again.
-# Minimum value: 0, maximum value: 359, default value: 220.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_COLORSTYLE_HUE = 220
-
-# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
-# in the HTML output. For a value of 0 the output will use grayscales only. A
-# value of 255 will produce the most vivid colors.
-# Minimum value: 0, maximum value: 255, default value: 100.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_COLORSTYLE_SAT = 100
-
-# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
-# luminance component of the colors in the HTML output. Values below 100
-# gradually make the output lighter, whereas values above 100 make the output
-# darker. The value divided by 100 is the actual gamma applied, so 80 represents
-# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
-# change the gamma.
-# Minimum value: 40, maximum value: 240, default value: 80.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_COLORSTYLE_GAMMA = 80
-
-# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
-# page will contain the date and time when the page was generated. Setting this
-# to YES can help to show when doxygen was last run and thus if the
-# documentation is up to date.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_TIMESTAMP = YES
-
-# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
-# documentation will contain sections that can be hidden and shown after the
-# page has loaded.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_DYNAMIC_SECTIONS = NO
-
-# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
-# shown in the various tree structured indices initially; the user can expand
-# and collapse entries dynamically later on. Doxygen will expand the tree to
-# such a level that at most the specified number of entries are visible (unless
-# a fully collapsed tree already exceeds this amount). So setting the number of
-# entries 1 will produce a full collapsed tree by default. 0 is a special value
-# representing an infinite number of entries and will result in a full expanded
-# tree by default.
-# Minimum value: 0, maximum value: 9999, default value: 100.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-HTML_INDEX_NUM_ENTRIES = 100
-
-# If the GENERATE_DOCSET tag is set to YES, additional index files will be
-# generated that can be used as input for Apple's Xcode 3 integrated development
-# environment (see: http://developer.apple.com/tools/xcode/), introduced with
-# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
-# Makefile in the HTML output directory. Running make will produce the docset in
-# that directory and running make install will install the docset in
-# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
-# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
-# for more information.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-GENERATE_DOCSET = NO
-
-# This tag determines the name of the docset feed. A documentation feed provides
-# an umbrella under which multiple documentation sets from a single provider
-# (such as a company or product suite) can be grouped.
-# The default value is: Doxygen generated docs.
-# This tag requires that the tag GENERATE_DOCSET is set to YES.
-
-DOCSET_FEEDNAME = "Doxygen generated docs"
-
-# This tag specifies a string that should uniquely identify the documentation
-# set bundle. This should be a reverse domain-name style string, e.g.
-# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
-# The default value is: org.doxygen.Project.
-# This tag requires that the tag GENERATE_DOCSET is set to YES.
-
-DOCSET_BUNDLE_ID = org.doxygen.Project
-
-# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
-# the documentation publisher. This should be a reverse domain-name style
-# string, e.g. com.mycompany.MyDocSet.documentation.
-# The default value is: org.doxygen.Publisher.
-# This tag requires that the tag GENERATE_DOCSET is set to YES.
-
-DOCSET_PUBLISHER_ID = org.doxygen.Publisher
-
-# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
-# The default value is: Publisher.
-# This tag requires that the tag GENERATE_DOCSET is set to YES.
-
-DOCSET_PUBLISHER_NAME = Publisher
-
-# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
-# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
-# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
-# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
-# Windows.
-#
-# The HTML Help Workshop contains a compiler that can convert all HTML output
-# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
-# files are now used as the Windows 98 help format, and will replace the old
-# Windows help format (.hlp) on all Windows platforms in the future. Compressed
-# HTML files also contain an index, a table of contents, and you can search for
-# words in the documentation. The HTML workshop also contains a viewer for
-# compressed HTML files.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-GENERATE_HTMLHELP = NO
-
-# The CHM_FILE tag can be used to specify the file name of the resulting .chm
-# file. You can add a path in front of the file if the result should not be
-# written to the html output directory.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-CHM_FILE =
-
-# The HHC_LOCATION tag can be used to specify the location (absolute path
-# including file name) of the HTML help compiler (hhc.exe). If non-empty,
-# doxygen will try to run the HTML help compiler on the generated index.hhp.
-# The file has to be specified with full path.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-HHC_LOCATION =
-
-# The GENERATE_CHI flag controls if a separate .chi index file is generated
-# (YES) or that it should be included in the master .chm file (NO).
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-GENERATE_CHI = NO
-
-# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
-# and project file content.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-CHM_INDEX_ENCODING =
-
-# The BINARY_TOC flag controls whether a binary table of contents is generated
-# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
-# enables the Previous and Next buttons.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-BINARY_TOC = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members to
-# the table of contents of the HTML help documentation and to the tree view.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-TOC_EXPAND = NO
-
-# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
-# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
-# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
-# (.qch) of the generated HTML documentation.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-GENERATE_QHP = NO
-
-# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
-# the file name of the resulting .qch file. The path specified is relative to
-# the HTML output folder.
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QCH_FILE =
-
-# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
-# Project output. For more information please see Qt Help Project / Namespace
-# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
-# The default value is: org.doxygen.Project.
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHP_NAMESPACE = org.doxygen.Project
-
-# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
-# Help Project output. For more information please see Qt Help Project / Virtual
-# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
-# folders).
-# The default value is: doc.
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHP_VIRTUAL_FOLDER = doc
-
-# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
-# filter to add. For more information please see Qt Help Project / Custom
-# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
-# filters).
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHP_CUST_FILTER_NAME =
-
-# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
-# custom filter to add. For more information please see Qt Help Project / Custom
-# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
-# filters).
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHP_CUST_FILTER_ATTRS =
-
-# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
-# project's filter section matches. Qt Help Project / Filter Attributes (see:
-# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHP_SECT_FILTER_ATTRS =
-
-# The QHG_LOCATION tag can be used to specify the location of Qt's
-# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
-# generated .qhp file.
-# This tag requires that the tag GENERATE_QHP is set to YES.
-
-QHG_LOCATION =
-
-# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
-# generated, together with the HTML files, they form an Eclipse help plugin. To
-# install this plugin and make it available under the help contents menu in
-# Eclipse, the contents of the directory containing the HTML and XML files needs
-# to be copied into the plugins directory of eclipse. The name of the directory
-# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
-# After copying Eclipse needs to be restarted before the help appears.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-GENERATE_ECLIPSEHELP = NO
-
-# A unique identifier for the Eclipse help plugin. When installing the plugin
-# the directory name containing the HTML and XML files should also have this
-# name. Each documentation set should have its own identifier.
-# The default value is: org.doxygen.Project.
-# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
-
-ECLIPSE_DOC_ID = org.doxygen.Project
-
-# If you want full control over the layout of the generated HTML pages it might
-# be necessary to disable the index and replace it with your own. The
-# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
-# of each HTML page. A value of NO enables the index and the value YES disables
-# it. Since the tabs in the index contain the same information as the navigation
-# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-DISABLE_INDEX = NO
-
-# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
-# structure should be generated to display hierarchical information. If the tag
-# value is set to YES, a side panel will be generated containing a tree-like
-# index structure (just like the one that is generated for HTML Help). For this
-# to work a browser that supports JavaScript, DHTML, CSS and frames is required
-# (i.e. any modern browser). Windows users are probably better off using the
-# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
-# further fine-tune the look of the index. As an example, the default style
-# sheet generated by doxygen has an example that shows how to put an image at
-# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
-# the same information as the tab index, you could consider setting
-# DISABLE_INDEX to YES when enabling this option.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-GENERATE_TREEVIEW = NO
-
-# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
-# doxygen will group on one line in the generated HTML documentation.
-#
-# Note that a value of 0 will completely suppress the enum values from appearing
-# in the overview section.
-# Minimum value: 0, maximum value: 20, default value: 4.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-ENUM_VALUES_PER_LINE = 4
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
-# to set the initial width (in pixels) of the frame in which the tree is shown.
-# Minimum value: 0, maximum value: 1500, default value: 250.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-TREEVIEW_WIDTH = 250
-
-# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
-# external symbols imported via tag files in a separate window.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-EXT_LINKS_IN_WINDOW = NO
-
-# Use this tag to change the font size of LaTeX formulas included as images in
-# the HTML documentation. When you change the font size after a successful
-# doxygen run you need to manually remove any form_*.png images from the HTML
-# output directory to force them to be regenerated.
-# Minimum value: 8, maximum value: 50, default value: 10.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-FORMULA_FONTSIZE = 10
-
-# Use the FORMULA_TRANPARENT tag to determine whether or not the images
-# generated for formulas are transparent PNGs. Transparent PNGs are not
-# supported properly for IE 6.0, but are supported on all modern browsers.
-#
-# Note that when changing this option you need to delete any form_*.png files in
-# the HTML output directory before the changes have effect.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-FORMULA_TRANSPARENT = YES
-
-# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
-# http://www.mathjax.org) which uses client side Javascript for the rendering
-# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
-# installed or if you want to formulas look prettier in the HTML output. When
-# enabled you may also need to install MathJax separately and configure the path
-# to it using the MATHJAX_RELPATH option.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-USE_MATHJAX = NO
-
-# When MathJax is enabled you can set the default output format to be used for
-# the MathJax output. See the MathJax site (see:
-# http://docs.mathjax.org/en/latest/output.html) for more details.
-# Possible values are: HTML-CSS (which is slower, but has the best
-# compatibility), NativeMML (i.e. MathML) and SVG.
-# The default value is: HTML-CSS.
-# This tag requires that the tag USE_MATHJAX is set to YES.
-
-MATHJAX_FORMAT = HTML-CSS
-
-# When MathJax is enabled you need to specify the location relative to the HTML
-# output directory using the MATHJAX_RELPATH option. The destination directory
-# should contain the MathJax.js script. For instance, if the mathjax directory
-# is located at the same level as the HTML output directory, then
-# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
-# Content Delivery Network so you can quickly see the result without installing
-# MathJax. However, it is strongly recommended to install a local copy of
-# MathJax from http://www.mathjax.org before deployment.
-# The default value is: http://cdn.mathjax.org/mathjax/latest.
-# This tag requires that the tag USE_MATHJAX is set to YES.
-
-MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
-
-# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
-# extension names that should be enabled during MathJax rendering. For example
-# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
-# This tag requires that the tag USE_MATHJAX is set to YES.
-
-MATHJAX_EXTENSIONS =
-
-# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
-# of code that will be used on startup of the MathJax code. See the MathJax site
-# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
-# example see the documentation.
-# This tag requires that the tag USE_MATHJAX is set to YES.
-
-MATHJAX_CODEFILE =
-
-# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
-# the HTML output. The underlying search engine uses javascript and DHTML and
-# should work on any modern browser. Note that when using HTML help
-# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
-# there is already a search function so this one should typically be disabled.
-# For large projects the javascript based search engine can be slow, then
-# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
-# search using the keyboard; to jump to the search box use + S
-# (what the is depends on the OS and browser, but it is typically
-# , /, or both). Inside the search box use the to jump into the search results window, the results can be navigated
-# using the . Press to select an item or to cancel
-# the search. The filter options can be selected when the cursor is inside the
-# search box by pressing +. Also here use the
-# to select a filter and or to activate or cancel the filter
-# option.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_HTML is set to YES.
-
-SEARCHENGINE = YES
-
-# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
-# implemented using a web server instead of a web client using Javascript. There
-# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
-# setting. When disabled, doxygen will generate a PHP script for searching and
-# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
-# and searching needs to be provided by external tools. See the section
-# "External Indexing and Searching" for details.
-# The default value is: NO.
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-SERVER_BASED_SEARCH = NO
-
-# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
-# script for searching. Instead the search results are written to an XML file
-# which needs to be processed by an external indexer. Doxygen will invoke an
-# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
-# search results.
-#
-# Doxygen ships with an example indexer (doxyindexer) and search engine
-# (doxysearch.cgi) which are based on the open source search engine library
-# Xapian (see: http://xapian.org/).
-#
-# See the section "External Indexing and Searching" for details.
-# The default value is: NO.
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-EXTERNAL_SEARCH = NO
-
-# The SEARCHENGINE_URL should point to a search engine hosted by a web server
-# which will return the search results when EXTERNAL_SEARCH is enabled.
-#
-# Doxygen ships with an example indexer (doxyindexer) and search engine
-# (doxysearch.cgi) which are based on the open source search engine library
-# Xapian (see: http://xapian.org/). See the section "External Indexing and
-# Searching" for details.
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-SEARCHENGINE_URL =
-
-# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
-# search data is written to a file for indexing by an external tool. With the
-# SEARCHDATA_FILE tag the name of this file can be specified.
-# The default file is: searchdata.xml.
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-SEARCHDATA_FILE = searchdata.xml
-
-# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
-# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
-# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
-# projects and redirect the results back to the right project.
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-EXTERNAL_SEARCH_ID =
-
-# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
-# projects other than the one defined by this configuration file, but that are
-# all added to the same external search index. Each project needs to have a
-# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
-# to a relative location where the documentation can be found. The format is:
-# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
-# This tag requires that the tag SEARCHENGINE is set to YES.
-
-EXTRA_SEARCH_MAPPINGS =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
-# The default value is: YES.
-
-GENERATE_LATEX = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
-# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
-# it.
-# The default directory is: latex.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_OUTPUT = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked.
-#
-# Note that when enabling USE_PDFLATEX this option is only used for generating
-# bitmaps for formulas in the HTML output, but not in the Makefile that is
-# written to the output directory.
-# The default file is: latex.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_CMD_NAME = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
-# index for LaTeX.
-# The default file is: makeindex.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-MAKEINDEX_CMD_NAME = makeindex
-
-# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
-# documents. This may be useful for small projects and may help to save some
-# trees in general.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-COMPACT_LATEX = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used by the
-# printer.
-# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
-# 14 inches) and executive (7.25 x 10.5 inches).
-# The default value is: a4.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-PAPER_TYPE = a4
-
-# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
-# that should be included in the LaTeX output. The package can be specified just
-# by its name or with the correct syntax as to be used with the LaTeX
-# \usepackage command. To get the times font for instance you can specify :
-# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
-# To use the option intlimits with the amsmath package you can specify:
-# EXTRA_PACKAGES=[intlimits]{amsmath}
-# If left blank no extra packages will be included.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-EXTRA_PACKAGES =
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
-# generated LaTeX document. The header should contain everything until the first
-# chapter. If it is left blank doxygen will generate a standard header. See
-# section "Doxygen usage" for information on how to let doxygen write the
-# default header to a separate file.
-#
-# Note: Only use a user-defined header if you know what you are doing! The
-# following commands have a special meaning inside the header: $title,
-# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
-# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
-# string, for the replacement values of the other commands the user is referred
-# to HTML_HEADER.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_HEADER =
-
-# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
-# generated LaTeX document. The footer should contain everything after the last
-# chapter. If it is left blank doxygen will generate a standard footer. See
-# LATEX_HEADER for more information on how to generate a default footer and what
-# special commands can be used inside the footer.
-#
-# Note: Only use a user-defined footer if you know what you are doing!
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_FOOTER =
-
-# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
-# LaTeX style sheets that are included after the standard style sheets created
-# by doxygen. Using this option one can overrule certain style aspects. Doxygen
-# will copy the style sheet files to the output directory.
-# Note: The order of the extra style sheet files is of importance (e.g. the last
-# style sheet in the list overrules the setting of the previous ones in the
-# list).
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_EXTRA_STYLESHEET =
-
-# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
-# other source files which should be copied to the LATEX_OUTPUT output
-# directory. Note that the files will be copied as-is; there are no commands or
-# markers available.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_EXTRA_FILES =
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
-# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
-# contain links (just like the HTML output) instead of page references. This
-# makes the output suitable for online browsing using a PDF viewer.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-PDF_HYPERLINKS = YES
-
-# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
-# the PDF file directly from the LaTeX files. Set this option to YES, to get a
-# higher quality PDF documentation.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-USE_PDFLATEX = YES
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
-# command to the generated LaTeX files. This will instruct LaTeX to keep running
-# if errors occur, instead of asking the user for help. This option is also used
-# when generating formulas in HTML.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_BATCHMODE = NO
-
-# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
-# index chapters (such as File Index, Compound Index, etc.) in the output.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_HIDE_INDICES = NO
-
-# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
-# code with syntax highlighting in the LaTeX output.
-#
-# Note that which sources are shown also depends on other settings such as
-# SOURCE_BROWSER.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_SOURCE_CODE = NO
-
-# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
-# bibliography, e.g. plainnat, or ieeetr. See
-# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
-# The default value is: plain.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_BIB_STYLE = plain
-
-# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
-# page will contain the date and time when the page was generated. Setting this
-# to NO can help when comparing the output of multiple runs.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_LATEX is set to YES.
-
-LATEX_TIMESTAMP = NO
-
-#---------------------------------------------------------------------------
-# Configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
-# RTF output is optimized for Word 97 and may not look too pretty with other RTF
-# readers/editors.
-# The default value is: NO.
-
-GENERATE_RTF = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
-# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
-# it.
-# The default directory is: rtf.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-RTF_OUTPUT = rtf
-
-# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
-# documents. This may be useful for small projects and may help to save some
-# trees in general.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-COMPACT_RTF = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
-# contain hyperlink fields. The RTF file will contain links (just like the HTML
-# output) instead of page references. This makes the output suitable for online
-# browsing using Word or some other Word compatible readers that support those
-# fields.
-#
-# Note: WordPad (write) and others do not support links.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-RTF_HYPERLINKS = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's config
-# file, i.e. a series of assignments. You only have to provide replacements,
-# missing definitions are set to their default value.
-#
-# See also section "Doxygen usage" for information on how to generate the
-# default style sheet that doxygen normally uses.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-RTF_STYLESHEET_FILE =
-
-# Set optional variables used in the generation of an RTF document. Syntax is
-# similar to doxygen's config file. A template extensions file can be generated
-# using doxygen -e rtf extensionFile.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-RTF_EXTENSIONS_FILE =
-
-# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
-# with syntax highlighting in the RTF output.
-#
-# Note that which sources are shown also depends on other settings such as
-# SOURCE_BROWSER.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_RTF is set to YES.
-
-RTF_SOURCE_CODE = NO
-
-#---------------------------------------------------------------------------
-# Configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
-# classes and files.
-# The default value is: NO.
-
-GENERATE_MAN = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
-# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
-# it. A directory man3 will be created inside the directory specified by
-# MAN_OUTPUT.
-# The default directory is: man.
-# This tag requires that the tag GENERATE_MAN is set to YES.
-
-MAN_OUTPUT = man
-
-# The MAN_EXTENSION tag determines the extension that is added to the generated
-# man pages. In case the manual section does not start with a number, the number
-# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
-# optional.
-# The default value is: .3.
-# This tag requires that the tag GENERATE_MAN is set to YES.
-
-MAN_EXTENSION = .3
-
-# The MAN_SUBDIR tag determines the name of the directory created within
-# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
-# MAN_EXTENSION with the initial . removed.
-# This tag requires that the tag GENERATE_MAN is set to YES.
-
-MAN_SUBDIR =
-
-# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
-# will generate one additional man file for each entity documented in the real
-# man page(s). These additional files only source the real man page, but without
-# them the man command would be unable to find the correct page.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_MAN is set to YES.
-
-MAN_LINKS = NO
-
-#---------------------------------------------------------------------------
-# Configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
-# captures the structure of the code including all documentation.
-# The default value is: NO.
-
-GENERATE_XML = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
-# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
-# it.
-# The default directory is: xml.
-# This tag requires that the tag GENERATE_XML is set to YES.
-
-XML_OUTPUT = xml
-
-# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
-# listings (including syntax highlighting and cross-referencing information) to
-# the XML output. Note that enabling this will significantly increase the size
-# of the XML output.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_XML is set to YES.
-
-XML_PROGRAMLISTING = YES
-
-#---------------------------------------------------------------------------
-# Configuration options related to the DOCBOOK output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
-# that can be used to generate PDF.
-# The default value is: NO.
-
-GENERATE_DOCBOOK = NO
-
-# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
-# front of it.
-# The default directory is: docbook.
-# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
-
-DOCBOOK_OUTPUT = docbook
-
-# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
-# program listings (including syntax highlighting and cross-referencing
-# information) to the DOCBOOK output. Note that enabling this will significantly
-# increase the size of the DOCBOOK output.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
-
-DOCBOOK_PROGRAMLISTING = NO
-
-#---------------------------------------------------------------------------
-# Configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
-# AutoGen Definitions (see http://autogen.sf.net) file that captures the
-# structure of the code including all documentation. Note that this feature is
-# still experimental and incomplete at the moment.
-# The default value is: NO.
-
-GENERATE_AUTOGEN_DEF = NO
-
-#---------------------------------------------------------------------------
-# Configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
-# file that captures the structure of the code including all documentation.
-#
-# Note that this feature is still experimental and incomplete at the moment.
-# The default value is: NO.
-
-GENERATE_PERLMOD = NO
-
-# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
-# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
-# output from the Perl module output.
-# The default value is: NO.
-# This tag requires that the tag GENERATE_PERLMOD is set to YES.
-
-PERLMOD_LATEX = NO
-
-# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
-# formatted so it can be parsed by a human reader. This is useful if you want to
-# understand what is going on. On the other hand, if this tag is set to NO, the
-# size of the Perl module output will be much smaller and Perl will parse it
-# just the same.
-# The default value is: YES.
-# This tag requires that the tag GENERATE_PERLMOD is set to YES.
-
-PERLMOD_PRETTY = YES
-
-# The names of the make variables in the generated doxyrules.make file are
-# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
-# so different doxyrules.make files included by the same Makefile don't
-# overwrite each other's variables.
-# This tag requires that the tag GENERATE_PERLMOD is set to YES.
-
-PERLMOD_MAKEVAR_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
-# C-preprocessor directives found in the sources and include files.
-# The default value is: YES.
-
-ENABLE_PREPROCESSING = YES
-
-# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
-# in the source code. If set to NO, only conditional compilation will be
-# performed. Macro expansion can be done in a controlled way by setting
-# EXPAND_ONLY_PREDEF to YES.
-# The default value is: NO.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-MACRO_EXPANSION = NO
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
-# the macro expansion is limited to the macros specified with the PREDEFINED and
-# EXPAND_AS_DEFINED tags.
-# The default value is: NO.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-EXPAND_ONLY_PREDEF = NO
-
-# If the SEARCH_INCLUDES tag is set to YES, the include files in the
-# INCLUDE_PATH will be searched if a #include is found.
-# The default value is: YES.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-SEARCH_INCLUDES = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by the
-# preprocessor.
-# This tag requires that the tag SEARCH_INCLUDES is set to YES.
-
-INCLUDE_PATH =
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
-# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will be
-# used.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-INCLUDE_FILE_PATTERNS =
-
-# The PREDEFINED tag can be used to specify one or more macro names that are
-# defined before the preprocessor is started (similar to the -D option of e.g.
-# gcc). The argument of the tag is a list of macros of the form: name or
-# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
-# is assumed. To prevent a macro definition from being undefined via #undef or
-# recursively expanded use the := operator instead of the = operator.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-PREDEFINED =
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
-# tag can be used to specify a list of macro names that should be expanded. The
-# macro definition that is found in the sources will be used. Use the PREDEFINED
-# tag if you want to use a different macro definition that overrules the
-# definition found in the source code.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-EXPAND_AS_DEFINED =
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
-# remove all references to function-like macros that are alone on a line, have
-# an all uppercase name, and do not end with a semicolon. Such function macros
-# are typically used for boiler-plate code, and will confuse the parser if not
-# removed.
-# The default value is: YES.
-# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-
-SKIP_FUNCTION_MACROS = YES
-
-#---------------------------------------------------------------------------
-# Configuration options related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES tag can be used to specify one or more tag files. For each tag
-# file the location of the external documentation should be added. The format of
-# a tag file without this location is as follows:
-# TAGFILES = file1 file2 ...
-# Adding location for the tag files is done as follows:
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where loc1 and loc2 can be relative or absolute paths or URLs. See the
-# section "Linking to external documentation" for more information about the use
-# of tag files.
-# Note: Each tag file must have a unique name (where the name does NOT include
-# the path). If a tag file is not located in the directory in which doxygen is
-# run, you must also specify the path to the tagfile here.
-
-TAGFILES =
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
-# tag file that is based on the input files it reads. See section "Linking to
-# external documentation" for more information about the usage of tag files.
-
-GENERATE_TAGFILE =
-
-# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
-# the class index. If set to NO, only the inherited external classes will be
-# listed.
-# The default value is: NO.
-
-ALLEXTERNALS = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will be
-# listed.
-# The default value is: YES.
-
-EXTERNAL_GROUPS = YES
-
-# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
-# the related pages index. If set to NO, only the current project's pages will
-# be listed.
-# The default value is: YES.
-
-EXTERNAL_PAGES = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of 'which perl').
-# The default file (with absolute path) is: /usr/bin/perl.
-
-PERL_PATH = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
-# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
-# NO turns the diagrams off. Note that this option also works with HAVE_DOT
-# disabled, but it is recommended to install and use dot, since it yields more
-# powerful graphs.
-# The default value is: YES.
-
-CLASS_DIAGRAMS = YES
-
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see:
-# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where
-# the mscgen tool resides. If left empty the tool is assumed to be found in the
-# default search path.
-
-MSCGEN_PATH =
-
-# You can include diagrams made with dia in doxygen documentation. Doxygen will
-# then run dia to produce the diagram and insert it in the documentation. The
-# DIA_PATH tag allows you to specify the directory where the dia binary resides.
-# If left empty dia is assumed to be found in the default search path.
-
-DIA_PATH =
-
-# If set to YES the inheritance and collaboration graphs will hide inheritance
-# and usage relations if the target is undocumented or is not a class.
-# The default value is: YES.
-
-HIDE_UNDOC_RELATIONS = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz (see:
-# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
-# Bell Labs. The other options in this section have no effect if this option is
-# set to NO
-# The default value is: NO.
-
-HAVE_DOT = NO
-
-# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
-# to run in parallel. When set to 0 doxygen will base this on the number of
-# processors available in the system. You can set it explicitly to a value
-# larger than 0 to get control over the balance between CPU load and processing
-# speed.
-# Minimum value: 0, maximum value: 32, default value: 0.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_NUM_THREADS = 0
-
-# When you want a differently looking font in the dot files that doxygen
-# generates you can specify the font name using DOT_FONTNAME. You need to make
-# sure dot is able to find the font, which can be done by putting it in a
-# standard location or by setting the DOTFONTPATH environment variable or by
-# setting DOT_FONTPATH to the directory containing the font.
-# The default value is: Helvetica.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_FONTNAME = Helvetica
-
-# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
-# dot graphs.
-# Minimum value: 4, maximum value: 24, default value: 10.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_FONTSIZE = 10
-
-# By default doxygen will tell dot to use the default font as specified with
-# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set
-# the path where dot can find it using this tag.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_FONTPATH =
-
-# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
-# each documented class showing the direct and indirect inheritance relations.
-# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-CLASS_GRAPH = YES
-
-# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
-# graph for each documented class showing the direct and indirect implementation
-# dependencies (inheritance, containment, and class references variables) of the
-# class with other documented classes.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-COLLABORATION_GRAPH = YES
-
-# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
-# groups, showing the direct groups dependencies.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-GROUP_GRAPHS = YES
-
-# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
-# collaboration diagrams in a style similar to the OMG's Unified Modeling
-# Language.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-UML_LOOK = NO
-
-# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
-# class node. If there are many fields or methods and many nodes the graph may
-# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
-# number of items for each type to make the size more manageable. Set this to 0
-# for no limit. Note that the threshold may be exceeded by 50% before the limit
-# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
-# but if the number exceeds 15, the total amount of fields shown is limited to
-# 10.
-# Minimum value: 0, maximum value: 100, default value: 10.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-UML_LIMIT_NUM_FIELDS = 10
-
-# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
-# collaboration graphs will show the relations between templates and their
-# instances.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-TEMPLATE_RELATIONS = NO
-
-# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
-# YES then doxygen will generate a graph for each documented file showing the
-# direct and indirect include dependencies of the file with other documented
-# files.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-INCLUDE_GRAPH = YES
-
-# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
-# set to YES then doxygen will generate a graph for each documented file showing
-# the direct and indirect include dependencies of the file with other documented
-# files.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-INCLUDED_BY_GRAPH = YES
-
-# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
-# dependency graph for every global function or class method.
-#
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable call graphs for selected
-# functions only using the \callgraph command. Disabling a call graph can be
-# accomplished by means of the command \hidecallgraph.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-CALL_GRAPH = NO
-
-# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
-# dependency graph for every global function or class method.
-#
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable caller graphs for selected
-# functions only using the \callergraph command. Disabling a caller graph can be
-# accomplished by means of the command \hidecallergraph.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-CALLER_GRAPH = NO
-
-# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
-# hierarchy of all classes instead of a textual one.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-GRAPHICAL_HIERARCHY = YES
-
-# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
-# dependencies a directory has on other directories in a graphical way. The
-# dependency relations are determined by the #include relations between the
-# files in the directories.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DIRECTORY_GRAPH = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. For an explanation of the image formats see the section
-# output formats in the documentation of the dot tool (Graphviz (see:
-# http://www.graphviz.org/)).
-# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
-# to make the SVG files visible in IE 9+ (other browsers do not have this
-# requirement).
-# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo,
-# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
-# png:gdiplus:gdiplus.
-# The default value is: png.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_IMAGE_FORMAT = png
-
-# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
-# enable generation of interactive SVG images that allow zooming and panning.
-#
-# Note that this requires a modern browser other than Internet Explorer. Tested
-# and working are Firefox, Chrome, Safari, and Opera.
-# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
-# the SVG files visible. Older versions of IE do not have SVG support.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-INTERACTIVE_SVG = NO
-
-# The DOT_PATH tag can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found in the path.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_PATH =
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the \dotfile
-# command).
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOTFILE_DIRS =
-
-# The MSCFILE_DIRS tag can be used to specify one or more directories that
-# contain msc files that are included in the documentation (see the \mscfile
-# command).
-
-MSCFILE_DIRS =
-
-# The DIAFILE_DIRS tag can be used to specify one or more directories that
-# contain dia files that are included in the documentation (see the \diafile
-# command).
-
-DIAFILE_DIRS =
-
-# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
-# path where java can find the plantuml.jar file. If left blank, it is assumed
-# PlantUML is not used or called during a preprocessing step. Doxygen will
-# generate a warning when it encounters a \startuml command in this case and
-# will not generate output for the diagram.
-
-PLANTUML_JAR_PATH =
-
-# When using plantuml, the specified paths are searched for files specified by
-# the !include statement in a plantuml block.
-
-PLANTUML_INCLUDE_PATH =
-
-# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
-# that will be shown in the graph. If the number of nodes in a graph becomes
-# larger than this value, doxygen will truncate the graph, which is visualized
-# by representing a node as a red box. Note that doxygen if the number of direct
-# children of the root node in a graph is already larger than
-# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
-# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
-# Minimum value: 0, maximum value: 10000, default value: 50.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_GRAPH_MAX_NODES = 50
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
-# generated by dot. A depth value of 3 means that only nodes reachable from the
-# root by following a path via at most 3 edges will be shown. Nodes that lay
-# further from the root node will be omitted. Note that setting this option to 1
-# or 2 may greatly reduce the computation time needed for large code bases. Also
-# note that the size of a graph can be further restricted by
-# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
-# Minimum value: 0, maximum value: 1000, default value: 0.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-MAX_DOT_GRAPH_DEPTH = 0
-
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
-# background. This is disabled by default, because dot on Windows does not seem
-# to support this out of the box.
-#
-# Warning: Depending on the platform used, enabling this option may lead to
-# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
-# read).
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_TRANSPARENT = NO
-
-# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
-# files in one run (i.e. multiple -o and -T options on the command line). This
-# makes dot run faster, but since only newer versions of dot (>1.8.10) support
-# this, this feature is disabled by default.
-# The default value is: NO.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_MULTI_TARGETS = NO
-
-# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
-# explaining the meaning of the various boxes and arrows in the dot generated
-# graphs.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-GENERATE_LEGEND = YES
-
-# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
-# files that are used to generate the various graphs.
-# The default value is: YES.
-# This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_CLEANUP = YES
diff --git a/client/client-multi/client-c/Modules/FindCUnit.cmake b/client/client-multi/client-c/Modules/FindCUnit.cmake
deleted file mode 100644
index 611a8aea29..0000000000
--- a/client/client-multi/client-c/Modules/FindCUnit.cmake
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-
-# Find the CUnit headers and libraries
-#
-# CUNIT_INCLUDE_DIRS - The CUnit include directory (directory where CUnit/CUnit.h was found)
-# CUNIT_LIBRARIES - The libraries needed to use CUnit
-# CUNIT_FOUND - True if CUnit found in system
-
-
-FIND_PATH(CUNIT_INCLUDE_DIR NAMES CUnit/CUnit.h)
-MARK_AS_ADVANCED(CUNIT_INCLUDE_DIR)
-
-FIND_LIBRARY(CUNIT_LIBRARY NAMES
- cunit
- libcunit
- cunitlib
-)
-MARK_AS_ADVANCED(CUNIT_LIBRARY)
-
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(CUnit DEFAULT_MSG CUNIT_LIBRARY CUNIT_INCLUDE_DIR)
-
-IF(CUNIT_FOUND)
- SET(CUNIT_LIBRARIES ${CUNIT_LIBRARY})
- SET(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR})
-ENDIF(CUNIT_FOUND)
diff --git a/client/client-multi/client-c/Modules/cppcheck/CMakeLists.txt b/client/client-multi/client-c/Modules/cppcheck/CMakeLists.txt
deleted file mode 100644
index 15b2dcc624..0000000000
--- a/client/client-multi/client-c/Modules/cppcheck/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# This cmake list is responsible for running cppcheck against sources.
-
-find_program(CPPCHECK_COMMAND cppcheck)
-
-if(CPPCHECK_COMMAND)
- add_custom_target(cppcheck
- COMMAND ${CPPCHECK_COMMAND} --quiet --enable=all --std=c99 --suppress=unusedFunction
- --force --error-exitcode=1 --template=gcc -I src/kaa
- --inline-suppr src/ test/
- -ithirdparty/
- WORKING_DERICTORY ${KAA_SDK_DIR}
- COMMENT "Running cppcheck"
- VERBATIM
- )
-else()
- message (STATUS "Could NOT find cppcheck")
-endif()
diff --git a/client/client-multi/client-c/Modules/doxygen/CMakeLists.txt b/client/client-multi/client-c/Modules/doxygen/CMakeLists.txt
deleted file mode 100644
index ccbcc080b2..0000000000
--- a/client/client-multi/client-c/Modules/doxygen/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# This cmake list is responsible for building doxygen documentation.
-
-find_package(Doxygen)
-
-add_custom_target(doxygen
- COMMAND ${CMAKE_COMMAND} -E make_directory target/apidocs/doxygen
- COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
- WORKING_DIRECTORY
- ${KAA_SDK_DIR}
- COMMENT "Generating doxygen docs"
- VERBATIM
- )
\ No newline at end of file
diff --git a/client/client-multi/client-c/README b/client/client-multi/client-c/README
deleted file mode 100644
index 23ddb97975..0000000000
--- a/client/client-multi/client-c/README
+++ /dev/null
@@ -1,179 +0,0 @@
-#
-# Copyright 2014-2015 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-************************************
-PREREQUISITES
-************************************
-
-Before building the C endpoint SDK, ensure the following components
-are installed:
-
-1. C compiler supporting the C99 standard
-2. cmake 2.8.8 or later
-
-************************************
-INSTALL
-************************************
-
-To build the C endpoint SDK, do the following:
-
-1. Download and untar the Kaa C SDK archive.
-2. Run the following commands:
-
- mkdir build
- cd build
-
-For x86-64:
- cmake ..
- make
- make install
-
-For iOS:
- cmake -DKAA_PLATFORM=ios -DCMAKE_TOOLCHAIN_FILE=../toolchains/iOS.cmake -GXcode ..
- xcodebuild
-
-************************************
-GENERAL CONFIGURATION
-************************************
-
-To configure the C endpoint SDK build, you can optionally specify
-the following parameters for the cmake command:
-------------------------------------
-KAA_INSTALL_PATH - specify the directory for Kaa to be installed.
-
-Accepted:
-'/path/to/some/directory'
-
-Default:
-'/usr/local'
-------------------------------------
-KAA_DEBUG_ENABLED=[0|1] - build type.
-
-Values:
-0 - the release type
-1 - the debug type
-
-Default:
-0
-------------------------------------
-KAA_MAX_LOG_LEVEL - maximum log level used by the Kaa SDK.
-
-Values:
-0 - NONE (no logs)
-1 - FATAL
-2 - ERROR
-3 - WARN
-4 - INFO
-5 - DEBUG
-6 - TRACE
-
-Default:
-4 - if KAA_DEBUG_ENABLED=0
-6 - if KAA_DEBUG_ENABLED=1
-------------------------------------
-KAA_WITHOUT_ - Kaa module to be omitted during the build.
-
-Values:
-EVENTS
-LOGGING
-CONFIGURATION
-
-Default:
-All modules are present in the build.
-------------------------------------
-KAA_PLATFORM - SDK target platform.
-
-Values:
-x86-64
-ios
-
-Default:
-x86-64
-
-Before running the cmake command with the KAA_PLATFORM parameter
-for a platform other than x86-64, do the following:
-
-1. Create a folder in $KAA_HOME/listfiles/platform/ and name it
- using [a-zA-z_-] symbols. You will be able to use the folder name
- as a value for the KAA_PLATFORM parameter.
-
-2. Put the CMakeLists.txt file into the created folder. This file may contain
- specific compilation/linking flags, platform-dependent source files,
- third-party library dependencies, that is all information necessary
- for building the C endpoint SDK for this platform.
-
-3. Optionally, specify the following parameters in the CMakeLists.txt file:
-
- KAA_INCLUDE_PATHS - full path(s) to folder(s) containing additional
- header files
- KAA_SOURCE_FILES - full path(s) to additional source files
- KAA_THIRDPARTY_LIBRARIES - third-party libraries
-
- In the CMakeLists.txt file:
-
- set(KAA_INCLUDE_PATHS
- ${KAA_INCLUDE_PATHS}
- path_to_folder_1_with_header_files
- path_to_folder_2_with_header_files
- )
- set(KAA_SOURCE_FILES
- ${KAA_SOURCE_FILES}
- path_to_source_file_1
- path_to_source_file_2
- )
- set(KAA_THIRDPARTY_LIBRARIES
- ${KAA_THIRDPARTY_LIBRARIES}
- some_library_1
- some_library_2
- )
-
-************************************
-PLATFORM-SPECIFIC CONFIGURATION
-************************************
-
-To configure platform-specific options, you can optionally specify
-the following parameters for the cmake command:
-
-------------------------------------
-IOS_PLATFORM - applicable for the iOS build (KAA_PLATFORM=ios). It specifies the target iOS platform
- (armv7/arm64 - for mobile devices, i386 - for the simulator).
-
-Values:
-OS - build for the mobile device (armv7/arm64)
-SIMULATOR - build for the simulator (i386)
-
-Default:
-OS
-
-************************************
-BUILD EXAMPLE
-************************************
-
-The following example illustrates the build procedure for the debug x86-64 build with the INFO log level disabled,
-EVENTS feature and specified path to the folder Kaa will be installed in:
-
- mkdir build
- cd build
- cmake -DKAA_INSTALL_PATH='/home/username/kaa' -DKAA_DEBUG_ENABLED=1 -DKAA_MAX_LOG_LEVEL=4 -DKAA_WITHOUT_EVENTS=1 ..
- make
- make install
-
-
-To build the C SDK for the iOS simulator with maximum log level:
- mkdir build
- cd build
- cmake -DKAA_PLATFORM=ios -DCMAKE_TOOLCHAIN_FILE=../toolchains/iOS.cmake -DIOS_PLATFORM=SIMULATOR -DKAA_MAX_LOG_LEVEL=6 -GXcode ..
- xcodebuild
diff --git a/client/client-multi/client-c/assembly/client-c-sdk-templates.xml b/client/client-multi/client-c/assembly/client-c-sdk-templates.xml
deleted file mode 100644
index 49f567ddee..0000000000
--- a/client/client-multi/client-c/assembly/client-c-sdk-templates.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
- c-sdk-templates
-
- tar.gz
-
- false
-
-
- ${project.basedir}/templates
- /
-
-
-
diff --git a/client/client-multi/client-c/assembly/client-c-sdk.xml b/client/client-multi/client-c/assembly/client-c-sdk.xml
deleted file mode 100644
index e4d4d56930..0000000000
--- a/client/client-multi/client-c/assembly/client-c-sdk.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
- c-sdk
-
- tar.gz
-
- false
-
-
- ${project.basedir}/test
- test
-
-
- ${project.basedir}/listfiles
- listfiles
-
-
- ${project.basedir}/toolchains
- toolchains
-
-
- ${project.basedir}/src
- src
-
-
- ${project.basedir}/Modules
- Modules
-
-
- ${project.basedir}/thirdparty
- thirdparty
-
-
- ${project.basedir}/tools
- tools
-
-
- ${project.basedir}
- /
-
- README
- CMakeLists.txt
- sonar-project.properties.in
-
-
-
-
-
- false
- /
-
- org.kaaproject.kaa.common:endpoint-shared:zip:*:avro
-
- true
- runtime
-
-
-
diff --git a/client/client-multi/client-c/build.sh b/client/client-multi/client-c/build.sh
deleted file mode 100755
index b1e1e7bfa4..0000000000
--- a/client/client-multi/client-c/build.sh
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/bin/sh
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Exits immediately if error occurs
-set -e
-
-help() {
- echo "Choose one of the following: {build|install|test|analyze|clean}"
- exit 1
-}
-
-if [ $# -eq 0 ]; then
- help
-fi
-
-if [ -z "${MAX_LOG_LEVEL+x}" ]; then
- MAX_LOG_LEVEL=6
-fi
-
-prepare_build() {
- mkdir -p build-posix
- cd build-posix
- cmake -DCMAKE_BUILD_TYPE=Debug -DKAA_MAX_LOG_LEVEL=$MAX_LOG_LEVEL -DKAA_UNITTESTS_COMPILE=1 -DKAA_COLLECT_COVERAGE=1 -DKAA_ENCRYPTION=1 .. -DCMAKE_C_FLAGS="-Werror"
- cd ..
-}
-
-build() {
- cd build-posix
- make
- cd ..
-}
-
-run_analysis() {
- cd build-posix
- ctest -T memcheck
- ctest -T coverage
- make cppcheck
- cd ..
-}
-
-run_tests() {
- cd build-posix
- ctest --output-on-failure .
- cd ..
-}
-
-clean() {
- if [ -d build-posix ]
- then
- cd build-posix
- if [ -f Makefile ]
- then
- make clean
- fi
- cd .. && rm -r build-posix
- fi
-}
-
-for cmd in "$@"; do
-
-case "$cmd" in
- build)
- prepare_build
- build
- ;;
-
- install)
- cd build-posix && make install && cd ..
- ;;
-
- test)
- prepare_build
- build
- run_tests
- ;;
-
- analyze)
- run_analysis
- ;;
-
- clean)
- clean
- ;;
-
- *)
- help
- ;;
-esac
-
-done
diff --git a/client/client-multi/client-c/cunit-to-junit.xsl b/client/client-multi/client-c/cunit-to-junit.xsl
deleted file mode 100644
index 289ea0718b..0000000000
--- a/client/client-multi/client-c/cunit-to-junit.xsl
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Test failed at line
-
- in file
-
- :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/client/client-multi/client-c/docs/code-style.org b/client/client-multi/client-c/docs/code-style.org
deleted file mode 100644
index 0dee162a3f..0000000000
--- a/client/client-multi/client-c/docs/code-style.org
+++ /dev/null
@@ -1,96 +0,0 @@
-#+TITLE: C/C++ Code Style
-#+AUTHOR: Alexey Shmalko
-#+OPTIONS: toc:nil
-
-# Confluence doesn't have C language highlight, so use C++ here.
-
-* Rules
-
- - Use 4 spaces for indentation. Don't use tabs.
-
- - Use 100-character column width.
-
- - Use snake_case for the names (not camelCase).
-
- - All macro names must be in UPPERCASE.
-
- - Use [[https://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS][1TBS]] (the one true brace style).
- #+begin_src c++
- int main(int argc, char *argv[])
- {
- if (argc > 2) {
- printf("too many args\n");
- } else {
- printf("too little args\n");
- }
-
- return 0;
- }
- #+end_src
- Note brace position. The braces in control structures are required even for a single statement.
-
- - The pointer star must be aligned to the variable name:
- #+begin_src c++
- int *x;
- #+end_src
-
- - Labels must be indented one level less than the normal indentation (except for case labels):
- #+begin_src c++
- int main(int argc, char *argv[])
- {
- switch (argc) {
- case 3:
- printf("hi\n");
-
- default:
- goto fail;
- }
- return 0;
-
- fail:
- return 1;
- }
- #+end_src
-
- - Prefer double-indent instead of alignment in conditions and argument lists:
- #+begin_src c++
- int my_function(int param1, int param2,
- int param3, int param4)
- {
- if (param1 > 3 && param2 > 3 &&
- param3 > 3 && param4 > 3) {
- return param1 + param2 + param3 +
- param4;
- } else {
- return 0;
- }
- }
- #+end_src
-
- - Don't allow trailing spaces or lines.
-
-* Editor configurations
-** Emacs
-
- #+begin_src emacs-lisp
- (require 'whitespace)
- (setq-default whitespace-style '(face
- tab-mark
- empty
- trailing
- lines-tail))
- (global-whitespace-mode t)
-
- (c-add-style "kaa"
- '("k&r"
- (whitespace-line-column . 100)
- (indent-tabs-mode . nil)
- (c-basic-offset . 4)
- (c-label-minimum-indentation . 0)
- (c-offsets-alist . ((case-label . +)
- (arglist-intro . ++)
- (arglist-cont-nonempty . ++)
- (inextern-lang . 0)))))
-
- (setq c-default-style "kaa")
- #+end_src
diff --git a/client/client-multi/client-c/docs/contribute.org b/client/client-multi/client-c/docs/contribute.org
deleted file mode 100644
index 79fa09669e..0000000000
--- a/client/client-multi/client-c/docs/contribute.org
+++ /dev/null
@@ -1,73 +0,0 @@
-#+TITLE: How to Contribute
-#+OPTIONS: toc:nil
-
-This guide is dedicated to self-review and contribution process of Kaa project. It involves comments and code introspection, functional and unit testing, commits preparation and external code review.
-
-* Code introspection
- When you about to finish your feature or bug fix you need to check your changes following the procedure below:
- 1. Code MUST use C99 (for C SDK) or C++11 (for C++ SDK) standards without using any compiler extensions, like GNU.
- 2. Code MUST compile for every [[http://docs.kaaproject.org/display/KAA/Supported+platforms][supported platform]].
- 3. Code MUST NOT contain any compiler warnings.
- 4. Corresponding doxygen comments SHOULD be added to new or changed interfaces/modules.
- 5. Every TODO item MUST reference an issue on Jira and issue key must be placed in a comment next to the TODO. (e.g., =// TODO(KAA-982): Use asserts=)
- 6. Bottlenecks and magic places MUST be well-commented. (/Well, ideally there should be no magic places./)
- 7. Commented-out chunks of code are forbidden.
- 8. Code style MUST be consistent. Check out our [[./code-style.org][Code Style Guide]].
- 9. It is RECOMMENDED to use a source formatting script against modified sources. The script is placed in =client/client-multi/client-c/scripts/srcformat.sh=.
-
-* Instrumentation
- This section describes requirements that every developer must follow using existing tooling, like code analyzers, test frameworks etc.
-
- 1. Changes SHOULD be covered with unit tests, reflecting the essence of these changes. (Check out our [[./testing.org][Testing Tutorial]].)
- 2. If possible and required, changes SHOULD be covered with functional tests too.
- 3. Changes MUST NOT break any existing unit or functional tests. A fix SHOULD be provided if any of tests is failing due to introduced changes, except cases when test is no longer valid.
- 4. A sample app that directly or indirectly relies on changes SHOULD be well tested in automated or manual fashion to make sure that nothing was broken. If it did break, a fix must be provided either in sample applications or SDK or both.
- 5. Cppcheck MUST be triggered against changes; reported issues MUST be reviewed, and important ones MUST be fixed.
-
- See also: [[./sandbox-updating.org][sandbox updating guide]].
-
-* Pre-commit checklist
- The following checklist guarantees your patch will pass the Travis build and increases chance for passing code review process:
-
- #+begin_src sh
- # The next commands must be executed from the client-c/ directory
- cd client/client-multi/client-c/
-
- # Clean up source tree
- rm -rf target build-*
-
- # Check license headers
- nix-shell -p maven --run 'mvn apache-rat:check'
- # If you have installed maven on your system you can use the following command:
- # mvn apache-rat:check
- # If it finds any violations, check ./target/rat.txt for the list of files.
-
- # Format changed files
- nix-shell --run './scripts/srcformat.sh '
-
- # Check SDK builds for all platforms, passes cppcheck and builds doxygen
- nix-shell --arg withWerror true --pure --run './scripts/build.sh'
- #+end_src
-
- Note: You should use nix-shell for source formatting as it contains a patch for the astyle to allow max-instatement-indent values lower than 40 (https://sourceforge.net/p/astyle/bugs/396/). Alternatively, you can patch your astyle with the [[../../../../nix/astyle/max_indent.patch][following patch]] manually.
-
-* Committing
- 1. All of the changes MUST be added to commit(s), and commit messages SHOULD NOT be too long.
- 2. The commit message SHOULD begin with ticket number: =KAA-[TICKET NUMBER] Description=.
- 3. Changes in commits SHOULD be as atomic as possible. It means that single commit of a pull request contains changes to a single entity (e.g., a module).
- 4. Single pull request SHOULD expose single feature or bug fix if possible. That will help reviewers to do their job.
-
- # TODO: Complete git guide of Kaa (using http://git.kernel.org/cgit/git/git.git/tree/Documentation/SubmittingPatches?id=HEAD as an example)
-
-* Review
- According to our [[http://docs.kaaproject.org/display/KAA/Git+Flow][Git Flow]], every Pull Request must be reviewed and approved by at least two members of the responsible team. When you receive a comment, you should address it; that means either changing the code or answering a question in the comments.
-
- If you do a small fix, don't add a new commit but rather squash your changes to the old commits. That's required to avoid commit chains as the next one:
- #+begin_src example
- KAA-XXX Implement feature xxx
- KAA-XXX Fix formatting
- KAA-XXX Fix typo
- KAA-XXX Address CR questions
- KAA-XXX Address CR questions
- KAA-XXX Fix typo
- #+end_src
diff --git a/client/client-multi/client-c/docs/nix.org b/client/client-multi/client-c/docs/nix.org
deleted file mode 100644
index 4a6a14a0bc..0000000000
--- a/client/client-multi/client-c/docs/nix.org
+++ /dev/null
@@ -1,60 +0,0 @@
-#+TITLE: Nix Guide
-#+AUTHOR: Alexey Shmalko
-#+OPTIONS: toc:nil
-
-[[http://nixos.org/nix/][Nix]] is a powerful Linux package manager. We use it to create a better development environment for C client and manage all dependencies.
-
-* Setup Nix
- The easiest way to setup Nix is next:
- #+begin_src sh
- curl https://nixos.org/nix/install | sh
- source $HOME/.nix-profile/etc/profile.d/nix.sh
- #+end_src
-
- And add =source $HOME/.nix-profile/et/profile.d/nix.sh= to your =.bashrc=.
-
- If you don't trust piping shell scripts from the Internet (and you shouldn't), feel free to examine the script or use alternate setup. (Though, you should google it up yourself.)
-
-* Install all dependencies and enter the shell
- The first time you enter shell environment, the Nix will install all dependencies needed for development.
- #+begin_src sh
- nix-shell
- #+end_src
-
- As CC3200 SDK is not freely available, nix-shell will abort and ask you to download the file manually and add it to nix-store -- follow instructions. Then re-run the command above.
-
-* Using shell
- After dependencies are installed you'll find yourself in a custom bash shell (you can enter it with =nix-shell= whenever you want).
-
- You can use all your development tools from there, =./build.sh=, =cmake=. Furthermore, a custom top-level Makefile is provided that propagates your commands to all targets (it also configures all targets appropriately). So just run =make= to build C SDK for all platforms.
-
- If you want to run a single command within a shell, you can use =--run= option. For example:
- #+begin_src sh
- nix-shell --run make
- #+end_src
-
-* Options
- | Option | Default value | Meaning |
- |--------------------+---------------+-----------------------------------------------|
- | posixSupport | true | Host build with gcc. Goes to =build-posix=. |
- | clangSupport | true | Host build with clang. Goes to =build-clang=. |
- | cc3200Support | true | CC3200. Goes to =build-cc3200=. |
- | esp8266Support | true | ESP8266. Goes to =build-esp8266=. |
- | raspberrypiSupport | true | Raspberry Pi. Goes to =build-rpi=. |
- | testSupport | true | Add all tools for build verification. |
- | withTooling | true | Add tools for building docs. |
- | withWerror | false | Enable =-Werror= for all builds. |
-
- You can override any option with the following command:
- #+begin_src sh
- nix-shell --arg optionName value
- #+end_src
-
- For example:
- #+begin_src sh
- nix-shell --arg withWerror true
- #+end_src
-
-* Further reading
- - [[http://lethalman.blogspot.com/2014/07/nix-pill-1-why-you-should-give-it-try.html][Nix pills series]]
- - [[https://nixos.org/nixpkgs/manual/][Nixpkgs Contributors Guide]]
diff --git a/client/client-multi/client-c/docs/sandbox-updating.org b/client/client-multi/client-c/docs/sandbox-updating.org
deleted file mode 100644
index 524590d80e..0000000000
--- a/client/client-multi/client-c/docs/sandbox-updating.org
+++ /dev/null
@@ -1,45 +0,0 @@
-#+TITLE: Sandbox Updating
-#+AUTHOR: Maxim Olender
-#+OPTIONS: toc:nil
-
-Sometimes there is a need to update already running sandbox with new Kaa server or upload new SDK code. This article describes how to do that with minimum hassle using C SDK as an example. You need Maven, JDK-8 (Java Development Kit), ssh and C compiler.
-
-* Step-by-step guide
-
- {info}
- Kaa requires JDK-8 to use maven with Kaa. Double check =$JAVA_HOME= environment variable and make sure that it points to JDK-8 home directory.
- {info}
-
- When your sandbox up and running, perform following steps to update it:
-
- 1. Navigate to the root of the Kaa repository and launch Maven:
- #+begin_src sh
- mvn clean -P compile-client-c,compile-gwt,mongo-dao,mariadb-dao clean install verify -DskipTests
- #+end_src
-
- 2. After build succeeds it is time to copy node package to the sandbox. =$SANDBOX_HOST= is a host or IP of your sandbox:
- #+begin_src sh
- scp server/node/target/kaa-node.deb kaa@${SANDBOX_HOST}:
- #+end_src
-
- 3. Copy C SDK archive. =$SDK_VERSION= is a version of the SDK. At the time of this writing, SDK version is 0.9.0. Again, =$SANDBOX_HOST= is a host or IP of your sandbox:
- #+begin_src sh
- scp client/client-multi/client-c/target/client-c-${SDK_VERSION}-SNAPSHOT-c-sdk.tar.gz kaa@${SANDBOX_HOST}:
- ssh kaa@${SANDBOX_HOST} sudo mv -v /home/kaa/client-c-${SDK_VERSION}-SNAPSHOT-c-sdk.tar.gz /usr/lib/kaa-node/sdk/c/kaa-c-ep-sdk-${SDK_VERSION}-SNAPSHOT.tar.gz
- #+end_src
-
- 4. After all files are copied to the proper destinations in sandbox, it is time to install Kaa server node:
- #+begin_src sh
- ssh kaa@${SANDBOX_HOST} sudo dpkg -i kaa-node.deb
- #+end_src
-
- 5. Now, Kaa restart is required:
- #+begin_src sh
- ssh kaa@${SANDBOX_HOST} kaa-node stop
- ssh kaa@${SANDBOX_HOST} kaa-node start
- #+end_src
-
- 6. If errors occur during restarting of Kaa sandbox, I recommend you to reboot sandbox virtual machine:
- #+begin_src sh
- ssh kaa@${SANDBOX_HOST} sudo reboot
- #+end_src
diff --git a/client/client-multi/client-c/docs/testing.org b/client/client-multi/client-c/docs/testing.org
deleted file mode 100644
index 9627cf871c..0000000000
--- a/client/client-multi/client-c/docs/testing.org
+++ /dev/null
@@ -1,134 +0,0 @@
-#+TITLE: Testing Tutorial
-#+AUTHOR: Alexey Shmalko
-#+OPTIONS: toc:nil
-
-We use [[https://cmocka.org/][cmocka]] testing framework for the C SDK. It has [[https://api.cmocka.org/modules.html][good documentation]] on various topics, and we encourage you to read it. This document's purpose is to give you a quick introduction into cmocka and some Kaa-related details.
-
-{note}
-The macros in ~test/kaa_test.h~ are not intended to be used; they were part of the previous test setup and will be removed later.
-{note}
-
-* First test
- Create the following C file in the ~test/~ directory (e.g., ~test/test_nothing.c~).
-
- #+begin_src c
- /* Copyright boilerplate */
- #include "kaa_test.h"
-
- static void test_nothing(void **state)
- {
- (void)state;
-
- assert_true(false);
- }
-
- int main(void)
- {
- const struct CMUnitTest tests[] = {
- cmocka_unit_test(test_nothing),
- };
-
- return cmocka_run_group_tests(tests, NULL, NULL);
- }
- #+end_src
-
- That is the simplest test; it defines a single test case (=test_nothing()=) and creates a test group. However, it doesn't run yet.
-
- To add the test to the global test suite, open ~listfiles/UnitTest.cmake~ and append the following:
- #+begin_src cmake
- kaa_add_unit_test(NAME test_nothing
- SOURCES
- test/test_nothing.c)
- #+end_src
-
- Now you must see a test failure if you run ~./build.sh test~.
-
-* Testing real code
- The best way to test a feature is to isolate it. A good example is a list implementation -- it isn't tied to any other Kaa feature and can be tested independently.
-
- We create a test executable which consists of our test code and list implementation. Add to ~listfiles/UnitTest.cmake~:
- #+begin_src cmake
- kaa_add_unit_test(NAME my_test_list
- SOURCES
- test/my_test_list.c
- src/kaa/collections/kaa_list.c
- INC_DIRS
- src/kaa)
- #+end_src
-
- That creates new test executable (~my_test_list~) that consists of ~test/my_test_list.c~ and ~src/kaa/collections/kaa_list.c~; we also add ~src/kaa~ to include directories so ~kaa_list.c~ can find its include files.
-
- It's time to write a real test (~test/my_test_list.c~):
- #+begin_src c
- /* Copyright boilerplate */
- #include
-
- #include "kaa_test.h"
-
- static void test_list_create(void **state)
- {
- (void)state;
- kaa_list_t *list = kaa_list_create();
-
- assert_int_equal(0, kaa_list_get_size(list));
- assert_null(kaa_list_begin(list));
- assert_null(kaa_list_back(list));
-
- kaa_list_destroy(list, NULL);
- }
-
- static void test_list_push_front(void **state)
- {
- (void)state;
- kaa_list_t *list = kaa_list_create();
-
- int a = 3;
- int b = 5;
-
- kaa_list_push_front(list, &a);
- kaa_list_push_front(list, &b);
-
- assert_int_equal(2, kaa_list_get_size(list));
- assert_ptr_equal(&b, kaa_list_begin(list));
- assert_ptr_equal(&a, kaa_list_back(list));
-
- kaa_list_destroy(list, NULL);
- }
-
- int main(void)
- {
- const struct CMUnitTest tests[] = {
- cmocka_unit_test(test_create),
- cmocka_unit_test(test_push_front),
- };
-
- return cmocka_run_group_tests(tests, NULL, NULL);
- }
- #+end_src
-
- We've created two test cases and added them to the test suite.
-
-* Mocking
- Not all modules are isolated as ~kaa_list~; some, however, have few dependencies and it's easy to replace them with our own implementation that aids testing.
-
- I don't see a good target for mocking demonstration here at Kaa; all tests are either not mocked or require too much mocking. So I won't bother with making up an example and will point you to the [[https://lwn.net/Articles/558106/][Unit testing with mock objects in C]] article at LWN.
-
-* Not mocking
- Some features are too hard to isolate. In that case it's ok to link to the whole kaa client library and call public API. That's what happens with most tests in the current set. (They were converted from another test framework and weren't fully adapted yet.)
-
- In example, here's how it's done for ~test_meta_extension~:
- #+begin_src cmake
- kaa_add_unit_test(NAME test_meta_extension
- SOURCES
- test/test_meta_extension.c
- test/kaa_test_external.c
- DEPENDS
- kaac)
- #+end_src
-
- Note that we include ~test/kaa_test_external.c~; that's an implementation of the platform layer for testing. (It does almost nothing, however.)
-
-* Further reading
- In addition to that, cmocka supports groups, setup, teardown, detecting memory leaks, and other cool things. You should really read [[https://api.cmocka.org/modules.html][the documentation]].
-
- For more info on [[https://en.wikipedia.org/wiki/Test-driven_development][test-driven development]] in general and testing for embedded systems in particular, we recommend [[https://pragprog.com/book/jgade/test-driven-development-for-embedded-c][Test Driven Development for Embedded C]] by James W. Grenning -- it has many examples of testing, isolating features and mocking.
diff --git a/client/client-multi/client-c/examples/my-kaa-application/CMakeLists.txt b/client/client-multi/client-c/examples/my-kaa-application/CMakeLists.txt
deleted file mode 100644
index ae019ef4fb..0000000000
--- a/client/client-multi/client-c/examples/my-kaa-application/CMakeLists.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-cmake_minimum_required(VERSION 3.5.2)
-project(kaa-application C)
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g -Wall -Wextra")
-
-add_subdirectory(kaa)
-
-add_executable(kaa-app src/kaa-application.c)
-target_link_libraries(kaa-app kaac)
diff --git a/client/client-multi/client-c/examples/my-kaa-application/src/kaa-application.c b/client/client-multi/client-c/examples/my-kaa-application/src/kaa-application.c
deleted file mode 100644
index 40a3c9e8b5..0000000000
--- a/client/client-multi/client-c/examples/my-kaa-application/src/kaa-application.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include
-#include
-#include
-#include
-
-
-static void dummy_function(void *context)
-{
- printf("Hello, I am a Kaa Application!\n");
- kaa_client_stop(context);
-}
-
-int main(void)
-{
- kaa_client_t *kaa_client = NULL;
- kaa_error_t error = kaa_client_create(&kaa_client, NULL);
- if (error) {
- return EXIT_FAILURE;
- }
-
- error = kaa_client_start(kaa_client, dummy_function, (void *)kaa_client, 0);
-
- kaa_client_destroy(kaa_client);
-
- if (error) {
- return EXIT_FAILURE;
- }
-
- return EXIT_SUCCESS;
-}
diff --git a/client/client-multi/client-c/gcovr b/client/client-multi/client-c/gcovr
deleted file mode 100755
index dc0b1c7030..0000000000
--- a/client/client-multi/client-c/gcovr
+++ /dev/null
@@ -1,1847 +0,0 @@
-#! /usr/bin/env python
-#
-# A report generator for gcov 3.4
-#
-# This routine generates a format that is similar to the format generated
-# by the Python coverage.py module. This code is similar to the
-# data processing performed by lcov's geninfo command. However, we
-# don't worry about parsing the *.gcna files, and backwards compatibility for
-# older versions of gcov is not supported.
-#
-# Outstanding issues
-# - verify that gcov 3.4 or newer is being used
-# - verify support for symbolic links
-#
-# gcovr is a FAST project. For documentation, bug reporting, and
-# updates, see https://software.sandia.gov/trac/fast/wiki/gcovr
-#
-# _________________________________________________________________________
-#
-# Gcovr: A parsing and reporting tool for gcov
-# Copyright (c) 2013 Sandia Corporation.
-# This software is distributed under the BSD License.
-# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
-# the U.S. Government retains certain rights in this software.
-# For more information, see the README.md file.
-# _________________________________________________________________________
-#
-# $Revision$
-# $Date$
-#
-
-try:
- import html
-except:
- import cgi as html
-import copy
-import glob
-import os
-import re
-import subprocess
-import sys
-import time
-import xml.dom.minidom
-import datetime
-import posixpath
-
-from optparse import OptionParser
-from string import Template
-from os.path import normpath
-
-medium_coverage = 75.0
-high_coverage = 90.0
-low_color = "LightPink"
-medium_color = "#FFFF55"
-high_color = "LightGreen"
-covered_color = "LightGreen"
-uncovered_color = "LightPink"
-
-__version__ = "3.1"
-src_revision = "$Revision$"
-
-output_re = re.compile("[Cc]reating [`'](.*)'$")
-source_re = re.compile("cannot open (source|graph) file")
-
-starting_dir = os.getcwd()
-
-exclude_line_flag = "_EXCL_"
-exclude_line_pattern = re.compile('([GL]COVR?)_EXCL_(LINE|START|STOP)')
-
-c_style_comment_pattern = re.compile('/\*.*?\*/')
-cpp_style_comment_pattern = re.compile('//.*?$')
-
-def version_str():
- ans = __version__
- m = re.match('\$Revision:\s*(\S+)\s*\$', src_revision)
- if m:
- ans = ans + " (r%s)" % (m.group(1))
- return ans
-
-#
-# Container object for coverage statistics
-#
-class CoverageData(object):
-
- def __init__(self, fname, uncovered, uncovered_exceptional, covered, branches, noncode):
- self.fname=fname
- # Shallow copies are cheap & "safe" because the caller will
- # throw away their copies of covered & uncovered after calling
- # us exactly *once*
- self.uncovered = copy.copy(uncovered)
- self.uncovered_exceptional = copy.copy(uncovered_exceptional)
- self.covered = copy.copy(covered)
- self.noncode = copy.copy(noncode)
- # But, a deep copy is required here
- self.all_lines = copy.deepcopy(uncovered)
- self.all_lines.update(uncovered_exceptional)
- self.all_lines.update(covered.keys())
- self.branches = copy.deepcopy(branches)
-
- def update(self, uncovered, uncovered_exceptional, covered, branches, noncode):
- self.all_lines.update(uncovered)
- self.all_lines.update(uncovered_exceptional)
- self.all_lines.update(covered.keys())
- self.uncovered.update(uncovered)
- self.uncovered_exceptional.update(uncovered_exceptional)
- self.noncode.intersection_update(noncode)
- for k in covered.keys():
- self.covered[k] = self.covered.get(k,0) + covered[k]
- for k in branches.keys():
- for b in branches[k]:
- d = self.branches.setdefault(k, {})
- d[b] = d.get(b, 0) + branches[k][b]
- self.uncovered.difference_update(self.covered.keys())
- self.uncovered_exceptional.difference_update(self.covered.keys())
-
- def uncovered_str(self, exceptional):
- if options.show_branch:
- # Don't do any aggregation on branch results
- tmp = []
- for line in self.branches.keys():
- for branch in self.branches[line]:
- if self.branches[line][branch] == 0:
- tmp.append(line)
- break
-
- tmp.sort()
- return ",".join([str(x) for x in tmp]) or ""
-
- if exceptional:
- tmp = list(self.uncovered_exceptional)
- else:
- tmp = list(self.uncovered)
- if len(tmp) == 0:
- return ""
-
- tmp.sort()
- first = None
- last = None
- ranges=[]
- for item in tmp:
- if last is None:
- first=item
- last=item
- elif item == (last+1):
- last=item
- else:
- if len(self.noncode.intersection(range(last+1,item))) \
- == item - last - 1:
- last = item
- continue
-
- if first==last:
- ranges.append(str(first))
- else:
- ranges.append(str(first)+"-"+str(last))
- first=item
- last=item
- if first==last:
- ranges.append(str(first))
- else:
- ranges.append(str(first)+"-"+str(last))
- return ",".join(ranges)
-
- def coverage(self):
- if ( options.show_branch ):
- total = 0
- cover = 0
- for line in self.branches.keys():
- for branch in self.branches[line].keys():
- total += 1
- cover += self.branches[line][branch] > 0 and 1 or 0
- else:
- total = len(self.all_lines)
- cover = len(self.covered)
-
- percent = total and str(int(100.0*cover/total)) or "--"
- return (total, cover, percent)
-
- def summary(self):
- tmp = options.root_filter.sub('',self.fname)
- if not self.fname.endswith(tmp):
- # Do no truncation if the filter does not start matching at
- # the beginning of the string
- tmp = self.fname
- tmp = tmp.ljust(40)
- if len(tmp) > 40:
- tmp=tmp+"\n"+" "*40
-
- (total, cover, percent) = self.coverage()
- uncovered_lines = self.uncovered_str(False)
- if not options.show_branch:
- t = self.uncovered_str(True)
- if len(t):
- uncovered_lines += " [* " + t + "]";
- return ( total, cover,
- tmp + str(total).rjust(8) + str(cover).rjust(8) + \
- percent.rjust(6) + "% " + uncovered_lines )
-
-
-def resolve_symlinks(orig_path):
- """
- Return the normalized absolute path name with all symbolic links resolved
- """
- return os.path.realpath(orig_path)
- # WEH - why doesn't os.path.realpath() suffice here?
- #
- drive,tmp = os.path.splitdrive(os.path.abspath(orig_path))
- if not drive:
- drive = os.path.sep
- parts = tmp.split(os.path.sep)
- actual_path = [drive]
- while parts:
- actual_path.append(parts.pop(0))
- if not os.path.islink(os.path.join(*actual_path)):
- continue
- actual_path[-1] = os.readlink(os.path.join(*actual_path))
- tmp_drive, tmp_path = os.path.splitdrive(
- resolve_symlinks(os.path.join(*actual_path)) )
- if tmp_drive:
- drive = tmp_drive
- actual_path = [drive] + tmp_path.split(os.path.sep)
- return os.path.join(*actual_path)
-
-
-
-#
-# Class that creates path aliases
-#
-class PathAliaser(object):
-
- def __init__(self):
- self.aliases = {}
- self.master_targets = set()
- self.preferred_name = {}
-
- def path_startswith(self, path, base):
- return path.startswith(base) and (
- len(base) == len(path) or path[len(base)] == os.path.sep )
-
- def master_path(self, path):
- match_found = False
- while True:
- for base, alias in self.aliases.items():
- if self.path_startswith(path, base):
- path = alias + path[len(base):]
- match_found = True
- break
- for master_base in self.master_targets:
- if self.path_startswith(path, master_base):
- return path, master_base, True
- if match_found:
- sys.stderr.write(
- "(ERROR) violating fundamental assumption while walking "
- "directory tree.\n\tPlease report this to the gcovr "
- "developers.\n" )
- return path, None, match_found
-
- def unalias_path(self, path):
- path = resolve_symlinks(path)
- path, master_base, known_path = self.master_path(path)
- if not known_path:
- return path
- # Try and resolve the preferred name for this location
- if master_base in self.preferred_name:
- return self.preferred_name[master_base] + path[len(master_base):]
- return path
-
- def add_master_target(self, master):
- self.master_targets.add(master)
-
- def add_alias(self, target, master):
- self.aliases[target] = master
-
- def set_preferred(self, master, preferred):
- self.preferred_name[master] = preferred
-
-aliases = PathAliaser()
-
-# This is UGLY. Here's why: UNIX resolves symbolic links by walking the
-# entire directory structure. What that means is that relative links
-# are always relative to the actual directory inode, and not the
-# "virtual" path that the user might have traversed (over symlinks) on
-# the way to that directory. Here's the canonical example:
-#
-# a / b / c / testfile
-# a / d / e --> ../../a/b
-# m / n --> /a
-# x / y / z --> /m/n/d
-#
-# If we start in "y", we will see the following directory structure:
-# y
-# |-- z
-# |-- e
-# |-- c
-# |-- testfile
-#
-# The problem is that using a simple traversal based on the Python
-# documentation:
-#
-# (os.path.join(os.path.dirname(path), os.readlink(result)))
-#
-# will not work: we will see a link to /m/n/d from /x/y, but completely
-# miss the fact that n is itself a link. If we then naively attempt to
-# apply the "c" relative link, we get an intermediate path that looks
-# like "/m/n/d/e/../../a/b", which would get normalized to "/m/n/a/b"; a
-# nonexistant path. The solution is that we need to walk the original
-# path, along with the full path of all links 1 directory at a time and
-# check for embedded symlinks.
-#
-#
-# NB: Users have complained that this code causes a performance issue.
-# I have replaced this logic with os.walk(), which works for Python >= 2.6
-#
-def link_walker(path):
- if sys.version_info >= (2,6):
- for root, dirs, files in os.walk(os.path.abspath(path), followlinks=True):
- yield os.path.abspath(os.path.realpath(root)), dirs, files
- else:
- targets = [os.path.abspath(path)]
- while targets:
- target_dir = targets.pop(0)
- actual_dir = resolve_symlinks(target_dir)
- #print "target dir: %s (%s)" % (target_dir, actual_dir)
- master_name, master_base, visited = aliases.master_path(actual_dir)
- if visited:
- #print " ...root already visited as %s" % master_name
- aliases.add_alias(target_dir, master_name)
- continue
- if master_name != target_dir:
- aliases.set_preferred(master_name, target_dir)
- aliases.add_alias(target_dir, master_name)
- aliases.add_master_target(master_name)
- #print " ...master name = %s" % master_name
- #print " ...walking %s" % target_dir
- for root, dirs, files in os.walk(target_dir, topdown=True):
- #print " ...reading %s" % root
- for d in dirs:
- tmp = os.path.abspath(os.path.join(root, d))
- #print " ...checking %s" % tmp
- if os.path.islink(tmp):
- #print " ...buffering link %s" % tmp
- targets.append(tmp)
- yield root, dirs, files
-
-
-def search_file(expr, path):
- """
- Given a search path, recursively descend to find files that match a
- regular expression.
- """
- ans = []
- pattern = re.compile(expr)
- if path is None or path == ".":
- path = os.getcwd()
- elif not os.path.exists(path):
- raise IOError("Unknown directory '"+path+"'")
- for root, dirs, files in link_walker(path):
- for name in files:
- if pattern.match(name):
- name = os.path.join(root,name)
- if os.path.islink(name):
- ans.append( os.path.abspath(os.readlink(name)) )
- else:
- ans.append( os.path.abspath(name) )
- return ans
-
-
-#
-# Get the list of datafiles in the directories specified by the user
-#
-def get_datafiles(flist, options):
- allfiles=set()
- for dir in flist:
- if options.verbose:
- sys.stdout.write( "Scanning directory %s for gcda/gcno files...\n"
- % (dir, ) )
- files = search_file(".*\.gc(da|no)$", dir)
- # gcno files will *only* produce uncovered results; however,
- # that is useful information for the case where a compilation
- # unit is never actually exercised by the test code. So, we
- # will process gcno files, but ONLY if there is no corresponding
- # gcda file.
- gcda_files = [file for file in files if file.endswith('gcda')]
- tmp = set(gcda_files)
- gcno_files = [ file for file in files if
- file.endswith('gcno') and file[:-2]+'da' not in tmp ]
- if options.verbose:
- sys.stdout.write(
- "Found %d files (and will process %d)\n" %
- ( len(files), len(gcda_files) + len(gcno_files) ) )
- allfiles.update(gcda_files)
- allfiles.update(gcno_files)
- return allfiles
-
-
-#
-# Process a single gcov datafile
-#
-def process_gcov_data(data_fname, covdata, options):
- INPUT = open(data_fname,"r")
- #
- # Get the filename
- #
- line = INPUT.readline()
- segments=line.split(':',3)
- if len(segments) != 4 or not segments[2].lower().strip().endswith('source'):
- raise RuntimeError('Fatal error parsing gcov file, line 1: \n\t"%s"' % line.rstrip())
- currdir = os.getcwd()
- os.chdir(root_dir)
- if sys.version_info >= (2,6):
- fname = os.path.abspath((segments[-1]).strip())
- else:
- fname = aliases.unalias_path(os.path.abspath((segments[-1]).strip()))
- os.chdir(currdir)
- if options.verbose:
- sys.stdout.write("Parsing coverage data for file %s\n" % fname)
- #
- # Return if the filename does not match the filter
- #
- filtered_fname = None
- for i in range(0,len(options.filter)):
- if options.filter[i].match(fname):
- filtered_fname = options.root_filter.sub('',fname)
- break
- if filtered_fname is None:
- if options.verbose:
- sys.stdout.write(" Filtering coverage data for file %s\n" % fname)
- return
- #
- # Return if the filename matches the exclude pattern
- #
- for i in range(0,len(options.exclude)):
- if (filtered_fname is not None and options.exclude[i].match(filtered_fname)) or \
- options.exclude[i].match(fname) or \
- options.exclude[i].match(os.path.abspath(fname)):
- if options.verbose:
- sys.stdout.write(" Excluding coverage data for file %s\n" % fname)
- return
- #
- # Parse each line, and record the lines
- # that are uncovered
- #
- excluding = []
- noncode = set()
- uncovered = set()
- uncovered_exceptional = set()
- covered = {}
- branches = {}
- #first_record=True
- lineno = 0
- last_code_line = ""
- last_code_lineno = 0
- last_code_line_excluded = False
- for line in INPUT:
- segments=line.split(":",2)
- tmp = segments[0].strip()
- if len(segments) > 1:
- try:
- lineno = int(segments[1].strip())
- except:
- pass # keep previous line number!
-
- if exclude_line_flag in line:
- excl_line = False
- for header, flag in exclude_line_pattern.findall(line):
- if flag == 'START':
- excluding.append((header, lineno))
- elif flag == 'STOP':
- if excluding:
- _header, _line = excluding.pop()
- if _header != header:
- sys.stderr.write(
- "(WARNING) %s_EXCL_START found on line %s "
- "was terminated by %s_EXCL_STOP on line %s, "
- "when processing %s\n"
- % (_header, _line, header, lineno, fname) )
- else:
- sys.stderr.write(
- "(WARNING) mismatched coverage exclusion flags.\n"
- "\t%s_EXCL_STOP found on line %s without "
- "corresponding %s_EXCL_START, when processing %s\n"
- % (header, lineno, header, fname) )
- elif flag == 'LINE':
- # We buffer the line exclusion so that it is always
- # the last thing added to the exclusion list (and so
- # only ONE is ever added to the list). This guards
- # against cases where puts a _LINE and _START (or
- # _STOP) on the same line... it also guards against
- # duplicate _LINE flags.
- excl_line = True
- if excl_line:
- excluding.append(False)
-
- is_code_statement = False
- if tmp[0] == '-' or (excluding and tmp[0] in "#=0123456789"):
- is_code_statement = True
- code = segments[2].strip()
- # remember certain non-executed lines
- if excluding or len(code) == 0 or code == "{" or code == "}" or \
- code.startswith("//") or code == 'else':
- noncode.add( lineno )
- elif tmp[0] == '#':
- is_code_statement = True
- uncovered.add( lineno )
- elif tmp[0] == '=':
- is_code_statement = True
- uncovered_exceptional.add( lineno )
- elif tmp[0] in "0123456789":
- is_code_statement = True
- covered[lineno] = int(segments[0].strip())
- elif tmp.startswith('branch'):
- exclude_branch = False
- if options.exclude_unreachable_branches and lineno == last_code_lineno:
- if last_code_line_excluded:
- exclude_branch = True
- exclude_reason = "marked with exclude pattern"
- else:
- code = last_code_line
- code = re.sub(cpp_style_comment_pattern, '', code)
- code = re.sub(c_style_comment_pattern, '', code)
- code = code.strip()
- code_nospace = code.replace(' ', '')
- exclude_branch = len(code) == 0 or code == '{' or code == '}' or code_nospace == '{}'
- exclude_reason = "detected as compiler-generated code"
-
- if exclude_branch:
- if options.verbose:
- sys.stdout.write("Excluding unreachable branch on line %d in file %s (%s).\n"
- % (lineno, fname, exclude_reason))
- else:
- fields = line.split()
- try:
- count = int(fields[3])
- branches.setdefault(lineno, {})[int(fields[1])] = count
- except:
- # We ignore branches that were "never executed"
- pass
- elif tmp.startswith('call'):
- pass
- elif tmp.startswith('function'):
- pass
- elif tmp[0] == 'f':
- pass
- #if first_record:
- #first_record=False
- #uncovered.add(prev)
- #if prev in uncovered:
- #tokens=re.split('[ \t]+',tmp)
- #if tokens[3] != "0":
- #uncovered.remove(prev)
- #prev = int(segments[1].strip())
- #first_record=True
- else:
- sys.stderr.write(
- "(WARNING) Unrecognized GCOV output: '%s'\n"
- "\tThis is indicitive of a gcov output parse error.\n"
- "\tPlease report this to the gcovr developers." % tmp )
-
- # save the code line to use it later with branches
- if is_code_statement:
- last_code_line = "".join(segments[2:])
- last_code_lineno = lineno
- last_code_line_excluded = False
- if excluding:
- last_code_line_excluded = True
-
- # clear the excluding flag for single-line excludes
- if excluding and not excluding[-1]:
- excluding.pop()
-
- ##print 'uncovered',uncovered
- ##print 'covered',covered
- ##print 'branches',branches
- ##print 'noncode',noncode
- #
- # If the file is already in covdata, then we
- # remove lines that are covered here. Otherwise,
- # initialize covdata
- #
- if not fname in covdata:
- covdata[fname] = CoverageData(fname,uncovered,uncovered_exceptional,covered,branches,noncode)
- else:
- covdata[fname].update(uncovered,uncovered_exceptional,covered,branches,noncode)
- INPUT.close()
-
- for header, line in excluding:
- sys.stderr.write("(WARNING) The coverage exclusion region start flag "
- "%s_EXCL_START\n\ton line %d did not have "
- "corresponding %s_EXCL_STOP flag\n\t in file %s.\n"
- % (header, line, header, fname))
-
-#
-# Process a datafile (generated by running the instrumented application)
-# and run gcov with the corresponding arguments
-#
-# This is trickier than it sounds: The gcda/gcno files are stored in the
-# same directory as the object files; however, gcov must be run from the
-# same directory where gcc/g++ was run. Normally, the user would know
-# where gcc/g++ was invoked from and could tell gcov the path to the
-# object (and gcda) files with the --object-directory command.
-# Unfortunately, we do everything backwards: gcovr looks for the gcda
-# files and then has to infer the original gcc working directory.
-#
-# In general, (but not always) we can assume that the gcda file is in a
-# subdirectory of the original gcc working directory, so we will first
-# try ".", and on error, move up the directory tree looking for the
-# correct working directory (letting gcov's own error codes dictate when
-# we hit the right directory). This covers 90+% of the "normal" cases.
-# The exception to this is if gcc was invoked with "-o ../[...]" (i.e.,
-# the object directory was a peer (not a parent/child) of the cwd. In
-# this case, things are really tough. We accept an argument
-# (--object-directory) that SHOULD BE THE SAME as the one povided to
-# gcc. We will then walk that path (backwards) in the hopes of
-# identifying the original gcc working directory (there is a bit of
-# trial-and-error here)
-#
-def process_datafile(filename, covdata, options):
- #
- # Launch gcov
- #
- abs_filename = os.path.abspath(filename)
- (dirname,fname) = os.path.split(abs_filename)
- #(name,ext) = os.path.splitext(base)
-
- potential_wd = []
- errors=[]
- Done = False
-
- if options.objdir:
- src_components = abs_filename.split(os.sep)
- components = normpath(options.objdir).split(os.sep)
- idx = 1
- while idx <= len(components):
- if idx > len(src_components):
- break
- if components[-1*idx] != src_components[-1*idx]:
- break
- idx += 1
- if idx > len(components):
- pass # a parent dir; the normal process will find it
- elif components[-1*idx] == '..':
- # NB: os.path.join does not re-add leading '/' characters!?!
- dirs = [ os.path.sep.join(src_components[:len(src_components)-idx]) ]
- while idx <= len(components) and components[-1*idx] == '..':
- tmp = []
- for d in dirs:
- for f in os.listdir(d):
- x = os.path.join(d,f)
- if os.path.isdir(x):
- tmp.append(x)
- dirs = tmp
- idx += 1
- potential_wd = dirs
- else:
- if components[0] == '':
- # absolute path
- tmp = [ options.objdir ]
- else:
- # relative path: check relative to both the cwd and the
- # gcda file
- tmp = [ os.path.join(x, options.objdir) for x in
- [os.path.dirname(abs_filename), os.getcwd()] ]
- potential_wd = [ testdir for testdir in tmp
- if os.path.isdir(testdir) ]
- if len(potential_wd) == 0:
- errors.append("ERROR: cannot identify the location where GCC "
- "was run using --object-directory=%s\n" %
- options.objdir)
- # Revert to the normal
- #sys.exit(1)
-
- # no objdir was specified (or it was a parent dir); walk up the dir tree
- if len(potential_wd) == 0:
- wd = os.path.split(abs_filename)[0]
- while True:
- potential_wd.append(wd)
- wd = os.path.split(wd)[0]
- if wd == potential_wd[-1]:
- break
-
- cmd = [ options.gcov_cmd, abs_filename,
- "--branch-counts", "--branch-probabilities", "--preserve-paths",
- '--object-directory', dirname ]
-
- # NB: Currently, we will only parse English output
- env = dict(os.environ)
- env['LC_ALL'] = 'en_US'
-
-
- while len(potential_wd) > 0 and not Done:
- # NB: either len(potential_wd) == 1, or all entires are absolute
- # paths, so we don't have to chdir(starting_dir) at every
- # iteration.
- os.chdir(potential_wd.pop(0))
-
-
- #if options.objdir:
- # cmd.extend(["--object-directory", Template(options.objdir).substitute(filename=filename, head=dirname, tail=base, root=name, ext=ext)])
-
- if options.verbose:
- sys.stdout.write("Running gcov: '%s' in '%s'\n" % ( ' '.join(cmd), os.getcwd() ))
- (out, err) = subprocess.Popen( cmd, env=env,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE ).communicate()
- out=out.decode('utf-8')
- err=err.decode('utf-8')
-
- # find the files that gcov created
- gcov_files = {'active':[], 'filter':[], 'exclude':[]}
- for line in out.splitlines():
- found = output_re.search(line.strip())
- if found is not None:
- fname = found.group(1)
- if not options.gcov_filter.match(fname):
- if options.verbose:
- sys.stdout.write("Filtering gcov file %s\n" % fname)
- gcov_files['filter'].append(fname)
- continue
- exclude=False
- for i in range(0,len(options.gcov_exclude)):
- if options.gcov_exclude[i].match(options.gcov_filter.sub('',fname)) or \
- options.gcov_exclude[i].match(fname) or \
- options.gcov_exclude[i].match(os.path.abspath(fname)):
- exclude=True
- break
- if not exclude:
- gcov_files['active'].append(fname)
- elif options.verbose:
- sys.stdout.write("Excluding gcov file %s\n" % fname)
- gcov_files['exclude'].append(fname)
-
- if source_re.search(err):
- # gcov tossed errors: try the next potential_wd
- errors.append(err)
- else:
- # Process *.gcov files
- for fname in gcov_files['active']:
- process_gcov_data(fname, covdata, options)
- Done = True
-
- if not options.keep:
- for group in gcov_files.values():
- for fname in group:
- if os.path.exists(fname):
- # Only remove files that actually exist.
- os.remove(fname)
-
- os.chdir(starting_dir)
- if options.delete:
- if not abs_filename.endswith('gcno'):
- os.remove(abs_filename)
-
- if not Done:
- sys.stderr.write(
- "(WARNING) GCOV produced the following errors processing %s:\n"
- "\t %s"
- "\t(gcovr could not infer a working directory that resolved it.)\n"
- % ( filename, "\t ".join(errors) ) )
-
-#
-# Produce the classic gcovr text report
-#
-def print_text_report(covdata):
- def _num_uncovered(key):
- (total, covered, percent) = covdata[key].coverage()
- return total - covered
- def _percent_uncovered(key):
- (total, covered, percent) = covdata[key].coverage()
- if covered:
- return -1.0*covered/total
- else:
- return total or 1e6
- def _alpha(key):
- return key
-
- if options.output:
- OUTPUT = open(options.output,'w')
- else:
- OUTPUT = sys.stdout
- total_lines=0
- total_covered=0
- # Header
- OUTPUT.write("-"*78 + '\n')
- a = options.show_branch and "Branches" or "Lines"
- b = options.show_branch and "Taken" or "Exec"
- c = "Missing"
- OUTPUT.write("File".ljust(40) + a.rjust(8) + b.rjust(8)+ " Cover " + c + "\n")
- OUTPUT.write("-"*78 + '\n')
-
- # Data
- keys = list(covdata.keys())
- keys.sort(key=options.sort_uncovered and _num_uncovered or \
- options.sort_percent and _percent_uncovered or _alpha)
- for key in keys:
- (t, n, txt) = covdata[key].summary()
- total_lines += t
- total_covered += n
- OUTPUT.write(txt + '\n')
-
- # Footer & summary
- OUTPUT.write("-"*78 + '\n')
- percent = total_lines and str(int(100.0*total_covered/total_lines)) or "--"
- OUTPUT.write("TOTAL".ljust(40) + str(total_lines).rjust(8) + \
- str(total_covered).rjust(8) + str(percent).rjust(6)+"%" + '\n')
- OUTPUT.write("-"*78 + '\n')
-
- # Close logfile
- if options.output:
- OUTPUT.close()
-
-#
-# CSS declarations for the HTML output
-#
-css = Template('''
- body
- {
- color: #000000;
- background-color: #FFFFFF;
- }
-
- /* Link formats: use maroon w/underlines */
- a:link
- {
- color: navy;
- text-decoration: underline;
- }
- a:visited
- {
- color: maroon;
- text-decoration: underline;
- }
- a:active
- {
- color: navy;
- text-decoration: underline;
- }
-
- /*** TD formats ***/
- td
- {
- font-family: sans-serif;
- }
- td.title
- {
- text-align: center;
- padding-bottom: 10px;
- font-size: 20pt;
- font-weight: bold;
- }
-
- /* TD Header Information */
- td.headerName
- {
- text-align: right;
- color: black;
- padding-right: 6px;
- font-weight: bold;
- vertical-align: top;
- white-space: nowrap;
- }
- td.headerValue
- {
- text-align: left;
- color: blue;
- font-weight: bold;
- white-space: nowrap;
- }
- td.headerTableEntry
- {
- text-align: right;
- color: black;
- font-weight: bold;
- white-space: nowrap;
- padding-left: 12px;
- padding-right: 4px;
- background-color: LightBlue;
- }
- td.headerValueLeg
- {
- text-align: left;
- color: black;
- font-size: 80%;
- white-space: nowrap;
- padding-left: 10px;
- padding-right: 10px;
- padding-top: 2px;
- }
-
- /* Color of horizontal ruler */
- td.hr
- {
- background-color: navy;
- height:3px;
- }
- /* Footer format */
- td.footer
- {
- text-align: center;
- padding-top: 3px;
- font-family: sans-serif;
- }
-
- /* Coverage Table */
-
- td.coverTableHead
- {
- text-align: center;
- color: white;
- background-color: SteelBlue;
- font-family: sans-serif;
- font-size: 120%;
- white-space: nowrap;
- padding-left: 4px;
- padding-right: 4px;
- }
- td.coverFile
- {
- text-align: left;
- padding-left: 10px;
- padding-right: 20px;
- color: black;
- background-color: LightBlue;
- font-family: monospace;
- font-weight: bold;
- font-size: 110%;
- }
- td.coverBar
- {
- padding-left: 10px;
- padding-right: 10px;
- background-color: LightBlue;
- }
- td.coverBarOutline
- {
- background-color: white;
- }
- td.coverValue
- {
- padding-top: 2px;
- text-align: right;
- padding-left: 10px;
- padding-right: 10px;
- font-family: sans-serif;
- white-space: nowrap;
- font-weight: bold;
- }
-
- /* Link Details */
- a.detail:link
- {
- color: #B8D0FF;
- font-size:80%;
- }
- a.detail:visited
- {
- color: #B8D0FF;
- font-size:80%;
- }
- a.detail:active
- {
- color: #FFFFFF;
- font-size:80%;
- }
-
- .graphcont{
- color:#000;
- font-weight:700;
- float:left
- }
-
- .graph{
- float:left;
- background-color: white;
- position:relative;
- width:280px;
- padding:0
- }
-
- .graph .bar{
- display:block;
- position:relative;
- border:black 1px solid;
- text-align:center;
- color:#fff;
- height:10px;
- font-family:Arial,Helvetica,sans-serif;
- font-size:12px;
- line-height:1.9em
- }
-
- .graph .bar span{
- position:absolute;
- left:1em
- }
-
- td.coveredLine,
- span.coveredLine
- {
- background-color: ${covered_color};
- }
-
- td.uncoveredLine,
- span.uncoveredLine
- {
- background-color: ${uncovered_color};
- }
-''')
-
-#
-# A string template for the root HTML output
-#
-root_page = Template('''
-
-
-
-
- ${HEAD}
-
-
-
-
-
-
- GCC Code Coverage Report
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- File
- Lines
- Branches
-
-
- ${ROWS}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-''')
-
-#
-# A string template for the source file HTML output
-#
-source_page = Template('''
-
-
-
-
- ${HEAD}
-
-
-
-
-
-
- GCC Code Coverage Report
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Line
- Exec
- Source
-
-
- ${ROWS}
-
-
-
-
-
-
-
-
-
-
-
-''')
-
-#
-# Produce an HTML report
-#
-def print_html_report(covdata, details):
- def _num_uncovered(key):
- (total, covered, percent) = covdata[key].coverage()
- return total - covered
- def _percent_uncovered(key):
- (total, covered, percent) = covdata[key].coverage()
- if covered:
- return -1.0*covered/total
- else:
- return total or 1e6
- def _alpha(key):
- return key
-
- if options.output is None:
- details = False
- data = {}
- data['HEAD'] = "Head"
- data['VERSION'] = version_str()
- data['TIME'] = str(int(time.time()))
- data['DATE'] = datetime.date.today().isoformat()
- data['ROWS'] = []
- data['low_color'] = low_color
- data['medium_color'] = medium_color
- data['high_color'] = high_color
- data['COVERAGE_MED'] = medium_coverage
- data['COVERAGE_HIGH'] = high_coverage
- data['CSS'] = css.substitute(low_color=low_color, medium_color=medium_color, high_color=high_color, covered_color=covered_color, uncovered_color=uncovered_color)
- data['DIRECTORY'] = ''
-
- branchTotal = 0
- branchCovered = 0
- options.show_branch = True
- for key in covdata.keys():
- (total, covered, percent) = covdata[key].coverage()
- branchTotal += total
- branchCovered += covered
- data['BRANCHES_EXEC'] = str(branchCovered)
- data['BRANCHES_TOTAL'] = str(branchTotal)
- coverage = 0.0 if branchTotal == 0 else round(100.0*branchCovered / branchTotal,1)
- data['BRANCHES_COVERAGE'] = str(coverage)
- if coverage < medium_coverage:
- data['BRANCHES_COLOR'] = low_color
- elif coverage < high_coverage:
- data['BRANCHES_COLOR'] = medium_color
- else:
- data['BRANCHES_COLOR'] = high_color
-
- lineTotal = 0
- lineCovered = 0
- options.show_branch = False
- for key in covdata.keys():
- (total, covered, percent) = covdata[key].coverage()
- lineTotal += total
- lineCovered += covered
- data['LINES_EXEC'] = str(lineCovered)
- data['LINES_TOTAL'] = str(lineTotal)
- coverage = 0.0 if lineTotal == 0 else round(100.0*lineCovered / lineTotal,1)
- data['LINES_COVERAGE'] = str(coverage)
- if coverage < medium_coverage:
- data['LINES_COLOR'] = low_color
- elif coverage < high_coverage:
- data['LINES_COLOR'] = medium_color
- else:
- data['LINES_COLOR'] = high_color
-
-
- # Generate the coverage output (on a per-package basis)
- #source_dirs = set()
- files = []
- keys = list(covdata.keys())
- keys.sort(key=options.sort_uncovered and _num_uncovered or \
- options.sort_percent and _percent_uncovered or _alpha)
- for f in keys:
- cdata = covdata[f]
- filtered_fname = options.root_filter.sub('',f)
- files.append(filtered_fname)
- cdata._filename = filtered_fname
- ttmp = os.path.abspath(options.output).split('.')
- if len(ttmp) > 1:
- cdata._sourcefile = '.'.join( ttmp[:-1] ) + '.' + cdata._filename.replace('/','_') + '.' + ttmp[-1]
- else:
- cdata._sourcefile = ttmp[0] + '.' + cdata._filename.replace('/','_') + '.html'
- # Define the common root directory, which may differ from options.root
- # when source files share a common prefix.
- if len(files) > 1:
- commondir = posixpath.commonprefix(files)
- if commondir != '':
- data['DIRECTORY'] = commondir
- else:
- dir_, file_ = os.path.split(filtered_fname)
- if dir_ != '':
- data['DIRECTORY'] = dir_ + os.sep
-
-
- for f in keys:
- cdata = covdata[f]
- class_lines = 0
- class_hits = 0
- class_branches = 0
- class_branch_hits = 0
- for line in cdata.all_lines:
- hits = cdata.covered.get(line, 0)
- class_lines += 1
- if hits > 0:
- class_hits += 1
- branches = cdata.branches.get(line)
- if branches is None:
- pass
- else:
- b_hits = 0
- for v in branches.values():
- if v > 0:
- b_hits += 1
- coverage = 100*b_hits/len(branches)
- class_branch_hits += b_hits
- class_branches += len(branches)
-
- lines_covered = 100.0 if class_lines == 0 else 100.0*class_hits/class_lines
- branches_covered = 100.0 if class_branches == 0 else 100.0*class_branch_hits/class_branches
-
- data['ROWS'].append( html_row(details, cdata._sourcefile, directory=data['DIRECTORY'], filename=cdata._filename, LinesExec=class_hits, LinesTotal=class_lines, LinesCoverage=lines_covered, BranchesExec=class_branch_hits, BranchesTotal=class_branches, BranchesCoverage=branches_covered ) )
- data['ROWS'] = '\n'.join(data['ROWS'])
-
- if data['DIRECTORY'] == '':
- data['DIRECTORY'] = "."
-
- htmlString = root_page.substitute(**data)
-
- if options.output is None:
- sys.stdout.write(htmlString+'\n')
- else:
- OUTPUT = open(options.output, 'w')
- OUTPUT.write(htmlString +'\n')
- OUTPUT.close()
-
- # Return, if no details are requested
- if not details:
- return
-
- #
- # Generate an HTML file for every source file
- #
- for f in keys:
- cdata = covdata[f]
-
- data['FILENAME'] = cdata._filename
- data['ROWS'] = ''
-
- options.show_branch = True
- branchTotal, branchCovered, tmp = cdata.coverage()
- data['BRANCHES_EXEC'] = str(branchCovered)
- data['BRANCHES_TOTAL'] = str(branchTotal)
- coverage = 0.0 if branchTotal == 0 else round(100.0*branchCovered / branchTotal,1)
- data['BRANCHES_COVERAGE'] = str(coverage)
- if coverage < medium_coverage:
- data['BRANCHES_COLOR'] = low_color
- elif coverage < high_coverage:
- data['BRANCHES_COLOR'] = medium_color
- else:
- data['BRANCHES_COLOR'] = high_color
-
- options.show_branch = False
- lineTotal, lineCovered, tmp = cdata.coverage()
- data['LINES_EXEC'] = str(lineCovered)
- data['LINES_TOTAL'] = str(lineTotal)
- coverage = 0.0 if lineTotal == 0 else round(100.0*lineCovered / lineTotal,1)
- data['LINES_COVERAGE'] = str(coverage)
- if coverage < medium_coverage:
- data['LINES_COLOR'] = low_color
- elif coverage < high_coverage:
- data['LINES_COLOR'] = medium_color
- else:
- data['LINES_COLOR'] = high_color
-
- data['ROWS'] = []
- currdir = os.getcwd()
- os.chdir(root_dir)
- INPUT = open(data['FILENAME'], 'r')
- ctr = 1
- for line in INPUT:
- data['ROWS'].append( source_row(ctr, line.rstrip(), cdata) )
- ctr += 1
- INPUT.close()
- os.chdir(currdir)
- data['ROWS'] = '\n'.join(data['ROWS'])
-
- htmlString = source_page.substitute(**data)
- OUTPUT = open(cdata._sourcefile, 'w')
- OUTPUT.write(htmlString +'\n')
- OUTPUT.close()
-
-
-def source_row(lineno, source, cdata):
- rowstr=Template('''
-
- ${lineno}
- ${linecount}
- ${source}
- ''')
- kwargs = {}
- kwargs['lineno'] = str(lineno)
- if lineno in cdata.covered:
- kwargs['covclass'] = 'class="coveredLine"'
- kwargs['linecount'] = str(cdata.covered.get(lineno,0))
- elif lineno in cdata.uncovered:
- kwargs['covclass'] = 'class="uncoveredLine"'
- kwargs['linecount'] = ''
- else:
- kwargs['covclass'] = ''
- kwargs['linecount'] = ''
- kwargs['source'] = html.escape(source)
- return rowstr.substitute(**kwargs)
-
-#
-# Generate the table row for a single file
-#
-nrows = 0
-def html_row(details, sourcefile, **kwargs):
- rowstr=Template('''
-
- ${filename}
-
-
-
- ${LinesCoverage} %
- ${LinesExec} / ${LinesTotal}
- ${BranchesCoverage} %
- ${BranchesExec} / ${BranchesTotal}
-
-''')
- global nrows
- nrows += 1
- if nrows % 2 == 0:
- kwargs['altstyle'] = 'style="background-color:LightSteelBlue"'
- else:
- kwargs['altstyle'] = ''
- if details:
- kwargs['filename'] = '%s ' % (sourcefile, kwargs['filename'][len(kwargs['directory']):])
- else:
- kwargs['filename'] = kwargs['filename'][len(kwargs['directory']):]
- kwargs['LinesCoverage'] = round(kwargs['LinesCoverage'],1)
- if kwargs['LinesCoverage'] < medium_coverage:
- kwargs['LinesColor'] = low_color
- kwargs['LinesBar'] = 'red'
- elif kwargs['LinesCoverage'] < high_coverage:
- kwargs['LinesColor'] = medium_color
- kwargs['LinesBar'] = 'yellow'
- else:
- kwargs['LinesColor'] = high_color
- kwargs['LinesBar'] = 'green'
-
- kwargs['BranchesCoverage'] = round(kwargs['BranchesCoverage'],1)
- if kwargs['BranchesCoverage'] < medium_coverage:
- kwargs['BranchesColor'] = low_color
- kwargs['BranchesBar'] = 'red'
- elif kwargs['BranchesCoverage'] < high_coverage:
- kwargs['BranchesColor'] = medium_color
- kwargs['BranchesBar'] = 'yellow'
- else:
- kwargs['BranchesColor'] = high_color
- kwargs['BranchesBar'] = 'green'
-
- return rowstr.substitute(**kwargs)
-
-
-#
-# Produce an XML report in the Cobertura format
-#
-def print_xml_report(covdata):
- branchTotal = 0
- branchCovered = 0
- lineTotal = 0
- lineCovered = 0
-
- options.show_branch = True
- for key in covdata.keys():
- (total, covered, percent) = covdata[key].coverage()
- branchTotal += total
- branchCovered += covered
-
- options.show_branch = False
- for key in covdata.keys():
- (total, covered, percent) = covdata[key].coverage()
- lineTotal += total
- lineCovered += covered
-
- impl = xml.dom.minidom.getDOMImplementation()
- docType = impl.createDocumentType(
- "coverage", None,
- "http://cobertura.sourceforge.net/xml/coverage-03.dtd" )
- doc = impl.createDocument(None, "coverage", docType)
- root = doc.documentElement
- root.setAttribute( "line-rate", lineTotal == 0 and '0.0' or
- str(float(lineCovered) / lineTotal) )
- root.setAttribute( "branch-rate", branchTotal == 0 and '0.0' or
- str(float(branchCovered) / branchTotal) )
- root.setAttribute( "timestamp", str(int(time.time())) )
- root.setAttribute( "version", "gcovr %s" % (version_str(),) )
-
- # Generate the element: this is either the root directory
- # (specified by --root), or the CWD.
- sources = doc.createElement("sources")
- root.appendChild(sources)
-
- # Generate the coverage output (on a per-package basis)
- packageXml = doc.createElement("packages")
- root.appendChild(packageXml)
- packages = {}
- source_dirs = set()
-
- keys = list(covdata.keys())
- keys.sort()
- for f in keys:
- data = covdata[f]
- dir = options.root_filter.sub('',f)
- if f.endswith(dir):
- src_path = f[:-1*len(dir)]
- if len(src_path) > 0:
- while dir.startswith(os.path.sep):
- src_path += os.path.sep
- dir = dir[len(os.path.sep):]
- source_dirs.add(src_path)
- else:
- # Do no truncation if the filter does not start matching at
- # the beginning of the string
- dir = f
- (dir, fname) = os.path.split(dir)
-
- package = packages.setdefault(
- dir, [ doc.createElement("package"), {},
- 0, 0, 0, 0 ] )
- c = doc.createElement("class")
- # The Cobertura DTD requires a methods section, which isn't
- # trivial to get from gcov (so we will leave it blank)
- c.appendChild(doc.createElement("methods"))
- lines = doc.createElement("lines")
- c.appendChild(lines)
-
- class_lines = 0
- class_hits = 0
- class_branches = 0
- class_branch_hits = 0
- for line in data.all_lines:
- hits = data.covered.get(line, 0)
- class_lines += 1
- if hits > 0:
- class_hits += 1
- l = doc.createElement("line")
- l.setAttribute("number", str(line))
- l.setAttribute("hits", str(hits))
- branches = data.branches.get(line)
- if branches is None:
- l.setAttribute("branch", "false")
- else:
- b_hits = 0
- for v in branches.values():
- if v > 0:
- b_hits += 1
- coverage = 100*b_hits/len(branches)
- l.setAttribute("branch", "true")
- l.setAttribute( "condition-coverage",
- "%i%% (%i/%i)" %
- (coverage, b_hits, len(branches)) )
- cond = doc.createElement('condition')
- cond.setAttribute("number", "0")
- cond.setAttribute("type", "jump")
- cond.setAttribute("coverage", "%i%%" % ( coverage ) )
- class_branch_hits += b_hits
- class_branches += float(len(branches))
- conditions = doc.createElement("conditions")
- conditions.appendChild(cond)
- l.appendChild(conditions)
-
- lines.appendChild(l)
-
- className = fname.replace('.', '_')
- c.setAttribute("name", className)
- c.setAttribute("filename", os.path.join(dir, fname))
- c.setAttribute("line-rate", str(class_hits / (1.0*class_lines or 1.0)))
- c.setAttribute( "branch-rate",
- str(class_branch_hits / (1.0*class_branches or 1.0)) )
- c.setAttribute("complexity", "0.0")
-
- package[1][className] = c
- package[2] += class_hits
- package[3] += class_lines
- package[4] += class_branch_hits
- package[5] += class_branches
-
- keys = list(packages.keys())
- keys.sort()
- for packageName in keys:
- packageData = packages[packageName]
- package = packageData[0];
- packageXml.appendChild(package)
- classes = doc.createElement("classes")
- package.appendChild(classes)
- classNames = list(packageData[1].keys())
- classNames.sort()
- for className in classNames:
- classes.appendChild(packageData[1][className])
- package.setAttribute("name", packageName.replace(os.sep, '.'))
- package.setAttribute("line-rate", str(packageData[2]/(1.0*packageData[3] or 1.0)))
- package.setAttribute( "branch-rate", str(packageData[4] / (1.0*packageData[5] or 1.0) ))
- package.setAttribute("complexity", "0.0")
-
-
- # Populate the element: this is either the root directory
- # (specified by --root), or relative directories based
- # on the filter, or the CWD
- if options.root is not None:
- source = doc.createElement("source")
- source.appendChild(doc.createTextNode(options.root.strip()))
- sources.appendChild(source)
- elif len(source_dirs) > 0:
- cwd = os.getcwd()
- for d in source_dirs:
- source = doc.createElement("source")
- if d.startswith(cwd):
- reldir = d[len(cwd):].lstrip(os.path.sep)
- elif cwd.startswith(d):
- i = 1
- while normpath(d) != normpath(os.path.join(*tuple([cwd]+['..']*i))):
- i += 1
- reldir = os.path.join(*tuple(['..']*i))
- else:
- reldir = d
- source.appendChild(doc.createTextNode(reldir.strip()))
- sources.appendChild(source)
- else:
- source = doc.createElement("source")
- source.appendChild(doc.createTextNode('.'))
- sources.appendChild(source)
-
- if options.prettyxml:
- import textwrap
- lines = doc.toprettyxml(" ").split('\n')
- for i in xrange(len(lines)):
- n=0
- while n < len(lines[i]) and lines[i][n] == " ":
- n += 1
- lines[i] = "\n".join(textwrap.wrap(lines[i], 78, break_long_words=False, break_on_hyphens=False, subsequent_indent=" "+ n*" "))
- xmlString = "\n".join(lines)
- #print textwrap.wrap(doc.toprettyxml(" "), 80)
- else:
- xmlString = doc.toprettyxml(indent="")
- if options.output is None:
- sys.stdout.write(xmlString+'\n')
- else:
- OUTPUT = open(options.output, 'w')
- OUTPUT.write(xmlString +'\n')
- OUTPUT.close()
-
-
-##
-## MAIN
-##
-
-#
-# Create option parser
-#
-parser = OptionParser()
-parser.add_option("--version",
- help="Print the version number, then exit",
- action="store_true",
- dest="version",
- default=False)
-parser.add_option("-v","--verbose",
- help="Print progress messages",
- action="store_true",
- dest="verbose",
- default=False)
-parser.add_option('--object-directory',
- help="Specify the directory that contains the gcov data files. gcovr must be able to identify the path between the *.gcda files and the directory where gcc was originally run. Normally, gcovr can guess correctly. This option overrides gcovr's normal path detection and can specify either the path from gcc to the gcda file (i.e. what was passed to gcc's '-o' option), or the path from the gcda file to gcc's original working directory.",
- action="store",
- dest="objdir",
- default=None)
-parser.add_option("-o","--output",
- help="Print output to this filename",
- action="store",
- dest="output",
- default=None)
-parser.add_option("-k","--keep",
- help="Keep the temporary *.gcov files generated by gcov. By default, these are deleted.",
- action="store_true",
- dest="keep",
- default=False)
-parser.add_option("-d","--delete",
- help="Delete the coverage files after they are processed. These are generated by the users's program, and by default gcovr does not remove these files.",
- action="store_true",
- dest="delete",
- default=False)
-parser.add_option("-f","--filter",
- help="Keep only the data files that match this regular expression",
- action="append",
- dest="filter",
- default=[])
-parser.add_option("-e","--exclude",
- help="Exclude data files that match this regular expression",
- action="append",
- dest="exclude",
- default=[])
-parser.add_option("--gcov-filter",
- help="Keep only gcov data files that match this regular expression",
- action="store",
- dest="gcov_filter",
- default=None)
-parser.add_option("--gcov-exclude",
- help="Exclude gcov data files that match this regular expression",
- action="append",
- dest="gcov_exclude",
- default=[])
-parser.add_option("-r","--root",
- help="Defines the root directory for source files. This is also used to filter the files, and to standardize the output.",
- action="store",
- dest="root",
- default=None)
-parser.add_option("-x","--xml",
- help="Generate XML instead of the normal tabular output.",
- action="store_true",
- dest="xml",
- default=False)
-parser.add_option("--xml-pretty",
- help="Generate pretty XML instead of the normal dense format.",
- action="store_true",
- dest="prettyxml",
- default=False)
-parser.add_option("--html",
- help="Generate HTML instead of the normal tabular output.",
- action="store_true",
- dest="html",
- default=False)
-parser.add_option("--html-details",
- help="Generate HTML output for source file coverage.",
- action="store_true",
- dest="html_details",
- default=False)
-parser.add_option("-b","--branches",
- help="Tabulate the branch coverage instead of the line coverage.",
- action="store_true",
- dest="show_branch",
- default=None)
-parser.add_option("-u","--sort-uncovered",
- help="Sort entries by increasing number of uncovered lines.",
- action="store_true",
- dest="sort_uncovered",
- default=None)
-parser.add_option("-p","--sort-percentage",
- help="Sort entries by decreasing percentage of covered lines.",
- action="store_true",
- dest="sort_percent",
- default=None)
-parser.add_option("--gcov-executable",
- help="Defines the name/path to the gcov executable [defaults to the "
- "GCOV environment variable, if present; else 'gcov'].",
- action="store",
- dest="gcov_cmd",
- default=os.environ.get('GCOV', 'gcov') )
-parser.add_option("--exclude-unreachable-branches",
- help="Exclude from coverage branches which are marked to be excluded by LCOV/GCOV markers "
- "or are determined to be from lines containing only compiler-generated \"dead\" code.",
- action="store_true",
- dest="exclude_unreachable_branches",
- default=False)
-parser.usage="gcovr [options]"
-parser.description="A utility to run gcov and generate a simple report that summarizes the coverage"
-#
-# Process options
-#
-(options, args) = parser.parse_args(args=sys.argv)
-if options.version:
- sys.stdout.write(
- "gcovr %s\n"
- "\n"
- "Copyright (2013) Sandia Corporation. Under the terms of Contract\n"
- "DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government\n"
- "retains certain rights in this software.\n"
- % (version_str(),) )
- sys.exit(0)
-if options.objdir:
- tmp = options.objdir.replace('/',os.sep).replace('\\',os.sep)
- while os.sep+os.sep in tmp:
- tmp = tmp.replace(os.sep+os.sep, os.sep)
- if normpath(options.objdir) != tmp:
- sys.stderr.write(
- "(WARNING) relative referencing in --object-directory.\n"
- "\tthis could cause strange errors when gcovr attempts to\n"
- "\tidentify the original gcc working directory.\n")
- if not os.path.exists(normpath(options.objdir)):
- sys.stderr.write(
- "(ERROR) Bad --object-directory option.\n"
- "\tThe specified directory does not exist.\n")
- sys.exit(1)
-#
-# Setup filters
-#
-for i in range(0,len(options.exclude)):
- options.exclude[i] = re.compile(options.exclude[i])
-
-if options.root is not None:
- if not options.root:
- sys.stderr.write(
- "(ERROR) empty --root option.\n"
- "\tRoot specifies the path to the root directory of your project.\n"
- "\tThis option cannot be an empty string.\n")
- sys.exit(1)
- options.root_filter = re.compile(re.escape(os.path.abspath(options.root)+os.sep))
- root_dir = os.path.abspath(options.root)
-else:
- options.root_filter = re.compile('')
- root_dir = starting_dir
-
-for i in range(0,len(options.filter)):
- options.filter[i] = re.compile(options.filter[i])
-if len(options.filter) == 0:
- options.filter.append(options.root_filter)
-
-for i in range(0,len(options.gcov_exclude)):
- options.gcov_exclude[i] = re.compile(options.gcov_exclude[i])
-if options.gcov_filter is not None:
- options.gcov_filter = re.compile(options.gcov_filter)
-else:
- options.gcov_filter = re.compile('')
-#
-# Get data files
-#
-if len(args) == 1:
- if options.root is None:
- datafiles = get_datafiles(["."], options)
- else:
- datafiles = get_datafiles(options.root, options)
-else:
- datafiles = get_datafiles(args[1:], options)
-#
-# Get coverage data
-#
-covdata = {}
-for file in datafiles:
- process_datafile(file,covdata,options)
-if options.verbose:
- sys.stdout.write("Gathered coveraged data for "+str(len(covdata))+" files\n")
-#
-# Print report
-#
-if options.xml or options.prettyxml:
- print_xml_report(covdata)
-elif options.html:
- print_html_report(covdata, options.html_details)
-else:
- print_text_report(covdata)
diff --git a/client/client-multi/client-c/listfiles/CMakeGen.cmake b/client/client-multi/client-c/listfiles/CMakeGen.cmake
deleted file mode 100644
index 982d7aa71a..0000000000
--- a/client/client-multi/client-c/listfiles/CMakeGen.cmake
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set (KAA_SOURCE_FILES ${KAA_SOURCE_FILES}
- ${KAA_SRC_FOLDER}/gen/kaa_profile_gen.c
- ${KAA_SRC_FOLDER}/gen/kaa_logging_gen.c
- ${KAA_SRC_FOLDER}/gen/kaa_configuration_gen.c
- ${KAA_SRC_FOLDER}/gen/kaa_notification_gen.c
-)
diff --git a/client/client-multi/client-c/listfiles/UnitTest.cmake b/client/client-multi/client-c/listfiles/UnitTest.cmake
deleted file mode 100644
index d62dd424f3..0000000000
--- a/client/client-multi/client-c/listfiles/UnitTest.cmake
+++ /dev/null
@@ -1,221 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-if(KAA_UNITTESTS_COMPILE)
- find_package(cmocka REQUIRED)
- find_program(MEMORYCHECK_COMMAND valgrind)
- set(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --show-reachable=yes --trace-children=yes -v")
-
- include(CTest)
- include(CMakeParseArguments)
-endif()
-
-################################################################################
-# Creates an unit test with given name and dependencies.
-#
-# TODO: move this function to the separate module, after new design will be implemented.
-# When new SDK build system will be ready, tests will be encapsulated
-# within each production module. Test system helpers, like this function
-# will be moved to separate cmake build modules or scripts.
-#
-# Syntax:
-# kaa_add_unit_test(NAME test_name
-# SOURCES test_sources_files...
-# [DEPENDS list_of_dependencies...]
-# [INC_DIRS list_of_include_directories...])
-function(kaa_add_unit_test)
- if(KAA_UNITTESTS_COMPILE)
- cmake_parse_arguments(
- UNIT_TEST
- ""
- "NAME"
- "SOURCES;DEPENDS;INC_DIRS"
- ${ARGN})
-
- if (NOT DEFINED UNIT_TEST_NAME AND DEFINED UNIT_TEST_SOURCES)
- message(FATAL_ERROR "Test sources and name must be defined!")
- endif()
-
- add_executable(${UNIT_TEST_NAME} ${UNIT_TEST_SOURCES})
- add_test(NAME ${UNIT_TEST_NAME} COMMAND ${UNIT_TEST_NAME})
- target_link_libraries(${UNIT_TEST_NAME} ${CMOCKA_LIBRARIES})
-
- if(UNIT_TEST_DEPENDS)
- target_link_libraries(${UNIT_TEST_NAME} ${UNIT_TEST_DEPENDS})
- endif()
-
- target_include_directories(
- ${UNIT_TEST_NAME}
- PRIVATE
- test)
- if(UNIT_TEST_INC_DIRS)
- target_include_directories(
- ${UNIT_TEST_NAME}
- PRIVATE
- ${UNIT_TEST_INC_DIRS})
- endif()
-
- message("-----------------------------------------------")
- message(" Test added: ${UNIT_TEST_NAME}")
- message(" Test sources: ${UNIT_TEST_SOURCES}")
- message(" Test dependencies: ${UNIT_TEST_DEPENDS}")
- message(" Test includes: ${UNIT_TEST_INC_DIRS}")
- message("-----------------------------------------------")
- endif()
-endfunction()
-
-################################################################################
-
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sonar-project.properties.in"
- "${CMAKE_CURRENT_SOURCE_DIR}/sonar-project.properties")
-
-
-if(WITH_EXTENSION_LOGGING)
- kaa_add_unit_test(NAME test_ext_log_storage_memory
- SOURCES
- test/platform-impl/test_ext_log_storage_memory.c
- test/kaa_test_external.c
- DEPENDS
- kaac
- INC_DIRS
- test)
-
- kaa_add_unit_test(NAME test_ext_log_upload_strategy_by_volume
- SOURCES
- test/platform-impl/test_ext_log_upload_strategies.c
- test/kaa_test_external.c
- DEPENDS
- kaac
- INC_DIRS
- test)
-
- kaa_add_unit_test(NAME test_platform_protocol
- SOURCES
- test/test_platform_protocol.c
- DEPENDS
- kaac)
-endif()
-
-kaa_add_unit_test(NAME test_meta_extension
- SOURCES
- test/test_meta_extension.c
- test/kaa_test_external.c
- DEPENDS
- kaac)
-
-kaa_add_unit_test(NAME test_platform_utils
- SOURCES
- test/test_platform_utils.c
- test/kaa_test_external.c
- DEPENDS
- kaac)
-
-kaa_add_unit_test(NAME test_context
- SOURCES
- test/test_kaa_context.c
- test/kaa_test_external.c
- DEPENDS
- kaac)
-
-kaa_add_unit_test(NAME test_status
- SOURCES
- test/test_kaa_status.c
- DEPENDS
- kaac)
-
-kaa_add_unit_test(NAME test_common
- SOURCES
- test/test_kaa_common.c
- test/kaa_test_external.c
- DEPENDS
- kaac)
-
-kaa_add_unit_test(NAME test_list
- SOURCES
- test/collections/test_kaa_list.c
- src/kaa/collections/kaa_list.c
- INC_DIRS
- src/kaa ${KAA_INCLUDE_PATHS} test)
-
-kaa_add_unit_test(NAME test_kaatcp_parser
- SOURCES
- test/kaatcp/kaatcp_parser_test.c
- test/kaa_test_external.c
- DEPENDS
- kaac
- INC_DIRS
- test)
-
-kaa_add_unit_test(NAME test_kaatcp_request
- SOURCES
- test/kaatcp/kaatcp_request_test.c
- test/kaa_test_external.c
- DEPENDS
- kaac
- INC_DIRS
- test)
-
-kaa_add_unit_test(NAME test_kaa_tcp_channel_bootstrap
- SOURCES
- test/kaa_tcp_channel/test_kaa_tcp_channel_bootstrap.c
- test/kaa_test_external.c
- DEPENDS
- kaac
- INC_DIRS
- test)
-
-kaa_add_unit_test(NAME test_kaa_common_schema
- SOURCES
- test/test_kaa_common_schema.c
- test/kaa_test_external.c
- DEPENDS
- kaac)
-
-kaa_add_unit_test(NAME test_kaa_reallocation
- SOURCES
- test/utilities/test_kaa_reallocation.c
- DEPENDS
- kaac
- INC_DIRS
- test)
-
-kaa_add_unit_test(NAME test_kaa_extension
- SOURCES
- test/test_kaa_extension.c src/kaa/kaa_extension.c
- INC_DIRS
- test/kaa_extension src/kaa)
-
-kaa_add_unit_test(NAME test_kaa_extension_private
- SOURCES
- test/test_kaa_extension_private.c src/kaa/kaa_extension.c
- INC_DIRS
- src/kaa src/extensions/bootstrap ${KAA_INCLUDE_PATHS})
-
-# KAA-985
-#kaa_add_unit_test(NAME test_kaa_tcp_channel_operation
-# SOURCES
-# test/kaa_tcp_channel/test_kaa_tcp_channel_operation.c
-# test/kaa_test_external.c
-# DEPENDS
-# kaac
-# INC_DIRS
-# test)
-
-kaa_add_unit_test(NAME test_kaa_channel_manager
- SOURCES
- test/test_kaa_channel_manager.c
- DEPENDS
- kaac)
diff --git a/client/client-multi/client-c/listfiles/platform/cc32xx/CMakeLists.txt b/client/client-multi/client-c/listfiles/platform/cc32xx/CMakeLists.txt
deleted file mode 100644
index 25aa0e6950..0000000000
--- a/client/client-multi/client-c/listfiles/platform/cc32xx/CMakeLists.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set(KAA_SOURCE_FILES
- ${KAA_SOURCE_FILES}
- ${KAA_SRC_FOLDER}/platform-impl/posix/kaa_client.c
- ${KAA_SRC_FOLDER}/platform-impl/common/kaa_failover_strategy.c
- ${KAA_SRC_FOLDER}/platform-impl/common/sha.c
- ${KAA_SRC_FOLDER}/platform-impl/cc32xx/logger.c
- ${KAA_SRC_FOLDER}/platform-impl/cc32xx/file_utils.c
- ${KAA_SRC_FOLDER}/platform-impl/cc32xx/status.c
- ${KAA_SRC_FOLDER}/platform-impl/cc32xx/configuration_persistence.c
- ${KAA_SRC_FOLDER}/platform-impl/cc32xx/time.c
- ${KAA_SRC_FOLDER}/platform-impl/cc32xx/reboot.c
- ${KAA_SRC_FOLDER}/platform-impl/common/key_utils.c
- ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_storage_memory.c
- ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_upload_strategies.c
- )
-
-if(NOT KAA_WITHOUT_TCP_CHANNEL)
- set(KAA_SOURCE_FILES
- ${KAA_SOURCE_FILES}
- ${KAA_SRC_FOLDER}/kaa_protocols/kaa_tcp/kaatcp_parser.c
- ${KAA_SRC_FOLDER}/kaa_protocols/kaa_tcp/kaatcp_request.c
- ${KAA_SRC_FOLDER}/platform-impl/cc32xx/tcp_utils.c
- ${KAA_SRC_FOLDER}/platform-impl/common/kaa_tcp_channel.c
- )
-endif()
-
-set(KAA_THIRDPARTY_LIBRARIES
- ${KAA_THIRDPARTY_LIBRARIES}
- )
-
-
-set(CC32XX_INCDIRS ${CC32XX_SDK}/inc
- ${CC32XX_SDK}/driverlib
- ${CC32XX_SDK}/oslib
- ${CC32XX_SDK}/simplelink
- ${CC32XX_SDK}/simplelink/include
- ${CC32XX_SDK}/simplelink/source
- ${CC32XX_SDK}/example/common
- )
-
- set(KAA_INCLUDE_PATHS ${KAA_INCLUDE_PATHS} ${CC32XX_INCDIRS} ${KAA_SRC_FOLDER}/platform-impl/cc32xx)
-
-
-add_library(driver STATIC IMPORTED)
-set_property(TARGET driver PROPERTY IMPORTED_LOCATION ${CC32XX_SDK}/driverlib/gcc/exe/libdriver.a)
-
-add_library(simplelink_nonos STATIC IMPORTED)
-set_property(TARGET simplelink_nonos PROPERTY IMPORTED_LOCATION ${CC32XX_SDK}/simplelink/gcc/exe/libsimplelink_nonos.a)
-
-add_definitions(-DCC32XX_PLATFORM)
-
-set(KAA_THIRDPARTY_LIBRARIES driver simplelink_nonos)
-
-set(KAA_BUILD_STATIC_ONLY 1)
diff --git a/client/client-multi/client-c/listfiles/platform/esp8266/CMakeLists.txt b/client/client-multi/client-c/listfiles/platform/esp8266/CMakeLists.txt
deleted file mode 100644
index 6e0505c928..0000000000
--- a/client/client-multi/client-c/listfiles/platform/esp8266/CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# esp8266-rtos-sdk has some warnings, so we put -Wno-comment and -Wno-pedantic to suppress them
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DESP8266_PLATFORM -Wno-comment -Wno-pedantic")
-
-set(ESP8266_SRC_FOLDER ${KAA_SRC_FOLDER}/platform-impl/esp8266)
-
-set(ESP8266_NAME "esp8266")
-
-set(ESP8266_SRC
- ${ESP8266_SRC_FOLDER}/logger.c
- ${ESP8266_SRC_FOLDER}/kaa_client.c
- ${ESP8266_SRC_FOLDER}/configuration_persistence.c
- ${ESP8266_SRC_FOLDER}/status.c
- ${ESP8266_SRC_FOLDER}/tcp_utils.c
- ${ESP8266_SRC_FOLDER}/time.c
- ${ESP8266_SRC_FOLDER}/exit.c
- ${ESP8266_SRC_FOLDER}/snprintf.c
- ${KAA_SRC_FOLDER}/platform-impl/common/sha.c
- ${KAA_SRC_FOLDER}/platform-impl/common/kaa_failover_strategy.c
- ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_storage_memory.c
- ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_upload_strategies.c
- ${KAA_SRC_FOLDER}/platform-impl/common/key_utils.c
- ${KAA_SRC_FOLDER}/platform-impl/common/kaa_tcp_channel.c
- ${KAA_SRC_FOLDER}/kaa_protocols/kaa_tcp/kaatcp_parser.c
- ${KAA_SRC_FOLDER}/kaa_protocols/kaa_tcp/kaatcp_request.c
- )
-
-set(KAA_SOURCE_FILES ${KAA_SOURCE_FILES} ${ESP8266_SRC})
-
-set(KAA_INCLUDE_PATHS ${KAA_INCLUDE_PATHS} ${ESP8266_INCDIRS} ${ESP8266_SRC_FOLDER})
-
-set(KAA_BUILD_STATIC_ONLY 1)
diff --git a/client/client-multi/client-c/listfiles/platform/ios/CMakeLists.txt b/client/client-multi/client-c/listfiles/platform/ios/CMakeLists.txt
deleted file mode 100644
index 7c1d1a9638..0000000000
--- a/client/client-multi/client-c/listfiles/platform/ios/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-
-
-set(KAA_SOURCE_FILES
- ${KAA_SOURCE_FILES}
- ${KAA_SRC_FOLDER}/platform-impl/ios/sha.c
- ${KAA_SRC_FOLDER}/platform-impl/posix/logger.c
- ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_storage_memory.c
- ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_upload_strategies.c
- )
-
-if(NOT KAA_WITHOUT_TCP_CHANNEL)
- set(KAA_SOURCE_FILES
- ${KAA_SOURCE_FILES}
- ${KAA_SRC_FOLDER}/kaa_protocols/kaa_tcp/kaatcp_parser.c
- ${KAA_SRC_FOLDER}/kaa_protocols/kaa_tcp/kaatcp_request.c
- ${KAA_SRC_FOLDER}/platform-impl/posix/tcp_utils.c
- ${KAA_SRC_FOLDER}/platform-impl/common/kaa_tcp_channel.c
- )
-endif()
-
-set(KAA_THIRDPARTY_LIBRARIES
- ${KAA_THIRDPARTY_LIBRARIES}
- )
diff --git a/client/client-multi/client-c/listfiles/platform/posix/CMakeLists.txt b/client/client-multi/client-c/listfiles/platform/posix/CMakeLists.txt
deleted file mode 100644
index 354341a0e5..0000000000
--- a/client/client-multi/client-c/listfiles/platform/posix/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set(KAA_SOURCE_FILES
- ${KAA_SOURCE_FILES}
- ${KAA_SRC_FOLDER}/platform-impl/posix/kaa_client.c
- ${KAA_SRC_FOLDER}/platform-impl/posix/logger.c
- ${KAA_SRC_FOLDER}/platform-impl/posix/file_utils.c
- ${KAA_SRC_FOLDER}/platform-impl/posix/status.c
- ${KAA_SRC_FOLDER}/platform-impl/posix/configuration_persistence.c
- ${KAA_SRC_FOLDER}/platform-impl/common/sha.c
- ${KAA_SRC_FOLDER}/platform-impl/common/kaa_failover_strategy.c
- ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_storage_memory.c
- ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_upload_strategies.c
- ${KAA_SRC_FOLDER}/platform-impl/common/key_utils.c
- )
-
-if(NOT KAA_WITHOUT_TCP_CHANNEL)
- set(KAA_SOURCE_FILES
- ${KAA_SOURCE_FILES}
- ${KAA_SRC_FOLDER}/kaa_protocols/kaa_tcp/kaatcp_parser.c
- ${KAA_SRC_FOLDER}/kaa_protocols/kaa_tcp/kaatcp_request.c
- ${KAA_SRC_FOLDER}/platform-impl/posix/tcp_utils.c
- ${KAA_SRC_FOLDER}/platform-impl/common/kaa_tcp_channel.c
- )
-endif()
-
-set(KAA_INCLUDE_PATHS ${KAA_SRC_FOLDER}/platform-impl/posix)
diff --git a/client/client-multi/client-c/pom.xml b/client/client-multi/client-c/pom.xml
deleted file mode 100644
index 176009227a..0000000000
--- a/client/client-multi/client-c/pom.xml
+++ /dev/null
@@ -1,195 +0,0 @@
-
-
-
- 4.0.0
-
- org.kaaproject.kaa.client
- 0.10.0-SNAPSHOT
- client-multi
-
- client-c
- pom
-
- Kaa Client (C)
- http://kaaproject.org
-
-
- UTF-8
- ${basedir}/../../..
-
- c++
- ${basedir}/src
- __cplusplus 1
- .c
- .h
- build-posix/valgrindReports/*.memreport.xml
- ${basedir}/src,/usr/include/,/usr/include/linux/,/usr/lib/gcc/x86_64-linux-gnu/4.9/include/
- build-posix/gcovr-report.xml
- build-posix/*-Results.xml
- cunit-to-junit.xsl
- build-posix/cppcheck.xml
- build-posix/rats-report.xml
-
-
-
-
-
- maven-assembly-plugin
-
-
- assembly/client-c-sdk.xml
- assembly/client-c-sdk-templates.xml
-
-
-
-
- make-assembly
- package
-
- single
-
-
-
-
-
- org.apache.rat
- apache-rat-plugin
- ${rat.version}
-
-
- **/.*
- **/*.log
-
- build-posix/gcovr-report.xml
-
- src/kaa/platform-impl/esp8266/snprintf.c
-
- gcovr
-
- docs/
- thirdparty/
- nix/astyle/max_indent.patch
-
-
- build-*/
- Makefile
- Doxyfile
-
-
-
-
-
-
-
-
- license
-
-
-
- com.mycila.maven-license-plugin
- maven-license-plugin
- 1.8.0
-
-
- **/avro_src/**
- **/sha1.c
- **/snprintf.c
-
-
-
-
-
-
-
- compile-client-c
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- 1.2.1
-
-
- build_script
- install
-
- exec
-
-
- bash
- ${basedir}
-
- ${basedir}/build.sh
- build
-
-
-
-
- clean_script
- clean
-
- exec
-
-
- bash
- ${basedir}
-
- ${basedir}/build.sh
- clean
-
-
-
-
- test_script
- test
-
- exec
-
-
- bash
- ${basedir}
-
- ${basedir}/build.sh
- test
-
-
-
-
-
-
- com.soebes.maven.plugins.dmg
- doxygen-maven-plugin
- 1.0.1
-
- Doxyfile
-
-
-
- attach-doxygen-docs
- compile
-
- report
-
-
-
-
-
-
-
-
-
diff --git a/client/client-multi/client-c/scripts/build.sh b/client/client-multi/client-c/scripts/build.sh
deleted file mode 100755
index ddcf2bef1f..0000000000
--- a/client/client-multi/client-c/scripts/build.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set -e
-set -v
-
-make
-
-cd build-posix
-ctest -T test
-ctest -T memcheck
-ctest -T coverage
-cd ..
-
-make -C build-posix doxygen
-
-make -C build-posix cppcheck
diff --git a/client/client-multi/client-c/scripts/srcformat.sh b/client/client-multi/client-c/scripts/srcformat.sh
deleted file mode 100755
index cfff263860..0000000000
--- a/client/client-multi/client-c/scripts/srcformat.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# SYNOPSIS
-# srcformat.sh [FILE]...
-#
-# DESCRIPTION
-# This script formats given source FILES according code style.
-
-if [ -z "$@" ]; then echo "You must specify source files"; exit 1; fi
-
-astyle --style=1tbs --indent=spaces=4 --pad-header --align-pointer=name --indent-preproc-block --indent-switches -M8 "$@"
diff --git a/client/client-multi/client-c/shell.nix b/client/client-multi/client-c/shell.nix
deleted file mode 100644
index 8bc26233af..0000000000
--- a/client/client-multi/client-c/shell.nix
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright 2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-args@
-{ posixSupport ? null
-, clangSupport ? null
-, cc3200Support ? null
-, esp8266Support ? null
-, raspberrypiSupport ? null
-, testSupport ? null
-, withWerror ? null
-, withTooling ? null
-, withValgrind ? null
-}:
-
-let pkgs = import ../../../nix { };
-
-in pkgs.kaa-client-c.override args
diff --git a/client/client-multi/client-c/sonar-project.properties.in b/client/client-multi/client-c/sonar-project.properties.in
deleted file mode 100644
index a09b70322b..0000000000
--- a/client/client-multi/client-c/sonar-project.properties.in
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-sonar.sources=client/client-multi/client-c/src
-sonar.language=c++
-sonar.projectBaseDir=@CMAKE_CURRENT_SOURCE_DIR@
-sonar.cxx.defines=__cplusplus 1
-sonar.cxx.suffixes.sources=.c
-sonar.cxx.suffixes.headers=.h
-sonar.cxx.valgrind.reportPath=client/client-multi/client-c/build/valgrindReports/*.memreport.xml
-sonar.cxx.includeDirectories=client/client-multi/client-c/src,/usr/include/,/usr/include/linux/,/usr/lib/gcc/x86_64-linux-gnu/4.9/include/
-sonar.cxx.coverage.reportPath=client/client-multi/client-c/build/gcovr-report.xml
-sonar.cxx.other.reportPath=client/client-multi/client-c/build/*-Results.xml
-sonar.cxx.xunit.xsltURL=client/client-multi/client-c/cunit-to-junit.xsl
-sonar.cxx.cppcheck.reportPath=client/client-multi/client-c/build/cppcheck.xml
-sonar.cxx.rats.reportPath=client/client-multi/client-c/build/rats-report.xml
\ No newline at end of file
diff --git a/client/client-multi/client-c/src/extensions/bootstrap/CMakeLists.txt b/client/client-multi/client-c/src/extensions/bootstrap/CMakeLists.txt
deleted file mode 100644
index 157ef8934e..0000000000
--- a/client/client-multi/client-c/src/extensions/bootstrap/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set(EXTENSION_BOOTSTRAP_SOURCE_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_bootstrap_manager.c)
-
-set(EXTENSION_BOOTSTRAP_HEADER_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_bootstrap_manager.h)
-
-add_library(extension_bootstrap ${EXTENSION_BOOTSTRAP_SOURCE_FILES})
-target_include_directories(extension_bootstrap PUBLIC ${CMAKE_CURRENT_LIST_DIR})
-target_link_libraries(extension_bootstrap PUBLIC kaac)
-
-# KAA-989
-#kaa_add_unit_test(NAME test_kaa_bootstrap_manager
-# SOURCES
-# ${CMAKE_CURRENT_LIST_DIR}/test/test_kaa_bootstrap_manager.c
-# DEPENDS
-# kaac)
diff --git a/client/client-multi/client-c/src/extensions/bootstrap/kaa_bootstrap_manager.c b/client/client-multi/client-c/src/extensions/bootstrap/kaa_bootstrap_manager.c
deleted file mode 100644
index 30116ba6be..0000000000
--- a/client/client-multi/client-c/src/extensions/bootstrap/kaa_bootstrap_manager.c
+++ /dev/null
@@ -1,682 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_private.h"
-
-#include
-#include
-#include
-#include
-#include
-#include "platform/stdio.h"
-#include "platform/sock.h"
-#include "kaa_defaults.h"
-#include "kaa_platform_common.h"
-#include "kaa_platform_utils.h"
-#include "collections/kaa_list.h"
-#include "kaa_bootstrap_manager.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-#include "kaa_channel_manager.h"
-#include "platform/ext_kaa_failover_strategy.h"
-#include "kaa_protocols/kaa_tcp/kaatcp_common.h"
-
-typedef struct {
- kaa_transport_protocol_id_t protocol_id;
- size_t index;
-} kaa_bootstrap_access_points_t;
-
-typedef struct {
- kaa_transport_protocol_id_t protocol_id;
- kaa_list_t *access_points;
- kaa_list_node_t *current_access_points;
-} kaa_operations_access_points_t;
-
-typedef struct {
- bool is_failover;
- kaa_access_point_t *acess_point;
- kaa_server_type_t server;
- kaa_transport_protocol_id_t protocol_id;
- kaa_time_t next_execution_time;
- kaa_failover_reason reason;
-} failover_meta_info;
-
-struct kaa_bootstrap_manager_t {
- kaa_channel_manager_t *channel_manager;
- kaa_list_t *operations_access_points;
- kaa_list_t *bootstrap_access_points;
- kaa_context_t *kaa_context;
- kaa_logger_t *logger;
- kaa_time_t next_operations_request_time;
- failover_meta_info failover_meta_info;
-};
-
-static kaa_extension_id bootstrap_sync_services[1] = { KAA_EXTENSION_BOOTSTRAP };
-
-kaa_error_t kaa_extension_bootstrap_init(kaa_context_t *kaa_context, void **context)
-{
- kaa_error_t result = kaa_bootstrap_manager_create((kaa_bootstrap_manager_t **)context, kaa_context);
- kaa_context->bootstrap_manager = *context;
- return result;
-}
-
-kaa_error_t kaa_extension_bootstrap_deinit(void *context)
-{
- kaa_bootstrap_manager_destroy(context);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_bootstrap_request_get_size(void *context, size_t *expected_size)
-{
- return kaa_channel_manager_bootstrap_request_get_size(
- ((kaa_bootstrap_manager_t *)context)->channel_manager, expected_size);
-}
-
-kaa_error_t kaa_extension_bootstrap_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync)
-{
- (void)request_id;
-
- // TODO(KAA-982): Use asserts
- if (!context || !size || !need_resync) {
- return KAA_ERR_BADPARAM;
- }
-
- *need_resync = true;
-
- size_t size_needed;
- kaa_error_t error = kaa_channel_manager_bootstrap_request_get_size(
- ((kaa_bootstrap_manager_t *)context)->channel_manager, &size_needed);
- if (error) {
- return error;
- }
-
- if (!buffer || *size < size_needed) {
- *size = size_needed;
- return KAA_ERR_BUFFER_IS_NOT_ENOUGH;
- }
-
- *size = size_needed;
-
- kaa_platform_message_writer_t writer = KAA_MESSAGE_WRITER(buffer, *size);
- error = kaa_bootstrap_manager_bootstrap_request_serialize(context, &writer);
- if (error) {
- return error;
- }
-
- *size = writer.current - buffer;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_bootstrap_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size)
-{
- (void)request_id;
-
- // TODO(KAA-982): Use asserts
- if (!context || !buffer) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_platform_message_reader_t reader = KAA_MESSAGE_READER(buffer, size);
- return kaa_bootstrap_manager_handle_server_sync(context, &reader, extension_options, size);
-}
-
-static void destroy_access_point(void *data)
-{
- KAA_RETURN_IF_NIL(data,);
- kaa_access_point_t *access_point = (kaa_access_point_t *)data;
- if (access_point->connection_data) {
- KAA_FREE(access_point->connection_data);
- }
- KAA_FREE(access_point);
-}
-
-static void destroy_operations_access_points(void *data)
-{
- KAA_RETURN_IF_NIL(data,);
- kaa_operations_access_points_t *operations_access_points =
- (kaa_operations_access_points_t *)data;
- kaa_list_destroy(operations_access_points->access_points, destroy_access_point);
- KAA_FREE(operations_access_points);
-}
-
-static bool find_operations_access_points(void *data, void *context)
-{
- KAA_RETURN_IF_NIL2(data, context, false);
- kaa_transport_protocol_id_t *matcher = (kaa_transport_protocol_id_t *) context;
- kaa_transport_protocol_id_t *source = &(((kaa_operations_access_points_t *)data)->protocol_id);
- return kaa_transport_protocol_id_equals(matcher, source);
-}
-
-static bool find_bootstrap_access_points(void *data, void *context)
-{
- KAA_RETURN_IF_NIL2(data, context, false);
- kaa_transport_protocol_id_t *matcher = (kaa_transport_protocol_id_t *) context;
- kaa_transport_protocol_id_t *source = &(((kaa_bootstrap_access_points_t *)data)->protocol_id);
- return kaa_transport_protocol_id_equals(matcher, source);
-}
-
-static kaa_error_t do_sync(kaa_bootstrap_manager_t *self)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
-
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(
- self->channel_manager, KAA_EXTENSION_BOOTSTRAP);
- if (channel) {
- channel->sync_handler(channel->context, bootstrap_sync_services, 1);
- return KAA_ERR_NONE;
- }
-
- return KAA_ERR_NOT_FOUND;
-}
-
-static kaa_error_t kaa_bootstrap_manager_on_server_sync(kaa_bootstrap_manager_t *self)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
-
- kaa_list_node_t *channel_it = kaa_list_begin(self->operations_access_points);
- while (channel_it) {
- kaa_operations_access_points_t *operations_access_points = kaa_list_get_data(channel_it);
- kaa_access_point_t *access_point = kaa_list_get_data(
- kaa_list_begin(operations_access_points->access_points));
-
- kaa_channel_manager_on_new_access_point(self->channel_manager
- , &operations_access_points->protocol_id
- , KAA_SERVER_OPERATIONS
- , access_point);
-
- channel_it = kaa_list_next(channel_it);
- }
-
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t add_operations_access_point(kaa_bootstrap_manager_t *self
- , kaa_transport_protocol_id_t *protocol_id
- , kaa_access_point_t *access_point)
-{
- KAA_RETURN_IF_NIL2(protocol_id, access_point, KAA_ERR_BADPARAM);
-
- kaa_list_node_t *channel_it = kaa_list_find_next(kaa_list_begin(self->operations_access_points)
- , find_operations_access_points
- , protocol_id);
-
- if (channel_it) {
- kaa_operations_access_points_t *operations_access_points = kaa_list_get_data(channel_it);
- kaa_list_node_t *access_point_it = kaa_list_push_front(operations_access_points->access_points
- , access_point);
- KAA_RETURN_IF_NIL(access_point_it, KAA_ERR_NOMEM);
-
- operations_access_points->current_access_points = access_point_it;
- } else {
- kaa_operations_access_points_t *operations_access_points =
- (kaa_operations_access_points_t *)KAA_CALLOC(1, sizeof(kaa_operations_access_points_t));
- KAA_RETURN_IF_NIL(operations_access_points, KAA_ERR_NOMEM);
-
- operations_access_points->protocol_id = *protocol_id;
- operations_access_points->access_points = kaa_list_create();
- operations_access_points->current_access_points = kaa_list_push_front(operations_access_points->access_points
- , access_point);
-
- if (!operations_access_points->access_points || !operations_access_points->current_access_points) {
- destroy_operations_access_points(operations_access_points);
- KAA_LOG_WARN(self->logger, KAA_ERR_NOMEM, "Failed to add new access point: "
- "id=0x%08X, protocol: id=0x%08X, version=%u"
- , access_point->id, protocol_id->id, protocol_id->version);
- return KAA_ERR_NOMEM;
- }
-
- kaa_list_node_t *operations_access_points_it = kaa_list_push_front(self->operations_access_points, operations_access_points);
- if (!operations_access_points_it) {
- destroy_operations_access_points(operations_access_points);
- KAA_LOG_WARN(self->logger, KAA_ERR_NOMEM, "Failed to add new access point: "
- "id=0x%08X, protocol: id=0x%08X, version=%u"
- , access_point->id, protocol_id->id, protocol_id->version);
- return KAA_ERR_NOMEM;
- }
- }
-
- return KAA_ERR_NONE;
-}
-
-/** @deprecated Use kaa_extension_manager_init(). */
-kaa_error_t kaa_bootstrap_manager_create(kaa_bootstrap_manager_t **bootstrap_manager_p, kaa_context_t *kaa_context)
-{
- KAA_RETURN_IF_NIL2(bootstrap_manager_p, kaa_context, KAA_ERR_BADPARAM);
-
- *bootstrap_manager_p = (kaa_bootstrap_manager_t*) KAA_CALLOC(1, sizeof(kaa_bootstrap_manager_t));
- KAA_RETURN_IF_NIL(*bootstrap_manager_p, KAA_ERR_NOMEM);
-
- (*bootstrap_manager_p)->channel_manager = kaa_context->channel_manager;
- (*bootstrap_manager_p)->logger = kaa_context->logger;
- (*bootstrap_manager_p)->kaa_context = kaa_context;
-
- (*bootstrap_manager_p)->bootstrap_access_points = kaa_list_create();
- KAA_RETURN_IF_NIL((*bootstrap_manager_p)->bootstrap_access_points, KAA_ERR_NOMEM);
-
- (*bootstrap_manager_p)->operations_access_points = kaa_list_create();
- KAA_RETURN_IF_NIL((*bootstrap_manager_p)->operations_access_points, KAA_ERR_NOMEM);
-
- return KAA_ERR_NONE;
-}
-
-/** @deprecated Use kaa_extension_manager_deinit(). */
-void kaa_bootstrap_manager_destroy(kaa_bootstrap_manager_t *self)
-{
- KAA_RETURN_IF_NIL(self,);
- kaa_list_destroy(self->bootstrap_access_points, NULL);
- kaa_list_destroy(self->operations_access_points, destroy_operations_access_points);
- KAA_FREE(self);
-}
-
-
-static kaa_error_t kaa_bootstrap_manager_schedule_failover(kaa_bootstrap_manager_t *self, kaa_access_point_t* current_access_point, kaa_access_point_t* next_access_point,
- kaa_transport_protocol_id_t *protocol_id, kaa_server_type_t type, kaa_failover_reason reason)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
- kaa_failover_decision_t decision = kaa_failover_strategy_on_failover(self->kaa_context->failover_strategy, reason);
- switch (decision.action) {
- case KAA_NOOP:
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Nothing to be done...");
- return KAA_ERR_NONE;
- case KAA_RETRY:
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to retry in %u seconds...", decision.retry_period);
- self->failover_meta_info.acess_point = current_access_point;
- break;
- case KAA_USE_NEXT_BOOTSTRAP:
- case KAA_USE_NEXT_OPERATIONS:
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to retry with another access point in %u seconds...", decision.retry_period);
- self->failover_meta_info.acess_point = next_access_point;
- break;
- case KAA_STOP_APP:
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Stopping SDK according to the failover strategy...");
- return KAA_ERR_SDK_STOP;
- }
- self->failover_meta_info.next_execution_time = KAA_TIME() + decision.retry_period;
- self->failover_meta_info.server = type;
- if (protocol_id) {
- self->failover_meta_info.protocol_id = *protocol_id;
- }
- self->failover_meta_info.reason = reason;
- self->failover_meta_info.is_failover = true;
-
- return KAA_ERR_NONE;
-}
-
-kaa_access_point_t *kaa_bootstrap_manager_get_operations_access_point(kaa_bootstrap_manager_t *self
- , kaa_transport_protocol_id_t *protocol_id)
-{
- KAA_RETURN_IF_NIL2(self, protocol_id, NULL);
-
- kaa_list_node_t *operations_access_points_it = kaa_list_find_next(kaa_list_begin(self->operations_access_points)
- , &find_operations_access_points
- , protocol_id);
- KAA_RETURN_IF_NIL(operations_access_points_it, NULL);
-
- kaa_operations_access_points_t *operations_access_points =
- (kaa_operations_access_points_t *)kaa_list_get_data(operations_access_points_it);
- return (kaa_access_point_t *)kaa_list_get_data(operations_access_points->current_access_points);
-}
-
-static kaa_error_t get_next_bootstrap_access_point_index(kaa_transport_protocol_id_t *protocol_id
- , size_t index_from
- , size_t *next_index, bool *execute_failover)
-{
- KAA_RETURN_IF_NIL4(protocol_id, next_index, execute_failover, KAA_BOOTSTRAP_ACCESS_POINT_COUNT, KAA_ERR_BADPARAM);
-
- size_t i = index_from;
- if (index_from < KAA_BOOTSTRAP_ACCESS_POINT_COUNT) {
- for (; i < KAA_BOOTSTRAP_ACCESS_POINT_COUNT; ++i) {
- if (kaa_transport_protocol_id_equals(&(KAA_BOOTSTRAP_ACCESS_POINTS[i].protocol_id), protocol_id)) {
- *next_index = i;
- return KAA_ERR_NONE;
- }
- }
- }
- i = 0; // from the beginning
- for (; i < KAA_BOOTSTRAP_ACCESS_POINT_COUNT; ++i) {
- if (kaa_transport_protocol_id_equals(&(KAA_BOOTSTRAP_ACCESS_POINTS[i].protocol_id), protocol_id)) {
- *next_index = i;
- *execute_failover = true; //execute failover
- return KAA_ERR_NONE;
- }
- }
-
- return KAA_ERR_NOT_FOUND;
-}
-
-static kaa_error_t add_bootstrap_access_point(kaa_bootstrap_manager_t *self
- , size_t index)
-{
- if (index >= KAA_BOOTSTRAP_ACCESS_POINT_COUNT)
- return KAA_ERR_BADDATA;
-
- kaa_bootstrap_access_points_t *bootstrap_access_point =
- (kaa_bootstrap_access_points_t *)KAA_MALLOC(sizeof(kaa_bootstrap_access_points_t));
- KAA_RETURN_IF_NIL(bootstrap_access_point, KAA_ERR_NOMEM);
-
- bootstrap_access_point->protocol_id = KAA_BOOTSTRAP_ACCESS_POINTS[index].protocol_id;
- bootstrap_access_point->index = index;
-
- kaa_list_node_t *bootstrap_access_point_it = kaa_list_push_front(self->bootstrap_access_points, bootstrap_access_point);
- if (!bootstrap_access_point_it) {
- KAA_FREE(bootstrap_access_point);
- KAA_LOG_ERROR(self->logger, KAA_ERR_NOMEM, "Failed to allocate memory for Bootstrap access point info");
- return KAA_ERR_NOMEM;
- }
-
- return KAA_ERR_NONE;
-}
-
-kaa_access_point_t *kaa_bootstrap_manager_get_bootstrap_access_point(kaa_bootstrap_manager_t *self
- , kaa_transport_protocol_id_t *protocol_id)
-{
- KAA_RETURN_IF_NIL2(self, protocol_id, NULL);
-
- kaa_list_node_t *bootstrap_access_points_it = kaa_list_find_next(kaa_list_begin(self->bootstrap_access_points)
- , &find_bootstrap_access_points
- , protocol_id);
-
- size_t index;
- bool execute_failover = false;
-
- if (bootstrap_access_points_it) {
- index = ((kaa_bootstrap_access_points_t *)kaa_list_get_data(bootstrap_access_points_it))->index;
- } else {
- kaa_error_t error_code = get_next_bootstrap_access_point_index(protocol_id, 0, &index, &execute_failover);
- if (error_code) {
- KAA_LOG_FATAL(self->logger, error_code, "Error: No bootstrap services been found. Please regenerate SDK.");
- return NULL;
- }
-
- error_code = add_bootstrap_access_point(self, index);
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to add Bootstrap access point index"
- "(protocol: id=0x%08X, version=%u)", protocol_id->id, protocol_id->version);
- return NULL;
- }
- }
-
- return (kaa_access_point_t *)&(KAA_BOOTSTRAP_ACCESS_POINTS[index].access_point);
-}
-
-kaa_error_t kaa_bootstrap_manager_handle_server_sync(kaa_bootstrap_manager_t *self
- , kaa_platform_message_reader_t *reader
- , uint16_t extension_options
- , size_t extension_length)
-{
- // Only used for logging
- (void)extension_options;
- (void)extension_length;
-
- KAA_RETURN_IF_NIL2(self, reader, KAA_ERR_BADPARAM);
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received bootstrap service sync: options %u, payload size %u", extension_options, extension_length);
-
- kaa_list_clear(self->operations_access_points, destroy_operations_access_points);
-
-
- uint16_t request_id;
- kaa_error_t error_code = kaa_platform_message_read(reader, &request_id, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
- request_id = KAA_NTOHS(request_id);
-
- uint16_t access_point_count;
- error_code = kaa_platform_message_read(reader, &access_point_count, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
- access_point_count = KAA_NTOHS(access_point_count);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received %u access points (request_id %u)"
- , access_point_count, request_id);
-
- if (!access_point_count) {
- kaa_transport_channel_interface_t *channel = kaa_channel_manager_get_transport_channel(self->channel_manager, KAA_EXTENSION_BOOTSTRAP);
- kaa_transport_protocol_id_t protocol_id = {0, 0};
- error_code = channel->get_protocol_id(channel->context, &protocol_id);
- KAA_RETURN_IF_ERR(error_code);
- kaa_access_point_t *acc_point = kaa_bootstrap_manager_get_bootstrap_access_point(self, &protocol_id);
-
- if (!acc_point) {
- return KAA_ERR_SDK_STOP;
- }
-
- kaa_list_node_t *bootstrap_access_points_it = kaa_list_find_next(kaa_list_begin(self->bootstrap_access_points)
- , &find_bootstrap_access_points
- , &protocol_id);
- size_t next_index = 0;
- bool execute_failover = false;
- get_next_bootstrap_access_point_index(&protocol_id, ((kaa_bootstrap_access_points_t *)
- kaa_list_get_data(bootstrap_access_points_it))->index + 1, &next_index, &execute_failover);
-
- kaa_access_point_t *next_acc_point = (kaa_access_point_t *)&(KAA_BOOTSTRAP_ACCESS_POINTS[next_index].access_point);
-
- error_code = kaa_bootstrap_manager_schedule_failover(self->kaa_context->bootstrap_manager, acc_point, next_acc_point, &protocol_id, KAA_SERVER_BOOTSTRAP, KAA_NO_OPERATION_SERVERS_RECEIVED);
- if (error_code) {
- return error_code;
- }
-
- return KAA_ERR_EVENT_NOT_ATTACHED;
- }
-
- kaa_transport_protocol_id_t protocol_id;
-
- while (access_point_count--) {
- kaa_access_point_t *new_access_point = (kaa_access_point_t *)KAA_MALLOC(sizeof(kaa_access_point_t));
- KAA_RETURN_IF_NIL(new_access_point, KAA_ERR_NOMEM);
-
- error_code = kaa_platform_message_read(reader, &new_access_point->id, sizeof(uint32_t));
- KAA_RETURN_IF_ERR(error_code);
- new_access_point->id = KAA_NTOHL(new_access_point->id);
-
- error_code = kaa_platform_message_read(reader, &protocol_id.id, sizeof(uint32_t));
- KAA_RETURN_IF_ERR(error_code);
- protocol_id.id = KAA_NTOHL(protocol_id.id);
-
- error_code = kaa_platform_message_read(reader, &protocol_id.version, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
- protocol_id.version = KAA_NTOHS(protocol_id.version);
-
- error_code = kaa_platform_message_read(reader, &new_access_point->connection_data_len, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
- new_access_point->connection_data_len = KAA_NTOHS(new_access_point->connection_data_len);
-
- new_access_point->connection_data = (char *)KAA_MALLOC(new_access_point->connection_data_len);
-
- if (!new_access_point->connection_data || !new_access_point->connection_data_len) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_NOMEM, "Failed to allocate buffer for connection data, size %u"
- , new_access_point->connection_data_len);
- destroy_access_point(new_access_point);
- return KAA_ERR_NOMEM;
- }
-
- error_code = kaa_platform_message_read_aligned(reader
- , new_access_point->connection_data
- , new_access_point->connection_data_len);
- if (error_code) {
- destroy_access_point(new_access_point);
- KAA_LOG_ERROR(self->logger, error_code, "Failed to read connection data");
- return error_code;
- }
-
- error_code = add_operations_access_point(self, &protocol_id, new_access_point);
- if (error_code) {
- destroy_access_point(new_access_point);
- KAA_LOG_WARN(self->logger, error_code, "Failed to add new access point "
- "to channel (protocol: id=0x%08X, version=%u)", protocol_id.id, protocol_id.version);
- }
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Added access point: access point id '%u', protocol id '0x%08X', protocol version '%u', connection data length '%u'"
- , new_access_point->id, protocol_id.id, protocol_id.version, new_access_point->connection_data_len);
- }
-
- kaa_bootstrap_manager_on_server_sync(self);
- self->next_operations_request_time = 0;
-
- return error_code;
-}
-
-// TODO(KAA-1089): Remove weak linkage
-__attribute__((weak))
-kaa_error_t kaa_bootstrap_manager_on_access_point_failed(kaa_bootstrap_manager_t *self,
- kaa_transport_protocol_id_t *protocol_id,
- kaa_server_type_t type,
- kaa_failover_reason reason_code)
-{
- KAA_RETURN_IF_NIL2(self, protocol_id, KAA_ERR_BADPARAM);
-
- kaa_access_point_t *access_point = NULL;
- kaa_access_point_t *prev_access_point = NULL;
- bool execute_failover = false;
-
- if (type == KAA_SERVER_BOOTSTRAP) {
- kaa_list_node_t *bootstrap_access_points_it = kaa_list_find_next(kaa_list_begin(self->bootstrap_access_points)
- , &find_bootstrap_access_points
- , protocol_id);
-
- size_t index_from = 0;
- if (bootstrap_access_points_it)
- index_from = ((kaa_bootstrap_access_points_t *)kaa_list_get_data(bootstrap_access_points_it))->index + 1;
-
- prev_access_point = (kaa_access_point_t *)&(KAA_BOOTSTRAP_ACCESS_POINTS[index_from].access_point);
- size_t next_index = 0;
- kaa_error_t error_code = get_next_bootstrap_access_point_index(protocol_id, index_from, &next_index, &execute_failover);
-
- if (error_code) {
- KAA_LOG_FATAL(self->logger, error_code, "Error: No bootstrap services been found. Please regenerate SDK.");
- return KAA_ERR_SDK_STOP;
- }
-
- access_point = (kaa_access_point_t *)&(KAA_BOOTSTRAP_ACCESS_POINTS[next_index].access_point);
-
- if (bootstrap_access_points_it){
- ((kaa_bootstrap_access_points_t *)kaa_list_get_data(bootstrap_access_points_it))->index = next_index;
- } else {
- error_code = add_bootstrap_access_point(self, next_index);
- KAA_RETURN_IF_ERR(error_code);
- }
- } else {
- kaa_list_node_t *operations_access_points_it = kaa_list_find_next(kaa_list_begin(self->operations_access_points)
- , &find_operations_access_points
- , protocol_id);
- KAA_RETURN_IF_NIL(operations_access_points_it, KAA_ERR_NOT_FOUND);
-
- kaa_operations_access_points_t *operations_access_points =
- (kaa_operations_access_points_t *)kaa_list_get_data(operations_access_points_it);
- if (kaa_list_get_data(operations_access_points->current_access_points)) {
- prev_access_point = (kaa_access_point_t *)kaa_list_get_data(operations_access_points->current_access_points);
- }
- operations_access_points->current_access_points =
- kaa_list_next(operations_access_points->current_access_points);
-
- access_point = (kaa_access_point_t *)kaa_list_get_data(operations_access_points->current_access_points);
-
- if (!access_point)
- execute_failover = true;
- }
-
- if (execute_failover) {
- kaa_error_t error_code = kaa_bootstrap_manager_schedule_failover(self, prev_access_point, access_point, protocol_id,
- type, reason_code);
-
- if (error_code) {
- return error_code;
- }
- }
-
- if (access_point && !execute_failover) {
- kaa_channel_manager_on_new_access_point(self->channel_manager
- , protocol_id
- , type
- , access_point);
- return KAA_ERR_EVENT_NOT_ATTACHED;
- } else if (type == KAA_SERVER_OPERATIONS) {
- KAA_LOG_WARN(self->logger, KAA_ERR_NOT_FOUND, "Could not find next Operations access point "
- "(protocol: id=0x%08X, version=%u)"
- , protocol_id->id, protocol_id->version);
- } else if (type == KAA_SERVER_BOOTSTRAP) {
- KAA_LOG_WARN(self->logger, KAA_ERR_NOT_FOUND, "Could not find next Bootstrap access point "
- "(protocol: id=0x%08X, version=%u)"
- , protocol_id->id, protocol_id->version);
- }
-
- return KAA_ERR_NOT_FOUND;
-}
-
-bool kaa_bootstrap_manager_process_failover(kaa_bootstrap_manager_t *self)
-{
- KAA_RETURN_IF_NIL2(self, self->kaa_context->failover_strategy, false);
-
- kaa_failover_decision_t decision = kaa_failover_strategy_on_failover(self->kaa_context->failover_strategy, self->failover_meta_info.reason);
- if (decision.action == KAA_NOOP) {
- return false;
- }
- kaa_error_t error_code = KAA_ERR_NONE;
- kaa_time_t current_time = KAA_TIME();
- if (!self->failover_meta_info.is_failover) {
- if (self->next_operations_request_time && current_time >= self->next_operations_request_time) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Response bootstrap time expired.");
- kaa_bootstrap_access_points_t * acc_point = (kaa_bootstrap_access_points_t *) kaa_list_get_data(kaa_list_begin(self->bootstrap_access_points));
- error_code = kaa_bootstrap_manager_on_access_point_failed(self, &acc_point->protocol_id, KAA_SERVER_BOOTSTRAP, KAA_BOOTSTRAP_SERVERS_NA);
- self->next_operations_request_time = 0;
- if (error_code == KAA_ERR_EVENT_NOT_ATTACHED) {
- do_sync(self);
- return false;
- }
- return true;
- } else {
- return false;
- }
- }
-
- if (current_time >= self->failover_meta_info.next_execution_time) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Executing failover strategy...");
- switch (self->failover_meta_info.server) {
- case KAA_SERVER_BOOTSTRAP:
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Processing failover of bootstraps");
- if (decision.action == KAA_RETRY) {
- error_code = do_sync(self);
- } else {
- kaa_channel_manager_on_new_access_point(self->channel_manager, &self->failover_meta_info.protocol_id, self->failover_meta_info.server, self->failover_meta_info.acess_point);
- }
- break;
- case KAA_SERVER_OPERATIONS: {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Processing failover of operations");
- if (decision.action == KAA_RETRY) {
- kaa_channel_manager_on_new_access_point(self->channel_manager, &self->failover_meta_info.protocol_id, self->failover_meta_info.server, self->failover_meta_info.acess_point);
- } else {
- error_code = do_sync(self);
- }
- if (error_code) {
- KAA_LOG_WARN(self->logger, KAA_ERR_NONE, "Failed to connect to bootstrap");
- }
- break;
- }
- default:
- KAA_LOG_ERROR(self->logger, KAA_ERR_BADDATA, "Failed to execute failover strategy: unknown server type");
- break;
- }
- self->failover_meta_info.is_failover = false;
- }
-
- return true;
-}
-
-kaa_error_t kaa_bootstrap_manager_bootstrap_request_serialize(kaa_bootstrap_manager_t *self, kaa_platform_message_writer_t* writer)
-{
- KAA_RETURN_IF_NIL2(self, writer, KAA_ERR_BADPARAM);
- self->next_operations_request_time = KAA_TIME() + KAA_BOOTSTRAP_RESPONSE_PERIOD;
- return kaa_channel_manager_bootstrap_request_serialize(self->channel_manager, writer);
-}
diff --git a/client/client-multi/client-c/src/extensions/bootstrap/kaa_bootstrap_manager.h b/client/client-multi/client-c/src/extensions/bootstrap/kaa_bootstrap_manager.h
deleted file mode 100644
index e12298ecac..0000000000
--- a/client/client-multi/client-c/src/extensions/bootstrap/kaa_bootstrap_manager.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file
- * @brief Management of the Operations servers connection parameters.
- *
- * Manages connection parameters to Operations servers that are received from Bootstrap servers.
- */
-
-#ifndef KAA_BOOTSTRAP_MANAGER_H_
-#define KAA_BOOTSTRAP_MANAGER_H_
-
-#include
-#include "kaa_error.h"
-#include "kaa_common.h"
-#include "platform/ext_kaa_failover_strategy.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#ifndef KAA_BOOTSTRAP_MANAGER_T
-# define KAA_BOOTSTRAP_MANAGER_T
-typedef struct kaa_bootstrap_manager_t kaa_bootstrap_manager_t;
-#endif
-
-
-
-typedef enum {
- KAA_SERVER_BOOTSTRAP = 0,
- KAA_SERVER_OPERATIONS = 1
-} kaa_server_type_t;
-
-
-
-/**
- * @brief Notifies some error has occurred while using an access point.
- *
- * @param[in] self Bootstrap manager.
- * @param[in] protocol_id Transport protocol id that failed access point belongs to.
- * @param[in] type Server type that failed access point belongs to.
- * @param[in] reason_code The reason of failure.
- * @return Error code.
- *
- * @see kaa_transport_protocol_id_t
- */
-kaa_error_t kaa_bootstrap_manager_on_access_point_failed(kaa_bootstrap_manager_t *self,
- kaa_transport_protocol_id_t *protocol_id,
- kaa_server_type_t type,
- kaa_failover_reason reason_code);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* KAA_BOOTSTRAP_MANAGER_H_ */
diff --git a/client/client-multi/client-c/src/extensions/bootstrap/test/test_kaa_bootstrap_manager.c b/client/client-multi/client-c/src/extensions/bootstrap/test/test_kaa_bootstrap_manager.c
deleted file mode 100644
index 7d7596aa1e..0000000000
--- a/client/client-multi/client-c/src/extensions/bootstrap/test/test_kaa_bootstrap_manager.c
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "kaa_test.h"
-
-#include "kaa_context.h"
-#include "kaa_defaults.h"
-#include "kaa_bootstrap_manager.h"
-#include "kaa_channel_manager.h"
-#include "utilities/kaa_log.h"
-#include "utilities/kaa_mem.h"
-#include "kaa_platform_common.h"
-#include "kaa_platform_protocol.h"
-#include "kaa_platform_utils.h"
-#include "platform/ext_transport_channel.h"
-#include "platform/sock.h"
-
-#include "kaa_private.h"
-
-typedef struct {
- kaa_transport_protocol_id_t protocol_info;
- kaa_access_point_t *access_point;
- kaa_extension_id* services;
- size_t services_count;
- kaa_transport_context_t transport_context;
-} test_channel_context_t;
-
-
-
-static kaa_context_t kaa_context;
-static kaa_logger_t *logger = NULL;
-static kaa_channel_manager_t *channel_manager = NULL;
-
-static kaa_extension_id SUPPORTED_SERVICES[] = { KAA_EXTENSION_PROFILE
- , KAA_EXTENSION_USER
- , KAA_EXTENSION_EVENT
- , KAA_EXTENSION_LOGGING };
-
-static size_t SUPPORTED_SERVICES_COUNT = sizeof(SUPPORTED_SERVICES) / sizeof(kaa_extension_id);
-
-
-
-static kaa_error_t test_init_channel(void *channel_context
- , kaa_transport_context_t *transport_context)
-{
- KAA_RETURN_IF_NIL2(channel_context, transport_context, KAA_ERR_BADPARAM);
-
- ((test_channel_context_t *)channel_context)->transport_context = *transport_context;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t test_set_access_point(void *context
- , kaa_access_point_t *access_point)
-{
- KAA_RETURN_IF_NIL2(context, access_point, KAA_ERR_BADPARAM);
- test_channel_context_t *channel_context = (test_channel_context_t *)context;
- channel_context->access_point = access_point;
-
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t test_get_protocol_info(void *context, kaa_transport_protocol_id_t *protocol_info)
-{
- KAA_RETURN_IF_NIL2(context, protocol_info, KAA_ERR_BADPARAM);
-
- test_channel_context_t *channel_context = (test_channel_context_t *)context;
- *protocol_info = channel_context->protocol_info;
-
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t test_get_supported_services(void *context
- , kaa_extension_id **supported_services
- , size_t *service_count)
-{
- KAA_RETURN_IF_NIL3(context, supported_services, service_count, KAA_ERR_BADPARAM);
-
- test_channel_context_t *channel_context = (test_channel_context_t *)context;
- *supported_services = channel_context->services;
- *service_count = channel_context->services_count;
-
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t test_sync_handler(void *context
- , const kaa_extension_id services[]
- , size_t service_count)
-{
- KAA_RETURN_IF_NIL3(context, services, service_count, KAA_ERR_BADPARAM);
- return KAA_ERR_NONE;
-}
-
-static void test_create_channel_interface(kaa_transport_channel_interface_t *channel
- , test_channel_context_t *context)
-{
- channel->context = context;
- channel->get_protocol_id = &test_get_protocol_info;
- channel->get_supported_services = &test_get_supported_services;
- channel->sync_handler = &test_sync_handler;
- channel->destroy = NULL;
- channel->init = &test_init_channel;
- channel->set_access_point = &test_set_access_point;
-}
-
-
-
-void test_create_bootstrap_manager(void **state)
-{
- (void)state;
-
- kaa_error_t error_code;
- kaa_bootstrap_manager_t* manager = NULL;
-
- error_code = kaa_bootstrap_manager_create(NULL, &kaa_context);
- ASSERT_NOT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_bootstrap_manager_create(&manager, NULL);
- ASSERT_NOT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_bootstrap_manager_create(&manager, &kaa_context);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_bootstrap_manager_destroy(manager);
-}
-
-static kaa_access_point_t *create_access_point(void)
-{
- const uint16_t MAX_CONNECTION_DATA_SIZE = 16;
-
- kaa_access_point_t *access_point = (kaa_access_point_t *)KAA_MALLOC(sizeof(kaa_access_point_t));
- ASSERT_NOT_NULL(access_point);
-
- access_point->id = rand();
- access_point->connection_data_len = 1 + rand() % MAX_CONNECTION_DATA_SIZE;
- access_point->connection_data = (char *)KAA_MALLOC(access_point->connection_data_len);
-
- ASSERT_NOT_NULL(access_point->connection_data);
-
- return access_point;
-}
-
-static void destroy_access_point(kaa_access_point_t * access_point)
-{
- if (access_point) {
- if (access_point->connection_data) {
- KAA_FREE(access_point->connection_data);
- }
- KAA_FREE(access_point);
- }
-}
-
-void test_handle_server_sync(void **state)
-{
- (void)state;
-
- kaa_error_t error_code;
- kaa_bootstrap_manager_t *bootstrap_manager = NULL;
-
-
- error_code = kaa_bootstrap_manager_create(&bootstrap_manager, &kaa_context);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_context.bootstrap_manager = bootstrap_manager;
- /**
- * TEST DATA
- */
- kaa_transport_protocol_id_t protocol1 = { 1, 1 };
- kaa_transport_protocol_id_t protocol2 = { 2, 1 };
- kaa_transport_protocol_id_t protocol3 = { 465, 564 };
-
- test_channel_context_t protocol1_channel_context = { protocol1, NULL, SUPPORTED_SERVICES,
- SUPPORTED_SERVICES_COUNT, {NULL} };
- kaa_transport_channel_interface_t protocol1_channel;
- test_create_channel_interface(&protocol1_channel, &protocol1_channel_context);
-
- test_channel_context_t protocol2_channel_context = { protocol2, NULL, SUPPORTED_SERVICES,
- SUPPORTED_SERVICES_COUNT, {NULL} };
- kaa_transport_channel_interface_t protocol2_channel;
- test_create_channel_interface(&protocol2_channel, &protocol2_channel_context);
-
- test_channel_context_t protocol3_channel_context = { protocol3, NULL, SUPPORTED_SERVICES,
- SUPPORTED_SERVICES_COUNT, {NULL} };
- kaa_transport_channel_interface_t protocol3_channel;
- test_create_channel_interface(&protocol3_channel, &protocol3_channel_context);
-
- uint32_t protocol1_channel_id;
- error_code = kaa_channel_manager_add_transport_channel(channel_manager
- , &protocol1_channel
- , &protocol1_channel_id);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint32_t protocol3_channel_id;
- error_code = kaa_channel_manager_add_transport_channel(channel_manager
- , &protocol3_channel
- , &protocol3_channel_id);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint16_t server_sync_payload_size = 0;
-
- size_t access_point_count = 0;
- kaa_access_point_t *access_point1_protocol1 = create_access_point();
- ASSERT_NOT_NULL(access_point1_protocol1);
- ++access_point_count;
- server_sync_payload_size += kaa_aligned_size_get(access_point1_protocol1->connection_data_len);
-
- kaa_access_point_t *access_point2_protocol1 = create_access_point();
- ASSERT_NOT_NULL(access_point2_protocol1);
- ++access_point_count;
- server_sync_payload_size += kaa_aligned_size_get(access_point2_protocol1->connection_data_len);
-
- kaa_access_point_t *access_point1_protocol2 = create_access_point();
- ASSERT_NOT_NULL(access_point1_protocol2);
- ++access_point_count;
- server_sync_payload_size += kaa_aligned_size_get(access_point1_protocol2->connection_data_len);
-
- server_sync_payload_size += sizeof(uint16_t)
- + sizeof(uint16_t)
- + access_point_count * (sizeof(uint32_t)
- + sizeof(uint32_t)
- + sizeof(uint16_t)
- + sizeof(uint16_t));
-
- /**
- * SERIALIZE TEST DATA
- */
- char server_sync_buffer[server_sync_payload_size];
- kaa_platform_message_writer_t *writer;
- error_code = kaa_platform_message_writer_create(&writer, server_sync_buffer, server_sync_payload_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint16_t network_order_16 = 0xAEF5;
- uint32_t network_order_32 = 0xEAFC5370;
-
- // request id
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- network_order_16 = KAA_HTONS(access_point_count);
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- /**
- * DO NOT CHANGE ELEMENT ORDER IN NEXT TWO ARRAYS
- */
- kaa_access_point_t *access_points[] = { access_point1_protocol1
- , access_point2_protocol1
- , access_point1_protocol2 };
-
- kaa_transport_protocol_id_t *protoco_infos[] = { &protocol1
- , &protocol1
- , &protocol2 };
-
- for (uint16_t i = 0; i < access_point_count; ++i) {
- network_order_32 = KAA_HTONL(access_points[i]->id);
- error_code = kaa_platform_message_write(writer, &network_order_32, sizeof(uint32_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- network_order_32 = KAA_HTONL(protoco_infos[i]->id);
- error_code = kaa_platform_message_write(writer, &network_order_32, sizeof(uint32_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- network_order_16 = KAA_HTONS(protoco_infos[i]->version);
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- network_order_16 = KAA_HTONS(access_points[i]->connection_data_len);
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_platform_message_write_aligned(writer
- , access_points[i]->connection_data
- , access_points[i]->connection_data_len);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- }
-
- kaa_platform_message_reader_t *reader = NULL;
- error_code = kaa_platform_message_reader_create(&reader, server_sync_buffer, server_sync_payload_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- /**
- * TEST
- */
- ASSERT_NULL(protocol1_channel_context.access_point);
- ASSERT_NULL(protocol2_channel_context.access_point);
- ASSERT_NULL(protocol3_channel_context.access_point);
-
- error_code = kaa_bootstrap_manager_handle_server_sync(bootstrap_manager, reader, 0, server_sync_payload_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- ASSERT_NOT_NULL(protocol1_channel_context.access_point);
- ASSERT_EQUAL(protocol1_channel_context.access_point->id, access_point2_protocol1->id);
-
- ASSERT_NULL(protocol3_channel_context.access_point);
-
- uint32_t protocol2_channel_id;
- error_code = kaa_channel_manager_add_transport_channel(channel_manager
- , &protocol2_channel
- , &protocol2_channel_id);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_NOT_NULL(protocol2_channel_context.access_point);
- ASSERT_EQUAL(protocol2_channel_context.access_point->id, access_point1_protocol2->id);
-
- ASSERT_NOT_NULL(protocol1_channel_context.transport_context.kaa_context);
- ASSERT_NOT_NULL(protocol1_channel_context.transport_context.kaa_context->bootstrap_manager);
- error_code = kaa_bootstrap_manager_on_access_point_failed(protocol1_channel_context.transport_context.kaa_context->bootstrap_manager
- , &protocol1_channel_context.protocol_info
- , KAA_SERVER_OPERATIONS);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_NOT_NULL(protocol1_channel_context.access_point);
- ASSERT_EQUAL(protocol1_channel_context.access_point->id, access_point1_protocol1->id);
-
- error_code = kaa_bootstrap_manager_on_access_point_failed(protocol1_channel_context.transport_context.kaa_context->bootstrap_manager
- , &protocol1_channel_context.protocol_info
- , KAA_SERVER_OPERATIONS);
- ASSERT_EQUAL(error_code, KAA_ERR_NOT_FOUND);
-
- /**
- * CLEAN UP
- */
- destroy_access_point(access_point1_protocol1);
- destroy_access_point(access_point1_protocol2);
- destroy_access_point(access_point2_protocol1);
- kaa_channel_manager_remove_transport_channel(channel_manager, protocol1_channel_id);
- kaa_channel_manager_remove_transport_channel(channel_manager, protocol2_channel_id);
- kaa_channel_manager_remove_transport_channel(channel_manager, protocol3_channel_id);
- kaa_platform_message_reader_destroy(reader);
- kaa_platform_message_writer_destroy(writer);
- kaa_bootstrap_manager_destroy(bootstrap_manager);
- kaa_context.bootstrap_manager = NULL;
-}
-
-
-
-#if KAA_BOOTSTRAP_ACCESS_POINT_COUNT > 0
-
-static kaa_error_t find_bootstrap_access_point_index(kaa_transport_protocol_id_t *id
- , size_t index_from
- , size_t *access_point_index)
-{
- KAA_RETURN_IF_NIL2(id, access_point_index, KAA_ERR_BADDATA);
-
- if (index_from < KAA_BOOTSTRAP_ACCESS_POINT_COUNT) {
- for (size_t i = index_from; i < KAA_BOOTSTRAP_ACCESS_POINT_COUNT; ++i) {
- if (0 == memcmp(id, &(KAA_BOOTSTRAP_ACCESS_POINTS[i].protocol_id), sizeof(kaa_transport_protocol_id_t))) {
- *access_point_index = i;
- return KAA_ERR_NONE;
- }
- }
- }
-
- return KAA_ERR_NOT_FOUND;
-}
-
-void test_bootstrap_channel(void **state)
-{
- (void)state;
-
- kaa_error_t error_code;
- kaa_bootstrap_manager_t *bootstrap_manager = NULL;
-
-
- error_code = kaa_bootstrap_manager_create(&bootstrap_manager, &kaa_context);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_context.bootstrap_manager = bootstrap_manager;
-
- /**
- * TEST DATA
- */
- size_t index = rand() % KAA_BOOTSTRAP_ACCESS_POINT_COUNT;
- kaa_extension_id bootstrap_service[] = { KAA_EXTENSION_BOOTSTRAP };
-
- test_channel_context_t bootstrap_channel_context = { KAA_BOOTSTRAP_ACCESS_POINTS[index].protocol_id
- , NULL
- , bootstrap_service
- , 1
- , {NULL} };
- kaa_transport_channel_interface_t bootstrap_channel;
- test_create_channel_interface(&bootstrap_channel, &bootstrap_channel_context);
-
- uint32_t bootstrap_channel_id;
- error_code = kaa_channel_manager_add_transport_channel(channel_manager
- , &bootstrap_channel
- , &bootstrap_channel_id);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- size_t expected_index;
- error_code = find_bootstrap_access_point_index((kaa_transport_protocol_id_t *)&(KAA_BOOTSTRAP_ACCESS_POINTS[index].protocol_id)
- , 0
- , &expected_index);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- ASSERT_NOT_NULL(bootstrap_channel_context.access_point);
- ASSERT_EQUAL(bootstrap_channel_context.access_point->connection_data_len
- , KAA_BOOTSTRAP_ACCESS_POINTS[expected_index].access_point.connection_data_len);
- ASSERT_EQUAL(0, memcmp(bootstrap_channel_context.access_point->connection_data
- , KAA_BOOTSTRAP_ACCESS_POINTS[expected_index].access_point.connection_data
- , bootstrap_channel_context.access_point->connection_data_len));
-
-
-#if KAA_BOOTSTRAP_ACCESS_POINT_COUNT > 1
- error_code = find_bootstrap_access_point_index((kaa_transport_protocol_id_t *)&(KAA_BOOTSTRAP_ACCESS_POINTS[index].protocol_id)
- , expected_index + 1
- , &expected_index);
-
- if (!error_code) {
- error_code = kaa_bootstrap_manager_on_access_point_failed(bootstrap_manager
- , (kaa_transport_protocol_id_t *)&(KAA_BOOTSTRAP_ACCESS_POINTS[index].protocol_id)
- , KAA_SERVER_BOOTSTRAP);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- ASSERT_NOT_NULL(bootstrap_channel_context.access_point);
- ASSERT_EQUAL(bootstrap_channel_context.access_point->connection_data_len
- , KAA_BOOTSTRAP_ACCESS_POINTS[expected_index].access_point.connection_data_len);
- ASSERT_EQUAL(0, memcmp(bootstrap_channel_context.access_point->connection_data
- , KAA_BOOTSTRAP_ACCESS_POINTS[expected_index].access_point.connection_data
- , bootstrap_channel_context.access_point->connection_data_len));
- }
-#endif
-
- error_code = kaa_bootstrap_manager_on_access_point_failed(bootstrap_manager
- , (kaa_transport_protocol_id_t *)&(KAA_BOOTSTRAP_ACCESS_POINTS[index].protocol_id)
- , KAA_SERVER_BOOTSTRAP);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_bootstrap_manager_destroy(bootstrap_manager);
- kaa_context.bootstrap_manager = NULL;
-}
-#endif
-
-int test_init(void)
-{
- srand(time(NULL));
-
- kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
- if (error || !logger)
- return error;
-
- kaa_context.logger = logger;
- kaa_context.platform_protocol = NULL;
- kaa_context.bootstrap_manager = NULL;
-
- error = kaa_channel_manager_create(&channel_manager, &kaa_context);
- if (error || !channel_manager)
- return error;
-
- return 0;
-}
-
-int test_deinit(void)
-{
- kaa_channel_manager_destroy(channel_manager);
- kaa_log_destroy(logger);
-
- return 0;
-}
-
-
-#if KAA_BOOTSTRAP_ACCESS_POINT > 0
-KAA_SUITE_MAIN(Bootstrap, test_init, test_deinit,
- KAA_TEST_CASE(create_bootstrap_manager, test_create_bootstrap_manager)
- KAA_TEST_CASE(handle_server_sync, test_handle_server_sync)
- KAA_TEST_CASE(test_bootstrap_channel, test_bootstrap_channel)
-)
-#else
-KAA_SUITE_MAIN(Bootstrap, test_init, test_deinit,
- KAA_TEST_CASE(create_bootstrap_manager, test_create_bootstrap_manager)
- KAA_TEST_CASE(handle_server_sync, test_handle_server_sync)
-)
-#endif
-
diff --git a/client/client-multi/client-c/src/extensions/configuration/CMakeLists.txt b/client/client-multi/client-c/src/extensions/configuration/CMakeLists.txt
deleted file mode 100644
index 351fe2ce48..0000000000
--- a/client/client-multi/client-c/src/extensions/configuration/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set(EXTENSION_CONFIGURATION_SOURCE_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_configuration_manager.c)
-
-set(EXTENSION_CONFIGURATION_HEADER_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_configuration_manager.h)
-
-add_library(extension_configuration ${EXTENSION_CONFIGURATION_SOURCE_FILES})
-target_include_directories(extension_configuration PUBLIC ${CMAKE_CURRENT_LIST_DIR})
-target_link_libraries(extension_configuration PUBLIC kaac)
-
-kaa_add_unit_test(NAME test_kaa_configuration_manager
- SOURCES
- ${CMAKE_CURRENT_LIST_DIR}/test/test_kaa_configuration.c
- ${KAA_SRC_FOLDER}/platform-impl/common/kaa_failover_strategy.c
- test/kaa_test_external.c
- DEPENDS
- kaac extension_configuration)
diff --git a/client/client-multi/client-c/src/extensions/configuration/kaa_configuration_manager.c b/client/client-multi/client-c/src/extensions/configuration/kaa_configuration_manager.c
deleted file mode 100644
index 6d127fe0c9..0000000000
--- a/client/client-multi/client-c/src/extensions/configuration/kaa_configuration_manager.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_configuration_manager_private.h"
-#include "kaa_configuration_manager.h"
-
-#include "kaa_private.h"
-
-#include
-#include
-#include
-#include
-#include "platform/stdio.h"
-#include "platform/sock.h"
-
-#include "platform/ext_sha.h"
-#include "platform/ext_configuration_persistence.h"
-#include "collections/kaa_list.h"
-#include "kaa_common.h"
-#include "kaa_status.h"
-#include "kaa_defaults.h"
-#include "kaa_platform_utils.h"
-#include "kaa_platform_common.h"
-#include "kaa_channel_manager.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-#include "avro_src/avro/io.h"
-
-#define KAA_CONFIGURATION_RECEIVE_UPDATES_FLAG 0x01
-#define KAA_CONFIGURATION_HASH_FLAG 0x02
-#define KAA_CONFIGURATION_FULL_RESYNC_FLAG 0x04
-#define KAA_CONFIGURATION_ALL_FLAGS (KAA_CONFIGURATION_RECEIVE_UPDATES_FLAG | KAA_CONFIGURATION_HASH_FLAG | KAA_CONFIGURATION_FULL_RESYNC_FLAG)
-
-
-#define KAA_CONFIGURATION_BODY_PRESENT 0x02
-
-static kaa_extension_id configuration_sync_services[1] = { KAA_EXTENSION_CONFIGURATION };
-
-struct kaa_configuration_manager_t {
- kaa_digest configuration_hash;
- kaa_configuration_root_receiver_t root_receiver;
- kaa_root_configuration_t *root_record;
- kaa_channel_manager_t *channel_manager;
- kaa_status_t *status;
- kaa_logger_t *logger;
- size_t payload_size;
-};
-
-kaa_error_t kaa_extension_configuration_init(kaa_context_t *kaa_context, void **context)
-{
- kaa_error_t result = kaa_configuration_manager_create(&kaa_context->configuration_manager,
- kaa_context->channel_manager,
- kaa_context->status->status_instance,
- kaa_context->logger);
- *context = kaa_context->configuration_manager;
- return result;
-}
-
-kaa_error_t kaa_extension_configuration_deinit(void *context)
-{
- kaa_configuration_manager_destroy(context);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_configuration_request_get_size(void *context, size_t *expected_size)
-{
- return kaa_configuration_manager_get_size(context, expected_size);
-}
-
-kaa_error_t kaa_extension_configuration_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync)
-{
- (void)request_id;
-
- // TODO(KAA-982): Use asserts
- if (!context || !size || !need_resync) {
- return KAA_ERR_BADPARAM;
- }
-
- *need_resync = true;
-
- size_t size_needed;
- kaa_error_t error = kaa_configuration_manager_get_size(context, &size_needed);
- if (error) {
- return error;
- }
-
- if (!buffer || *size < size_needed) {
- *size = size_needed;
- return KAA_ERR_BUFFER_IS_NOT_ENOUGH;
- }
-
- *size = size_needed;
-
- kaa_platform_message_writer_t writer = KAA_MESSAGE_WRITER(buffer, *size);
- error = kaa_configuration_manager_request_serialize(context, &writer);
- if (error) {
- return error;
- }
-
- *size = writer.current - buffer;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_configuration_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size)
-{
- (void)request_id;
-
- // TODO(KAA-982): Use asserts
- if (!context || !buffer) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_platform_message_reader_t reader = KAA_MESSAGE_READER(buffer, size);
- return kaa_configuration_manager_handle_server_sync(context, &reader, extension_options, size);
-}
-
-static kaa_root_configuration_t *kaa_configuration_manager_deserialize(const char *buffer, size_t buffer_size)
-{
- KAA_RETURN_IF_NIL2(buffer, buffer_size, NULL);
-
- avro_reader_t reader = avro_reader_memory(buffer, buffer_size);
- KAA_RETURN_IF_NIL(reader, NULL);
- kaa_root_configuration_t *result = KAA_CONFIGURATION_DESERIALIZE(reader);
- avro_reader_free(reader);
- return result;
-}
-
-
-/** @deprecated Use kaa_extension_configuration_init(). */
-kaa_error_t kaa_configuration_manager_create(kaa_configuration_manager_t **configuration_manager_p, kaa_channel_manager_t *channel_manager, kaa_status_t *status, kaa_logger_t *logger)
-{
- KAA_RETURN_IF_NIL3(configuration_manager_p, status, logger, KAA_ERR_BADPARAM);
- kaa_configuration_manager_t *manager = (kaa_configuration_manager_t *) KAA_MALLOC(sizeof(kaa_configuration_manager_t));
- KAA_RETURN_IF_NIL(manager, KAA_ERR_NOMEM);
-
- manager->channel_manager = channel_manager;
- manager->status = status;
- manager->logger = logger;
- manager->root_receiver = (kaa_configuration_root_receiver_t) { NULL, NULL };
-
- char *buffer = NULL;
- size_t buffer_size = 0;
- bool need_deallocation = false;
- if (status->is_updated)
- ext_configuration_read(&buffer, &buffer_size, &need_deallocation);
- else
- ext_configuration_delete();
- if (!buffer || !buffer_size) {
- need_deallocation = false;
-#if KAA_CONFIGURATION_DATA_LENGTH > 0
- buffer = (char *)KAA_CONFIGURATION_DATA;
- buffer_size = KAA_CONFIGURATION_DATA_LENGTH;
-#endif
- }
-
- if (buffer && buffer_size > 0) {
- ext_calculate_sha_hash(buffer, buffer_size, manager->configuration_hash);
- manager->root_record = kaa_configuration_manager_deserialize(buffer, buffer_size);
-
- if (!manager->root_record) {
- KAA_FREE(manager);
- if (need_deallocation && buffer)
- KAA_FREE(buffer);
- return KAA_ERR_NOMEM;
- }
-
- if (need_deallocation)
- KAA_FREE(buffer);
- }
-
- *configuration_manager_p = manager;
- return KAA_ERR_NONE;
-}
-
-
-
-/** @deprecated Use kaa_extension_configuration_deinit(). */
-void kaa_configuration_manager_destroy(kaa_configuration_manager_t *self)
-{
- if (self) {
- if (self->root_record)
- self->root_record->destroy(self->root_record);
- KAA_FREE(self);
- }
-}
-
-
-
-kaa_error_t kaa_configuration_manager_get_size(kaa_configuration_manager_t *self, size_t *expected_size)
-{
- KAA_RETURN_IF_NIL2(self, expected_size, KAA_ERR_BADPARAM);
-
- *expected_size = KAA_EXTENSION_HEADER_SIZE + SHA_1_DIGEST_LENGTH;
- self->payload_size = SHA_1_DIGEST_LENGTH;
-
- return KAA_ERR_NONE;
-}
-
-
-
-kaa_error_t kaa_configuration_manager_request_serialize(kaa_configuration_manager_t *self, kaa_platform_message_writer_t *writer)
-{
- KAA_RETURN_IF_NIL2(self, writer, KAA_ERR_BADPARAM);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize client configuration sync");
-
- kaa_platform_message_writer_t tmp_writer = *writer;
- kaa_error_t error_code = kaa_platform_message_write_extension_header(&tmp_writer, KAA_EXTENSION_CONFIGURATION, KAA_CONFIGURATION_ALL_FLAGS, self->payload_size);
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to write configuration extension header");
- return KAA_ERR_WRITE_FAILED;
- }
-
- error_code = kaa_platform_message_write_aligned(&tmp_writer, self->configuration_hash, SHA_1_DIGEST_LENGTH);
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to write configuration hash");
- return KAA_ERR_WRITE_FAILED;
- }
-
- *writer = tmp_writer;
-
- return KAA_ERR_NONE;
-}
-
-
-
-kaa_error_t kaa_configuration_manager_handle_server_sync(kaa_configuration_manager_t *self
- , kaa_platform_message_reader_t *reader
- , uint16_t extension_options
- , size_t extension_length)
-{
- KAA_RETURN_IF_NIL2(self, reader, KAA_ERR_BADPARAM);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received configuration server sync: options %u, payload size %u", extension_options, extension_length);
-
- if (extension_length >= sizeof(uint32_t)) {
- if (extension_options & KAA_CONFIGURATION_BODY_PRESENT) {
- uint32_t body_size = KAA_NTOHL(*((uint32_t *) reader->current));
- reader->current += sizeof(uint32_t);
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received configuration body, size '%u' ", body_size);
- const uint8_t *body = reader->current;
- kaa_error_t error = kaa_platform_message_skip(reader, kaa_aligned_size_get(body_size));
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read configuration body, size %u", body_size);
- return error;
- }
-
- if (self->root_record)
- self->root_record->destroy(self->root_record);
-
- self->root_record = kaa_configuration_manager_deserialize((const char *)body, body_size);
- if (!self->root_record) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_READ_FAILED, "Failed to deserialize configuration body, size %u", body_size);
- return KAA_ERR_READ_FAILED;
- }
-
- kaa_error_t err = ext_calculate_sha_hash((const char *)body, body_size, self->configuration_hash);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to calculate configuration body hash");
- return err;
- }
- ext_configuration_store((const char *)body, body_size);
-
- if (self->root_receiver.on_configuration_updated)
- self->root_receiver.on_configuration_updated(self->root_receiver.context, self->root_record);
-
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(self->channel_manager, configuration_sync_services[0]);
- if (channel)
- channel->sync_handler(channel->context, configuration_sync_services, 1);
- }
- }
- return KAA_ERR_NONE;
-}
-
-
-
-const kaa_root_configuration_t *kaa_configuration_manager_get_configuration(kaa_configuration_manager_t *self)
-{
- return self ? self->root_record : NULL;
-}
-
-
-
-kaa_error_t kaa_configuration_manager_set_root_receiver(kaa_configuration_manager_t *self, const kaa_configuration_root_receiver_t *receiver)
-{
- KAA_RETURN_IF_NIL2(self, receiver, KAA_ERR_BADPARAM);
-
- self->root_receiver = *receiver;
-
- return KAA_ERR_NONE;
-}
diff --git a/client/client-multi/client-c/src/extensions/configuration/kaa_configuration_manager.h b/client/client-multi/client-c/src/extensions/configuration/kaa_configuration_manager.h
deleted file mode 100644
index cb0597c8aa..0000000000
--- a/client/client-multi/client-c/src/extensions/configuration/kaa_configuration_manager.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef KAA_CONFIGURATION_MANAGER_H_
-#define KAA_CONFIGURATION_MANAGER_H_
-
-#include "gen/kaa_configuration_definitions.h"
-#include "platform/ext_configuration_receiver.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct kaa_configuration_manager_t;
-typedef struct kaa_configuration_manager_t kaa_configuration_manager_t;
-
-/**
- * @brief Retrieves the current configuration data.
- *
- * @param[in] self The valid pointer to @link kaa_configuration_manager_t @endlink instance.
- *
- * @return The current configuration data (NOTE: don't modify this instance), or NULL if something went wrong.
- * Don't cache this pointer, it could become invalid after the next configuration update.
- */
-const kaa_root_configuration_t *kaa_configuration_manager_get_configuration(kaa_configuration_manager_t *self);
-
-/**
- * @brief Sets the new receiver of updated configuration data. See @link kaa_configuration_root_receiver_t @endlink .
- *
- * @param[in] self The valid pointer to @link kaa_configuration_manager_t @endlink instance.
- * @param[in] receiver The new receiver instance. This callback will be called each time when the new configuration arrives.
- *
- * @return Error code.
- */
-kaa_error_t kaa_configuration_manager_set_root_receiver(kaa_configuration_manager_t *self, const kaa_configuration_root_receiver_t *receiver);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif /* KAA_CONFIGURATION_MANAGER_H_ */
diff --git a/client/client-multi/client-c/src/extensions/configuration/kaa_configuration_manager_private.h b/client/client-multi/client-c/src/extensions/configuration/kaa_configuration_manager_private.h
deleted file mode 100644
index fce721cc5b..0000000000
--- a/client/client-multi/client-c/src/extensions/configuration/kaa_configuration_manager_private.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef KAA_CONFIGURATION_MANAGER_PRIVATE_H
-#define KAA_CONFIGURATION_MANAGER_PRIVATE_H
-
-#include
-#include "kaa_configuration_manager.h"
-#include
-#include
-#include
-#include
-
-kaa_error_t kaa_configuration_manager_create(kaa_configuration_manager_t **configuration_manager_p,
- kaa_channel_manager_t *channel_manager, kaa_status_t *status, kaa_logger_t *logger);
-void kaa_configuration_manager_destroy(kaa_configuration_manager_t *self);
-kaa_error_t kaa_configuration_manager_get_size(kaa_configuration_manager_t *self, size_t *expected_size);
-kaa_error_t kaa_configuration_manager_request_serialize(kaa_configuration_manager_t *self,
- kaa_platform_message_writer_t *writer);
-kaa_error_t kaa_configuration_manager_handle_server_sync(kaa_configuration_manager_t *self, kaa_platform_message_reader_t *reader, uint16_t extension_options, size_t extension_length);
-
-#endif /* KAA_CONFIGURATION_MANAGER_PRIVATE_H */
diff --git a/client/client-multi/client-c/src/extensions/configuration/test/test_kaa_configuration.c b/client/client-multi/client-c/src/extensions/configuration/test/test_kaa_configuration.c
deleted file mode 100644
index 6d81f32b57..0000000000
--- a/client/client-multi/client-c/src/extensions/configuration/test/test_kaa_configuration.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include
-#include
-#include "kaa_configuration_manager.h"
-#include "kaa_configuration_manager_private.h"
-
-#include "platform/sock.h"
-#include "platform/ext_sha.h"
-#include "platform/ext_configuration_persistence.h"
-#include "platform/ext_configuration_receiver.h"
-#include "kaa_test.h"
-#include "kaa_platform_utils.h"
-#include "kaa_status.h"
-#include "kaa_defaults.h"
-#include "kaa_channel_manager.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-
-#include "kaa_private.h"
-
-static kaa_logger_t *logger = NULL;
-static kaa_status_t *status = NULL;
-static kaa_configuration_manager_t *config_manager = NULL;
-
-#define CONFIG_START_SEQ_N 5
-#define CONFIG_NEW_SEQ_N 6
-#define CONFIG_RESPONSE_FLAGS 0x02
-#define CONFIG_DATA_FIELD "Basic configuration schema"
-
-static const size_t CONFIG_UUID_SIZE = 16;
-static const char CONFIG_UUID[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
-
-static kaa_error_t on_configuration_updated(void *context, const kaa_root_configuration_t *configuration)
-{
- (void)configuration;
- bool *result = (bool *) context;
- *result = true;
- return KAA_ERR_NONE;
-}
-
-void test_create_request(void **state)
-{
- (void)state;
-
- size_t expected_size = 0;
- ASSERT_EQUAL(kaa_configuration_manager_get_size(config_manager, &expected_size), KAA_ERR_NONE);
- ASSERT_EQUAL(expected_size, KAA_EXTENSION_HEADER_SIZE + SHA_1_DIGEST_LENGTH);
-
- uint8_t request_buffer[expected_size];
- kaa_platform_message_writer_t *writer = NULL;
- ASSERT_EQUAL(kaa_platform_message_writer_create(&writer, request_buffer, expected_size), KAA_ERR_NONE);
- ASSERT_EQUAL(kaa_configuration_manager_request_serialize(config_manager, writer), KAA_ERR_NONE);
-
- uint8_t *cursor = writer->begin;
- ASSERT_EQUAL(KAA_HTONS(*((uint16_t *) cursor)), KAA_EXTENSION_CONFIGURATION);
- cursor += sizeof(uint32_t);
-
- ASSERT_EQUAL(KAA_NTOHL(*((uint32_t *) cursor)), SHA_1_DIGEST_LENGTH); // checking payload size
- cursor += sizeof(uint32_t);
-
- kaa_digest check_hash;
- ext_calculate_sha_hash(KAA_CONFIGURATION_DATA, KAA_CONFIGURATION_DATA_LENGTH, check_hash); // checking configuration hash
- ASSERT_EQUAL(memcmp(cursor, check_hash, SHA_1_DIGEST_LENGTH), 0);
- cursor += SHA_1_DIGEST_LENGTH;
-
- ASSERT_EQUAL(cursor, writer->end);
-
- kaa_platform_message_writer_destroy(writer);
-}
-
-void test_response(void **state)
-{
- (void)state;
- const size_t response_size = kaa_aligned_size_get(KAA_CONFIGURATION_DATA_LENGTH) + sizeof(uint32_t);
- uint8_t response[response_size];
- uint8_t *response_cursor = response;
-
- *((uint32_t *) response_cursor) = KAA_HTONL(KAA_CONFIGURATION_DATA_LENGTH);
- response_cursor += sizeof(uint32_t);
-
- memcpy(response_cursor, KAA_CONFIGURATION_DATA, KAA_CONFIGURATION_DATA_LENGTH);
-
- kaa_platform_message_reader_t *reader = NULL;
- ASSERT_EQUAL(kaa_platform_message_reader_create(&reader, response, response_size), KAA_ERR_NONE);
-
- bool is_callback_invoked = false;
- kaa_configuration_root_receiver_t receiver = { &is_callback_invoked, &on_configuration_updated };
- ASSERT_EQUAL(kaa_configuration_manager_set_root_receiver(config_manager, &receiver), KAA_ERR_NONE);
-
- ASSERT_EQUAL(kaa_configuration_manager_handle_server_sync(config_manager, reader, CONFIG_RESPONSE_FLAGS, response_size), KAA_ERR_NONE);
-
- ASSERT_EQUAL(is_callback_invoked, true);
-
- const kaa_root_configuration_t *root_config = kaa_configuration_manager_get_configuration(config_manager);
- ASSERT_EQUAL(strcmp(root_config->data->data, CONFIG_DATA_FIELD), 0);
-
- kaa_bytes_t *uuid = (kaa_bytes_t *) root_config->__uuid->data;
- ASSERT_EQUAL(uuid->size, CONFIG_UUID_SIZE);
- ASSERT_EQUAL(memcmp(uuid->buffer, CONFIG_UUID, uuid->size), 0);
-
- kaa_platform_message_reader_destroy(reader);
-}
-
-int test_init(void)
-{
- kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
- if (error || !logger) {
- return error;
- }
-
- error = kaa_status_create(&status);
- if (error || !status) {
- return error;
- }
-
- error = kaa_configuration_manager_create(&config_manager, NULL, status, logger);
- if (error || config_manager) {
- return error;
- }
-
- return 0;
-}
-
-int test_deinit(void)
-{
- kaa_status_destroy(status);
- kaa_configuration_manager_destroy(config_manager);
- kaa_log_destroy(logger);
- return 0;
-}
-
-KAA_SUITE_MAIN(Log, test_init, test_deinit,
- KAA_TEST_CASE(create_request, test_create_request)
- KAA_TEST_CASE(process_response, test_response))
diff --git a/client/client-multi/client-c/src/extensions/event/CMakeLists.txt b/client/client-multi/client-c/src/extensions/event/CMakeLists.txt
deleted file mode 100644
index 87746c1141..0000000000
--- a/client/client-multi/client-c/src/extensions/event/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set(EXTENSION_EVENT_SOURCE_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_event.c)
-
-set(EXTENSION_EVENT_HEADER_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_event.h)
-
-add_library(extension_event ${EXTENSION_EVENT_SOURCE_FILES})
-target_include_directories(extension_event PUBLIC ${CMAKE_CURRENT_LIST_DIR})
-target_link_libraries(extension_event PUBLIC kaac)
-
-kaa_add_unit_test(NAME test_event
- SOURCES
- ${CMAKE_CURRENT_LIST_DIR}/test/test_kaa_event.c
- test/kaa_test_external.c
- DEPENDS
- kaac)
diff --git a/client/client-multi/client-c/src/extensions/event/kaa_event.c b/client/client-multi/client-c/src/extensions/event/kaa_event.c
deleted file mode 100644
index b4b870fd6e..0000000000
--- a/client/client-multi/client-c/src/extensions/event/kaa_event.c
+++ /dev/null
@@ -1,1203 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_event.h"
-#include "kaa_event_private.h"
-
-#include "kaa_private.h"
-
-#include
-#include
-#include
-#include
-#include
-#include "platform/stdio.h"
-#include "platform/sock.h"
-#include "platform/ext_sha.h"
-#include "kaa_status.h"
-#include "kaa_channel_manager.h"
-#include "kaa_platform_utils.h"
-#include "kaa_platform_common.h"
-#include "kaa_common_schema.h"
-#include "collections/kaa_list.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-#include "platform/ext_system_logger.h"
-#include "gen/kaa_event_fqn_definitions.h"
-
-#define KAA_EVENT_CLIENT_SYNC_EXTENSION_FLAG_RECEIVE_EVENTS 0x1
-#define KAA_EVENT_CLIENT_SYNC_EXTENSION_FLAG_SEQUENCE_NUMBER_SYNC 0x2
-
-#define KAA_EVENT_SERVER_SYNC_EXTENSION_FLAG_SEQUENCE_NUMBER_PRESENT 0x1
-
-#define KAA_EVENT_OPTION_TARGET_ID_PRESENT 0x1
-#define KAA_EVENT_OPTION_EVENT_HAS_DATA 0x2
-
-typedef enum {
- EVENT_LISTENERS_FIELD = 0x00,
- EVENTS_FIELD = 0x01,
-} event_server_sync_field_t;
-
-typedef enum {
- EVENT_LISTENERS_SUCCESS = 0x00,
- EVENT_LISTENERS_FAILURE = 0x01
-} event_listeners_result_t;
-
-typedef struct {
- int32_t seq_num;
- /**
- * Use kaa_bytes_t for the fqn parameter (string type) to reduce strlen overhead.
- * The kaa_bytes_t buffer will be null terminated.
- */
- kaa_bytes_t* event_class_fqn;
- kaa_bytes_t* event_data;
- kaa_bytes_t* target;
-} kaa_event_t;
-
-typedef struct {
- size_t request_id;
- kaa_list_t *sent_events;
-} sent_events_tuple_t;
-
-typedef struct {
- char *fqn;
- kaa_event_callback_t cb;
-} event_callback_pair_t;
-
-typedef struct {
- kaa_event_block_id id;
- kaa_list_t *events;
-} event_transaction_t;
-
-typedef enum {
- KAA_EVENT_SEQUENCE_NUMBER_UNSYNCHRONIZED,
- KAA_EVENT_SEQUENCE_NUMBER_SYNC_IN_PROGRESS,
- KAA_EVENT_SEQUENCE_NUMBER_SYNCHRONIZED
-} kaa_event_sequence_number_status_t;
-
-typedef struct {
- uint16_t request_id;
- bool is_sent;
- kaa_bytes_t **fqns;
- size_t fqns_count;
- kaa_event_listeners_callback_t callback;
-} kaa_event_listeners_request_t;
-
-/* Public stuff */
-struct kaa_event_manager_t {
- sent_events_tuple_t events_awaiting_response;
- kaa_list_t *pending_events;
- kaa_list_t *event_callbacks;
- kaa_list_t *transactions;
- kaa_list_t *event_listeners_requests;
- kaa_event_block_id trx_counter;
- kaa_event_callback_t global_event_callback;
- size_t event_sequence_number;
- size_t extension_payload_size;
- kaa_event_sequence_number_status_t sequence_number_status;
-
- kaa_status_t *status;
- kaa_channel_manager_t *channel_manager;
- kaa_logger_t *logger;
-
- uint16_t event_listeners_request_id;
-
- kaa_endpoint_id_p event_source;
-};
-
-static kaa_extension_id event_sync_services[1] = { KAA_EXTENSION_EVENT };
-
-kaa_error_t kaa_extension_event_init(kaa_context_t *kaa_context, void **context)
-{
- kaa_error_t error = kaa_event_manager_create(&kaa_context->event_manager, kaa_context->status->status_instance,
- kaa_context->channel_manager, kaa_context->logger);
- *context = kaa_context->event_manager;
- return error;
-}
-
-kaa_error_t kaa_extension_event_deinit(void *context)
-{
- kaa_event_manager_destroy(context);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_event_request_get_size(void *context, size_t *expected_size)
-{
- return kaa_event_request_get_size(context, expected_size);
-}
-
-kaa_error_t kaa_extension_event_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync)
-{
- // TODO(KAA-982): Use asserts
- if (!context || !size || !need_resync) {
- return KAA_ERR_BADPARAM;
- }
-
- *need_resync = true;
-
- size_t size_needed;
- kaa_error_t error = kaa_extension_event_request_get_size(context, &size_needed);
- if (error) {
- return error;
- }
-
- if (!buffer || *size < size_needed) {
- *size = size_needed;
- return KAA_ERR_BUFFER_IS_NOT_ENOUGH;
- }
-
- *size = size_needed;
-
- kaa_platform_message_writer_t writer = KAA_MESSAGE_WRITER(buffer, *size);
- error = kaa_event_request_serialize(context, request_id, &writer);
- if (error) {
- return error;
- }
-
- *size = writer.current - buffer;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_event_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size)
-{
- // TODO(KAA-982): Use asserts
- if (!context || !buffer) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_platform_message_reader_t reader = KAA_MESSAGE_READER(buffer, size);
- return kaa_event_handle_server_sync(context, &reader, extension_options, size, request_id);
-}
-
-static void destroy_event_listener_request(void *request_p)
-{
- KAA_RETURN_IF_NIL(request_p,);
- kaa_event_listeners_request_t *subscriber = (kaa_event_listeners_request_t *) request_p;
- if (subscriber->fqns) {
- size_t i = 0;
- for (; i < subscriber->fqns_count; ++i) {
- if (subscriber->fqns[i]) {
- kaa_bytes_destroy(subscriber->fqns[i]);
- }
- }
- KAA_FREE(subscriber->fqns);
- }
- KAA_FREE(subscriber);
-}
-
-static kaa_event_listeners_request_t *create_event_listener_request(kaa_event_manager_t *self, const char *fqns[], size_t fqns_count, const kaa_event_listeners_callback_t *callback)
-{
- kaa_event_listeners_request_t *result = (kaa_event_listeners_request_t *) KAA_MALLOC(sizeof(kaa_event_listeners_request_t));
- KAA_RETURN_IF_NIL(result, NULL);
-
- result->is_sent = false;
- result->callback = *callback;
- result->request_id = self->event_listeners_request_id + 1;
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to create event listeners request: fqns count %zu, request id '%u'", fqns_count, result->request_id);
-
- result->fqns = (kaa_bytes_t **) KAA_CALLOC(fqns_count, sizeof(kaa_bytes_t *));
- if (!result->fqns) {
- destroy_event_listener_request(result);
- return NULL;
- }
- result->fqns_count = fqns_count;
-
- size_t i = 0;
- for (; i < fqns_count; ++i) {
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Target fqn[%d]: '%s'", i+1, fqns[i]);
- result->fqns[i] = kaa_bytes_copy_create((const uint8_t *) fqns[i], strlen(fqns[i]));
- if (!result->fqns[i]) {
- destroy_event_listener_request(result);
- return NULL;
- }
- }
-
- return result;
-}
-
-static bool find_listeners_request_by_id(void *request_p, void *context)
-{
- kaa_event_listeners_request_t *request = (kaa_event_listeners_request_t *) request_p;
- uint16_t *request_id = (uint16_t *) context;
- return (request && request_id && ((*request_id) == request->request_id));
-}
-
-static void kaa_event_destroy(void* data)
-{
- if (data) {
- kaa_event_t* record = (kaa_event_t*)data;
-
- kaa_bytes_destroy(record->event_class_fqn);
- kaa_bytes_destroy(record->event_data);
- kaa_bytes_destroy(record->target);
-
- KAA_FREE(record);
- }
-}
-
-static event_callback_pair_t *create_event_callback_pair(const char *fqn
- , kaa_event_callback_t callback)
-{
- event_callback_pair_t *pair = (event_callback_pair_t *) KAA_MALLOC(sizeof(event_callback_pair_t));
- KAA_RETURN_IF_NIL(pair, NULL);
-
- size_t fqn_length = strlen(fqn);
- pair->fqn = (char *) KAA_MALLOC((fqn_length + 1) * sizeof(char));
- if (!pair->fqn) {
- KAA_FREE(pair);
- return NULL;
- }
- strcpy(pair->fqn, fqn);
- pair->cb = callback;
- return pair;
-}
-
-static void kaa_event_destroy_callback_pair(void *pair_p)
-{
- KAA_RETURN_IF_NIL(pair_p, );
- event_callback_pair_t *pair = (event_callback_pair_t *) pair_p;
- KAA_FREE(pair->fqn);
- KAA_FREE(pair);
-}
-
-static kaa_event_callback_t find_event_callback(kaa_list_t *head, const char *fqn)
-{
- kaa_list_node_t *it = kaa_list_begin(head);
- while (it) {
- event_callback_pair_t *pair = (event_callback_pair_t *) kaa_list_get_data(it);
- if (strcmp(fqn, pair->fqn) == 0)
- return pair->cb;
- it = kaa_list_next(it);
- }
- return NULL;
-}
-
-static event_transaction_t *create_transaction(kaa_event_block_id id)
-{
- event_transaction_t *trx = (event_transaction_t *) KAA_MALLOC(sizeof(event_transaction_t));
- KAA_RETURN_IF_NIL(trx, NULL);
-
- trx->id = id;
- trx->events = kaa_list_create();
- if (!trx->events) {
- KAA_FREE(trx);
- return NULL;
- }
-
- return trx;
-}
-
-static void destroy_transaction(void *trx_p)
-{
- KAA_RETURN_IF_NIL(trx_p, );
- event_transaction_t *trx = (event_transaction_t *) trx_p;
- kaa_list_destroy(trx->events, &kaa_event_destroy);
- KAA_FREE(trx);
-}
-
-static bool transaction_search_by_id_predicate(void *trx_p, void *context)
-{
- event_transaction_t *trx = (event_transaction_t *) trx_p;
- kaa_event_block_id *matcher = (kaa_event_block_id *) context;
- return (matcher && trx) ? ((*matcher) == trx->id) : false;
-}
-
-/** @deprecated Use kaa_extension_event_deinit(). */
-void kaa_event_manager_destroy(kaa_event_manager_t *self)
-{
- if (self) {
- kaa_list_destroy(self->pending_events, &kaa_event_destroy);
- kaa_list_destroy(self->events_awaiting_response.sent_events, &kaa_event_destroy);
- kaa_list_destroy(self->event_callbacks, &kaa_event_destroy_callback_pair);
- kaa_list_destroy(self->transactions, &destroy_transaction);
- kaa_list_destroy(self->event_listeners_requests, &destroy_event_listener_request);
-
- if (self->event_source) {
- KAA_FREE((void*)self->event_source);
- }
- KAA_FREE(self);
- }
-}
-
-/** @deprecated Use kaa_extension_event_init(). */
-kaa_error_t kaa_event_manager_create(kaa_event_manager_t **context, kaa_status_t *status,
- kaa_channel_manager_t *channel_manager, kaa_logger_t *logger)
-{
- kaa_event_manager_t **event_manager_p = (kaa_event_manager_t **)context;
- KAA_RETURN_IF_NIL(event_manager_p, KAA_ERR_BADPARAM);
-
- *event_manager_p = (kaa_event_manager_t *) KAA_MALLOC(sizeof(kaa_event_manager_t));
- KAA_RETURN_IF_NIL(*event_manager_p, KAA_ERR_NOMEM);
-
- (*event_manager_p)->events_awaiting_response.request_id = (size_t) -1;
- (*event_manager_p)->event_listeners_request_id = 0;
- (*event_manager_p)->trx_counter = 0;
- (*event_manager_p)->global_event_callback = NULL;
- (*event_manager_p)->event_sequence_number = status->event_seq_n;
-
- (*event_manager_p)->sequence_number_status = KAA_EVENT_SEQUENCE_NUMBER_UNSYNCHRONIZED;
-
- (*event_manager_p)->status = status;
- (*event_manager_p)->channel_manager = channel_manager;
- (*event_manager_p)->logger = logger;
-
- (*event_manager_p)->event_source = (kaa_endpoint_id_p)KAA_MALLOC(sizeof(kaa_endpoint_id));
- KAA_RETURN_IF_NIL((*event_manager_p)->event_source, KAA_ERR_NOMEM);
-
- (*event_manager_p)->pending_events = kaa_list_create();
- (*event_manager_p)->events_awaiting_response.sent_events = kaa_list_create();
- (*event_manager_p)->event_callbacks = kaa_list_create();
- (*event_manager_p)->transactions = kaa_list_create();
- (*event_manager_p)->event_listeners_requests = kaa_list_create();
-
- if (!(*event_manager_p)->pending_events || !(*event_manager_p)->events_awaiting_response.sent_events ||
- !(*event_manager_p)->event_callbacks || !(*event_manager_p)->transactions ||
- !(*event_manager_p)->event_listeners_requests)
- {
- kaa_event_manager_destroy(*event_manager_p);
- return KAA_ERR_NOMEM;
- }
-
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_fill_event_structure(kaa_event_t *event
- , size_t sequence_number
- , const char *fqn
- , const char *event_data
- , size_t event_data_size
- , kaa_endpoint_id_p target)
-{
- KAA_RETURN_IF_NIL2(event, fqn, KAA_ERR_BADPARAM);
-
- event->seq_num = sequence_number;
- event->event_class_fqn = kaa_bytes_copy_create((const uint8_t *)fqn
- , strlen(fqn) + 1);
- --event->event_class_fqn->size;
- KAA_RETURN_IF_NIL(event->event_class_fqn, KAA_ERR_NOMEM);
-
- if (event_data && event_data_size > 0) {
- event->event_data = kaa_bytes_move_create((const uint8_t *) event_data
- , event_data_size
- , &kaa_data_destroy);
- KAA_RETURN_IF_NIL(event->event_data, KAA_ERR_NOMEM);
- }
-
- if (target) {
- event->target = kaa_bytes_copy_create(target, KAA_ENDPOINT_ID_LENGTH);
- KAA_RETURN_IF_NIL(event->target, KAA_ERR_NOMEM);
- }
-
- return KAA_ERR_NONE;
-}
-
-/*
- * @brief Sends raw event
- *
- * It is not recommended to use this function directly. Instead you should use
- * functions contained in EventClassFamily auto-generated headers (placed at src/event/)
- *
- * @param[in] self Valid pointer to the event manager instance.
- * @param[in] fqn Fully-qualified name of the event (null-terminated string).
- * @param[in] event_data Serialized event object.
- * @param[in] event_data_size Size of data in event_data parameter.
- * @param[in] target The target endpoint of the event (null-terminated string). The size of
- * the target parameter should be equal to @link KAA_ENDPOINT_ID_LENGTH @endlink .
- * If @code NULL @endcode event will be broadcasted.
- *
- * @return Error code.
- */
-kaa_error_t kaa_event_manager_send_event(kaa_event_manager_t *self
- , const char *fqn
- , const char *event_data
- , size_t event_data_size
- , kaa_endpoint_id_p target)
-{
- /**
- * Both the event data + its size and the target may be left unspecified (null).
- */
- KAA_RETURN_IF_NIL(self, KAA_ERR_NOT_INITIALIZED);
- KAA_RETURN_IF_NIL(fqn, KAA_ERR_EVENT_BAD_FQN);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Adding a new event \"%s\"", fqn);
-
- /**
- * KAA_CALLOC is really needed there.
- */
- kaa_event_t *event = (kaa_event_t*)KAA_CALLOC(1, sizeof(kaa_event_t));
- if (!event) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_NOMEM, "Failed to allocate a new event structure");
- return KAA_ERR_NOMEM;
- }
-
- size_t new_sequence_number = (self->sequence_number_status == KAA_EVENT_SEQUENCE_NUMBER_SYNCHRONIZED ?
- ++self->event_sequence_number :
- (size_t) -1);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Filling a new event with data size %u", event_data_size);
-# ifdef KAA_LOG_LEVEL_TRACE_ENABLED
- if (target) {
- char target_string[2 * KAA_ENDPOINT_ID_LENGTH + 1];
- int i = 0;
- for (; i < KAA_ENDPOINT_ID_LENGTH; ++i) {
- ext_snpintf(&target_string[2 * i], 3, "%02X", target[i]);
- }
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Event target = %s", target_string);
- }
-# endif
- kaa_error_t error = kaa_fill_event_structure(event
- , new_sequence_number
- , fqn
- , event_data
- , event_data_size
- , target);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to fill a new event (size=%u)", event_data_size);
- kaa_event_destroy(event);
- return error;
- }
-
- if (!kaa_list_push_back(self->pending_events, event)) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_NOMEM, "Failed to save a new event");
- kaa_event_destroy(event);
- return KAA_ERR_NOMEM;
- }
-
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(self->channel_manager, event_sync_services[0]);
- if (channel)
- channel->sync_handler(channel->context, event_sync_services, 1);
-
- return KAA_ERR_NONE;
-}
-
-static size_t kaa_event_list_get_request_size(kaa_list_t *events)
-{
- size_t expected_size = 0;
-
- kaa_list_node_t *it = kaa_list_begin(events);
- while (it) {
- kaa_event_t *event = (kaa_event_t *)kaa_list_get_data(it);
-
- expected_size += sizeof(uint32_t) /*Event sequence number*/
- + sizeof(uint16_t) /*Event options*/
- + sizeof(uint16_t); /*Event class FQN length */
-
- if (event->event_data) {
- expected_size += sizeof(uint32_t); /*Event data size*/
- }
-
- if (event->target /*have Target Endpoint ID*/) {
- expected_size += KAA_ENDPOINT_ID_LENGTH; /*Target Endpoint ID*/
- }
-
- expected_size += kaa_aligned_size_get(event->event_class_fqn->size); /*Event class FQN + padding */
-
- if (event->event_data) {
- expected_size += kaa_aligned_size_get(event->event_data->size);/*Event data + padding*/
- }
-
- it = kaa_list_next(it);
- }
- return expected_size;
-}
-
-static kaa_error_t kaa_event_request_get_size_no_header(kaa_event_manager_t *self, size_t *expected_size)
-{
- KAA_RETURN_IF_NIL2(self, expected_size, KAA_ERR_BADPARAM);
-
- *expected_size = 0;
- if (self->sequence_number_status == KAA_EVENT_SEQUENCE_NUMBER_SYNCHRONIZED) {
- bool have_events = (kaa_list_get_size(self->pending_events) > 0) ||
- (kaa_list_get_size(self->events_awaiting_response.sent_events) > 0);
-
- if (have_events) {
- *expected_size += sizeof(uint32_t); // field id(1) + reserved + events count
- *expected_size += kaa_event_list_get_request_size(self->pending_events);
- *expected_size += kaa_event_list_get_request_size(self->events_awaiting_response.sent_events);
- }
- }
-
- if (kaa_list_get_size(self->event_listeners_requests) > 0) {
- *expected_size += sizeof(uint32_t); // field id(0) + reserved + listeners count
-
- kaa_list_node_t *it = kaa_list_begin(self->event_listeners_requests);
- while (it) {
- kaa_event_listeners_request_t *request = (kaa_event_listeners_request_t *) kaa_list_get_data(it);
- if (!request->is_sent) {
- *expected_size += sizeof(uint32_t); // request id + fqns count
- *expected_size += sizeof(uint32_t) * request->fqns_count; // fqn length + reserved
- for (size_t i = 0; i < request->fqns_count; ++i) {
- *expected_size += kaa_aligned_size_get(request->fqns[i]->size);
- }
- }
- it = kaa_list_next(it);
- }
- }
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_event_request_get_size(kaa_event_manager_t *self, size_t *expected_size)
-{
- KAA_RETURN_IF_NIL2(self, expected_size, KAA_ERR_BADPARAM);
-
- kaa_error_t error = kaa_event_request_get_size_no_header(self, expected_size);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to get event extension length");
- *expected_size = 0;
- return error;
- }
-
- self->extension_payload_size = *expected_size;
- *expected_size += KAA_EXTENSION_HEADER_SIZE;
-
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_event_list_serialize(kaa_event_manager_t *self, kaa_list_t *events, kaa_platform_message_writer_t *writer)
-{
- uint16_t temp_network_order_16 = 0;
- uint16_t options = 0;
- uint32_t temp_network_order_32 = 0;
-
- kaa_list_node_t *it = kaa_list_begin(events);
- while (it) {
- kaa_event_t *event = (kaa_event_t *) kaa_list_get_data(it);
-
- if (event->seq_num == -1) {
- event->seq_num = ++self->event_sequence_number;
- }
-
- temp_network_order_32 = KAA_HTONL(event->seq_num);
- kaa_error_t error = kaa_platform_message_write(writer, &temp_network_order_32, sizeof(uint32_t));
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write event sequence number");
- return error;
- }
-
- /**
- * Event options
- */
- options = (!event->target ? 0 : KAA_EVENT_OPTION_TARGET_ID_PRESENT)
- | (event->event_data ? KAA_EVENT_OPTION_EVENT_HAS_DATA : 0);
- options = KAA_HTONS(options);
-
- error = kaa_platform_message_write(writer, &options, sizeof(uint16_t));
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write event options");
- return error;
- }
-
- temp_network_order_16 = KAA_HTONS(event->event_class_fqn->size);
- error = kaa_platform_message_write(writer, &temp_network_order_16, sizeof(uint16_t));
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write event class fqn length");
- return error;
- }
-
- if (event->event_data) {
- temp_network_order_32 = KAA_HTONL(event->event_data->size);
- error = kaa_platform_message_write(writer, &temp_network_order_32, sizeof(uint32_t));
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write event data size");
- return error;
- }
- }
-
- if (event->target) {
- error = kaa_platform_message_write_aligned(writer,
- event->target->buffer
- , KAA_ENDPOINT_ID_LENGTH);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write event target id");
- return error;
- }
- }
-
- error = kaa_platform_message_write_aligned(writer
- , event->event_class_fqn->buffer
- , event->event_class_fqn->size);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write event class fqn aligned");
- return error;
- }
-
-
- if (event->event_data) {
- error = kaa_platform_message_write_aligned(writer
- , event->event_data->buffer
- , event->event_data->size);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write event data aligned");
- return error;
- }
- }
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Serialized event: sqn '%u', options '%u', data size '%u', fqn '%s'"
- , event->seq_num, KAA_NTOHS(options), event->event_data ? event->event_data->size : 0, event->event_class_fqn->buffer);
- it = kaa_list_next(it);
- }
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_event_listeners_request_serialize(kaa_event_manager_t *self, kaa_platform_message_writer_t *writer, uint16_t *serialized_listeners_count)
-{
- kaa_list_node_t *it = kaa_list_begin(self->event_listeners_requests);
- *serialized_listeners_count = 0;
- while (it) {
- kaa_event_listeners_request_t *request = (kaa_event_listeners_request_t *) kaa_list_get_data(it);
- if (!request->is_sent) {
- *((uint16_t *) writer->current) = KAA_HTONS(request->request_id);
- writer->current += sizeof(uint16_t);
- *((uint16_t *) writer->current) = KAA_HTONS((uint16_t) request->fqns_count);
- writer->current += sizeof(uint16_t);
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize event listeners: request id '%u', fqn count '%u'"
- , request->request_id, request->fqns_count);
- for (size_t i = 0; i < request->fqns_count; ++i) {
- size_t fqn_length = request->fqns[i]->size;
- *((uint16_t *) writer->current) = KAA_HTONS((uint16_t) fqn_length);
- writer->current += sizeof(uint32_t); // fqn length + reserved
- kaa_error_t error = kaa_platform_message_write_aligned(writer, request->fqns[i]->buffer, fqn_length);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write event listener request");
- *serialized_listeners_count = 0;
- return error;
- }
- }
-
- request->is_sent = true;
- (*serialized_listeners_count)++;
- }
- it = kaa_list_next(it);
- }
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_event_request_serialize(kaa_event_manager_t *self, size_t request_id, kaa_platform_message_writer_t *writer)
-{
- KAA_RETURN_IF_NIL2(self, writer, KAA_ERR_BADPARAM);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize client event sync");
-
- /* write extension header */
- uint16_t extension_options = 0;
- if (self->sequence_number_status != KAA_EVENT_SEQUENCE_NUMBER_SYNCHRONIZED) {
- extension_options |= KAA_EVENT_CLIENT_SYNC_EXTENSION_FLAG_SEQUENCE_NUMBER_SYNC;
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to sync event SQN");
- } else {
- extension_options |= KAA_EVENT_CLIENT_SYNC_EXTENSION_FLAG_RECEIVE_EVENTS;
- }
-
- kaa_error_t error = kaa_platform_message_write_extension_header(writer
- , KAA_EXTENSION_EVENT
- , extension_options
- , self->extension_payload_size);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write event extension header (ext type %u, options %X, payload size %u)"
- , KAA_EXTENSION_EVENT, extension_options, self->extension_payload_size);
- return error;
- }
-
- /* write events */
- if (self->extension_payload_size) {
- kaa_list_t *pending_events = self->pending_events;
- kaa_list_t *resending_events = self->events_awaiting_response.sent_events;
- uint16_t events_count = kaa_list_get_size(pending_events) + kaa_list_get_size(resending_events);
-
- if (events_count) {
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Serializing %u events", events_count);
- *((uint8_t *) writer->current) = EVENTS_FIELD;
- writer->current += sizeof(uint16_t); // field id + reserved
- *((uint16_t *) writer->current) = KAA_HTONS(events_count);
- writer->current += sizeof(uint16_t);
-
- error = kaa_event_list_serialize(self, resending_events, writer);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write events");
- return error;
- }
-
- error = kaa_event_list_serialize(self, pending_events, writer);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write events");
- return error;
- }
-
- self->events_awaiting_response.request_id = request_id;
- self->events_awaiting_response.sent_events = kaa_lists_merge(self->events_awaiting_response.sent_events
- , self->pending_events);
- }
-
- if (kaa_list_get_size(self->event_listeners_requests)) {
- *((uint8_t *) writer->current) = EVENT_LISTENERS_FIELD;
- writer->current += sizeof(uint16_t); // field id + reserved
- uint8_t *listeners_count_p = writer->current; // Pointer to the listeners count. Will be filled in later
- writer->current += sizeof(uint16_t);
-
- uint16_t listeners_count = 0;
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Serializing event listeners");
- error = kaa_event_listeners_request_serialize(self, writer, &listeners_count);
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Serialized %u event listeners", listeners_count);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to serialize event listeners request");
- return error;
- }
- *((uint16_t *) listeners_count_p) = KAA_HTONS(listeners_count);
- }
- }
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_event_read_event(kaa_event_manager_t *self, kaa_platform_message_reader_t *reader)
-{
-
- KAA_RETURN_IF_NIL2(self, reader, KAA_ERR_BADPARAM);
-
- uint16_t event_options = 0;
- kaa_error_t error = kaa_platform_message_read(reader, &event_options, sizeof(uint16_t));
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read event options field");
- return error;
- }
- event_options = KAA_NTOHS(event_options);
-
- uint16_t event_class_fqn_length = 0;
- error = kaa_platform_message_read(reader, &event_class_fqn_length, sizeof(uint16_t));
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read event class fqn length field");
- return error;
- }
- event_class_fqn_length = KAA_NTOHS(event_class_fqn_length);
-
- uint32_t event_data_size = 0;
- if (event_options & KAA_EVENT_OPTION_EVENT_HAS_DATA) {
- error = kaa_platform_message_read(reader, &event_data_size, sizeof(uint32_t));
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read event data size field");
- return error;
- }
- event_data_size = KAA_NTOHL(event_data_size);
- }
-
- error = kaa_platform_message_read(reader, (void*)self->event_source, sizeof(kaa_endpoint_id));
-
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read event source endpoint id field");
- return error;
- }
-
- bool is_enough = kaa_platform_message_is_buffer_large_enough(reader, kaa_aligned_size_get(event_class_fqn_length));
-
- if (!is_enough) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_READ_FAILED, "Buffer size is less than event class fqn length value");
- return KAA_ERR_READ_FAILED;
- }
- char* event_fqn = (char *)KAA_MALLOC(event_class_fqn_length + 1);
-
- KAA_RETURN_IF_NIL(event_fqn, KAA_ERR_NOMEM);
-
- error = kaa_platform_message_read_aligned(reader, event_fqn, event_class_fqn_length);
-
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read event class fqn field");
- KAA_FREE(event_fqn);
- return error;
- }
- event_fqn[event_class_fqn_length] = '\0';
-
- KAA_LOG_DEBUG(self->logger, KAA_ERR_NONE, "Processing event: options '%u', fqn length '%u', fqn '%s' ", event_options, event_class_fqn_length, event_fqn);
-
- kaa_event_callback_t callback = find_event_callback(self->event_callbacks, event_fqn);
- if (!callback)
- callback = self->global_event_callback;
-
- if (event_options & KAA_EVENT_OPTION_EVENT_HAS_DATA) {
- const uint8_t *event_data = reader->current;
- kaa_error_t error = kaa_platform_message_skip(reader, kaa_aligned_size_get(event_data_size));
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read event data, size %u", event_data_size);
- KAA_FREE(event_fqn);
- return error;
- }
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Successfully retrieved event data size=%u", event_data_size);
- if (callback)
- (*callback)(event_fqn, (const char *)event_data, event_data_size, self->event_source);
- } else if (callback) {
- (*callback)(event_fqn, NULL, 0, self->event_source);
- }
- KAA_FREE(event_fqn);
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_event_read_listeners_response(kaa_event_manager_t *self, kaa_platform_message_reader_t *reader)
-{
- uint16_t request_id = KAA_NTOHS(*(uint16_t *) reader->current);
- reader->current += sizeof(uint16_t);
- uint16_t listeners_result = KAA_NTOHS(*(uint16_t *) reader->current);
- reader->current += sizeof(uint16_t);
-
- uint32_t listeners_count = KAA_NTOHL(*(uint32_t *) reader->current);
- reader->current += sizeof(uint32_t);
-
- KAA_LOG_DEBUG(self->logger, KAA_ERR_NONE, "Received %u event listener(s) on %u request"
- , listeners_count, request_id);
-
- kaa_list_node_t *request_node = kaa_list_find_next(kaa_list_begin(self->event_listeners_requests)
- , &find_listeners_request_by_id
- , &request_id);
- if (request_node) {
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Found event listeners callback with request id %u", request_id);
- if (reader->current + (listeners_count * KAA_ENDPOINT_ID_LENGTH) > reader->end) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_READ_FAILED, "Failed to read endpoint ids for request id %u", request_id);
- return KAA_ERR_READ_FAILED;
- }
- kaa_event_listeners_request_t *request = (kaa_event_listeners_request_t *) kaa_list_get_data(request_node);
- if (listeners_result == EVENT_LISTENERS_SUCCESS) {
- request->callback.on_event_listeners(request->callback.context, (const kaa_endpoint_id *) reader->current, listeners_count);
- KAA_LOG_DEBUG(self->logger, KAA_ERR_NONE, "Success event listeners response for request id %u", request_id);
- } else {
- request->callback.on_event_listeners_failed(request->callback.context);
- KAA_LOG_DEBUG(self->logger, KAA_ERR_NONE, "Failed to find event listeners, request id %u", request_id);
- }
- kaa_list_remove_at(self->event_listeners_requests, request_node, &destroy_event_listener_request);
- } else {
- KAA_LOG_WARN(self->logger, KAA_ERR_NOT_FOUND, "Failed to find event listeners callback with request id %u", request_id);
- }
- reader->current += listeners_count * KAA_ENDPOINT_ID_LENGTH;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_event_handle_server_sync(kaa_event_manager_t *self
- , kaa_platform_message_reader_t *reader
- , uint16_t extension_options
- , size_t extension_length
- , size_t request_id)
-{
- KAA_RETURN_IF_NIL2(self, reader, KAA_ERR_BADPARAM);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received event server sync: options %u, payload size %u", extension_options, extension_length);
-
- if (extension_options & KAA_EVENT_SERVER_SYNC_EXTENSION_FLAG_SEQUENCE_NUMBER_PRESENT) {
- uint32_t event_sequence_number = 0;
- kaa_error_t error = kaa_platform_message_read(reader, &event_sequence_number, sizeof(uint32_t));
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read event_sequence number field");
- return error;
- }
-
- event_sequence_number = KAA_HTONL(event_sequence_number);
- extension_length -= sizeof(uint32_t);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received event sequence number '%u'", event_sequence_number);
- if (self->sequence_number_status != KAA_EVENT_SEQUENCE_NUMBER_SYNCHRONIZED) {
- self->sequence_number_status = KAA_EVENT_SEQUENCE_NUMBER_SYNCHRONIZED;
-
- if (self->event_sequence_number != event_sequence_number) {
- KAA_LOG_WARN(self->logger, KAA_ERR_BAD_STATE, "Stored event sequence number is not correct (stored %u, received %u).", self->event_sequence_number, event_sequence_number);
- self->event_sequence_number = event_sequence_number;
- kaa_list_node_t *it = kaa_list_begin(self->pending_events);
- while (it) {
- kaa_event_t *event = (kaa_event_t *)kaa_list_get_data(it);
- event->seq_num = ++self->event_sequence_number;
- it = kaa_list_next(it);
- }
- }
- }
- if (kaa_list_get_size(self->pending_events) > 0) {
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(self->channel_manager, event_sync_services[0]);
- if (channel)
- channel->sync_handler(channel->context, event_sync_services, 1);
- }
- }
-
- if (request_id == self->events_awaiting_response.request_id) {
- kaa_list_clear(self->events_awaiting_response.sent_events, &kaa_event_destroy);
- self->events_awaiting_response.request_id = (size_t) -1;
- }
-
- while (extension_length > 0) {
- uint8_t field_id = 0;
- const uint8_t *field_id_pos = reader->current;
-
- kaa_error_t error = kaa_platform_message_read(reader, &field_id, sizeof(uint8_t)); //read field id
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read field id in Event server sync message");
- return error;
- }
-
- error = kaa_platform_message_skip(reader, sizeof(uint8_t)); // skip reserved
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to skip reserved field in Event server sync message");
- return error;
- }
- switch (field_id) {
- case EVENTS_FIELD: {
- uint16_t events_count = 0;
- error = kaa_platform_message_read(reader, &events_count, sizeof(uint16_t)); // read events count
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read field id in Event server sync message");
- return error;
- }
- events_count = KAA_NTOHS(events_count);
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received %u events", events_count);
- while (events_count--) {
- error = kaa_event_read_event(self, reader);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read event from server sync");
- return error;
- }
- }
- break;
- }
- case EVENT_LISTENERS_FIELD: {
- uint16_t event_listeners_responses_count = 0;
- error = kaa_platform_message_read(reader, &event_listeners_responses_count, sizeof(uint16_t)); // read events count
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read event listener response in Event server sync message");
- return error;
- }
-
- event_listeners_responses_count = KAA_NTOHS(event_listeners_responses_count);
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received %u event listeners response(s)"
- , event_listeners_responses_count);
-
- while (event_listeners_responses_count--) {
- error = kaa_event_read_listeners_response(self, reader);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to read event listeners response");
- return error;
- }
- }
- break;
- }
- default:
- KAA_LOG_ERROR(self->logger, KAA_ERR_BADDATA, "Unexpected field id %u", field_id);
- return KAA_ERR_BADDATA;
- }
-
- extension_length -= (reader->current - field_id_pos);
- }
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_event_manager_find_event_listeners(kaa_event_manager_t *self, const char *fqns[], size_t fqns_count, const kaa_event_listeners_callback_t *callback)
-{
- KAA_RETURN_IF_NIL5(self, fqns_count, callback, callback->on_event_listeners, callback->on_event_listeners_failed, KAA_ERR_BADPARAM);
-
- kaa_event_listeners_request_t *subscriber = create_event_listener_request(self, fqns, fqns_count, callback);
- KAA_RETURN_IF_NIL(subscriber, KAA_ERR_NOMEM);
-
- kaa_list_node_t *request_it = kaa_list_push_front(self->event_listeners_requests, subscriber);
- if (!request_it) {
- destroy_event_listener_request(subscriber);
- return KAA_ERR_NOMEM;
- }
-
- ++self->event_listeners_request_id;
-
- kaa_transport_channel_interface_t *channel = kaa_channel_manager_get_transport_channel(self->channel_manager, event_sync_services[0]);
- if (channel)
- channel->sync_handler(channel->context, event_sync_services, 1);
-
- return KAA_ERR_NONE;
-}
-
-/*
- * @brief Register listener to an event.
- *
- * It is not recommended to use this function directly. Instead you should use
- * functions contained in EventClassFamily auto-generated headers (placed at src/event/)
- *
- * @param[in] self Valid pointer to the event manager instance.
- * @param[in] fqn Fully-qualified name of the event (null-terminated string).
- * If @code NULL @endcode, this callback will be invoked for
- * all events which do not have registered specific callback.
- * @param[in] callback Event callback function.
- *
- * @return Error code.
- */
-kaa_error_t kaa_event_manager_add_on_event_callback(kaa_event_manager_t *self, const char *fqn, kaa_event_callback_t callback)
-{
- KAA_RETURN_IF_NIL2(self, callback, KAA_ERR_BADPARAM);
- if (fqn) {
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Adding callback for events, fqn '%s'", fqn);
- event_callback_pair_t *pair = create_event_callback_pair(fqn, callback);
- KAA_RETURN_IF_NIL(pair, KAA_ERR_NOMEM);
- kaa_list_node_t *it = kaa_list_begin(self->event_callbacks);
- while (it) {
- event_callback_pair_t *data = (event_callback_pair_t *) kaa_list_get_data(it);
- if (strcmp(fqn, data->fqn) == 0) {
- kaa_list_set_data_at(it, pair, &kaa_event_destroy_callback_pair);
- return KAA_ERR_NONE;
- }
- it = kaa_list_next(it);
- }
- if (!kaa_list_push_back(self->event_callbacks, pair)) {
- kaa_event_destroy_callback_pair(pair);
- return KAA_ERR_NOMEM;
- }
- } else {
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Adding global event callback");
- self->global_event_callback = callback;
- }
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_event_create_transaction(kaa_event_manager_t *self, kaa_event_block_id *trx_id)
-{
- KAA_RETURN_IF_NIL2(self, trx_id, KAA_ERR_NOT_INITIALIZED);
-
- *trx_id = self->trx_counter + 1;
- event_transaction_t *new_transaction = create_transaction(*trx_id);
- KAA_RETURN_IF_NIL(new_transaction, KAA_ERR_NOMEM);
-
- if (!kaa_list_push_back(self->transactions, new_transaction)) {
- destroy_transaction(new_transaction);
- return KAA_ERR_NOMEM;
- }
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Creating new events batch, id %zu", *trx_id);
-
- self->trx_counter = *trx_id;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_event_finish_transaction(kaa_event_manager_t *self, kaa_event_block_id trx_id)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_NOT_INITIALIZED);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to send events from event batch, id %zu", trx_id);
-
- kaa_list_node_t *it = kaa_list_find_next(kaa_list_begin(self->transactions), &transaction_search_by_id_predicate, &trx_id);
- if (it) {
- event_transaction_t *trx = kaa_list_get_data(it);
- bool need_sync = false;
- if (kaa_get_max_log_level(self->logger) >= KAA_LOG_LEVEL_TRACE) {
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Events batch with id %zu has %zu events", trx_id, kaa_list_get_size(trx->events));
- }
- if (kaa_list_get_size(trx->events) > 0) {
- self->pending_events = kaa_lists_merge(self->pending_events, trx->events);
- need_sync = true;
- }
- kaa_list_remove_at(self->transactions, it, &destroy_transaction);
-
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(self->channel_manager, event_sync_services[0]);
- if (need_sync && channel)
- channel->sync_handler(channel->context, event_sync_services, 1);
-
- return KAA_ERR_NONE;
- }
-
- KAA_LOG_WARN(self->logger, KAA_ERR_NOT_FOUND, "Events batch with id %zu was not created before", trx_id);
-
- return KAA_ERR_NOT_FOUND;
-}
-
-kaa_error_t kaa_event_remove_transaction(kaa_event_manager_t *self, kaa_event_block_id trx_id)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_NOT_INITIALIZED);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to remove events batch with id %zu", trx_id);
-
- kaa_error_t error = kaa_list_remove_first(self->transactions, &transaction_search_by_id_predicate, &trx_id, &destroy_transaction);
- if (error) {
- KAA_LOG_WARN(self->logger, error, "Events batch with id %zu was not created before", trx_id);
- }
-
- return error;
-}
-
-/*
- * @brief Adds a raw event to the transaction.
- *
- * It is not recommended to use this function directly. Instead you should use
- * functions contained in EventClassFamily auto-generated headers (@code kaa_event_manager_add_*_event_to_block(...) @endcode)
- *
- * @param[in] self Valid pointer to the event manager instance.
- * @param[in] trx_id The ID of the event block to be sent.
- * @param[in] fqn Fully-qualified name of the event (null-terminated string).
- * @param[in] event_data Serialized event object.
- * @param[in] event_data_size Size of data in event_data parameter.
- * @param[in] target The target endpoint of the event. If @code NULL @endcode event will be broadcasted.
- * @param[in] target_size Size of data in target parameter.
- *
- * @return Error code.
- */
-kaa_error_t kaa_event_manager_add_event_to_transaction(kaa_event_manager_t *self
- , kaa_event_block_id trx_id
- , const char *fqn
- , const char *event_data
- , size_t event_data_size
- , kaa_endpoint_id_p target)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_NOT_INITIALIZED);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to add event to events batch, id %zu", trx_id);
-
- KAA_RETURN_IF_NIL(fqn, KAA_ERR_EVENT_BAD_FQN);
-
- kaa_list_node_t *it = kaa_list_find_next(kaa_list_begin(self->transactions), &transaction_search_by_id_predicate, &trx_id);
- if (it) {
- /**
- * KAA_CALLOC is really needed there.
- */
- kaa_event_t *event = (kaa_event_t*)KAA_CALLOC(1, sizeof(kaa_event_t));
- KAA_RETURN_IF_NIL(event, KAA_ERR_NOMEM);
-
- kaa_error_t error = kaa_fill_event_structure(event
- , (size_t)-1
- , fqn
- , event_data
- , event_data_size
- , target);
- if (error) {
- kaa_event_destroy(event);
- return error;
- }
-
- event_transaction_t *trx = kaa_list_get_data(it);
- if (!kaa_list_push_back(trx->events, event)) {
- kaa_event_destroy(event);
- return KAA_ERR_NOMEM;
- }
-
- return KAA_ERR_NONE;
- }
-
- KAA_LOG_WARN(self->logger, KAA_ERR_NOT_FOUND, "Can not add event to events batch, id %zu.", trx_id);
-
- return KAA_ERR_EVENT_TRX_NOT_FOUND;
-}
-
-const char *kaa_find_class_family_name(const char *fqn)
-{
- size_t i = 0;
- while (SUPPORTED_EVENT_CLASS_FAMILIES_SIZE - i++) {
- size_t fqn_count = SUPPORTED_EVENT_CLASS_FAMILIES[SUPPORTED_EVENT_CLASS_FAMILIES_SIZE - i].supported_incoming_fqns_count;
- char **fqns = SUPPORTED_EVENT_CLASS_FAMILIES[SUPPORTED_EVENT_CLASS_FAMILIES_SIZE - i].supported_incoming_fqns;
- while (fqn_count--) {
- if (strcmp(fqn, fqns[fqn_count]) == 0) {
- return SUPPORTED_EVENT_CLASS_FAMILIES[SUPPORTED_EVENT_CLASS_FAMILIES_SIZE - i].ecf_name;
- }
- }
- }
- return NULL;
-}
diff --git a/client/client-multi/client-c/src/extensions/event/kaa_event.h b/client/client-multi/client-c/src/extensions/event/kaa_event.h
deleted file mode 100644
index e139d3e0b7..0000000000
--- a/client/client-multi/client-c/src/extensions/event/kaa_event.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file kaa_event.h
- * @brief Kaa event subsystem API
- *
- * Supplies API for Kaa event subsystem
- */
-
-#ifndef KAA_EVENT_H_
-#define KAA_EVENT_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include
-#include "kaa_error.h"
-#include "platform/ext_event_listeners_callback.h"
-
-typedef void (*kaa_event_callback_t)(const char *event_fqn, const char *event_data, size_t event_data_size, kaa_endpoint_id_p event_source);
-typedef size_t kaa_event_block_id;
-
-#ifndef KAA_EVENT_MANAGER_T
-# define KAA_EVENT_MANAGER_T
- typedef struct kaa_event_manager_t kaa_event_manager_t;
-#endif
-
-
-/**
- * @brief Initiates a request to the server to search for available event listeners by given FQNs.
- *
- *
- * @param[in] self Valid pointer to the event manager instance.
- * @param[in] fqns List of FQN strings.
- * @param[in] fqns_count Number of FQNs in the list.
- * @param[in] callback Pointer to callback structure.
- *
- * @return Error code.
- */
-kaa_error_t kaa_event_manager_find_event_listeners(kaa_event_manager_t *self, const char *fqns[], size_t fqns_count, const kaa_event_listeners_callback_t *callback);
-
-
-/**
- * @brief Start a new event block.
- *
- * Returns a new id which must be used to add an event to the block.
- *
- * @param[in] self Valid pointer to the event manager instance.
- * @param[in,out] trx_id Pointer to the @link kaa_event_block_id @endlink instance which will be fulfilled with a corresponding ID.
- *
- * @return Error code.
- */
-kaa_error_t kaa_event_create_transaction(kaa_event_manager_t *self, kaa_event_block_id *trx_id);
-
-
-/**
- * @brief Send all the events from the event block at once.
- *
- * The event block is identified by the given @p trx_id.
- *
- * @param[in] self Valid pointer to the event manager instance.
- * @param[in] trx_id The ID of the event block to be sent.
- *
- * @return Error code.
- */
-kaa_error_t kaa_event_finish_transaction(kaa_event_manager_t *self, kaa_event_block_id trx_id);
-
-
-/**
- * @brief Removes the event block without sending events.
- *
- * @param[in] self Valid pointer to the event manager instance.
- * @param[in] trx_id The ID of the event block to be sent.
- *
- * @return Error code.
- */
-kaa_error_t kaa_event_remove_transaction(kaa_event_manager_t *self, kaa_event_block_id trx_id);
-
-/**
- * @brief Find class family name of the event by its fully-qualified name.
- *
- * @param[in] fqn Fully-qualified name of the event (null-terminated string).
- *
- * @return Null-terminated string if corresponding event class family was found, @c NULL otherwise.
- */
-
-const char *kaa_find_class_family_name(const char *fqn);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-#endif /* KAA_EVENT_H_ */
diff --git a/client/client-multi/client-c/src/extensions/event/kaa_event_private.h b/client/client-multi/client-c/src/extensions/event/kaa_event_private.h
deleted file mode 100644
index 5a6823434a..0000000000
--- a/client/client-multi/client-c/src/extensions/event/kaa_event_private.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef KAA_EVENT_PRIVATE_H
-#define KAA_EVENT_PRIVATE_H
-
-#include
-#include
-#include
-#include
-#include
-
-kaa_error_t kaa_event_manager_create(kaa_event_manager_t **event_manager_p, kaa_status_t *status,
- kaa_channel_manager_t *channel_manager, kaa_logger_t *logger);
-void kaa_event_manager_destroy(kaa_event_manager_t *self);
-kaa_error_t kaa_event_manager_send_event(kaa_event_manager_t *self, const char *fqn, const char *event_data,
- size_t event_data_size, kaa_endpoint_id_p target);
-
-kaa_error_t kaa_event_manager_add_event_to_transaction(kaa_event_manager_t *self, kaa_event_block_id trx_id,
- const char *fqn, const char *event_data, size_t event_data_size, kaa_endpoint_id_p target);
-
-kaa_error_t kaa_event_manager_add_on_event_callback(kaa_event_manager_t *self, const char *fqn,
- kaa_event_callback_t callback);
-
-kaa_error_t kaa_event_request_get_size(kaa_event_manager_t *self, size_t *expected_size);
-kaa_error_t kaa_event_request_serialize(kaa_event_manager_t *self, size_t request_id,
- kaa_platform_message_writer_t *writer);
-kaa_error_t kaa_event_handle_server_sync(kaa_event_manager_t *self, kaa_platform_message_reader_t *reader, uint16_t extension_options, size_t extension_length, size_t request_id);
-
-#endif /* KAA_EVENT_PRIVATE_H */
diff --git a/client/client-multi/client-c/src/extensions/event/test/test_kaa_event.c b/client/client-multi/client-c/src/extensions/event/test/test_kaa_event.c
deleted file mode 100644
index 9c85460ada..0000000000
--- a/client/client-multi/client-c/src/extensions/event/test/test_kaa_event.c
+++ /dev/null
@@ -1,659 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include
-#include
-#include
-
-#include "platform/ext_sha.h"
-#include "kaa_event.h"
-#include "kaa_event_private.h"
-
-#include "kaa_test.h"
-
-#include "kaa_context.h"
-#include "utilities/kaa_log.h"
-#include "utilities/kaa_mem.h"
-#include "kaa_status.h"
-#include "kaa_channel_manager.h"
-#include "kaa_platform_utils.h"
-#include "platform/sock.h"
-
-#include "kaa_private.h"
-
-
-static int global_events_counter = 0;
-static int specific_events_counter = 0;
-
-static kaa_context_t kaa_context;
-static kaa_logger_t *logger = NULL;
-static kaa_status_t *status = NULL;
-static kaa_channel_manager_t *channel_manager = NULL;
-static kaa_event_manager_t *event_manager = NULL;
-
-
-
-static int test_init(void);
-static int test_deinit(void);
-
-
-
-void test_kaa_create_event_manager(void **state)
-{
- (void)state;
-
- kaa_status_t* status = NULL;
- kaa_status_create(&status);
- kaa_event_manager_t *event_manager = NULL;
- kaa_error_t err_code = kaa_event_manager_create(&event_manager, status, NULL, logger);
- ASSERT_EQUAL(err_code, KAA_ERR_NONE);
- ASSERT_NOT_NULL(event_manager);
- kaa_event_manager_destroy(event_manager);
-
- KAA_FREE(status);
-}
-
-static kaa_endpoint_id endpoint_id1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
-static kaa_endpoint_id endpoint_id2 = { 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 };
-static bool is_event_listeners_cb_called = false;
-
-static kaa_error_t event_listeners_callback(void *context, const kaa_endpoint_id listeners[], size_t listeners_count)
-{
- (void)context;
- ASSERT_EQUAL(listeners_count, 2);
- ASSERT_EQUAL(memcmp(listeners[0], endpoint_id1, KAA_ENDPOINT_ID_LENGTH), 0);
- ASSERT_EQUAL(memcmp(listeners[1], endpoint_id2, KAA_ENDPOINT_ID_LENGTH), 0);
- is_event_listeners_cb_called = true;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t event_listeners_request_failed(void *context)
-{
- (void)context;
- return KAA_ERR_NONE;
-}
-
-void test_kaa_event_listeners_serialize_request(void **state)
-{
- (void)state;
-
- size_t expected_size = KAA_EXTENSION_HEADER_SIZE + sizeof(uint32_t); // header + field id + reserved + listeners count
- expected_size += sizeof(uint32_t); // request id + fqns count
- expected_size += 2 * sizeof(uint32_t); // fqn length + reserved
-
- const char *fqns[] = { "test.fqn1", "test.fqn2" };
- const size_t fqn1_len = strlen(fqns[0]);
- const size_t fqn2_len = strlen(fqns[1]);
-
- expected_size += kaa_aligned_size_get(fqn1_len) + kaa_aligned_size_get(fqn2_len);
-
- kaa_event_listeners_callback_t callback = { NULL, NULL, NULL };
- ASSERT_NOT_EQUAL(kaa_event_manager_find_event_listeners(event_manager, fqns, 2, &callback), KAA_ERR_NONE);
-
- callback = (kaa_event_listeners_callback_t) { NULL, &event_listeners_callback, &event_listeners_request_failed };
- ASSERT_EQUAL(kaa_event_manager_find_event_listeners(event_manager, fqns, 2, &callback), KAA_ERR_NONE);
-
- size_t actual_size = 0;
- ASSERT_EQUAL(kaa_event_request_get_size(event_manager, &actual_size), KAA_ERR_NONE);
- ASSERT_EQUAL(actual_size, expected_size);
-
- uint8_t buffer[actual_size];
- kaa_platform_message_writer_t *writer;
- ASSERT_EQUAL(kaa_platform_message_writer_create(&writer, buffer, actual_size), KAA_ERR_NONE);
-
- ASSERT_EQUAL(kaa_event_request_serialize(event_manager, 1, writer), KAA_ERR_NONE);
-
- uint8_t *cursor = buffer + KAA_EXTENSION_HEADER_SIZE;
- ASSERT_EQUAL((*(uint8_t *) cursor), 0); // verifying field id 0
- cursor += sizeof(uint16_t); // skipping field id + reserved
-
- ASSERT_EQUAL(KAA_NTOHS(*(uint16_t *) cursor), 1); // verifying listeners count = 1
- cursor += sizeof(uint16_t);
-
- ASSERT_EQUAL(KAA_NTOHS(*(uint16_t *) cursor), 1); // verifying request id = 1
- cursor += sizeof(uint16_t);
-
- ASSERT_EQUAL(KAA_NTOHS(*(uint16_t *) cursor), 2); // verifying FQNs count = 2
- cursor += sizeof(uint16_t);
-
- ASSERT_EQUAL(KAA_NTOHS(*(uint16_t *) cursor), fqn1_len); // verifying FQN 1 length
- cursor += sizeof(uint32_t); // skipping FQN length + reserved
-
- ASSERT_EQUAL(memcmp(cursor, fqns[0], fqn1_len), 0); // verifying FQN 1
- cursor += kaa_aligned_size_get(fqn1_len);
-
- ASSERT_EQUAL(KAA_NTOHS(*(uint16_t *) cursor), fqn2_len); // verifying FQN 2 length
- cursor += sizeof(uint32_t); // skipping FQN length + reserved
-
- ASSERT_EQUAL(memcmp(cursor, fqns[1], fqn2_len), 0); // verifying FQN 2
- cursor += kaa_aligned_size_get(fqn2_len);
-
- ASSERT_EQUAL(cursor, buffer + actual_size);
-
- kaa_platform_message_writer_destroy(writer);
-}
-
-void test_kaa_event_listeners_handle_sync(void **state)
-{
- (void)state;
-
- const uint32_t extension_size = 52;
- uint8_t buffer[extension_size];
-
- uint8_t *cursor = buffer;
- *cursor = 0; // field id (0)
- cursor += sizeof(uint16_t); // skipping field id + reserved
-
- *((uint16_t *) cursor) = KAA_HTONS(1); // responses count = 1
- cursor += sizeof(uint16_t);
-
- *((uint16_t *) cursor) = KAA_HTONS(1); // request id = 1
- cursor += sizeof(uint16_t);
-
- *((uint16_t *) cursor) = KAA_HTONS(0); // listener result = 0 (SUCCESS)
- cursor += sizeof(uint16_t);
-
- *((uint32_t *) cursor) = KAA_HTONL(2); // listener count = 2
- cursor += sizeof(uint32_t);
-
- memcpy(cursor, endpoint_id1, KAA_ENDPOINT_ID_LENGTH); // copying endpoint id 1
- cursor += KAA_ENDPOINT_ID_LENGTH;
-
- memcpy(cursor, endpoint_id2, KAA_ENDPOINT_ID_LENGTH); // copying endpoint id 2
- cursor += KAA_ENDPOINT_ID_LENGTH;
-
- ASSERT_EQUAL(cursor, buffer + extension_size);
-
- kaa_platform_message_reader_t *reader;
- ASSERT_EQUAL(kaa_platform_message_reader_create(&reader, buffer, extension_size), KAA_ERR_NONE);
-
- ASSERT_FALSE(is_event_listeners_cb_called);
- ASSERT_EQUAL(kaa_event_handle_server_sync(event_manager, reader, 0, extension_size, 1), KAA_ERR_NONE);
- ASSERT_TRUE(is_event_listeners_cb_called);
- ASSERT_EQUAL(reader->current, reader->end);
-
- // Verifying that callback was removed from the manager
- is_event_listeners_cb_called = false;
- reader->current = reader->begin;
- ASSERT_EQUAL(kaa_event_handle_server_sync(event_manager, reader, 0, extension_size, 1), KAA_ERR_NONE);
- ASSERT_FALSE(is_event_listeners_cb_called);
-
- kaa_platform_message_reader_destroy(reader);
-}
-
-void test_kaa_event_sync_get_size(void **state)
-{
- (void)state;
-
- kaa_error_t error_code;
- size_t expected_size = KAA_EXTENSION_HEADER_SIZE
- + sizeof(uint8_t)
- + sizeof(uint8_t)
- + sizeof(uint16_t);
-
- const char *fqn = "test fqn";
- const size_t fqn_len = strlen(fqn);
-
- const size_t event_data_size = 16;
- /**
- * Allocated data will be freed automatically.
- */
- const char *event_data = (const char *) KAA_MALLOC(event_data_size);
-
- kaa_endpoint_id target = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
-
- const size_t buffer_size = KAA_EXTENSION_HEADER_SIZE + sizeof(uint32_t);
- uint8_t buffer[buffer_size];
- kaa_platform_message_writer_t *writer;
- error_code = kaa_platform_message_writer_create(&writer, buffer, buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- const uint32_t sequence_number = KAA_HTONL(12345);
- error_code = kaa_platform_message_write(writer, &sequence_number, sizeof(uint32_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_platform_message_reader_t *reader;
- error_code = kaa_platform_message_reader_create(&reader, buffer, buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_event_manager_send_event(event_manager, fqn, event_data, event_data_size, target);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- expected_size += sizeof(uint32_t)
- + sizeof(uint16_t)
- + sizeof(uint16_t)
- + sizeof(uint32_t)
- + KAA_ENDPOINT_ID_LENGTH
- + kaa_aligned_size_get(fqn_len)
- + kaa_aligned_size_get(event_data_size);
-
- error_code = kaa_event_manager_send_event(event_manager, fqn, NULL, 0, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- expected_size += sizeof(uint32_t)
- + sizeof(uint16_t)
- + sizeof(uint16_t)
- + kaa_aligned_size_get(fqn_len);
-
- size_t event_sync_size;
- error_code = kaa_event_request_get_size(event_manager, &event_sync_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- ASSERT_EQUAL(event_sync_size, KAA_EXTENSION_HEADER_SIZE);
-
- error_code = kaa_event_handle_server_sync(event_manager, reader, 0x1, sizeof(uint32_t), 1);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_event_request_get_size(event_manager, &event_sync_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_EQUAL(event_sync_size, expected_size);
-
- kaa_platform_message_writer_destroy(writer);
- kaa_platform_message_reader_destroy(reader);
-}
-
-static kaa_error_t serialize_event(kaa_platform_message_writer_t *writer
- , const char *fqn
- , const char *event_data
- , size_t event_data_size
- , kaa_endpoint_id_p target
- , size_t sequence_number
- , bool need_sequence_number)
-{
- KAA_RETURN_IF_NIL2(writer, fqn, KAA_ERR_BADPARAM);
-
- kaa_error_t error_code;
-
- uint16_t event_options = (event_data ? 0x2 : 0) | (target ? 0x1 : 0);
- uint16_t fqn_len = strlen(fqn);
-
- uint16_t network_order_16;
- uint32_t network_order_32;
-
- if (need_sequence_number) {
- network_order_32 = KAA_HTONL(sequence_number);
- error_code = kaa_platform_message_write(writer, &network_order_32, sizeof(uint32_t));
- KAA_RETURN_IF_ERR(error_code);
- }
-
- network_order_16 = KAA_HTONS(event_options);
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
-
- network_order_16 = KAA_HTONS(fqn_len);
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
-
- if (event_data) {
- network_order_32 = KAA_HTONL(event_data_size);
- error_code = kaa_platform_message_write(writer, &network_order_32, sizeof(uint32_t));
- KAA_RETURN_IF_ERR(error_code);
- }
-
- if (target) {
- error_code = kaa_platform_message_write_aligned(writer, target, KAA_ENDPOINT_ID_LENGTH);
- KAA_RETURN_IF_ERR(error_code);
- }
-
- error_code = kaa_platform_message_write_aligned(writer, fqn, fqn_len);
- KAA_RETURN_IF_ERR(error_code);
-
- if (event_data) {
- error_code = kaa_platform_message_write_aligned(writer, event_data, event_data_size);
- KAA_RETURN_IF_ERR(error_code);
- }
-
- return error_code;
-}
-
-
-
-void test_event_sync_serialize(void **state)
-{
- (void)state;
- test_deinit();
- test_init();
-
- kaa_error_t error_code;
-
- const uint8_t event_field = 1;
- const uint8_t reserved_field = 0;
- uint16_t event_count = 0;
-
- const char *fqn = "test fqn";
- /**
- * Allocated data will be freed automatically.
- */
- const size_t event_data_size = 16;
- const char *event_data = (const char *) KAA_MALLOC(event_data_size);
-
- kaa_endpoint_id target = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
-
- const size_t server_sync_buffer_size = KAA_EXTENSION_HEADER_SIZE + sizeof(uint32_t);
- uint8_t server_sync_buffer[server_sync_buffer_size];
- kaa_platform_message_writer_t *server_sync_writer;
- error_code = kaa_platform_message_writer_create(&server_sync_writer, server_sync_buffer, server_sync_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint32_t sequence_number = KAA_HTONL(12345);
- error_code = kaa_platform_message_write(server_sync_writer, &sequence_number, sizeof(uint32_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- sequence_number = KAA_NTOHL(sequence_number);
-
- kaa_platform_message_reader_t *server_sync_reader;
- error_code = kaa_platform_message_reader_create(&server_sync_reader, server_sync_buffer, server_sync_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_event_handle_server_sync(event_manager, server_sync_reader, 0x1, sizeof(uint32_t), 1);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_event_manager_send_event(event_manager, fqn, event_data, event_data_size, target);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ++event_count;
- error_code = kaa_event_manager_send_event(event_manager, fqn, NULL, 0, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ++event_count;
-
- size_t event_sync_size = 0;
- error_code = kaa_event_request_get_size(event_manager, &event_sync_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint8_t manual_buffer[event_sync_size];
- uint8_t auto_buffer[event_sync_size];
-
- uint8_t *manual_buffer_ptr = manual_buffer;
- uint8_t *auto_buffer_ptr = auto_buffer;
-
- kaa_platform_message_writer_t *manual_writer;
- error_code = kaa_platform_message_writer_create(&manual_writer, manual_buffer, event_sync_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- kaa_platform_message_writer_t *auto_writer;
- error_code = kaa_platform_message_writer_create(&auto_writer, auto_buffer, event_sync_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_platform_message_write_extension_header(manual_writer
- , KAA_EXTENSION_EVENT
- , 0x1
- , event_sync_size - KAA_EXTENSION_HEADER_SIZE);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- error_code = kaa_platform_message_write(manual_writer, &event_field, sizeof(uint8_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- error_code = kaa_platform_message_write(manual_writer, &reserved_field, sizeof(uint8_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- event_count = KAA_HTONS(event_count);
- error_code = kaa_platform_message_write(manual_writer, &event_count, sizeof(uint16_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = serialize_event(manual_writer, fqn, event_data, event_data_size, target, ++sequence_number, true);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- error_code = serialize_event(manual_writer, fqn, NULL, 0, NULL, ++sequence_number, true);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_event_request_serialize(event_manager, 1, auto_writer);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = (memcmp(auto_buffer_ptr, manual_buffer_ptr, KAA_EXTENSION_HEADER_SIZE) == 0 ? KAA_ERR_NONE : KAA_ERR_BADDATA);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- auto_buffer_ptr += KAA_EXTENSION_HEADER_SIZE;
- manual_buffer_ptr += KAA_EXTENSION_HEADER_SIZE;
- event_sync_size -= KAA_EXTENSION_HEADER_SIZE;
-
- ASSERT_EQUAL(*auto_buffer_ptr, *manual_buffer_ptr);
-
- auto_buffer_ptr += sizeof(uint16_t);
- manual_buffer_ptr += sizeof(uint16_t);
- event_sync_size -= sizeof(uint16_t);
-
- error_code = (memcmp(auto_buffer_ptr, manual_buffer_ptr, event_sync_size) == 0 ? KAA_ERR_NONE : KAA_ERR_BADDATA);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_platform_message_writer_destroy(manual_writer);
- kaa_platform_message_writer_destroy(auto_writer);
- kaa_platform_message_reader_destroy(server_sync_reader);
- kaa_platform_message_writer_destroy(server_sync_writer);
-}
-
-
-
-void global_event_cb(const char *fqn, const char *data, size_t size, kaa_endpoint_id_p source)
-{
- (void)fqn;
- (void)data;
- (void)size;
- (void)source;
- global_events_counter++;
-}
-
-
-
-void specific_event_cb(const char *fqn, const char *data, size_t size, kaa_endpoint_id_p source)
-{
- (void)fqn;
- (void)data;
- (void)size;
- (void)source;
- specific_events_counter++;
-}
-
-static size_t event_get_size(const char *fqn
- , const char *event_data
- , size_t event_data_size
- , kaa_endpoint_id_p source)
-{
- (void)source;
- size_t size = 0;
-
- size += sizeof(uint16_t) /* event options */
- + sizeof(uint16_t); /* fqn */
-
- if (event_data) {
- size += sizeof(uint32_t);
- }
-
- size += KAA_ENDPOINT_ID_LENGTH
- + kaa_aligned_size_get(strlen(fqn));
-
- if (event_data) {
- size += kaa_aligned_size_get(event_data_size);
- }
-
- return size;
-}
-
-void test_event_blocks(void **state)
-{
- (void)state;
-
- test_deinit();
- test_init();
-
- size_t server_sync_buffer_size = sizeof(uint32_t);
-
- uint8_t server_sync_buffer[server_sync_buffer_size];
- memset(server_sync_buffer, 0, server_sync_buffer_size);
-
- kaa_platform_message_reader_t *server_sync_reader;
- kaa_error_t error_code = kaa_platform_message_reader_create(&server_sync_reader, server_sync_buffer, server_sync_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- // Synchronizing sequence number
- error_code = kaa_event_handle_server_sync(event_manager, server_sync_reader, 0x01, server_sync_buffer_size, 1);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_event_block_id trx_id = 0;
- error_code = kaa_event_create_transaction(event_manager, &trx_id);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_TRUE(trx_id);
-
- const size_t event1_size = 6;
- char *event1 = (char *) KAA_MALLOC(event1_size + 1);
- strcpy(event1, "event1");
- error_code = kaa_event_manager_add_event_to_transaction(event_manager, trx_id, "test.fqn1", event1, event1_size, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- const size_t event2_size = 6;
- char *event2 = (char *) KAA_MALLOC(event2_size + 1);
- strcpy(event2, "event2");
- error_code = kaa_event_manager_add_event_to_transaction(event_manager, trx_id, "test.fqn2", event2, event2_size, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_event_manager_add_event_to_transaction(event_manager, trx_id, "test.fqn3", NULL, 0, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_event_finish_transaction(event_manager, trx_id);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- size_t expected_size = KAA_EXTENSION_HEADER_SIZE
- + sizeof(uint32_t) // Events count
- + 3 * sizeof(uint32_t) // Event sequence numbers
- + 3 * sizeof(uint32_t) // Event options + FQN length
- + 2 * sizeof(uint32_t) // Event data sizes
- + kaa_aligned_size_get(event1_size) + kaa_aligned_size_get(strlen("test.fqn1"))
- + kaa_aligned_size_get(event2_size) + kaa_aligned_size_get(strlen("test.fqn2"))
- + kaa_aligned_size_get(strlen("test.fqn3"));
-
- size_t request_size = 0;
- error_code = kaa_event_request_get_size(event_manager, &request_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_EQUAL(request_size, expected_size);
-
- kaa_platform_message_reader_destroy(server_sync_reader);
-}
-
-void test_kaa_server_sync_with_event_callbacks(void **state)
-{
- (void)state;
-
- test_deinit();
- test_init();
-
- kaa_error_t error_code;
-
- const uint8_t event_field = 1;
- const uint8_t reserved_field = 0;
- uint16_t event_count = 2;
-
- const char *important_fqn = "important fqn";
- const char *unimportant_fqn = "unimportant fqn";
-
- /**
- * Allocated data will be freed automatically.
- */
- const size_t event_data_size = 14;
- const char *event_data = (const char *) KAA_MALLOC(event_data_size);
-
- kaa_endpoint_id source = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
-
- error_code = kaa_event_manager_add_on_event_callback(event_manager, important_fqn, specific_event_cb);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- error_code = kaa_event_manager_add_on_event_callback(event_manager, NULL, global_event_cb);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- size_t server_sync_buffer_size = 0;
-
- server_sync_buffer_size += sizeof(uint32_t)
- + sizeof(uint8_t)
- + sizeof(uint8_t)
- + sizeof(uint16_t)
- + event_get_size(unimportant_fqn, NULL, 0, source)
- + event_get_size(important_fqn, event_data, event_data_size, source);
-
- uint8_t server_sync_buffer[server_sync_buffer_size];
- kaa_platform_message_writer_t *server_sync_writer;
- error_code = kaa_platform_message_writer_create(&server_sync_writer, server_sync_buffer, server_sync_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint32_t sequence_number = KAA_HTONL(12345);
- error_code = kaa_platform_message_write(server_sync_writer, &sequence_number, sizeof(uint32_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- sequence_number = KAA_NTOHL(sequence_number);
-
- error_code = kaa_platform_message_write(server_sync_writer, &event_field, sizeof(uint8_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_platform_message_write(server_sync_writer, &reserved_field, sizeof(uint8_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- event_count = KAA_HTONS(event_count);
- error_code = kaa_platform_message_write(server_sync_writer, &event_count, sizeof(uint16_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = serialize_event(server_sync_writer, unimportant_fqn, NULL, 0, source, 0, false);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = serialize_event(server_sync_writer, important_fqn, event_data, event_data_size, source, 0, false);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_platform_message_reader_t *server_sync_reader;
- error_code = kaa_platform_message_reader_create(&server_sync_reader, server_sync_buffer, server_sync_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_event_handle_server_sync(event_manager, server_sync_reader, 0x1, server_sync_buffer_size, 1);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- ASSERT_EQUAL(global_events_counter, 1);
- ASSERT_EQUAL(specific_events_counter, 1);
-
- kaa_platform_message_reader_destroy(server_sync_reader);
- kaa_platform_message_writer_destroy(server_sync_writer);
- KAA_FREE((void *) event_data);
-}
-
-static int test_init(void)
-{
- kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
- if (error || !logger) {
- return error;
- }
-
- kaa_context.logger = logger;
-
- error = kaa_status_create(&status);
- if (error || !status) {
- return error;
- }
-
- error = kaa_channel_manager_create(&channel_manager, &kaa_context);
- if (error || !channel_manager) {
- return error;
- }
-
- error = kaa_event_manager_create(&event_manager, status, channel_manager, logger);
- if (error || !event_manager) {
- return error;
- }
- return 0;
-}
-
-
-
-static int test_deinit(void)
-{
- kaa_event_manager_destroy(event_manager);
- kaa_channel_manager_destroy(channel_manager);
- kaa_status_destroy(status);
- kaa_log_destroy(logger);
- return 0;
-}
-
-KAA_SUITE_MAIN(Event, test_init, test_deinit,
- KAA_TEST_CASE(create_event_manager, test_kaa_create_event_manager)
- KAA_TEST_CASE(compile_event_request, test_kaa_event_sync_get_size)
- KAA_TEST_CASE(event_sync_serialize, test_event_sync_serialize)
- KAA_TEST_CASE(add_on_event_callback, test_kaa_server_sync_with_event_callbacks)
- KAA_TEST_CASE(event_listeners_serialize_request, test_kaa_event_listeners_serialize_request)
- KAA_TEST_CASE(event_listeners_handle_sync, test_kaa_event_listeners_handle_sync)
- KAA_TEST_CASE(event_test_blocks, test_event_blocks))
diff --git a/client/client-multi/client-c/src/extensions/logging/CMakeLists.txt b/client/client-multi/client-c/src/extensions/logging/CMakeLists.txt
deleted file mode 100644
index 3eb2dbb0c8..0000000000
--- a/client/client-multi/client-c/src/extensions/logging/CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set(EXTENSION_LOGGING_SOURCE_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_logging.c)
-
-set(EXTENSION_LOGGING_HEADER_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_logging.h)
-
-add_library(extension_logging ${EXTENSION_LOGGING_SOURCE_FILES})
-target_include_directories(extension_logging PUBLIC ${CMAKE_CURRENT_LIST_DIR})
-target_link_libraries(extension_logging PUBLIC kaac)
-
-kaa_add_unit_test(NAME test_log
- SOURCES
- ${CMAKE_CURRENT_LIST_DIR}/test/test_kaa_log.c
- test/kaa_test_external.c
- ${KAA_SRC_FOLDER}/gen/kaa_logging_gen.c
- ${KAA_SRC_FOLDER}/avro_src/io.c
- ${KAA_SRC_FOLDER}/avro_src/encoding_binary.c
- ${KAA_SRC_FOLDER}/collections/kaa_list.c
- ${KAA_SRC_FOLDER}/utilities/kaa_log.c
- ${KAA_SRC_FOLDER}/platform-impl/posix/logger.c
- ${KAA_SRC_FOLDER}/kaa_platform_utils.c
- ${KAA_SRC_FOLDER}/kaa_channel_manager.c
- ${KAA_SRC_FOLDER}/kaa_common_schema.c
- ${KAA_SRC_FOLDER}/kaa_status.c
- ${KAA_SRC_FOLDER}/platform-impl/common/kaa_failover_strategy.c
- DEPENDS
- kaac extension_logging)
diff --git a/client/client-multi/client-c/src/extensions/logging/kaa_logging.c b/client/client-multi/client-c/src/extensions/logging/kaa_logging.c
deleted file mode 100644
index e323164d10..0000000000
--- a/client/client-multi/client-c/src/extensions/logging/kaa_logging.c
+++ /dev/null
@@ -1,844 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_logging_private.h"
-#include "kaa_logging.h"
-
-#include "kaa_private.h"
-
-#include
-#include
-#include
-#include "platform/stdio.h"
-#include "platform/sock.h"
-#include "platform/time.h"
-#include "platform/ext_sha.h"
-#include "collections/kaa_list.h"
-#include "kaa_common.h"
-#include "kaa_status.h"
-#include "kaa_channel_manager.h"
-#include "kaa_platform_utils.h"
-#include "kaa_platform_common.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-#include "avro_src/avro/io.h"
-
-#define KAA_LOGGING_RECEIVE_UPDATES_FLAG 0x01
-#define KAA_MAX_PADDING_LENGTH (KAA_ALIGNMENT - 1)
-
-typedef enum {
- LOGGING_RESULT_SUCCESS = 0x00,
- LOGGING_RESULT_FAILURE = 0x01
-} logging_sync_result_t;
-
-typedef struct {
- /** Bucket must be threated as expired after this deadline.
- * Already expired buckets marked with deadline equal to 0.
- */
- kaa_time_t deadline;
- uint16_t log_bucket_id; /**< ID of bucket present in storage. */
- uint16_t log_count; /**< Current logs count. */
-} timeout_info_t;
-
-typedef struct {
- size_t size; /**< Bucket size in bytes. */
- size_t log_count; /**< Count of logs in bucket. */
- uint16_t id; /**< Bucket id. */
-} last_bucket_info_t;
-
-struct kaa_log_collector_t {
- kaa_log_bucket_constraints_t bucket_size;
- void *log_storage_context;
- void *log_upload_strategy_context;
- kaa_status_t *status;
- kaa_channel_manager_t *channel_manager;
- kaa_logger_t *logger;
- kaa_list_t *timeouts;
- kaa_log_delivery_listener_t log_delivery_listeners;
- bool is_sync_ignored;
- uint32_t log_last_id; /**< Last log record ID */
- uint16_t log_bucket_id;
- last_bucket_info_t last_bucket;
-};
-
-static const kaa_extension_id logging_sync_services[] = {KAA_EXTENSION_LOGGING};
-
-kaa_error_t kaa_extension_logging_init(kaa_context_t *kaa_context, void **context)
-{
- kaa_error_t error = kaa_log_collector_create(&kaa_context->log_collector,
- kaa_context->status->status_instance,
- kaa_context->channel_manager, kaa_context->logger);
- *context = kaa_context->log_collector;
- return error;
-}
-
-kaa_error_t kaa_extension_logging_deinit(void *context)
-{
- kaa_log_collector_destroy(context);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_logging_request_get_size(void *context, size_t *expected_size)
-{
- return kaa_logging_request_get_size(context, expected_size);
-}
-
-kaa_error_t kaa_extension_logging_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync)
-{
- (void)request_id;
-
- // TODO(KAA-982): Use asserts
- if (!context || !size || !need_resync) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_error_t error;
-
- size_t size_needed;
- error = kaa_logging_request_get_size(context, &size_needed);
- if (error) {
- return error;
- }
-
- *need_resync = false;
- error = kaa_logging_need_logging_resync(context, need_resync);
- if (error) {
- return error;
- }
-
- if (!*need_resync) {
- *size = 0;
- return KAA_ERR_NONE;
- }
-
- if (!buffer || *size < size_needed) {
- *size = size_needed;
- return KAA_ERR_BUFFER_IS_NOT_ENOUGH;
- }
-
- *size = size_needed;
-
- kaa_platform_message_writer_t writer = KAA_MESSAGE_WRITER(buffer, *size);
- error = kaa_logging_request_serialize(context, &writer);
- if (error) {
- return error;
- }
-
- *size = writer.current - buffer;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_logging_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size)
-{
- (void)request_id;
-
- // TODO(KAA-982): Use asserts
- if (!context || !buffer) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_platform_message_reader_t reader = KAA_MESSAGE_READER(buffer, size);
- return kaa_logging_handle_server_sync(context, &reader, extension_options, size);
-}
-
-kaa_error_t kaa_logging_need_logging_resync(kaa_log_collector_t *self, bool *result)
-{
- // TODO(KAA-982): Use asserts
- if (!self || !result) {
- return KAA_ERR_BADPARAM;
- }
-
- if (self->is_sync_ignored) {
- *result = false;
- return KAA_ERR_NONE;
- }
-
- *result = true;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t remember_request(kaa_log_collector_t *self, uint16_t bucket_id, uint16_t count)
-{
- // TODO(KAA-982): Use asserts
- if (!self) {
- return KAA_ERR_BADPARAM;
- }
-
- timeout_info_t *info = KAA_MALLOC(sizeof(*info));
- if (!info) {
- return KAA_ERR_NOMEM;
- }
-
- info->log_bucket_id = bucket_id;
- info->deadline = KAA_TIME() + (kaa_time_t)ext_log_upload_strategy_get_timeout(self->log_upload_strategy_context);
- info->log_count = count;
-
- kaa_list_node_t *it = kaa_list_push_back(self->timeouts, info);
- if (!it) {
- KAA_FREE(info);
- return KAA_ERR_NOMEM;
- }
-
- return KAA_ERR_NONE;
-}
-
-static bool find_by_bucket_id(void *data, void *context)
-{
- // TODO(KAA-982): Use asserts
- if (!data || !context) {
- return false;
- }
-
- uint16_t bucket_id = *(uint16_t *) context;
- timeout_info_t *timeout_info = data;
-
- if (timeout_info->log_bucket_id == bucket_id) {
- return true;
- }
-
- return false;
-}
-
-
-/* Returns amount of logs in bucket */
-static size_t remove_request(kaa_log_collector_t *self, uint16_t bucket_id)
-{
- kaa_list_node_t *node;
- timeout_info_t *info;
- size_t logs_sent = 0;
-
- node = kaa_list_find_next(kaa_list_begin(self->timeouts), find_by_bucket_id, &bucket_id);
-
- if (node) {
- info = kaa_list_get_data(node);
-
- if (info) {
- logs_sent = info->log_count;
- }
-
- kaa_list_remove_at(self->timeouts, node, NULL);
- }
-
- return logs_sent;
-}
-
-/** Handles timeout event. Must be called if timeout is occurred. */
-static void handle_timeout(kaa_log_collector_t *self)
-{
- // TODO(KAA-982): Use asserts
- if (!self || !self->timeouts) {
- return;
- }
-
- kaa_error_t err = ext_log_upload_strategy_on_timeout(self->log_upload_strategy_context);
-
- bool expire_every_entry = (err == KAA_ERR_EVENT_NOT_ATTACHED);
-
- if (expire_every_entry) {
- /* Upload strategy decided to switch an access point. All pending logs are now deemed as
- * timeouted.
- */
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Access point has been switched. All buckets are expired.");
- }
-
- for (kaa_list_node_t *it = kaa_list_begin(self->timeouts); it; it = kaa_list_next(it)) {
- timeout_info_t *info = kaa_list_get_data(it);
-
- if (expire_every_entry || !info->deadline) {
- ext_log_storage_unmark_by_bucket_id(self->log_storage_context, info->log_bucket_id);
- if (self->log_delivery_listeners.on_timeout) {
- kaa_log_bucket_info_t log_bucket_info = {
- .bucket_id = info->log_bucket_id,
- .log_count = info->log_count,
- };
-
- self->log_delivery_listeners.on_timeout(self->log_delivery_listeners.ctx,
- &log_bucket_info);
- }
- }
- }
-
- kaa_list_clear(self->timeouts, NULL);
-}
-
-static bool is_timeout(kaa_log_collector_t *self)
-{
- kaa_time_t now = KAA_TIME();
- bool timeout_occur = false;
-
- for (kaa_list_node_t *it = kaa_list_begin(self->timeouts); it; it = kaa_list_next(it)) {
- timeout_info_t *info = kaa_list_get_data(it);
- if (now >= info->deadline) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_TIMEOUT,
- "Log delivery timeout occurred (bucket_id %u)", info->log_bucket_id);
- timeout_occur = true;
- /* Mark bucket as expired */
- info->deadline = 0;
- }
- }
-
- return timeout_occur;
-}
-
-static bool is_upload_allowed(kaa_log_collector_t *self)
-{
- size_t pendingCount = kaa_list_get_size(self->timeouts);
- size_t allowedCount = ext_log_upload_strategy_get_max_parallel_uploads(self->log_upload_strategy_context);
-
- if (pendingCount >= allowedCount) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Ignore log upload: too much pending requests %zu, max allowed %zu",
- pendingCount, allowedCount);
- return false;
- }
-
- return true;
-}
-
-/** @deprecated Use kaa_extension_logging_deinit(). */
-void kaa_log_collector_destroy(kaa_log_collector_t *self)
-{
- // TODO(KAA-982): Use asserts
- if (!self) {
- return;
- }
-
- ext_log_upload_strategy_destroy(self->log_upload_strategy_context);
- ext_log_storage_destroy(self->log_storage_context);
- kaa_list_destroy(self->timeouts, NULL);
- KAA_FREE(self);
-}
-
-/** @deprecated Use kaa_extension_logging_init(). */
-kaa_error_t kaa_log_collector_create(kaa_log_collector_t **log_collector_p,
- kaa_status_t *status, kaa_channel_manager_t *channel_manager, kaa_logger_t *logger)
-{
- // TODO(KAA-982): Use asserts
- if (!log_collector_p) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_log_collector_t *collector = KAA_MALLOC(sizeof(*collector));
- if (!collector) {
- return KAA_ERR_NOMEM;
- }
-
- collector->log_bucket_id = 0;
- collector->log_last_id = 0;
- collector->log_storage_context = NULL;
- collector->log_upload_strategy_context = NULL;
- collector->status = status;
- collector->channel_manager = channel_manager;
- collector->logger = logger;
- collector->is_sync_ignored = false;
- collector->last_bucket.log_count = 0;
- collector->last_bucket.size = 0;
- collector->last_bucket.id = 1;
-
- /* Must be overriden in _init() */
- collector->bucket_size.max_bucket_log_count = 0;
- collector->bucket_size.max_bucket_size = 0;
-
- collector->timeouts = kaa_list_create();
- if (!collector->timeouts) {
- KAA_FREE(collector);
- return KAA_ERR_NOMEM;
- }
-
- *log_collector_p = collector;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_logging_init(kaa_log_collector_t *self, void *log_storage_context,
- void *log_upload_strategy_context, const kaa_log_bucket_constraints_t *bucket_sizes)
-{
- // TODO(KAA-982): Use asserts
- if (!self || !log_storage_context || !log_upload_strategy_context) {
- return KAA_ERR_BADPARAM;
- }
-
- ext_log_storage_destroy(self->log_storage_context);
- ext_log_upload_strategy_destroy(self->log_upload_strategy_context);
-
- self->log_storage_context = log_storage_context;
- self->log_upload_strategy_context = log_upload_strategy_context;
- self->log_delivery_listeners = KAA_LOG_EMPTY_LISTENERS;
- self->bucket_size = *bucket_sizes;
-
- KAA_LOG_DEBUG(self->logger, KAA_ERR_NONE, "Initialized log collector with log storage {%p}, log upload strategy {%p}"
- , log_storage_context, log_upload_strategy_context);
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_logging_set_strategy(kaa_log_collector_t *self, void *log_upload_strategy_context)
-{
- // TODO(KAA-982): Use asserts
- if (!self || !log_upload_strategy_context) {
- return KAA_ERR_BADPARAM;
- }
-
- if (self->log_upload_strategy_context) {
- ext_log_upload_strategy_destroy(self->log_upload_strategy_context);
- }
-
- self->log_upload_strategy_context = log_upload_strategy_context;
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_logging_set_storage(kaa_log_collector_t *self, void *log_storage_context)
-{
- // TODO(KAA-982): Use asserts
- if (!self || !log_storage_context) {
- return KAA_ERR_BADPARAM;
- }
-
- if (self->log_storage_context) {
- ext_log_storage_destroy(self->log_storage_context);
- }
-
- self->log_storage_context = log_storage_context;
-
- return KAA_ERR_NONE;
-}
-
-static void do_sync(kaa_log_collector_t *self)
-{
- // TODO(KAA-982): Use asserts
- if (!self) {
- return;
- }
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Initiating log upload...");
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(self->channel_manager, logging_sync_services[0]);
- if (channel) {
- channel->sync_handler(channel->context, logging_sync_services, 1);
- }
-}
-
-static void update_storage(kaa_log_collector_t *self)
-{
- // TODO(KAA-982): Use asserts
- if (!self) {
- return;
- }
-
- switch (ext_log_upload_strategy_decide(self->log_upload_strategy_context, self->log_storage_context)) {
- case UPLOAD:
- if (is_upload_allowed(self)) {
- do_sync(self);
- }
- break;
- default:
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Upload will not be triggered now.");
- break;
- }
-}
-
-/** Checks if there is a place for a new record */
-static bool no_more_space_in_bucket(kaa_log_collector_t *self, kaa_log_record_t *new_record)
-{
- if (self->last_bucket.log_count + 1 > self->bucket_size.max_bucket_log_count
- || self->last_bucket.size + new_record->size > self->bucket_size.max_bucket_size) {
- return true;
- }
-
- return false;
-}
-
-/** Checks if the given bucket is the last bucket */
-static bool last_bucket(kaa_log_collector_t *self, uint16_t bucket)
-{
- return self->last_bucket.id == bucket;
-}
-
-/** Creates a new empty bucket */
-static void form_new_bucket(kaa_log_collector_t *self)
-{
- self->last_bucket.id++;
- // Avoid hitting reserved values
- if (!self->last_bucket.id) {
- self->last_bucket.id++;
- }
-
- self->last_bucket.log_count = 0;
- self->last_bucket.size = 0;
-}
-
-/** Puts the given record in the current bucket */
-static void place_record_in_current_bucket(kaa_log_collector_t *self, kaa_log_record_t *new_record)
-{
- new_record->bucket_id = self->last_bucket.id;
- self->last_bucket.log_count++;
- self->last_bucket.size += new_record->size;
-}
-
-/** Creates the next bucket and puts the given record there */
-static void place_record_in_next_bucket(kaa_log_collector_t *self, kaa_log_record_t *new_record)
-{
- form_new_bucket(self);
- place_record_in_current_bucket(self, new_record);
-}
-
-kaa_error_t kaa_logging_add_record(kaa_log_collector_t *self, kaa_user_log_record_t *entry, kaa_log_record_info_t *log_info)
-{
- // TODO(KAA-982): Use asserts
- if (!self || !entry) {
- return KAA_ERR_BADPARAM;
- }
-
- // TODO(KAA-982): Use asserts
- if (!self->log_storage_context) {
- return KAA_ERR_NOT_INITIALIZED;
- }
-
- // Bucket ID will be incremented only if it will be added without errors
- kaa_log_record_t record = {
- .data = NULL,
- .size = entry->get_size(entry),
- .bucket_id = 0,
- };
-
- if (!record.size) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_BADDATA,
- "Failed to add log record: serialized record size is null. "
- "Maybe log record schema is empty");
- return KAA_ERR_BADDATA;
- }
-
- bool next_bucket_required = no_more_space_in_bucket(self, &record);
-
- // To restore last bucket state in case of error
- last_bucket_info_t fallback = self->last_bucket;
-
- // Put log in the next bucket if required
- if (next_bucket_required) {
- place_record_in_next_bucket(self, &record);
- } else {
- place_record_in_current_bucket(self, &record);
- }
-
- kaa_error_t error = ext_log_storage_allocate_log_record_buffer(self->log_storage_context,
- &record);
- if (error) {
- KAA_LOG_ERROR(self->logger, error,
- "Failed to add log record: cannot allocate buffer for log record");
- goto err_buffer;
- }
-
- avro_writer_t writer = avro_writer_memory((char *)record.data, record.size);
- if (!writer) {
- error = KAA_ERR_NOMEM;
- KAA_LOG_ERROR(self->logger, error,
- "Failed to add log record: cannot create serializer");
- ext_log_storage_deallocate_log_record_buffer(self->log_storage_context, &record);
- goto err_avro;
- }
-
- entry->serialize(writer, entry);
- avro_writer_free(writer);
-
- error = ext_log_storage_add_log_record(self->log_storage_context, &record);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to add log record to storage");
- ext_log_storage_deallocate_log_record_buffer(self->log_storage_context, &record);
- goto err_add;
- }
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Added log record, size %zu, bucket %u",
- record.size,
- record.bucket_id);
-
- if (is_timeout(self)) {
- handle_timeout(self);
- } else {
- update_storage(self);
- }
-
- if (log_info) {
- log_info->bucket_id = self->last_bucket.id;
- log_info->log_id = self->log_last_id++;
- }
-
- return KAA_ERR_NONE;
-
-err_add:
-err_avro:
- ext_log_storage_deallocate_log_record_buffer(self->log_storage_context, &record);
-err_buffer:
- self->last_bucket = fallback;
- return error;
-}
-
-kaa_error_t kaa_logging_set_listeners(kaa_log_collector_t *self, const kaa_log_delivery_listener_t *listeners)
-{
- // TODO(KAA-982): Use asserts
- if (!self || !listeners) {
- return KAA_ERR_BADPARAM;
- }
-
- self->log_delivery_listeners = *listeners;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_logging_request_get_size(kaa_log_collector_t *self, size_t *expected_size)
-{
- // TODO(KAA-982): Use asserts
- if (!self || !expected_size) {
- return KAA_ERR_BADPARAM;
- }
-
- // TODO(KAA-982): Use asserts
- if (!self->log_storage_context) {
- return KAA_ERR_NOT_INITIALIZED;
- }
-
- *expected_size = 0;
-
- if (!is_upload_allowed(self)) {
- self->is_sync_ignored = true;
- return KAA_ERR_NONE;
- }
-
- size_t records_count = ext_log_storage_get_records_count(self->log_storage_context);
- size_t total_size = ext_log_storage_get_total_size(self->log_storage_context);
-
- self->is_sync_ignored = (!records_count || !total_size);
-
- if (!self->is_sync_ignored) {
- *expected_size = KAA_EXTENSION_HEADER_SIZE;
- *expected_size += sizeof(uint32_t); // request id + log records count
-
- size_t actual_size = records_count * sizeof(uint32_t) + records_count * KAA_MAX_PADDING_LENGTH + total_size;
- size_t bucket_size = self->bucket_size.max_bucket_size;
-
- *expected_size += ((actual_size > bucket_size) ? bucket_size : actual_size);
- }
-
- return KAA_ERR_NONE;
-}
-
-
-
-kaa_error_t kaa_logging_request_serialize(kaa_log_collector_t *self, kaa_platform_message_writer_t *writer)
-{
- // TODO(KAA-982): Use asserts
- if (!self || !writer) {
- return KAA_ERR_BADPARAM;
- }
-
- // TODO(KAA-982): Use asserts
- if (!self->log_storage_context) {
- return KAA_ERR_NOT_INITIALIZED;
- }
-
- if (self->is_sync_ignored) {
- return KAA_ERR_NONE;
- }
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize client logging sync");
-
- kaa_platform_message_writer_t tmp_writer = *writer;
-
- uint8_t *extension_size_p = tmp_writer.current + sizeof(uint32_t); // Pointer to the extension size. Will be filled in later.
- kaa_error_t error = kaa_platform_message_write_extension_header(&tmp_writer,
- KAA_EXTENSION_LOGGING,
- KAA_LOGGING_RECEIVE_UPDATES_FLAG,
- 0);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write log extension header");
- return KAA_ERR_WRITE_FAILED;
- }
-
- uint8_t *bucket_id_p = tmp_writer.current;
- tmp_writer.current += sizeof(uint16_t);
- uint8_t *records_count_p = tmp_writer.current; // Pointer to the records count. Will be filled in later.
- tmp_writer.current += sizeof(uint16_t);
-
- uint16_t bucket_id;
- uint16_t first_bucket = 0;
-
- /* Bucket size constraints */
-
- size_t bucket_size = self->bucket_size.max_bucket_size;
- size_t max_log_count = self->bucket_size.max_bucket_log_count;
- size_t actual_size = (tmp_writer.end - tmp_writer.current);
-
- bucket_size = (actual_size > bucket_size ? bucket_size : actual_size);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE,
- "Extracting log records... (bucket size %zu)", bucket_size);
-
- uint16_t records_count = 0;
-
- while (!error && bucket_size > sizeof(uint32_t) && records_count < max_log_count) {
- size_t record_len = 0;
- error = ext_log_storage_write_next_record(self->log_storage_context,
- (char *)tmp_writer.current + sizeof(uint32_t),
- bucket_size - sizeof(uint32_t),
- &bucket_id,
- &record_len);
-
- switch (error) {
- case KAA_ERR_NONE:
- if (first_bucket == 0) {
- first_bucket = bucket_id;
- } else if (bucket_id != first_bucket) {
- // Put back log item if it is in another bucket
- ext_log_storage_unmark_by_bucket_id(self->log_storage_context, bucket_id);
- break;
- }
-
- ++records_count;
- *((uint32_t *) tmp_writer.current) = KAA_HTONL(record_len);
- tmp_writer.current += (sizeof(uint32_t) + record_len);
- kaa_platform_message_write_alignment(&tmp_writer);
- bucket_size -= kaa_aligned_size_get(record_len) + sizeof(uint32_t);
- break;
- case KAA_ERR_NOT_FOUND:
- case KAA_ERR_INSUFFICIENT_BUFFER:
- // These errors are normal if they appear after at least one record got serialized
- if (!records_count) {
- KAA_LOG_ERROR(self->logger, error, "Failed to write the log record");
- return error;
- }
- break;
- default:
- KAA_LOG_ERROR(self->logger, error, "Failed to write the log record");
- return error;
- }
- }
-
- *((uint16_t *) bucket_id_p) = KAA_HTONS(first_bucket);
-
- size_t payload_size = tmp_writer.current - writer->current - KAA_EXTENSION_HEADER_SIZE;
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE,
- "Created log bucket: id '%u', log records count %u, payload size %zu",
- first_bucket, records_count, payload_size);
-
- *((uint32_t *) extension_size_p) = KAA_HTONL(payload_size);
- *((uint16_t *) records_count_p) = KAA_HTONS(records_count);
- *writer = tmp_writer;
-
- error = remember_request(self, first_bucket, records_count);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to remember request time stamp");
- }
-
- // Incomplete bucket sent, so let's go and step to the next bucket
- if (last_bucket(self, first_bucket)) {
- form_new_bucket(self);
- }
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_logging_handle_server_sync(kaa_log_collector_t *self,
- kaa_platform_message_reader_t *reader, uint16_t extension_options, size_t extension_length)
-{
- // Only used for logging
- (void)extension_options;
- (void)extension_length;
-
- // TODO(KAA-982): Use asserts
- if (!self || !reader) {
- return KAA_ERR_BADPARAM;
- }
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received logging server sync: options 0, payload size %u", extension_length);
-
- uint32_t delivery_status_count;
- kaa_error_t error_code = kaa_platform_message_read(reader, &delivery_status_count, sizeof(uint32_t));
- if (error_code) {
- return error_code;
- }
-
- delivery_status_count = KAA_NTOHL(delivery_status_count);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received %lu log delivery statuses", delivery_status_count);
-
- uint16_t bucket_id;
- int8_t delivery_result;
- int8_t delivery_error_code;
-
- for (uint32_t i = 0; i < delivery_status_count; ++i) {
- error_code = kaa_platform_message_read(reader, &bucket_id, sizeof(uint16_t));
- if (error_code) {
- return error_code;
- }
-
- bucket_id = KAA_NTOHS(bucket_id);
-
- error_code = kaa_platform_message_read(reader, &delivery_result, sizeof(int8_t));
- if (error_code) {
- return error_code;
- }
-
- error_code = kaa_platform_message_read(reader, &delivery_error_code, sizeof(int8_t));
- if (error_code) {
- return error_code;
- }
-
- if (delivery_result == LOGGING_RESULT_SUCCESS) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Log bucket uploaded successfully, id '%u'", bucket_id);
- } else {
- KAA_LOG_ERROR(self->logger, KAA_ERR_WRITE_FAILED,
- "Failed to upload log bucket, id '%u' (delivery error code '%u')",
- bucket_id, delivery_error_code);
- }
-
- size_t uploaded_count = remove_request(self, bucket_id);
-
- kaa_log_bucket_info_t log_bucket_info = {
- .log_count = uploaded_count,
- .bucket_id = bucket_id,
- };
-
- if (delivery_result == LOGGING_RESULT_SUCCESS) {
- if (self->log_delivery_listeners.on_success) {
- self->log_delivery_listeners.on_success(self->log_delivery_listeners.ctx,
- &log_bucket_info);
- }
- ext_log_storage_remove_by_bucket_id(self->log_storage_context, bucket_id);
- } else {
- if (self->log_delivery_listeners.on_failed) {
- self->log_delivery_listeners.on_failed(self->log_delivery_listeners.ctx,
- &log_bucket_info);
- }
- ext_log_storage_unmark_by_bucket_id(self->log_storage_context, bucket_id);
- ext_log_upload_strategy_on_failure(self->log_upload_strategy_context,
- (logging_delivery_error_code_t)delivery_error_code);
- }
- }
-
- update_storage(self);
-
- return error_code;
-}
-
-
-void ext_log_upload_timeout(kaa_log_collector_t *self)
-{
- if (!is_timeout(self)
- || ext_log_upload_strategy_is_timeout_strategy(self->log_upload_strategy_context)) {
- update_storage(self);
- } else {
- handle_timeout(self);
- }
-}
diff --git a/client/client-multi/client-c/src/extensions/logging/kaa_logging.h b/client/client-multi/client-c/src/extensions/logging/kaa_logging.h
deleted file mode 100644
index f9082e4ad3..0000000000
--- a/client/client-multi/client-c/src/extensions/logging/kaa_logging.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file kaa_logging.h
- * @brief Kaa data logging subsystem API
- *
- * Supplies API for Kaa data collection / logging subsystem.
- */
-
-#ifndef KAA_LOGGING_H_
-#define KAA_LOGGING_H_
-
-
-#include "gen/kaa_logging_definitions.h"
-#include "platform/ext_log_storage.h"
-#include "platform/ext_log_upload_strategy.h"
-#include "platform/ext_log_delivery_listener.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
- * Private log collector structure.
- */
-struct kaa_log_collector_t;
-typedef struct kaa_log_collector_t kaa_log_collector_t;
-
-/**
- * @brief Log record info.
- *
- * Each log is contained in the bucket. Bucket is used to agreggate
- * multiple logs into one entity that will be atomically sent to the server.
- * Bucket can either be entirely successfully sent or be entirely failed.
- * Corresponding events are generated. User may subscribe to them.
- * @sa kaa_log_event_fn
- * @sa kaa_log_listeners_t
- * @sa kaa_logging_set_listeners
- */
-typedef struct {
- uint32_t log_id; /**< Id of a log record processed by kaa_logging_add_record() */
- uint16_t bucket_id; /**< Id of a bucket where a log record contained */
-} kaa_log_record_info_t;
-
-/** Constraints applied to log buckets */
-typedef struct {
- size_t max_bucket_size; /**< The maximum bucket size in bytes */
- size_t max_bucket_log_count; /**< The maximum log count within a single bucket */
-} kaa_log_bucket_constraints_t;
-
-/**
- * @brief Initializes data collection module with the storage interface, upload strategy, and other settings.
- *
- * @param[in] self Pointer to a @link kaa_log_collector_t @endlink instance.
- * @param[in] log_storage_context Log storage context.
- * @param[in] log_upload_strategy_context Log upload strategy context.
- * @param[in] bucket_sizes Bucket size constraints.
- *
- * @return Error code.
- */
-kaa_error_t kaa_logging_init(kaa_log_collector_t *self, void *log_storage_context, void *log_upload_strategy_context, const kaa_log_bucket_constraints_t *bucket_sizes);
-
-/**
- * @brief Sets custom strategy for given collector.
- *
- * If a strategy has been assigned to collector previously then it will be
- * destroyed and new strategy will be assigned.
- *
- * @param[in] self Pointer to a @link kaa_log_collector_t @endlink instance.
- * @param[in] log_upload_strategy_context Log storage context.
- *
- * @return Error code.
- */
-kaa_error_t kaa_logging_set_strategy(kaa_log_collector_t *self, void *log_upload_strategy_context);
-
-/**
- * @brief Sets custom storage for given collector.
- *
- * If a storage has been assigned to collector previously then it will be
- * destroyed and new storage will be assigned. Be aware that all items from
- * previous storage will be deleted.
- *
- * @param[in] self Pointer to a @link kaa_log_collector_t @endlink instance.
- * @param[in] log_storage_context Log storage context.
- *
- * @return Error code.
- */
-kaa_error_t kaa_logging_set_storage(kaa_log_collector_t *self, void *log_storage_context);
-
-/**
- * @brief Serializes and adds a log record to the log storage.
- *
- * @param[in] self Pointer to a @link kaa_log_collector_t @endlink instance.
- * @param[in] entry Pointer to log entry to be added to the storage.
- * @param[out] log_info Pointer to log info. May be @c NULL.
- *
- * @return Error code.
- */
-kaa_error_t kaa_logging_add_record(kaa_log_collector_t *self, kaa_user_log_record_t *entry, kaa_log_record_info_t *log_info);
-
-/**
- * @brief Sets listeners of log events.
- *
- * @param[in] self Pointer to a @link kaa_log_collector_t @endlink instance.
- * @param[in] listeners Pointer to listeners that will be used to handle
- * various log delivery events. @sa KAA_LOG_EMPTY_LISTENERS
- * can be used to unsubscribe from log events.
- * @return Error code.
- */
-kaa_error_t kaa_logging_set_listeners(kaa_log_collector_t *self, const kaa_log_delivery_listener_t *listeners);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* KAA_LOGGING_H_ */
diff --git a/client/client-multi/client-c/src/extensions/logging/kaa_logging_private.h b/client/client-multi/client-c/src/extensions/logging/kaa_logging_private.h
deleted file mode 100644
index 2fe7c53074..0000000000
--- a/client/client-multi/client-c/src/extensions/logging/kaa_logging_private.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef KAA_LOGGING_PRIVATE_H
-#define KAA_LOGGING_PRIVATE_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-kaa_error_t kaa_log_collector_create(kaa_log_collector_t ** log_collector_p, kaa_status_t *status,
- kaa_channel_manager_t *channel_manager, kaa_logger_t *logger);
-void kaa_log_collector_destroy(kaa_log_collector_t *self);
-kaa_error_t kaa_logging_need_logging_resync(kaa_log_collector_t *self, bool *result);
-
-kaa_error_t kaa_logging_request_get_size(kaa_log_collector_t *self, size_t *expected_size);
-kaa_error_t kaa_logging_request_serialize(kaa_log_collector_t *self,
- kaa_platform_message_writer_t *writer);
-kaa_error_t kaa_logging_handle_server_sync(kaa_log_collector_t *self, kaa_platform_message_reader_t *reader, uint16_t extension_options, size_t extension_length);
-
-void ext_log_upload_timeout(kaa_log_collector_t *self);
-void ext_log_upload_timeout(kaa_log_collector_t *self);
-bool ext_log_upload_strategy_is_timeout_strategy(void *strategy);
-
-kaa_error_t ext_unlimited_log_storage_create(void **log_storage_context_p, kaa_logger_t *logger);
-kaa_error_t ext_limited_log_storage_create(void **log_storage_context_p, kaa_logger_t *logger,
- size_t storage_size, size_t percent_to_delete);
-kaa_error_t ext_log_storage_destroy(void *context);
-
-#endif /* KAA_LOGGING_PRIVATE_H */
diff --git a/client/client-multi/client-c/src/extensions/logging/test/test_kaa_log.c b/client/client-multi/client-c/src/extensions/logging/test/test_kaa_log.c
deleted file mode 100644
index 5d5c0e3245..0000000000
--- a/client/client-multi/client-c/src/extensions/logging/test/test_kaa_log.c
+++ /dev/null
@@ -1,1648 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include "platform/ext_sha.h"
-
-#include "kaa_logging.h"
-#include "kaa_logging_private.h"
-
-#include "kaa_test.h"
-
-#include "kaa_context.h"
-#include "kaa_platform_protocol.h"
-#include "kaa_channel_manager.h"
-#include "kaa_platform_utils.h"
-#include "kaa_status.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-#include "platform/sock.h"
-#include "platform/ext_log_storage.h"
-#include "platform/ext_log_upload_strategy.h"
-
-#include "kaa_private.h"
-
-static kaa_context_t kaa_context;
-static kaa_logger_t *logger = NULL;
-static kaa_status_t *status = NULL;
-static kaa_channel_manager_t *channel_manager = NULL;
-
-static const kaa_extension_id OPERATIONS_SERVICES[] = {
- KAA_EXTENSION_PROFILE,
- KAA_EXTENSION_USER,
- KAA_EXTENSION_CONFIGURATION,
- KAA_EXTENSION_EVENT,
- KAA_EXTENSION_LOGGING,
- KAA_EXTENSION_NOTIFICATION
-};
-static const int OPERATIONS_SERVICES_COUNT = sizeof(OPERATIONS_SERVICES) / sizeof(kaa_extension_id);
-
-#define TEST_LOG_BUFFER "log_record"
-#define TEST_TIMEOUT 1
-
-
-typedef struct {
- size_t timeout;
- size_t max_parallel_uploads;
- int on_timeout_count;
- int on_failure_count;
- ext_log_upload_decision_t decision;
- kaa_error_t timeout_retval; // Return value when timeout event hits
-} mock_strategy_context_t;
-
-typedef struct {
- kaa_list_t *logs;
- size_t record_count;
- size_t total_size;
- int on_remove_by_id_count;
- int on_unmark_by_id_count;
-} mock_storage_context_t;
-
-typedef struct {
- size_t on_sync_count;
-} mock_transport_channel_context_t;
-
-
-
-/*
- * TRANSPORT_CHANNEL INTERFACE
- */
-static kaa_error_t test_kaa_init_channel(void *channel_context,
- kaa_transport_context_t *transport_context)
-{
- (void)channel_context;
- (void)transport_context;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t test_kaa_set_access_point(void *channel_context,
- kaa_access_point_t *access_point)
-{
- (void)channel_context;
- (void)access_point;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t test_kaa_get_protocol_id(void *context,
- kaa_transport_protocol_id_t *protocol_info)
-{
- (void)context;
- protocol_info->id = 1;
- protocol_info->version = 1;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t test_kaa_get_supported_services(void *context,
- const kaa_extension_id **supported_services,
- size_t *service_count)
-{
- (void)context;
- *supported_services = OPERATIONS_SERVICES;
- *service_count = OPERATIONS_SERVICES_COUNT;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t test_kaa_sync_handler(void *context, const kaa_extension_id services[],
- size_t service_count)
-{
- (void)services;
- (void)service_count;
- ((mock_transport_channel_context_t *)context)->on_sync_count++;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t test_kaa_channel_destroy(void *context)
-{
- KAA_FREE(context);
- return KAA_ERR_NONE;
-}
-
-static void test_kaa_channel_create(kaa_transport_channel_interface_t *self)
-{
- self->context = KAA_CALLOC(1, sizeof(mock_transport_channel_context_t));
-
- self->get_protocol_id = test_kaa_get_protocol_id;
- self->get_supported_services = test_kaa_get_supported_services;
- self->destroy = test_kaa_channel_destroy;
- self->sync_handler = test_kaa_sync_handler;
- self->init = test_kaa_init_channel;
- self->set_access_point = test_kaa_set_access_point;
-}
-
-
-
-/*
- * STRATEGY INTERFACE
- */
-ext_log_upload_decision_t ext_log_upload_strategy_decide(void *context,
- const void *log_storage_context)
-{
- (void)log_storage_context;
- return ((mock_strategy_context_t *)context)->decision;
-}
-
-size_t ext_log_upload_strategy_get_timeout(void *context)
-{
- return ((mock_strategy_context_t *)context)->timeout;
-}
-
-kaa_error_t ext_log_upload_strategy_on_timeout(void *context)
-{
- mock_strategy_context_t *mock_ctx = context;
- mock_ctx->on_timeout_count++;
- return mock_ctx->timeout_retval;
-}
-
-kaa_error_t ext_log_upload_strategy_on_failure(void *context,
- logging_delivery_error_code_t error_code)
-{
- (void)error_code;
- ((mock_strategy_context_t *)context)->on_failure_count++;
- return KAA_ERR_NONE;
-}
-
-size_t ext_log_upload_strategy_get_max_parallel_uploads(void *context)
-{
- return ((mock_strategy_context_t *)context)->max_parallel_uploads;
-}
-
-void ext_log_upload_strategy_destroy(void *context)
-{
- (void)context;
-}
-
-bool ext_log_upload_strategy_is_timeout_strategy(void *strategy)
-{
- (void)strategy;
- return false;
-}
-
-
-/*
- * STORAGE INTERFACE
- */
-
-typedef struct {
- bool processed;
- kaa_log_record_t rec;
-} test_log_record_t;
-
-static void destroy_log_record(void *record_p)
-{
- if (record_p) {
- test_log_record_t *test_rec = record_p;
- KAA_FREE(test_rec->rec.data);
- KAA_FREE(test_rec);
- }
-}
-
-static bool match_unprocessed(void *log_record_p, void *arg)
-{
- (void) arg;
- test_log_record_t *record = log_record_p;
- return !record->processed;
-}
-
-kaa_error_t ext_log_storage_allocate_log_record_buffer(void *context, kaa_log_record_t *record)
-{
- (void)context;
- record->data = KAA_MALLOC(record->size);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t ext_log_storage_deallocate_log_record_buffer(void *context, kaa_log_record_t *record)
-{
- (void)context;
- KAA_FREE(record->data);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t ext_log_storage_add_log_record(void *context, kaa_log_record_t *record)
-{
- mock_storage_context_t *self = context;
-
- test_log_record_t *test_rec = KAA_MALLOC(sizeof(*test_rec));
- if (!test_rec) {
- return KAA_ERR_NOMEM;
- }
-
- test_rec->rec = *record;
- test_rec->processed = false;
-
- kaa_list_push_back(self->logs, test_rec);
-
- self->record_count++;
- self->total_size += test_rec->rec.size;
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t ext_log_storage_write_next_record(void *context, char *buffer, size_t buffer_len,
- uint16_t *bucket_id, size_t *record_len)
-{
- mock_storage_context_t *self = context;
- KAA_RETURN_IF_NIL2(self, self->logs, KAA_ERR_NOT_FOUND);
-
- kaa_list_node_t *node = kaa_list_find_next(kaa_list_begin(self->logs),
- match_unprocessed, NULL);
-
- if (!node) {
- return KAA_ERR_NOT_FOUND;
- }
-
- test_log_record_t *record = kaa_list_get_data(node);
-
- if (buffer_len < record->rec.size) {
- return KAA_ERR_INSUFFICIENT_BUFFER;
- }
-
- *record_len = record->rec.size;
- *bucket_id = record->rec.bucket_id;
- memcpy(buffer, record->rec.data, *record_len);
- record->processed = true;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t ext_log_storage_remove_by_bucket_id(void *context, uint16_t bucket_id)
-{
- (void)bucket_id;
- mock_storage_context_t *self = context;
- self->on_remove_by_id_count++;
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t ext_log_storage_unmark_by_bucket_id(void *context, uint16_t bucket_id)
-{
- (void)bucket_id;
- ((mock_storage_context_t *)context)->on_unmark_by_id_count++;
- return KAA_ERR_NONE;
-}
-
-size_t ext_log_storage_get_total_size(const void *context)
-{
- return ((mock_storage_context_t *)context)->total_size;
-}
-
-size_t ext_log_storage_get_records_count(const void *context)
-{
- return ((mock_storage_context_t *)context)->record_count;
-}
-
-mock_storage_context_t *create_mock_storage(void)
-{
- mock_storage_context_t *storage = KAA_CALLOC(1, sizeof(mock_storage_context_t));
- KAA_RETURN_IF_NIL(storage, NULL);
- storage->logs = kaa_list_create();
-
- return storage;
-}
-
-kaa_error_t ext_log_storage_destroy(void *context)
-{
- if (context) {
- kaa_list_destroy(((mock_storage_context_t *)context)->logs, &destroy_log_record);
- KAA_FREE(context);
- }
- return KAA_ERR_NONE;
-}
-
-
-
-void test_create_request(void **state)
-{
- (void)state;
-
- kaa_user_log_record_t *test_log_record = kaa_test_log_record_create();
- test_log_record->data = kaa_string_copy_create(TEST_LOG_BUFFER);
- size_t test_log_record_size = test_log_record->get_size(test_log_record);
-
- kaa_log_collector_t *log_collector = NULL;
- kaa_error_t error_code = kaa_log_collector_create(&log_collector, status,
- channel_manager, logger);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- mock_strategy_context_t strategy;
- memset(&strategy, 0, sizeof(mock_strategy_context_t));
- strategy.decision = NOOP;
- strategy.max_parallel_uploads = UINT32_MAX;
-
- kaa_log_bucket_constraints_t constraints = {
- .max_bucket_size = 2 * test_log_record_size,
- .max_bucket_log_count = UINT32_MAX,
- };
-
- error_code = kaa_logging_init(log_collector, create_mock_storage(), &strategy, &constraints);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- size_t expected_size = 0;
- error_code = kaa_logging_request_get_size(log_collector, &expected_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint8_t buffer[expected_size];
- kaa_platform_message_writer_t *writer = NULL;
- error_code = kaa_platform_message_writer_create(&writer, buffer, expected_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_NOT_NULL(writer);
-
- error_code = kaa_logging_request_serialize(log_collector, writer);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- kaa_platform_message_writer_destroy(writer);
-
- uint8_t *buf_cursor = buffer;
- ASSERT_EQUAL(KAA_EXTENSION_LOGGING, KAA_HTONS(*(uint16_t *)buf_cursor));
- buf_cursor += sizeof(uint16_t);
-
- uint8_t options[] = { 0x00, 0x01 };
- ASSERT_EQUAL(memcmp(buf_cursor, options, 2), 0);
- buf_cursor += 2;
-
- ASSERT_EQUAL(*(uint32_t *) buf_cursor, KAA_HTONL(20));
- buf_cursor += sizeof(uint32_t);
-
- uint8_t request_id_records_count[] = { 0x00, 0x01, 0x00, 0x01 };
- ASSERT_EQUAL(memcmp(buf_cursor, request_id_records_count, 4), 0);
- buf_cursor += 4;
-
- uint8_t record_buf[test_log_record_size];
- avro_writer_t avro_writer = avro_writer_memory((char *)record_buf, test_log_record_size);
- test_log_record->serialize(avro_writer, test_log_record);
- avro_writer_free(avro_writer);
-
- ASSERT_EQUAL(*(uint32_t *) buf_cursor, KAA_HTONL(test_log_record_size));
- buf_cursor += sizeof(uint32_t);
-
- ASSERT_EQUAL(memcmp(buf_cursor, record_buf, test_log_record_size), 0);
-
- kaa_log_collector_destroy(log_collector);
- test_log_record->destroy(test_log_record);
-}
-
-
-
-void test_response(void **state)
-{
- (void)state;
-
- srand(time(NULL));
-
- kaa_log_collector_t *log_collector = NULL;
- kaa_error_t error_code = kaa_log_collector_create(&log_collector, status, channel_manager, logger);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- mock_strategy_context_t strategy;
- memset(&strategy, 0, sizeof(mock_strategy_context_t));
-
- mock_storage_context_t *storage = create_mock_storage();
-
- kaa_log_bucket_constraints_t constraints = {
- .max_bucket_size = 1024,
- .max_bucket_log_count = UINT32_MAX,
- };
-
- error_code = kaa_logging_init(log_collector, storage, &strategy, &constraints);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint32_t response_count = 2;
- size_t response_buffer_size = sizeof(uint32_t) + sizeof(uint32_t) * response_count;
- uint8_t response_buffer[response_buffer_size];
-
- uint8_t *response = response_buffer;
- *((uint32_t *)response) = KAA_HTONL(response_count);
- response += sizeof(uint32_t);
-
- /* First response */
- *((uint16_t *)response) = KAA_HTONS(rand());
- response += sizeof(uint16_t);
- *((uint8_t *)response) = 0x0; // SUCCESS
- response += sizeof(uint8_t);
- *((uint8_t *)response) = 0;
- response += sizeof(uint8_t);
-
- /* Second response */
- *((uint16_t *)response) = KAA_HTONS(rand());
- response += sizeof(uint16_t);
- *((uint8_t *)response) = 0x1; // FAILURE
- response += sizeof(uint8_t);
- *((uint8_t *)response) = rand() % 4;
- response += sizeof(uint8_t);
-
- kaa_platform_message_reader_t *reader = NULL;
- error_code = kaa_platform_message_reader_create(&reader, response_buffer, response_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_NOT_NULL(reader);
-
- error_code = kaa_logging_handle_server_sync(log_collector, reader, 0, response_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- ASSERT_TRUE(strategy.on_failure_count);
- ASSERT_TRUE(storage->on_remove_by_id_count);
- ASSERT_TRUE(storage->on_unmark_by_id_count);
-
- kaa_platform_message_reader_destroy(reader);
- kaa_log_collector_destroy(log_collector);
-}
-
-
-
-void test_timeout(void **state)
-{
- (void)state;
-
- kaa_log_collector_t *log_collector = NULL;
- kaa_error_t error_code = kaa_log_collector_create(&log_collector,
- status, channel_manager, logger);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_user_log_record_t *test_log_record = kaa_test_log_record_create();
- test_log_record->data = kaa_string_copy_create(TEST_LOG_BUFFER);
- size_t test_log_record_size = test_log_record->get_size(test_log_record);
-
- mock_strategy_context_t strategy;
- memset(&strategy, 0, sizeof(mock_strategy_context_t));
- strategy.timeout = TEST_TIMEOUT;
- strategy.decision = NOOP;
- strategy.max_parallel_uploads = UINT32_MAX;
-
- kaa_log_bucket_constraints_t constraints = {
- .max_bucket_size = 2 * test_log_record_size,
- .max_bucket_log_count = UINT32_MAX,
- };
-
- error_code = kaa_logging_init(log_collector, create_mock_storage(), &strategy, &constraints);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- size_t request_buffer_size = 256;
- uint8_t request_buffer[request_buffer_size];
- kaa_platform_message_writer_t *writer = NULL;
- error_code = kaa_platform_message_writer_create(&writer, request_buffer, request_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_logging_request_serialize(log_collector, writer);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- sleep(TEST_TIMEOUT + 1);
-
- error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- ASSERT_TRUE(strategy.on_timeout_count);
-
- test_log_record->destroy(test_log_record);
- kaa_platform_message_writer_destroy(writer);
- kaa_log_collector_destroy(log_collector);
-}
-
-void test_decline_timeout(void **state)
-{
- (void)state;
-
- kaa_log_collector_t *log_collector = NULL;
- kaa_error_t error_code = kaa_log_collector_create(&log_collector, status, channel_manager, logger);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_user_log_record_t *test_log_record = kaa_test_log_record_create();
- test_log_record->data = kaa_string_copy_create(TEST_LOG_BUFFER);
- size_t test_log_record_size = test_log_record->get_size(test_log_record);
-
- mock_strategy_context_t strategy;
- memset(&strategy, 0, sizeof(mock_strategy_context_t));
- strategy.timeout = TEST_TIMEOUT;
- strategy.decision = NOOP;
- strategy.max_parallel_uploads = UINT32_MAX;
-
- mock_storage_context_t *storage = create_mock_storage();
- ASSERT_NOT_NULL(storage);
-
- kaa_log_bucket_constraints_t constraints = {
- .max_bucket_size = 2 * test_log_record_size,
- .max_bucket_log_count = UINT32_MAX,
- };
-
- error_code = kaa_logging_init(log_collector, storage, &strategy, &constraints);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- size_t request_buffer_size = 256;
- uint8_t request_buffer[request_buffer_size];
- kaa_platform_message_writer_t *writer = NULL;
- error_code = kaa_platform_message_writer_create(&writer, request_buffer, request_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_logging_request_serialize(log_collector, writer);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- sleep(TEST_TIMEOUT + 1);
-
- uint16_t bucket_id = *((uint16_t *)(request_buffer + KAA_EXTENSION_HEADER_SIZE));
- bucket_id = KAA_NTOHS(bucket_id);
-
- uint32_t response_count = 1;
- size_t response_buffer_size = sizeof(uint32_t) + sizeof(uint32_t) * response_count;
- uint8_t response_buffer[response_buffer_size];
-
- uint8_t *response = response_buffer;
- *((uint32_t *)response) = KAA_HTONL(response_count);
- response += sizeof(uint32_t);
-
- /* First response */
- *((uint16_t *)response) = KAA_HTONS(bucket_id);
- response += sizeof(uint16_t);
- *((uint8_t *)response) = 0x0; // SUCCESS
- response += sizeof(uint8_t);
- *((uint8_t *)response) = 0;
- response += sizeof(uint8_t);
-
- kaa_platform_message_reader_t *reader = NULL;
- error_code = kaa_platform_message_reader_create(&reader, response_buffer, response_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_NOT_NULL(reader);
-
- error_code = kaa_logging_handle_server_sync(log_collector, reader, 0, response_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_TRUE(storage->on_remove_by_id_count);
-
- error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- ASSERT_FALSE(strategy.on_timeout_count);
-
- test_log_record->destroy(test_log_record);
- kaa_platform_message_writer_destroy(writer);
- kaa_platform_message_reader_destroy(reader);
- kaa_log_collector_destroy(log_collector);
-}
-
-void test_max_parallel_uploads_with_log_sync(void **state)
-{
- (void)state;
-
- uint32_t channel_id = 0;
- kaa_transport_channel_interface_t transport_context;
- test_kaa_channel_create(&transport_context);
-
- kaa_channel_manager_add_transport_channel(channel_manager, &transport_context, &channel_id);
-
- kaa_log_collector_t *log_collector = NULL;
- kaa_error_t error_code = kaa_log_collector_create(&log_collector, status, channel_manager, logger);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_user_log_record_t *test_log_record = kaa_test_log_record_create();
- test_log_record->data = kaa_string_copy_create(TEST_LOG_BUFFER);
- size_t test_log_size = test_log_record->get_size(test_log_record);
-
- mock_strategy_context_t strategy;
- memset(&strategy, 0, sizeof(mock_strategy_context_t));
- strategy.timeout = INT16_MAX;
- strategy.decision = UPLOAD;
-
- mock_storage_context_t *storage = create_mock_storage();
- ASSERT_NOT_NULL(storage);
-
- kaa_log_bucket_constraints_t constraints = {
- .max_bucket_size = 2 * test_log_size,
- .max_bucket_log_count = UINT32_MAX,
- };
-
- error_code = kaa_logging_init(log_collector, storage, &strategy, &constraints);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- /*
- * Ensure the log delivery is forbidden at all.
- */
- strategy.max_parallel_uploads = 0;
- error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- ASSERT_EQUAL(((mock_transport_channel_context_t *)transport_context.context)->on_sync_count, 0);
-
- /*
- * Ensure the first request is allowed.
- */
- strategy.max_parallel_uploads = 1;
- error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_EQUAL(((mock_transport_channel_context_t *)transport_context.context)->on_sync_count, 1);
-
- /*
- * Do the first request to remember the delivery timeout of the log batch.
- */
- size_t request_buffer_size = 256;
- uint8_t request_buffer[request_buffer_size];
- kaa_platform_message_writer_t *writer = NULL;
- error_code = kaa_platform_message_writer_create(&writer, request_buffer, request_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_logging_request_serialize(log_collector, writer);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- /*
- * Ensure the second request is forbidden.
- */
- ASSERT_EQUAL(((mock_transport_channel_context_t *)transport_context.context)->on_sync_count, 1);
-
- /*
- * Clean up.
- */
- error_code = kaa_channel_manager_remove_transport_channel(channel_manager, channel_id);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- test_log_record->destroy(test_log_record);
- kaa_log_collector_destroy(log_collector);
-}
-
-void test_max_parallel_uploads_with_sync_all(void **state)
-{
- (void)state;
-
- uint32_t channel_id = 0;
- kaa_transport_channel_interface_t transport_context;
- test_kaa_channel_create(&transport_context);
-
- kaa_channel_manager_add_transport_channel(channel_manager, &transport_context, &channel_id);
-
- kaa_log_collector_t *log_collector = NULL;
- kaa_error_t error_code = kaa_log_collector_create(&log_collector,
- status, channel_manager, logger);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- kaa_user_log_record_t *test_log_record = kaa_test_log_record_create();
- test_log_record->data = kaa_string_copy_create(TEST_LOG_BUFFER);
- size_t test_log_size = test_log_record->get_size(test_log_record);
-
- mock_strategy_context_t strategy;
- memset(&strategy, 0, sizeof(mock_strategy_context_t));
- strategy.timeout = INT16_MAX;
- strategy.decision = UPLOAD;
-
- mock_storage_context_t *storage = create_mock_storage();
- ASSERT_NOT_NULL(storage);
-
- kaa_log_bucket_constraints_t constraints = {
- .max_bucket_size = 2 * test_log_size,
- .max_bucket_log_count = UINT32_MAX,
- };
-
- error_code = kaa_logging_init(log_collector, storage, &strategy, &constraints);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- /*
- * Ensure the log delivery is forbidden at all.
- */
- strategy.max_parallel_uploads = 0;
- error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- size_t expected_size = 0;
- error_code = kaa_logging_request_get_size(log_collector, &expected_size);
- assert_int_equal(KAA_ERR_NONE, error_code);
- ASSERT_FALSE(expected_size);
-
- /*
- * Ensure the first request is allowed.
- */
- strategy.max_parallel_uploads = 1;
- error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- /*
- * Do the first request to remember the delivery timeout of the log batch.
- */
- error_code = kaa_logging_request_get_size(log_collector, &expected_size);
- assert_int_equal(KAA_ERR_NONE, error_code);
- ASSERT_TRUE(expected_size);
- size_t request_buffer_size = 256;
- uint8_t request_buffer[request_buffer_size];
- kaa_platform_message_writer_t *writer = NULL;
- error_code = kaa_platform_message_writer_create(&writer, request_buffer, request_buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_logging_request_serialize(log_collector, writer);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- /*
- * Ensure the second request is forbidden.
- */
- error_code = kaa_logging_request_get_size(log_collector, &expected_size);
- assert_int_equal(KAA_ERR_NONE, error_code);
- ASSERT_FALSE(expected_size);
-
- /*
- * Clean up.
- */
- error_code = kaa_channel_manager_remove_transport_channel(channel_manager, channel_id);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- test_log_record->destroy(test_log_record);
- kaa_log_collector_destroy(log_collector);
-}
-
-/* ---------------------------------------------------------------------------*/
-/* Log delivery tests */
-/* ---------------------------------------------------------------------------*/
-
-/* Server chunk, managed by a corresponding reader object.
- * Perfectly packed. Packed attribute is intentionally avoided. */
-struct response_chunk {
- uint8_t bucket_id[2]; /* 16 bits for bucket ID */
- uint8_t resp_code; /* 8 bits for response code. 0 == SUCCESS, 1 == FAILURE */
- // cppcheck-suppress unusedStructMember
- uint8_t reserved; /* Should be 0 */
-};
-
-struct response_packet {
- uint8_t resp_cnt[4]; /* 32 bits for amount of responces in buffer */
- struct response_chunk resps[]; /* Responses itself */
-};
-
-#define RESP_PACKETS 2 /* Amount of response packets */
-#define RESP_SUCCESS_IDX 0 /* Index of successfull response */
-#define RESP_FAILURE_IDX 1 /* Index of failed response */
-#define TEST_BUFFER_SIZE 1024
-#define TEST_EXT_OP 0 /* Simple stub */
-
-
-static mock_strategy_context_t test_strategy1;
-static mock_strategy_context_t test_strategy2;
-static mock_storage_context_t *test_storage1;
-static mock_storage_context_t *test_storage2;
-static kaa_log_collector_t *log_collector;
-static size_t test_log_record_size = TEST_BUFFER_SIZE;
-/* Will contain response_packet. Thus required to be aligned. */
-static uint32_t test_reader_buffer[TEST_BUFFER_SIZE / 4];
-static uint32_t test_writer_buffer[TEST_BUFFER_SIZE / 4];
-/* Portion of the test buffer filled with valid data */
-static size_t test_filled_size;
-static kaa_platform_message_reader_t *test_reader;
-static kaa_platform_message_writer_t *test_writer;
-static kaa_user_log_record_t *test_log_record;
-
-/* Values to be checked inside mock event function */
-static void *expected_ctx;
-static int check_bucket;
-static uint16_t expected_bucked_id;
-
-/* Required to trace generic mock function calls */
-static int call_is_expected;
-static int call_completed;
-
-/* Required to trace on fail mock function calls */
-static int failed_call_is_expected;
-static int failed_call_completed;
-
-/* Required to trace on success mock function calls */
-static int success_call_is_expected;
-static int success_call_completed;
-
-/* Required to trace on timeout mock function calls */
-static int timeout_call_is_expected;
-static int timeout_call_completed;
-
-/* Mock event functions */
-
-static void mock_log_event_generic_fn(void *ctx, const kaa_log_bucket_info_t *bucket)
-{
- ASSERT_TRUE(call_is_expected);
- ASSERT_NOT_NULL(bucket); /* Shouldn't be NULL no matter what */
-
- if (check_bucket) {
- ASSERT_EQUAL(expected_bucked_id, bucket->bucket_id);
- }
-
- ASSERT_EQUAL(expected_ctx, ctx);
-
- call_completed++;
-}
-
-static void mock_log_event_failed_fn(void *ctx, const kaa_log_bucket_info_t *bucket)
-{
- ASSERT_TRUE(failed_call_is_expected);
- /* Make sure that generic function will not fail */
- call_is_expected = 1;
- mock_log_event_generic_fn(ctx, bucket);
-
- failed_call_completed++;
-}
-
-static void mock_log_event_success_fn(void *ctx, const kaa_log_bucket_info_t *bucket)
-{
- ASSERT_TRUE(success_call_is_expected);
- /* Make sure that generic function will not fail */
- call_is_expected = 1;
- mock_log_event_generic_fn(ctx, bucket);
-
- success_call_completed++;
-}
-
-static void mock_log_event_timeout_fn(void *ctx, const kaa_log_bucket_info_t *bucket)
-{
- ASSERT_TRUE(timeout_call_is_expected);
- /* Make sure that generic function will not fail */
- call_is_expected = 1;
- mock_log_event_generic_fn(ctx, bucket);
-
- timeout_call_completed++;
-}
-
-/* ---------------------------------------------------------------------------*/
-/* Log setters test group */
-/* ---------------------------------------------------------------------------*/
-
-KAA_GROUP_SETUP(log_setters)
-{
- (void)state;
- kaa_error_t rc;
-
- rc = kaa_log_collector_create(&log_collector,
- status,
- channel_manager,
- logger);
-
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- /* Test objects for strategy test */
-
- memset(&test_strategy1, 0, sizeof(test_strategy1));
- memset(&test_strategy2, 0, sizeof(test_strategy2));
-
- kaa_log_bucket_constraints_t constraints = {
- .max_bucket_size = 2 * test_log_record_size,
- .max_bucket_log_count = UINT32_MAX,
- };
-
- /* Test objects for storage tests */
-
- test_storage1 = create_mock_storage();
- test_storage2 = create_mock_storage();
-
- rc = kaa_logging_init(log_collector, test_storage1,
- &test_strategy1, &constraints);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- expected_ctx = NULL;
- expected_bucked_id = 0;
- call_is_expected = 0;
-
- return 0;
-}
-
-KAA_GROUP_TEARDOWN(log_setters)
-{
- (void)state;
-
- /* If tests will pass, one of storages will be destroyed.
- * Each test in this will decide which one should be deleted. */
- kaa_log_collector_destroy(log_collector);
- log_collector = NULL;
-
- return 0;
-}
-
-
-KAA_TEST_CASE_EX(log_setters, set_strategy_invalid_parameters)
-{
- (void)state;
- kaa_error_t rc;
-
- rc = kaa_logging_set_strategy(log_collector, NULL);
- ASSERT_EQUAL(KAA_ERR_BADPARAM, rc);
-
- rc = kaa_logging_set_strategy(NULL, &test_strategy2);
- ASSERT_EQUAL(KAA_ERR_BADPARAM, rc);
-
- ext_log_storage_destroy(test_storage2);
- ext_log_upload_strategy_destroy(&test_strategy2);
-}
-
-
-KAA_TEST_CASE_EX(log_setters, set_storage_invalid_parameters)
-{
- (void)state;
- kaa_error_t rc;
-
- rc = kaa_logging_set_storage(log_collector, NULL);
- ASSERT_EQUAL(KAA_ERR_BADPARAM, rc);
-
- rc = kaa_logging_set_storage(NULL, test_storage2);
- ASSERT_EQUAL(KAA_ERR_BADPARAM, rc);
-
- ext_log_storage_destroy(test_storage2);
- ext_log_upload_strategy_destroy(&test_strategy2);
-}
-
-KAA_TEST_CASE_EX(log_setters, set_strategy_valid_parameters)
-{
- (void)state;
- kaa_error_t rc;
-
- /* First strategy will be internally deleted */
- rc = kaa_logging_set_strategy(log_collector, &test_strategy2);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- ext_log_storage_destroy(test_storage2);
-
- /* Second strategy will be deleted on test teardown */
-}
-
-
-KAA_TEST_CASE_EX(log_setters, set_storage_valid_parameters)
-{
- (void)state;
- kaa_error_t rc;
-
- /* First storage will be internally deleted */
- rc = kaa_logging_set_storage(log_collector, test_storage2);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- ext_log_upload_strategy_destroy(&test_strategy2);
-
- /* Second storage will be deleted on test teardown */
-}
-
-
-/* ---------------------------------------------------------------------------*/
-/* Log delivery callback basic test group */
-/* ---------------------------------------------------------------------------*/
-
-
-KAA_GROUP_SETUP(log_callback_basic)
-{
- (void)state;
- kaa_error_t error_code;
-
- error_code = kaa_log_collector_create(&log_collector,
- status,
- channel_manager,
- logger);
-
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- memset(&test_strategy1, 0, sizeof(test_strategy1));
-
- kaa_log_bucket_constraints_t constraints = {
- .max_bucket_size = 2 * test_log_record_size,
- .max_bucket_log_count = UINT32_MAX,
- };
-
- error_code = kaa_logging_init(log_collector, create_mock_storage(), &test_strategy1, &constraints);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- expected_ctx = NULL;
- expected_bucked_id = 0;
- call_is_expected = 0;
-
- return 0;
-}
-
-KAA_GROUP_TEARDOWN(log_callback_basic)
-{
- (void)state;
-
- kaa_log_collector_destroy(log_collector);
- log_collector = NULL;
-
- return 0;
-}
-
-KAA_TEST_CASE_EX(log_callback_basic, invalid_parameters)
-{
- (void)state;
-
- kaa_log_delivery_listener_t listeners = {
- .on_success = NULL,
- .on_failed = NULL,
- .on_timeout = NULL,
- .ctx = NULL,
- };
-
- /* NULL parameters case */
-
- kaa_error_t rc = kaa_logging_set_listeners(log_collector, NULL);
- ASSERT_EQUAL(KAA_ERR_BADPARAM, rc);
- rc = kaa_logging_set_listeners(NULL, &listeners);
- ASSERT_EQUAL(KAA_ERR_BADPARAM, rc);
-
- return;
-}
-
-/* This test is also testing the case when listeners isn't called
- * if no logs added */
-KAA_TEST_CASE_EX(log_callback_basic, valid_parameters)
-{
- (void)state;
-
- kaa_error_t rc;
-
- kaa_log_delivery_listener_t listeners = {
- mock_log_event_generic_fn,
- mock_log_event_generic_fn,
- mock_log_event_generic_fn,
- NULL,
- };
-
- /* Any of listeners can be NULL */
-
- rc = kaa_logging_set_listeners(log_collector, &listeners);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- listeners.on_failed = NULL;
- rc = kaa_logging_set_listeners(log_collector, &listeners);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- listeners.on_success = NULL;
- rc = kaa_logging_set_listeners(log_collector, &listeners);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- listeners.on_timeout = NULL;
- rc = kaa_logging_set_listeners(log_collector, &listeners);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- /* Special macro should work too */
- rc = kaa_logging_set_listeners(log_collector, &KAA_LOG_EMPTY_LISTENERS);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- /* Post conditions check */
-
- /* No callbacks should be called */
- ASSERT_FALSE(call_completed);
-}
-
-/* ---------------------------------------------------------------------------*/
-/* Log delivery callback extended test group */
-/* ---------------------------------------------------------------------------*/
-
-KAA_GROUP_SETUP(log_callback_with_storage)
-{
- (void)state;
- kaa_error_t error_code;
-
- error_code = kaa_log_collector_create(&log_collector,
- status,
- channel_manager,
- logger);
-
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- memset(&test_strategy1, 0, sizeof(mock_strategy_context_t));
- memset(test_reader_buffer, 0, sizeof(test_reader_buffer));
- memset(test_writer_buffer, 0, sizeof(test_writer_buffer));
-
- expected_ctx = NULL;
- expected_bucked_id = 0;
- call_is_expected = 0;
- call_completed = 0;
- failed_call_completed = 0;
- failed_call_is_expected = 0;
- success_call_completed = 0;
- success_call_is_expected = 0;
- check_bucket = 0;
-
- test_storage1 = create_mock_storage();
- kaa_log_bucket_constraints_t constraints = {
- .max_bucket_size = 2 * test_log_record_size,
- .max_bucket_log_count = UINT32_MAX,
- };
-
- error_code = kaa_logging_init(log_collector, test_storage1,
- &test_strategy1, &constraints);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
-
- uint32_t response_count = 2;
- struct response_packet *response = (struct response_packet *) test_reader_buffer;
- *(uint32_t *) response->resp_cnt = KAA_HTONL(response_count);
-
- /* First response */
-
- /* Later on we'll override that */
- *(uint16_t *) response->resps[RESP_SUCCESS_IDX].bucket_id = 0;
- response->resps[RESP_SUCCESS_IDX].resp_code = 0; // SUCCESS
-
- /* Second response */
-
- /* Later on we'll override that */
- *(uint16_t *) response->resps[RESP_FAILURE_IDX].bucket_id = 0;
- response->resps[RESP_FAILURE_IDX].resp_code = 1; // FAILURE
-
- test_filled_size = sizeof(struct response_packet)
- + sizeof(struct response_chunk) * 2;
-
- error_code = kaa_platform_message_reader_create(
- &test_reader,
- (const uint8_t *)test_reader_buffer,
- test_filled_size);
-
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_NOT_NULL(test_reader);
-
- return 0;
-}
-
-KAA_GROUP_TEARDOWN(log_callback_with_storage)
-{
- (void)state;
-
- kaa_platform_message_reader_destroy(test_reader);
- test_reader = NULL;
- /* Destroys mock storage as well */
- kaa_log_collector_destroy(log_collector);
- log_collector = NULL;
-
- return 0;
-}
-
-KAA_TEST_CASE_EX(log_callback_with_storage, on_fail_called)
-{
- (void)state;
-
- kaa_error_t rc;
- int dummy_ctx;
-
- kaa_log_delivery_listener_t listeners = {
- NULL,
- mock_log_event_failed_fn,
- NULL,
- &dummy_ctx,
- };
-
- /* Notify mocks about test intentions */
- failed_call_is_expected = 1;
- expected_ctx = &dummy_ctx;
- check_bucket = 1;
- expected_bucked_id = 42;
-
- rc = kaa_logging_set_listeners(log_collector, &listeners);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- /* Response packet is passed internally via test reader */
- struct response_packet *response = (struct response_packet *) test_reader_buffer;
- *(uint16_t *) response->resps[RESP_FAILURE_IDX].bucket_id = KAA_HTONS(expected_bucked_id);
-
- /* Test itself */
- rc = kaa_logging_handle_server_sync(log_collector, test_reader, TEST_EXT_OP, test_filled_size);
-
- ASSERT_EQUAL(rc, KAA_ERR_NONE);
-
- /* Post-conditions check */
-
- ASSERT_FALSE(success_call_completed);
- ASSERT_TRUE(failed_call_completed);
- ASSERT_FALSE(timeout_call_completed);
-}
-
-KAA_TEST_CASE_EX(log_callback_with_storage, on_success_called)
-{
- (void)state;
-
- kaa_error_t rc;
- int dummy_ctx;
-
- kaa_log_delivery_listener_t listeners = {
- mock_log_event_success_fn,
- NULL,
- NULL,
- &dummy_ctx,
- };
-
- /* Notify mocks about test intentions */
- check_bucket = 1;
- expected_bucked_id = 42;
- success_call_is_expected = 1;
- expected_ctx = &dummy_ctx;
-
- rc = kaa_logging_set_listeners(log_collector, &listeners);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- /* Response packet is passed internally via test reader */
- struct response_packet *response = (struct response_packet *) test_reader_buffer;
- *(uint16_t *) response->resps[RESP_SUCCESS_IDX].bucket_id = KAA_HTONS(expected_bucked_id);
-
- /* Test itself */
- rc = kaa_logging_handle_server_sync(log_collector, test_reader, TEST_EXT_OP, test_filled_size);
-
- ASSERT_EQUAL(rc, KAA_ERR_NONE);
-
- /* Post-conditions check */
-
- ASSERT_TRUE(success_call_completed);
- ASSERT_FALSE(failed_call_completed);
- ASSERT_FALSE(timeout_call_completed);
-}
-
-KAA_TEST_CASE_EX(log_callback_with_storage, on_fail_and_success_called)
-{
- (void)state;
-
- kaa_error_t rc;
- int dummy_ctx;
-
- kaa_log_delivery_listener_t listeners = {
- mock_log_event_success_fn,
- mock_log_event_failed_fn,
- NULL,
- &dummy_ctx,
- };
-
- /* Notify mocks about test intentions */
- check_bucket = 1;
- expected_bucked_id = 42;
- failed_call_is_expected = 1;
- success_call_is_expected = 1;
- expected_ctx = &dummy_ctx;
-
- rc = kaa_logging_set_listeners(log_collector, &listeners);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- /* Response packet is passed internally via test reader */
- struct response_packet *response = (struct response_packet *) test_reader_buffer;
- *(uint16_t *) response->resps[RESP_SUCCESS_IDX].bucket_id
- = KAA_HTONS(expected_bucked_id);
- *(uint16_t *) response->resps[RESP_FAILURE_IDX].bucket_id
- = KAA_HTONS(expected_bucked_id);
-
- /* Test itself */
- rc = kaa_logging_handle_server_sync(log_collector, test_reader, TEST_EXT_OP, test_filled_size);
-
- ASSERT_EQUAL(rc, KAA_ERR_NONE);
-
- /* Post-conditions check */
-
- ASSERT_TRUE(success_call_completed);
- ASSERT_TRUE(failed_call_completed);
- ASSERT_FALSE(timeout_call_completed);
-}
-
-/* ---------------------------------------------------------------------------*/
-/* Log delivery callback group with valid mock strategy. */
-/* The initialized mock strategy is essential for timeouts */
-/* ---------------------------------------------------------------------------*/
-
-KAA_GROUP_SETUP(log_callback_with_storage_and_strategy)
-{
- (void)state;
- kaa_error_t error_code;
- size_t test_log_record_size;
-
- error_code = kaa_log_collector_create(&log_collector,
- status,
- channel_manager,
- logger);
-
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- memset(&test_strategy1, 0, sizeof(mock_strategy_context_t));
- test_strategy1.timeout = TEST_TIMEOUT;
- test_strategy1.decision = NOOP;
- test_strategy1.max_parallel_uploads = UINT32_MAX;
-
- kaa_log_bucket_constraints_t constraints = {
- .max_bucket_size = TEST_BUFFER_SIZE,
- .max_bucket_log_count = UINT32_MAX,
- };
-
- expected_ctx = NULL;
- expected_bucked_id = 0;
- call_is_expected = 0;
- call_completed = 0;
- failed_call_completed = 0;
- failed_call_is_expected = 0;
- success_call_completed = 0;
- success_call_is_expected = 0;
- timeout_call_completed = 0;
- check_bucket = 0;
-
- error_code = kaa_logging_init(log_collector, create_mock_storage(),
- &test_strategy1, &constraints);
-
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint32_t response_count = 2;
-
- struct response_packet *response = (struct response_packet *) test_reader_buffer;
- *(uint32_t *) response->resp_cnt = KAA_HTONL(response_count);
-
- /* First response */
-
- /* Later on we'll override that */
- *(uint16_t *) response->resps[RESP_SUCCESS_IDX].bucket_id = 0;
- response->resps[RESP_SUCCESS_IDX].resp_code = 0; // SUCCESS
-
- /* Second response */
-
- /* Later on we'll override that */
- *(uint16_t *) response->resps[RESP_FAILURE_IDX].bucket_id = 0;
- response->resps[RESP_FAILURE_IDX].resp_code = 1; // FAILURE
-
- test_filled_size = sizeof(struct response_packet)
- + sizeof(struct response_chunk) * 2;
-
- test_log_record = kaa_test_log_record_create();
- test_log_record->data = kaa_string_copy_create(TEST_LOG_BUFFER);
- test_log_record_size = test_log_record->get_size(test_log_record);
-
- error_code = kaa_platform_message_reader_create(
- &test_reader,
- (const uint8_t *)test_reader_buffer,
- test_filled_size);
-
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_NOT_NULL(test_reader);
-
- error_code = kaa_platform_message_writer_create(
- &test_writer,
- (uint8_t *)test_writer_buffer,
- test_log_record_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- return 0;
-}
-
-KAA_GROUP_TEARDOWN(log_callback_with_storage_and_strategy)
-{
- (void)state;
-
- test_log_record->destroy(test_log_record);
-
- kaa_platform_message_writer_destroy(test_writer);
- test_writer = NULL;
- kaa_platform_message_reader_destroy(test_reader);
- test_reader = NULL;
-
- /* Destroys mock storage as well */
- kaa_log_collector_destroy(log_collector);
- log_collector = NULL;
-
- return 0;
-}
-
-KAA_TEST_CASE_EX(log_callback_with_storage_and_strategy, on_timeout_called)
-{
- (void)state;
-
- kaa_error_t rc;
- int dummy_ctx;
-
- kaa_log_delivery_listener_t listeners = {
- NULL,
- NULL,
- mock_log_event_timeout_fn,
- &dummy_ctx,
- };
-
- kaa_log_record_info_t bucket;
-
- timeout_call_is_expected = 1;
- expected_ctx = &dummy_ctx;
-
- rc = kaa_logging_set_listeners(log_collector, &listeners);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- rc = kaa_logging_add_record(log_collector, test_log_record, &bucket);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- /* Notify mocks about bucket */
- check_bucket = 1;
- expected_bucked_id = bucket.bucket_id;
-
- /* Test itself */
-
- rc = kaa_logging_request_serialize(log_collector, test_writer);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- sleep(TEST_TIMEOUT + 1);
-
- rc = kaa_logging_add_record(log_collector, test_log_record, NULL);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- /* Post-conditions check */
-
- /* Timeout callback should be called once */
- ASSERT_EQUAL(1, timeout_call_completed);
-}
-
-/* ---------------------------------------------------------------------------*/
-/* Log delivery callback delivery timeout advanced group. */
-/* Special group is dedicated to cases where timeouts occur within different */
-/* buckets. */
-/* This group will require only writer instance to serialize log data. */
-/* ---------------------------------------------------------------------------*/
-
-KAA_GROUP_SETUP(log_advanced_timeouts)
-{
- (void)state;
- kaa_error_t error_code;
- size_t test_log_record_size;
-
- error_code = kaa_log_collector_create(&log_collector, status, channel_manager, logger);
-
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- memset(&test_strategy1, 0, sizeof(test_strategy1));
- test_strategy1.timeout = TEST_TIMEOUT;
- test_strategy1.decision = NOOP;
- test_strategy1.max_parallel_uploads = UINT32_MAX;
-
- kaa_log_bucket_constraints_t constraints = {
- .max_bucket_size = TEST_BUFFER_SIZE,
- .max_bucket_log_count = 1,
- };
-
- expected_ctx = NULL;
- expected_bucked_id = 0;
- call_is_expected = 0;
- call_completed = 0;
- failed_call_completed = 0;
- failed_call_is_expected = 0;
- success_call_completed = 0;
- success_call_is_expected = 0;
- timeout_call_completed = 0;
- check_bucket = 0;
-
- error_code = kaa_logging_init(log_collector, create_mock_storage(), &test_strategy1, &constraints);
-
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- test_log_record = kaa_test_log_record_create();
- test_log_record->data = kaa_string_copy_create(TEST_LOG_BUFFER);
- test_log_record_size = test_log_record->get_size(test_log_record);
-
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_platform_message_writer_create(&test_writer,
- (uint8_t *)test_writer_buffer,
- test_log_record_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- return 0;
-}
-
-KAA_GROUP_TEARDOWN(log_advanced_timeouts)
-{
- (void)state;
-
- test_log_record->destroy(test_log_record);
-
- kaa_platform_message_writer_destroy(test_writer);
- test_writer = NULL;
-
- /* Destroys mock storage as well */
- kaa_log_collector_destroy(log_collector);
- log_collector = NULL;
-
- return 0;
-}
-
-KAA_TEST_CASE_EX(log_advanced_timeouts, few_buckets)
-{
- (void)state;
-
- kaa_error_t rc;
- int dummy_ctx;
-
- kaa_log_delivery_listener_t listeners = {
- NULL,
- NULL,
- mock_log_event_timeout_fn,
- &dummy_ctx,
- };
-
- kaa_log_record_info_t bucket;
-
- timeout_call_is_expected = 1;
- expected_ctx = &dummy_ctx;
-
- test_strategy1.timeout = 1;
-
- /* Means that AP will be switched as a result of timeout */
- test_strategy1.timeout_retval = KAA_ERR_EVENT_NOT_ATTACHED;
-
- /* Test itself */
-
- rc = kaa_logging_set_listeners(log_collector, &listeners);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- rc = kaa_logging_add_record(log_collector, test_log_record, &bucket);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- rc = kaa_logging_add_record(log_collector, test_log_record, &bucket);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- rc = kaa_logging_add_record(log_collector, test_log_record, &bucket);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- /* One bucket per serialize request. */
-
- rc = kaa_logging_request_serialize(log_collector, test_writer);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
- /* Don't care about data written, rewinding buffer. */
- test_writer->current = test_writer->begin;
-
- /* Following two buckets must expire due to AP change. Large timeout will guarantee that. */
- test_strategy1.timeout = 100;
-
- rc = kaa_logging_request_serialize(log_collector, test_writer);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
- /* Don't care about data written, rewinding buffer. */
- test_writer->current = test_writer->begin;
-
- rc = kaa_logging_request_serialize(log_collector, test_writer);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- sleep(TEST_TIMEOUT + 2);
-
- /* Check for timeout */
- ext_log_upload_timeout(log_collector);
-
- /* Post-conditions check */
-
- /* Timeout callback should be called once */
- ASSERT_EQUAL(3, timeout_call_completed);
-}
-
-/* ---------------------------------------------------------------------------*/
-/* End of log delivery test groups */
-/* ---------------------------------------------------------------------------*/
-
-int test_init(void)
-{
- kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
- if (error || !logger) {
- return error;
- }
-
- kaa_context.logger = logger;
-
- error = kaa_status_create(&status);
- if (error || !status) {
- return error;
- }
-
- error = kaa_channel_manager_create(&channel_manager, &kaa_context);
- if (error || !channel_manager) {
- return error;
- }
- return 0;
-}
-
-
-
-int test_deinit(void)
-{
- kaa_channel_manager_destroy(channel_manager);
- kaa_status_destroy(status);
- kaa_log_destroy(logger);
-
- return 0;
-}
-
-KAA_SUITE_MAIN(Log, test_init, test_deinit,
- KAA_TEST_CASE(create_request, test_create_request)
- KAA_TEST_CASE(process_response, test_response)
- KAA_TEST_CASE(process_timeout, test_timeout)
- KAA_TEST_CASE(decline_timeout, test_decline_timeout)
- KAA_TEST_CASE(max_parallel_uploads_with_log_sync, test_max_parallel_uploads_with_log_sync)
- KAA_TEST_CASE(max_parallel_uploads_with_sync_all, test_max_parallel_uploads_with_sync_all)
- KAA_RUN_TEST(log_setters, set_strategy_invalid_parameters)
- KAA_RUN_TEST(log_setters, set_strategy_valid_parameters)
- KAA_RUN_TEST(log_setters, set_storage_invalid_parameters)
- KAA_RUN_TEST(log_setters, set_storage_valid_parameters)
- KAA_RUN_TEST(log_callback_basic, valid_parameters)
- KAA_RUN_TEST(log_callback_basic, invalid_parameters)
- KAA_RUN_TEST(log_callback_basic, valid_parameters)
- KAA_RUN_TEST(log_callback_with_storage, on_success_called)
- KAA_RUN_TEST(log_callback_with_storage, on_fail_called)
- KAA_RUN_TEST(log_callback_with_storage, on_fail_and_success_called)
- KAA_RUN_TEST(log_callback_with_storage_and_strategy, on_timeout_called)
- KAA_RUN_TEST(log_advanced_timeouts, few_buckets))
diff --git a/client/client-multi/client-c/src/extensions/notification/CMakeLists.txt b/client/client-multi/client-c/src/extensions/notification/CMakeLists.txt
deleted file mode 100644
index e91810cecb..0000000000
--- a/client/client-multi/client-c/src/extensions/notification/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set(EXTENSION_NOTIFICATION_SOURCE_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_notification_manager.c)
-
-set(EXTENSION_NOTIFICATION_HEADER_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_notification_manager.h)
-
-add_library(extension_notification ${EXTENSION_NOTIFICATION_SOURCE_FILES})
-target_include_directories(extension_notification PUBLIC ${CMAKE_CURRENT_LIST_DIR})
-target_link_libraries(extension_notification PUBLIC kaac)
-
-kaa_add_unit_test(NAME test_kaa_notification_manager
- SOURCES
- ${CMAKE_CURRENT_LIST_DIR}/test/test_kaa_notification.c
- DEPENDS
- kaac)
diff --git a/client/client-multi/client-c/src/extensions/notification/kaa_notification_manager.c b/client/client-multi/client-c/src/extensions/notification/kaa_notification_manager.c
deleted file mode 100644
index 038f44e1ac..0000000000
--- a/client/client-multi/client-c/src/extensions/notification/kaa_notification_manager.c
+++ /dev/null
@@ -1,1368 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_private.h"
-
-#include "kaa_notification_manager.h"
-
-#include
-#include
-
-#include "kaa_status.h"
-#include "kaa_platform_common.h"
-#include "utilities/kaa_mem.h"
-#include "kaa_common.h"
-#include "utilities/kaa_log.h"
-#include "kaa_platform_utils.h"
-#include "kaa_channel_manager.h"
-#include "platform-impl/common/kaa_htonll.h"
-
-#include "platform/sock.h"
-
-struct kaa_notification_manager_t {
- kaa_list_t *mandatory_listeners;
- kaa_list_t *topics_listeners;
- kaa_list_t *optional_listeners;
- kaa_list_t *subscriptions;
- kaa_list_t *unsubscriptions;
- kaa_list_t *uids;
- kaa_list_t *notifications;
- size_t extension_payload_size;
-
- kaa_platform_message_writer_t *writer;
-
- kaa_status_t *status;
- kaa_channel_manager_t *channel_manager;
- kaa_logger_t *logger;
-};
-
-typedef enum {
- KAA_CLIENT_WANTS_TO_RECEIVE_NOTIFICATIONS = 0x01,
- KAA_SUBSCRIBED_TOPIC_HASH_IS_PRESENT = 0x02,
-} kaa_notification_extension_flags_t;
-
-typedef enum {
- KAA_NO_DELTA,
- KAA_DELTA,
- KAA_RESYNC,
-} kaa_sync_response_status;
-
-typedef enum {
- SYSTEM = 0x0,
- CUSTOM = 0x1,
-} kaa_notification_type;
-
-typedef struct {
- uint16_t length;
- void *data;
-} kaa_notifications_uid_t;
-
-#define TOPICS 0x0
-#define NOTIFICATIONS 0x1
-#define TOPICS_STATE_ID 0x0
-#define UID_ID 0x1
-#define SUBSCRIPTION_ID 0x2
-#define UNSUBSCRIPTION_ID 0x3
-
-typedef struct {
- uint64_t topic_id;
- kaa_list_t *listeners;
-} kaa_optional_notification_listeners_wrapper_t;
-
-typedef struct {
- uint32_t id;
- kaa_notification_listener_t listener;
-} kaa_notification_listener_wrapper_t;
-
-typedef struct {
- uint32_t id;
- kaa_topic_listener_t listener;
-} kaa_topic_listener_wrapper_t;
-
-static kaa_error_t kaa_notification_manager_create(kaa_notification_manager_t **self, kaa_status_t *status, kaa_channel_manager_t *channel_manager, kaa_logger_t *logger);
-void kaa_notification_manager_destroy(kaa_notification_manager_t *self);
-
-static kaa_error_t kaa_notification_manager_get_size(kaa_notification_manager_t *self, size_t *expected_size);
-static kaa_error_t kaa_notification_manager_request_serialize(kaa_notification_manager_t *self,
- kaa_platform_message_writer_t *writer);
-static kaa_error_t kaa_notification_manager_handle_server_sync(kaa_notification_manager_t *self, kaa_platform_message_reader_t *reader, uint32_t extension_length);
-
-kaa_error_t kaa_extension_notification_init(kaa_context_t *kaa_context, void **context)
-{
- kaa_error_t error = kaa_notification_manager_create(&kaa_context->notification_manager,
- kaa_context->status->status_instance,
- kaa_context->channel_manager,
- kaa_context->logger);
- *context = kaa_context->notification_manager;
- return error;
-}
-
-kaa_error_t kaa_extension_notification_deinit(void *context)
-{
- kaa_notification_manager_destroy(context);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_notification_request_get_size(void *context, size_t *expected_size)
-{
- return kaa_notification_manager_get_size(context, expected_size);
-}
-
-kaa_error_t kaa_extension_notification_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync)
-{
- (void)request_id;
-
- // TODO(KAA-982): Use asserts
- if (!context || !size || !need_resync) {
- return KAA_ERR_BADPARAM;
- }
-
- *need_resync = true;
-
- size_t size_needed;
- kaa_error_t error = kaa_notification_manager_get_size(context, &size_needed);
- if (error) {
- return error;
- }
-
- if (!buffer || *size < size_needed) {
- *size = size_needed;
- return KAA_ERR_BUFFER_IS_NOT_ENOUGH;
- }
-
- *size = size_needed;
-
- kaa_platform_message_writer_t writer = KAA_MESSAGE_WRITER(buffer, *size);
- error = kaa_notification_manager_request_serialize(context, &writer);
- if (error) {
- return error;
- }
-
- *size = writer.current - buffer;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_notification_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size)
-{
- (void)request_id;
- (void)extension_options;
-
- // TODO(KAA-982): Use asserts
- if (!context || !buffer) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_platform_message_reader_t reader = KAA_MESSAGE_READER(buffer, size);
- return kaa_notification_manager_handle_server_sync(context, &reader, size);
-}
-
-static void shift_and_sub_extension(kaa_platform_message_reader_t *reader, uint32_t *extension_length, size_t size)
-{
- KAA_RETURN_IF_NIL2(reader, extension_length,);
- reader->current += size;
- *extension_length -= size;
-}
-
-typedef struct {
- kaa_notification_t *notification;
- uint32_t sqn;
-} kaa_notification_wrapper_t;
-
-typedef struct {
- uint64_t topic_id;
- kaa_list_t *notifications;
-} kaa_topic_notifications_node_t;
-
-static bool find_notifications_by_topic(void *data, void *context)
-{
- kaa_topic_notifications_node_t *node = data;
- return node->topic_id == *((uint64_t *) context);
-}
-
-static bool sort_topic_by_id(void *node_1, void *node_2)
-{
- KAA_RETURN_IF_NIL2(node_1, node_2, false);
- kaa_topic_t *wrapper_1 = node_1;
- kaa_topic_t *wrapper_2 = node_2;
- return wrapper_1->id < wrapper_2->id;
-}
-
-static uint64_t get_topic_id(void *node)
-{
- kaa_topic_t *wrapper = node;
- return wrapper->id;
-}
-
-static void kaa_destroy_notification_wrapper(void *data)
-{
- KAA_RETURN_IF_NIL(data, );
- kaa_notification_wrapper_t *wrapper = data;
- if (wrapper->notification) {
- wrapper->notification->destroy(wrapper->notification);
- }
- KAA_FREE(wrapper);
-}
-
-static void kaa_destroy_notification_node(void *data)
-{
- KAA_RETURN_IF_NIL(data, );
- kaa_topic_notifications_node_t *node = data;
- if (node->notifications) {
- kaa_list_destroy(node->notifications, kaa_destroy_notification_wrapper);
- }
- KAA_FREE(node);
-}
-
-static kaa_error_t kaa_create_topic_notification_node(kaa_topic_notifications_node_t **node, kaa_notification_t *item, uint32_t *sqn, uint64_t topic_id)
-{
- KAA_RETURN_IF_NIL(node, KAA_ERR_BADPARAM);
-
- kaa_topic_notifications_node_t *new_node = KAA_MALLOC(sizeof(*new_node));
- KAA_RETURN_IF_NIL(new_node, KAA_ERR_NOMEM);
-
- new_node->notifications = kaa_list_create();
- if (!new_node->notifications) {
- kaa_destroy_notification_node(new_node);
- return KAA_ERR_NOMEM;
- }
-
- kaa_notification_wrapper_t *wrapper = KAA_MALLOC(sizeof(*wrapper));
- if (!wrapper) {
- kaa_destroy_notification_node(new_node);
- return KAA_ERR_NOMEM;
- }
-
- if (!kaa_list_push_back(new_node->notifications, wrapper)) {
- kaa_destroy_notification_node(new_node);
- KAA_FREE(wrapper);
- return KAA_ERR_NOMEM;
- }
-
- new_node->topic_id = topic_id;
- wrapper->notification = item;
- wrapper->sqn = *sqn;
- *node = new_node;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_add_notification_to_map(kaa_list_t *notifications, kaa_notification_t *item, uint64_t topic_id, uint32_t *sqn)
-{
- KAA_RETURN_IF_NIL3(notifications, item, sqn, KAA_ERR_BADPARAM);
- kaa_list_node_t *notification_list_node = kaa_list_find_next(kaa_list_begin(notifications), find_notifications_by_topic, &topic_id);
- kaa_topic_notifications_node_t *notification_node = NULL;
- if (!notification_list_node) {
- kaa_error_t err = kaa_create_topic_notification_node(¬ification_node, item, sqn, topic_id);
- if (err) {
- kaa_list_destroy(notifications, &kaa_destroy_notification_node);
- item->destroy(item);
- return err;
- }
- if (!kaa_list_push_back(notifications, notification_node)) {
- kaa_list_destroy(notifications, &kaa_destroy_notification_node);
- kaa_destroy_notification_node(notification_node);
- item->destroy(item);
- return KAA_ERR_NOMEM;
- }
- } else {
- notification_node = kaa_list_get_data(notification_list_node);
- kaa_notification_wrapper_t *new_wrapper = KAA_MALLOC(sizeof(*new_wrapper));
- if (!new_wrapper) {
- kaa_list_destroy(notifications, &kaa_destroy_notification_node);
- item->destroy(item);
- return KAA_ERR_NOMEM;
- }
- if (!kaa_list_push_back(notification_node->notifications, new_wrapper)) {
- kaa_list_destroy(notifications, &kaa_destroy_notification_node);
- item->destroy(item);
- KAA_FREE(new_wrapper);
- return KAA_ERR_NOMEM;
- }
-
- new_wrapper->notification = item;
- new_wrapper->sqn = *sqn;
- }
-
- return KAA_ERR_NONE;
-}
-
-static bool kaa_predicate_for_notifications(void *notif_1, void *notif_2)
-{
- KAA_RETURN_IF_NIL2(notif_1, notif_2, false);
- kaa_notification_wrapper_t *wrapper_1 = notif_1;
- kaa_notification_wrapper_t *wrapper_2 = notif_2;
- return wrapper_1->sqn < wrapper_2->sqn;
-}
-static void kaa_sort_notifications_by_sqn(void *data, void *context)
-{
- (void)context;
- kaa_topic_notifications_node_t *node = data;
- kaa_list_sort(node->notifications, &kaa_predicate_for_notifications);
-}
-
-static void kaa_sort_notifications(kaa_list_t *notifications)
-{
- kaa_list_for_each(kaa_list_begin(notifications), kaa_list_back(notifications), &kaa_sort_notifications_by_sqn, NULL);
-}
-
-static kaa_extension_id notification_sync_services[] = { KAA_EXTENSION_NOTIFICATION };
-
-static bool kaa_find_notification_listener_by_id(void *listener, void *context)
-{
- KAA_RETURN_IF_NIL2(listener, context, KAA_ERR_NONE);
- return ((kaa_notification_listener_wrapper_t *) listener)->id == *(uint32_t *)context;
-}
-static bool kaa_find_topic_listener_by_id(void *listener, void *context)
-{
- KAA_RETURN_IF_NIL2(listener, context, KAA_ERR_NONE);
- return ((kaa_topic_listener_wrapper_t *) listener)->id == *(uint32_t *)context;
-}
-
-static bool kaa_find_optional_notification_listener_by_id (void *optional_listener_list, void *topic_id)
-{
- KAA_RETURN_IF_NIL2(optional_listener_list, topic_id, KAA_ERR_NONE);
- kaa_optional_notification_listeners_wrapper_t *optional_listener_node = optional_listener_list;
- return optional_listener_node->topic_id == *(uint64_t *)topic_id;
-}
-
-static bool kaa_find_topic_by_id(void *topic, void *id)
-{
- KAA_RETURN_IF_NIL2(topic, id, KAA_ERR_NONE);
- kaa_topic_t* notification_topic = topic;
- return notification_topic->id == *(uint64_t *)id;
-}
-
-static kaa_error_t kaa_find_topic(kaa_notification_manager_t *self, kaa_topic_t **topic, uint64_t *topic_id)
-{
- KAA_RETURN_IF_NIL2(topic_id, topic, KAA_ERR_BADPARAM);
- kaa_list_node_t *topic_node = kaa_list_find_next(kaa_list_begin(self->status->topics), &kaa_find_topic_by_id, topic_id);
- if (!topic_node) {
- return KAA_ERR_NOT_FOUND;
- }
-
- *topic = kaa_list_get_data(topic_node);
- return KAA_ERR_NONE;
-}
-
-static bool kaa_find_uid(void *data, void *context)
-{
- KAA_RETURN_IF_NIL2(data, context, KAA_ERR_NONE);
- kaa_notifications_uid_t *uid = data;
- kaa_notifications_uid_t *search_context = context;
- if (uid->length != search_context->length) {
- return false;
- }
-
- if (!memcmp(uid->data, search_context->data, uid->length)) {
- return true;
- }
- return false;
-}
-
-static bool kaa_find_topic_state_by_id(void *topic_state, void *id)
-{
- KAA_RETURN_IF_NIL2(topic_state, id, KAA_ERR_BADPARAM);
- kaa_topic_state_t *state = topic_state;
- return state->topic_id == *(uint64_t *)id;
-}
-
-kaa_error_t kaa_calculate_topic_listener_id(const kaa_topic_listener_t *listener, uint32_t *listener_id)
-{
- KAA_RETURN_IF_NIL2(listener, listener_id, KAA_ERR_BADPARAM);
-
- const uint32_t prime = 31;
-
- *listener_id = 1;
- *listener_id = prime * (*listener_id) + (ptrdiff_t)listener->context;
- *listener_id = prime * (*listener_id) + (ptrdiff_t)listener->callback;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_calculate_notification_listener_id(const kaa_notification_listener_t *listener, uint32_t *listener_id)
-{
- KAA_RETURN_IF_NIL2(listener, listener_id, KAA_ERR_BADPARAM);
-
- const uint32_t prime = 31;
-
- *listener_id = 1;
- *listener_id = prime * (*listener_id) + (ptrdiff_t)listener->context;
- *listener_id = prime * (*listener_id) + (ptrdiff_t)listener->callback;
- return KAA_ERR_NONE;
-}
-
-static size_t get_subscriptions_size(kaa_list_t *subscriptions)
-{
- if (kaa_list_get_size(subscriptions) > 0) {
- size_t expected_size = sizeof(uint32_t); //meta data for subscribe commands
- expected_size += kaa_list_get_size(subscriptions) * sizeof(uint64_t);
- return expected_size;
- }
-
- return 0;
-}
-
-kaa_error_t kaa_notification_manager_get_size(kaa_notification_manager_t *self, size_t *expected_size)
-{
- KAA_RETURN_IF_NIL2(self, expected_size, KAA_ERR_BADPARAM);
- *expected_size = 0;
- *expected_size += sizeof(uint32_t); //state sqn size
-
- if (kaa_list_get_size(self->status->topic_states) > 0) {
- *expected_size += sizeof(uint32_t); //field id + reserved + count
- *expected_size += (sizeof(uint64_t) + sizeof(uint32_t)) * kaa_list_get_size(self->status->topic_states);
- }
-
- if (kaa_list_get_size(self->uids) > 0) {
- *expected_size += sizeof(uint32_t); //field id + reserved + count
- *expected_size += sizeof(uint32_t) * kaa_list_get_size(self->uids);
-
- kaa_list_node_t *uid_node = kaa_list_begin(self->uids);
- while (uid_node) {
- kaa_notifications_uid_t *uid = kaa_list_get_data(uid_node);
- *expected_size += kaa_aligned_size_get(uid->length);
- uid_node = kaa_list_next(uid_node);
- }
- }
-
- *expected_size += get_subscriptions_size(self->subscriptions);
- *expected_size += get_subscriptions_size(self->unsubscriptions);
-
- self->extension_payload_size = *expected_size;
- *expected_size += KAA_EXTENSION_HEADER_SIZE;
- return KAA_ERR_NONE;
-}
-
-static void serialize_topic_state(kaa_topic_state_t *state, kaa_notification_manager_t *self)
-{
- KAA_RETURN_IF_NIL3(state, self, self->writer, );
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Serializing topic state: topic id '%llu', sqn '%lu'", state->topic_id, state->sqn_number);
- *(uint64_t *)self->writer->current = KAA_HTONLL(state->topic_id);
- self->writer->current += sizeof(uint64_t);
- *(uint32_t *)self->writer->current = KAA_HTONL((uint32_t)state->sqn_number);
- self->writer->current += sizeof(uint32_t);
-}
-
-static void serialize_notifications_uid(kaa_notifications_uid_t * uid, kaa_platform_message_writer_t *writer)
-{
- KAA_RETURN_IF_NIL2(uid, writer, );
- *(uint32_t *)writer->current = KAA_HTONL(uid->length);
- writer->current += sizeof(uint32_t);
- kaa_platform_message_write_aligned(writer, uid->data, uid->length);
-}
-
-static void serialize_subscription(uint64_t *topic_id, kaa_notification_manager_t *self)
-{
- KAA_RETURN_IF_NIL3(topic_id, self, self->writer, );
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Topic id '%llu'", *topic_id);
- *(uint64_t *)self->writer->current = KAA_HTONLL(*topic_id);
- self->writer->current += sizeof(uint64_t);
-}
-
-static void serialize_subscriptions(kaa_notification_manager_t *self, uint8_t subscription_type)
-{
- KAA_RETURN_IF_NIL(self, );
-
- kaa_list_t *subscriptions = NULL;
-
- if (subscription_type == SUBSCRIPTION_ID) {
- KAA_RETURN_IF_NIL(kaa_list_get_size(self->subscriptions), );
- subscriptions = self->subscriptions;
- }
- if (subscription_type == UNSUBSCRIPTION_ID) {
- KAA_RETURN_IF_NIL(kaa_list_get_size(self->unsubscriptions), );
- subscriptions = self->unsubscriptions;
- }
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize %s", subscription_type == SUBSCRIPTION_ID ? "subscriptions" : "unsubscriptions");
-
- *(uint8_t *)self->writer->current = subscription_type;
- self->writer->current += sizeof(uint16_t);
- *(uint16_t *)self->writer->current = KAA_HTONS((uint16_t)kaa_list_get_size(subscriptions));
- self->writer->current += sizeof(uint16_t);
-
-
- kaa_list_for_each(kaa_list_begin(subscriptions), kaa_list_back(subscriptions),
- (process_data)serialize_subscription, self);
-}
-
-kaa_error_t kaa_notification_manager_request_serialize(kaa_notification_manager_t *self, kaa_platform_message_writer_t *writer)
-{
- KAA_RETURN_IF_NIL2(self, writer, KAA_ERR_BADPARAM);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize client notification sync");
-
- self->writer = writer;
-
- kaa_error_t err = kaa_platform_message_write_extension_header(writer,
- KAA_EXTENSION_NOTIFICATION, KAA_CLIENT_WANTS_TO_RECEIVE_NOTIFICATIONS,
- self->extension_payload_size);
- if (err) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_BADPARAM, "Failed to write notification header");
- return KAA_ERR_BADPARAM;
- }
-
- *(int32_t *)writer->current = KAA_HTONL((int32_t)self->status->topic_list_hash);
- writer->current += sizeof(int32_t);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize %zu topic states", kaa_list_get_size(self->status->topic_states));
- if (kaa_list_get_size(self->status->topic_states) > 0) {
- *(uint8_t *)writer->current = (uint8_t)TOPICS_STATE_ID;
- writer->current += sizeof(uint16_t);
- *(uint16_t *)writer->current = KAA_HTONS((uint16_t)kaa_list_get_size(self->status->topic_states));
- writer->current += sizeof(uint16_t);
-
- kaa_list_for_each(kaa_list_begin(self->status->topic_states),
- kaa_list_back(self->status->topic_states),
- (process_data)serialize_topic_state, self);
- }
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize %zu uids", kaa_list_get_size(self->uids));
- if (kaa_list_get_size(self->uids) > 0) {
- *(uint8_t *)writer->current = (uint8_t)UID_ID;
- writer->current += sizeof(uint16_t);
- *(uint16_t *)writer->current = KAA_HTONS(kaa_list_get_size(self->uids));
- writer->current += sizeof(uint16_t);
-
- kaa_list_for_each(kaa_list_begin(self->uids), kaa_list_back(self->uids),
- (process_data)serialize_notifications_uid, writer);
- }
-
- serialize_subscriptions(self, SUBSCRIPTION_ID);
- serialize_subscriptions(self, UNSUBSCRIPTION_ID);
-
- return KAA_ERR_NONE;
-}
-
-static void destroy_notifications_uid(void *data)
-{
- if (!data) {
- return;
- }
-
- KAA_RETURN_IF_NIL(data,);
- kaa_notifications_uid_t *uid = data;
- KAA_FREE(uid->data);
- KAA_FREE(uid);
-}
-
-static void destroy_topic(void *data)
-{
- if (!data) {
- return;
- }
-
- kaa_topic_t *topic = data;
- KAA_FREE(topic->name);
- KAA_FREE(data);
-}
-
-static void destroy_optional_listeners_wrapper(void *data)
-{
- KAA_RETURN_IF_NIL(data,);
- kaa_optional_notification_listeners_wrapper_t *wrapper = data;
- kaa_list_destroy(wrapper->listeners, NULL);
- KAA_FREE(wrapper);
-}
-
-/** @deprecated Use kaa_extension_notification_deinit(). */
-void kaa_notification_manager_destroy(kaa_notification_manager_t *self)
-{
- if (!self) {
- return;
- }
-
- kaa_list_destroy(self->mandatory_listeners, kaa_data_destroy);
- kaa_list_destroy(self->topics_listeners, kaa_data_destroy);
- kaa_list_destroy(self->subscriptions, kaa_data_destroy);
- kaa_list_destroy(self->unsubscriptions, kaa_data_destroy);
- kaa_list_destroy(self->optional_listeners, destroy_optional_listeners_wrapper);
- kaa_list_destroy(self->uids, destroy_notifications_uid);
- kaa_list_destroy(self->notifications, kaa_destroy_notification_node);
-
- KAA_FREE(self);
-}
-
-/** @deprecated Use kaa_extension_notification_init(). */
-kaa_error_t kaa_notification_manager_create(kaa_notification_manager_t **self, kaa_status_t *status,
- kaa_channel_manager_t *channel_manager, kaa_logger_t *logger)
-{
- if (!self || !status || !channel_manager || !logger) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_notification_manager_t *manager = KAA_MALLOC(sizeof(*manager));
- if (!manager) {
- return KAA_ERR_NOMEM;
- }
-
- manager->mandatory_listeners = kaa_list_create();
- manager->topics_listeners = kaa_list_create();
- manager->optional_listeners = kaa_list_create();
- manager->subscriptions = kaa_list_create();
- manager->unsubscriptions = kaa_list_create();
- manager->notifications = kaa_list_create();
- manager->uids = kaa_list_create();
-
- if (!manager->mandatory_listeners || !manager->topics_listeners
- || !manager->optional_listeners ||!manager->subscriptions
- || !manager->unsubscriptions || !manager->uids)
- {
- kaa_notification_manager_destroy(manager);
- return KAA_ERR_NOMEM;
- }
-
- manager->extension_payload_size = 0;
-
- manager->writer = NULL;
- manager->status = status;
- manager->channel_manager = channel_manager;
- manager->logger = logger;
-
- *self = manager;
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_add_notification_listener(kaa_notification_manager_t *self, kaa_notification_listener_t *listener, uint32_t* listener_id)
-{
- KAA_RETURN_IF_NIL2(self, listener, KAA_ERR_BADPARAM);
-
- if (!listener->callback) {
- KAA_LOG_WARN(self->logger, KAA_ERR_BADPARAM, "Failed to add mandatory notification listener: NULL callback");
- return KAA_ERR_BADPARAM;
- }
-
- uint32_t id;
- kaa_error_t err = kaa_calculate_notification_listener_id(listener, &id);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to calculate mandatory listener id");
- return err;
- }
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to add mandatory notification listener, id '%lu'", id);
-
- if (kaa_list_find_next(kaa_list_begin(self->mandatory_listeners), &kaa_find_notification_listener_by_id, &id)) {
- KAA_LOG_WARN(self->logger, KAA_ERR_ALREADY_EXISTS, "Failed to add mandatory listener: listener is already subscribed");
- return KAA_ERR_ALREADY_EXISTS;
- }
-
- kaa_notification_listener_wrapper_t* wrapper = KAA_MALLOC(sizeof(*wrapper));
- KAA_RETURN_IF_NIL(wrapper, KAA_ERR_NOMEM);
-
- if (!kaa_list_push_front(self->mandatory_listeners, wrapper)) {
- KAA_FREE(wrapper);
- KAA_LOG_WARN(self->logger, KAA_ERR_NOMEM, "Failed to add mandatory listener");
- return KAA_ERR_NOMEM;
- }
-
- wrapper->listener = *listener;
- wrapper->id = id; // for user to have convenient way to address notification listener
-
- if (listener_id) {
- *listener_id = id;
- }
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Added mandatory notification listener id '%lu'", id);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_remove_notification_listener(kaa_notification_manager_t *self, uint32_t *listener_id)
-{
- KAA_RETURN_IF_NIL2(self, listener_id, KAA_ERR_BADPARAM);
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to remove mandatory notification listener, id '%lu'", *listener_id);
-
- kaa_error_t err = kaa_list_remove_first(self->mandatory_listeners,
- kaa_find_notification_listener_by_id, listener_id, &kaa_data_destroy);
- if (err) {
- KAA_LOG_TRACE(self->logger, err,
- "Failed to remove mandatory notification listener: the listener with id '%lu' is not found", *listener_id);
- } else {
- KAA_LOG_TRACE(self->logger, err,
- "Removed mandatory notification listener, id '%lu'", *listener_id);
- }
-
- return err;
-}
-
-kaa_error_t kaa_add_optional_notification_listener(kaa_notification_manager_t *self,
- kaa_notification_listener_t *listener, uint64_t *topic_id, uint32_t *listener_id)
-{
- KAA_RETURN_IF_NIL4(self, listener, listener->callback, topic_id, KAA_ERR_BADPARAM);
-
- if (!kaa_list_find_next(kaa_list_begin(self->status->topics), &kaa_find_topic_by_id, topic_id)) {
- KAA_LOG_WARN(self->logger, KAA_ERR_NOT_FOUND,
- "Failed to add optional notification listener: topic with id '%llu' not found",
- *topic_id);
- return KAA_ERR_NOT_FOUND;
- }
-
- uint32_t id;
- kaa_error_t err = kaa_calculate_notification_listener_id(listener, &id);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to calculate optional listener id");
- return err;
- }
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to add optional notification listener: id '%lu', topic id '%llu'", id, *topic_id);
-
- kaa_notification_listener_wrapper_t *wrapper = KAA_MALLOC(sizeof(*wrapper));
- KAA_RETURN_IF_NIL(wrapper, KAA_ERR_NOMEM);
-
- kaa_list_node_t *opt_listeners_node = kaa_list_find_next(
- kaa_list_begin(self->optional_listeners), kaa_find_optional_notification_listener_by_id,
- topic_id);
- if (!opt_listeners_node) {
- kaa_optional_notification_listeners_wrapper_t* optional_wrapper = KAA_MALLOC(sizeof(*optional_wrapper));
- if (!optional_wrapper) {
- KAA_FREE(wrapper);
- return KAA_ERR_NOMEM;
- }
-
- optional_wrapper->listeners = kaa_list_create();
- if (!kaa_list_push_front(optional_wrapper->listeners, wrapper)) {
- KAA_FREE(wrapper);
- destroy_optional_listeners_wrapper(optional_wrapper);
- return KAA_ERR_NOMEM;
- }
-
- if (!kaa_list_push_front(self->optional_listeners, optional_wrapper)) {
- KAA_FREE(wrapper);
- destroy_optional_listeners_wrapper(optional_wrapper);
- return KAA_ERR_NOMEM;
- }
-
- optional_wrapper->topic_id = *topic_id;
- } else {
- kaa_optional_notification_listeners_wrapper_t* optional_wrapper = kaa_list_get_data(opt_listeners_node);
-
- if (kaa_list_find_next(kaa_list_begin(optional_wrapper->listeners), &kaa_find_notification_listener_by_id, &id)) {
- KAA_LOG_WARN(self->logger, KAA_ERR_ALREADY_EXISTS, "Failed to add the optional listener: the listener is already subscribed");
- KAA_FREE(wrapper);
- return KAA_ERR_ALREADY_EXISTS;
- }
-
- if (!kaa_list_push_front(optional_wrapper->listeners, wrapper)) {
- KAA_FREE(wrapper);
- return KAA_ERR_NOMEM;
- }
- }
-
- wrapper->listener = *listener;
- wrapper->id = id; // for user to have convenient way to address notification listener
- if (listener_id) {
- *listener_id = id;
- }
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Added optional notification listener: id '%lu', topic id '%llu'", id, *topic_id);
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_remove_optional_notification_listener(kaa_notification_manager_t *self, uint64_t *topic_id, uint32_t *listener_id)
-{
- KAA_RETURN_IF_NIL3(self, topic_id, listener_id, KAA_ERR_BADPARAM);
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to remove optional notification listener: id '%u', topic id '%u'", *listener_id, *topic_id);
-
- kaa_list_node_t *opt_listeners_node = kaa_list_find_next(
- kaa_list_begin(self->optional_listeners),
- &kaa_find_optional_notification_listener_by_id, topic_id);
- if (!opt_listeners_node) {
- KAA_LOG_WARN(self->logger, KAA_ERR_NOT_FOUND, "Failed to remove the optional listener: there is no listeners subscribed on this topic (topic id '%llu').", *topic_id);
- return KAA_ERR_NOT_FOUND;
- }
-
- kaa_optional_notification_listeners_wrapper_t *optional_wrapper = kaa_list_get_data(opt_listeners_node);
-
- kaa_error_t error = kaa_list_remove_first(optional_wrapper->listeners,
- &kaa_find_notification_listener_by_id, listener_id, &kaa_data_destroy);
- if (error) {
- KAA_LOG_WARN(self->logger, KAA_ERR_NOT_FOUND, "Failed to remove the optional listener: the listener with id '%lu' is not found", *listener_id);
- return error;
- } else {
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Removed optional notification listener id: '%lu', topic id '%llu'", *listener_id, *topic_id);
- if (!kaa_list_get_size(optional_wrapper->listeners)) {
- kaa_list_remove_at(self->optional_listeners, opt_listeners_node, &destroy_optional_listeners_wrapper);
- }
- return KAA_ERR_NONE;
- }
-}
-
-kaa_error_t kaa_add_topic_list_listener(kaa_notification_manager_t *self, kaa_topic_listener_t *listener, uint32_t *topic_listener_id)
-{
- KAA_RETURN_IF_NIL3(self, listener, listener->callback, KAA_ERR_BADPARAM);
-
-
- uint32_t id;
- kaa_error_t err = kaa_calculate_topic_listener_id(listener, &id);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to calculate mandatory listener's id");
- return err;
- }
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to add topic list listener, id '%lu'", id);
-
- kaa_topic_listener_wrapper_t *wrapper = (kaa_topic_listener_wrapper_t *) KAA_MALLOC(sizeof(kaa_topic_listener_wrapper_t));
- KAA_RETURN_IF_NIL(wrapper, KAA_ERR_NOMEM);
-
- if (kaa_list_find_next(kaa_list_begin(self->topics_listeners), &kaa_find_topic_listener_by_id, &id)) {
- KAA_LOG_WARN(self->logger, KAA_ERR_ALREADY_EXISTS, "Failed to add topic the listener: the listener is already subscribed");
- KAA_FREE(wrapper);
- return KAA_ERR_ALREADY_EXISTS;
- }
-
- if (!kaa_list_push_front(self->topics_listeners, wrapper)) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_NOMEM, "Failed to add the topic listener");
- KAA_FREE(wrapper);
- return KAA_ERR_NOMEM;
- }
-
- wrapper->listener = *listener;
- wrapper->id = id;// for user to have convenient way to address notification listener
- if (topic_listener_id) {
- *topic_listener_id = id;
- }
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Added topic list listener, id '%lu'", id);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_remove_topic_list_listener(kaa_notification_manager_t *self, uint32_t *topic_listener_id)
-{
- KAA_RETURN_IF_NIL2(self, topic_listener_id, KAA_ERR_BADPARAM);
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to remove topic list listener, id '%lu'", *topic_listener_id);
-
- kaa_error_t err = kaa_list_remove_first(self->topics_listeners,
- &kaa_find_topic_listener_by_id, topic_listener_id, &kaa_data_destroy);
- if (err) {
- KAA_LOG_WARN(self->logger, err,
- "Failed to remove topic list listener: listener id '%lu' not found",
- *topic_listener_id);
- return err;
- }
- KAA_LOG_TRACE(self->logger, err, "Removed topic list listener, id '%lu'", *topic_listener_id);
- return err;
-}
-
-kaa_error_t kaa_get_topics(kaa_notification_manager_t *self, kaa_list_t **topics)
-{
- KAA_RETURN_IF_NIL2(self, topics, KAA_ERR_BADPARAM);
- *topics = self->status->topics;
- return KAA_ERR_NONE;
-}
-
-static void notify_topic_update_subscriber(kaa_topic_listener_wrapper_t *wrapper, kaa_list_t *topics)
-{
- KAA_RETURN_IF_NIL2(wrapper, topics, );
- wrapper->listener.callback(wrapper->listener.context, topics);
-}
-
-static kaa_error_t kaa_notify_topic_update_subscribers(kaa_notification_manager_t *self, kaa_list_t *topics)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
- kaa_list_for_each(kaa_list_begin(self->topics_listeners), kaa_list_back(self->topics_listeners),
- (process_data)notify_topic_update_subscriber, topics);
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_notify_mandatory_notification_subscribers(kaa_notification_manager_t *self,
- uint64_t topic_id, kaa_notification_t *notification)
-{
- KAA_RETURN_IF_NIL2(self, notification, KAA_ERR_BADPARAM);
- kaa_list_node_t *current_listener_node = kaa_list_begin(self->mandatory_listeners);
- while (current_listener_node) {
- kaa_notification_listener_wrapper_t *wrapper = kaa_list_get_data(current_listener_node);
- wrapper->listener.callback(wrapper->listener.context, &topic_id, notification);
- current_listener_node = kaa_list_next(current_listener_node);
- }
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_notify_optional_notification_subscribers(kaa_notification_manager_t *self,
- uint64_t topic_id, kaa_notification_t *notification)
-{
- KAA_RETURN_IF_NIL3(self, topic_id, notification, KAA_ERR_BADPARAM);
- kaa_list_node_t *opt_listeners_node = kaa_list_find_next(
- kaa_list_begin(self->optional_listeners),
- kaa_find_optional_notification_listener_by_id, &topic_id);
- KAA_RETURN_IF_NIL(opt_listeners_node, KAA_ERR_NOT_FOUND);
-
- kaa_optional_notification_listeners_wrapper_t* optional_wrapper =
- kaa_list_get_data(opt_listeners_node);
-
- kaa_list_node_t *optional_listener_node = kaa_list_begin(optional_wrapper->listeners);
- while (optional_listener_node) {
- kaa_notification_listener_wrapper_t *wrapper = kaa_list_get_data(optional_listener_node);
- wrapper->listener.callback(wrapper->listener.context, &topic_id, notification);
- optional_listener_node = kaa_list_next(optional_listener_node);
- }
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_add_subscribtion_or_unsubscribtion(kaa_list_t *target, uint64_t *topic_id)
-{
- KAA_RETURN_IF_NIL2(target, topic_id, KAA_ERR_BADPARAM);
- uint64_t *subs_topic_id = (uint64_t *) KAA_MALLOC(sizeof(uint64_t));
- KAA_RETURN_IF_NIL(subs_topic_id, KAA_ERR_NOMEM);
- *subs_topic_id = *topic_id;
- if (!kaa_list_push_front(target, subs_topic_id)) {
- KAA_FREE(subs_topic_id);
- return KAA_ERR_NOMEM;
- }
-
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_add_subscribtions_or_unsubscribtions(kaa_notification_manager_t *self, uint64_t *topic_ids, size_t size, uint8_t subscription_id)
-{
- KAA_RETURN_IF_NIL2(self, topic_ids, KAA_ERR_BADPARAM);
-
- kaa_list_t *new_subscriptions = kaa_list_create();
- KAA_RETURN_IF_NIL(new_subscriptions, KAA_ERR_NOMEM);
- while (size--) {
- uint64_t *subs_topic_id = KAA_MALLOC(sizeof(*subs_topic_id));
- KAA_RETURN_IF_NIL(subs_topic_id, KAA_ERR_NOMEM);
- *subs_topic_id = topic_ids[size];
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to add %s to topic with id '%llu'",
- subscription_id == SUBSCRIPTION_ID ? "subscription" : "unsubscription",
- *subs_topic_id);
- if (!kaa_list_push_front(new_subscriptions, subs_topic_id)) {
- KAA_FREE(subs_topic_id);
- kaa_list_destroy(new_subscriptions, &kaa_data_destroy);
- return KAA_ERR_NOMEM;
- }
- }
- kaa_list_t *subscriptions = subscription_id == SUBSCRIPTION_ID ? self->subscriptions : self->unsubscriptions;
- kaa_lists_merge(subscriptions, new_subscriptions);
- kaa_list_destroy(new_subscriptions, NULL);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_subscribe_to_topic(kaa_notification_manager_t *self, uint64_t *topic_id, bool force_sync)
-{
- KAA_RETURN_IF_NIL2(self, topic_id, KAA_ERR_BADPARAM);
- kaa_topic_t* topic = NULL;
- kaa_error_t err = kaa_find_topic(self, &topic, topic_id);
- if (err) {
- KAA_LOG_WARN(self->logger, KAA_ERR_BADPARAM, "Failed to subscribe to the topic with id '%llu'.", *topic_id);
- return err;
- }
- if (topic->subscription_type == MANDATORY_SUBSCRIPTION) {
- KAA_LOG_WARN(self->logger, KAA_ERR_BADPARAM, "Failed to subscribe to the topic with id '%llu'. Topic isn't optional.", *topic_id);
- return KAA_ERR_BADPARAM;
- }
- err = kaa_add_subscribtion_or_unsubscribtion(self->subscriptions, topic_id);
- KAA_RETURN_IF_ERR(err);
-
- if (force_sync) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to subscribe to topic '%llu'", *topic_id);
- kaa_sync_topic_subscriptions(self);
- } else {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Subscription to topic '%llu' is postponed till sync", *topic_id);
- }
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_subscribe_to_topics(kaa_notification_manager_t *self, uint64_t *topic_ids, size_t size, bool force_sync)
-{
- KAA_RETURN_IF_NIL2(self, topic_ids, KAA_ERR_BADPARAM);
- kaa_topic_t *topic = NULL;
- kaa_error_t err = KAA_ERR_NONE;
- size_t size_copy = size;
- while (size_copy--) {
- err = kaa_find_topic(self, &topic, topic_ids + size_copy);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to subscribe to the topic: topic not found, id '%llu'", topic_ids[size_copy]);
- return err;
- } else {
- if (topic->subscription_type == MANDATORY_SUBSCRIPTION) {
- KAA_LOG_WARN(self->logger, KAA_ERR_BADPARAM, "Failed to subscribe to the topics. Topic with id '%llu'. Topic isn't optional.", topic_ids[size_copy]);
- return KAA_ERR_BADPARAM;
- }
- }
- }
- if (force_sync) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to subscribe to the topics");
- } else {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Subscription to topics is postponed till sync");
- }
- err = kaa_add_subscribtions_or_unsubscribtions(self, topic_ids, size, SUBSCRIPTION_ID);
- KAA_RETURN_IF_ERR(err);
-
- if (force_sync) {
- kaa_sync_topic_subscriptions(self);
- }
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_unsubscribe_from_topic(kaa_notification_manager_t *self, uint64_t *topic_id, bool force_sync)
-{
- KAA_RETURN_IF_NIL2(self, topic_id, KAA_ERR_BADPARAM);
- kaa_topic_t* topic = NULL;
- kaa_error_t err = kaa_find_topic(self, &topic, topic_id);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to unsubscribe from the topic with id '%llu'.", *topic_id);
- return err;
- }
- if (topic->subscription_type == MANDATORY_SUBSCRIPTION) {
- KAA_LOG_WARN(self->logger, KAA_ERR_BADPARAM, "Failed to unsubscribe from the topic with id '%llu'. Topic isn't optional.", *topic_id);
- return KAA_ERR_BADPARAM;
- }
- err = kaa_add_subscribtion_or_unsubscribtion(self->unsubscriptions, topic_id);
- KAA_RETURN_IF_ERR(err);
-
- if (force_sync) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to unsubscribe from the topic '%llu'", *topic_id);
- kaa_sync_topic_subscriptions(self);
- } else {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Unsubscription from the topic '%llu' is postponed till sync", *topic_id);
- }
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_unsubscribe_from_topics(kaa_notification_manager_t *self, uint64_t *topic_ids, size_t size, bool force_sync)
-{
- KAA_RETURN_IF_NIL2(self, topic_ids, KAA_ERR_BADPARAM);
- kaa_topic_t *topic = NULL;
- kaa_error_t err = KAA_ERR_NONE;
- size_t size_copy = size;
-
- while (size_copy--) {
- err = kaa_find_topic(self, &topic, topic_ids + size_copy);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to unsubscribe from the topic: topic not found, id '%llu'", topic_ids[size_copy]);
- return err;
- } else {
- if (topic->subscription_type == MANDATORY_SUBSCRIPTION) {
- KAA_LOG_WARN(self->logger, KAA_ERR_BADPARAM, "Failed to unsubscribe from the topics. Topic with id '%llu'. Topic isn't optional.", topic_ids[size_copy]);
- return KAA_ERR_BADPARAM;
- }
- }
- }
-
- if (force_sync) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to unsubscribe from the topics");
- } else {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Unsubscription from the topics is postponed till sync");
- }
-
- err = kaa_add_subscribtions_or_unsubscribtions(self, topic_ids, size, UNSUBSCRIPTION_ID);
- KAA_RETURN_IF_ERR(err);
-
- if (force_sync) {
- kaa_sync_topic_subscriptions(self);
- }
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t do_sync(kaa_notification_manager_t *self)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(self->channel_manager,
- notification_sync_services[0]);
- if (channel) {
- channel->sync_handler(channel->context, notification_sync_services, 1);
- } else {
- KAA_LOG_ERROR(self->logger, KAA_ERR_NOT_FOUND, "Failed to sync: transport channel not found");
- }
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_sync_topic_subscriptions(kaa_notification_manager_t *self)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
- return do_sync(self);
-}
-
-static kaa_error_t kaa_topic_list_update(kaa_notification_manager_t *self, kaa_list_t *new_topics)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
- kaa_topic_t *topic = NULL;
- kaa_list_node_t *topic_node = kaa_list_begin(new_topics);
-
- // "Substracts" self topics from new topics based on IDs
- while (topic_node && kaa_list_get_size(self->status->topics) > 0) {
- topic = kaa_list_get_data(topic_node);
- KAA_RETURN_IF_NIL(topic, KAA_ERR_NOMEM);
- kaa_list_remove_first(self->status->topics, kaa_find_topic_by_id, &topic->id, destroy_topic);
- topic_node = kaa_list_next(topic_node);
- }
-
- if (kaa_list_get_size(self->status->topics)) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE,
- "Going to remove optional listener(s) from obsolete %zu topics",
- kaa_list_get_size(self->status->topics));
-
- kaa_list_node_t *outdated_topics = kaa_list_begin(self->status->topics);
- while (outdated_topics) {
- topic = kaa_list_get_data(outdated_topics);
- kaa_list_remove_first(self->optional_listeners,
- kaa_find_optional_notification_listener_by_id, &topic->id,
- destroy_optional_listeners_wrapper);
- outdated_topics = kaa_list_next(outdated_topics);
- }
- }
-
- kaa_list_destroy(self->status->topics, &destroy_topic);
- kaa_list_sort(new_topics, &sort_topic_by_id);
- self->status->topic_list_hash = kaa_list_hash(new_topics, &get_topic_id);
- self->status->topics = new_topics;
- return kaa_notify_topic_update_subscribers(self, new_topics);
-}
-
-static kaa_error_t kaa_notification_received(kaa_notification_manager_t *self, kaa_notification_t *notification, uint64_t topic_id)
-{
- KAA_RETURN_IF_NIL2(self, notification, KAA_ERR_BADDATA);
- if (kaa_notify_optional_notification_subscribers(self, topic_id, notification)) {
- kaa_notify_mandatory_notification_subscribers(self, topic_id, notification);
- }
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t update_sequence_number(kaa_notification_manager_t *self, uint64_t topic_id, uint32_t sqn_number)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
-
- kaa_topic_state_t *state;
- kaa_list_node_t *it = kaa_list_find_next(kaa_list_begin(self->status->topic_states),
- kaa_find_topic_state_by_id, &topic_id);
- if (!it) {
- state = KAA_MALLOC(sizeof(*state));
- KAA_RETURN_IF_NIL(state, KAA_ERR_NOMEM);
-
- if (!kaa_list_push_front(self->status->topic_states, state)) {
- KAA_FREE(state);
- return KAA_ERR_NOMEM;
- }
-
- state->topic_id = topic_id;
- state->sqn_number = sqn_number;
- self->status->has_update = true;
- } else {
- state = kaa_list_get_data(it);
- if (sqn_number > state->sqn_number) {
- state->sqn_number = sqn_number;
- self->status->has_update = true;
- }
- }
- return KAA_ERR_NONE;
-}
-
-static void kaa_notify_notification_listeners(void *data, void* context)
-{
- KAA_RETURN_IF_NIL2(data, context, );
- kaa_error_t err = KAA_ERR_NONE;
- kaa_topic_notifications_node_t *node = data;
- kaa_list_node_t *notification_list_node = kaa_list_begin(node->notifications);
- kaa_notification_manager_t *self = context;
-
- while(notification_list_node) {
- kaa_notification_wrapper_t *wrapper = kaa_list_get_data(notification_list_node);
- kaa_list_node_t *it = kaa_list_find_next(kaa_list_begin(self->status->topic_states),
- kaa_find_topic_state_by_id, &node->topic_id);
- if (it) {
- kaa_topic_state_t *state = kaa_list_get_data(it);
- if (wrapper->sqn > state->sqn_number) {
- err = kaa_notification_received(self, wrapper->notification, node->topic_id);
- }
- } else {
- err = kaa_notification_received(self, wrapper->notification, node->topic_id);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to notify notification listener");
- return;
- }
- }
-
- err = update_sequence_number(self, node->topic_id, wrapper->sqn);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to update notification sequence number for topic '%llu'", node->topic_id);
- }
-
- notification_list_node = kaa_list_next(notification_list_node);
- }
-}
-
-kaa_error_t kaa_notification_manager_handle_server_sync(kaa_notification_manager_t *self,
- kaa_platform_message_reader_t *reader, uint32_t extension_length)
-{
- KAA_RETURN_IF_NIL2(self, reader, KAA_ERR_BADPARAM);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received notification server sync: options 0, payload size %lu", extension_length);
-
- kaa_list_clear(self->subscriptions, &kaa_data_destroy);
- kaa_list_clear(self->unsubscriptions, &kaa_data_destroy);
-
- if (extension_length > 0) {
- kaa_error_t err = KAA_ERR_NONE;
- if (KAA_NTOHL(*((uint32_t *) reader->current)) == KAA_NO_DELTA) {
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Received delta response: NO DELTA. Going to clear uids list...");
- kaa_list_clear(self->uids, destroy_notifications_uid);
- }
- shift_and_sub_extension(reader, &extension_length, sizeof(uint32_t));
- while (extension_length > 0) {
- uint8_t field_id = *(uint8_t *)reader->current; //field id
- shift_and_sub_extension(reader, &extension_length, sizeof(uint16_t)); // + reserved
-
- switch (field_id) {
- case NOTIFICATIONS: {
- kaa_notification_t *notification = NULL;
- uint32_t seq_number = 0;
- uint16_t notifications_count = KAA_NTOHS(*((uint16_t *) reader->current)); // notifications count
- shift_and_sub_extension(reader, &extension_length, sizeof(uint16_t));
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received notifications. Notifications count is %u", notifications_count);
-
- while (notifications_count--) {
- seq_number = KAA_NTOHL(*((uint32_t *) reader->current)); // sqn of the last received notification
- shift_and_sub_extension(reader, &extension_length, sizeof(uint16_t) + sizeof(uint32_t)); // + notification type
- uint16_t uid_length = KAA_NTOHS(*((uint16_t *) reader->current)); // uid length
- shift_and_sub_extension(reader, &extension_length, sizeof(uint16_t));
- uint32_t notification_size = KAA_NTOHL(*((uint32_t *) reader->current)); // notification body size
- shift_and_sub_extension(reader, &extension_length, sizeof(uint32_t));
- uint64_t topic_id = KAA_NTOHLL(*((uint64_t *) reader->current)); // topic id
- shift_and_sub_extension(reader, &extension_length, sizeof(uint64_t));
-
- kaa_topic_t *topic_found;
- err = kaa_find_topic(self, &topic_found, &topic_id);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Topic with id %llu is not found. Skipping notification...", topic_id);
- size_t skiped_size = kaa_aligned_size_get(uid_length) + kaa_aligned_size_get(notification_size);
- shift_and_sub_extension(reader, &extension_length, skiped_size);
- continue;
- }
- if (uid_length) {
- kaa_notifications_uid_t *uid = KAA_MALLOC(sizeof(*uid));
- KAA_RETURN_IF_NIL(uid, KAA_ERR_NOMEM);
-
- uid->length = uid_length;
- uid->data = KAA_MALLOC(uid_length);
- if (!uid->data) {
- destroy_notifications_uid(uid);
- return KAA_ERR_NOMEM;
- }
- err = kaa_platform_message_read_aligned(reader, uid->data, uid->length);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to read UID body, topic id %llu", topic_id);
- return err;
- }
- extension_length -= kaa_aligned_size_get(uid->length);
-
- kaa_list_node_t *has_been_already_received = kaa_list_find_next(kaa_list_begin(self->uids), &kaa_find_uid, uid);
- if (has_been_already_received) {
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "This unicast notification has been already received");
- shift_and_sub_extension(reader, &extension_length, kaa_aligned_size_get(notification_size));
- destroy_notifications_uid(uid);
- continue;
- }
-
- if (!kaa_list_push_front(self->uids, uid)) {
- destroy_notifications_uid(uid);
- return KAA_ERR_NOMEM;
- }
- }
- if (notification_size) {
- avro_reader_t avro_reader = avro_reader_memory((const char *)reader->current, notification_size);
- if (!avro_reader) {
- return KAA_ERR_NOMEM;
- }
- notification = KAA_NOTIFICATION_DESERIALIZE(avro_reader);
- avro_reader_free(avro_reader);
- if (!notification) {
- KAA_LOG_WARN(self->logger, KAA_ERR_NOMEM, "Failed to deserialize notification");
- return KAA_ERR_NOMEM;
- }
- }
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Notification's sqn '%lu', topic id '%llu', type '%s', size '%lu'"
- , seq_number, topic_id, uid_length ? "unicast" : "multicast", notification_size);
- shift_and_sub_extension(reader, &extension_length, kaa_aligned_size_get(notification_size));
- if (uid_length == 0) {
- err = kaa_add_notification_to_map(self->notifications, notification, topic_id, &seq_number);
- } else {
- err = kaa_notification_received(self, notification, topic_id);
- notification->destroy(notification);
- }
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to add notification to map");
- return KAA_ERR_NOMEM;
- }
- }
- break;
- }
-
- case TOPICS: {
- kaa_list_t *new_topics = kaa_list_create();
- KAA_RETURN_IF_NIL(new_topics, KAA_ERR_NOMEM);
-
- uint16_t topic_count = KAA_NTOHS(*((uint16_t *) reader->current)); // topics count
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received topics list. Topics count is %u", topic_count);
- shift_and_sub_extension(reader, &extension_length, sizeof(uint16_t));
-
- while (topic_count--) {
- kaa_topic_t *topic = (kaa_topic_t *) KAA_MALLOC(sizeof(kaa_topic_t));
- KAA_RETURN_IF_NIL(topic, KAA_ERR_NOMEM);
- topic->id = KAA_NTOHLL(*((uint64_t *) reader->current)); // topic id
- shift_and_sub_extension(reader, &extension_length, sizeof(uint64_t));
- topic->subscription_type = (*((uint8_t *) reader->current) == MANDATORY_SUBSCRIPTION) ? MANDATORY_SUBSCRIPTION : OPTIONAL_SUBSCRIPTION;
- shift_and_sub_extension(reader, &extension_length, sizeof(uint16_t)); // + reserved
- topic->name_length = KAA_NTOHS(*((uint16_t *) reader->current)); // name length
- shift_and_sub_extension(reader, &extension_length, sizeof(uint16_t));
-
- topic->name = (char *) KAA_MALLOC(topic->name_length + 1); // Topic name
- if (!topic->name) {
- destroy_topic(topic);
- return KAA_ERR_NOMEM;
- }
-
- err = kaa_platform_message_read_aligned(reader, topic->name, topic->name_length);
- if (err) {
- KAA_LOG_WARN(self->logger, KAA_ERR_BADDATA, "Failed to read topic's name");
- destroy_topic(topic);
- return err;
- }
-
- topic->name[topic->name_length] = '\0';
- extension_length -= kaa_aligned_size_get(topic->name_length);
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Topic Id '%llu', subscription type '%s', name '%s'"
- , topic->id, (topic->subscription_type == MANDATORY_SUBSCRIPTION) ? "mandatory": "optional", topic->name);
-
- if (!kaa_list_push_front(new_topics, topic)) {
- destroy_topic(topic);
- return KAA_ERR_NOMEM;
- }
- }
-
- err = kaa_topic_list_update(self, new_topics);
- if (err) {
- KAA_LOG_WARN(self->logger, err, "Failed to notify topic list listeners");
- }
- break;
- }
-
- default:
- KAA_LOG_ERROR(self->logger, KAA_ERR_NONE, "Bad field ID type");
- return KAA_ERR_BADDATA;
- }
- }
- }
-
- if (kaa_list_get_size(self->notifications)) {
- kaa_sort_notifications(self->notifications);
- kaa_list_for_each(kaa_list_begin(self->notifications), kaa_list_back(self->notifications), kaa_notify_notification_listeners, self);
- kaa_list_clear(self->notifications, &kaa_destroy_notification_node);
- if (!self->notifications) {
- return KAA_ERR_NOMEM;
- }
- }
-
- return do_sync(self);
-}
diff --git a/client/client-multi/client-c/src/extensions/notification/kaa_notification_manager.h b/client/client-multi/client-c/src/extensions/notification/kaa_notification_manager.h
deleted file mode 100644
index 5e8c75887b..0000000000
--- a/client/client-multi/client-c/src/extensions/notification/kaa_notification_manager.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef KAA_KAA_NOTIFICATION_H_
-#define KAA_KAA_NOTIFICATION_H_
-
-#include
-#include
-#include
-
-#include "kaa_error.h"
-#include "platform/ext_notification_receiver.h"
-#include "collections/kaa_list.h"
-
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef KAA_NOTIFICATION_MANAGER_T
-# define KAA_NOTIFICATION_MANAGER_T
- /**
- * @brief Kaa notification manager structure.
- */
- typedef struct kaa_notification_manager_t kaa_notification_manager_t;
-#endif
-
-
-
-/**
-* @brief Calculates the topic listener id to manage this topic listener.
-*
-* @param[in] listener The pointer to the listener whose id is calculated.
-* @param[out] listener_id The pointer to the variable which is initialized with the calculated id.
-*
-* @return The error code.
-*/
-kaa_error_t kaa_calculate_topic_listener_id(const kaa_topic_listener_t *listener, uint32_t *listener_id);
-
-/**
-* @brief Calculates the notification listener id to manage this notification listener.
-*
-* @param[in] listener The pointer to the listener whose id is calculated.
-* @param[out] listener_id The pointer to the variable which is initialized with the calculated id.
-*
-* @return The error code.
-*/
-kaa_error_t kaa_calculate_notification_listener_id(const kaa_notification_listener_t *listener, uint32_t *listener_id);
-
-/**
-* @brief Adds a mandatory notification listener to receive notifications on mandatory topics.
-*
-* @param[in] self The pointer to the notification manager instance.
-* @param[in] listener The pointer to the listener whose callback is called as soon as a notification is received.
-* @param[out] listener_id The pointer to the variable which is initialized with the calculated id.
-*
-* @return The error code.
-*/
-kaa_error_t kaa_add_notification_listener(kaa_notification_manager_t *self, kaa_notification_listener_t *listener, uint32_t *listener_id);
-
-/**
-* @brief Adds an optional notification listener to receive notifications on optional topics.
-*
-* @param[in] self The pointer to the notification manager instance.
-* @param[in] listener The pointer to the listener whose callback is called as soon as a notification is received.
-* @param[in] topic_id The pointer to the id of the topic about which the listener is notified.
-* @param[out] listener_id The pointer to the variable which is initialized with the calculated id. If @c NULL, @p listener_id is not initialized.
-*
-* @return The error code.
-*/
-kaa_error_t kaa_add_optional_notification_listener(kaa_notification_manager_t *self, kaa_notification_listener_t *listener
- , uint64_t *topic_id, uint32_t *listener_id);
-
-/**
-* @brief Removes the mandatory notification listener.
-*
-* @param[in] self The pointer to the notification manager instance.
-* @param[in] listener_id The pointer to the listener id which is used to find the listener that should be removed from the notification listeners list. If @c NULL, @p listener_id is not initialized
-*
-* @return The error code.
-*/
-kaa_error_t kaa_remove_notification_listener(kaa_notification_manager_t *self, uint32_t *listener_id);
-
-/**
-* @brief Removes the optional notification listener.
-*
-* @param[in] self The pointer to the notification manager instance.
-* @param[in] topic_id The pointer to the id of the topic the listener should not be notified about anymore.
-* @param[in] listener_id The pointer to the variable which is used to find the listener that should be removed from the notification listeners list.
-*
-* @return The error code.
-*/
-kaa_error_t kaa_remove_optional_notification_listener(kaa_notification_manager_t *self, uint64_t *topic_id, uint32_t *listener_id);
-
-/**
-* @brief Adds a topic list listener.
-*
-* @param[in] self The pointer to the notification manager instance.
-* @param[in] listener The pointer to the listener whose callback is called as soon as a notification is received.
-* @param[out] topic_listener_id The pointer to the variable which is initialized with the calculated id.
-*
-* @return The error code.
-*/
-kaa_error_t kaa_add_topic_list_listener(kaa_notification_manager_t *self, kaa_topic_listener_t *listener, uint32_t *topic_listener_id);
-
-/**
-* @brief Removes the topic list listener.
-*
-* @param[in] self The pointer to the notification manager instance.
-* @param[in] topic_listener_id The pointer to the variable which is used to find the listener that should be removed from the topic listeners list. If @c NULL, @p topic_listener_id is not initialized.
-*
-* @return The error code.
-*/
-kaa_error_t kaa_remove_topic_list_listener(kaa_notification_manager_t *self, uint32_t *topic_listener_id);
-
-/**
-* @brief Retrieves the topic list.
-*
-* @param[in] self The pointer to the notification manager instance.
-* @param[out] topics The pointer to the pointer that is initialized with the topic list.
-*
-* @return The error code.
-*/
-kaa_error_t kaa_get_topics(kaa_notification_manager_t *self, kaa_list_t **topics);
-
-/**
-* @brief Subscribes to the topic.
-*
-* @param[in] self The pointer to the notification manager instance.
-* @param[in] topic_id The pointer to the id of the topic to which the endpoint should be subscribed.
-* @param[in] force_sync Indicates whether subscription should be performed immediately (true) or should be postponed (false).
-*
-* @return The error code.
-*/
-kaa_error_t kaa_subscribe_to_topic(kaa_notification_manager_t *self, uint64_t *topic_id, bool force_sync);
-
-/**
-* @brief Subscribes to the topics.
-*
-* @param[in] self The pointer to the notification manager instance.
-* @param[in] topic_ids An array of the ids of the topics to which the endpoint should be subscribed.
-* @param[in] size The size of the topic ids array.
-* @param[in] force_sync Indicates whether subscription should be performed immediately (true) or should be postponed (false).
-*
-* @return The error code.
-*/
-kaa_error_t kaa_subscribe_to_topics(kaa_notification_manager_t *self, uint64_t *topic_ids, size_t size, bool force_sync);
-
-/**
-* @brief Unsubscribes from the topic.
-*
-* @param[in] self The pointer to the notification manager instance.
-* @param[in] topic_id The pointer to the id of the topic from which the endpoint should be unsubscribed.
-* @param[in] force_sync Sync topic unsubscription
-*
-* @return The error code.
-*/
-kaa_error_t kaa_unsubscribe_from_topic(kaa_notification_manager_t *self, uint64_t *topic_id, bool force_sync);
-
-/**
-* @brief Unsubscribes from the topics.
-*
-* @param[in] self The pointer to the notification manager instance.
-* @param[in] topic_ids An array of the ids of the topics from which the endpoint should be unsubscribed.
-* @param[in] size The size of the topic ids array.
-* @param[in] force_sync Indicates whether unsubscription should be performed immediately (true) or should be postponed (false).
-*
-* @return The error code.
-*/
-kaa_error_t kaa_unsubscribe_from_topics(kaa_notification_manager_t *self, uint64_t *topic_ids, size_t size, bool force_sync);
-
-/**
-* @brief Sends the sync request to the server.
-*
-* @param[in] self The pointer to the notification manager instance.
-*
-* @return The error code.
-*/
-kaa_error_t kaa_sync_topic_subscriptions(kaa_notification_manager_t *self);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* KAA_KAA_NOTIFICATION_H_ */
diff --git a/client/client-multi/client-c/src/extensions/notification/test/test_kaa_notification.c b/client/client-multi/client-c/src/extensions/notification/test/test_kaa_notification.c
deleted file mode 100644
index 191ae387ae..0000000000
--- a/client/client-multi/client-c/src/extensions/notification/test/test_kaa_notification.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include
-
-#include "kaa_test.h"
-
-#include "kaa_notification_manager.h"
-#include "kaa.h"
-#include
-#include "kaa_error.h"
-#include "kaa_common.h"
-#include "kaa_context.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-#include "avro_src/avro/io.h"
-#include "platform/sock.h"
-#include "kaa_platform_common.h"
-#include "kaa_platform_utils.h"
-#include "kaa_platform_protocol.h"
-
-//----------------------------------------------------------------------------------------------
-kaa_context_t *context = NULL;
-
-kaa_notification_listener_t listener;
-kaa_notification_listener_t listener_2;
-kaa_logger_t* logger;
-
-uint8_t *buffer_pointer = NULL;
-kaa_list_t *topics = NULL;
-uint64_t topic_id;
-
-uint32_t id,id2;
-kaa_error_t err = 0;
-size_t size = 0;
-
-uint8_t *pointer_to_sqn = NULL;
-
-bool listener_has_been_notified = false;
-kaa_topic_listener_t topic_listener;
-kaa_topic_listener_t topic_listener_2;
-//-----------------------------------------------------------------------------------------------
-void on_notification(void* contextmock, uint64_t *topic_id, kaa_notification_t *notif)
-{
- (void)contextmock;
- (void)topic_id;
- (void)notif;
- printf("\nNotification listener got his Notification\n\n");
- listener_has_been_notified = true;
-}
-
-void on_topic(void* contextmock, kaa_list_t *topics)
-{
- (void)contextmock;
- (void)topics;
- printf("\nTopic list listener got his topic list.\n\n");
-}
-
-uint8_t *buffer = NULL;
-size_t buffer_size = 0;
-
-/* We should remove status file after running the test, because
- * client persists notification sequence number and if the test is run
- * two times in a row, notification manager will throw out the notification
- * which is serialized in test, because it considers that the notification
- * has already been received -> client won't received the notification and
- * the test will be failed.
- */
-#define KAA_STATUS_FILE_NAME "./kaa_status.bin"
-static void remove_state_file(const char* filename)
-{
- int res = remove(filename);
- if (!res) {
- printf("Status file has been successfully removed\n");
- } else {
- printf("Error: Can't remove status file!\n");
- }
-}
-
-
-int test_init(void)
-{
- err = KAA_ERR_NONE;
-
- err = kaa_init(&context);
- if (err) {
- return err;
- }
- listener.callback = &on_notification;
- listener.context = NULL;
- listener_2.callback = &on_notification;
- listener_2.context = &listener;
-
- topic_listener.callback = &on_topic;
- topic_listener.context = NULL;
- topic_listener_2.callback = &on_topic;
- topic_listener_2.context = &topic_listener;
-
- topic_id = 22;
- return 0;
-}
-
-int test_deinit(void)
-{
- if (context) {
- kaa_deinit(context);
- }
- if (buffer_pointer) {
- KAA_FREE(buffer_pointer);
- }
-
- remove_state_file(KAA_STATUS_FILE_NAME);
- return 0;
-}
-
-void test_deserializing(void **state)
-{
- (void)state;
-
- kaa_notification_t *notification = kaa_notification_notification_create();
- const char *message = "Hello World!!!\n";
- notification->message = kaa_string_copy_create(message);
- size = (sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) /*that was header*/+ sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) /*extension options
- and payload length*/ + sizeof(uint32_t) + sizeof(uint32_t) /*state sqn and delta status*/ + sizeof(uint16_t) + sizeof(uint16_t) /*field id and topic count*/ + sizeof(uint64_t) /*topic ID*/
- + sizeof(uint16_t) + sizeof(uint16_t) /*subscriptions type + topic name length*/ + sizeof(uint32_t) /*topic name + padding */ + sizeof(uint16_t) + sizeof(uint16_t) /*field id and notifications count*/
- + sizeof(uint32_t) /* Notification sqn */ + sizeof(uint16_t) + sizeof(uint16_t) /* Notification type + uid length */+ sizeof (uint32_t) /* notification body size*/ + sizeof (uint64_t) /*Topic Id*/
- + /*Not unicast notifications*/ + kaa_aligned_size_get(notification->get_size(notification)));
-
- uint8_t *unserialized_buffer = KAA_MALLOC(size);
- ASSERT_NOT_NULL(unserialized_buffer);
- buffer_pointer = unserialized_buffer;
- memset(unserialized_buffer, 0, size);
- *(uint32_t *)unserialized_buffer = KAA_HTONL((uint32_t) KAA_PLATFORM_PROTOCOL_ID); //KAA_HTONL(KAA_PLATFORM_PROTOCOL_ID);
- unserialized_buffer += sizeof(uint32_t);
- *(uint16_t *)unserialized_buffer = KAA_HTONS((uint16_t)1);
- unserialized_buffer += sizeof(uint16_t);
- *(uint16_t *)unserialized_buffer = KAA_HTONS((uint16_t)1); // extension count
- unserialized_buffer += sizeof(uint16_t);
-
- *(uint16_t *)unserialized_buffer = KAA_HTONS((uint16_t)KAA_EXTENSION_NOTIFICATION);
- unserialized_buffer += sizeof(uint16_t);
- unserialized_buffer += sizeof(uint16_t); // pass by extension options
-
- uint32_t payload_info = sizeof(uint32_t) /*delta status*/ + sizeof(uint16_t) + sizeof(uint16_t) /*field id and topic count*/ + sizeof(uint64_t) /*topic ID*/
- + sizeof(uint16_t) + sizeof(uint16_t) /*subscriptions type + topic name length*/ + sizeof(uint32_t) /*topic name + padding */ + sizeof(uint16_t) + sizeof(uint16_t) /*field id and notifications count*/
- + sizeof(uint32_t) /* Notification sqn */ + sizeof(uint16_t) + sizeof(uint16_t) /* Notification type + uid length */+ sizeof (uint32_t) /* notification body size*/ + sizeof (uint64_t) /*Topic Id*/
- + kaa_aligned_size_get(notification->get_size(notification));
-
- *(uint32_t *)unserialized_buffer = KAA_HTONL((uint32_t) payload_info);
- unserialized_buffer += sizeof(uint32_t);
- *(uint32_t *)unserialized_buffer = KAA_HTONL((uint32_t)2); // Delta status
- unserialized_buffer += sizeof(uint32_t);
- //TOPICS
- *(uint8_t *)unserialized_buffer = (uint8_t)0;
- unserialized_buffer += sizeof(uint16_t);
- *(uint16_t *)unserialized_buffer = KAA_HTONS ((uint16_t)1); // topics count
- unserialized_buffer += sizeof(uint16_t);
- *(uint64_t *)unserialized_buffer = KAA_HTONLL((uint64_t)22); //topic id
- unserialized_buffer += sizeof(uint64_t);
- *(uint8_t *)unserialized_buffer = (uint8_t)OPTIONAL_SUBSCRIPTION;
- unserialized_buffer += sizeof(uint16_t);
- *(uint16_t *)unserialized_buffer = KAA_HTONS((uint16_t)4); //KAA
- unserialized_buffer += sizeof(uint16_t);
- *unserialized_buffer++ = 'K';*unserialized_buffer++ = 'A'; // topic name + padding
- *unserialized_buffer++ = 'A';*unserialized_buffer++ = 'A';
- unserialized_buffer += (4 - kaa_aligned_size_get(4));
- //-----------------------------------------------------------------------
- *(uint8_t *)unserialized_buffer = (uint8_t)1; //Notification field ID
- unserialized_buffer += sizeof(uint16_t);
- *(uint16_t *)unserialized_buffer = KAA_HTONS ((uint16_t)1); // notitifications count
- unserialized_buffer += sizeof(uint16_t);
- *(uint32_t *)unserialized_buffer = KAA_HTONL((uint32_t)99); //sqn
- pointer_to_sqn = unserialized_buffer; // To have the possibility to change sqn.
- unserialized_buffer += sizeof(uint32_t);
- *(uint8_t *)unserialized_buffer = (uint8_t)0x1; //notification type
- unserialized_buffer += sizeof(uint16_t);
- *(uint16_t *)unserialized_buffer = KAA_HTONS ((uint16_t) 0); //uid length
- unserialized_buffer += sizeof(uint16_t);
- *(uint32_t *)unserialized_buffer = KAA_HTONL ((uint32_t)notification->get_size(notification));
- unserialized_buffer += sizeof(uint32_t);
- *(uint64_t *)unserialized_buffer = KAA_HTONLL((uint64_t)22);
- unserialized_buffer += sizeof(uint64_t);
-
- avro_writer_t avro_writer = avro_writer_memory((const char *)unserialized_buffer, notification->get_size(notification));
- notification->serialize(avro_writer, notification);
- err = kaa_platform_protocol_process_server_sync(context->platform_protocol, buffer_pointer, size);
- avro_writer_free(avro_writer);
-
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- notification->destroy(notification);
-}
-
-void test_notification_listeners_adding_and_removing(void **state)
-{
- (void)state;
-
- err = kaa_add_notification_listener(context->notification_manager, &listener, &id);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_add_notification_listener(context->notification_manager, &listener, &id);
- ASSERT_NOT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_add_notification_listener(context->notification_manager, &listener_2, &id2);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_remove_notification_listener(context->notification_manager, &id);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_remove_notification_listener(context->notification_manager, &id);
- ASSERT_NOT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_remove_notification_listener(context->notification_manager, &id2);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_add_optional_notification_listener(context->notification_manager, &listener, &topic_id, &id);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_add_optional_notification_listener(context->notification_manager, &listener, &topic_id, &id);
- ASSERT_NOT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_add_optional_notification_listener(context->notification_manager, &listener_2, &topic_id, &id2);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- *(uint32_t *)pointer_to_sqn = KAA_HTONL((uint32_t) 100); // Need to change sqn
- err = kaa_platform_protocol_process_server_sync(context->platform_protocol, buffer_pointer, size);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- ASSERT_EQUAL(listener_has_been_notified, true); // whether callback has been called
-
- err = kaa_remove_optional_notification_listener(context->notification_manager, &topic_id, &id);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_remove_optional_notification_listener(context->notification_manager, &topic_id, &id);
- ASSERT_NOT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_remove_optional_notification_listener(context->notification_manager, &topic_id, &id2);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-}
-
-void test_topic_list_listeners_adding_and_removing(void **state)
-{
- (void)state;
-
- err = kaa_get_topics(context->notification_manager, &topics);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_add_topic_list_listener(context->notification_manager, &topic_listener, &id);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_add_topic_list_listener(context->notification_manager, &topic_listener, &id);
- ASSERT_NOT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_add_topic_list_listener(context->notification_manager, &topic_listener_2, &id2);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_remove_topic_list_listener(context->notification_manager, &id);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_remove_topic_list_listener(context->notification_manager, &id);
- ASSERT_NOT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_remove_topic_list_listener(context->notification_manager, &id2);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-}
-
-void test_retrieving_topic_list(void **state)
-{
- (void)state;
-
- err = kaa_get_topics(context->notification_manager, &topics);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- size_t topics_size = kaa_list_get_size(topics);
- ASSERT_EQUAL(topics_size, 1);
-}
-
-void test_serializing(void **state)
-{
- (void)state;
-
- kaa_extension_id service[] = { KAA_EXTENSION_NOTIFICATION };
-
- err = kaa_platform_protocol_alloc_serialize_client_sync(context->platform_protocol, service, 1,
- &buffer, &buffer_size);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- KAA_FREE(buffer);
-}
-
-void test_subscriptions(void **state)
-{
- (void)state;
-
- err = kaa_subscribe_to_topic(context->notification_manager, &topic_id, false);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_unsubscribe_from_topic(context->notification_manager, &topic_id, false);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- uint64_t fake_ids[2] = { 22, 11 };
- err = kaa_subscribe_to_topics(context->notification_manager, fake_ids, 2, false);
- ASSERT_NOT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_unsubscribe_from_topics(context->notification_manager, fake_ids, 2, false);
- ASSERT_NOT_EQUAL(err, KAA_ERR_NONE);
-
- uint64_t existing_ids[1] = { 22 };
- err = kaa_subscribe_to_topics(context->notification_manager, existing_ids, 1, false);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-
- err = kaa_unsubscribe_from_topics(context->notification_manager, existing_ids, 1, false);
- ASSERT_EQUAL(err, KAA_ERR_NONE);
-}
-
-KAA_SUITE_MAIN(Notification, test_init, test_deinit,
- KAA_TEST_CASE(deserializing, test_deserializing)
- KAA_TEST_CASE(removing_and_adding_notifications_listeners, test_notification_listeners_adding_and_removing)
- KAA_TEST_CASE(removing_and_adding_topic_list_listeners, test_topic_list_listeners_adding_and_removing)
- KAA_TEST_CASE(topic_list_retrieving, test_retrieving_topic_list)
- KAA_TEST_CASE(serializing, test_serializing)
- KAA_TEST_CASE(subscriptions, test_subscriptions))
diff --git a/client/client-multi/client-c/src/extensions/profile/CMakeLists.txt b/client/client-multi/client-c/src/extensions/profile/CMakeLists.txt
deleted file mode 100644
index a486431441..0000000000
--- a/client/client-multi/client-c/src/extensions/profile/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set(EXTENSION_PROFILE_SOURCE_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_profile.c)
-
-set(EXTENSION_PROFILE_HEADER_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_profile.h)
-
-add_library(extension_profile ${EXTENSION_PROFILE_SOURCE_FILES})
-target_include_directories(extension_profile PUBLIC ${CMAKE_CURRENT_LIST_DIR})
-target_link_libraries(extension_profile PUBLIC kaac)
-
-kaa_add_unit_test(NAME test_profile
- SOURCES
- ${CMAKE_CURRENT_LIST_DIR}/test/test_kaa_profile.c
- test/kaa_test_external.c
- ${KAA_SRC_FOLDER}/gen/kaa_profile_gen.c
- DEPENDS
- kaac)
diff --git a/client/client-multi/client-c/src/extensions/profile/kaa_profile.c b/client/client-multi/client-c/src/extensions/profile/kaa_profile.c
deleted file mode 100644
index 9bb4d27015..0000000000
--- a/client/client-multi/client-c/src/extensions/profile/kaa_profile.c
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include "kaa_profile_private.h"
-
-#include "kaa_private.h"
-
-#include
-#include
-#include
-#include
-#include "platform/sock.h"
-#include "avro_src/avro/io.h"
-#include "platform/ext_sha.h"
-#include "platform/ext_key_utils.h"
-#include "kaa_status.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-#include "kaa_defaults.h"
-#include "kaa_channel_manager.h"
-#include "kaa_platform_common.h"
-#include "kaa_platform_utils.h"
-
-
-
-#define KAA_PROFILE_RESYNC_OPTION 0x1
-
-static kaa_extension_id profile_sync_services[] = { KAA_EXTENSION_PROFILE };
-
-typedef struct {
- size_t payload_size;
- kaa_bytes_t public_key;
- kaa_bytes_t access_token;
-} kaa_profile_extension_data_t;
-
-struct kaa_profile_manager_t {
- bool need_resync;
- kaa_bytes_t profile_body;
- kaa_digest profile_hash;
- kaa_channel_manager_t *channel_manager;
- kaa_status_t *status;
- kaa_logger_t *logger;
- kaa_profile_extension_data_t *extension_data;
-};
-
-kaa_error_t kaa_extension_profile_init(kaa_context_t *kaa_context, void **context)
-{
- kaa_error_t result = kaa_profile_manager_create(&kaa_context->profile_manager,
- kaa_context->status->status_instance,
- kaa_context->channel_manager, kaa_context->logger);
- *context = kaa_context->profile_manager;
- return result;
-}
-
-kaa_error_t kaa_extension_profile_deinit(void *context)
-{
- kaa_profile_manager_destroy(context);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_profile_request_get_size(void *context,
- size_t *expected_size)
-{
- return kaa_profile_request_get_size(context, expected_size);
-}
-
-static bool resync_is_required(kaa_profile_manager_t *self)
-{
- return self->need_resync || self->status->profile_needs_resync;
-}
-
-kaa_error_t kaa_extension_profile_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync)
-{
- (void)request_id;
-
- // TODO(KAA-982): Use asserts
- if (!context || !size || !need_resync) {
- return KAA_ERR_BADPARAM;
- }
-
- *need_resync = resync_is_required(context);
- if (!*need_resync) {
- *size = 0;
- return KAA_ERR_NONE;
- }
-
- size_t size_needed;
- kaa_error_t error = kaa_profile_request_get_size(context, &size_needed);
- if (error) {
- return error;
- }
-
- if (!buffer || *size < size_needed) {
- *size = size_needed;
- return KAA_ERR_BUFFER_IS_NOT_ENOUGH;
- }
-
- *size = size_needed;
-
- kaa_platform_message_writer_t writer = KAA_MESSAGE_WRITER(buffer, *size);
- error = kaa_profile_request_serialize(context, &writer);
- if (error) {
- return error;
- }
-
- *size = writer.current - buffer;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_profile_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size)
-{
- (void)request_id;
-
- // TODO(KAA-982): Use asserts
- if (!context || !buffer) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_platform_message_reader_t reader = KAA_MESSAGE_READER(buffer, size);
- return kaa_profile_handle_server_sync(context, &reader, extension_options, size);
-}
-
-/*
- * PUBLIC FUNCTIONS
- */
-/** @deprecated Use kaa_extension_profile_init(). */
-kaa_error_t kaa_profile_manager_create(kaa_profile_manager_t **profile_manager_p, kaa_status_t *status
- , kaa_channel_manager_t *channel_manager, kaa_logger_t *logger)
-{
- if (!profile_manager_p || !channel_manager || !status) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_profile_manager_t *profile_manager = KAA_MALLOC(sizeof(kaa_profile_manager_t));
- if (!profile_manager) {
- return KAA_ERR_NOMEM;
- }
-
- /**
- * KAA_CALLOC is really needed.
- */
- profile_manager->extension_data = KAA_CALLOC(1, sizeof(kaa_profile_extension_data_t));
- if (!profile_manager->extension_data) {
- KAA_FREE(profile_manager);
- return KAA_ERR_NOMEM;
- }
-
- profile_manager->need_resync = true;
-
- profile_manager->profile_body.size = 0;
- profile_manager->profile_body.buffer = NULL;
- profile_manager->channel_manager = channel_manager;
- profile_manager->status = status;
- profile_manager->logger = logger;
-
- ext_calculate_sha_hash(NULL, 0, profile_manager->profile_hash);
- ext_copy_sha_hash(profile_manager->status->profile_hash, profile_manager->profile_hash);
-
- *profile_manager_p = profile_manager;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_profile_force_sync(kaa_profile_manager_t *self)
-{
- if (!self)
- return KAA_ERR_BADPARAM;
-
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(
- self->channel_manager, KAA_EXTENSION_PROFILE);
- if (!channel) {
- return KAA_ERR_NOT_FOUND;
- }
-
- channel->sync_handler(channel->context, profile_sync_services, 1);
- return KAA_ERR_NONE;
-}
-
-
-bool kaa_profile_manager_is_profile_set(kaa_profile_manager_t *self)
-{
-#if KAA_PROFILE_SCHEMA_VERSION > 0
- return self->profile_body.buffer != NULL && self->profile_body.size != 0;
-#else
- return true;
-#endif
-}
-
-
-
-/** @deprecated Use kaa_extension_profile_deinit(). */
-void kaa_profile_manager_destroy(kaa_profile_manager_t *self)
-{
- if (self) {
- if (self->profile_body.buffer && self->profile_body.size > 0) {
- KAA_FREE(self->profile_body.buffer);
- }
- if (self->extension_data) {
- if (self->extension_data->public_key.buffer && self->extension_data->public_key.destroy) {
- self->extension_data->public_key.destroy(self->extension_data->public_key.buffer);
- }
- KAA_FREE(self->extension_data);
- }
- KAA_FREE(self);
- }
-}
-
-
-
-kaa_error_t kaa_profile_need_profile_resync(kaa_profile_manager_t *self, bool *result)
-{
- KAA_RETURN_IF_NIL2(self, result, KAA_ERR_BADPARAM);
- *result = resync_is_required(self);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_profile_request_get_size(kaa_profile_manager_t *self, size_t *expected_size)
-{
- // TODO(KAA-982): Use asserts
- if (!self || !expected_size) {
- return KAA_ERR_BADPARAM;
- }
-
- if (!resync_is_required(self)) {
- *expected_size = 0;
- return KAA_ERR_NONE;
- }
-
- *expected_size = KAA_EXTENSION_HEADER_SIZE;
- *expected_size += sizeof(uint32_t); // profile body size
-#if KAA_PROFILE_SCHEMA_VERSION > 0
- if (resync_is_required(self))
- *expected_size += kaa_aligned_size_get(self->profile_body.size); // profile data
-#endif
-
- if (!self->status->is_registered) {
- if (!self->extension_data->public_key.buffer) {
- ext_get_endpoint_public_key((const uint8_t **)&self->extension_data->public_key.buffer,
- (size_t *)&self->extension_data->public_key.size);
- }
-
- if (self->extension_data->public_key.buffer && self->extension_data->public_key.size > 0) {
- *expected_size += sizeof(uint32_t); // public key size
- *expected_size += kaa_aligned_size_get(self->extension_data->public_key.size); // public key
-
- } else {
- return KAA_ERR_BADDATA;
- }
- }
-
- self->extension_data->access_token.buffer = (uint8_t *) self->status->endpoint_access_token;
- if (self->extension_data->access_token.buffer) {
- self->extension_data->access_token.size = strlen((const char*)self->extension_data->access_token.buffer);
- *expected_size += sizeof(uint32_t); // access token length
- *expected_size += kaa_aligned_size_get(self->extension_data->access_token.size); // access token
- }
- self->extension_data->payload_size = *expected_size - KAA_EXTENSION_HEADER_SIZE;
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_profile_request_serialize(kaa_profile_manager_t *self, kaa_platform_message_writer_t *writer)
-{
- KAA_RETURN_IF_NIL2(self, writer, KAA_ERR_BADPARAM);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to compile profile client sync");
-
- kaa_error_t error_code = kaa_platform_message_write_extension_header(writer
- , KAA_EXTENSION_PROFILE
- , 0
- , self->extension_data->payload_size);
- KAA_RETURN_IF_ERR(error_code);
-
- uint32_t network_order_32 = KAA_HTONL(0);
-#if KAA_PROFILE_SCHEMA_VERSION > 0
- if (resync_is_required(self)) {
- network_order_32 = KAA_HTONL(self->profile_body.size);
- error_code = kaa_platform_message_write(writer, &network_order_32, sizeof(uint32_t));
- KAA_RETURN_IF_ERR(error_code);
- if (self->profile_body.size) {
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Writing profile body (size %u)...", self->profile_body.size);
- error_code = kaa_platform_message_write_aligned(writer, self->profile_body.buffer, self->profile_body.size);
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to write profile body");
- return error_code;
- }
- }
- } else {
- error_code = kaa_platform_message_write(writer, &network_order_32, sizeof(uint32_t));
- KAA_RETURN_IF_ERR(error_code);
- }
-#else
- error_code = kaa_platform_message_write(writer, &network_order_32, sizeof(uint32_t));
- KAA_RETURN_IF_ERR(error_code);
-#endif
-
- uint16_t network_order_16 = 0;
- uint16_t field_number_with_reserved = 0;
-
- if (!self->status->is_registered) {
- field_number_with_reserved = KAA_HTONS(PUB_KEY_VALUE << 8);
- error_code = kaa_platform_message_write(writer
- , &field_number_with_reserved
- , sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
-
- network_order_16 = KAA_HTONS(self->extension_data->public_key.size);
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Writing public key (size %u)...", self->extension_data->public_key.size);
- error_code = kaa_platform_message_write_aligned(writer
- , (char*)self->extension_data->public_key.buffer
- , self->extension_data->public_key.size);
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to write public key");
- return error_code;
- }
- }
-
- if (self->extension_data->access_token.buffer) {
- field_number_with_reserved = KAA_HTONS(ACCESS_TOKEN_VALUE << 8);
- error_code = kaa_platform_message_write(writer
- , &field_number_with_reserved
- , sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
-
- network_order_16 = KAA_HTONS(self->extension_data->access_token.size);
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Writing access token (size %u)...", self->extension_data->access_token.size);
- error_code = kaa_platform_message_write_aligned(writer
- , (char*)self->extension_data->access_token.buffer
- , self->extension_data->access_token.size);
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to write access token");
- return error_code;
- }
- }
-
- return error_code;
-}
-
-
-
-kaa_error_t kaa_profile_handle_server_sync(kaa_profile_manager_t *self
- , kaa_platform_message_reader_t *reader
- , uint16_t extension_options
- , size_t extension_length)
-{
- // Only used for logging
- (void)extension_options;
- (void)extension_length;
- KAA_RETURN_IF_NIL2(self, reader, KAA_ERR_BADPARAM);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received profile server sync: options %u, payload size %zu", extension_options, extension_length);
-
- kaa_error_t error_code = KAA_ERR_NONE;
-
- self->need_resync = false;
- if (extension_options & KAA_PROFILE_RESYNC_OPTION) {
- self->need_resync = true;
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to resync profile...");
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(self->channel_manager, profile_sync_services[0]);
- if (channel)
- channel->sync_handler(channel->context, profile_sync_services, 1);
- }
-
-
- if (!self->status->is_registered) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Endpoint has been registered");
- self->status->is_registered = true;
- }
-
- return error_code;
-}
-
-kaa_error_t kaa_profile_manager_update_profile(kaa_profile_manager_t *self, kaa_profile_t *profile_body)
-{
-#if KAA_PROFILE_SCHEMA_VERSION > 0
- KAA_RETURN_IF_NIL2(self, profile_body, KAA_ERR_BADPARAM);
-
- size_t serialized_profile_size = profile_body->get_size(profile_body);
- if (!serialized_profile_size) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_BADDATA,
- "Failed to update profile: serialize profile size is null. Maybe profile schema is empty");
- return KAA_ERR_BADDATA;
- }
-
- char *serialized_profile = (char *) KAA_MALLOC(serialized_profile_size * sizeof(char));
- KAA_RETURN_IF_NIL(serialized_profile, KAA_ERR_NOMEM);
-
- avro_writer_t writer = avro_writer_memory(serialized_profile, serialized_profile_size);
- if (!writer) {
- KAA_FREE(serialized_profile);
- return KAA_ERR_NOMEM;
- }
- profile_body->serialize(writer, profile_body);
- avro_writer_free(writer);
-
- kaa_digest new_hash;
- ext_calculate_sha_hash(serialized_profile, serialized_profile_size, new_hash);
-
- if (!memcmp(new_hash, self->status->profile_hash, SHA_1_DIGEST_LENGTH)) {
- self->need_resync = false;
- KAA_FREE(serialized_profile);
- return KAA_ERR_NONE;
- }
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Endpoint profile is updated");
-
- if (ext_copy_sha_hash(self->status->profile_hash, new_hash)) {
- KAA_FREE(serialized_profile);
- return KAA_ERR_BAD_STATE;
- }
-
- if (self->profile_body.size > 0) {
- KAA_FREE(self->profile_body.buffer);
- self->profile_body.buffer = NULL;
- }
-
- self->profile_body.buffer = (uint8_t*)serialized_profile;
- self->profile_body.size = serialized_profile_size;
-
- self->need_resync = true;
-
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(self->channel_manager, profile_sync_services[0]);
- if (channel)
- channel->sync_handler(channel->context, profile_sync_services, 1);
-
-#endif
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_profile_manager_set_endpoint_access_token(kaa_profile_manager_t *self, const char *token)
-{
- KAA_RETURN_IF_NIL2(self, token, KAA_ERR_BADPARAM);
- return kaa_status_set_endpoint_access_token(self->status, token);
-}
-
-kaa_error_t kaa_profile_manager_get_endpoint_id(kaa_profile_manager_t *self, kaa_endpoint_id_p result_id)
-{
- KAA_RETURN_IF_NIL2(self, result_id, KAA_ERR_BADPARAM);
- return ext_copy_sha_hash((kaa_digest_p) result_id, self->status->endpoint_public_key_hash);
-}
diff --git a/client/client-multi/client-c/src/extensions/profile/kaa_profile.h b/client/client-multi/client-c/src/extensions/profile/kaa_profile.h
deleted file mode 100644
index 554a90fae6..0000000000
--- a/client/client-multi/client-c/src/extensions/profile/kaa_profile.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file kaa_profile.h
- * @brief Kaa profile reporting API
- *
- * Supplies API to report endpoint profile to Operations server.
- */
-
-#ifndef KAA_PROFILE_H_
-#define KAA_PROFILE_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include
-#include "kaa_error.h"
-#include "kaa_common.h"
-#include "gen/kaa_profile_definitions.h"
-
-
-
-#ifndef KAA_PROFILE_MANAGER_T
-# define KAA_PROFILE_MANAGER_T
- /**
- * Private profile manager data structure
- */
- typedef struct kaa_profile_manager_t kaa_profile_manager_t;
-#endif
-
-
-
-/**
- * @brief Updates user profile.
- *
- * After a new profile is set a sync request to Operations server will be sent.
- * The profile must be set prior to the endpoint registration.
- *
- * @param[in] self Profile manager instance.
- * @param[in] profile Filled in user-defined profile data structure.
- *
- * @return Error code.
- */
-kaa_error_t kaa_profile_manager_update_profile(kaa_profile_manager_t *self, kaa_profile_t *profile);
-
-
-
-/**
- * @brief Updates user's access token.
- *
- * @param[in] self Profile manager instance.
- * @param[in] token New user access token.
- *
- * @return Error code.
- */
-kaa_error_t kaa_profile_manager_set_endpoint_access_token(kaa_profile_manager_t *self, const char *token);
-
-
-
-/**
- * @brief Retrieves the endpoint ID.
- *
- * @param[in] self Profile manager instance.
- * @param[out] result_id The buffer of size @link KAA_ENDPOINT_ID_LENGTH @endlink where the result will be stored.
- *
- * @return Error code.
- */
-kaa_error_t kaa_profile_manager_get_endpoint_id(kaa_profile_manager_t *self, kaa_endpoint_id_p result_id);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* KAA_PROFILE_H_ */
diff --git a/client/client-multi/client-c/src/extensions/profile/kaa_profile_private.h b/client/client-multi/client-c/src/extensions/profile/kaa_profile_private.h
deleted file mode 100644
index f0db1156a4..0000000000
--- a/client/client-multi/client-c/src/extensions/profile/kaa_profile_private.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef KAA_PROFILE_PRIVATE_H
-#define KAA_PROFILE_PRIVATE_H
-
-#include
-#include
-#include
-#include
-#include
-
-kaa_error_t kaa_profile_manager_create(kaa_profile_manager_t **profile_manager_p, kaa_status_t *status,
- kaa_channel_manager_t *channel_manager, kaa_logger_t *logger);
-void kaa_profile_manager_destroy(kaa_profile_manager_t *self);
-bool kaa_profile_manager_is_profile_set(kaa_profile_manager_t *self);
-
-kaa_error_t kaa_profile_need_profile_resync(kaa_profile_manager_t *kaa_context, bool *result);
-
-kaa_error_t kaa_profile_force_sync(kaa_profile_manager_t *self);
-kaa_error_t kaa_profile_request_get_size(kaa_profile_manager_t *self, size_t *expected_size);
-kaa_error_t kaa_profile_request_serialize(kaa_profile_manager_t *self,
- kaa_platform_message_writer_t* writer);
-kaa_error_t kaa_profile_handle_server_sync(kaa_profile_manager_t *self, kaa_platform_message_reader_t *reader, uint16_t extension_options, size_t extension_length);
-
-#endif /* KAA_PROFILE_PRIVATE_H */
diff --git a/client/client-multi/client-c/src/extensions/profile/test/test_kaa_profile.c b/client/client-multi/client-c/src/extensions/profile/test/test_kaa_profile.c
deleted file mode 100644
index d560187ed7..0000000000
--- a/client/client-multi/client-c/src/extensions/profile/test/test_kaa_profile.c
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include
-#include
-#include
-
-#include "kaa_profile.h"
-#include "kaa_profile_private.h"
-
-#include "kaa_status.h"
-#include "kaa_test.h"
-
-#include "kaa_context.h"
-#include "kaa_status.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-#include "kaa_context.h"
-#include "kaa_defaults.h"
-#include "gen/kaa_profile_gen.h"
-#include "kaa_platform_utils.h"
-#include "platform/ext_status.h"
-#include "platform/ext_sha.h"
-#include "platform/ext_key_utils.h"
-#include "platform/sock.h"
-#include "platform/ext_transport_channel.h"
-#include "kaa_channel_manager.h"
-
-#include "kaa_private.h"
-
-static kaa_context_t kaa_context;
-static kaa_logger_t *logger = NULL;
-static kaa_status_t *status = NULL;
-static kaa_channel_manager_t *channel_manager = NULL;
-static kaa_profile_manager_t *profile_manager = NULL;
-
-
-#define TEST_PUB_KEY_SIZE 20
-static const uint8_t test_ep_key[TEST_PUB_KEY_SIZE] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14};
-
-
-
-void kaa_read_status_ext(char **buffer, size_t *buffer_size, bool *needs_deallocation)
-{
- (void)buffer;
- (void)buffer_size;
- (void)needs_deallocation;
-}
-
-void kaa_store_status_ext(const char *buffer, size_t buffer_size)
-{
- (void)buffer;
- (void)buffer_size;
-}
-
-void kaa_get_endpoint_public_key(char **buffer, size_t *buffer_size, bool *needs_deallocation)
-{
- *buffer = (char *) KAA_MALLOC(TEST_PUB_KEY_SIZE * sizeof(char));
- if (*buffer) {
- memcpy(*buffer, test_ep_key, TEST_PUB_KEY_SIZE);
- *buffer_size = TEST_PUB_KEY_SIZE;
- *needs_deallocation = true;
- } else {
- *buffer_size = 0;
- *needs_deallocation = false;
- }
-}
-
-
-/*----------------------------------------------------------------------------*/
-/* Mock transport channel */
-
-/* Flag to check that sync handler is actually called */
-static int mock_sync_handler_called;
-
-static kaa_error_t init_channel(void *ctx, kaa_transport_context_t *tctx)
-{
- (void)ctx;
- (void)tctx;
- return KAA_ERR_NONE;
-}
-static kaa_error_t set_access_point(void *ctx, kaa_access_point_t *ap)
-{
- (void)ctx;
- (void)ap;
- return KAA_ERR_NONE;
-}
-static kaa_error_t get_protocol_id(void *ctx, kaa_transport_protocol_id_t *id)
-{
- (void)ctx;
- id->id = 0;
- id->version = 0;
- return KAA_ERR_NONE;
-}
-static kaa_error_t get_services(void *ctx,
- const kaa_extension_id **supported_list,
- size_t *count)
-{
- (void)ctx;
- /* Only profile service is "supported" by this mock */
- static const kaa_extension_id services[] = { KAA_EXTENSION_PROFILE };
- *supported_list = services;
- *count = 1;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t sync_handler(void *ctx,
- const kaa_extension_id services[],
- size_t count)
-{
- (void)ctx;
-
- ASSERT_EQUAL(1, count);
- ASSERT_EQUAL(KAA_EXTENSION_PROFILE, services[0]);
-
- mock_sync_handler_called = 1;
-
- return KAA_ERR_NONE;
-}
-
-static kaa_transport_channel_interface_t channel = {
- .context = NULL,
- .destroy = NULL,
- .sync_handler = sync_handler,
- .init = init_channel,
- .set_access_point = set_access_point,
- .get_protocol_id = get_protocol_id,
- .get_supported_services = get_services,
-};
-
-/*----------------------------------------------------------------------------*/
-
-void test_profile_is_set(void **state)
-{
- (void)state;
-
-#if KAA_PROFILE_SCHEMA_VERSION > 0
- ASSERT_FALSE(kaa_profile_manager_is_profile_set(profile_manager));
- kaa_profile_t *profile = kaa_profile_basic_endpoint_profile_test_create();
- profile->profile_body = kaa_string_copy_create("test");
- kaa_error_t error = kaa_profile_manager_update_profile(profile_manager, profile);
- profile->destroy(profile);
- ASSERT_EQUAL(error, KAA_ERR_NONE);
- ASSERT_TRUE(kaa_profile_manager_is_profile_set(profile_manager));
-#else
- ASSERT_TRUE(kaa_profile_manager_is_profile_set(profile_manager));
-#endif
-}
-
-void test_profile_update(void **state)
-{
- (void)state;
-
- kaa_profile_t *profile1 = kaa_profile_basic_endpoint_profile_test_create();
- profile1->profile_body = kaa_string_copy_create("dummy");
- kaa_error_t error = kaa_profile_manager_update_profile(profile_manager, profile1);
- ASSERT_EQUAL(error, KAA_ERR_NONE);
-
- bool need_resync = false;
- error = kaa_profile_need_profile_resync(profile_manager, &need_resync);
- ASSERT_EQUAL(error, KAA_ERR_NONE);
- ASSERT_TRUE(need_resync);
-
- error = kaa_profile_manager_update_profile(profile_manager, profile1);
- ASSERT_EQUAL(error, KAA_ERR_NONE);
-
- error = kaa_profile_need_profile_resync(profile_manager, &need_resync);
- ASSERT_EQUAL(error, KAA_ERR_NONE);
- ASSERT_FALSE(need_resync);
-
- profile1->destroy(profile1);
-
- kaa_profile_t *profile2 = kaa_profile_basic_endpoint_profile_test_create();
- profile2->profile_body = kaa_string_copy_create("new_dummy");
- error = kaa_profile_manager_update_profile(profile_manager, profile2);
- ASSERT_EQUAL(error, KAA_ERR_NONE);
-
- error = kaa_profile_need_profile_resync(profile_manager, &need_resync);
- ASSERT_EQUAL(error, KAA_ERR_NONE);
- ASSERT_TRUE(need_resync);
-
- profile2->destroy(profile2);
-}
-
-void test_profile_sync_get_size(void **state)
-{
- (void)state;
-
- kaa_profile_t *profile = kaa_profile_basic_endpoint_profile_test_create();
- profile->profile_body = kaa_string_copy_create("dummy");
-
- size_t serialized_profile_size = profile->get_size(profile);
- char *serialized_profile = (char *) KAA_MALLOC(serialized_profile_size * sizeof(char));
- avro_writer_t writer = avro_writer_memory(serialized_profile, serialized_profile_size);
- profile->serialize(writer, profile);
-
- size_t expected_size = KAA_EXTENSION_HEADER_SIZE
- + sizeof(uint32_t) // profile size
- + kaa_aligned_size_get(serialized_profile_size);
-
- size_t profile_sync_size = 0;
-
- kaa_error_t error_code = kaa_profile_manager_update_profile(profile_manager, profile);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- status->is_registered = true;
-
- error_code = kaa_profile_request_get_size(profile_manager, &profile_sync_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_EQUAL(expected_size, profile_sync_size);
-
- status->is_registered = false;
-
- expected_size += sizeof(uint32_t)
- + TEST_PUB_KEY_SIZE;
-
- error_code = kaa_profile_request_get_size(profile_manager, &profile_sync_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_EQUAL(expected_size, profile_sync_size);
-
- const char *access_token = "access token";
- error_code = kaa_profile_manager_set_endpoint_access_token(profile_manager, access_token);
- assert_int_equal(KAA_ERR_NONE, error_code);
-
- expected_size += sizeof(uint32_t)
- + strlen(access_token);
-
- error_code = kaa_profile_request_get_size(profile_manager, &profile_sync_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_EQUAL(expected_size, profile_sync_size);
-
- avro_writer_free(writer);
- KAA_FREE(serialized_profile);
- profile->destroy(profile);
-}
-
-void test_profile_sync_serialize(void **state)
-{
- (void)state;
-
- kaa_error_t error_code;
- kaa_platform_message_writer_t *manual_writer;
- kaa_platform_message_writer_t *auto_writer;
-
- const char *access_token = "access token";
- const size_t access_token_size = strlen(access_token);
- kaa_profile_t *profile = kaa_profile_basic_endpoint_profile_test_create();
- profile->profile_body = kaa_string_copy_create("dummy");
- size_t serialized_profile_size = profile->get_size(profile);
- char *serialized_profile = (char *) KAA_MALLOC(serialized_profile_size * sizeof(char));
- avro_writer_t avro_writer = avro_writer_memory(serialized_profile, serialized_profile_size);
-
- profile->serialize(avro_writer, profile);
-
- error_code = kaa_profile_manager_update_profile(profile_manager, profile);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- status->is_registered = false;
- error_code = kaa_profile_manager_set_endpoint_access_token(profile_manager, access_token);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- size_t profile_sync_size;
- error_code = kaa_profile_request_get_size(profile_manager, &profile_sync_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint8_t buffer[profile_sync_size];
- error_code = kaa_platform_message_writer_create(&manual_writer, buffer, profile_sync_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint32_t network_order_32;
-
- error_code = kaa_platform_message_write_extension_header(manual_writer
- , KAA_EXTENSION_PROFILE
- , 0
- , profile_sync_size - KAA_EXTENSION_HEADER_SIZE);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- bool need_resync = true;
- ASSERT_EQUAL(kaa_profile_need_profile_resync(profile_manager, &need_resync), KAA_ERR_NONE);
-
- network_order_32 = KAA_HTONL(0);
- if (need_resync)
- network_order_32 = KAA_HTONL(serialized_profile_size);
- error_code = kaa_platform_message_write(manual_writer, &network_order_32, sizeof(uint32_t));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- if (need_resync) {
- error_code = kaa_platform_message_write_aligned(manual_writer, serialized_profile, serialized_profile_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- }
-
- uint16_t network_order_16 = KAA_HTONS(PUB_KEY_VALUE << 8);
- error_code = kaa_platform_message_write(manual_writer, &network_order_16, sizeof(network_order_16));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- network_order_16 = KAA_HTONS(TEST_PUB_KEY_SIZE);
- error_code = kaa_platform_message_write(manual_writer, &network_order_16, sizeof(network_order_16));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_platform_message_write_aligned(manual_writer, test_ep_key, TEST_PUB_KEY_SIZE);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- network_order_16 = KAA_HTONS(ACCESS_TOKEN_VALUE << 8);
- error_code = kaa_platform_message_write(manual_writer, &network_order_16, sizeof(network_order_16));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- network_order_16 = KAA_HTONS(access_token_size);
- error_code = kaa_platform_message_write(manual_writer, &network_order_16, sizeof(network_order_16));
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_platform_message_write_aligned(manual_writer, access_token, access_token_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- uint8_t buffer2[profile_sync_size];
- error_code = kaa_platform_message_writer_create(&auto_writer, buffer2, profile_sync_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_profile_request_serialize(profile_manager, auto_writer);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = (memcmp(buffer, buffer2, profile_sync_size) == 0 ? KAA_ERR_NONE : KAA_ERR_BADDATA);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- KAA_FREE(serialized_profile);
- avro_writer_free(avro_writer);
- profile->destroy(profile);
- kaa_platform_message_writer_destroy(auto_writer);
- kaa_platform_message_writer_destroy(manual_writer);
-}
-
-void test_profile_handle_sync(void **state)
-{
- (void)state;
-
- bool need_resync = false;
- uint16_t extension_options = 0x1; /* Need resync */
-
- const size_t buffer_size = 6;
- uint8_t buffer[buffer_size];
- kaa_platform_message_reader_t *reader;
- kaa_error_t error_code = kaa_platform_message_reader_create(&reader, buffer, buffer_size);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
-
- error_code = kaa_profile_handle_server_sync(profile_manager, reader, extension_options, 0);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- error_code = kaa_profile_need_profile_resync(profile_manager, &need_resync);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_TRUE(need_resync);
-
- extension_options = 0x0; /* Need resync */
- error_code = kaa_profile_handle_server_sync(profile_manager, reader, extension_options, 0);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- error_code = kaa_profile_need_profile_resync(profile_manager, &need_resync);
- ASSERT_EQUAL(error_code, KAA_ERR_NONE);
- ASSERT_FALSE(need_resync);
-
- kaa_platform_message_reader_destroy(reader);
-}
-
-static void test_profile_force_sync(void **state)
-{
- (void)state;
- kaa_error_t rc = kaa_profile_force_sync(profile_manager);
- ASSERT_EQUAL(KAA_ERR_NONE, rc);
-
- ASSERT_TRUE(mock_sync_handler_called);
-}
-
-int test_init(void **state)
-{
- (void)state;
-
- kaa_error_t error = kaa_log_create(&logger,
- KAA_MAX_LOG_MESSAGE_LENGTH,
- KAA_MAX_LOG_LEVEL,
- NULL);
- if (error || !logger) {
- return error;
- }
-
- kaa_context.logger = logger;
-
- error = kaa_status_create(&status);
- if (error || !status) {
- return error;
- }
-
- error = kaa_channel_manager_create(&channel_manager, &kaa_context);
- if (error || !channel_manager) {
- return error;
- }
-
- /* Add channel will fail due to absent access point, but it is expected */
- kaa_channel_manager_add_transport_channel(channel_manager, &channel, NULL);
-
- error = kaa_profile_manager_create(&profile_manager,
- status, channel_manager, logger);
- if (error || !profile_manager) {
- return error;
- }
-
- return 0;
-}
-
-int test_deinit(void **state)
-{
- (void)state;
-
- kaa_profile_manager_destroy(profile_manager);
- kaa_channel_manager_destroy(channel_manager);
- kaa_status_destroy(status);
- kaa_log_destroy(logger);
- return 0;
-}
-
-int main(void)
-{
- const struct CMUnitTest tests[] = {
- cmocka_unit_test_setup_teardown(test_profile_is_set, test_init, test_deinit),
- cmocka_unit_test_setup_teardown(test_profile_update, test_init, test_deinit),
- cmocka_unit_test_setup_teardown(test_profile_sync_get_size, test_init, test_deinit),
- cmocka_unit_test_setup_teardown(test_profile_sync_serialize, test_init, test_deinit),
- cmocka_unit_test_setup_teardown(test_profile_handle_sync, test_init, test_deinit),
- cmocka_unit_test_setup_teardown(test_profile_force_sync, test_init, test_deinit),
- };
- return cmocka_run_group_tests(tests, NULL, NULL);
-}
diff --git a/client/client-multi/client-c/src/extensions/user/CMakeLists.txt b/client/client-multi/client-c/src/extensions/user/CMakeLists.txt
deleted file mode 100644
index 503831508a..0000000000
--- a/client/client-multi/client-c/src/extensions/user/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright 2014-2016 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set(EXTENSION_USER_SOURCE_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_user.c)
-
-set(EXTENSION_USER_HEADER_FILES
- ${CMAKE_CURRENT_LIST_DIR}/kaa_user.h)
-
-add_library(extension_user ${EXTENSION_USER_SOURCE_FILES})
-target_include_directories(extension_user PUBLIC ${CMAKE_CURRENT_LIST_DIR})
-target_link_libraries(extension_user PUBLIC kaac)
-
-kaa_add_unit_test(NAME test_user_extension
- SOURCES
- ${CMAKE_CURRENT_LIST_DIR}/test/test_kaa_user.c
- test/kaa_test_external.c
- DEPENDS
- kaac)
diff --git a/client/client-multi/client-c/src/extensions/user/kaa_user.c b/client/client-multi/client-c/src/extensions/user/kaa_user.c
deleted file mode 100644
index 972b614c3a..0000000000
--- a/client/client-multi/client-c/src/extensions/user/kaa_user.c
+++ /dev/null
@@ -1,767 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_private.h"
-
-#include "kaa_user.h"
-#include "kaa_user_private.h"
-
-#include
-#include
-#include "platform/stdio.h"
-#include "platform/sock.h"
-#include "kaa_defaults.h"
-#include "platform/ext_sha.h"
-#include "kaa_status.h"
-#include "kaa_channel_manager.h"
-#include "kaa_platform_common.h"
-#include "kaa_platform_utils.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-#include "collections/kaa_list.h"
-#include "kaa_common.h"
-
-
-
-#define KAA_USER_RECEIVE_UPDATES_FLAG 0x01
-
-#define EXTERNAL_SYSTEM_AUTH_FIELD 0x00
-#define EXTERNAL_SYSTEM_ENDPOINT_ATTACH_FIELD 0x01
-#define EXTERNAL_SYSTEM_ENDPOINT_DETACH_FIELD 0x02
-
-#define USER_SYNC_ENDPOINT_ID_OPTION 0x01
-
-
-typedef struct {
- char *user_external_id;
- size_t user_external_id_len;
- char *user_access_token;
- size_t user_access_token_len;
- char *user_verifier_token;
- size_t user_verifier_token_len;
-} user_info_t;
-
-typedef struct {
- uint16_t request_id;
- char *access_token;
- size_t access_token_length;
- kaa_endpoint_id endpoint_token;
- bool is_waiting_response;
- kaa_endpoint_status_listener_t *listener;
-} kaa_endpoint_info_t;
-
-struct kaa_user_manager_t {
- kaa_attachment_status_listeners_t attachment_listeners; /*!< Client code-defined user attachment listeners */
- user_info_t *user_info; /*!< User credentials */
- bool is_waiting_user_attach_response;
- kaa_list_t *attach_endpoints; /*!< Endpoints attach list*/
- kaa_list_t *detach_endpoints; /*!< Endpoints detach list */
- uint16_t endpoint_request_counter; /*!< Endpoints counter of request id*/
- kaa_status_t *status; /*!< Reference to global status */
- kaa_channel_manager_t *channel_manager; /*!< Reference to global channel manager */
- kaa_logger_t *logger;
-};
-
-typedef enum {
- USER_RESULT_SUCCESS = 0x00,
- USER_RESULT_FAILURE = 0x01
-} user_sync_result_t;
-
-typedef enum {
- USER_ATTACH_RESPONSE_FIELD = 0,
- USER_ATTACH_NOTIFICATION_FIELD = 1,
- USER_DETACH_NOTIFICATION_FIELD = 2,
- ENDPOINT_ATTACH_RESPONSES_FIELD = 3,
- ENDPOINT_DETACH_RESPONSES_FIELD = 4
-} user_server_sync_field_t;
-
-
-
-static kaa_extension_id user_sync_services[1] = {KAA_EXTENSION_USER};
-
-kaa_error_t kaa_extension_user_init(kaa_context_t *kaa_context, void **context)
-{
- kaa_error_t error = kaa_user_manager_create(&kaa_context->user_manager, kaa_context->status->status_instance,
- kaa_context->channel_manager, kaa_context->logger);
- *context = kaa_context->user_manager;
- return error;
-}
-
-kaa_error_t kaa_extension_user_deinit(void *context)
-{
- kaa_user_manager_destroy(context);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_user_request_get_size(void *context, size_t *expected_size)
-{
- return kaa_user_request_get_size(context, expected_size);
-}
-
-kaa_error_t kaa_extension_user_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync)
-{
- (void)request_id;
-
- // TODO(KAA-982): Use asserts
- if (!context || !size || !need_resync) {
- return KAA_ERR_BADPARAM;
- }
-
- *need_resync = true;
-
- size_t size_needed;
- kaa_error_t error = kaa_user_request_get_size(context, &size_needed);
- if (error) {
- return error;
- }
-
- if (!buffer || *size < size_needed) {
- *size = size_needed;
- return KAA_ERR_BUFFER_IS_NOT_ENOUGH;
- }
-
- *size = size_needed;
-
- kaa_platform_message_writer_t writer = KAA_MESSAGE_WRITER(buffer, *size);
- error = kaa_user_request_serialize(context, &writer);
- if (error) {
- return error;
- }
-
- *size = writer.current - buffer;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_user_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size)
-{
- (void)request_id;
-
- // TODO(KAA-982): Use asserts
- if (!context || !buffer) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_platform_message_reader_t reader = KAA_MESSAGE_READER(buffer, size);
- return kaa_user_handle_server_sync(context, &reader, extension_options, size);
-}
-
-static void dtor_endpoint_info(void *data)
-{
- KAA_RETURN_IF_NIL(data, );
- kaa_endpoint_info_t *endpoint_info = (kaa_endpoint_info_t*)data;
- if(endpoint_info->access_token)
- KAA_FREE(endpoint_info->access_token);
- KAA_FREE(endpoint_info);
-}
-
-static bool match_predicate_endpoint_info(void *data, void *context)
-{
- KAA_RETURN_IF_NIL2(data, context, false);
-
- kaa_endpoint_info_t *endpoint_item = (kaa_endpoint_info_t*)data;
- uint16_t request_id = *(uint16_t*)context;
-
- return request_id == endpoint_item->request_id;
-}
-
-static void destroy_user_info(user_info_t *user_info)
-{
- KAA_RETURN_IF_NIL(user_info, );
-
- if (user_info->user_external_id)
- KAA_FREE(user_info->user_external_id);
- if (user_info->user_access_token)
- KAA_FREE(user_info->user_access_token);
- if (user_info->user_verifier_token)
- KAA_FREE(user_info->user_verifier_token);
-
- KAA_FREE(user_info);
-}
-
-static user_info_t *create_user_info(const char *external_id, const char *user_access_token, const char *user_verifier_token)
-{
- KAA_RETURN_IF_NIL3(external_id, user_access_token, user_verifier_token, NULL);
-
- user_info_t *user_info = (user_info_t *) KAA_CALLOC(1, sizeof(user_info_t));
- KAA_RETURN_IF_NIL(user_info, NULL);
-
- user_info->user_external_id_len = strlen(external_id);
- user_info->user_access_token_len = strlen(user_access_token);
- user_info->user_verifier_token_len = strlen(user_verifier_token);
-
- user_info->user_external_id = (char *) KAA_MALLOC((user_info->user_external_id_len + 1) * sizeof(char));
- if (!user_info->user_external_id) {
- destroy_user_info(user_info);
- return NULL;
- }
- strcpy(user_info->user_external_id, external_id);
-
- user_info->user_access_token = (char *) KAA_MALLOC((user_info->user_access_token_len + 1) * sizeof(char));
- if (!user_info->user_access_token) {
- destroy_user_info(user_info);
- return NULL;
- }
- strcpy(user_info->user_access_token, user_access_token);
-
- user_info->user_verifier_token = (char *) KAA_MALLOC((user_info->user_verifier_token_len + 1) * sizeof(char));
- if (!user_info->user_verifier_token) {
- destroy_user_info(user_info);
- return NULL;
- }
- strcpy(user_info->user_verifier_token, user_verifier_token);
-
- return user_info;
-}
-
-/** @deprecated Use kaa_extension_user_init(). */
-kaa_error_t kaa_user_manager_create(kaa_user_manager_t **user_manager_p
- , kaa_status_t *status
- , kaa_channel_manager_t *channel_manager
- , kaa_logger_t *logger)
-{
- KAA_RETURN_IF_NIL2(user_manager_p, status, KAA_ERR_BADPARAM);
-
- *user_manager_p = (kaa_user_manager_t *) KAA_MALLOC(sizeof(kaa_user_manager_t));
- KAA_RETURN_IF_NIL((*user_manager_p), KAA_ERR_NOMEM);
-
- (*user_manager_p)->attachment_listeners.on_attached = NULL;
- (*user_manager_p)->attachment_listeners.on_detached = NULL;
- (*user_manager_p)->attachment_listeners.on_attach_success = NULL;
- (*user_manager_p)->attachment_listeners.on_attach_failed = NULL;
- (*user_manager_p)->user_info = NULL;
- (*user_manager_p)->is_waiting_user_attach_response = false;
- (*user_manager_p)->attach_endpoints = kaa_list_create();
- (*user_manager_p)->detach_endpoints = kaa_list_create();
- (*user_manager_p)->endpoint_request_counter = 0;
- (*user_manager_p)->status = status;
- (*user_manager_p)->channel_manager = channel_manager;
- (*user_manager_p)->logger = logger;
-
- return KAA_ERR_NONE;
-}
-
-/** @deprecated Use kaa_extension_user_deinit(). */
-void kaa_user_manager_destroy(kaa_user_manager_t *self)
-{
- if (self) {
- kaa_list_destroy(self->attach_endpoints, dtor_endpoint_info);
- kaa_list_destroy(self->detach_endpoints, dtor_endpoint_info);
- destroy_user_info(self->user_info);
- KAA_FREE(self);
- }
-}
-
-bool kaa_user_manager_is_attached_to_user(kaa_user_manager_t *self)
-{
- KAA_RETURN_IF_NIL2(self, self->status, false);
- return self->status->is_attached;
-}
-
-kaa_error_t kaa_user_manager_attach_to_user(kaa_user_manager_t *self
- , const char *user_external_id
- , const char *access_token
- , const char *user_verifier_token)
-{
- KAA_RETURN_IF_NIL3(self, user_external_id, access_token, KAA_ERR_BADPARAM);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to attach to user "
- "(external id = \"%s\", access token = \"%s\", verifier token = \"%s\")"
- , user_external_id, access_token, user_verifier_token);
-
- if (self->is_waiting_user_attach_response) {
- destroy_user_info(self->user_info);
- self->user_info = NULL;
- self->is_waiting_user_attach_response = false;
- }
-
- self->user_info = create_user_info(user_external_id, access_token, user_verifier_token);
- if (!self->user_info)
- return KAA_ERR_NOMEM;
-
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(self->channel_manager, user_sync_services[0]);
- if (channel)
- channel->sync_handler(channel->context, user_sync_services, 1);
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_user_manager_attach_endpoint(kaa_user_manager_t *self, const char *endpoint_access_token, kaa_endpoint_status_listener_t *listener)
-{
- KAA_RETURN_IF_NIL2(self, endpoint_access_token, KAA_ERR_BADPARAM);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to attach endpoint by access token "
- "(endpoint_access_token = \"%s\")"
- , endpoint_access_token);
-
- kaa_endpoint_info_t *info = KAA_CALLOC(1, sizeof(kaa_endpoint_info_t));
- KAA_RETURN_IF_NIL(info, KAA_ERR_NOMEM);
-
-
- info->access_token_length = strlen(endpoint_access_token);
- info->access_token = KAA_MALLOC(info->access_token_length);
-
- if (!info->access_token) {
- dtor_endpoint_info((void*)info);
- return KAA_ERR_NOMEM;
- }
-
- memcpy(info->access_token, endpoint_access_token, info->access_token_length);
-
- if (listener)
- info->listener = listener;
-
- info->request_id = ++self->endpoint_request_counter;
-
- if (!kaa_list_push_back(self->attach_endpoints, (void*)info)) {
- dtor_endpoint_info((void*)info);
- return KAA_ERR_NOMEM;
- }
-
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(self->channel_manager, user_sync_services[0]);
- if (channel)
- channel->sync_handler(channel->context, user_sync_services, 1);
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_user_manager_detach_endpoint(kaa_user_manager_t *self, const kaa_endpoint_id_p endpoint_hash_key, kaa_endpoint_status_listener_t *listener)
-{
- KAA_RETURN_IF_NIL2(self, endpoint_hash_key, KAA_ERR_BADPARAM);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Going to detach endpoint");
-
-
- kaa_endpoint_info_t *info = KAA_CALLOC(1, sizeof(kaa_endpoint_info_t));
- KAA_RETURN_IF_NIL(info, KAA_ERR_NOMEM);
-
- memcpy(info->endpoint_token, endpoint_hash_key, KAA_ENDPOINT_ID_LENGTH);
-
- if (listener)
- info->listener = listener;
-
- info->request_id = ++self->endpoint_request_counter;
-
- if (!kaa_list_push_back(self->detach_endpoints, (void*)info)) {
- dtor_endpoint_info((void*)info);
- return KAA_ERR_NOMEM;
- }
-
- kaa_transport_channel_interface_t *channel =
- kaa_channel_manager_get_transport_channel(self->channel_manager, user_sync_services[0]);
- if (channel)
- channel->sync_handler(channel->context, user_sync_services, 1);
-
-
- return KAA_ERR_NONE;
-}
-
-#ifdef DEFAULT_USER_VERIFIER_TOKEN
-kaa_error_t kaa_user_manager_default_attach_to_user(kaa_user_manager_t *self
- , const char *user_external_id
- , const char *access_token)
-{
- KAA_RETURN_IF_NIL3(self, user_external_id, access_token, KAA_ERR_BADPARAM);
- return kaa_user_manager_attach_to_user(self, user_external_id, access_token, DEFAULT_USER_VERIFIER_TOKEN);
-}
-#endif
-
-kaa_error_t kaa_user_manager_set_attachment_listeners(kaa_user_manager_t *self
- , const kaa_attachment_status_listeners_t *listeners)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
- self->attachment_listeners = *listeners;
- return KAA_ERR_NONE;
-}
-
-static size_t kaa_user_request_get_size_no_header(kaa_user_manager_t *self)
-{
- size_t expected_size = 0;
- if (self->user_info && !self->is_waiting_user_attach_response) {
- expected_size += sizeof(uint32_t) // field id + user external ID length + user access token length
- + sizeof(uint32_t); // verifier id length + reserved
- expected_size += kaa_aligned_size_get(self->user_info->user_external_id_len);
- expected_size += kaa_aligned_size_get(self->user_info->user_access_token_len);
- expected_size += kaa_aligned_size_get(self->user_info->user_verifier_token_len);
- }
-
- if (kaa_list_get_size(self->attach_endpoints)) {
-
- expected_size += sizeof(uint32_t); // field id + reserved + endpoint attach requests count
-
- kaa_list_node_t *node = kaa_list_begin(self->attach_endpoints);
- while (node) {
- kaa_endpoint_info_t *info = (kaa_endpoint_info_t*)kaa_list_get_data(node);
- expected_size += sizeof(uint32_t) + kaa_aligned_size_get(info->access_token_length); //request id + endpoint access token length
- node = kaa_list_next(node);
- }
- }
-
- if (kaa_list_get_size(self->detach_endpoints)) {
- //field id + reserved + endpoint detach requests count
- expected_size += sizeof(uint32_t) + kaa_list_get_size(self->detach_endpoints) * (sizeof(uint32_t)/*request id + reserved*/ + KAA_ENDPOINT_ID_LENGTH);
- }
-
- return expected_size;
-}
-
-kaa_error_t kaa_user_request_get_size(kaa_user_manager_t *self, size_t *expected_size)
-{
- KAA_RETURN_IF_NIL2(self, expected_size, KAA_ERR_BADPARAM);
- *expected_size = KAA_EXTENSION_HEADER_SIZE + kaa_user_request_get_size_no_header(self);
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_user_request_serialize(kaa_user_manager_t *self, kaa_platform_message_writer_t* writer)
-{
- KAA_RETURN_IF_NIL2(self, writer, KAA_ERR_BADPARAM);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize client user sync");
-
- size_t size = kaa_user_request_get_size_no_header(self);
- if (kaa_platform_message_write_extension_header(writer, KAA_EXTENSION_USER, KAA_USER_RECEIVE_UPDATES_FLAG, size)) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_WRITE_FAILED, "Failed to write the user extension header");
- return KAA_ERR_WRITE_FAILED;
- }
-
- if (self->user_info && !self->is_waiting_user_attach_response) {
- *(writer->current++) = EXTERNAL_SYSTEM_AUTH_FIELD;
- *(writer->current++) = (uint8_t) self->user_info->user_external_id_len;
- *((uint16_t *) writer->current) = KAA_HTONS((uint16_t) self->user_info->user_access_token_len);
- writer->current += sizeof(uint16_t);
- *((uint16_t *) writer->current) = KAA_HTONS((uint16_t) self->user_info->user_verifier_token_len);
- writer->current += sizeof(uint32_t); /* verifier token length + reserved */
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Serializing external system authentication parameters: user external id '%s', access token '%s', verifier token '%s'"
- , self->user_info->user_external_id, self->user_info->user_access_token, self->user_info->user_verifier_token);
-
- if (self->user_info->user_external_id_len) {
- if (kaa_platform_message_write_aligned(writer
- , self->user_info->user_external_id
- , self->user_info->user_external_id_len))
- {
- KAA_LOG_ERROR(self->logger, KAA_ERR_WRITE_FAILED, "Failed to write the user external id \"%s\""
- , self->user_info->user_external_id);
- return KAA_ERR_WRITE_FAILED;
- }
- }
- if (self->user_info->user_access_token_len) {
- if (kaa_platform_message_write_aligned(writer
- , self->user_info->user_access_token
- , self->user_info->user_access_token_len))
- {
- KAA_LOG_ERROR(self->logger, KAA_ERR_WRITE_FAILED, "Failed to write the user access token \"%s\""
- , self->user_info->user_access_token);
- return KAA_ERR_WRITE_FAILED;
- }
- }
- if (self->user_info->user_verifier_token_len) {
- if (kaa_platform_message_write_aligned(writer
- , self->user_info->user_verifier_token
- , self->user_info->user_verifier_token_len))
- {
- KAA_LOG_ERROR(self->logger, KAA_ERR_WRITE_FAILED, "Failed to write the user verifier token \"%s\""
- , self->user_info->user_verifier_token);
- return KAA_ERR_WRITE_FAILED;
- }
- }
-
- self->is_waiting_user_attach_response = true;
- }
-
- if (kaa_list_get_size(self->attach_endpoints)) {
- kaa_list_node_t *node = kaa_list_begin(self->attach_endpoints);
- *(writer->current) = EXTERNAL_SYSTEM_ENDPOINT_ATTACH_FIELD;
- writer->current += sizeof(uint16_t);
- *((uint16_t*)writer->current) = KAA_HTONS((uint16_t)kaa_list_get_size(self->attach_endpoints));
- writer->current += sizeof(uint16_t);
-
- while (node) {
- kaa_endpoint_info_t *info = (kaa_endpoint_info_t*)kaa_list_get_data(node);
-
- if (!info->is_waiting_response) {
- *((uint16_t*)writer->current) = KAA_HTONS(info->request_id);
- writer->current += sizeof(uint16_t);
- *((uint16_t*)writer->current) = KAA_HTONS((uint16_t)info->access_token_length);
- writer->current += sizeof(uint16_t);
- if (kaa_platform_message_write_aligned(writer
- , info->access_token
- , info->access_token_length))
- {
- KAA_LOG_ERROR(self->logger, KAA_ERR_WRITE_FAILED, "Failed to write the user Endpoint access token");
- return KAA_ERR_WRITE_FAILED;
- }
-
- info->is_waiting_response = true;
- }
-
- node = kaa_list_next(node);
- }
- }
-
- if (kaa_list_get_size(self->detach_endpoints)) {
- kaa_list_node_t *node = kaa_list_begin(self->detach_endpoints);
- *(writer->current) = EXTERNAL_SYSTEM_ENDPOINT_DETACH_FIELD;
- writer->current += sizeof(uint16_t);
- *((uint16_t*)writer->current) = KAA_HTONS((uint16_t)kaa_list_get_size(self->detach_endpoints));
- writer->current += sizeof(uint16_t);
-
- while (node) {
- kaa_endpoint_info_t *info = (kaa_endpoint_info_t*)kaa_list_get_data(node);
-
- if (!info->is_waiting_response) {
- *((uint16_t*)writer->current) = KAA_HTONS(info->request_id);
- writer->current += sizeof(uint32_t);
-
- memcpy(writer->current, info->endpoint_token, KAA_ENDPOINT_ID_LENGTH);
- writer->current += KAA_ENDPOINT_ID_LENGTH;
-
- info->is_waiting_response = true;
- }
-
- node = kaa_list_next(node);
- }
- }
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_user_handle_server_sync(kaa_user_manager_t *self
- , kaa_platform_message_reader_t *reader
- , uint16_t extension_options
- , size_t extension_length)
-{
- // Only used for logging
- (void)extension_options;
- (void)extension_length;
- KAA_RETURN_IF_NIL2(self, reader, KAA_ERR_BADPARAM);
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received user server sync: options %u, payload size %u", extension_options, extension_length);
-
- size_t remaining_length = extension_length;
-
- while (remaining_length > 0) {
- uint32_t field_header = KAA_NTOHL(*(uint32_t *)reader->current);
- reader->current += sizeof(uint32_t);
- remaining_length -= sizeof(uint32_t);
-
- user_server_sync_field_t field = (field_header >> 24) & 0xFF;
- switch (field) {
- case USER_ATTACH_RESPONSE_FIELD: {
- user_sync_result_t result = (uint8_t) (field_header >> 8) & 0xFF;
- destroy_user_info(self->user_info);
- self->user_info = NULL;
- self->is_waiting_user_attach_response = false;
-
- if (result == USER_RESULT_SUCCESS) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Endpoint was successfully attached to user");
- kaa_status_set_attached(self->status, true);
- if (self->attachment_listeners.on_attach_success)
- (self->attachment_listeners.on_attach_success)(self->attachment_listeners.context);
- } else {
-
- uint16_t user_verifier_error_code;
- if (kaa_platform_message_read(reader, &user_verifier_error_code, sizeof(uint16_t))) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_READ_FAILED, "Failed to read user verifier error code");
- return KAA_ERR_READ_FAILED;
- }
-
- user_verifier_error_code = KAA_NTOHS(user_verifier_error_code);
- remaining_length -= sizeof(uint16_t);
-
- uint16_t reason_length;
- if (kaa_platform_message_read(reader, &reason_length, sizeof(uint16_t))) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_READ_FAILED, "Failed to read reason length");
- return KAA_ERR_READ_FAILED;
- }
-
- reason_length = KAA_NTOHS(reason_length);
- remaining_length -= sizeof(uint16_t);
-
- if (reason_length) {
- char reason[reason_length + 1];
- if (kaa_platform_message_read_aligned(reader, reason, reason_length)) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_READ_FAILED, "Failed to read error reason");
- return KAA_ERR_READ_FAILED;
- }
-
- reason[reason_length] = '\0';
- remaining_length -= kaa_aligned_size_get(reason_length);
-
- KAA_LOG_ERROR(self->logger, KAA_ERR_EVENT_NOT_ATTACHED, "Failed to attach to user: error %d, reason '%s'", user_verifier_error_code, reason);
-
- if (self->attachment_listeners.on_attach_failed) {
- (self->attachment_listeners.on_attach_failed)(self->attachment_listeners.context
- , (user_verifier_error_code_t)user_verifier_error_code
- , reason);
- }
- } else {
- KAA_LOG_ERROR(self->logger, KAA_ERR_EVENT_NOT_ATTACHED, "Failed to attach to user: error %d, reason 'unknown'", user_verifier_error_code);
- if (self->attachment_listeners.on_attach_failed) {
- (self->attachment_listeners.on_attach_failed)(self->attachment_listeners.context
- , (user_verifier_error_code_t)user_verifier_error_code
- , NULL);
- }
-
- }
- }
- break;
- }
- case USER_ATTACH_NOTIFICATION_FIELD: {
- uint8_t external_id_length = (field_header >> 16) & 0xFF;
- uint16_t access_token_length = (field_header) & 0xFFFF;
- if (external_id_length + access_token_length > remaining_length)
- return KAA_ERR_INVALID_BUFFER_SIZE;
-
- char external_id[external_id_length + 1];
- char access_token[access_token_length + 1];
-
- if (kaa_platform_message_read_aligned(reader, external_id, external_id_length)) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_READ_FAILED, "Failed to read the external ID (length %u)"
- , external_id_length);
- return KAA_ERR_READ_FAILED;
- }
- external_id[external_id_length] = '\0';
- remaining_length -= kaa_aligned_size_get(external_id_length);
-
- if (kaa_platform_message_read_aligned(reader, access_token, access_token_length)) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_READ_FAILED, "Failed to read the access token (length %u)"
- , access_token_length);
- return KAA_ERR_READ_FAILED;
- }
- access_token[access_token_length] = '\0';
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received user attach notification: endpoint external id '%s' (length %u), access token '%s' (length %u)"
- , external_id, external_id_length, access_token, access_token_length);
- remaining_length -= kaa_aligned_size_get(access_token_length);
-
- kaa_status_set_attached(self->status, true);
-
- if (self->attachment_listeners.on_attached)
- (self->attachment_listeners.on_attached)(self->attachment_listeners.context
- , external_id, access_token);
- break;
- }
- case USER_DETACH_NOTIFICATION_FIELD: {
- uint16_t access_token_length = (field_header) & 0xFFFF;
- if (access_token_length > remaining_length)
- return KAA_ERR_INVALID_BUFFER_SIZE;
-
- char access_token[access_token_length + 1];
- if (kaa_platform_message_read_aligned(reader, access_token, access_token_length)) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_READ_FAILED, "Failed to read the access token (length %u)"
- , access_token_length);
- return KAA_ERR_READ_FAILED;
- }
- access_token[access_token_length] = '\0';
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Received user detach notification: endpoint access token '%s' (length %u)"
- , access_token, access_token_length);
- remaining_length -= kaa_aligned_size_get(access_token_length);
-
- kaa_status_set_attached(self->status, false);
-
- if (self->attachment_listeners.on_detached)
- (self->attachment_listeners.on_detached)(self->attachment_listeners.context, access_token);
- break;
- }
- case ENDPOINT_ATTACH_RESPONSES_FIELD: {
- uint16_t attach_responses_count = (field_header) & 0xFFFF;
-
- if (sizeof(uint32_t) > remaining_length) {
- return KAA_ERR_INVALID_BUFFER_SIZE;
- }
-
- for (uint32_t i = 0; i < attach_responses_count; ++i) {
- uint8_t result_code = *(reader->current++);
- uint8_t options = *(reader->current++);
- uint16_t request_id = KAA_NTOHS(*(uint16_t*)reader->current);
-
- reader->current += sizeof(uint16_t);
- remaining_length -= sizeof(uint32_t);
-
- if (result_code == USER_RESULT_FAILURE) {
- kaa_list_node_t *node = kaa_list_find_next(kaa_list_begin(self->attach_endpoints), match_predicate_endpoint_info, (void*)&request_id);
- if (node) {
- kaa_endpoint_info_t *info = (kaa_endpoint_info_t*)kaa_list_get_data(node);
- if (info->listener && info->listener->on_attach_failed)
- info->listener->on_attach_failed(info->listener->context);
- kaa_list_remove_at(self->attach_endpoints, node, dtor_endpoint_info);
- }
- continue;
- }
-
- if (options & USER_SYNC_ENDPOINT_ID_OPTION) {
- kaa_endpoint_id endpoint_id;
- memcpy(endpoint_id, reader->current, KAA_ENDPOINT_ID_LENGTH);
- reader->current += KAA_ENDPOINT_ID_LENGTH;
- remaining_length -= KAA_ENDPOINT_ID_LENGTH;
-
- kaa_list_node_t *node = kaa_list_find_next(kaa_list_begin(self->attach_endpoints), match_predicate_endpoint_info, (void*)&request_id);
- if (node) {
- kaa_endpoint_info_t *info = (kaa_endpoint_info_t*)kaa_list_get_data(node);
- if (info->listener && info->listener->on_attached)
- info->listener->on_attached(info->listener->context, endpoint_id);
- kaa_list_remove_at(self->attach_endpoints, node, dtor_endpoint_info);
- }
- }
- }
-
- break;
- }
- case ENDPOINT_DETACH_RESPONSES_FIELD: {
- uint16_t detach_responses_count = field_header & 0xFFFF;
-
- if (sizeof(uint32_t) > remaining_length) {
- return KAA_ERR_INVALID_BUFFER_SIZE;
- }
-
- for (uint32_t i = 0; i < detach_responses_count; ++i) {
- uint8_t result_code = *(reader->current++);
- reader->current++;
- uint16_t request_id = KAA_NTOHS(*(uint16_t*)reader->current);
- reader->current += sizeof(uint16_t);
- remaining_length -= sizeof(uint32_t);
-
- if (result_code == USER_RESULT_FAILURE) {
- kaa_list_node_t *node = kaa_list_find_next(kaa_list_begin(self->detach_endpoints), match_predicate_endpoint_info, (void*)&request_id);
- if (node) {
- kaa_endpoint_info_t *info = (kaa_endpoint_info_t*)kaa_list_get_data(node);
- if (info->listener && info->listener->on_detach_failed)
- info->listener->on_detach_failed(info->listener->context);
- kaa_list_remove_at(self->detach_endpoints, node, dtor_endpoint_info);
- }
- continue;
- }
-
- kaa_list_node_t *node = kaa_list_find_next(kaa_list_begin(self->detach_endpoints), match_predicate_endpoint_info, (void*)&request_id);
- if (node) {
- kaa_endpoint_info_t *info = (kaa_endpoint_info_t*)kaa_list_get_data(node);
- if (info->listener && info->listener->on_detached)
- info->listener->on_detached(info->listener->context);
- kaa_list_remove_at(self->detach_endpoints, node, dtor_endpoint_info);
- }
- }
-
- break;
- }
- default:
- KAA_LOG_ERROR(self->logger, KAA_ERR_READ_FAILED, "Invalid field %u", field);
- return KAA_ERR_READ_FAILED;
- }
- }
- return KAA_ERR_NONE;
-}
diff --git a/client/client-multi/client-c/src/extensions/user/kaa_user.h b/client/client-multi/client-c/src/extensions/user/kaa_user.h
deleted file mode 100644
index 530d2d46c7..0000000000
--- a/client/client-multi/client-c/src/extensions/user/kaa_user.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file kaa_user.h
- * @brief Endpoint-to-user association management for Kaa C SDK.
- *
- * Manages endpoint's association with a user entity in Kaa.
- */
-
-#ifndef KAA_USER_H_
-#define KAA_USER_H_
-
-#include
-
-#include "kaa_error.h"
-#include "kaa_defaults.h"
-#include "platform/ext_user_callback.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-
-/**
- * @brief Kaa user manager structure.
- */
-#ifndef KAA_USER_MANAGER_T
-# define KAA_USER_MANAGER_T
- typedef struct kaa_user_manager_t kaa_user_manager_t;
-#endif
-
-
-
-/**
- * @brief Attaches the endpoint to a user entity. The user verification is carried out by the default verifier.
- *
- * Use this function to request attachment of the endpoint to a user entity using the specified external authentication
- * credentials. Only endpoints associated with the same user entity can exchange events.
- *
- * @param[in] self The user manager instance.
- * @param[in] user_external_id Null-terminated string representing external user ID.
- * @param[in] access_token Null-terminated string representing external access token.
- *
- * @return Error code.
- */
-#ifdef DEFAULT_USER_VERIFIER_TOKEN
-kaa_error_t kaa_user_manager_default_attach_to_user(kaa_user_manager_t *self
- , const char *user_external_id
- , const char *access_token);
-#endif
-
-
-
-/**
- * @brief Attaches the endpoint to a user entity. The user verification is carried out by the specified verifier.
- *
- * Use this function to request attachment of the endpoint to a user entity using the specified external authentication
- * credentials. Only endpoints associated with the same user entity can exchange events.
- *
- * @param[in] self The user manager instance.
- * @param[in] user_external_id Null-terminated string representing external user ID.
- * @param[in] access_token Null-terminated string representing external access token.
- * @param[in] user_verifier_token Null-terminated string representing user verifier token.
- *
- * @return Error code.
- */
-kaa_error_t kaa_user_manager_attach_to_user(kaa_user_manager_t *self
- , const char *user_external_id
- , const char *access_token
- , const char *user_verifier_token);
-
-
-
-/**
- * @brief Checks if current endpoint is attached to user.
- *
- * @param[in] self The user manager instance.
- * @retval true The endpoint is attached to user
- * @retval false Otherwise
- */
-bool kaa_user_manager_is_attached_to_user(kaa_user_manager_t *self);
-
-
-/**
- * @brief Sets callback functions to receive notifications when the endpoint gets attached or detached to (from) user.
- *
- * @param[in] self The user manager instance.
- * @param[in] listeners A filled in @link kaa_attachment_status_listeners_t @endlink structure.
- *
- * @return Error code.
- */
-kaa_error_t kaa_user_manager_set_attachment_listeners(kaa_user_manager_t *self
- , const kaa_attachment_status_listeners_t *listeners);
-
-/**
- * @brief Attaches external endpoint by its access token.
- *
- * @param[in] self The user manager instance.
- * @param[in] endpoint_access_token Null-terminated string representing endpoint access token.
- * @param[in] listener Status listener to set.
- *
- * @return Error code.
- */
-kaa_error_t kaa_user_manager_attach_endpoint(kaa_user_manager_t *self, const char *endpoint_access_token, kaa_endpoint_status_listener_t *listener);
-
-
-/**
- * @brief Detaches external endpoint by its access token.
- *
- * @param[in] self The user manager instance.
- * @param[in] endpoint_hash_key Unique endpoint id.
- * @param[in] listener
- *
- * @return Error code.
- */
-kaa_error_t kaa_user_manager_detach_endpoint(kaa_user_manager_t *self, const kaa_endpoint_id_p endpoint_hash_key, kaa_endpoint_status_listener_t *listener);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* KAA_USER_H_ */
diff --git a/client/client-multi/client-c/src/extensions/user/kaa_user_private.h b/client/client-multi/client-c/src/extensions/user/kaa_user_private.h
deleted file mode 100644
index c4d376f4aa..0000000000
--- a/client/client-multi/client-c/src/extensions/user/kaa_user_private.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef KAA_USER_PRIVATE_H
-#define KAA_USER_PRIVATE_H
-
-#include
-#include
-#include
-#include
-#include
-
-kaa_error_t kaa_user_manager_create(kaa_user_manager_t **user_manager_p, kaa_status_t *status,
- kaa_channel_manager_t *channel_manager, kaa_logger_t *logger);
-
-void kaa_user_manager_destroy(kaa_user_manager_t *user_manager);
-
-kaa_error_t kaa_user_request_get_size(kaa_user_manager_t *self, size_t *expected_size);
-kaa_error_t kaa_user_request_serialize(kaa_user_manager_t *self, kaa_platform_message_writer_t* writer);
-kaa_error_t kaa_user_handle_server_sync(kaa_user_manager_t *self, kaa_platform_message_reader_t *reader, uint16_t extension_options, size_t extension_length);
-
-#endif /* KAA_USER_PRIVATE_H */
diff --git a/client/client-multi/client-c/src/extensions/user/test/test_kaa_user.c b/client/client-multi/client-c/src/extensions/user/test/test_kaa_user.c
deleted file mode 100644
index 36c0ac898b..0000000000
--- a/client/client-multi/client-c/src/extensions/user/test/test_kaa_user.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include
-#include
-#include "platform/ext_sha.h"
-
-#include "kaa_user.h"
-#include "kaa_user_private.h"
-
-#include "kaa_test.h"
-
-#include "kaa.h"
-#include "kaa_context.h"
-#include "kaa_platform_protocol.h"
-#include "kaa_channel_manager.h"
-#include "kaa_status.h"
-#include "kaa_platform_utils.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-#include "platform/sock.h"
-
-#include "kaa_private.h"
-
-#define USER_EXTERNAL_ID "user@id"
-#define ACCESS_TOKEN "token"
-#define USER_VERIFIER "user_verifier"
-
-#define ATTACH_ERROR_REASON "Bad user credentials"
-
-static kaa_context_t kaa_context;
-static kaa_user_manager_t *user_manager = NULL;
-static kaa_logger_t *logger = NULL;
-static kaa_status_t *status = NULL;
-static kaa_channel_manager_t *channel_manager = NULL;
-
-static bool is_on_attached_invoked = false;
-static bool is_on_detached_invoked = false;
-static bool is_attach_success_invoked = false;
-static bool is_attach_failed_invoked = false;
-static bool last_is_attached_result = false;
-
-
-
-static kaa_error_t on_attached(void *context, const char *user_external_id, const char *endpoint_access_token)
-{
- (void)context;
-
- ASSERT_EQUAL(strcmp(ACCESS_TOKEN, endpoint_access_token), 0);
- ASSERT_EQUAL(strcmp(USER_EXTERNAL_ID, user_external_id), 0);
- is_on_attached_invoked = true;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t on_detached(void *context, const char *endpoint_access_token)
-{
- (void)context;
-
- ASSERT_EQUAL(strcmp(ACCESS_TOKEN, endpoint_access_token), 0);
- is_on_detached_invoked = true;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t on_attach_success(void *context)
-{
- (void)context;
-
- last_is_attached_result = true;
- is_attach_success_invoked = true;
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t on_attach_failed(void *context, user_verifier_error_code_t error_code, const char *reason)
-{
- (void)context;
- is_attach_failed_invoked = true;
- ASSERT_EQUAL(error_code, CONNECTION_ERROR);
- ASSERT_EQUAL(memcmp(reason, ATTACH_ERROR_REASON, strlen(ATTACH_ERROR_REASON)), 0);
- return KAA_ERR_NONE;
-}
-
-void test_specified_user_verifier(void **state)
-{
- (void)state;
-
- ASSERT_EQUAL(kaa_user_manager_attach_to_user(user_manager, USER_EXTERNAL_ID, ACCESS_TOKEN, USER_VERIFIER), KAA_ERR_NONE);
-
- size_t expected_size = 0;
- ASSERT_EQUAL(kaa_user_request_get_size(user_manager, &expected_size), KAA_ERR_NONE);
-
- uint8_t buffer[expected_size];
- kaa_platform_message_writer_t *writer = NULL;
- ASSERT_EQUAL(kaa_platform_message_writer_create(&writer, buffer, expected_size), KAA_ERR_NONE);
- ASSERT_NOT_NULL(writer);
-
- ASSERT_EQUAL(kaa_user_request_serialize(user_manager, writer), KAA_ERR_NONE);
-
- uint8_t *buf_cursor = buffer;
- ASSERT_EQUAL(KAA_EXTENSION_USER, KAA_HTONS(*(uint16_t*)buf_cursor));
- buf_cursor += sizeof(uint16_t);
-
- char options[] = { 0x00, 0x01 };
- ASSERT_EQUAL(memcmp(buf_cursor, options, 2), 0);
- buf_cursor += 2;
-
- ASSERT_EQUAL(*(uint32_t * ) buf_cursor, KAA_HTONL(2 * sizeof(uint32_t)
- + kaa_aligned_size_get(strlen(USER_EXTERNAL_ID))
- + kaa_aligned_size_get(strlen(ACCESS_TOKEN)
- + kaa_aligned_size_get(strlen(USER_VERIFIER)))));
- buf_cursor += sizeof(uint32_t);
-
- ASSERT_EQUAL(0, *buf_cursor);
- ++buf_cursor;
-
- ASSERT_EQUAL(strlen(USER_EXTERNAL_ID), *buf_cursor);
- ++buf_cursor;
-
- ASSERT_EQUAL(KAA_HTONS(strlen(ACCESS_TOKEN)), *(uint16_t *) buf_cursor);
- buf_cursor += sizeof(uint16_t);
-
- ASSERT_EQUAL(KAA_HTONS(strlen(USER_VERIFIER)), *(uint16_t *) buf_cursor);
- buf_cursor += sizeof(uint32_t); // + reserved 16B
-
- ASSERT_EQUAL(memcmp(buf_cursor, USER_EXTERNAL_ID, strlen(USER_EXTERNAL_ID)), 0);
- buf_cursor += kaa_aligned_size_get(strlen(USER_EXTERNAL_ID));
-
- ASSERT_EQUAL(memcmp(buf_cursor, ACCESS_TOKEN, strlen(ACCESS_TOKEN)), 0);
- buf_cursor += kaa_aligned_size_get(strlen(ACCESS_TOKEN));
-
- ASSERT_EQUAL(memcmp(buf_cursor, USER_VERIFIER, strlen(USER_VERIFIER)), 0);
- buf_cursor += kaa_aligned_size_get(strlen(USER_VERIFIER));
-
- kaa_platform_message_writer_destroy(writer);
-}
-
-void test_success_response(void **state)
-{
- (void)state;
-
- uint8_t success_response[] = {
- /* bit 0 */ 0x00, 0x00, 0x00, 0x00, /* User attach response field. Result - success */
- /* bit 32 */ 0x01, 0x07, 0x00, 0x05, /* User attach notification field */
- /* bit 64 */ 'u', 's', 'e', 'r',
- /* bit 96 */ '@', 'i', 'd', 0x00,
- /* bit 128 */ 't', 'o', 'k', 'e',
- /* bit 160 */ 'n', 0x00, 0x00, 0x00,
- /* bit 192 */ 0x02, 0x00, 0x00, 0x05, /* User detach notification field */
- /* bit 224 */ 't', 'o', 'k', 'e',
- /* bit 256 */ 'n', 0x00, 0x00, 0x00
-
- };
-
- kaa_platform_message_reader_t *reader = NULL;
- ASSERT_EQUAL(kaa_platform_message_reader_create(&reader, success_response, 36), KAA_ERR_NONE);
- ASSERT_NOT_NULL(reader);
-
- ASSERT_EQUAL(kaa_user_handle_server_sync(user_manager, reader, 0, 36), KAA_ERR_NONE);
- ASSERT_TRUE(is_on_attached_invoked);
- ASSERT_TRUE(is_on_detached_invoked);
- ASSERT_TRUE(is_attach_success_invoked);
- ASSERT_TRUE(last_is_attached_result);
-
- kaa_platform_message_reader_destroy(reader);
-}
-
-void test_failed_response(void **state)
-{
- (void)state;
-
- uint8_t failed_response[] = {
- /* bit 0 */ 0x00, 0x00, 0x01, 0x00, /* User attach response field. Result - success */
- /* bit 32 */ 0x00, 0x04, 0x00, 0x14, /* User attach notification field */
- /* bit 64 */ 'B', 'a', 'd', ' ',
- /* bit 96 */ 'u', 's', 'e', 'r',
- /* bit 128 */ ' ', 'c', 'r', 'e',
- /* bit 160 */ 'd', 'e', 'n', 't',
- /* bit 192 */ 'i', 'a', 'l', 's'
- };
-
- kaa_platform_message_reader_t *reader = NULL;
- ASSERT_EQUAL(kaa_platform_message_reader_create(&reader, failed_response, 28), KAA_ERR_NONE);
- ASSERT_NOT_NULL(reader);
-
- ASSERT_EQUAL(kaa_user_handle_server_sync(user_manager, reader, 0, 28), KAA_ERR_NONE);
- ASSERT_TRUE(is_attach_failed_invoked);
-
- kaa_platform_message_reader_destroy(reader);
-}
-
-
-
-int test_init(void)
-{
- kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
- if (error || !logger) {
- return error;
- }
-
- kaa_context.logger = logger;
-
- error = kaa_status_create(&status);
- if (error || !status) {
- return error;
- }
-
- error = kaa_channel_manager_create(&channel_manager, &kaa_context);
- if (error || !channel_manager) {
- return error;
- }
-
- error = kaa_user_manager_create(&user_manager, status, channel_manager, logger);
- if (error || !user_manager) {
- return error;
- }
-
- kaa_attachment_status_listeners_t listeners = { NULL, &on_attached, &on_detached, &on_attach_success, &on_attach_failed };
- error = kaa_user_manager_set_attachment_listeners(user_manager, &listeners);
- if (error) {
- return error;
- }
-
- return 0;
-}
-
-int test_deinit(void)
-{
- kaa_user_manager_destroy(user_manager);
- kaa_channel_manager_destroy(channel_manager);
- kaa_status_destroy(status);
- kaa_log_destroy(logger);
-
- return 0;
-}
-
-KAA_SUITE_MAIN(Log, test_init, test_deinit
- ,
- KAA_TEST_CASE(specified_user_verifier, test_specified_user_verifier)
- KAA_TEST_CASE(process_success_response, test_success_response)
- KAA_TEST_CASE(process_failed_response, test_failed_response)
- )
diff --git a/client/client-multi/client-c/src/kaa/Mainpage.dox b/client/client-multi/client-c/src/kaa/Mainpage.dox
deleted file mode 100644
index a3eeb281f4..0000000000
--- a/client/client-multi/client-c/src/kaa/Mainpage.dox
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*!
- \mainpage Kaa client C SDK
- \section contents Table of contents
-
- \link quickstart Quick start \endlink
- \link programminguide Programming guide \endlink
- \link demo Demo application \endlink
-
-
- \section quickstart Quick start
-
- \subsection building Building Kaa C SDK
- To build the Kaa C SDK, do the following:
- @code{.sh}
- $ mkdir build
- $ cd build
- $ cmake ..
- $ make
- $ make install
- @endcode
-
- Specific build options are described in the README and in the official online documentation.
-
- \subsection linkage Link Kaa library to your project
-
- If you use GNU Compiler, add the linker flag -lkaac to link against a dynamic
- library or -lkaac_s to link against a static library.
-
- \subsection init_kaa Initializing Kaa library
-
- Before building a user application with the Kaa library, the developer must implement the following functions in the user-space code:
-
- @link ext_get_endpoint_public_key @endlink - generate 256-bytes RSA public key
- @link ext_status_store @endlink - persist the Kaa SDK state
- @link ext_status_read @endlink - restore the persisted the Kaa SDK state
-
-
- Next, the \c kaa_context_t instance should be created:
- @code
- #include "kaa.h"
- #include "kaa_error.h"
- #include "kaa_common.h"
- #include "kaa_context.h"
-
- kaa_context_t *kaa_context = NULL;
-
- kaa_error_t error_code = kaa_init(&kaa_context);
- if (error_code) {
- return error_code;
- }
-
- /* Some useful work */
-
- kaa_deinit(kaa_context);
- @endcode
-
- To communicate with Kaa servers, at least one transport channel must be added for both Bootstrap server and Operations server.
-
- You may use the reference implementation (\link kaa_tcp_channel_create \endlink) or provide your own channel
- (for more details see \c kaa_transport_channel_interface_t):
- @code
- #include
- #include
- #include
-
- kaa_extension_id BOOTSTRAP_SERVICE[] = {
- KAA_EXTENSION_BOOTSTRAP,
- };
-
- const size_t BOOTSTRAP_SERVICE_COUNT = sizeof(BOOTSTRAP_SERVICE) / sizeof(kaa_extension_id);
-
- kaa_extension_id OPERATIONS_SERVICES[] = {
- KAA_EXTENSION_PROFILE,
- KAA_EXTENSION_USER,
- KAA_EXTENSION_EVENT,
- KAA_EXTENSION_LOGGING,
- };
-
- const size_t OPERATIONS_SERVICES_COUNT = sizeof(OPERATIONS_SERVICES) / sizeof(kaa_extension_id);
-
- kaa_transport_channel_interface_t *bootstrap_channel;
- kaa_transport_channel_interface_t *operations_channel;
-
- error_code = kaa_tcp_channel_create(&operations_channel, kaa_context->logger,
- OPERATIONS_SERVICES, OPERATIONS_SERVICES_COUNT);
- if (error_code) {
- return error_code;
- }
-
- error_code = kaa_tcp_channel_create(&bootstrap_channel, kaa_context->logger,
- BOOTSTRAP_SERVICE, BOOTSTRAP_SERVICE_COUNT);
- if (error_code) {
- return error_code;
- }
-
- error_code = kaa_channel_manager_add_transport_channel(kaa_context->channel_manager,
- bootstrap_channel, NULL);
- if (error_code) {
- return error_code;
- }
-
- error_code = kaa_channel_manager_add_transport_channel(kaa_context->channel_manager,
- operations_channel, NULL);
- if (error_code) {
- return error_code;
- }
- @endcode
-
- @note To use the log collection feature, go through
- additional initialization steps.
-
- To finish the Kaa C SDK initialization, execute the following command:
- @code
- kaa_error_t error_code = kaa_start(kaa_context);
- if (error_code) {
- return error_code;
- }
- @endcode
-
- \section programminguide Programming guide
-
- For more information about functions supported by the Kaa C SDK, see our Programming guide:
-
-
- \section demo Demo application
-
- To better familiarize yourself with Kaa C SDK, you may look at our demo application.
-
- Find the demo source code in the 'example' directory located in the root of the Kaa project.
-
- */
\ No newline at end of file
diff --git a/client/client-multi/client-c/src/kaa/avro_src/avro/io.h b/client/client-multi/client-c/src/kaa/avro_src/avro/io.h
deleted file mode 100644
index 224b591507..0000000000
--- a/client/client-multi/client-c/src/kaa/avro_src/avro/io.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#ifndef AVRO_IO_H
-#define AVRO_IO_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "platform.h"
-#include
-
-struct avro_reader_t_ {
- const char *buf;
- int64_t len;
- int64_t read;
-};
-
-struct avro_writer_t_ {
- const char *buf;
- int64_t len;
- int64_t written;
-};
-
-typedef struct avro_reader_t_ *avro_reader_t;
-typedef struct avro_writer_t_ *avro_writer_t;
-
-avro_reader_t avro_reader_memory(const char *buf, int64_t len);
-avro_writer_t avro_writer_memory(const char *buf, int64_t len);
-
-int avro_read(avro_reader_t reader, void *buf, int64_t len);
-int avro_skip(avro_reader_t reader, int64_t len);
-int avro_write(avro_writer_t writer, void *buf, int64_t len);
-
-void avro_reader_free(avro_reader_t reader);
-void avro_writer_free(avro_writer_t writer);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-#endif
diff --git a/client/client-multi/client-c/src/kaa/avro_src/avro/platform.h b/client/client-multi/client-c/src/kaa/avro_src/avro/platform.h
deleted file mode 100644
index ae058ed809..0000000000
--- a/client/client-multi/client-c/src/kaa/avro_src/avro/platform.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#ifndef AVRO_PLATFORM_H
-#define AVRO_PLATFORM_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Use this header file to include platform specific definitions */
-
-#ifdef _WIN32
- #include
-#endif
-
-// Defines for printing size_t.
-#if defined(_WIN64)
- #define PRIsz PRIu64
-#elif defined(_WIN32)
- #define PRIsz PRIu32
-#else // GCC
- #define PRIsz "zu"
-#endif
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-#endif
diff --git a/client/client-multi/client-c/src/kaa/avro_src/avro_private.h b/client/client-multi/client-c/src/kaa/avro_src/avro_private.h
deleted file mode 100644
index 4b62695f4e..0000000000
--- a/client/client-multi/client-c/src/kaa/avro_src/avro_private.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef AVRO_PRIVATE_H
-#define AVRO_PRIVATE_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include
-
-#include "avro/platform.h"
-
-#ifdef HAVE_CONFIG_H
-/* This is only true for now in the autotools build */
-#include "config.h"
-#endif
-
-#ifdef _WIN32
-#define snprintf _snprintf
-#endif
-
-/* Note that AVRO_PLATFORM_IS_BIG_ENDIAN is *always* defined. It is
- * either TRUE (1) or FALSE (0).
- */
-#ifdef _WIN32
- #define AVRO_PLATFORM_IS_BIG_ENDIAN (0)
-#else // UNIX
- #include
- #if BYTE_ORDER == BIG_ENDIAN
- #define AVRO_PLATFORM_IS_BIG_ENDIAN (1)
- #else
- #define AVRO_PLATFORM_IS_BIG_ENDIAN (0)
- #endif
-#endif
-
-/* Add definition of EILSEQ if it is not defined in errno.h. */
-#include
-#ifndef EILSEQ
-#define EILSEQ 138
-#endif
-
-
-#define check(rval, call) { rval = call; if(rval) return rval; }
-
-#define check_set(rval, call, ...) \
- { \
- rval = call; \
- if (rval) { \
- return rval; \
- } \
- }
-
-#define check_prefix(rval, call, ...) \
- { \
- rval = call; \
- if (rval) { \
- return rval; \
- } \
- }
-
-#define check_param(result, test, name) \
- { \
- if (!(test)) { \
- return result; \
- } \
- }
-
-#define AVRO_UNUSED(var) (void)var;
-
-#define container_of(ptr_, type_, member_) \
- ((type_ *)((char *)ptr_ - (size_t)&((type_ *)0)->member_))
-
-#define nullstrcmp(s1, s2) \
- (((s1) && (s2)) ? strcmp(s1, s2) : ((s1) || (s2)))
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-#endif
diff --git a/client/client-multi/client-c/src/kaa/avro_src/encoding.h b/client/client-multi/client-c/src/kaa/avro_src/encoding.h
deleted file mode 100644
index 31bd5ee7e6..0000000000
--- a/client/client-multi/client-c/src/kaa/avro_src/encoding.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef AVRO_ENCODING_H
-#define AVRO_ENCODING_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "avro/platform.h"
-#include "avro/io.h"
-
-/*
- * TODO: this will need more functions when JSON encoding is added
- */
-struct avro_encoding_t {
- const char *description;
- /*
- * string
- */
- int (*read_string) (avro_reader_t reader, char **s, int64_t *len);
- int (*write_string) (avro_writer_t writer, const char *s);
- /*
- * bytes
- */
- int (*read_bytes) (avro_reader_t reader, char **bytes, int64_t * len);
- int (*write_bytes) (avro_writer_t writer,
- const char *bytes, const int64_t len);
- /*
- * int
- */
- int (*read_int) (avro_reader_t reader, int32_t * i);
- int (*write_int) (avro_writer_t writer, const int32_t i);
- /*
- * long
- */
- int (*read_long) (avro_reader_t reader, int64_t * l);
- int (*write_long) (avro_writer_t writer, const int64_t l);
- /*
- * float
- */
- int (*read_float) (avro_reader_t reader, float *f);
- int (*write_float) (avro_writer_t writer, const float f);
- /*
- * double
- */
- int (*read_double) (avro_reader_t reader, double *d);
- int (*write_double) (avro_writer_t writer, const double d);
- /*
- * boolean
- */
- int (*read_boolean) (avro_reader_t reader, int8_t * b);
- int (*write_boolean) (avro_writer_t writer, const int8_t b);
- /*
- * null
- */
- int (*read_null) (avro_reader_t reader);
- int (*write_null) (avro_writer_t writer);
-};
-typedef struct avro_encoding_t avro_encoding_t;
-
-#define AVRO_WRITE(writer, buf, len) \
-{ int rval = avro_write( writer, buf, len ); if(rval) return rval; }
-#define AVRO_READ(reader, buf, len) \
-{ int rval = avro_read( reader, buf, len ); if(rval) return rval; }
-
-extern const avro_encoding_t avro_binary_encoding; /* in
- * encoding_binary
- */
-#ifdef __cplusplus
-} // extern "C"
-#endif
-#endif
diff --git a/client/client-multi/client-c/src/kaa/avro_src/encoding_binary.c b/client/client-multi/client-c/src/kaa/avro_src/encoding_binary.c
deleted file mode 100644
index 64d893f61b..0000000000
--- a/client/client-multi/client-c/src/kaa/avro_src/encoding_binary.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include
-#include "encoding.h"
-
-#include
-#include
-#include
-#include
-#include "utilities/kaa_mem.h"
-#include "avro_private.h"
-
-#define MAX_VARINT_BUF_SIZE 10
-
-static int read_long(avro_reader_t reader, int64_t * l)
-{
- uint64_t value = 0;
- uint8_t b;
- int offset = 0;
- do {
- if (offset == MAX_VARINT_BUF_SIZE) {
- return EILSEQ;
- }
- AVRO_READ(reader, &b, 1);
- value |= (int64_t) (b & 0x7F) << (7 * offset);
- ++offset;
- }
- while (b & 0x80);
- *l = ((value >> 1) ^ -(value & 1));
- return 0;
-}
-
-static int write_long(avro_writer_t writer, int64_t l)
-{
- char buf[MAX_VARINT_BUF_SIZE];
- uint8_t bytes_written = 0;
- uint64_t n = (l << 1) ^ (l >> 63);
- while (n & ~0x7F) {
- buf[bytes_written++] = (char)((((uint8_t) n) & 0x7F) | 0x80);
- n >>= 7;
- }
- buf[bytes_written++] = (char)n;
- AVRO_WRITE(writer, buf, bytes_written);
- return 0;
-}
-
-static int read_int(avro_reader_t reader, int32_t * i)
-{
- int64_t l;
- int rval;
- check(rval, read_long(reader, &l));
- if (!(INT_MIN <= l && l <= INT_MAX)) {
- return ERANGE;
- }
- *i = l;
- return 0;
-}
-
-static int write_int(avro_writer_t writer, const int32_t i)
-{
- int64_t l = i;
- return write_long(writer, l);
-}
-
-static int read_bytes(avro_reader_t reader, char **bytes, int64_t * len)
-{
- int rval;
- check_prefix(rval, read_long(reader, len),
- "Cannot read bytes length: ");
- *bytes = (char *) KAA_MALLOC(*len);
- if (!*bytes) {
- return ENOMEM;
- }
- AVRO_READ(reader, *bytes, *len);
- return 0;
-}
-
-static int
-write_bytes(avro_writer_t writer, const char *bytes, const int64_t len)
-{
- int rval;
- if (len < 0) {
- return EINVAL;
- }
- check_prefix(rval, write_long(writer, len),
- "Cannot write bytes length: ");
- AVRO_WRITE(writer, (char *)bytes, len);
- return 0;
-}
-
-static int read_string(avro_reader_t reader, char **s, int64_t *len)
-{
- (void)len;
- int64_t str_len = 0;
- int rval;
- check_prefix(rval, read_long(reader, &str_len),
- "Cannot read string length: ");
- *s = (char *) KAA_MALLOC(str_len + 1);
- if (!*s) {
- return ENOMEM;
- }
- (*s)[str_len] = '\0';
- AVRO_READ(reader, *s, str_len);
- return 0;
-}
-
-static int write_string(avro_writer_t writer, const char *s)
-{
- int64_t len = strlen(s);
- return write_bytes(writer, s, len);
-}
-
-static int read_float(avro_reader_t reader, float *f)
-{
-#if AVRO_PLATFORM_IS_BIG_ENDIAN
- uint8_t buf[4];
-#endif
- union {
- float f;
- int32_t i;
- } v;
-#if AVRO_PLATFORM_IS_BIG_ENDIAN
- AVRO_READ(reader, buf, 4);
- v.i = ((int32_t) buf[0] << 0)
- | ((int32_t) buf[1] << 8)
- | ((int32_t) buf[2] << 16) | ((int32_t) buf[3] << 24);
-#else
- AVRO_READ(reader, (void *)&v.i, 4);
-#endif
- *f = v.f;
- return 0;
-}
-
-static int write_float(avro_writer_t writer, const float f)
-{
-#if AVRO_PLATFORM_IS_BIG_ENDIAN
- uint8_t buf[4];
-#endif
- union {
- float f;
- int32_t i;
- } v;
-
- v.f = f;
-#if AVRO_PLATFORM_IS_BIG_ENDIAN
- buf[0] = (uint8_t) (v.i >> 0);
- buf[1] = (uint8_t) (v.i >> 8);
- buf[2] = (uint8_t) (v.i >> 16);
- buf[3] = (uint8_t) (v.i >> 24);
- AVRO_WRITE(writer, buf, 4);
-#else
- AVRO_WRITE(writer, (void *)&v.i, 4);
-#endif
- return 0;
-}
-
-static int read_double(avro_reader_t reader, double *d)
-{
-#if AVRO_PLATFORM_IS_BIG_ENDIAN
- uint8_t buf[8];
-#endif
- union {
- double d;
- int64_t l;
- } v;
-
-#if AVRO_PLATFORM_IS_BIG_ENDIAN
- AVRO_READ(reader, buf, 8);
- v.l = ((int64_t) buf[0] << 0)
- | ((int64_t) buf[1] << 8)
- | ((int64_t) buf[2] << 16)
- | ((int64_t) buf[3] << 24)
- | ((int64_t) buf[4] << 32)
- | ((int64_t) buf[5] << 40)
- | ((int64_t) buf[6] << 48) | ((int64_t) buf[7] << 56);
-#else
- AVRO_READ(reader, (void *)&v.l, 8);
-#endif
- *d = v.d;
- return 0;
-}
-
-static int write_double(avro_writer_t writer, const double d)
-{
-#if AVRO_PLATFORM_IS_BIG_ENDIAN
- uint8_t buf[8];
-#endif
- union {
- double d;
- int64_t l;
- } v;
-
- v.d = d;
-#if AVRO_PLATFORM_IS_BIG_ENDIAN
- buf[0] = (uint8_t) (v.l >> 0);
- buf[1] = (uint8_t) (v.l >> 8);
- buf[2] = (uint8_t) (v.l >> 16);
- buf[3] = (uint8_t) (v.l >> 24);
- buf[4] = (uint8_t) (v.l >> 32);
- buf[5] = (uint8_t) (v.l >> 40);
- buf[6] = (uint8_t) (v.l >> 48);
- buf[7] = (uint8_t) (v.l >> 56);
- AVRO_WRITE(writer, buf, 8);
-#else
- AVRO_WRITE(writer, (void *)&v.l, 8);
-#endif
- return 0;
-}
-
-static int read_boolean(avro_reader_t reader, int8_t * b)
-{
- AVRO_READ(reader, b, 1);
- return 0;
-}
-
-static int write_boolean(avro_writer_t writer, const int8_t b)
-{
- AVRO_WRITE(writer, (char *)&b, 1);
- return 0;
-}
-
-static int read_skip_null(avro_reader_t reader)
-{
- /*
- * no-op
- */
- AVRO_UNUSED(reader);
-
- return 0;
-}
-
-static int write_null(avro_writer_t writer)
-{
- /*
- * no-op
- */
- AVRO_UNUSED(writer);
-
- return 0;
-}
-
-/* Win32 doesn't support the C99 method of initializing named elements
- * in a struct declaration. So hide the named parameters for Win32,
- * and initialize in the order the code was written.
- */
-const avro_encoding_t avro_binary_encoding = {
- /* .description = */ "BINARY FORMAT",
- /*
- * string
- */
- /* .read_string = */ read_string,
- /* .write_string = */ write_string,
- /*
- * bytes
- */
- /* .read_bytes = */ read_bytes,
- /* .write_bytes = */ write_bytes,
- /*
- * int
- */
- /* .read_int = */ read_int,
- /* .write_int = */ write_int,
- /*
- * long
- */
- /* .read_long = */ read_long,
- /* .write_long = */ write_long,
- /*
- * float
- */
- /* .read_float = */ read_float,
- /* .write_float = */ write_float,
- /*
- * double
- */
- /* .read_double = */ read_double,
- /* .write_double = */ write_double,
- /*
- * boolean
- */
- /* .read_boolean = */ read_boolean,
- /* .write_boolean = */ write_boolean,
- /*
- * null
- */
- /* .read_null = */ read_skip_null,
- /* .write_null = */ write_null,
-};
diff --git a/client/client-multi/client-c/src/kaa/avro_src/io.c b/client/client-multi/client-c/src/kaa/avro_src/io.c
deleted file mode 100644
index 0ffe3b38ea..0000000000
--- a/client/client-multi/client-c/src/kaa/avro_src/io.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include
-#include "avro/io.h"
-
-#include
-#include
-#include
-#include
-#include "utilities/kaa_mem.h"
-
-#include "avro_private.h"
-
-avro_reader_t avro_reader_memory(const char *buf, int64_t len)
-{
- struct avro_reader_t_ *mem_reader = (struct avro_reader_t_ *) KAA_CALLOC(1,
- sizeof(struct avro_reader_t_));
- if (!mem_reader) {
- return NULL;
- }
- mem_reader->buf = buf;
- mem_reader->len = len;
- mem_reader->read = 0;
- return mem_reader;
-}
-
-avro_writer_t avro_writer_memory(const char *buf, int64_t len)
-{
- struct avro_writer_t_ *mem_writer = (struct avro_writer_t_ *) KAA_CALLOC(1,
- sizeof(struct avro_writer_t_));
- if (!mem_writer) {
- return NULL;
- }
- mem_writer->buf = buf;
- mem_writer->len = len;
- mem_writer->written = 0;
- return mem_writer;
-}
-
-static int avro_read_memory(struct avro_reader_t_ *reader, void *buf, int64_t len)
-{
- if (len > 0) {
- if ((reader->len - reader->read) < len) {
- return ENOSPC;
- }
- memcpy(buf, reader->buf + reader->read, len);
- reader->read += len;
- }
- return 0;
-}
-
-#define bytes_available(reader) (reader->end - reader->cur)
-#define buffer_reset(reader) {reader->cur = reader->end = reader->buffer;}
-
-int avro_read(avro_reader_t reader, void *buf, int64_t len)
-{
- if (buf && len >= 0) {
- return avro_read_memory(reader, buf, len);
- }
- return EINVAL;
-}
-
-static int avro_skip_memory(struct avro_reader_t_ *reader, int64_t len)
-{
- if (len > 0) {
- if ((reader->len - reader->read) < len) {
- return ENOSPC;
- }
- reader->read += len;
- }
- return 0;
-}
-
-int avro_skip(avro_reader_t reader, int64_t len)
-{
- if (len >= 0) {
- return avro_skip_memory(reader, len);
- }
- return 0;
-}
-
-static int avro_write_memory(struct avro_writer_t_ *writer, void *buf, int64_t len)
-{
- if (len) {
- if ((writer->len - writer->written) < len) {
- return ENOSPC;
- }
- memcpy((void *) (writer->buf + writer->written), buf, len);
- writer->written += len;
- }
- return 0;
-}
-
-int avro_write(avro_writer_t writer, void *buf, int64_t len)
-{
- if (buf && len >= 0) {
- return avro_write_memory(writer, buf, len);
- }
- return EINVAL;
-}
-
-void avro_reader_free(avro_reader_t reader)
-{
- if (reader) {
- KAA_FREE(reader);
- }
-}
-
-void avro_writer_free(avro_writer_t writer)
-{
- if (writer) {
- KAA_FREE(writer);
- }
-}
diff --git a/client/client-multi/client-c/src/kaa/collections/kaa_list.c b/client/client-multi/client-c/src/kaa/collections/kaa_list.c
deleted file mode 100644
index 8459362218..0000000000
--- a/client/client-multi/client-c/src/kaa/collections/kaa_list.c
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include
-
-#include "kaa_list.h"
-#include "kaa_common.h"
-#include "utilities/kaa_mem.h"
-
-
-
-struct kaa_list_node_t {
- void *data;
- struct kaa_list_node_t *next;
- struct kaa_list_node_t *prev;
-};
-
-struct kaa_list_t {
- kaa_list_node_t *head;
- kaa_list_node_t *tail;
- size_t size;
-};
-
-static kaa_list_node_t *set_next_neighbor(kaa_list_node_t *whom, kaa_list_node_t *neighbor)
-{
- if (neighbor) {
- neighbor->prev = whom;
- }
-
- if (whom) {
- whom->next = neighbor;
- }
-
- return neighbor;
-}
-
-static kaa_list_node_t *create_node(void *data)
-{
- KAA_RETURN_IF_NIL(data, NULL);
- kaa_list_node_t *node = (kaa_list_node_t *)KAA_MALLOC(sizeof(kaa_list_node_t));
- KAA_RETURN_IF_NIL(node, NULL);
- node->data = data;
- node->next = node->prev = NULL;
- return node;
-}
-
-static void destroy_node(kaa_list_node_t *it, deallocate_list_data deallocator)
-{
- KAA_RETURN_IF_NIL(it, );
- if (deallocator) {
- (*deallocator)(it->data);
- } else {
- KAA_FREE(it->data);
- }
- KAA_FREE(it);
-}
-
-static void reset_list(kaa_list_t *list)
-{
- KAA_RETURN_IF_NIL(list, );
- list->head = list->tail = NULL;
- list->size = 0;
-}
-
-void *kaa_list_get_data(kaa_list_node_t *it)
-{
- return (it ? it->data : NULL);
-}
-
-kaa_list_node_t *kaa_list_next(kaa_list_node_t *it)
-{
- return (it ? it->next : NULL);
-}
-
-kaa_list_node_t *kaa_list_prev(kaa_list_node_t *it)
-{
- return (it ? it->prev : NULL);
-}
-
-kaa_list_t *kaa_lists_merge(kaa_list_t *destination_head, kaa_list_t *tail)
-{
- KAA_RETURN_IF_NIL(destination_head, tail);
- KAA_RETURN_IF_NIL(tail, destination_head);
-
- if (!destination_head->head) {
- destination_head->head = tail->head;
- } else {
- set_next_neighbor(destination_head->tail, tail->head);
- }
-
- destination_head->tail = tail->tail;
- destination_head->size += tail->size;
-
- reset_list(tail);
-
- return destination_head;
-}
-
-size_t kaa_list_get_size(kaa_list_t *list)
-{
- KAA_RETURN_IF_NIL(list, 0);
- return list->size;
-}
-
-kaa_list_t *kaa_list_create(void)
-{
- return (kaa_list_t *) KAA_CALLOC(1, sizeof(kaa_list_t));
-}
-
-kaa_list_node_t *kaa_list_push_front(kaa_list_t *list, void *data)
-{
- KAA_RETURN_IF_NIL2(list, data, NULL);
- kaa_list_node_t *node = create_node(data);
- KAA_RETURN_IF_NIL(node, NULL);
-
- ++list->size;
- set_next_neighbor(node, list->head);
-
- list->head = node;
- if (!list->tail) {
- list->tail = node;
- }
-
- return node;
-}
-
-kaa_list_node_t *kaa_list_push_back(kaa_list_t *list, void *data)
-{
- KAA_RETURN_IF_NIL(list, NULL);
- kaa_list_node_t *node = create_node(data);
- KAA_RETURN_IF_NIL(node, NULL);
-
- ++list->size;
- set_next_neighbor(list->tail, node);
-
- list->tail = node;
- if (!list->head) {
- list->head = node;
- }
-
- return node;
-}
-
-kaa_list_node_t *kaa_list_begin(kaa_list_t *list)
-{
- KAA_RETURN_IF_NIL(list, NULL);
- return list->head;
-}
-
-kaa_list_node_t *kaa_list_back(kaa_list_t *list)
-{
- KAA_RETURN_IF_NIL(list, NULL);
- return list->tail;
-}
-
-void kaa_list_clear(kaa_list_t *list, deallocate_list_data deallocator)
-{
- KAA_RETURN_IF_NIL2(list, list->size, );
- kaa_list_node_t *it = list->head;
- while (it) {
- kaa_list_node_t *next = it->next;
- destroy_node(it, deallocator);
- it = next;
- }
-
- reset_list(list);
-}
-
-void kaa_list_destroy(kaa_list_t *list, deallocate_list_data deallocator)
-{
- KAA_RETURN_IF_NIL(list, );
- kaa_list_clear(list, deallocator);
- KAA_FREE(list);
-}
-
-kaa_list_node_t *kaa_list_remove_at(kaa_list_t *list, kaa_list_node_t *it, deallocate_list_data deallocator)
-{
- KAA_RETURN_IF_NIL3(list, it, list->size, NULL);
-
- kaa_list_node_t *next = it->next;
- if (list->head == it) {
- list->head = next;
- }
- if (list->tail == it) {
- list->tail = it->prev;
- }
-
- set_next_neighbor(it->prev, next);
- destroy_node(it, deallocator);
- --list->size;
-
- return next;
-}
-
-kaa_error_t kaa_list_remove_first(kaa_list_t *list, match_predicate pred, void *context, deallocate_list_data deallocator)
-{
- KAA_RETURN_IF_NIL3(list, pred, list->size, KAA_ERR_BADPARAM);
-
- kaa_list_node_t *it = kaa_list_find_next(kaa_list_begin(list), pred, context);
- kaa_list_remove_at(list, it, deallocator);
- return it ? KAA_ERR_NONE : KAA_ERR_NOT_FOUND;
-}
-
-void kaa_list_set_data_at(kaa_list_node_t *it, void *data, deallocate_list_data deallocator)
-{
- KAA_RETURN_IF_NIL(it, );
- if (deallocator) {
- deallocator(it->data);
- } else {
- KAA_FREE(it->data);
- }
- it->data = data;
-}
-
-kaa_list_node_t *kaa_list_find_next(kaa_list_node_t *from, match_predicate pred, void *context)
-{
- KAA_RETURN_IF_NIL2(from, pred, NULL);
- while (from) {
- if (pred(from->data, context)) {
- return from;
- }
- from = from->next;
- }
- return NULL;
-}
-
-void kaa_list_for_each(kaa_list_node_t *first, kaa_list_node_t *last, process_data process, void *context)
-{
- KAA_RETURN_IF_NIL3(first, last, process, );
- while (first) {
- process(first->data, context);
- if (first == last) {
- break;
- }
-
- first = kaa_list_next(first);
- }
-}
-
-static kaa_list_node_t *kaa_split_util(kaa_list_node_t *head);
-
-
-static kaa_list_node_t *kaa_merge_util(kaa_list_node_t *first, kaa_list_node_t *second, match_predicate pred)
-{
- KAA_RETURN_IF_NIL(first, second);
- KAA_RETURN_IF_NIL(second, first);
-
- if (pred(first->data, second->data)) {
-
- first->next = kaa_merge_util(first->next, second, pred);
- first->next->prev = first;
- first->prev = NULL;
-
- return first;
- } else {
- second->next = kaa_merge_util(first, second->next, pred);
- second->next->prev = second;
- second->prev = NULL;
- return second;
- }
-}
-
-static kaa_list_node_t *kaa_merge_sort(kaa_list_node_t *head, match_predicate pred)
-{
- KAA_RETURN_IF_NIL2(head, head->next, head);
-
- kaa_list_node_t *second = kaa_split_util(head);
-
- head = kaa_merge_sort(head, pred);
- second = kaa_merge_sort(second, pred);
-
- head = kaa_merge_util(head, second, pred);
- return head;
-}
-
-static kaa_list_node_t *kaa_split_util( kaa_list_node_t *head)
-{
- kaa_list_node_t *fast = head;
- kaa_list_node_t *slow = head;
- while (fast->next && fast->next->next) {
- fast = fast->next->next;
- slow = slow->next;
- }
- kaa_list_node_t *temp = slow->next;
- slow->next = NULL;
- return temp;
-}
-
-void kaa_list_sort(kaa_list_t *list, match_predicate pred)
-{
- KAA_RETURN_IF_NIL(list->size,);
- kaa_list_node_t *node = kaa_merge_sort(kaa_list_begin(list), pred);
- list->head = node;
- while (node->next) {
- node = node->next;
- }
- list->tail = node;
-}
-
-int32_t kaa_list_hash(kaa_list_t *list, list_node_hash pred)
-{
- KAA_RETURN_IF_NIL2(list, pred, 0);
- uint32_t result = 1;
- kaa_list_node_t *node = kaa_list_begin(list);
- while (node) {
- uint64_t element = pred(node->data);
- result = 31 * result + (uint32_t) (element ^ (element >> 32));
- node = node->next;
- }
- return (int32_t) result;
-}
diff --git a/client/client-multi/client-c/src/kaa/collections/kaa_list.h b/client/client-multi/client-c/src/kaa/collections/kaa_list.h
deleted file mode 100644
index f254d332b1..0000000000
--- a/client/client-multi/client-c/src/kaa/collections/kaa_list.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef KAA_LIST_H_
-#define KAA_LIST_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include
-#include
-
-#include "kaa_error.h"
-
-typedef struct kaa_list_node_t kaa_list_node_t;
-typedef struct kaa_list_t kaa_list_t;
-
-/**
- * @brief Return @b false if data doesn't match search criteria.
- */
-typedef bool (*match_predicate)(void *data, void *context);
-
-/**
- * @brief Use to deallocate list node data.
- */
-typedef void (*deallocate_list_data)(void *);
-
-/**
- * @brief Returns list node hash.
- */
-typedef uint64_t list_node_hash(void * item);
-
-/**
- * @brief Use to process element data.
- */
-typedef void (*process_data)(void *data, void *context);
-
-/**
- * @brief Creates empty list.
- * @return The list object.
- */
-kaa_list_t *kaa_list_create(void);
-
-/**
- * @brief Destroys list and all elements.
- */
-void kaa_list_destroy(kaa_list_t *list, deallocate_list_data deallocator);
-
-/**
- * @brief Removes all elements from the list (which are destroyed), and leaving the list with a size of 0.
- */
-void kaa_list_clear(kaa_list_t *list, deallocate_list_data deallocator);
-
-/**
- * @brief Returns the number of elements in the list.
- * @return The number of elements.
- * @retval NULL the list is @c NULL
- */
-size_t kaa_list_get_size(kaa_list_t *list);
-
-/**
- * @brief Inserts a new element at the beginning of the list, right before its current first element.
- * @return An iterator to the inserted element.
- * @retval NULL the list or data are @c NULL
- */
-kaa_list_node_t *kaa_list_push_front(kaa_list_t *list, void *data);
-
-/**
- * @brief Inserts a new element at the end of the list, after its current last element.
- * @return An iterator to the inserted element
- * @retval NULL the list or data are @c NULL
- */
-kaa_list_node_t *kaa_list_push_back(kaa_list_t *list, void *data);
-
-/**
- * @brief Returns an iterator pointing to the first element in the list.
- * @return An iterator
- * @retval NULL the list is @c NULL
- */
-kaa_list_node_t *kaa_list_begin(kaa_list_t *list);
-
-/**
- * @brief Returns an iterator pointing to the last element in the list.
- * @return An iterator
- * @retval NULL the list is @c NULL
- */
-kaa_list_node_t *kaa_list_back(kaa_list_t *list);
-
-/**
- * @brief Gets iterator to the next element.
- * @return An iterator
- * @retval NULL the provided iterator is @c NULL
- */
-kaa_list_node_t *kaa_list_next(kaa_list_node_t *it);
-
-/**
- * @brief Gets iterator to the previous element.
- * @return An iterator
- * @retval NULL the provided iterator is @c NULL
- */
-kaa_list_node_t *kaa_list_prev(kaa_list_node_t *it);
-
-/**
- * @brief Gets data from the iterator.
- * @return Data
- * @retval NULL the iterator is @c NULL
- */
-void *kaa_list_get_data(kaa_list_node_t *it);
-
-/**
- * @brief Sets new data to the element. Old data will be destroyed.
- */
-void kaa_list_set_data_at(kaa_list_node_t *it, void *data, deallocate_list_data deallocator);
-
-/**
- * @brief Returns an iterator to the first element in the list that matches by the predicate.
- * @retval NULL no such element is found
- */
-kaa_list_node_t *kaa_list_find_next(kaa_list_node_t *from, match_predicate pred, void *context);
-
-/**
- * @brief Merges the source list into the destination list by transferring all of its elements at their respective
- * ordered positions at the end of the source list.
- * @return The result list which contains all merged elements.
- */
-kaa_list_t *kaa_lists_merge(kaa_list_t *destination, kaa_list_t *source);
-
-/**
- * @brief Removes from the list a single element.
- * @return An iterator pointing to the element that followed the last element erased by the function call or NULL.
- */
-kaa_list_node_t *kaa_list_remove_at(kaa_list_t *list, kaa_list_node_t *it, deallocate_list_data deallocator);
-
-/**
- * @brief Removes from the list the first element for which the predicate returns true.
- * @retval KAA_ERR_NONE element was found
- */
-kaa_error_t kaa_list_remove_first(kaa_list_t *list, match_predicate pred, void *context, deallocate_list_data deallocator);
-
-/**
- * @brief Applies the function process to each of the elements in the range [first,last].
- */
-void kaa_list_for_each(kaa_list_node_t *first, kaa_list_node_t *last, process_data process, void *context);
-
-/**
- * @brief Sorts list according to predicate condition.
- * @param list List to sort.
- * @param pred Predicate that is used to sort list.
- */
-void kaa_list_sort(kaa_list_t *list, match_predicate pred);
-
-/**
- * @brief Estimate hash from sorted array.
- * @param list List to calculate hash from.
- * @param pred Predicate that is used to get list node's hash, id or other unique @c uint64_t value.
- */
-int32_t kaa_list_hash(kaa_list_t *list, list_node_hash pred);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-#endif /* KAA_LIST_H_ */
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_configuration_definitions.h b/client/client-multi/client-c/src/kaa/gen/kaa_configuration_definitions.h
deleted file mode 100644
index 5b90698d15..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_configuration_definitions.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# ifndef KAA_CONFIGURATION_DEFINITIONS_H_
-# define KAA_CONFIGURATION_DEFINITIONS_H_
-
-# include "kaa_configuration_gen.h"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-typedef kaa_configuration_root_record_t kaa_root_configuration_t;
-# define KAA_CONFIGURATION_DESERIALIZE(reader) kaa_configuration_root_record_deserialize(reader)
-
-# ifdef __cplusplus
-} /* extern "C" */
-# endif
-
-# endif /* KAA_CONFIGURATION_DEFINITIONS_H_ */
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_configuration_gen.c b/client/client-multi/client-c/src/kaa/gen/kaa_configuration_gen.c
deleted file mode 100644
index 1e5ff73b1c..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_configuration_gen.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# include
-# include
-# include
-# include "kaa_configuration_gen.h"
-# include "avro_src/avro/io.h"
-# include "avro_src/encoding.h"
-# include "utilities/kaa_mem.h"
-
-/*
- * AUTO-GENERATED CODE
- */
-
-
-# ifndef KAA_UNION_NULL_OR_FIXED_C_
-# define KAA_UNION_NULL_OR_FIXED_C_
-static void kaa_union_null_or_fixed_destroy(void *data)
-{
- if (data) {
- kaa_union_t *kaa_union = (kaa_union_t *)data;
-
- switch (kaa_union->type) {
- case KAA_UNION_NULL_OR_FIXED_BRANCH_1:
- {
- if (kaa_union->data) {
- kaa_bytes_destroy(kaa_union->data);
- }
- break;
- }
- default:
- break;
- }
-
- kaa_data_destroy(kaa_union);
- }
-}
-
-static size_t kaa_union_null_or_fixed_get_size(void *data)
-{
- if (data) {
- kaa_union_t *kaa_union = (kaa_union_t *)data;
- size_t union_size = avro_long_get_size(kaa_union->type);
-
- switch (kaa_union->type) {
- case KAA_UNION_NULL_OR_FIXED_BRANCH_1:
- {
- if (kaa_union->data) {
- union_size += kaa_bytes_get_size(kaa_union->data);
- }
- break;
- }
- default:
- break;
- }
-
- return union_size;
- }
-
- return 0;
-}
-
-static void kaa_union_null_or_fixed_serialize(avro_writer_t writer, void *data)
-{
- if (data) {
- kaa_union_t *kaa_union = (kaa_union_t *)data;
- avro_binary_encoding.write_long(writer, kaa_union->type);
-
- switch (kaa_union->type) {
- case KAA_UNION_NULL_OR_FIXED_BRANCH_1:
- {
- if (kaa_union->data) {
- kaa_bytes_serialize(writer, kaa_union->data);
- }
- break;
- }
- default:
- break;
- }
- }
-}
-static kaa_union_t *kaa_union_null_or_fixed_create(void)
-{
- kaa_union_t *kaa_union = KAA_CALLOC(1, sizeof(kaa_union_t));
-
- if (kaa_union) {
- kaa_union->serialize = kaa_union_null_or_fixed_serialize;
- kaa_union->get_size = kaa_union_null_or_fixed_get_size;
- kaa_union->destroy = kaa_union_null_or_fixed_destroy;
- }
-
- return kaa_union;
-}
-
-kaa_union_t *kaa_union_null_or_fixed_branch_0_create(void)
-{
- kaa_union_t *kaa_union = kaa_union_null_or_fixed_create();
- if (kaa_union) {
- kaa_union->type = KAA_UNION_NULL_OR_FIXED_BRANCH_0;
- }
- return kaa_union;
-}
-
-kaa_union_t *kaa_union_null_or_fixed_branch_1_create(void)
-{
- kaa_union_t *kaa_union = kaa_union_null_or_fixed_create();
- if (kaa_union) {
- kaa_union->type = KAA_UNION_NULL_OR_FIXED_BRANCH_1;
- }
- return kaa_union;
-}
-
-kaa_union_t *kaa_union_null_or_fixed_deserialize(avro_reader_t reader)
-{
- kaa_union_t *kaa_union = kaa_union_null_or_fixed_create();
-
- if (kaa_union) {
- int64_t branch;
- avro_binary_encoding.read_long(reader, &branch);
- kaa_union->type = branch;
-
- switch (kaa_union->type) {
- case KAA_UNION_NULL_OR_FIXED_BRANCH_1:
- {
- kaa_union->data = kaa_bytes_deserialize(reader);
- break;
- }
- default:
- break;
- }
- }
-
- return kaa_union;
-}
-# endif // KAA_UNION_NULL_OR_FIXED_C_
-
-
-static void kaa_configuration_root_record_destroy(void *data)
-{
- if (data) {
- kaa_configuration_root_record_t *record = (kaa_configuration_root_record_t *)data;
-
- kaa_string_destroy(record->data);
- if (record->__uuid && record->__uuid->destroy) {
- record->__uuid->destroy(record->__uuid);
- }
- kaa_data_destroy(record);
- }
-}
-
-static void kaa_configuration_root_record_serialize(avro_writer_t writer, void *data)
-{
- if (data) {
- kaa_configuration_root_record_t *record = (kaa_configuration_root_record_t *)data;
-
- kaa_string_serialize(writer, record->data);
- record->__uuid->serialize(writer, record->__uuid);
- }
-}
-
-static size_t kaa_configuration_root_record_get_size(void *data)
-{
- if (data) {
- size_t record_size = 0;
- kaa_configuration_root_record_t *record = (kaa_configuration_root_record_t *)data;
-
- record_size += kaa_string_get_size(record->data);
- record_size += record->__uuid->get_size(record->__uuid);
-
- return record_size;
- }
-
- return 0;
-}
-
-kaa_configuration_root_record_t *kaa_configuration_root_record_create(void)
-{
- kaa_configuration_root_record_t *record =
- (kaa_configuration_root_record_t *)KAA_CALLOC(1, sizeof(kaa_configuration_root_record_t));
-
- if (record) {
- record->serialize = kaa_configuration_root_record_serialize;
- record->get_size = kaa_configuration_root_record_get_size;
- record->destroy = kaa_configuration_root_record_destroy;
- }
-
- return record;
-}
-
-kaa_configuration_root_record_t *kaa_configuration_root_record_deserialize(avro_reader_t reader)
-{
- kaa_configuration_root_record_t *record =
- (kaa_configuration_root_record_t *)KAA_MALLOC(sizeof(kaa_configuration_root_record_t));
-
- if (record) {
- record->serialize = kaa_configuration_root_record_serialize;
- record->get_size = kaa_configuration_root_record_get_size;
- record->destroy = kaa_configuration_root_record_destroy;
-
- record->data = kaa_string_deserialize(reader);
- record->__uuid = kaa_union_null_or_fixed_deserialize(reader);
- }
-
- return record;
-}
-
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_configuration_gen.h b/client/client-multi/client-c/src/kaa/gen/kaa_configuration_gen.h
deleted file mode 100644
index 2365242b42..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_configuration_gen.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# ifndef KAA_CONFIGURATION_GEN_H_
-# define KAA_CONFIGURATION_GEN_H_
-
-# include "kaa_common_schema.h"
-# include "collections/kaa_list.h"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-
-# ifndef KAA_UNION_NULL_OR_FIXED_H_
-# define KAA_UNION_NULL_OR_FIXED_H_
-
-# define KAA_UNION_NULL_OR_FIXED_BRANCH_0 0
-# define KAA_UNION_NULL_OR_FIXED_BRANCH_1 1
-
-kaa_union_t *kaa_union_null_or_fixed_branch_0_create(void);
-kaa_union_t *kaa_union_null_or_fixed_branch_1_create(void);
-
-kaa_union_t *kaa_union_null_or_fixed_deserialize(avro_reader_t reader);
-
-# endif // KAA_UNION_NULL_OR_FIXED_H_
-
-
-typedef struct {
- kaa_string_t * data;
- kaa_union_t * __uuid;
-
- serialize_fn serialize;
- get_size_fn get_size;
- destroy_fn destroy;
-} kaa_configuration_root_record_t;
-
-kaa_configuration_root_record_t *kaa_configuration_root_record_create(void);
-kaa_configuration_root_record_t *kaa_configuration_root_record_deserialize(avro_reader_t reader);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_event_fqn_definitions.h b/client/client-multi/client-c/src/kaa/gen/kaa_event_fqn_definitions.h
deleted file mode 100644
index 30ed8b46cb..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_event_fqn_definitions.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
- /*
- * This header contains information about all the Event families and
- * events are supported by current SDK.
- */
-
-# ifndef KAA_FQN_DEFINITIONS_
-# define KAA_FQN_DEFINITIONS_
-
-typedef struct {
- char *ecf_name;
- size_t supported_incoming_fqns_count;
- char **supported_incoming_fqns;
-} event_class_family_t;
-
-static const char *TestEventFamilyFQNS[8] = {
- "org.kaaproject.kaa.example.audio.PlayCommand",
- "org.kaaproject.kaa.example.audio.RewindCommand",
- "org.kaaproject.kaa.example.audio.PauseCommand",
- "org.kaaproject.kaa.example.audio.StopCommand",
- "org.kaaproject.kaa.example.audio.PlaybackStatus",
- "org.kaaproject.kaa.example.audio.BatteryChargingStatus",
- "org.kaaproject.kaa.example.audio.BatteryStatus",
- "org.kaaproject.kaa.example.audio.StatusEvent"
-};
-
-# define SUPPORTED_EVENT_CLASS_FAMILIES_SIZE 1
-
-static const event_class_family_t SUPPORTED_EVENT_CLASS_FAMILIES[SUPPORTED_EVENT_CLASS_FAMILIES_SIZE] =
-{
- {
- /* .ecf_name = */ "TestEventFamily",
- /* .supported_incoming_fqns_count = */ 8,
- /* .supported_incoming_fqns = */ (char **)TestEventFamilyFQNS
- }
-};
-# endif
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_logging_definitions.h b/client/client-multi/client-c/src/kaa/gen/kaa_logging_definitions.h
deleted file mode 100644
index 42a7343579..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_logging_definitions.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# ifndef KAA_LOGGING_DEFINITIONS_H_
-# define KAA_LOGGING_DEFINITIONS_H_
-
-# include "kaa_logging_gen.h"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-/**
- * @typedef User-defined log record structure.
- */
-typedef kaa_test_log_record_t kaa_user_log_record_t;
-
-# define KAA_LOGGING_DESERIALIZE(reader) kaa_test_log_record_deserialize(reader)
-
-# ifdef __cplusplus
-} /* extern "C" */
-# endif
-
-# endif /* KAA_LOGGING_DEFINITIONS_H_ */
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_logging_gen.c b/client/client-multi/client-c/src/kaa/gen/kaa_logging_gen.c
deleted file mode 100644
index ea9f1d4e80..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_logging_gen.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# include
-# include
-# include
-# include "kaa_logging_gen.h"
-# include "avro_src/avro/io.h"
-# include "avro_src/encoding.h"
-# include "utilities/kaa_mem.h"
-
-/*
- * AUTO-GENERATED CODE
- */
-
-
-static void kaa_test_log_record_destroy(void *data)
-{
- if (data) {
- kaa_test_log_record_t *record = (kaa_test_log_record_t *)data;
-
- kaa_string_destroy(record->data);
- kaa_data_destroy(record);
- }
-}
-
-static void kaa_test_log_record_serialize(avro_writer_t writer, void *data)
-{
- if (data) {
- kaa_test_log_record_t *record = (kaa_test_log_record_t *)data;
-
- kaa_string_serialize(writer, record->data);
- }
-}
-
-static size_t kaa_test_log_record_get_size(void *data)
-{
- if (data) {
- size_t record_size = 0;
- kaa_test_log_record_t *record = (kaa_test_log_record_t *)data;
-
- record_size += kaa_string_get_size(record->data);
-
- return record_size;
- }
-
- return 0;
-}
-
-kaa_test_log_record_t *kaa_test_log_record_create(void)
-{
- kaa_test_log_record_t *record =
- (kaa_test_log_record_t *)KAA_CALLOC(1, sizeof(kaa_test_log_record_t));
-
- if (record) {
- record->serialize = kaa_test_log_record_serialize;
- record->get_size = kaa_test_log_record_get_size;
- record->destroy = kaa_test_log_record_destroy;
- }
-
- return record;
-}
-
-kaa_test_log_record_t *kaa_test_log_record_deserialize(avro_reader_t reader)
-{
- kaa_test_log_record_t *record =
- (kaa_test_log_record_t *)KAA_MALLOC(sizeof(kaa_test_log_record_t));
-
- if (record) {
- record->serialize = kaa_test_log_record_serialize;
- record->get_size = kaa_test_log_record_get_size;
- record->destroy = kaa_test_log_record_destroy;
-
- record->data = kaa_string_deserialize(reader);
- }
-
- return record;
-}
-
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_logging_gen.h b/client/client-multi/client-c/src/kaa/gen/kaa_logging_gen.h
deleted file mode 100644
index f002170d24..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_logging_gen.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# ifndef KAA_LOGGING_GEN_H_
-# define KAA_LOGGING_GEN_H_
-
-# include "kaa_common_schema.h"
-# include "collections/kaa_list.h"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-
-typedef struct {
- kaa_string_t * data;
-
- serialize_fn serialize;
- get_size_fn get_size;
- destroy_fn destroy;
-} kaa_test_log_record_t;
-
-kaa_test_log_record_t *kaa_test_log_record_create(void);
-kaa_test_log_record_t *kaa_test_log_record_deserialize(avro_reader_t reader);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_notification_definitions.h b/client/client-multi/client-c/src/kaa/gen/kaa_notification_definitions.h
deleted file mode 100644
index 2f9d65ecde..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_notification_definitions.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# ifndef KAA_NOTIFICATION_DEFINITIONS_H_
-# define KAA_NOTIFICATION_DEFINITIONS_H_
-
-# include "kaa_notification_gen.h"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-typedef kaa_notification_notification_t kaa_notification_t;
-# define KAA_NOTIFICATION_DESERIALIZE(reader) kaa_notification_notification_deserialize(reader)
-
-# ifdef __cplusplus
-} /* extern "C" */
-# endif
-
-# endif /* KAA_NOTIFICATION_DEFINITIONS_H_ */
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_notification_gen.c b/client/client-multi/client-c/src/kaa/gen/kaa_notification_gen.c
deleted file mode 100644
index 7033b959da..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_notification_gen.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# include
-# include
-# include
-# include "kaa_notification_gen.h"
-# include "avro_src/avro/io.h"
-# include "avro_src/encoding.h"
-# include "utilities/kaa_mem.h"
-
-/*
- * AUTO-GENERATED CODE
- */
-
-
-static void kaa_notification_notification_destroy(void *data)
-{
- if (data) {
- kaa_notification_notification_t *record = (kaa_notification_notification_t *)data;
-
- kaa_string_destroy(record->message);
- kaa_data_destroy(record);
- }
-}
-
-static void kaa_notification_notification_serialize(avro_writer_t writer, void *data)
-{
- if (data) {
- kaa_notification_notification_t *record = (kaa_notification_notification_t *)data;
-
- kaa_string_serialize(writer, record->message);
- }
-}
-
-static size_t kaa_notification_notification_get_size(void *data)
-{
- if (data) {
- size_t record_size = 0;
- kaa_notification_notification_t *record = (kaa_notification_notification_t *)data;
-
- record_size += kaa_string_get_size(record->message);
-
- return record_size;
- }
-
- return 0;
-}
-
-kaa_notification_notification_t *kaa_notification_notification_create(void)
-{
- kaa_notification_notification_t *record =
- (kaa_notification_notification_t *)KAA_CALLOC(1, sizeof(kaa_notification_notification_t));
-
- if (record) {
- record->serialize = kaa_notification_notification_serialize;
- record->get_size = kaa_notification_notification_get_size;
- record->destroy = kaa_notification_notification_destroy;
- }
-
- return record;
-}
-
-kaa_notification_notification_t *kaa_notification_notification_deserialize(avro_reader_t reader)
-{
- kaa_notification_notification_t *record =
- (kaa_notification_notification_t *)KAA_MALLOC(sizeof(kaa_notification_notification_t));
-
- if (record) {
- record->serialize = kaa_notification_notification_serialize;
- record->get_size = kaa_notification_notification_get_size;
- record->destroy = kaa_notification_notification_destroy;
-
- record->message = kaa_string_deserialize(reader);
- }
-
- return record;
-}
-
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_notification_gen.h b/client/client-multi/client-c/src/kaa/gen/kaa_notification_gen.h
deleted file mode 100644
index aa4a0ca034..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_notification_gen.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# ifndef KAA_NOTIFICATION_GEN_H_
-# define KAA_NOTIFICATION_GEN_H_
-
-# include "kaa_common_schema.h"
-# include "collections/kaa_list.h"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-
-typedef struct {
- kaa_string_t * message;
-
- serialize_fn serialize;
- get_size_fn get_size;
- destroy_fn destroy;
-} kaa_notification_notification_t;
-
-kaa_notification_notification_t *kaa_notification_notification_create();
-kaa_notification_notification_t *kaa_notification_notification_deserialize(avro_reader_t reader);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_profile_definitions.h b/client/client-multi/client-c/src/kaa/gen/kaa_profile_definitions.h
deleted file mode 100644
index 308a1d9094..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_profile_definitions.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# ifndef KAA_PROFILE_DEFINITIONS_H_
-# define KAA_PROFILE_DEFINITIONS_H_
-
-# include "kaa_profile_gen.h"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-/**
- * @typedef User-defined endpoint profile structure.
- */
-typedef kaa_profile_basic_endpoint_profile_test_t kaa_profile_t;
-
-# define KAA_PROFILE_DESERIALIZE(reader) kaa_profile_basic_endpoint_profile_test_deserialize(reader)
-
-# ifdef __cplusplus
-} /* extern "C" */
-# endif
-
-# endif /* KAA_PROFILE_DEFINITIONS_H_ */
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_profile_gen.c b/client/client-multi/client-c/src/kaa/gen/kaa_profile_gen.c
deleted file mode 100644
index b1ac73060f..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_profile_gen.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# include
-# include
-# include
-# include "kaa_profile_gen.h"
-# include "avro_src/avro/io.h"
-# include "avro_src/encoding.h"
-# include "utilities/kaa_mem.h"
-
-/*
- * AUTO-GENERATED CODE
- */
-
-
-static void kaa_profile_basic_endpoint_profile_test_destroy(void *data)
-{
- if (data) {
- kaa_profile_basic_endpoint_profile_test_t *record = (kaa_profile_basic_endpoint_profile_test_t *)data;
-
- kaa_string_destroy(record->profile_body);
- kaa_data_destroy(record);
- }
-}
-
-static void kaa_profile_basic_endpoint_profile_test_serialize(avro_writer_t writer, void *data)
-{
- if (data) {
- kaa_profile_basic_endpoint_profile_test_t *record = (kaa_profile_basic_endpoint_profile_test_t *)data;
-
- kaa_string_serialize(writer, record->profile_body);
- }
-}
-
-static size_t kaa_profile_basic_endpoint_profile_test_get_size(void *data)
-{
- if (data) {
- size_t record_size = 0;
- kaa_profile_basic_endpoint_profile_test_t *record = (kaa_profile_basic_endpoint_profile_test_t *)data;
-
- record_size += kaa_string_get_size(record->profile_body);
-
- return record_size;
- }
-
- return 0;
-}
-
-kaa_profile_basic_endpoint_profile_test_t *kaa_profile_basic_endpoint_profile_test_create(void)
-{
- kaa_profile_basic_endpoint_profile_test_t *record =
- (kaa_profile_basic_endpoint_profile_test_t *)KAA_CALLOC(1, sizeof(kaa_profile_basic_endpoint_profile_test_t));
-
- if (record) {
- record->serialize = kaa_profile_basic_endpoint_profile_test_serialize;
- record->get_size = kaa_profile_basic_endpoint_profile_test_get_size;
- record->destroy = kaa_profile_basic_endpoint_profile_test_destroy;
- }
-
- return record;
-}
-
-kaa_profile_basic_endpoint_profile_test_t *kaa_profile_basic_endpoint_profile_test_deserialize(avro_reader_t reader)
-{
- kaa_profile_basic_endpoint_profile_test_t *record =
- (kaa_profile_basic_endpoint_profile_test_t *)KAA_MALLOC(sizeof(kaa_profile_basic_endpoint_profile_test_t));
-
- if (record) {
- record->serialize = kaa_profile_basic_endpoint_profile_test_serialize;
- record->get_size = kaa_profile_basic_endpoint_profile_test_get_size;
- record->destroy = kaa_profile_basic_endpoint_profile_test_destroy;
-
- record->profile_body = kaa_string_deserialize(reader);
- }
-
- return record;
-}
-
diff --git a/client/client-multi/client-c/src/kaa/gen/kaa_profile_gen.h b/client/client-multi/client-c/src/kaa/gen/kaa_profile_gen.h
deleted file mode 100644
index ead0a4359d..0000000000
--- a/client/client-multi/client-c/src/kaa/gen/kaa_profile_gen.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# ifndef KAA_PROFILE_GEN_H_
-# define KAA_PROFILE_GEN_H_
-
-# include "kaa_common_schema.h"
-# include "collections/kaa_list.h"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-
-typedef struct {
- kaa_string_t * profile_body;
-
- serialize_fn serialize;
- get_size_fn get_size;
- destroy_fn destroy;
-} kaa_profile_basic_endpoint_profile_test_t;
-
-kaa_profile_basic_endpoint_profile_test_t *kaa_profile_basic_endpoint_profile_test_create(void);
-kaa_profile_basic_endpoint_profile_test_t *kaa_profile_basic_endpoint_profile_test_deserialize(avro_reader_t reader);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif
diff --git a/client/client-multi/client-c/src/kaa/kaa.c b/client/client-multi/client-c/src/kaa/kaa.c
deleted file mode 100644
index a2e498a1cb..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_private.h"
-
-#include
-#include
-#include
-#include "platform/stdio.h"
-#include "platform/ext_sha.h"
-#include "kaa_status.h"
-#include "kaa.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-
-#include "kaa_channel_manager.h"
-#include "kaa_defaults.h"
-#include "platform/ext_key_utils.h"
-
-#ifdef KAA_ENCRYPTION
-#include "platform/ext_encryption_utils.h"
-#endif
-
-#include
-
-#ifndef KAA_DISABLE_FEATURE_PROFILE
-#include "kaa_profile_private.h"
-#endif
-
-static kaa_error_t kaa_context_destroy(kaa_context_t *context);
-
-static kaa_error_t kaa_context_create(kaa_context_t **context_p, kaa_logger_t *logger)
-{
- // TODO(KAA-982): use asserts
- if (!context_p || !logger) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_context_t *context = KAA_CALLOC(1, sizeof(*context));
- if (!context) {
- return KAA_ERR_NOMEM;
- }
-
- context->logger = logger;
-
- kaa_error_t error = KAA_ERR_NONE;
- context->status = KAA_CALLOC(1, sizeof(*context->status));
- if (!context->status) {
- error = KAA_ERR_NOMEM;
- goto exit;
- }
-
- error = kaa_status_create(&context->status->status_instance);
- if (error) {
- goto exit;
- }
-
- error = kaa_platform_protocol_create(&context->platform_protocol, context->logger,
- context->status->status_instance);
- if (error) {
- goto exit;
- }
-
- error = kaa_channel_manager_create(&context->channel_manager, context);
- if (error) {
- goto exit;
- }
-
- error = kaa_extension_init_all(context);
- if (error) {
- goto exit;
- }
-
- error = kaa_failover_strategy_create(&context->failover_strategy, logger);
- if (error) {
- goto extensions_deinit;
- }
-
- *context_p = context;
-
- return KAA_ERR_NONE;
-
-extensions_deinit:
- kaa_extension_deinit_all();
-
-exit:
- kaa_context_destroy(context);
-
- return error;
-}
-
-static kaa_error_t kaa_context_destroy(kaa_context_t *context)
-{
- KAA_RETURN_IF_NIL(context, KAA_ERR_BADPARAM);
-
- kaa_channel_manager_destroy(context->channel_manager);
- kaa_status_destroy(context->status->status_instance);
- kaa_failover_strategy_destroy(context->failover_strategy);
- KAA_FREE(context->status);
- kaa_platform_protocol_destroy(context->platform_protocol);
- KAA_FREE(context);
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_init_keys(void)
-{
- kaa_error_t error = kaa_init_rsa_keypair();
- if (error) {
- return error;
- }
-#ifdef KAA_ENCRYPTION
- error = kaa_init_session_key();
- if (error) {
- return error;
- }
-#endif
- return error;
-}
-
-static void kaa_deinit_keys(void)
-{
- kaa_deinit_rsa_keypair();
-}
-
-kaa_error_t kaa_init(kaa_context_t **kaa_context_p)
-{
- KAA_RETURN_IF_NIL(kaa_context_p, KAA_ERR_BADPARAM);
-
- // Initialize logger
- kaa_logger_t *logger = NULL;
- kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL); // TODO: make log destination configurable
- if (error) {
- return error;
- }
-
- KAA_LOG_INFO(logger, KAA_ERR_NONE, "Kaa SDK version %s, commit hash %s", KAA_BUILD_VERSION, KAA_BUILD_COMMIT_HASH);
-
- // Initialize general Kaa context
- error = kaa_context_create(kaa_context_p, logger);
- if (error) {
- KAA_LOG_FATAL(logger, error, "Failed to create Kaa context");
- *kaa_context_p = NULL;
- return error;
- }
-
- // Initialize endpoint identity
- uint8_t *sha1 = NULL;
- size_t sha1_size = 0;
-
- error = kaa_init_keys();
- if (error) {
- KAA_LOG_ERROR(logger, error, "Failed to initialize keys");
- return error;
- }
-
- ext_get_sha1_public(&sha1, &sha1_size);
- ext_copy_sha_hash((*kaa_context_p)->status->status_instance->endpoint_public_key_hash, sha1);
-
- return kaa_status_set_updated((*kaa_context_p)->status->status_instance, true);
-}
-
-kaa_error_t kaa_start(kaa_context_t *kaa_context)
-{
- KAA_RETURN_IF_NIL(kaa_context, KAA_ERR_BADPARAM);
-
- KAA_LOG_INFO(kaa_context->logger, KAA_ERR_NONE, "Going to start Kaa endpoint");
-
- kaa_transport_channel_interface_t *bootstrap_channel = kaa_channel_manager_get_transport_channel(
- kaa_context->channel_manager, KAA_EXTENSION_BOOTSTRAP);
- if (bootstrap_channel) {
- const kaa_extension_id bootstrap_service[] = { KAA_EXTENSION_BOOTSTRAP };
- kaa_error_t error = bootstrap_channel->sync_handler(bootstrap_channel->context, bootstrap_service, 1);
- if (error) {
- KAA_LOG_ERROR(kaa_context->logger, error, "Failed to sync Bootstrap service. Try again later");
- return error;
- }
- } else {
- KAA_LOG_FATAL(kaa_context->logger, KAA_ERR_NOT_FOUND, "Could not find Bootstrap transport channel");
- return KAA_ERR_NOT_FOUND;
- }
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_stop(kaa_context_t *kaa_context)
-{
- KAA_RETURN_IF_NIL(kaa_context, KAA_ERR_BADPARAM);
- return kaa_status_save(kaa_context->status->status_instance);
-}
-
-kaa_error_t kaa_deinit(kaa_context_t *kaa_context)
-{
- KAA_RETURN_IF_NIL(kaa_context, KAA_ERR_BADPARAM);
-
- kaa_logger_t *logger = kaa_context->logger;
- kaa_error_t error = kaa_context_destroy(kaa_context);
- if (error) {
- KAA_LOG_ERROR(logger, error, "Failed to destroy Kaa context");
- }
- kaa_log_destroy(logger);
- kaa_deinit_keys();
- return error;
-}
-
-bool kaa_process_failover(kaa_context_t *kaa_context)
-{
- KAA_RETURN_IF_NIL(kaa_context, false);
- return kaa_bootstrap_manager_process_failover(kaa_context->bootstrap_manager);
-}
-
-kaa_error_t kaa_context_set_status_registered(kaa_context_t *kaa_context, bool is_registered)
-{
- KAA_RETURN_IF_NIL(kaa_context, KAA_ERR_BADPARAM);
- return kaa_status_set_registered(kaa_context->status->status_instance, is_registered);
-}
-
-kaa_error_t kaa_check_readiness(kaa_context_t *kaa_context)
-{
- KAA_RETURN_IF_NIL(kaa_context, KAA_ERR_BADPARAM);
-
-#ifndef KAA_DISABLE_FEATURE_PROFILE
- if (!kaa_profile_manager_is_profile_set(kaa_context->profile_manager)) {
- KAA_LOG_ERROR(kaa_context->logger, KAA_ERR_PROFILE_IS_NOT_SET, "Profile isn't set");
- return KAA_ERR_PROFILE_IS_NOT_SET;
- }
-#endif
-
- return KAA_ERR_NONE;
-}
diff --git a/client/client-multi/client-c/src/kaa/kaa.h b/client/client-multi/client-c/src/kaa/kaa.h
deleted file mode 100644
index 8954a6ba9b..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file kaa.h
- * @brief Kaa C endpoint library
- *
- * Supplies API for initializing and de-initializing general Kaa endpoint context.
- */
-
-#ifndef KAA_H_
-#define KAA_H_
-
-#include
-#include "kaa_context.h"
-#include "kaa_error.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-
-/**
- * @brief Creates and initializes general Kaa endpoint context.
- *
- * The endpoint SDK assumes ownership of the memory allocated for the context and nested data structures.
- *
- * @param[in,out] kaa_context_p Pointer to return the address of initialized Kaa endpoint context to.
- *
- * @return Error code.
- */
-kaa_error_t kaa_init(kaa_context_t **kaa_context_p);
-
-
-
-/**
- * @brief Starts Kaa's workflow.
- *
- * @note Should be called after @link kaa_init() @endlink.
- *
- * @param[in] kaa_context Pointer to an initialized Kaa endpoint context.
- *
- * @return Error code.
- */
-kaa_error_t kaa_start(kaa_context_t *kaa_context);
-
-/**
- * @brief Stops Kaa's workflow.
- *
- * @note Should be called after @link kaa_start() @endlink.
- *
- * @param[in] kaa_context Pointer to an initialized Kaa endpoint context.
- *
- * @return Error code.
- */
-kaa_error_t kaa_stop(kaa_context_t *kaa_context);
-
-
-/**
- * @brief De-initializes and destroys general Kaa endpoint context.
- *
- * After a successful call @c kaa_context pointer becomes invalid.
- *
- * @param[in] kaa_context Pointer to an initialized Kaa endpoint context.
- *
- * @return Error code.
- */
-kaa_error_t kaa_deinit(kaa_context_t *kaa_context);
-
-
-
-/**
- * @brief Processes failovers.
- *
- * @param[in] kaa_context Bootstrap manager.
- * @retval true Failover is scheduled
- * @retval false Otherwise
- */
-bool kaa_process_failover(kaa_context_t *kaa_context);
-
-
-
-/**
- * @brief Checks if Kaa context is initialized and ready to be used.
- *
- * @param[in] kaa_context Pointer to an initialized Kaa endpoint context.
- *
- * @return KAA_ERR_NONE if Kaa context is ready to be used.
- */
-kaa_error_t kaa_check_readiness(kaa_context_t *kaa_context);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* KAA_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_channel_manager.c b/client/client-multi/client-c/src/kaa/kaa_channel_manager.c
deleted file mode 100644
index a903d4398d..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_channel_manager.c
+++ /dev/null
@@ -1,497 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_private.h"
-
-#include
-#include
-
-#include "kaa_channel_manager.h"
-#include "collections/kaa_list.h"
-#include "utilities/kaa_log.h"
-#include "utilities/kaa_mem.h"
-#include "kaa_platform_common.h"
-#include "kaa_platform_utils.h"
-// This header conflicts with stdio.h and should be put last
-#include "platform/sock.h"
-
-typedef struct {
- uint32_t channel_id;
- kaa_server_type_t server_type;
- kaa_transport_channel_interface_t channel;
-} kaa_transport_channel_wrapper_t;
-
-typedef struct {
- bool is_up_to_date;
- uint16_t request_id;
- uint32_t payload_size;
- uint16_t channel_count;
-} kaa_sync_info_t;
-
-typedef struct {
- kaa_auth_failure_fn callback;
- void *context;
-} kaa_auth_failure_handler;
-
-struct kaa_channel_manager_t {
- kaa_list_t *transport_channels;
- kaa_context_t *kaa_context;
- kaa_logger_t *logger;
- kaa_sync_info_t sync_info;
- kaa_auth_failure_handler auth_failure_handler;
-};
-
-
-
-static void destroy_channel(void *data)
-{
- KAA_RETURN_IF_NIL(data,);
-
- kaa_transport_channel_wrapper_t *channel_wrapper = (kaa_transport_channel_wrapper_t *)data;
-
- if (channel_wrapper->channel.destroy) {
- channel_wrapper->channel.destroy(channel_wrapper->channel.context);
- }
-
- KAA_FREE(channel_wrapper);
-}
-
-static bool find_channel_by_channel_id(/* current channel */void *data, /* channel-matcher */void *context)
-{
- KAA_RETURN_IF_NIL2(data, context, false);
- return (((kaa_transport_channel_wrapper_t *)data)->channel_id == *((uint32_t *)context));
-}
-
-static bool find_channel_by_protocol_id(/* current channel */void *data, /* channel-matcher */void *context)
-{
- KAA_RETURN_IF_NIL2(data, context, false);
-
- kaa_transport_protocol_id_t channel_info;
- kaa_error_t error_code = ((kaa_transport_channel_wrapper_t *)data)->channel.
- get_protocol_id(((kaa_transport_channel_wrapper_t *)data)->channel.context, &channel_info);
- if (error_code)
- return false;
-
- return kaa_transport_protocol_id_equals((kaa_transport_protocol_id_t *)context, &channel_info);
-}
-
-kaa_error_t kaa_channel_manager_create(kaa_channel_manager_t **channel_manager_p,
- kaa_context_t *context)
-{
- if (!channel_manager_p || !context) {
- return KAA_ERR_BADPARAM;
- }
-
- kaa_channel_manager_t *channel_manager = KAA_MALLOC(sizeof(kaa_channel_manager_t));
- if (!channel_manager) {
- return KAA_ERR_NOMEM;
- }
-
- channel_manager->transport_channels = kaa_list_create();
- if (!channel_manager->transport_channels) {
- KAA_FREE(channel_manager);
- return KAA_ERR_NOMEM;
- }
-
- channel_manager->kaa_context = context;
- channel_manager->sync_info.request_id = 0;
- channel_manager->sync_info.is_up_to_date = false;
- channel_manager->logger = context->logger;
- channel_manager->auth_failure_handler.callback = NULL;
- channel_manager->auth_failure_handler.context = NULL;
-
- *channel_manager_p = channel_manager;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_transport_channel_id_calculate(kaa_transport_channel_interface_t *channel
- , uint32_t *channel_id)
-{
- KAA_RETURN_IF_NIL2(channel, channel_id, KAA_ERR_BADPARAM);
-
- const uint32_t prime = 31;
-
- *channel_id = 1;
- *channel_id = prime * (*channel_id) + (ptrdiff_t)channel->context;
- *channel_id = prime * (*channel_id) + (ptrdiff_t)channel->destroy;
- *channel_id = prime * (*channel_id) + (ptrdiff_t)channel->init;
- *channel_id = prime * (*channel_id) + (ptrdiff_t)channel->set_access_point;
- *channel_id = prime * (*channel_id) + (ptrdiff_t)channel->sync_handler;
- *channel_id = prime * (*channel_id) + (ptrdiff_t)channel->get_protocol_id;
- kaa_transport_protocol_id_t protoco_id = { 0, 0 };
- channel->get_protocol_id(channel->context, &protoco_id);
- *channel_id = prime * (*channel_id) + protoco_id.id;
- *channel_id = prime * (*channel_id) + protoco_id.version;
-
- *channel_id = prime * (*channel_id) + (ptrdiff_t)channel->get_supported_services;
- size_t services_count = 0;
- const kaa_extension_id *services = NULL;
- channel->get_supported_services(channel->context, &services, &services_count);
- if (services) {
- size_t i = 0;
- for (; i < services_count; ++i)
- *channel_id = prime * (*channel_id) + (int) services[i];
- }
-
- return KAA_ERR_NONE;
-}
-
-void kaa_channel_manager_destroy(kaa_channel_manager_t *self)
-{
- if (self) {
- kaa_list_destroy(self->transport_channels, destroy_channel);
- KAA_FREE(self);
- }
-}
-
-static bool is_bootstrap_service_supported(kaa_transport_channel_interface_t *channel)
-{
- KAA_RETURN_IF_NIL(channel, false);
-
- const kaa_extension_id *services;
- size_t service_count;
- kaa_error_t error_code = channel->get_supported_services(channel->context
- , &services
- , &service_count);
-
- if (!error_code) {
- size_t i = 0;
- for (; i < service_count; ++i) {
- if (services[i] == KAA_EXTENSION_BOOTSTRAP) {
- return true;
- }
- }
- }
-
- return false;
-}
-
-static kaa_error_t add_channel(kaa_channel_manager_t *self
- , kaa_transport_channel_interface_t *channel
- , uint32_t *channel_id)
-{
- KAA_RETURN_IF_NIL2(self, channel, KAA_ERR_BADPARAM);
-
- kaa_transport_protocol_id_t protocol_id = { 0, 0 };
- channel->get_protocol_id(channel->context, &protocol_id);
-
- uint32_t id;
- kaa_transport_channel_id_calculate(channel, &id);
-
- kaa_list_node_t *it = kaa_list_find_next(kaa_list_begin(self->transport_channels), &find_channel_by_channel_id, &id);
- if (it) {
- KAA_LOG_WARN(self->kaa_context->logger, KAA_ERR_ALREADY_EXISTS,
- "Transport channel [0x%08X] already exists (protocol: id=0x%08X, version=%u)"
- , id, protocol_id.id, protocol_id.version);
- return KAA_ERR_ALREADY_EXISTS;
- }
-
- kaa_transport_channel_wrapper_t *wrapper =
- (kaa_transport_channel_wrapper_t *)KAA_MALLOC(sizeof(kaa_transport_channel_wrapper_t));
- KAA_RETURN_IF_NIL(wrapper, KAA_ERR_NOMEM);
-
- wrapper->channel_id = id;
- wrapper->channel = *channel;
- wrapper->server_type = is_bootstrap_service_supported(channel) ? KAA_SERVER_BOOTSTRAP : KAA_SERVER_OPERATIONS;
-
- it = kaa_list_push_front(self->transport_channels, wrapper);
- if (!it) {
- KAA_LOG_ERROR(self->kaa_context->logger, KAA_ERR_NOMEM,
- "Failed to add new transport channel [0x%08X] (protocol: id=0x%08X, version=%u)"
- , id, protocol_id.id, protocol_id.version);
- KAA_FREE(wrapper);
- return KAA_ERR_NOMEM;
- }
-
- if (channel_id) {
- *channel_id = id;
- }
-
- self->sync_info.is_up_to_date = false;
-
- KAA_LOG_INFO(self->kaa_context->logger, KAA_ERR_NONE,
- "%s transport channel [0x%08X] added (protocol: id=0x%08X, version=%u)"
- , (wrapper->server_type == KAA_SERVER_BOOTSTRAP) ? "Bootstrap" : "Operations"
- , id, protocol_id.id, protocol_id.version);
-
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t init_channel(kaa_channel_manager_t *self
- , kaa_transport_channel_interface_t *channel)
-{
- KAA_RETURN_IF_NIL3(self, self->kaa_context, channel, KAA_ERR_BADPARAM);
-
- static kaa_transport_context_t transport_context = { NULL };
- transport_context.kaa_context = self->kaa_context;
-
- channel->init(channel->context, &transport_context);
-
- kaa_transport_protocol_id_t protocol_id = { 0, 0 };
- kaa_error_t error_code = channel->get_protocol_id(channel->context, &protocol_id);
-
- if (!error_code) {
- kaa_access_point_t *access_point;
-
- uint32_t id;
- kaa_transport_channel_id_calculate(channel, &id);
-
- kaa_list_node_t *it = kaa_list_find_next(kaa_list_begin(self->transport_channels), &find_channel_by_channel_id, &id);
- KAA_RETURN_IF_NIL(it, KAA_ERR_NOT_FOUND);
-
- bool is_bootstrap_channel = ((kaa_transport_channel_wrapper_t *)kaa_list_get_data(it))->
- server_type == KAA_SERVER_BOOTSTRAP;
-
- if (is_bootstrap_channel) {
- access_point = kaa_bootstrap_manager_get_bootstrap_access_point(self->kaa_context->bootstrap_manager, &protocol_id);
- } else {
- access_point = kaa_bootstrap_manager_get_operations_access_point(self->kaa_context->bootstrap_manager, &protocol_id);
- }
-
- if (access_point) {
- KAA_LOG_TRACE(self->kaa_context->logger, KAA_ERR_NONE, "Found %s access point [0x%08X] for channel [0x%08X] "
- "(protocol: id=0x%08X, version=%u)", (is_bootstrap_channel ? "Bootstrap" : "Operations")
- , access_point->id, id, protocol_id.id, protocol_id.version);
-
- channel->set_access_point(channel->context, access_point);
- } else {
- if (is_bootstrap_channel) {
- KAA_LOG_WARN(self->kaa_context->logger, KAA_ERR_NOT_FOUND, "Could not find access point for Bootstrap channel [0x%08X] "
- "(protocol: id=0x%08X, version=%u)", id, protocol_id.id, protocol_id.version);
- } else {
- KAA_LOG_INFO(self->kaa_context->logger, KAA_ERR_NOT_FOUND, "Could not find access point for Operations channel [0x%08X] "
- "(protocol: id=0x%08X, version=%u)", id, protocol_id.id, protocol_id.version);
- }
- return KAA_ERR_BAD_STATE;
- }
- }
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_channel_manager_add_transport_channel(kaa_channel_manager_t *self
- , kaa_transport_channel_interface_t *channel
- , uint32_t *channel_id)
-{
- KAA_RETURN_IF_NIL2(self, channel, KAA_ERR_BADPARAM);
-
- kaa_error_t error_code = add_channel(self, channel, channel_id);
- if (!error_code) {
- error_code = init_channel(self, channel);
- }
-
- return error_code;
-}
-
-kaa_error_t kaa_channel_manager_remove_transport_channel(kaa_channel_manager_t *self
- , uint32_t channel_id)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
-
- kaa_error_t error_code = kaa_list_remove_first(self->transport_channels
- , &find_channel_by_channel_id
- , &channel_id
- , &destroy_channel);
-
- if (!error_code) {
- self->sync_info.is_up_to_date = false;
- KAA_LOG_INFO(self->kaa_context->logger, KAA_ERR_NONE, "Transport channel [0x%08X] was removed", channel_id);
- return KAA_ERR_NONE;
- }
-
- KAA_LOG_WARN(self->kaa_context->logger, error_code, "Transport channel [0x%08X] was not found", channel_id);
-
- return error_code;
-}
-
-kaa_transport_channel_interface_t *kaa_channel_manager_get_transport_channel(kaa_channel_manager_t *self
- , kaa_extension_id service_type)
-{
- KAA_RETURN_IF_NIL(self, NULL);
-
- kaa_transport_channel_wrapper_t *channel_wrapper;
- const kaa_extension_id *services;
- size_t service_count;
-
- kaa_list_node_t *it = kaa_list_begin(self->transport_channels);
- while (it) {
- channel_wrapper = kaa_list_get_data(it);
-
- kaa_error_t error_code = channel_wrapper->channel.get_supported_services(channel_wrapper->channel.context,
- &services,
- &service_count);
- if (error_code || !services || !service_count) {
- KAA_LOG_WARN(self->kaa_context->logger, error_code, "Failed to retrieve list of supported services "
- "for transport channel [0x%08X]", channel_wrapper->channel_id);
- continue;
- }
-
- while (service_count--) {
- if (*services++ == service_type) {
- KAA_LOG_TRACE(self->kaa_context->logger, KAA_ERR_NONE, "Transport channel "
- "[0x%08X] for service %u was found"
- , channel_wrapper->channel_id, service_type);
- return &channel_wrapper->channel;
- }
- }
-
- it = kaa_list_next(it);
- }
-
- KAA_LOG_DEBUG(self->kaa_context->logger, KAA_ERR_NOT_FOUND,
- "Failed to find transport channel for service %u", service_type);
-
- return NULL;
-}
-
-kaa_error_t kaa_channel_manager_bootstrap_request_get_size(kaa_channel_manager_t *self
- , size_t *expected_size)
-{
- KAA_RETURN_IF_NIL2(self, expected_size, KAA_ERR_BADPARAM);
-
- *expected_size = 0;
-
- if (!self->sync_info.is_up_to_date) {
- size_t channel_count = kaa_list_get_size(self->transport_channels);
-
- if (channel_count > 0) {
- *expected_size += KAA_EXTENSION_HEADER_SIZE
- + sizeof(uint16_t) /* Request ID */
- + sizeof(uint16_t) /* Supported protocols count */
- + channel_count * (sizeof(uint32_t) /* Supported protocol ID */
- + sizeof(uint16_t) /* Supported protocol version */
- + sizeof(uint16_t) /* Reserved */);
-
- self->sync_info.payload_size = *expected_size - KAA_EXTENSION_HEADER_SIZE;
- self->sync_info.channel_count = channel_count;
- self->sync_info.is_up_to_date = true;
- }
- } else {
- *expected_size = self->sync_info.payload_size + KAA_EXTENSION_HEADER_SIZE;
- }
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_channel_manager_bootstrap_request_serialize(kaa_channel_manager_t *self
- , kaa_platform_message_writer_t* writer)
-{
- KAA_RETURN_IF_NIL2(self, writer, KAA_ERR_BADPARAM);
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize client bootstrap sync");
-
- kaa_error_t error_code = KAA_ERR_NONE;
-
- if (self->sync_info.payload_size > 0 && self->sync_info.channel_count > 0) {
- error_code = kaa_platform_message_write_extension_header(writer
- , KAA_EXTENSION_BOOTSTRAP
- , 0
- , self->sync_info.payload_size);
- KAA_RETURN_IF_ERR(error_code);
-
- uint16_t network_order_16;
- uint32_t network_order_32;
-
- ++self->sync_info.request_id;
- network_order_16 = KAA_HTONS(self->sync_info.request_id);
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
-
- network_order_16 = KAA_HTONS(self->sync_info.channel_count);
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Serializing %u supported protocol(s), request id %u", self->sync_info.channel_count, self->sync_info.request_id);
- kaa_transport_channel_wrapper_t *channel_wrapper;
- kaa_transport_protocol_id_t protocol_info;
-
- kaa_list_node_t *it = kaa_list_begin(self->transport_channels);
- while (it) {
- channel_wrapper = (kaa_transport_channel_wrapper_t *)kaa_list_get_data(it);
-
- error_code = channel_wrapper->channel.get_protocol_id(channel_wrapper->channel.context
- , &protocol_info);
- KAA_RETURN_IF_ERR(error_code);
-
- network_order_32 = KAA_HTONL(protocol_info.id);
- error_code = kaa_platform_message_write(writer, &network_order_32, sizeof(uint32_t));
- KAA_RETURN_IF_ERR(error_code);
-
- network_order_16 = KAA_HTONS(protocol_info.version);
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
-
- network_order_16 = 0; /* Reserved */
- error_code = kaa_platform_message_write(writer, &network_order_16, sizeof(uint16_t));
- KAA_RETURN_IF_ERR(error_code);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Serialized protocol: id '%u', version '%u'", protocol_info.id, protocol_info.version);
- it = kaa_list_next(it);
- }
- }
-
- return error_code;
-}
-
-kaa_error_t kaa_channel_manager_on_new_access_point(kaa_channel_manager_t *self
- , kaa_transport_protocol_id_t *protocol_id
- , kaa_server_type_t server_type
- , kaa_access_point_t *access_point)
-{
- KAA_RETURN_IF_NIL3(self, protocol_id, access_point, KAA_ERR_BADPARAM);
-
- kaa_list_node_t *channel_it = kaa_list_find_next(kaa_list_begin(self->transport_channels)
- , &find_channel_by_protocol_id
- , protocol_id);
-
- while (channel_it) {
- kaa_transport_channel_wrapper_t *channel_wrapper = kaa_list_get_data(channel_it);
- if (channel_wrapper->server_type == server_type) {
- KAA_LOG_TRACE(self->kaa_context->logger, KAA_ERR_NONE, "Set new %s access point [0x%08X] for channel [0x%08X] "
- "(protocol: id=0x%08X, version=%u)"
- , (channel_wrapper->server_type == KAA_SERVER_BOOTSTRAP ? "Bootstrap" : "Operations")
- , access_point->id, channel_wrapper->channel_id, protocol_id->id, protocol_id->version);
- channel_wrapper->channel.set_access_point(
- channel_wrapper->channel.context, access_point);
- }
-
- channel_it = kaa_list_find_next(kaa_list_next(channel_it)
- , &find_channel_by_protocol_id
- , protocol_id);
- }
-
- return KAA_ERR_NONE;
-}
-
-void kaa_channel_manager_set_auth_failure_handler(kaa_channel_manager_t *self,
- kaa_auth_failure_fn handler, void *context)
-{
- if (!self) {
- return;
- }
-
- self->auth_failure_handler.callback = handler;
- self->auth_failure_handler.context = context;
-}
-
-void kaa_channel_manager_process_auth_failure(kaa_channel_manager_t *self,
- kaa_auth_failure_reason reason)
-{
- if (!self || !self->auth_failure_handler.callback) {
- return;
- }
-
- self->auth_failure_handler.callback(reason, self->auth_failure_handler.context);
-}
diff --git a/client/client-multi/client-c/src/kaa/kaa_channel_manager.h b/client/client-multi/client-c/src/kaa/kaa_channel_manager.h
deleted file mode 100644
index 7181e3c4f5..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_channel_manager.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file kaa_channel_manager.h
- * @brief User defined channels manager for Kaa C SDK.
- *
- * Manages client transport channels.
- *
- * Notifies about new access points and indicates to user defined protocol
- * implementations that Kaa services have data to sync with Operations server.
- */
-
-#ifndef KAA_CHANNEL_MANAGER_H_
-#define KAA_CHANNEL_MANAGER_H_
-
-#include "kaa_common.h"
-#include "platform/ext_transport_channel.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Kaa channel manager structure.
- */
-#ifndef KAA_CHANNEL_MANAGER_T
-# define KAA_CHANNEL_MANAGER_T
-typedef struct kaa_channel_manager_t kaa_channel_manager_t;
-#endif
-
-
-
-/**
- * Calculates the unique id for the transport channel implementations.
- *
- * @param[in] channel Interface of the transport channel implementations.
- * @param[in,out] channel_id Pointer to calculated channel id.
- *
- * @return Error code.
- */
-kaa_error_t kaa_transport_channel_id_calculate(kaa_transport_channel_interface_t *channel,
- uint32_t *channel_id);
-
-/**
- * @brief Adds user-defined transport channel implementation as a sync request
- * handler for the given list of services.
- *
- * Kaa library will call the channel's callback when there is data to be sent to
- * Operations server for one of the specified services.
- *
- * @b NOTE: It is possible to register more than one channel for the same service.
- * In such event Kaa library will use the last registered one.
- *
- * @param[in] self Channel manager.
- * @param[in] channel Transport channel implementations.
- * @param[in,out] channel_id Pointer to calculate channel id.
- * May be NULL if id isn't needed.
- *
- * @return Error code.
- */
-kaa_error_t kaa_channel_manager_add_transport_channel(kaa_channel_manager_t *self,
- kaa_transport_channel_interface_t *channel,
- uint32_t *channel_id);
-
-/**
- * Gets transport channel associated with the service.
- *
- * @param[in] self Channel manager.
- * @param[in] service_type Type of service with associated channel.
- * @return Channel, if found. NULL if not found.
- */
-kaa_transport_channel_interface_t *kaa_channel_manager_get_transport_channel(kaa_channel_manager_t *self,
- kaa_extension_id service_type);
-
-
-/**
- * @brief Removes user-defined transport channel implementation from
- * the currently registered list.
- *
- * @b NOTE: The channel manager is responsible to release all resources related
- * to this channel.
- *
- * @param[in] self Channel manager.
- * @param[in] channel_id Channel id.
- *
- * @return Error code.
- */
-kaa_error_t kaa_channel_manager_remove_transport_channel(kaa_channel_manager_t *self,
- uint32_t channel_id);
-
-
-
-/**
- * Specifies authorization failure reason.
- *
- */
-typedef enum {
- KAA_AUTH_STATUS_UNKNOWN, /**< Authorization failed for unknown reason. */
- KAA_AUTH_STATUS_BAD_CREDENTIALS, /**< Authorization failed because credentials are invalid. */
- KAA_AUTH_STATUS_VERIFICATION_FAILED, /**< Authorization failed because of verification failure. */
-} kaa_auth_failure_reason;
-
-
-
-/**
- * Processes authorization failure.
- *
- * @param[in] reason Authorization failure reason.
- * @param[in] context Handler context.
- */
-typedef void (*kaa_auth_failure_fn)(kaa_auth_failure_reason reason, void *context);
-
-
-
-/**
- * Specify authorization failure handler
- *
- * @param[in] self Channel manager.
- * @param[in] handler Authorization failure handler.
- * @param[in] context Handler context.
- */
-void kaa_channel_manager_set_auth_failure_handler(kaa_channel_manager_t *self,
- kaa_auth_failure_fn handler, void *context);
-
-
-/**
- * Processes authorization failure if valid handler exists.
- *
- * @param[in] self Channel manager.
- * @param[in] reason Authorization failure reason.
- */
-void kaa_channel_manager_process_auth_failure(kaa_channel_manager_t *self,
- kaa_auth_failure_reason reason);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* KAA_CHANNEL_MANAGER_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_common.h b/client/client-multi/client-c/src/kaa/kaa_common.h
deleted file mode 100644
index 43258b7d97..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_common.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file kaa_common.h
- * @brief Common C EP SDK definitions and small utilities
- */
-
-#ifndef KAA_COMMON_H_
-#define KAA_COMMON_H_
-
-#include
-#include "kaa_error.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief Kaa extensions.
- */
-typedef enum {
- // Don't change numbers. They are critical to platform protocol.
- KAA_EXTENSION_BOOTSTRAP = 0,
- KAA_EXTENSION_META_DATA = 1,
- KAA_EXTENSION_PROFILE = 2,
- KAA_EXTENSION_USER = 3,
- KAA_EXTENSION_LOGGING = 4,
- KAA_EXTENSION_CONFIGURATION = 5,
- KAA_EXTENSION_EVENT = 7,
- KAA_EXTENSION_NOTIFICATION = 6,
-} kaa_extension_id;
-
-/*
- * Standard error handling macros
- */
-#define KAA_RETURN_IF_ERR(E) \
- do { if (E) return E; } while (0)
-
-#define KAA_RETURN_IF_NIL(p, E) \
- do { if (!(p)) return E; } while (0)
-
-#define KAA_RETURN_IF_NIL2(p1, p2, E) \
- do { if (!(p1) || !(p2)) return E; } while (0)
-
-#define KAA_RETURN_IF_NIL3(p1, p2, p3, E) \
- do { if (!(p1) || !(p2) || !(p3)) return E; } while (0)
-
-#define KAA_RETURN_IF_NIL4(p1, p2, p3, p4, E) \
- do { if (!(p1) || !(p2) || !(p3) || !(p4)) return E; } while (0)
-
-#define KAA_RETURN_IF_NIL5(p1, p2, p3, p4, p5,E) \
- do { if (!(p1) || !(p2) || !(p3) || !(p4) || !(p5)) return E; } while (0)
-
-/**
- * @brief Identifier used to uniquely represent transport protocol.
- */
-typedef struct {
- uint32_t id;
- uint16_t version;
-} kaa_transport_protocol_id_t;
-
-static inline int kaa_transport_protocol_id_equals(const kaa_transport_protocol_id_t *first, const kaa_transport_protocol_id_t *second)
-{
- return first && second && first->id == second->id && first->version == second->version;
-}
-
-/**
- * @brief Connection parameters used by transport channels to establish
- * connection both to Bootstrap and Operations servers.
- */
-typedef struct {
- uint32_t id;
- uint16_t connection_data_len;
- char *connection_data;
-} kaa_access_point_t;
-
-/*
- * Endpoint ID
- */
-#define KAA_ENDPOINT_ID_LENGTH 20
-typedef uint8_t kaa_endpoint_id[KAA_ENDPOINT_ID_LENGTH];
-typedef const uint8_t *kaa_endpoint_id_p;
-
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* KAA_COMMON_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_common_schema.c b/client/client-multi/client-c/src/kaa/kaa_common_schema.c
deleted file mode 100644
index 1814fa94c3..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_common_schema.c
+++ /dev/null
@@ -1,499 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_private.h"
-
-#include
-#include
-
-#include "kaa_common.h"
-#include "platform/stdio.h"
-#include "kaa_common_schema.h"
-#include "avro_src/avro/io.h"
-#include "avro_src/encoding.h"
-#include "utilities/kaa_mem.h"
-#include "kaa_error.h"
-
-
-
-size_t avro_long_get_size(int64_t l)
-{
- int64_t len = 0;
- uint64_t n = (l << 1) ^ (l >> 63);
- while (n & ~0x7F) {
- len++;
- n >>= 7;
- }
- len++;
- return len;
-}
-
-void kaa_string_serialize(avro_writer_t writer, void *data)
-{
- KAA_RETURN_IF_NIL2(writer, data,);
-
- kaa_string_t *str = (kaa_string_t *)data;
- if (str->data) {
- avro_binary_encoding.write_string(writer, str->data);
- }
-}
-
-kaa_string_t *kaa_string_move_create(const char *data, destroy_fn destroy)
-{
- KAA_RETURN_IF_NIL(data, NULL);
-
- kaa_string_t *str = (kaa_string_t *)KAA_MALLOC(sizeof(kaa_string_t));
- KAA_RETURN_IF_NIL(str, NULL);
-
- str->data = (char *)data;
- str->destroy = destroy;
-
- return str;
-}
-
-kaa_string_t *kaa_string_copy_create(const char *data)
-{
- KAA_RETURN_IF_NIL(data, NULL);
-
- kaa_string_t *str = (kaa_string_t *)KAA_MALLOC(sizeof(kaa_string_t));
- KAA_RETURN_IF_NIL(str, NULL);
-
- size_t len = strlen(data) + 1;
- str->data = (char *)KAA_MALLOC(len * sizeof(char));
- if (!str->data) {
- KAA_FREE(str);
- return NULL;
- }
-
- memcpy(str->data, data, len);
- str->destroy = &kaa_data_destroy;
-
- return str;
-}
-
-void kaa_string_destroy(void *data)
-{
- KAA_RETURN_IF_NIL(data,);
-
- kaa_string_t *str = (kaa_string_t *)data;
- if (str->data && str->destroy) {
- str->destroy(str->data);
- }
- KAA_FREE(str);
-}
-
-kaa_string_t *kaa_string_deserialize(avro_reader_t reader)
-{
- KAA_RETURN_IF_NIL(reader, NULL);
-
- kaa_string_t *str = (kaa_string_t *)KAA_MALLOC(sizeof(kaa_string_t));
- KAA_RETURN_IF_NIL(str, NULL);
-
- avro_binary_encoding.read_string(reader, &str->data, NULL);
- str->destroy = kaa_data_destroy;
-
- return str;
-}
-
-size_t kaa_string_get_size(void *data)
-{
- KAA_RETURN_IF_NIL(data, 0);
-
- kaa_string_t *str = (kaa_string_t *)data;
- if (str->data) {
- size_t len = strlen(str->data);
- return avro_long_get_size(len) + len;
- }
- return 0;
-}
-
-kaa_bytes_t *kaa_bytes_move_create(const uint8_t *data, size_t data_len, destroy_fn destroy)
-{
- KAA_RETURN_IF_NIL2(data, data_len, NULL);
-
- kaa_bytes_t *bytes_array = (kaa_bytes_t *)KAA_MALLOC(sizeof(kaa_bytes_t));
- KAA_RETURN_IF_NIL(bytes_array, NULL);
-
- bytes_array->buffer = (uint8_t *)data;
- bytes_array->size = data_len;
- bytes_array->destroy = destroy;
-
- return bytes_array;
-}
-
-kaa_bytes_t *kaa_bytes_copy_create(const uint8_t *data, size_t data_len)
-{
- KAA_RETURN_IF_NIL2(data, data_len, NULL);
-
- kaa_bytes_t *bytes_array = (kaa_bytes_t *)KAA_MALLOC(sizeof(kaa_bytes_t));
- KAA_RETURN_IF_NIL(bytes_array, NULL);
-
- bytes_array->buffer = (uint8_t *)KAA_MALLOC(sizeof(uint8_t) * data_len);
- if (!bytes_array->buffer) {
- KAA_FREE(bytes_array);
- return NULL;
- }
-
- memcpy(bytes_array->buffer, data, data_len);
- bytes_array->size = data_len;
- bytes_array->destroy = &kaa_data_destroy;
-
- return bytes_array;
-}
-
-void kaa_bytes_destroy(void *data)
-{
- KAA_RETURN_IF_NIL(data, );
-
- kaa_bytes_t *bytes = (kaa_bytes_t *)data;
- if (bytes->buffer && bytes->destroy) {
- bytes->destroy(bytes->buffer);
- }
- KAA_FREE(bytes);
-}
-
-kaa_bytes_t *kaa_bytes_deserialize(avro_reader_t reader)
-{
- KAA_RETURN_IF_NIL(reader, NULL);
-
- kaa_bytes_t *bytes = (kaa_bytes_t *)KAA_MALLOC(sizeof(kaa_bytes_t));
- KAA_RETURN_IF_NIL(bytes, NULL);
-
- int64_t size;
- avro_binary_encoding.read_bytes(reader, (char **)&bytes->buffer, &size);
- bytes->size = size;
- bytes->destroy = kaa_data_destroy;
-
- return bytes;
-}
-
-void kaa_bytes_serialize(avro_writer_t writer, void *data)
-{
- kaa_bytes_t *bytes = (kaa_bytes_t *)data;
- KAA_RETURN_IF_NIL4(writer, bytes, bytes->buffer, bytes->size, );
-
- avro_binary_encoding.write_bytes(writer, (char *)bytes->buffer, bytes->size);
-}
-
-size_t kaa_bytes_get_size(void *data)
-{
- kaa_bytes_t *bytes = (kaa_bytes_t *)data;
- KAA_RETURN_IF_NIL3(bytes, bytes->buffer, bytes->size, 0);
- return avro_long_get_size(bytes->size) + bytes->size;
-
-}
-
-kaa_bytes_t *kaa_fixed_move_create(const uint8_t *data, size_t data_len, destroy_fn destroy)
-{
- return kaa_bytes_move_create(data, data_len, destroy);
-}
-
-kaa_bytes_t *kaa_fixed_copy_create(const uint8_t *data, size_t data_len)
-{
- return kaa_bytes_copy_create(data, data_len);
-}
-
-void kaa_fixed_destroy(void *data)
-{
- kaa_bytes_destroy(data);
-}
-
-void kaa_fixed_serialize(avro_writer_t writer, void *data)
-{
- kaa_bytes_t *bytes = (kaa_bytes_t *)data;
- KAA_RETURN_IF_NIL4(writer, bytes, bytes->buffer, bytes->size, );
-
- avro_write(writer, (char *)bytes->buffer, bytes->size);
-}
-
-kaa_bytes_t *kaa_fixed_deserialize(avro_reader_t reader, void *context)
-{
- KAA_RETURN_IF_NIL2(reader, context, NULL);
-
- kaa_bytes_t *bytes = (kaa_bytes_t *)KAA_MALLOC(sizeof(kaa_bytes_t));
- KAA_RETURN_IF_NIL(bytes, NULL);
- bytes->buffer = (uint8_t*)KAA_MALLOC((*(size_t *)context) * sizeof(uint8_t));
- if (!bytes->buffer) {
- KAA_FREE(bytes);
- return NULL;
- }
-
- avro_read(reader, (void *)bytes->buffer, (*(size_t *)context));
- bytes->size = (*(size_t *)context);
- bytes->destroy = kaa_data_destroy;
-
- return bytes;
-}
-
-size_t kaa_fixed_get_size(void *data)
-{
- kaa_bytes_t *bytes = (kaa_bytes_t *)data;
- KAA_RETURN_IF_NIL3(bytes, bytes->buffer, bytes->size, 0);
- return bytes->size;
-}
-
-void kaa_boolean_serialize(avro_writer_t writer, void *data)
-{
- KAA_RETURN_IF_NIL2(writer, data,);
- avro_binary_encoding.write_boolean(writer, *((int8_t *)data));
-}
-
-int8_t* kaa_boolean_deserialize(avro_reader_t reader)
-{
- KAA_RETURN_IF_NIL(reader, NULL);
-
- int8_t* data = (int8_t*)KAA_MALLOC(sizeof(int8_t));
- KAA_RETURN_IF_NIL(data, NULL);
- avro_binary_encoding.read_boolean(reader, data);
- return data;
-}
-
-size_t kaa_boolean_get_size(void *data)
-{
- KAA_RETURN_IF_NIL(data, 0);
- return avro_long_get_size(*((int8_t *)data));
-}
-
-void kaa_int_serialize(avro_writer_t writer, void *data)
-{
- KAA_RETURN_IF_NIL2(writer, data,);
- avro_binary_encoding.write_int(writer, *((int32_t *)data));
-}
-
-int32_t *kaa_int_deserialize(avro_reader_t reader)
-{
- KAA_RETURN_IF_NIL(reader, NULL);
-
- int32_t *data = (int32_t *)KAA_MALLOC(sizeof(int32_t));
- KAA_RETURN_IF_NIL(data, NULL);
- avro_binary_encoding.read_int(reader, data);
- return data;
-}
-
-size_t kaa_int_get_size(void *data)
-{
- KAA_RETURN_IF_NIL(data, 0);
- return avro_long_get_size(*((int32_t *)data));
-}
-
-void kaa_long_serialize(avro_writer_t writer, void *data)
-{
- KAA_RETURN_IF_NIL2(writer, data,);
- avro_binary_encoding.write_long(writer, *((int64_t *)data));
-}
-
-int64_t *kaa_long_deserialize(avro_reader_t reader)
-{
- KAA_RETURN_IF_NIL(reader, NULL);
-
- int64_t *data = (int64_t *)KAA_MALLOC(sizeof(int64_t));
- KAA_RETURN_IF_NIL(data, NULL);
- avro_binary_encoding.read_long(reader, data);
- return data;
-}
-
-size_t kaa_long_get_size(void *data)
-{
- KAA_RETURN_IF_NIL(data, 0);
- return avro_long_get_size(*((int64_t *)data));
-}
-
-void kaa_enum_serialize(avro_writer_t writer, void *data)
-{
- KAA_RETURN_IF_NIL2(writer, data,);
- avro_binary_encoding.write_long(writer, *((int *)data));
-}
-
-int *kaa_enum_deserialize(avro_reader_t reader)
-{
- KAA_RETURN_IF_NIL(reader, NULL);
-
- int *data = (int *)KAA_MALLOC(sizeof(int));
- KAA_RETURN_IF_NIL(data, NULL);
- int64_t value;
- avro_binary_encoding.read_long(reader, &value);
- *data = value;
- return data;
-}
-
-size_t kaa_enum_get_size(void *data)
-{
- KAA_RETURN_IF_NIL(data, 0);
- return avro_long_get_size(*((int *)data));
-}
-
-void kaa_float_serialize(avro_writer_t writer, void *data)
-{
- KAA_RETURN_IF_NIL2(writer, data, );
- avro_binary_encoding.write_float(writer, *((float *)data));
-}
-
-float *kaa_float_deserialize(avro_reader_t reader)
-{
- KAA_RETURN_IF_NIL(reader, NULL);
-
- float *data = (float *)KAA_MALLOC(sizeof(float));
- KAA_RETURN_IF_NIL(data, NULL);
- avro_binary_encoding.read_float(reader, data);
- return data;
-}
-
-size_t kaa_float_get_size(void *data)
-{
- KAA_RETURN_IF_NIL(data, 0);
- return AVRO_FLOAT_SIZE;
-}
-
-void kaa_double_serialize(avro_writer_t writer, void *data)
-{
- KAA_RETURN_IF_NIL2(writer, data,);
- avro_binary_encoding.write_double(writer, *((double *)data));
-}
-
-double *kaa_double_deserialize(avro_reader_t reader)
-{
- KAA_RETURN_IF_NIL(reader, NULL);
-
- double* data = (double *)KAA_MALLOC(sizeof(double));
- KAA_RETURN_IF_NIL(data, NULL);
- avro_binary_encoding.read_double(reader, data);
- return data;
-}
-
-size_t kaa_double_get_size(void *data)
-{
- KAA_RETURN_IF_NIL(data, 0);
- return AVRO_DOUBLE_SIZE;
-}
-
-void kaa_array_serialize(avro_writer_t writer, kaa_list_t *array, serialize_fn serialize)
-{
- KAA_RETURN_IF_NIL(writer, );
-
- size_t element_count = kaa_list_get_size(array);
-
- if (element_count > 0) {
- avro_binary_encoding.write_long(writer, element_count);
- if (serialize) {
- kaa_list_node_t *it = kaa_list_begin(array);
- while (it) {
- serialize(writer, kaa_list_get_data(it));
- it = kaa_list_next(it);
- }
- }
- }
-
- avro_binary_encoding.write_long(writer, 0);
-}
-
-static void *do_deserialize(avro_reader_t reader, deserialize_fn deserialize, void *context)
-{
- if (context) {
- return ((deserialize_w_ctx_fn)deserialize)(reader, context);
- }
-
- return ((deserialize_wo_ctx_fn)deserialize)(reader);
-}
-
-static kaa_list_t *kaa_array_deserialize(avro_reader_t reader, deserialize_fn deserialize, void *context)
-{
- KAA_RETURN_IF_NIL2(reader, deserialize, NULL);
-
- kaa_list_t *array = kaa_list_create();
- KAA_RETURN_IF_NIL(array, NULL);
-
- int64_t element_count;
- avro_binary_encoding.read_long(reader, &element_count);
-
- while (element_count != 0) {
- if (element_count < 0) {
- int64_t temp;
- element_count *= (-1);
- avro_binary_encoding.read_long(reader, &temp);
- }
-
- while (element_count-- > 0) {
- kaa_list_push_back(array, do_deserialize(reader, deserialize, context));
- }
-
- avro_binary_encoding.read_long(reader, &element_count);
- }
-
- return array;
-}
-
-kaa_list_t *kaa_array_deserialize_wo_ctx(avro_reader_t reader, deserialize_wo_ctx_fn deserialize)
-{
- KAA_RETURN_IF_NIL2(reader, deserialize, NULL);
- return kaa_array_deserialize(reader, deserialize, NULL);
-}
-
-kaa_list_t *kaa_array_deserialize_w_ctx(avro_reader_t reader, deserialize_w_ctx_fn deserialize, void *context)
-{
- KAA_RETURN_IF_NIL3(reader, deserialize, context, NULL);
- return kaa_array_deserialize(reader, deserialize, context);
-}
-
-size_t kaa_array_get_size(kaa_list_t *array, get_size_fn get_size)
-{
- KAA_RETURN_IF_NIL(get_size, 0);
-
- size_t array_size = 0;
-
- if (array) {
- kaa_list_node_t *it = kaa_list_begin(array);
- while (it) {
- array_size += get_size(kaa_list_get_data(it));
- it = kaa_list_next(it);
- }
-
- array_size += avro_long_get_size(kaa_list_get_size(array));
- }
-
- array_size += avro_long_get_size(0);
-
- return array_size;
-}
-
-void kaa_null_serialize(avro_writer_t writer, void *data)
-{
- (void)writer;
- (void)data;
-}
-
-void *kaa_null_deserialize(avro_reader_t reader)
-{
- (void)reader;
- return NULL;
-}
-
-void kaa_null_destroy(void *data)
-{
- (void)data;
-}
-
-size_t kaa_null_get_size(void* data)
-{
- (void)data;
- return AVRO_NULL_SIZE;
-}
-
-void kaa_data_destroy(void *data)
-{
- KAA_RETURN_IF_NIL(data,);
- KAA_FREE(data);
-}
-
diff --git a/client/client-multi/client-c/src/kaa/kaa_common_schema.h b/client/client-multi/client-c/src/kaa/kaa_common_schema.h
deleted file mode 100644
index aaba9062c2..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_common_schema.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef KAA_COMMON_SCHEMA_H_
-#define KAA_COMMON_SCHEMA_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include
-
-#include "avro_src/avro/io.h"
-#include "collections/kaa_list.h"
-
-
-
-/*
- * Do not change neither name or value of these constants.
- */
-#define AVRO_NULL_SIZE 0
-#define AVRO_FLOAT_SIZE 4
-#define AVRO_DOUBLE_SIZE 8
-
-
-
-typedef void (*serialize_fn)(avro_writer_t writer, void *data);
-
-/**
- * @brief This is like a parent class both for @ref deserialize_wo_ctx_fn
- * and @ref deserialize_w_ctx_fn that is why it has an empty parameter list instead of using @c void.
- *
- * @note It is not expected to use it explicitly. It is used under the hood of Avro Gen C.
- *
- * It is a workaround to specify different type of a deserializer. For now there is two kinds - with and without context.
- * Now a context is used to deserialize the fixed Avro type. See @ref kaa_fixed_deserialize().
- */
-typedef void *(*deserialize_fn)();
-
-/**
- * @brief See @ref deserialize_fn.
- */
-typedef void *(*deserialize_wo_ctx_fn)(avro_reader_t reader);
-
-/**
- * @brief See @ref deserialize_fn.
- */
-typedef void *(*deserialize_w_ctx_fn)(avro_reader_t reader, void *context);
-
-typedef size_t (*get_size_fn)(void *data);
-typedef void (*destroy_fn)(void *data);
-
-
-
-typedef struct {
- uint8_t* buffer;
- int32_t size;
-
- destroy_fn destroy;
-} kaa_bytes_t;
-
-typedef struct {
- char* data;
-
- destroy_fn destroy;
-} kaa_string_t;
-
-typedef struct {
- uint8_t type;
- void *data;
-
- serialize_fn serialize;
- get_size_fn get_size;
- destroy_fn destroy;
-} kaa_union_t;
-
-
-
-kaa_string_t *kaa_string_move_create(const char *data, destroy_fn destroy);
-kaa_string_t *kaa_string_copy_create(const char *data);
-
-void kaa_string_destroy(void *data);
-void kaa_string_serialize(avro_writer_t writer, void *data);
-kaa_string_t *kaa_string_deserialize(avro_reader_t reader);
-size_t kaa_string_get_size(void *data);
-
-
-
-kaa_bytes_t *kaa_bytes_move_create(const uint8_t *data, size_t data_len, destroy_fn destroy);
-kaa_bytes_t *kaa_bytes_copy_create(const uint8_t *data, size_t data_len);
-
-void kaa_bytes_destroy(void *data);
-void kaa_bytes_serialize(avro_writer_t writer, void *data);
-kaa_bytes_t *kaa_bytes_deserialize(avro_reader_t reader);
-size_t kaa_bytes_get_size(void *data);
-
-
-
-kaa_bytes_t *kaa_fixed_move_create(const uint8_t *data, size_t data_len, destroy_fn destroy);
-kaa_bytes_t *kaa_fixed_copy_create(const uint8_t *data, size_t data_len);
-
-void kaa_fixed_destroy(void *data);
-void kaa_fixed_serialize(avro_writer_t writer, void *data);
-kaa_bytes_t *kaa_fixed_deserialize(avro_reader_t reader, void *context);
-size_t kaa_fixed_get_size(void *data);
-
-
-
-void kaa_boolean_serialize(avro_writer_t writer, void *data);
-int8_t *kaa_boolean_deserialize(avro_reader_t reader);
-size_t kaa_boolean_get_size(void *data);
-
-
-
-void kaa_int_serialize(avro_writer_t writer, void *data);
-int32_t *kaa_int_deserialize(avro_reader_t reader);
-size_t kaa_int_get_size(void *data);
-
-
-
-void kaa_long_serialize(avro_writer_t writer, void *data);
-int64_t *kaa_long_deserialize(avro_reader_t reader);
-size_t kaa_long_get_size(void *data);
-
-
-
-void kaa_enum_serialize(avro_writer_t writer, void *data);
-int *kaa_enum_deserialize(avro_reader_t reader);
-size_t kaa_enum_get_size(void *data);
-
-
-
-void kaa_float_serialize(avro_writer_t writer, void *data);
-float *kaa_float_deserialize(avro_reader_t reader);
-size_t kaa_float_get_size(void *data);
-
-
-
-void kaa_double_serialize(avro_writer_t writer, void *data);
-double *kaa_double_deserialize(avro_reader_t reader);
-size_t kaa_double_get_size(void *data);
-
-
-
-void kaa_array_serialize(avro_writer_t writer, kaa_list_t *array, serialize_fn serialize);
-kaa_list_t *kaa_array_deserialize_wo_ctx(avro_reader_t reader, deserialize_wo_ctx_fn deserialize);
-kaa_list_t *kaa_array_deserialize_w_ctx(avro_reader_t reader, deserialize_w_ctx_fn deserialize, void *deserialize_context);
-size_t kaa_array_get_size(kaa_list_t *array, get_size_fn get_size);
-
-
-
-void kaa_null_serialize(avro_writer_t writer, void *data);
-void *kaa_null_deserialize(avro_reader_t reader);
-void kaa_null_destroy(void *data);
-size_t kaa_null_get_size(void* data);
-
-void kaa_data_destroy(void *data);
-
-size_t avro_long_get_size(int64_t l);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-#endif /* KAA_COMMON_SCHEMA_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_context.h b/client/client-multi/client-c/src/kaa/kaa_context.h
deleted file mode 100644
index 05e9436735..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_context.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file kaa_context.h
- * @brief Kaa endpoint context definition
- *
- * Defines the general Kaa endpoint context.
- */
-
-#ifndef KAA_CONTEXT_H_
-#define KAA_CONTEXT_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Forward-declare
-struct kaa_status_t;
-struct kaa_platform_protocol_t;
-struct kaa_status_holder_t;
-struct kaa_bootstrap_manager_t;
-struct kaa_channel_manager_t;
-struct kaa_profile_manager_t;
-struct kaa_user_manager_t;
-struct kaa_event_manager_t;
-struct kaa_log_collector;
-struct kaa_configuration_manager;
-struct kaa_notification_manager_t;
-struct kaa_logger_t;
-struct kaa_failover_strategy_t;
-
-/**
- * General Kaa endpoint context. Contains private structures of all Kaa endpoint SDK subsystems that can be used
- * independently to perform API calls to specific subsystems.
- */
-typedef struct kaa_context_s {
- struct kaa_status_holder_t *status; /**< See @link kaa_status.h @endlink. */
- struct kaa_platform_protocol_t *platform_protocol; /**< See @link kaa_platform_protocol.h @endlink. */
- struct kaa_bootstrap_manager_t *bootstrap_manager; /**< See @link kaa_bootstrap_manager.h @endlink. */
- struct kaa_channel_manager_t *channel_manager; /**< See @link kaa_channel_manager.h @endlink. */
- struct kaa_profile_manager_t *profile_manager; /**< See @link kaa_profile.h @endlink. */
- struct kaa_user_manager_t *user_manager; /**< See @link kaa_user.h @endlink. */
- struct kaa_event_manager_t *event_manager; /**< See @link kaa_event.h @endlink. */
- struct kaa_log_collector_t *log_collector; /**< See @link kaa_logging.h @endlink. */
- struct kaa_configuration_manager_t *configuration_manager; /**< See @link kaa_configuration_manager.h @endlink. */
- struct kaa_logger_t *logger; /**< See @link kaa_log.h @endlink. */
- struct kaa_notification_manager_t *notification_manager; /**< See @link kaa_notification_manager.h @endlink. */
- struct kaa_failover_strategy_t *failover_strategy;
-} kaa_context_t;
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* KAA_CONTEXT_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_defaults.h b/client/client-multi/client-c/src/kaa/kaa_defaults.h
deleted file mode 100644
index 6685246611..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_defaults.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-# ifndef KAA_DEFAULTS_H_
-# define KAA_DEFAULTS_H_
-
-/**
- *
- * DO NOT EDIT THIS FILE. IT IS AUTO-GENERATED.
- *
- */
-
-# include "kaa_common.h"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-# define KAA_BUILD_VERSION "0.8.0-SNAPSHOT"
-# define KAA_BUILD_COMMIT_HASH "N/A"
-
-# define KAA_SDK_TOKEN "012345678901234567891234567"
-
-# define KAA_PROFILE_SCHEMA_VERSION 2
-
-# define KAA_SYNC_TIMEOUT 60000L
-
-/**
- * @brief Uses to represent transport-specific connection data to establish
- * connection to Bootstrap servers.
- *
- * @see kaa_transport_protocol_id_t
- * @see kaa_access_point_t
- */
-typedef struct {
- kaa_transport_protocol_id_t protocol_id;
- kaa_access_point_t access_point;
-} kaa_bootstrap_server_connection_data_t;
-
-# define KAA_BOOTSTRAP_ACCESS_POINT_COUNT 1
-
-static const kaa_bootstrap_server_connection_data_t KAA_BOOTSTRAP_ACCESS_POINTS[KAA_BOOTSTRAP_ACCESS_POINT_COUNT] =
-{
- {
- { 1, 2 },
- {
- 12345,
- 4,
- "ABCD"
- }
- }
-};
-
-
-
-# define KAA_CONFIGURATION_DATA_LENGTH 45
-
-static const char KAA_CONFIGURATION_DATA[KAA_CONFIGURATION_DATA_LENGTH] = { 0x34, 0x42, 0x61, 0x73, 0x69, 0x63, 0x20, 0x63, 0x6F, 0x6E, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6D, 0x61, 0x02, 0x20, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
-
-# ifdef __cplusplus
-} // extern "C"
-# endif
-
-# endif /* KAA_DEFAULTS_H_ */
-
diff --git a/client/client-multi/client-c/src/kaa/kaa_error.h b/client/client-multi/client-c/src/kaa/kaa_error.h
deleted file mode 100644
index 240424abf8..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_error.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file kaa_error.h
- * @brief Kaa error codes
- *
- * Defines @c kaa_error_t enumeration type for standard error codes used across the C Endpoint SDK.
- */
-
-#ifndef KAA_ERROR_H_
-#define KAA_ERROR_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
- KAA_ERR_NONE = 0,
-
- /* General errors */
- KAA_ERR_GENERIC = -1,
- KAA_ERR_NOMEM = -2,
- KAA_ERR_BADDATA = -3,
- KAA_ERR_BADPARAM = -4,
- KAA_ERR_READ_FAILED = -5,
- KAA_ERR_WRITE_FAILED = -6,
- KAA_ERR_NOT_FOUND = -7,
- KAA_ERR_NOT_INITIALIZED = -8,
- KAA_ERR_BAD_STATE = -9,
- KAA_ERR_INVALID_PUB_KEY = -10,
- KAA_ERR_INVALID_BUFFER_SIZE = -11,
- KAA_ERR_UNSUPPORTED = -12,
- KAA_ERR_BAD_PROTOCOL_ID = -13,
- KAA_ERR_BAD_PROTOCOL_VERSION = -14,
- KAA_ERR_INSUFFICIENT_BUFFER = -15,
- KAA_ERR_ALREADY_EXISTS = -16,
- KAA_ERR_TIMEOUT = -17,
- KAA_ERR_PROFILE_IS_NOT_SET = -18,
- /* TODO(KAA-924): temporary solution to initiate SDK stop in certian cases */
- KAA_ERR_SDK_STOP = -19,
-
- KAA_ERR_EVENT_NOT_ATTACHED = -41,
- KAA_ERR_EVENT_BAD_FQN = -42,
- KAA_ERR_EVENT_TRX_NOT_FOUND = -43,
-
- KAA_ERR_BUFFER_IS_NOT_ENOUGH = -51,
- KAA_ERR_BUFFER_INVALID_SIZE = -52,
-
- KAA_ERR_SOCKET_ERROR = -91,
- KAA_ERR_SOCKET_CONNECT_ERROR = -92,
- KAA_ERR_SOCKET_INVALID_FAMILY = -93,
-
- KAA_ERR_TCPCHANNEL_AP_RESOLVE_FAILED = -101,
- KAA_ERR_TCPCHANNEL_PARSER_INIT_FAILED = -102,
- KAA_ERR_TCPCHANNEL_PARSER_ERROR = -103,
-} kaa_error_t;
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* KAA_ERROR_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_extension.c b/client/client-multi/client-c/src/kaa/kaa_extension.c
deleted file mode 100644
index d7094a5ef6..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_extension.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_extension.h"
-
-#include
-
-#include
-
-#define EXTENSION_COUNT (sizeof(kaa_extensions)/sizeof(*kaa_extensions))
-
-#define EXTENSION_NOT_FOUND ((size_t)-1)
-
-/**
- * A list of kaa contexts.
- */
-static void *kaa_extension_contexts[EXTENSION_COUNT] = { NULL };
-
-/**
- * Return the index of extension in the kaa_extensions.
- */
-static size_t extension_id_to_idx(kaa_extension_id id)
-{
- for (size_t i = 0; i < EXTENSION_COUNT; ++i) {
- if (kaa_extensions[i]->id == id) {
- return i;
- }
- }
- return EXTENSION_NOT_FOUND;
-}
-
-const struct kaa_extension *kaa_extension_get(kaa_extension_id id)
-{
- size_t idx = extension_id_to_idx(id);
- return idx == EXTENSION_NOT_FOUND ? NULL : kaa_extensions[idx];
-}
-
-void *kaa_extension_get_context(kaa_extension_id id)
-{
- size_t idx = extension_id_to_idx(id);
- return idx == EXTENSION_NOT_FOUND ? NULL : kaa_extension_contexts[idx];
-}
-
-kaa_error_t kaa_extension_set_context(kaa_extension_id id, void *context)
-{
- size_t idx = extension_id_to_idx(id);
- if (idx == EXTENSION_NOT_FOUND) {
- return KAA_ERR_NOT_FOUND;
- }
-
- kaa_extension_contexts[idx] = context;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_extension_init_all(struct kaa_context_s *kaa_context)
-{
- kaa_error_t result = KAA_ERR_NONE;
-
- size_t i = 0;
- for (; i < EXTENSION_COUNT; ++i) {
- result = kaa_extensions[i]->init(kaa_context, &kaa_extension_contexts[i]);
- if (result != KAA_ERR_NONE) {
- break;
- }
- }
-
- if (result != KAA_ERR_NONE) {
- while (i > 0) {
- --i;
- kaa_extensions[i]->deinit(kaa_extension_contexts[i]);
- }
- }
-
- return result;
-}
-
-kaa_error_t kaa_extension_deinit_all(void)
-{
- kaa_error_t result = KAA_ERR_NONE;
-
- for (size_t i = EXTENSION_COUNT; i > 0;) {
- --i;
-
- kaa_error_t res = kaa_extensions[i]->deinit(kaa_extension_contexts[i]);
- if (res != KAA_ERR_NONE) {
- result = res;
- }
- }
-
- return result;
-}
-
-kaa_error_t kaa_extension_request_serialize(kaa_extension_id id, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *sync_needed)
-{
- size_t idx = extension_id_to_idx(id);
- if (idx == EXTENSION_NOT_FOUND) {
- return KAA_ERR_NOT_FOUND;
- }
-
- return kaa_extensions[idx]->request_serialize(kaa_extension_contexts[idx], request_id,
- buffer, size, sync_needed);
-}
-
-kaa_error_t kaa_extension_server_sync(kaa_extension_id id, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size)
-{
- size_t idx = extension_id_to_idx(id);
- if (idx == EXTENSION_NOT_FOUND) {
- return KAA_ERR_NOT_FOUND;
- }
-
- return kaa_extensions[idx]->server_sync(kaa_extension_contexts[idx], request_id,
- extension_options, buffer, size);
-}
diff --git a/client/client-multi/client-c/src/kaa/kaa_extension.h b/client/client-multi/client-c/src/kaa/kaa_extension.h
deleted file mode 100644
index 990bfb47c4..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_extension.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file
- * Extension manager. The extensions should be defined in the
- * kaa_extension_private.h. Currently that file is static but will be
- * auto-generated in the future.
- */
-#ifndef KAA_EXTENSION_H
-#define KAA_EXTENSION_H
-
-#include
-#include
-#include
-#include
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Forward-declaring kaa_context_t
-struct kaa_context_s;
-
-/**
- * An extension interface facing Kaa core.
- */
-struct kaa_extension {
- kaa_extension_id id;
-
- /**
- * Init function must initialize resource or return error code. In
- * case of error all resources should be freed.
- *
- * @param[in] kaa_context Kaa client context.
- * @param[out] context Opaque extension context.
- */
- kaa_error_t (*init)(struct kaa_context_s *kaa_context, void **context);
-
- /**
- * A reverse of init(). Must deinit all allocated resources.
- *
- * It's guaranteed to be called only once per init() call and with
- * output of init().
- *
- * @param[in] context Context returned by call to init.
- */
- kaa_error_t (*deinit)(void *context);
-
- /**
- * Serialize request.
- *
- * @note @p buffer may be @c NULL. In that case the function must
- * return the required size of the buffer in @p size.
- *
- * @param[in] context The context of the extension, as returned
- * by init().
- *
- * @param[in] request_id The id of the currently serializing request.
- *
- * @param[out] buffer Serialized request.
- *
- * @param[in,out] size Size of the buffer. The function must
- * set to the actual size used (or required).
- *
- * @param[out] sync_needed Extension must set it to @c true if
- * it requires syncing. If set to @c false,
- * the extension's buffer is ignored and not
- * synced.
- *
- * @return Error code.
- *
- * @retval KAA_ERR_BUFFER_IS_NOT_ENOUGH Should be returned if @p
- * size is smaller than needed.
- *
- * @note Error codes other than @c KAA_ERR_NONE will result in
- * abort of transaction; extension must set @p sync_needed to
- * @c false if extension has nothing to say.
- */
- kaa_error_t (*request_serialize)(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *sync_needed);
-
- /**
- * Extension's action in response to the server's sync message.
- *
- * @param[in] context The extension context, as returned by init().
- *
- * @param[in] request_id The id of the request server is responding.
- *
- * @param[in] extension_options
- * @parblock
- * Protocol-dependent options.
- *
- * @note Don't rely on it, as it may be removed in the future.
- * @endparblock
- *
- * @param[in] buffer The message.
- *
- * @param[in] size Size of the @p buffer.
- *
- * @return Error code.
- */
- kaa_error_t (*server_sync)(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size);
-};
-
-/**
- * Return extension for given extension @p id.
- *
- * @retval NULL Extension not found.
- */
-const struct kaa_extension *kaa_extension_get(kaa_extension_id id);
-
-/**
- * Return context for the given extension @p id.
- *
- * @retval NULL Extension not found.
- */
-void *kaa_extension_get_context(kaa_extension_id id);
-
-/**
- * Sets extension context to later be retrieved with
- * kaa_extension_get_context().
- *
- * @retval KAA_ERR_NONE Success.
- * @retval KAA_ERR_NOT_FOUND No extension with such id.
- */
-kaa_error_t kaa_extension_set_context(kaa_extension_id id, void *context);
-
-/**
- * Initializes all extensions. If error occurs, it deinitializes all
- * initialized extensions in reverse order and returns error.
- *
- * @return Error code.
- */
-kaa_error_t kaa_extension_init_all(struct kaa_context_s *kaa_context);
-
-/**
- * Deinitializes all extensions in reverse order.
- *
- * If any extension errored during deinitialization, error code is
- * returned.
- *
- * @warning The function doesn't check if extension was
- * initialized. Must only be called if kaa_extension_init_all()
- * succeeded before.
- *
- * @retval KAA_ERR_NONE All extensions deinitialized successfully.
- *
- * @note In case several extensions failed deinitialization it's
- * unspecified which error code is returned.
- */
-kaa_error_t kaa_extension_deinit_all(void);
-
-/**
- * A proxy for kaa_extension::request_serialize().
- *
- * @retval KAA_ERR_NOT_FOUND Extension was not found.
- */
-kaa_error_t kaa_extension_request_serialize(kaa_extension_id id, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *sync_needed);
-
-/**
- * A proxy for kaa_extension::server_sync().
- *
- * @retval KAA_ERR_NOT_FOUND Extension was not found.
- */
-kaa_error_t kaa_extension_server_sync(kaa_extension_id id, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* KAA_EXTENSION_H */
diff --git a/client/client-multi/client-c/src/kaa/kaa_extension_private.h b/client/client-multi/client-c/src/kaa/kaa_extension_private.h
deleted file mode 100644
index e9894992ad..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_extension_private.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file
- * This file defines all extensions for the current client
- * instance. Currently, this file is static but will be auto-generated
- * in the future.
- *
- * kaa_extension.c MUST use this file. That's a requirement, so we can
- * easily replace this file with auto-generated one in the future.
- *
- * @warning this file is a private part of the kaa_extension.c and
- * must only be used from that file. If you need extension instance,
- * use interface defined in the kaa_extension.h. (That is the reason
- * why the file doesn't have include guard.)
- */
-#include
-
-#include "kaa_private.h"
-
-// Meta data extension is not really an extension. It doesn't have any
-// context and its implementation is embedded in platfrom_protocol.
-
-// They will be extern, thus prefixed.
-static struct kaa_extension kaa_extension_bootstrap = {
- .id = KAA_EXTENSION_BOOTSTRAP,
- .init = kaa_extension_bootstrap_init,
- .deinit = kaa_extension_bootstrap_deinit,
- .request_serialize = kaa_extension_bootstrap_request_serialize,
- .server_sync = kaa_extension_bootstrap_server_sync,
-};
-
-#ifndef KAA_DISABLE_FEATURE_PROFILE
-static struct kaa_extension kaa_extension_profile = {
- .id = KAA_EXTENSION_PROFILE,
- .init = kaa_extension_profile_init,
- .deinit = kaa_extension_profile_deinit,
- .request_serialize = kaa_extension_profile_request_serialize,
- .server_sync = kaa_extension_profile_server_sync,
-};
-#endif
-
-#ifndef KAA_DISABLE_FEATURE_EVENTS
-static struct kaa_extension kaa_extension_event = {
- .id = KAA_EXTENSION_EVENT,
- .init = kaa_extension_event_init,
- .deinit = kaa_extension_event_deinit,
- .request_serialize = kaa_extension_event_request_serialize,
- .server_sync = kaa_extension_event_server_sync,
-};
-#endif
-
-#ifndef KAA_DISABLE_FEATURE_LOGGING
-static struct kaa_extension kaa_extension_logging = {
- .id = KAA_EXTENSION_LOGGING,
- .init = kaa_extension_logging_init,
- .deinit = kaa_extension_logging_deinit,
- .request_serialize = kaa_extension_logging_request_serialize,
- .server_sync = kaa_extension_logging_server_sync,
-};
-#endif
-
-#ifndef KAA_DISABLE_FEATURE_CONFIGURATION
-static struct kaa_extension kaa_extension_configuration = {
- .id = KAA_EXTENSION_CONFIGURATION,
- .init = kaa_extension_configuration_init,
- .deinit = kaa_extension_configuration_deinit,
- .request_serialize = kaa_extension_configuration_request_serialize,
- .server_sync = kaa_extension_configuration_server_sync,
-};
-#endif
-
-#ifndef KAA_DISABLE_FEATURE_NOTIFICATION
-static struct kaa_extension kaa_extension_notification = {
- .id = KAA_EXTENSION_NOTIFICATION,
- .init = kaa_extension_notification_init,
- .deinit = kaa_extension_notification_deinit,
- .request_serialize = kaa_extension_notification_request_serialize,
- .server_sync = kaa_extension_notification_server_sync,
-};
-#endif
-
-#ifndef KAA_DISABLE_FEATURE_USER
-static struct kaa_extension kaa_extension_user = {
- .id = KAA_EXTENSION_USER,
- .init = kaa_extension_user_init,
- .deinit = kaa_extension_user_deinit,
- .request_serialize = kaa_extension_user_request_serialize,
- .server_sync = kaa_extension_user_server_sync,
-};
-#endif
-
-// I'm not sure in what order they should be, so just kept order from
-// kaa_context_init().
-static const struct kaa_extension *kaa_extensions[] = {
- &kaa_extension_bootstrap,
-
-#ifndef KAA_DISABLE_FEATURE_PROFILE
- &kaa_extension_profile,
-#endif
-
-#ifndef KAA_DISABLE_FEATURE_EVENTS
- &kaa_extension_event,
-#endif
-
-#ifndef KAA_DISABLE_FEATURE_LOGGING
- &kaa_extension_logging,
-#endif
-
-#ifndef KAA_DISABLE_FEATURE_CONFIGURATION
- &kaa_extension_configuration,
-#endif
-
-#ifndef KAA_DISABLE_FEATURE_NOTIFICATION
- &kaa_extension_notification,
-#endif
-
-#ifndef KAA_DISABLE_FEATURE_USER
- &kaa_extension_user,
-#endif
-};
diff --git a/client/client-multi/client-c/src/kaa/kaa_platform_common.h b/client/client-multi/client-c/src/kaa/kaa_platform_common.h
deleted file mode 100644
index fd2d277b0f..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_platform_common.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef KAA_PLATFORM_COMMON_H_
-#define KAA_PLATFORM_COMMON_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define KAA_PLATFORM_PROTOCOL_VERSION 1
-#define KAA_PLATFORM_PROTOCOL_ID 0x3553c66f
-
-#define KAA_ALIGNMENT 4
-
-/*
- * All definitions related to a field size specify in bytes.
- */
-#define KAA_PROTOCOL_ID_SIZE 4
-#define KAA_PROTOCOL_VERSION_SIZE 2
-#define KAA_PROTOCOL_EXTENSIONS_COUNT_SIZE 2
-#define KAA_PROTOCOL_MESSAGE_HEADER_SIZE (KAA_PROTOCOL_ID_SIZE + KAA_PROTOCOL_VERSION_SIZE + KAA_PROTOCOL_EXTENSIONS_COUNT_SIZE)
-
-#define KAA_EXTENSION_TYPE_SIZE 2
-#define KAA_EXTENSION_OPTIONS_SIZE 2
-#define KAA_EXTENSION_PAYLOAD_LENGTH_SIZE 4
-#define KAA_EXTENSION_HEADER_SIZE (KAA_EXTENSION_TYPE_SIZE + KAA_EXTENSION_OPTIONS_SIZE + KAA_EXTENSION_PAYLOAD_LENGTH_SIZE)
-
-
-#define KAA_SDK_TOKEN_LENGTH 27
-
-/**
- * Constants used for a meta data extension.
- */
-typedef enum {
- TIMEOUT_VALUE = 0x1,
- PUBLIC_KEY_HASH_VALUE = 0x2,
- PROFILE_HASH_VALUE = 0x4,
- APP_TOKEN_VALUE = 0x8
-} kaa_meta_data_extension_options_t;
-
-/**
- * Constants used for a profile extension.
- */
-typedef enum {
- CONFIG_SCHEMA_VERSION_VALUE = 0x0,
- PROFILE_SCHEMA_VERSION_VALUE = 0x1,
- SYS_NF_VERSION_VALUE = 0x2,
- USER_NF_VERSION_VALUE = 0x3,
- LOG_SCHEMA_VERSION_VALUE = 0x4,
- EVENT_FAMILY_VERSIONS_COUNT_VALUE = 0x5,
- PUB_KEY_VALUE = 0x6,
- ACCESS_TOKEN_VALUE = 0x7
-} kaa_profile_extension_options_t;
-
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* SRC_KAA_PLATFORM_COMMON_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_platform_protocol.c b/client/client-multi/client-c/src/kaa/kaa_platform_protocol.c
deleted file mode 100644
index a789f77d9d..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_platform_protocol.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_private.h"
-
-#include
-#include
-#include
-#include "platform/stdio.h"
-#include "platform/ext_sha.h"
-#include "platform/sock.h"
-#include "kaa_status.h"
-#include "kaa_platform_protocol.h"
-#include "utilities/kaa_mem.h"
-#include "utilities/kaa_log.h"
-#include "kaa_defaults.h"
-
-#include "kaa_platform_common.h"
-#include "kaa_platform_utils.h"
-
-#include
-
-#ifndef KAA_DISABLE_FEATURE_PROFILE
-#include "kaa_profile_private.h"
-#endif
-
-/** Resync flag indicating that profile manager should be resynced */
-#define KAA_PROFILE_RESYNC_FLAG 0x1
-
-static const size_t kaa_meta_data_request_size =
- KAA_EXTENSION_HEADER_SIZE +
- sizeof(uint32_t) +
- sizeof(uint32_t) +
- KAA_ALIGNED_SIZE(SHA_1_DIGEST_LENGTH) +
- KAA_ALIGNED_SIZE(SHA_1_DIGEST_LENGTH) +
- KAA_ALIGNED_SIZE(KAA_SDK_TOKEN_LENGTH);
-
-struct kaa_platform_protocol_t
-{
- kaa_status_t *status;
- kaa_logger_t *logger;
- uint32_t request_id;
-};
-
-/**
- * That's a function that aids transition to the new interface. Its
- * usages should be removed.
- */
-static kaa_error_t get_extension_request_size(kaa_extension_id id, size_t *size);
-
-kaa_error_t kaa_meta_data_request_serialize(kaa_platform_protocol_t *self,
- kaa_platform_message_writer_t *writer, uint32_t request_id)
-{
- // TODO(KAA-982): Use assert here
- if (!self || !self->status || !writer) {
- return KAA_ERR_BADPARAM;
- }
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Going to serialize client meta sync");
-
- uint16_t options = TIMEOUT_VALUE | PUBLIC_KEY_HASH_VALUE | PROFILE_HASH_VALUE | APP_TOKEN_VALUE;
-
- const size_t payload_length = kaa_meta_data_request_size - KAA_EXTENSION_HEADER_SIZE;
-
- kaa_error_t err_code = kaa_platform_message_write_extension_header(writer,
- KAA_EXTENSION_META_DATA, options, payload_length);
- if (err_code) {
- return err_code;
- }
-
- uint32_t request_id_network = KAA_HTONL(request_id);
- err_code = kaa_platform_message_write(writer, &request_id_network, sizeof(uint32_t));
- if (err_code) {
- return err_code;
- }
-
- uint32_t timeout = KAA_HTONL(KAA_SYNC_TIMEOUT);
- err_code = kaa_platform_message_write(writer, &timeout, sizeof(timeout));
- if (err_code) {
- return err_code;
- }
-
- err_code = kaa_platform_message_write_aligned(writer,
- self->status->endpoint_public_key_hash, SHA_1_DIGEST_LENGTH);
- if (err_code) {
- return err_code;
- }
-
- err_code = kaa_platform_message_write_aligned(writer,
- self->status->profile_hash, SHA_1_DIGEST_LENGTH);
- if (err_code) {
- return err_code;
- }
-
- err_code = kaa_platform_message_write_aligned(writer, KAA_SDK_TOKEN, KAA_SDK_TOKEN_LENGTH);
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE,
- "Meta sync: payload length '%u', request id '%u'", payload_length, request_id);
-
- return err_code;
-}
-
-kaa_error_t kaa_platform_protocol_create(kaa_platform_protocol_t **platform_protocol_p,
- kaa_logger_t *logger, kaa_status_t *status)
-{
- if (!platform_protocol_p || !logger || !status) {
- return KAA_ERR_BADPARAM;
- }
-
- *platform_protocol_p = KAA_MALLOC(sizeof(**platform_protocol_p));
- if (!*platform_protocol_p) {
- return KAA_ERR_NOMEM;
- }
-
- **platform_protocol_p = (kaa_platform_protocol_t){
- .request_id = 0,
- .status = status,
- .logger = logger,
- };
-
- return KAA_ERR_NONE;
-}
-
-void kaa_platform_protocol_destroy(kaa_platform_protocol_t *self)
-{
- KAA_FREE(self);
-}
-
-static kaa_error_t kaa_client_sync_get_size(kaa_platform_protocol_t *self,
- const kaa_extension_id *extensions,
- const size_t extension_count,
- size_t *expected_size)
-{
- // TODO(KAA-982): Use assert here
- if (!self || !extensions || !expected_size || extension_count == 0) {
- return KAA_ERR_BADPARAM;
- }
-
- *expected_size = KAA_PROTOCOL_MESSAGE_HEADER_SIZE + kaa_meta_data_request_size;
-
- for (size_t i = 0; i < extension_count; ++i) {
- size_t extension_size = 0;
-
- kaa_error_t error = get_extension_request_size(extensions[i], &extension_size);
- if (error && error != KAA_ERR_NOT_FOUND) {
- KAA_LOG_ERROR(self->logger, error,
- "Failed to query extension size for %u", extensions[i]);
- return error;
- }
-
- *expected_size += extension_size;
- }
-
- return KAA_ERR_NONE;
-}
-
-static kaa_error_t kaa_client_sync_serialize(kaa_platform_protocol_t *self,
- const kaa_extension_id services[], size_t services_count, uint8_t *buffer, size_t *size)
-{
- kaa_platform_message_writer_t writer = KAA_MESSAGE_WRITER(buffer, *size);
-
- uint16_t total_services_count = services_count + 1 /* Meta extension */;
-
- kaa_error_t error_code = kaa_platform_message_header_write(&writer,
- KAA_PLATFORM_PROTOCOL_ID, KAA_PLATFORM_PROTOCOL_VERSION);
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to write the client sync header");
- goto fail;
- }
-
- uint16_t *extension_count_p = (uint16_t *)writer.current;
- writer.current += KAA_PROTOCOL_EXTENSIONS_COUNT_SIZE;
- // TODO: static assert KAA_PROTOCOL_EXTENSIONS_COUNT_SIZE == sizeof(uint16_t)
-
- error_code = kaa_meta_data_request_serialize(self, &writer, self->request_id);
- if (error_code) {
- goto fail;
- }
-
- while (!error_code && services_count--) {
- size_t size_required = writer.end - writer.current;
- bool need_resync = false;
- error_code = kaa_extension_request_serialize(services[services_count],
- self->request_id, writer.current, &size_required, &need_resync);
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code,
- "Failed to serialize the '%d' extension", services[services_count]);
- continue;
- }
-
- if (!need_resync) {
- --total_services_count;
- continue;
- }
-
- writer.current += size_required;
- }
-
- *extension_count_p = KAA_HTONS(total_services_count);
- *size = writer.current - writer.begin;
-
-fail:
- return error_code;
-}
-
-kaa_error_t kaa_platform_protocol_serialize_client_sync(kaa_platform_protocol_t *self,
- const kaa_extension_id *services, size_t services_count,
- uint8_t *buffer, size_t *buffer_size)
-{
- if (!self || !buffer_size) {
- return KAA_ERR_BADPARAM;
- }
-
- if (!services || services_count == 0) {
- return KAA_ERR_BADDATA;
- }
-
- size_t required_buffer_size = 0;
- kaa_error_t error = kaa_client_sync_get_size(self, services, services_count,
- &required_buffer_size);
- if (error) {
- KAA_LOG_ERROR(self->logger, error, "Failed to get required buffer size");
- return error;
- }
-
- if (*buffer_size < required_buffer_size || !buffer) {
- *buffer_size = required_buffer_size;
- return KAA_ERR_BUFFER_IS_NOT_ENOUGH;
- }
- *buffer_size = required_buffer_size;
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Serializing client sync...");
-
- self->request_id++;
- error = kaa_client_sync_serialize(self, services, services_count, buffer, buffer_size);
- if (error) {
- self->request_id--;
- return error;
- }
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE,
- "Client sync serialized: request id '%u', payload size '%zu'",
- self->request_id, *buffer_size);
-
- return KAA_ERR_NONE;
-}
-
-// TODO(KAA-1089): Remove weak linkage
-__attribute__((weak))
-kaa_error_t kaa_platform_protocol_process_server_sync(kaa_platform_protocol_t *self,
- const uint8_t *buffer, size_t buffer_size)
-{
- if (!self || !buffer || buffer_size == 0) {
- return KAA_ERR_BADPARAM;
- }
-
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE,
- "Server sync received: payload size '%zu'", buffer_size);
-
- kaa_platform_message_reader_t reader = KAA_MESSAGE_READER(buffer, buffer_size);
-
- uint32_t protocol_id = 0;
- uint16_t protocol_version = 0;
- uint16_t extension_count = 0;
-
- kaa_error_t error_code = kaa_platform_message_header_read(&reader,
- &protocol_id, &protocol_version, &extension_count);
- if (error_code) {
- goto fail;
- }
-
- if (protocol_id != KAA_PLATFORM_PROTOCOL_ID) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_BAD_PROTOCOL_ID,
- "Unsupported protocol ID %x", protocol_id);
- error_code = KAA_ERR_BAD_PROTOCOL_ID;
- goto fail;
- }
-
- if (protocol_version != KAA_PLATFORM_PROTOCOL_VERSION) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_BAD_PROTOCOL_VERSION,
- "Unsupported protocol version %u", protocol_version);
- error_code = KAA_ERR_BAD_PROTOCOL_VERSION;
- goto fail;
- }
-
- uint32_t request_id = 0;
-
- while (kaa_platform_message_is_buffer_large_enough(&reader, KAA_PROTOCOL_MESSAGE_HEADER_SIZE)) {
-
- uint16_t extension_type;
- uint16_t extension_options;
- uint32_t extension_length;
- error_code = kaa_platform_message_read_extension_header(&reader, &extension_type,
- &extension_options, &extension_length);
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to read extension header");
- goto fail;
- }
-
- /* Do not resync unless it is requested by the metadata extension */
-
- // TODO: must profile_needs_resync be set inside of the loop?
- self->status->profile_needs_resync = false;
-
- if (extension_type == KAA_EXTENSION_META_DATA) {
- error_code = kaa_platform_message_read(&reader, &request_id, sizeof(request_id));
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to read meta data (request_id)");
- goto fail;
- }
-
- request_id = KAA_NTOHL(request_id);
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Server sync request id %u", request_id);
-
- /* Check if managers needs resync */
-
- uint32_t resync_request;
- error_code = kaa_platform_message_read(&reader,
- &resync_request, sizeof(resync_request));
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to read meta data (resync_request)");
- goto fail;
- }
-
- resync_request = KAA_NTOHL(resync_request);
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE,
- "Server resync request %u", resync_request);
-
- if (resync_request & KAA_PROFILE_RESYNC_FLAG) {
- KAA_LOG_INFO(self->logger, KAA_ERR_NONE, "Profile resync is requested");
- self->status->profile_needs_resync = true;
-
-#ifndef KAA_DISABLE_FEATURE_PROFILE
- void *profile_ctx = kaa_extension_get_context(KAA_EXTENSION_PROFILE);
- if (!profile_ctx) {
- error_code = KAA_ERR_NOT_FOUND;
- KAA_LOG_ERROR(self->logger, error_code,
- "Profile extension is not found. Force resync can't be done");
- goto fail;
- }
-
- error_code = kaa_profile_force_sync(profile_ctx);
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to force-sync profile");
- goto fail;
- }
-#endif
- }
- } else {
- error_code = kaa_extension_server_sync(extension_type, request_id,
- extension_options, reader.current, extension_length);
- reader.current += extension_length;
-
- if (error_code == KAA_ERR_NOT_FOUND) {
- KAA_LOG_WARN(self->logger, KAA_ERR_UNSUPPORTED,
- "Unsupported extension received (type = %u)", extension_type);
- error_code = KAA_ERR_NONE;
- } else if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code,
- "Server sync is corrupted. Failed to read extension with type %u",
- extension_type);
- goto fail;
- }
- }
- }
-
- error_code = kaa_status_save(self->status);
- if (error_code) {
- KAA_LOG_ERROR(self->logger, error_code, "Failed to save status");
- goto fail;
- }
-
- KAA_LOG_TRACE(self->logger, KAA_ERR_NONE, "Server sync successfully processed");
-
-fail:
- return error_code;
-}
-
-// TODO(KAA-1089): Remove weak linkage
-__attribute__((weak))
-kaa_error_t kaa_platform_protocol_alloc_serialize_client_sync(kaa_platform_protocol_t *self,
- const kaa_extension_id *services, size_t services_count,
- uint8_t **buffer, size_t *buffer_size)
-{
- if (!self || !buffer || !buffer_size) {
- return KAA_ERR_BADPARAM;
- }
-
- if (!services || services_count == 0) {
- return KAA_ERR_BADDATA;
- }
-
- *buffer_size = 0;
- kaa_error_t error = kaa_platform_protocol_serialize_client_sync(self, services, services_count,
- NULL, buffer_size);
- // TODO(982): assert error != KAA_ERR_NONE
- if (error != KAA_ERR_BUFFER_IS_NOT_ENOUGH) {
- return error;
- }
-
- *buffer = KAA_MALLOC(*buffer_size);
- if (!*buffer) {
- KAA_LOG_ERROR(self->logger, KAA_ERR_NOMEM, "No memory for buffer");
- return KAA_ERR_NOMEM;
- }
-
- return kaa_platform_protocol_serialize_client_sync(self, services, services_count,
- *buffer, buffer_size);
-}
-
-static kaa_error_t get_extension_request_size(kaa_extension_id id, size_t *size)
-{
- bool need_resync;
- kaa_error_t error = kaa_extension_request_serialize(id, 0, NULL, size, &need_resync);
- if (error == KAA_ERR_BUFFER_IS_NOT_ENOUGH) {
- error = KAA_ERR_NONE;
- }
-
- if (!need_resync) {
- *size = 0;
- }
-
- return error;
-}
diff --git a/client/client-multi/client-c/src/kaa/kaa_platform_protocol.h b/client/client-multi/client-c/src/kaa/kaa_platform_protocol.h
deleted file mode 100644
index fd672e6ccb..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_platform_protocol.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file kaa_platform_protocol.h
- * @brief Kaa binary platform level protocol implementation
- * (org.kaaproject.protocol.platform.binary ).
- *
- * Supplies API for serializing client and server sync messages.
- */
-
-#ifndef KAA_PLATFORM_PROTOCOL_H_
-#define KAA_PLATFORM_PROTOCOL_H_
-
-#include
-#include
-
-#include "kaa_error.h"
-#include "kaa_context.h"
-#include "kaa_common.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef KAA_PLATFORM_PRTOCOL_T
-#define KAA_PLATFORM_PRTOCOL_T
-/**
- * Kaa platform protocol state structure
- */
-typedef struct kaa_platform_protocol_t kaa_platform_protocol_t;
-#endif
-
-/**
- * Serialize info structure
- */
-typedef struct {
- kaa_extension_id *services; /**< Non-empty list of services to include into the sync message */
- size_t services_count; /**< Number of elements in @c services */
-} kaa_serialize_info_t;
-
-/**
- * @brief Constructs a sync request for the specified list of services
- * based on the current state of Kaa context and serializes it into
- * the buffer.
- *
- * If buffer size is not enough, @c KAA_ERR_BUFFER_IS_NOT_ENOUGH is
- * returned. You should reallocate buffer and repeat the call.
- *
- * @param[in] self Pointer to a @ref kaa_platform_protocol_t instance.
- * @param[in] services A list of services to serialize.
- * @param[in] services_count A number of @c services.
- * @param[out] buffer The buffer with serialized data.
- * @param[out] buffer_size The buffer's actual size.
- *
- * @return Error code.
- *
- * @retval KAA_ERR_BUFFER_IS_NOT_ENOUGH The buffer size is not
- * enough. In that case, @p buffer_size is updated to the required
- * buffer size.
- */
-kaa_error_t kaa_platform_protocol_serialize_client_sync(kaa_platform_protocol_t *self,
- const kaa_extension_id *services, size_t services_count,
- uint8_t *buffer, size_t *buffer_size);
-
-/**
- * Allocates the buffer of the needed size and calls
- * kaa_platform_protocol_serialize_client_sync().
- *
- * @note The caller must deallocate the buffer.
- *
- * @deprecated You should maintain buffer yourself and call
- * kaa_platform_protocol_serialize_client_sync() directly. The
- * function is defined as a transition to the new approach.
- */
-kaa_error_t kaa_platform_protocol_alloc_serialize_client_sync(kaa_platform_protocol_t *self,
- const kaa_extension_id *services, size_t services_count,
- uint8_t **buffer, size_t *buffer_size);
-
-/**
- * @brief Processes downstream data received from Operations server.
- *
- * @param[in] self Pointer to a @ref kaa_platform_protocol_t instance.
- * @param[in] buffer Pointer to a data buffer for processing received from server.
- * @param[in] buffer_size Size of @c buffer.
- *
- * @return Error code.
- */
-kaa_error_t kaa_platform_protocol_process_server_sync(kaa_platform_protocol_t *self,
- const uint8_t *buffer, size_t buffer_size);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* KAA_PLATFORM_PROTOCOL_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_platform_utils.c b/client/client-multi/client-c/src/kaa/kaa_platform_utils.c
deleted file mode 100644
index fc5735b66b..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_platform_utils.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_private.h"
-
-#include
-#include
-#include "platform/sock.h"
-#include
-#include "kaa_platform_utils.h"
-
-#include "kaa_common.h"
-#include "utilities/kaa_mem.h"
-
-kaa_error_t kaa_platform_message_writer_create(kaa_platform_message_writer_t** writer_p
- , uint8_t *buf
- , size_t len)
-{
- KAA_RETURN_IF_NIL3(writer_p, buf, len, KAA_ERR_BADPARAM);
-
- *writer_p = (kaa_platform_message_writer_t*)KAA_MALLOC(sizeof(kaa_platform_message_writer_t));
- KAA_RETURN_IF_NIL(*writer_p, KAA_ERR_NOMEM);
-
- (*writer_p)->begin = buf;
- (*writer_p)->end = buf + len;
- (*writer_p)->current = buf;
-
- return KAA_ERR_NONE;
-}
-
-
-
-void kaa_platform_message_writer_destroy(kaa_platform_message_writer_t* writer)
-{
- if (writer) {
- KAA_FREE(writer);
- }
-}
-
-
-
-kaa_error_t kaa_platform_message_write(kaa_platform_message_writer_t* writer
- , const void *data
- , size_t data_size)
-{
- KAA_RETURN_IF_NIL3(writer, data, data_size, KAA_ERR_BADPARAM);
-
- if ((writer->current + data_size) <= writer->end) {
- memcpy((void *)writer->current, data, data_size);
- writer->current += data_size;
- return KAA_ERR_NONE;
- }
-
- return KAA_ERR_WRITE_FAILED;
-}
-
-
-
-kaa_error_t kaa_platform_message_write_alignment(kaa_platform_message_writer_t* writer)
-{
- KAA_RETURN_IF_NIL(writer, KAA_ERR_BADPARAM);
-
- size_t alignment_size = (KAA_ALIGNMENT - ((writer->current - writer->begin) % KAA_ALIGNMENT)) % KAA_ALIGNMENT;
- if (!alignment_size)
- return KAA_ERR_NONE;
-
- if (writer->current + alignment_size <= writer->end) {
- memset((void *)writer->current, 0, alignment_size);
- writer->current += alignment_size;
- return KAA_ERR_NONE;
- }
-
- return KAA_ERR_WRITE_FAILED;
-}
-
-
-kaa_error_t kaa_platform_message_write_aligned(kaa_platform_message_writer_t* writer
- , const void *data
- , size_t data_size)
-{
- KAA_RETURN_IF_NIL3(writer, data, data_size, KAA_ERR_BADPARAM);
-
- size_t aligned_size = kaa_aligned_size_get(data_size);
-
- if ((writer->current + aligned_size) <= writer->end) {
- memcpy((void *)writer->current, data, data_size);
- memset((void *)(writer->current + data_size), 0, (aligned_size - data_size));
- writer->current += aligned_size;
- return KAA_ERR_NONE;
- }
-
- return KAA_ERR_WRITE_FAILED;
-}
-
-
-kaa_error_t kaa_platform_message_header_write(kaa_platform_message_writer_t* writer
- , uint32_t protocol_id
- , uint16_t protocol_version)
-{
- KAA_RETURN_IF_NIL(writer, KAA_ERR_BADPARAM);
-
- if ((writer->current + KAA_PROTOCOL_ID_SIZE + KAA_PROTOCOL_VERSION_SIZE) <= writer->end) {
- *(uint32_t *) writer->current = KAA_HTONL(protocol_id);
- writer->current += KAA_PROTOCOL_ID_SIZE;
- *(uint16_t *) writer->current = KAA_HTONS(protocol_version);
- writer->current += KAA_PROTOCOL_VERSION_SIZE;
- return KAA_ERR_NONE;
- }
-
- return KAA_ERR_WRITE_FAILED;
-}
-
-kaa_error_t kaa_platform_message_write_extension_header(kaa_platform_message_writer_t* writer
- , uint16_t extension_type
- , uint16_t options
- , uint32_t payload_size)
-{
- KAA_RETURN_IF_NIL(writer, KAA_ERR_BADPARAM);
-
- if ((writer->current + KAA_EXTENSION_HEADER_SIZE) <= writer->end) {
- extension_type = KAA_HTONS(extension_type);
- options = KAA_HTONS(options);
- payload_size = KAA_HTONL(payload_size);
-
- memcpy((void *)writer->current, &extension_type, KAA_EXTENSION_TYPE_SIZE);
- writer->current += KAA_EXTENSION_TYPE_SIZE;
- memcpy((void *)writer->current, &options, KAA_EXTENSION_OPTIONS_SIZE);
- writer->current += KAA_EXTENSION_OPTIONS_SIZE;
- memcpy((void *)writer->current, &payload_size, KAA_EXTENSION_PAYLOAD_LENGTH_SIZE);
- writer->current += KAA_EXTENSION_PAYLOAD_LENGTH_SIZE;
-
- return KAA_ERR_NONE;
- }
-
- return KAA_ERR_WRITE_FAILED;
-}
-
-kaa_error_t kaa_platform_message_reader_create(kaa_platform_message_reader_t **reader_p
- , const uint8_t *buffer
- , size_t len)
-{
- KAA_RETURN_IF_NIL3(reader_p, buffer, len, KAA_ERR_BADPARAM);
-
- *reader_p = (kaa_platform_message_reader_t *) KAA_MALLOC(sizeof(kaa_platform_message_reader_t));
- KAA_RETURN_IF_NIL(*reader_p, KAA_ERR_NOMEM);
-
- (*reader_p)->begin = buffer;
- (*reader_p)->current = buffer;
- (*reader_p)->end = buffer + len;
-
- return KAA_ERR_NONE;
-}
-
-void kaa_platform_message_reader_destroy(kaa_platform_message_reader_t *reader)
-{
- if (reader) {
- KAA_FREE(reader);
- }
-}
-
-kaa_error_t kaa_platform_message_read(kaa_platform_message_reader_t *reader, void *buffer, size_t expected_size)
-{
- KAA_RETURN_IF_NIL3(reader, buffer, expected_size, KAA_ERR_BADPARAM);
- if (reader->current + expected_size <= reader->end) {
- memcpy(buffer, reader->current, expected_size);
- reader->current += expected_size;
- return KAA_ERR_NONE;
- }
- return KAA_ERR_READ_FAILED;
-}
-
-kaa_error_t kaa_platform_message_read_aligned(kaa_platform_message_reader_t *reader
- , void *buffer
- , size_t expected_size)
-{
- KAA_RETURN_IF_NIL3(reader, buffer, expected_size, KAA_ERR_BADPARAM);
- size_t aligned_size = kaa_aligned_size_get(expected_size);
- if (reader->current + aligned_size <= reader->end) {
- memcpy(buffer, reader->current, expected_size);
- reader->current += aligned_size;
- return KAA_ERR_NONE;
- }
- return KAA_ERR_READ_FAILED;
-}
-
-
-
-kaa_error_t kaa_platform_message_header_read(kaa_platform_message_reader_t* reader
- , uint32_t *protocol_id
- , uint16_t *protocol_version
- , uint16_t *extension_count)
-{
- KAA_RETURN_IF_NIL4(reader, protocol_id, protocol_version, extension_count, KAA_ERR_BADPARAM);
-
- if (reader->current + KAA_PROTOCOL_MESSAGE_HEADER_SIZE <= reader->end) {
- *protocol_id = KAA_NTOHL(*((const uint32_t *)reader->current));
- reader->current += sizeof(uint32_t);
- *protocol_version = KAA_NTOHS(*((const uint16_t *)reader->current));
- reader->current += sizeof(uint16_t);
- *extension_count = KAA_NTOHS(*((const uint16_t *)reader->current));
- reader->current += sizeof(uint16_t);
- return KAA_ERR_NONE;
- }
-
- return KAA_ERR_READ_FAILED;
-}
-
-
-
-kaa_error_t kaa_platform_message_read_extension_header(kaa_platform_message_reader_t *reader
- , uint16_t *extension_type
- , uint16_t *extension_options
- , uint32_t *extension_payload_length)
-{
- KAA_RETURN_IF_NIL4(reader, extension_type, extension_options, extension_payload_length, KAA_ERR_BADPARAM);
-
- if (reader->current + KAA_EXTENSION_HEADER_SIZE <= reader->end) {
- memcpy(extension_type, reader->current, KAA_EXTENSION_OPTIONS_SIZE);
- *extension_type = KAA_NTOHS(*extension_type);
- reader->current += KAA_EXTENSION_TYPE_SIZE;
- memcpy(extension_options, reader->current, KAA_EXTENSION_OPTIONS_SIZE);
- *extension_options = KAA_NTOHS(*extension_options);
- reader->current += KAA_EXTENSION_OPTIONS_SIZE;
- *extension_payload_length = KAA_NTOHL(*((const uint32_t *)reader->current));
- reader->current += KAA_EXTENSION_PAYLOAD_LENGTH_SIZE;
- return KAA_ERR_NONE;
- }
-
- return KAA_ERR_READ_FAILED;
-}
-
-bool kaa_platform_message_is_buffer_large_enough(kaa_platform_message_reader_t *reader
- , size_t size)
-{
- if (!reader) {
- return false;
- }
-
- if (!size) {
- return true;
- }
-
- return (reader->current + size <= reader->end);
-}
-
-kaa_error_t kaa_platform_message_skip(kaa_platform_message_reader_t *reader, size_t size)
-{
- KAA_RETURN_IF_NIL2(reader, size, KAA_ERR_BADPARAM);
-
- if (reader->current + size <= reader->end) {
- reader->current += size;
- return KAA_ERR_NONE;
- }
-
- return KAA_ERR_READ_FAILED;
-}
diff --git a/client/client-multi/client-c/src/kaa/kaa_platform_utils.h b/client/client-multi/client-c/src/kaa/kaa_platform_utils.h
deleted file mode 100644
index 7caa177e40..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_platform_utils.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef KAA_PLATFORM_UTILS_H_
-#define KAA_PLATFORM_UTILS_H_
-
-#include
-#include
-#include
-
-#include "kaa_error.h"
-#include "kaa_platform_common.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-typedef struct {
- uint8_t *begin;
- uint8_t *current;
- uint8_t *end;
-} kaa_platform_message_writer_t;
-
-
-typedef struct {
- const uint8_t *begin;
- const uint8_t *current;
- const uint8_t *end;
-} kaa_platform_message_reader_t;
-
-#define KAA_MESSAGE_WRITER(buffer, len) \
- (kaa_platform_message_writer_t){ (buffer), (buffer), (buffer) + (len) }
-
-#define KAA_MESSAGE_READER(buffer, len) \
- (kaa_platform_message_reader_t){ (buffer), (buffer), (buffer) + (len) }
-
-/**
- * @deprecated Use @ref KAA_MESSAGE_WRITER instead -- it doesn't allocate memory.
- */
-kaa_error_t kaa_platform_message_writer_create(kaa_platform_message_writer_t** writer_p,
- uint8_t *buf, size_t len);
-
-void kaa_platform_message_writer_destroy(kaa_platform_message_writer_t* writer);
-
-kaa_error_t kaa_platform_message_write(kaa_platform_message_writer_t* writer
- , const void *data
- , size_t data_size);
-
-kaa_error_t kaa_platform_message_write_alignment(kaa_platform_message_writer_t* writer);
-
-kaa_error_t kaa_platform_message_write_aligned(kaa_platform_message_writer_t* writer
- , const void *data
- , size_t data_size);
-
-kaa_error_t kaa_platform_message_header_write(kaa_platform_message_writer_t* writer
- , uint32_t protocol_id
- , uint16_t protocol_version);
-
-kaa_error_t kaa_platform_message_write_extension_header(kaa_platform_message_writer_t* writer
- , uint16_t extension_type
- , uint16_t options
- , uint32_t payload_size);
-
-
-
-/**
- * @deprecated Use @ref KAA_MESSAGE_READER instead -- it doesn't allocate memory.
- */
-kaa_error_t kaa_platform_message_reader_create(kaa_platform_message_reader_t **reader_p
- , const uint8_t *buffer
- , size_t len);
-
-void kaa_platform_message_reader_destroy(kaa_platform_message_reader_t *reader);
-
-kaa_error_t kaa_platform_message_read(kaa_platform_message_reader_t *reader
- , void *buffer
- , size_t expected_size);
-
-kaa_error_t kaa_platform_message_read_aligned(kaa_platform_message_reader_t *reader
- , void *buffer
- , size_t expected_size);
-
-kaa_error_t kaa_platform_message_header_read(kaa_platform_message_reader_t* reader
- , uint32_t *protocol_id
- , uint16_t *protocol_version
- , uint16_t *extension_count);
-
-kaa_error_t kaa_platform_message_read_extension_header(kaa_platform_message_reader_t *reader
- , uint16_t *extension_type
- , uint16_t *extension_options
- , uint32_t *extension_payload_length);
-
-bool kaa_platform_message_is_buffer_large_enough(kaa_platform_message_reader_t *reader
- , size_t size);
-
-kaa_error_t kaa_platform_message_skip(kaa_platform_message_reader_t *reader, size_t size);
-
-#define KAA_ALIGNED_SIZE(s) ((s) + (KAA_ALIGNMENT - (s) % KAA_ALIGNMENT) % KAA_ALIGNMENT)
-
-static inline size_t kaa_aligned_size_get(size_t size)
-{
- return (size + (KAA_ALIGNMENT - (size % KAA_ALIGNMENT)) % KAA_ALIGNMENT);
-}
-
-#define KAA_STATIC_ASSERT(name, expr) \
- static char static_assertion_##name[expr] __attribute__((unused))
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* KAA_PLATFORM_UTILS_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_private.h b/client/client-multi/client-c/src/kaa/kaa_private.h
deleted file mode 100644
index 39891d647e..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_private.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** @file
- * This file is a container for all private APIs. That's a temporary
- * measure---a safety net for refactoring. The header is included in
- * every C file, so compiler will catch any interface changes.
- *
- * The header will be deleted later.
- */
-#ifndef KAA_PRIVATE_H
-#define KAA_PRIVATE_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-kaa_error_t kaa_status_create(kaa_status_t **kaa_status_p);
-kaa_error_t kaa_status_save(kaa_status_t *kaa_status_p);
-void kaa_status_destroy(kaa_status_t *self);
-
-kaa_error_t kaa_channel_manager_create(kaa_channel_manager_t **channel_manager_p, kaa_context_t *context);
-void kaa_channel_manager_destroy(kaa_channel_manager_t *self);
-kaa_transport_channel_interface_t *kaa_channel_manager_get_transport_channel(kaa_channel_manager_t *self,
- kaa_extension_id service_type);
-
-kaa_error_t kaa_bootstrap_manager_create(kaa_bootstrap_manager_t **bootstrap_manager_p, kaa_context_t *kaa_context);
-
-void kaa_bootstrap_manager_destroy(kaa_bootstrap_manager_t *self);
-
-kaa_error_t kaa_platform_protocol_create(kaa_platform_protocol_t **platform_protocol_p,
- kaa_logger_t *logger, kaa_status_t *status);
-void kaa_platform_protocol_destroy(kaa_platform_protocol_t *self);
-
-kaa_error_t kaa_status_set_registered(kaa_status_t *self, bool is_registered);
-
-kaa_error_t kaa_failover_strategy_create(kaa_failover_strategy_t** strategy, kaa_logger_t *logger);
-void kaa_failover_strategy_destroy(kaa_failover_strategy_t* strategy);
-bool kaa_bootstrap_manager_process_failover(kaa_bootstrap_manager_t *self);
-
-kaa_error_t kaa_channel_manager_on_new_access_point(kaa_channel_manager_t *self
- , kaa_transport_protocol_id_t *protocol_id
- , kaa_server_type_t server_type
- , kaa_access_point_t *access_point);
-
-kaa_access_point_t *kaa_bootstrap_manager_get_operations_access_point(kaa_bootstrap_manager_t *self
- , kaa_transport_protocol_id_t *protocol_info);
-
-kaa_access_point_t *kaa_bootstrap_manager_get_bootstrap_access_point(
- kaa_bootstrap_manager_t *self,
- kaa_transport_protocol_id_t *protocol_id);
-
-
-kaa_error_t kaa_status_set_endpoint_access_token(kaa_status_t *self, const char *token);
-
-
-kaa_error_t kaa_status_set_updated(kaa_status_t *self, bool is_updated);
-
-kaa_error_t kaa_status_set_attached(kaa_status_t *self, bool is_attached);
-
-kaa_error_t kaa_context_set_status_registered(kaa_context_t *kaa_context, bool is_registered);
-
-struct kaa_status_holder_t {
- kaa_status_t *status_instance;
-};
-
-kaa_error_t kaa_extension_bootstrap_init(kaa_context_t *kaa_context, void **context);
-kaa_error_t kaa_extension_profile_init(kaa_context_t *kaa_context, void **context);
-kaa_error_t kaa_extension_event_init(kaa_context_t *kaa_context, void **context);
-kaa_error_t kaa_extension_logging_init(kaa_context_t *kaa_context, void **context);
-kaa_error_t kaa_extension_configuration_init(kaa_context_t *kaa_context, void **context);
-kaa_error_t kaa_extension_notification_init(kaa_context_t *kaa_context, void **context);
-kaa_error_t kaa_extension_user_init(kaa_context_t *kaa_context, void **context);
-
-kaa_error_t kaa_extension_bootstrap_deinit(void *context);
-kaa_error_t kaa_extension_profile_deinit(void *context);
-kaa_error_t kaa_extension_event_deinit(void *context);
-kaa_error_t kaa_extension_logging_deinit(void *context);
-kaa_error_t kaa_extension_configuration_deinit(void *context);
-kaa_error_t kaa_extension_notification_deinit(void *context);
-kaa_error_t kaa_extension_user_deinit(void *context);
-
-kaa_error_t kaa_extension_bootstrap_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync);
-kaa_error_t kaa_extension_profile_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync);
-kaa_error_t kaa_extension_event_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync);
-kaa_error_t kaa_extension_logging_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync);
-kaa_error_t kaa_extension_configuration_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync);
-kaa_error_t kaa_extension_notification_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync);
-kaa_error_t kaa_extension_user_request_serialize(void *context, uint32_t request_id,
- uint8_t *buffer, size_t *size, bool *need_resync);
-
-kaa_error_t kaa_extension_bootstrap_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size);
-kaa_error_t kaa_extension_profile_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size);
-kaa_error_t kaa_extension_event_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size);
-kaa_error_t kaa_extension_logging_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size);
-kaa_error_t kaa_extension_configuration_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size);
-kaa_error_t kaa_extension_notification_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size);
-kaa_error_t kaa_extension_user_server_sync(void *context, uint32_t request_id,
- uint16_t extension_options, const uint8_t *buffer, size_t size);
-
-/* ALL FUNCTIONS BELOW ARE DEPRECATED
- *
- * They should be removed once we move extensions out of the core.
- */
-
-kaa_error_t kaa_channel_manager_bootstrap_request_get_size(kaa_channel_manager_t *self, size_t *expected_size);
-
-kaa_error_t kaa_channel_manager_bootstrap_request_serialize(kaa_channel_manager_t *self,
- kaa_platform_message_writer_t* writer);
-kaa_error_t kaa_bootstrap_manager_bootstrap_request_serialize(kaa_bootstrap_manager_t *self,
- kaa_platform_message_writer_t* writer);
-kaa_error_t kaa_meta_data_request_serialize(kaa_platform_protocol_t *status,
- kaa_platform_message_writer_t* writer, uint32_t request_id);
-
-kaa_error_t kaa_bootstrap_manager_handle_server_sync(kaa_bootstrap_manager_t *self, kaa_platform_message_reader_t *reader, uint16_t extension_options, size_t extension_length);
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#endif /* KAA_PRIVATE_H */
diff --git a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp.h b/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp.h
deleted file mode 100644
index da6e24a612..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef KAATCP_H_
-#define KAATCP_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "kaatcp_parser.h"
-#include "kaatcp_request.h"
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif
-
diff --git a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_common.h b/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_common.h
deleted file mode 100644
index f30d628334..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_common.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef KAATCP_COMMON_H_
-#define KAATCP_COMMON_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include
-
-#define KAATCP_PROTOCOL_NAME_MAX_SIZE 10
-
-#define FIRST_BIT 0x80
-#define MAX_MESSAGE_TYPE_LENGTH 0x0F
-#define MAX_MESSAGE_LENGTH 0x0FFFFFFF
-#define PROTOCOL_VERSION 0x01
-
-#define KAA_SYNC_HEADER_LENGTH 12
-#define KAA_SYNC_ZIPPED_BIT 0x02
-#define KAA_SYNC_ENCRYPTED_BIT 0x04
-#define KAA_SYNC_REQUEST_BIT 0x01
-#define KAA_SYNC_SYNC_BIT 0x10
-#define KAA_SYNC_BOOTSTRAP_BIT 0x20
-
-#define KAA_BOOTSTRAP_RSA_PKSC8 0x01
-#define KAA_BOOTSTRAP_CHANNEL_HTTP 0x01
-#define KAA_BOOTSTRAP_CHANNEL_HTTPLP 0x02
-#define KAA_BOOTSTRAP_CHANNEL_KAATCP 0x03
-
-#define KAA_CONNECT_FLAGS 0x02
-#define KAA_CONNECT_HEADER_LENGTH 18
-
-#define KAA_CONNECT_KEY_AES_RSA 0x11
-#define KAA_CONNECT_SIGNATURE_SHA1 0x01
-
-#define KAA_TCP_NAME "Kaatcp"
-#define KAA_TCP_NAME_LENGTH 6
-
-#define KAA_PING_MESSAGE_SIZE 2
-#define KAA_DISCONNECT_MESSAGE_SIZE 4
-
-typedef enum {
- KAATCP_ERR_NONE = 0,
- KAATCP_ERR_NOMEM = -1,
- KAATCP_ERR_BUFFER_NOT_ENOUGH = -2,
- KAATCP_ERR_BAD_PARAM = -3,
- KAATCP_ERR_INVALID_STATE = -4,
- KAATCP_ERR_INVALID_PROTOCOL = -5
-} kaatcp_error_t;
-
-typedef enum {
- KAATCP_MESSAGE_UNKNOWN = 0x00,
- KAATCP_MESSAGE_CONNECT = 0x01,
- KAATCP_MESSAGE_CONNACK = 0x02,
- KAATCP_MESSAGE_PINGREQ = 0x0C,
- KAATCP_MESSAGE_PINGRESP = 0x0D,
- KAATCP_MESSAGE_DISCONNECT = 0x0E,
- KAATCP_MESSAGE_KAASYNC = 0x0F
-} kaatcp_message_type_t;
-
-typedef struct {
- uint16_t protocol_name_length;
- char protocol_name[KAATCP_PROTOCOL_NAME_MAX_SIZE];
-
- uint8_t protocol_version;
-
- uint8_t connect_flags;
-
- uint32_t next_ptorocol_id;
-
- uint8_t session_key_flags;
- uint8_t signature_flags;
-
- uint16_t keep_alive;
-
- size_t session_key_size;
- char *session_key;
-
- size_t signature_size;
- char *signature;
-
- size_t sync_request_size;
- char *sync_request;
-
-} kaatcp_connect_t;
-
-typedef enum {
- KAATCP_CONNACK_UNKNOWN = 0x00,
- KAATCP_CONNACK_SUCCESS = 0x01,
- KAATCP_CONNACK_UNACCEPTABLE_VERSION = 0x02,
- KAATCP_CONNACK_IDENTIFIER_REJECTED = 0x03,
- KAATCP_CONNACK_SERVER_UNAVAILABLE = 0x04,
- KAATCP_CONNACK_REFUSE_BAD_CREDENTIALS = 0x05,
- KAATCP_CONNACK_NOT_AUTHORIZED = 0x06,
- KAATCP_CONNACK_REFUSE_VERIFICATION_FAILED = 0x10,
-} kaatcp_connack_code_t;
-
-typedef struct {
- uint16_t return_code;
-} kaatcp_connack_t;
-
-typedef enum {
- KAATCP_DISCONNECT_NONE = 0x00,
- KAATCP_DISCONNECT_BAD_REQUEST = 0x01,
- KAATCP_DISCONNECT_INTERNAL_ERROR = 0x02,
- KAATCP_DISCONNECT_CREDENTIALS_REVOKED = 0x03,
-} kaatcp_disconnect_reason_t;
-
-typedef struct {
- uint16_t reason;
-} kaatcp_disconnect_t;
-
-typedef struct {
- uint16_t protocol_name_length;
- char protocol_name[KAATCP_PROTOCOL_NAME_MAX_SIZE];
-
- uint8_t protocol_version;
- uint16_t message_id;
- uint8_t flags;
-} kaatcp_kaasync_header_t;
-
-typedef struct {
- kaatcp_kaasync_header_t sync_header;
-
- size_t sync_request_size;
- char *sync_request;
-} kaatcp_kaasync_t;
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* KAATCP_COMMON_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_parser.c b/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_parser.c
deleted file mode 100644
index 7dcbfa8563..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_parser.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#include "kaatcp_parser.h"
-
-#include "kaa_common.h"
-#include
-#include "utilities/kaa_mem.h"
-
-
-
-static kaatcp_error_t kaatcp_parser_message_done(kaatcp_parser_t *parser)
-{
- KAA_RETURN_IF_NIL(parser, KAATCP_ERR_BAD_PARAM);
-
- switch (parser->message_type) {
- case KAATCP_MESSAGE_CONNACK:
- if (parser->handlers.connack_handler) {
- kaatcp_connack_t connack = { *(parser->payload + 1) };
- parser->handlers.connack_handler(parser->handlers.handlers_context, connack);
- }
- break;
- case KAATCP_MESSAGE_DISCONNECT:
- if (parser->handlers.disconnect_handler) {
- kaatcp_disconnect_t disconnect = { *(parser->payload + 1) };
- parser->handlers.disconnect_handler(parser->handlers.handlers_context, disconnect);
- }
- break;
- case KAATCP_MESSAGE_PINGRESP:
- if (parser->handlers.pingresp_handler) {
- parser->handlers.pingresp_handler(parser->handlers.handlers_context);
- }
- break;
- case KAATCP_MESSAGE_KAASYNC:
- {
- kaatcp_kaasync_header_t sync_header;
- const char *cursor = parser->payload;
-
- sync_header.protocol_name_length = KAA_NTOHS(*((uint16_t *) cursor));
- if (sync_header.protocol_name_length > KAATCP_PROTOCOL_NAME_MAX_SIZE) {
- return KAATCP_ERR_INVALID_PROTOCOL;
- }
-
- cursor += sizeof(uint16_t);
-
- if (memcmp(cursor, KAA_TCP_NAME, KAA_TCP_NAME_LENGTH)) {
- return KAATCP_ERR_INVALID_PROTOCOL;
- }
-
- memcpy(sync_header.protocol_name, cursor, sync_header.protocol_name_length);
- sync_header.protocol_name[sync_header.protocol_name_length] = '\0';
- cursor += sync_header.protocol_name_length;
-
- sync_header.protocol_version = *(cursor++);
- if (sync_header.protocol_version != PROTOCOL_VERSION) {
- return KAATCP_ERR_INVALID_PROTOCOL;
- }
-
- uint16_t msg_id;
- memcpy(&msg_id, cursor, sizeof(uint16_t));
- cursor += sizeof(uint16_t);
- sync_header.message_id = KAA_NTOHS(msg_id);
- sync_header.flags = *(cursor++);
-
- if ((sync_header.flags & KAA_SYNC_SYNC_BIT) && parser->handlers.kaasync_handler) {
- kaatcp_kaasync_t *kaasync = (kaatcp_kaasync_t *) KAA_MALLOC(sizeof(kaatcp_kaasync_t));
- KAA_RETURN_IF_NIL(kaasync, KAATCP_ERR_NOMEM);
-
- kaasync->sync_header = sync_header;
- kaasync->sync_request_size = parser->message_length - KAA_SYNC_HEADER_LENGTH;
-
- if (kaasync->sync_request_size) {
- kaasync->sync_request = (char *) KAA_MALLOC(kaasync->sync_request_size);
- if (!kaasync->sync_request) {
- KAA_FREE(kaasync);
- return KAATCP_ERR_NOMEM;
- }
- memcpy(kaasync->sync_request, cursor, kaasync->sync_request_size);
- } else {
- kaasync->sync_request = NULL;
- }
-
- parser->handlers.kaasync_handler(parser->handlers.handlers_context, kaasync);
- }
- break;
- }
- default:
- break;
- }
- return kaatcp_parser_reset(parser);
-}
-
-static void kaatcp_parser_retrieve_message_type(kaatcp_parser_t *parser, uint8_t byte)
-{
- KAA_RETURN_IF_NIL(parser, );
- parser->message_type = ((byte & 0xFF) >> 4);
-}
-
-static kaatcp_error_t kaatcp_parser_process_byte(kaatcp_parser_t *parser, uint8_t byte)
-{
- KAA_RETURN_IF_NIL(parser, KAATCP_ERR_BAD_PARAM);
-
- switch (parser->state) {
- case KAATCP_PARSER_STATE_NONE:
- kaatcp_parser_retrieve_message_type(parser, byte);
- parser->state = KAATCP_PARSER_STATE_PROCESSING_LENGTH;
- break;
- case KAATCP_PARSER_STATE_PROCESSING_LENGTH:
- parser->message_length += ((byte & ~FIRST_BIT) * parser->length_multiplier);
- parser->length_multiplier *= FIRST_BIT;
- if (!(byte & FIRST_BIT)) {
- if (parser->message_length) {
- parser->state = KAATCP_PARSER_STATE_PROCESSING_PAYLOAD;
- } else {
- return kaatcp_parser_message_done(parser);
- }
- }
- break;
- default:
- return KAATCP_ERR_INVALID_STATE;
- }
-
- if (parser->state == KAATCP_PARSER_STATE_PROCESSING_PAYLOAD && parser->message_length > parser->payload_buffer_size) {
- char *ptr = KAA_REALLOC(parser->payload, parser->message_length);
- if (ptr) {
- parser->payload = ptr;
- parser->payload_buffer_size = parser->message_length;
- } else
- return (kaatcp_error_t)KAA_ERR_NOMEM;
- }
-
- return KAATCP_ERR_NONE;
-}
-
-kaatcp_error_t kaatcp_parser_reset(kaatcp_parser_t *parser)
-{
- KAA_RETURN_IF_NIL(parser, KAATCP_ERR_BAD_PARAM);
-
- parser->state = KAATCP_PARSER_STATE_NONE;
- parser->message_type = KAATCP_MESSAGE_UNKNOWN;
- parser->message_length = 0;
- parser->processed_payload_length = 0;
- parser->length_multiplier = 1;
-
- return KAATCP_ERR_NONE;
-}
-
-kaatcp_error_t kaatcp_parser_init(kaatcp_parser_t *parser
- , const kaatcp_parser_handlers_t *handlers)
-{
- KAA_RETURN_IF_NIL2(parser, handlers, KAATCP_ERR_BAD_PARAM);
-
- kaatcp_error_t rval = kaatcp_parser_reset(parser);
- KAA_RETURN_IF_ERR(rval);
-
- parser->handlers = *handlers;
- return rval;
-}
-
-kaatcp_error_t kaatcp_parser_process_buffer(kaatcp_parser_t *parser, const char *buf, size_t buf_size)
-{
- KAA_RETURN_IF_NIL3(parser, buf, buf_size, KAATCP_ERR_BAD_PARAM);
-
- kaatcp_error_t rval = KAATCP_ERR_NONE;
- const char *buf_cursor = buf;
-
- while (buf_cursor != buf + buf_size) {
- if (parser->state == KAATCP_PARSER_STATE_PROCESSING_PAYLOAD) {
- uint32_t remaining_size = parser->message_length - parser->processed_payload_length;
- uint32_t buffer_remaining_size = buf + buf_size - buf_cursor;
- uint32_t bytes_to_read = (remaining_size > buffer_remaining_size) ? buffer_remaining_size : remaining_size;
-
- memcpy(parser->payload + parser->processed_payload_length, buf_cursor, bytes_to_read);
- parser->processed_payload_length += bytes_to_read;
- buf_cursor += bytes_to_read;
-
- if (parser->message_length == parser->processed_payload_length) {
- rval = kaatcp_parser_message_done(parser);
- KAA_RETURN_IF_ERR(rval);
- }
- } else {
- rval = kaatcp_parser_process_byte(parser, *(buf_cursor++));
- KAA_RETURN_IF_ERR(rval);
- }
- }
-
- return rval;
-}
-
-void kaatcp_parser_kaasync_destroy(kaatcp_kaasync_t *message)
-{
- KAA_RETURN_IF_NIL(message,);
-
- if (message->sync_request) {
- KAA_FREE(message->sync_request);
- }
-
- KAA_FREE(message);
-}
-
diff --git a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_parser.h b/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_parser.h
deleted file mode 100644
index 8ec9751e7d..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_parser.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef KAATCP_PARSER_H_
-#define KAATCP_PARSER_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "kaatcp_common.h"
-
-
-typedef void (*on_connack_message_fn)(void *context, kaatcp_connack_t message);
-typedef void (*on_disconnect_message_fn)(void *context, kaatcp_disconnect_t message);
-typedef void (*on_kaasync_message_fn)(void *context, kaatcp_kaasync_t *message);
-typedef void (*on_pingresp_message_fn)(void *context);
-
-
-
-typedef enum {
- KAATCP_PARSER_STATE_NONE = 0x00,
- KAATCP_PARSER_STATE_PROCESSING_LENGTH = 0x01,
- KAATCP_PARSER_STATE_PROCESSING_PAYLOAD = 0x02,
-} kaatcp_parser_state_t;
-
-typedef struct {
- void *handlers_context;
- on_connack_message_fn connack_handler;
- on_disconnect_message_fn disconnect_handler;
- on_kaasync_message_fn kaasync_handler;
- on_pingresp_message_fn pingresp_handler;
-} kaatcp_parser_handlers_t;
-
-typedef struct {
- kaatcp_parser_state_t state;
- kaatcp_message_type_t message_type;
- uint32_t message_length;
- uint32_t processed_payload_length;
- uint32_t length_multiplier;
- uint32_t payload_buffer_size;
- char *payload;
-
- kaatcp_parser_handlers_t handlers;
-} kaatcp_parser_t;
-
-
-
-kaatcp_error_t kaatcp_parser_init(kaatcp_parser_t *parser
- , const kaatcp_parser_handlers_t *handlers);
-
-kaatcp_error_t kaatcp_parser_reset(kaatcp_parser_t *parser);
-
-kaatcp_error_t kaatcp_parser_process_buffer(kaatcp_parser_t *parser
- , const char *buf
- , size_t buf_size);
-
-void kaatcp_parser_kaasync_destroy(kaatcp_kaasync_t *message);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* KAATCP_PARSER_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_request.c b/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_request.c
deleted file mode 100644
index 7a70f2a7dc..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_request.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-#include
-#include
-#include
-
-#include "kaatcp_request.h"
-
-#include "kaa_common.h"
-#include
-
-
-
-static uint8_t create_basic_header(uint8_t message_type, size_t length, char *message)
-{
- if (length <= MAX_MESSAGE_LENGTH && message_type <= MAX_MESSAGE_TYPE_LENGTH) {
- uint8_t size = 1;
- *(message++) = (char) (message_type << 4);
- do {
- uint8_t byte = length % FIRST_BIT;
- length /= FIRST_BIT;
- if (length) {
- byte |= FIRST_BIT;
- }
- *(message++) = (char) byte;
- ++size;
- } while (length);
- return size;
- }
- return 0;
-}
-
-// TODO(KAA-1089): Remove weak linkage
-__attribute__((weak))
-kaatcp_error_t kaatcp_fill_connect_message(uint16_t keepalive, uint32_t next_protocol_id
- , char *sync_request, size_t sync_request_size
- , char *session_key, size_t session_key_size
- , char *signature, size_t signature_size
- , kaatcp_connect_t *message)
-{
- KAA_RETURN_IF_NIL2(sync_request, sync_request_size, KAATCP_ERR_BAD_PARAM);
- if ((session_key_size > 0 && !session_key) || (signature_size > 0 && !signature))
- return KAATCP_ERR_BAD_PARAM;
- KAA_RETURN_IF_NIL(message, KAATCP_ERR_BAD_PARAM);
-
- memset(message, 0, sizeof(kaatcp_connect_t));
-
- message->protocol_name_length = KAA_TCP_NAME_LENGTH;
- memcpy(message->protocol_name, KAA_TCP_NAME, KAA_TCP_NAME_LENGTH);
-
- message->protocol_version = PROTOCOL_VERSION;
- message->connect_flags = KAA_CONNECT_FLAGS;
-
- message->next_ptorocol_id = next_protocol_id;
-
- if (session_key) {
- message->session_key = session_key;
- message->session_key_size = session_key_size;
- message->session_key_flags = KAA_CONNECT_KEY_AES_RSA;
- }
- if (signature) {
- message->signature = signature;
- message->signature_size = signature_size;
- message->signature_flags = KAA_CONNECT_SIGNATURE_SHA1;
- }
-
- message->keep_alive = keepalive;
-
- message->sync_request_size = sync_request_size;
- message->sync_request = sync_request;
-
- return KAATCP_ERR_NONE;
-}
-
-kaatcp_error_t kaatcp_get_request_size(const kaatcp_connect_t *message, kaatcp_message_type_t type, size_t *size)
-{
- KAA_RETURN_IF_NIL2(message, size, KAATCP_ERR_BAD_PARAM);
-
- size_t payload_size = message->sync_request_size
- + message->session_key_size
- + message->signature_size
- + KAA_CONNECT_HEADER_LENGTH;
-
- if (payload_size <= MAX_MESSAGE_LENGTH && type <= MAX_MESSAGE_TYPE_LENGTH) {
- uint8_t header_size = 1;
- do {
- payload_size /= FIRST_BIT;
- ++header_size;
- } while (payload_size);
-
- *size = payload_size + header_size;
- return (kaatcp_error_t)KAA_ERR_NONE;
- }
-
- return (kaatcp_error_t)KAA_ERR_BADPARAM;
-
-}
-
-// TODO: Remove weak linkage
-__attribute__((weak))
-kaatcp_error_t kaatcp_get_request_connect(const kaatcp_connect_t *message
- , char *buf
- , size_t *buf_size)
-{
- KAA_RETURN_IF_NIL3(message, buf, buf_size, KAATCP_ERR_BAD_PARAM);
-
- char header[6];
- size_t payload_size = message->sync_request_size
- + message->session_key_size
- + message->signature_size
- + KAA_CONNECT_HEADER_LENGTH;
-
- uint8_t header_size = create_basic_header(KAATCP_MESSAGE_CONNECT
- , payload_size
- , header);
-
- if ((*buf_size) < payload_size + header_size) {
- return KAATCP_ERR_BUFFER_NOT_ENOUGH;
- }
-
- char *cursor = buf;
-
- memcpy(cursor, header, header_size);
- cursor += header_size;
-
- uint16_t name_length = KAA_HTONS(message->protocol_name_length);
- memcpy(cursor, &name_length, sizeof(uint16_t));
- cursor += sizeof(uint16_t);
-
- memcpy(cursor, message->protocol_name, message->protocol_name_length);
- cursor += message->protocol_name_length;
-
- *(cursor++) = PROTOCOL_VERSION;
- *(cursor++) = message->connect_flags;
-
- uint32_t next_protocol_id = KAA_HTONL(message->next_ptorocol_id);
- memcpy(cursor, &next_protocol_id, sizeof(uint32_t));
- cursor += sizeof(uint32_t);
-
- *(cursor++) = message->session_key_flags;
- *(cursor++) = message->signature_flags;
-
- uint16_t keep_alive = KAA_HTONS(message->keep_alive);
- memcpy(cursor, &keep_alive, sizeof(uint16_t));
- cursor += sizeof(uint16_t);
-
- if (message->session_key && message->session_key_flags) {
- memcpy(cursor, message->session_key, message->session_key_size);
- cursor += message->session_key_size;
- }
- if (message->signature && message->signature_flags) {
- memcpy(cursor, message->signature, message->signature_size);
- cursor += message->signature_size;
- }
-
- if (message->sync_request) {
- memcpy(cursor, message->sync_request, message->sync_request_size);
- cursor += message->sync_request_size;
- }
- *buf_size = cursor - buf;
- return KAATCP_ERR_NONE;
-}
-
-kaatcp_error_t kaatcp_fill_disconnect_message(kaatcp_disconnect_reason_t return_code, kaatcp_disconnect_t *message)
-{
- KAA_RETURN_IF_NIL(message, KAATCP_ERR_BAD_PARAM);
- message->reason = return_code;
- return KAATCP_ERR_NONE;
-}
-
-kaatcp_error_t kaatcp_get_request_disconnect(const kaatcp_disconnect_t *message, char *buf, size_t *buf_size)
-{
- KAA_RETURN_IF_NIL3(message, buf, buf_size, KAATCP_ERR_BAD_PARAM);
-
- if (*buf_size < KAA_DISCONNECT_MESSAGE_SIZE) {
- return KAATCP_ERR_BUFFER_NOT_ENOUGH;
- }
- char *cursor = buf;
- create_basic_header(KAATCP_MESSAGE_DISCONNECT, 2, cursor);
- cursor += 2;
-
- *(cursor++) = 0;
- *(cursor++) = (message->reason & 0xFF);
-
- *buf_size = KAA_DISCONNECT_MESSAGE_SIZE;
- return KAATCP_ERR_NONE;
-}
-
-static void kaatcp_fill_kaasync_header(uint16_t message_id, uint8_t zipped, uint8_t encrypted, kaatcp_kaasync_header_t *header)
-{
- KAA_RETURN_IF_NIL(header,);
-
- header->protocol_name_length = KAA_TCP_NAME_LENGTH;
- memcpy(header->protocol_name, KAA_TCP_NAME, KAA_TCP_NAME_LENGTH);
-
- header->protocol_version = PROTOCOL_VERSION;
-
- header->message_id = message_id;
-
- header->flags |= KAA_SYNC_REQUEST_BIT;
- if (zipped) {
- header->flags |= KAA_SYNC_ZIPPED_BIT;
- }
- if (encrypted) {
- header->flags |= KAA_SYNC_ENCRYPTED_BIT;
- }
-}
-
-static kaatcp_error_t kaatcp_get_kaasync_header(const kaatcp_kaasync_header_t *sync_header
- , size_t payload_length
- , char *buf
- , size_t *buf_size
- , char **end)
-{
- KAA_RETURN_IF_NIL5(sync_header, payload_length, buf, buf_size, end, KAATCP_ERR_BAD_PARAM);
-
- char header[6];
- size_t payload_size = payload_length + KAA_SYNC_HEADER_LENGTH;
- uint8_t header_size = create_basic_header(KAATCP_MESSAGE_KAASYNC, payload_size, header);
-
- if ((*buf_size) < payload_size + header_size) {
- return KAATCP_ERR_BUFFER_NOT_ENOUGH;
- }
-
- char *cursor = buf;
-
- memcpy(cursor, header, header_size);
- cursor += header_size;
-
- uint16_t name_length = KAA_HTONS(sync_header->protocol_name_length);
- memcpy(cursor, &name_length, sizeof(uint16_t));
- cursor += sizeof(uint16_t);
-
- memcpy(cursor, sync_header->protocol_name, sync_header->protocol_name_length);
- cursor += sync_header->protocol_name_length;
-
- *(cursor++) = PROTOCOL_VERSION;
-
- uint16_t message_id = KAA_HTONS(sync_header->message_id);
- memcpy(cursor, &message_id, sizeof(uint16_t));
- cursor += sizeof(uint16_t);
-
- *(cursor++) = sync_header->flags;
- *end = cursor;
- return KAATCP_ERR_NONE;
-}
-
-kaatcp_error_t kaatcp_fill_kaasync_message(char *sync_request, size_t sync_request_size
- , uint16_t message_id, uint8_t zipped, uint8_t encrypted
- , kaatcp_kaasync_t *message)
-{
- KAA_RETURN_IF_NIL3(sync_request, sync_request_size, message, KAATCP_ERR_BAD_PARAM);
-
- memset(message, 0, sizeof(kaatcp_kaasync_t));
- kaatcp_fill_kaasync_header(message_id, zipped, encrypted, &message->sync_header);
- message->sync_header.flags |= KAA_SYNC_SYNC_BIT;
- message->sync_request = sync_request;
- message->sync_request_size = sync_request_size;
-
- return KAATCP_ERR_NONE;
-}
-
-kaatcp_error_t kaatcp_get_request_kaasync(const kaatcp_kaasync_t *message, char *buf, size_t *buf_size)
-{
- KAA_RETURN_IF_NIL3(message, buf, buf_size, KAATCP_ERR_BAD_PARAM);
-
- size_t first_buf_size = *buf_size;
- char *cursor = NULL;
- kaatcp_error_t rval = kaatcp_get_kaasync_header(&message->sync_header
- , message->sync_request_size
- , buf
- , buf_size
- , &cursor);
- KAA_RETURN_IF_ERR(rval);
-
- if (message->sync_request) {
- if (cursor + message->sync_request_size <= buf + first_buf_size) {
- memcpy(cursor, message->sync_request, message->sync_request_size);
- cursor += message->sync_request_size;
- }
- }
- *buf_size = cursor - buf;
- return first_buf_size < *buf_size ? KAATCP_ERR_BUFFER_NOT_ENOUGH : KAATCP_ERR_NONE;
-}
-
-
-kaatcp_error_t kaatcp_get_request_ping(char *buf, size_t *buf_size)
-{
- KAA_RETURN_IF_NIL2(buf, buf_size, KAATCP_ERR_BAD_PARAM);
-
- if (*buf_size < KAA_PING_MESSAGE_SIZE) {
- return KAATCP_ERR_BUFFER_NOT_ENOUGH;
- }
- create_basic_header(KAATCP_MESSAGE_PINGREQ, 0, buf);
- *buf_size = KAA_PING_MESSAGE_SIZE;
- return KAATCP_ERR_NONE;
-}
-
-
diff --git a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_request.h b/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_request.h
deleted file mode 100644
index 042bd58d24..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_protocols/kaa_tcp/kaatcp_request.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef KAATCP_REQUEST_H_
-#define KAATCP_REQUEST_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "kaatcp_common.h"
-
-
-
-kaatcp_error_t kaatcp_fill_connect_message(uint16_t keepalive, uint32_t next_protocol_id
- , char *sync_request, size_t sync_request_size
- , char *session_key, size_t session_key_size
- , char *signature, size_t signature_size
- , kaatcp_connect_t *message);
-
-kaatcp_error_t kaatcp_get_request_connect(const kaatcp_connect_t *message
- , char *buf
- , size_t *buf_size);
-
-kaatcp_error_t kaatcp_fill_disconnect_message(kaatcp_disconnect_reason_t reason
- , kaatcp_disconnect_t *message);
-
-kaatcp_error_t kaatcp_get_request_disconnect(const kaatcp_disconnect_t *message
- , char *buf
- , size_t *buf_size);
-
-kaatcp_error_t kaatcp_fill_kaasync_message(char *sync_request, size_t sync_request_size
- , uint16_t message_id, uint8_t zipped, uint8_t encrypted
- , kaatcp_kaasync_t *message);
-
-kaatcp_error_t kaatcp_get_request_kaasync(const kaatcp_kaasync_t *message
- , char *buf
- , size_t *buf_size);
-
-kaatcp_error_t kaatcp_get_request_ping(char *buf, size_t *buf_size);
-
-kaatcp_error_t kaatcp_get_request_size(const kaatcp_connect_t *message, kaatcp_message_type_t type, size_t *size);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-#endif /* KAATCP_REQUEST_H_ */
diff --git a/client/client-multi/client-c/src/kaa/kaa_status.c b/client/client-multi/client-c/src/kaa/kaa_status.c
deleted file mode 100644
index 1911a9c286..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_status.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "kaa_private.h"
-
-#include
-#include
-#include
-#include
-
-#include "platform/ext_notification_receiver.h"
-#include "platform/ext_sha.h"
-#include "platform/ext_status.h"
-#include "kaa_status.h"
-#include "kaa_defaults.h"
-#include "utilities/kaa_mem.h"
-
-/*
- * KAA Status persistent content:
- *
- * is_registered sizeof(bool)
- * is_attached sizeof(bool)
- * event_seq_n sizeof(uint32_t)
- * endpoint_public_key_hash SHA_1_DIGEST_LENGTH * sizeof(char)
- * profile_hash SHA_1_DIGEST_LENGTH * sizeof(char)
- * profile_needs_resync sizeof(bool)
- * endpoint_access_token_length sizeof(size_t)
- * endpoint_access_token (variable length)
- * states_count sizeof(size_t)
- * states (variable length)
- * topic_id
- * sqn_number
- * topics_count sizeof(size_t)
- * topics (variable length)
- * topic_id
- * subscription_type
- * name_length
- * name
- * topic_hash sizeof(int32_t)
- * token_buf sizeof(KAA_SDK_TOKEN)
- */
-#define KAA_STATUS_STATIC_SIZE (sizeof(bool) + sizeof(bool) + sizeof(size_t) + sizeof(bool) + sizeof(uint32_t) + sizeof(size_t) + SHA_1_DIGEST_LENGTH * sizeof(char) * 2 + sizeof(KAA_SDK_TOKEN))
-
-#define READ_BUFFER(FROM, TO, SIZE) \
- memcpy(TO, FROM, SIZE); \
- FROM += SIZE
-
-#define WRITE_BUFFER(FROM, TO, SIZE) \
- memcpy(TO, FROM, SIZE); \
- TO += SIZE
-
-// TODO KAA-845: discuss/implement a failover, when storage is somehow broken
-kaa_error_t kaa_status_create(kaa_status_t ** kaa_status_p)
-{
- KAA_RETURN_IF_NIL(kaa_status_p, KAA_ERR_BADPARAM);
-
- kaa_status_t *kaa_status = KAA_CALLOC(1, sizeof(*kaa_status));
- KAA_RETURN_IF_NIL(kaa_status, KAA_ERR_NOMEM);
-
- kaa_status->topic_states = kaa_list_create();
- KAA_RETURN_IF_NIL(kaa_status->topic_states, KAA_ERR_NOMEM);
- kaa_status->topics = kaa_list_create();
- KAA_RETURN_IF_NIL(kaa_status->topics, KAA_ERR_NOMEM);
-
- char * read_buf = NULL;
- char * read_buf_head = NULL;
- size_t read_size = 0;
- bool needs_deallocation = false;
- ext_status_read(&read_buf, &read_size, &needs_deallocation);
- read_buf_head = read_buf;
-
- if (read_size >= KAA_STATUS_STATIC_SIZE + sizeof(size_t)) {
- READ_BUFFER(read_buf, &kaa_status->is_registered, sizeof(kaa_status->is_registered));
- READ_BUFFER(read_buf, &kaa_status->is_attached, sizeof(kaa_status->is_attached));
- READ_BUFFER(read_buf, &kaa_status->event_seq_n, sizeof(kaa_status->event_seq_n));
- READ_BUFFER(read_buf, kaa_status->endpoint_public_key_hash, SHA_1_DIGEST_LENGTH);
- READ_BUFFER(read_buf, kaa_status->profile_hash, SHA_1_DIGEST_LENGTH);
- READ_BUFFER(read_buf, &kaa_status->profile_needs_resync, sizeof(kaa_status->profile_needs_resync));
-
- size_t endpoint_access_token_length = 0;
- READ_BUFFER(read_buf, &endpoint_access_token_length, sizeof(endpoint_access_token_length));
-
- if (endpoint_access_token_length > 0) {
- kaa_status->endpoint_access_token = KAA_MALLOC((endpoint_access_token_length + 1) * sizeof(char));
- if (!kaa_status->endpoint_access_token) {
- KAA_FREE(kaa_status);
- return KAA_ERR_NOMEM;
- }
- READ_BUFFER(read_buf, kaa_status->endpoint_access_token, endpoint_access_token_length);
- kaa_status->endpoint_access_token[endpoint_access_token_length] = '\0';
- }
-
- size_t states_count = 0;
- READ_BUFFER(read_buf, &states_count, sizeof(size_t));
- while (states_count--) {
- kaa_topic_state_t *state = KAA_MALLOC(sizeof(kaa_topic_state_t));
- KAA_RETURN_IF_NIL(state, KAA_ERR_NOMEM);
- READ_BUFFER(read_buf, &state->topic_id, sizeof(uint64_t));
- READ_BUFFER(read_buf, &state->sqn_number, sizeof(uint32_t));
-
- if (!kaa_list_push_back(kaa_status->topic_states, state)) {
- KAA_FREE(state);
- return KAA_ERR_NOMEM;
- }
- }
-
- // Restore all topics
-
- size_t topics_count;
- READ_BUFFER(read_buf, &topics_count, sizeof(topics_count));
-
- while (topics_count--) {
- kaa_topic_t *topic = KAA_MALLOC(sizeof(*topic));
- KAA_RETURN_IF_NIL(topic, KAA_ERR_NOMEM);
-
- READ_BUFFER(read_buf, &topic->id, sizeof(topic->id));
- READ_BUFFER(read_buf, &topic->subscription_type,
- sizeof(topic->subscription_type));
- READ_BUFFER(read_buf, &topic->name_length, sizeof(topic->name_length));
-
- if (topic->name_length) {
- topic->name = KAA_CALLOC(topic->name_length + 1, 1);
- KAA_RETURN_IF_NIL(topic->name, KAA_ERR_NOMEM);
- READ_BUFFER(read_buf, topic->name, topic->name_length);
- }
-
- if (!kaa_list_push_back(kaa_status->topics, topic)) {
- KAA_FREE(topic);
- return KAA_ERR_NOMEM;
- }
- }
-
- READ_BUFFER(read_buf, &kaa_status->topic_list_hash, sizeof(kaa_status->topic_list_hash));
- char token_buf[sizeof(KAA_SDK_TOKEN)];
- READ_BUFFER(read_buf, token_buf, sizeof(token_buf));
-
- // TODO: shouldn't that be memcmp?
- if (strcmp(token_buf, KAA_SDK_TOKEN)) {
- kaa_status->is_registered = false;
- } else {
- kaa_status_set_updated(kaa_status, true);
- }
- }
-
- if (needs_deallocation) {
- KAA_FREE(read_buf_head);
- }
-
- *kaa_status_p = kaa_status;
- return KAA_ERR_NONE;
-}
-
-void kaa_status_destroy(kaa_status_t *self)
-{
- if (self) {
- KAA_FREE(self->endpoint_access_token);
- kaa_list_destroy(self->topic_states, NULL);
- kaa_list_destroy(self->topics, NULL);
- KAA_FREE(self);
- }
-}
-
-kaa_error_t kaa_status_set_endpoint_access_token(kaa_status_t * self, const char *token)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
-
- char *new_token;
- size_t len = strlen(token);
-
- /* Do not delete old access token before new will be allocated */
-
- new_token = KAA_MALLOC((len + 1) * sizeof(char));
- if (!new_token)
- return KAA_ERR_NOMEM;
-
- strcpy(new_token, token);
-
- if (self->endpoint_access_token)
- KAA_FREE(self->endpoint_access_token);
-
- self->endpoint_access_token = new_token;
- self->has_update = true;
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_status_set_registered(kaa_status_t *self, bool is_registered)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
- self->is_registered = is_registered;
- self->has_update = true;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_status_set_attached(kaa_status_t *self, bool is_attached)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
- self->is_attached = is_attached;
- self->has_update = true;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_status_set_updated(kaa_status_t *self, bool is_updated)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
- self->is_updated = is_updated;
- self->has_update = true;
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_status_save(kaa_status_t *self)
-{
- KAA_RETURN_IF_NIL(self, KAA_ERR_BADPARAM);
-
- if (!self->has_update)
- return KAA_ERR_NONE;
-
- size_t endpoint_access_token_length = self->endpoint_access_token ? strlen(self->endpoint_access_token) : 0;
- size_t states_count = kaa_list_get_size(self->topic_states);
- size_t topics_count = kaa_list_get_size(self->topics);
-
- // Calculate size of whole list of topics
- kaa_list_node_t *topic_node = kaa_list_begin(self->topics);
- size_t topics_size = 0;
- while (topic_node) {
- kaa_topic_t *topic = kaa_list_get_data(topic_node);
-
- topics_size += sizeof(topic->id)
- + sizeof(topic->subscription_type)
- + sizeof(topic->name_length)
- + topic->name_length;
-
- topic_node = kaa_list_next(topic_node);
- }
-
-
- size_t buffer_size = KAA_STATUS_STATIC_SIZE
- + sizeof(endpoint_access_token_length)
- + endpoint_access_token_length
- /* Topic ID Sequence number */
- + states_count * (sizeof(uint32_t) + sizeof(uint64_t))
- + topics_size
- + sizeof(int32_t);
-
- char *buffer_head = KAA_MALLOC(buffer_size * sizeof(char));
- KAA_RETURN_IF_NIL(buffer_head, KAA_ERR_NOMEM);
-
- char *buffer = buffer_head;
-
- WRITE_BUFFER(&self->is_registered, buffer, sizeof(self->is_registered));
- WRITE_BUFFER(&self->is_attached, buffer, sizeof(self->is_attached));
- WRITE_BUFFER(&self->event_seq_n, buffer, sizeof(self->event_seq_n));
- WRITE_BUFFER(self->endpoint_public_key_hash, buffer, SHA_1_DIGEST_LENGTH);
- WRITE_BUFFER(self->profile_hash, buffer, SHA_1_DIGEST_LENGTH);
- WRITE_BUFFER(&self->profile_needs_resync, buffer, sizeof(self->profile_needs_resync));
- WRITE_BUFFER(&endpoint_access_token_length, buffer,
- sizeof(endpoint_access_token_length));
- if (endpoint_access_token_length) {
- WRITE_BUFFER(self->endpoint_access_token, buffer, endpoint_access_token_length);
- }
-
- kaa_list_node_t *state_node = kaa_list_begin(self->topic_states);
- WRITE_BUFFER(&states_count, buffer, sizeof(size_t));
- while (state_node) {
- kaa_topic_state_t *state = kaa_list_get_data(state_node);
- WRITE_BUFFER(&state->topic_id, buffer, sizeof(uint64_t));
- WRITE_BUFFER(&state->sqn_number, buffer, sizeof(uint32_t));
- state_node = kaa_list_next(state_node);
- }
-
- topic_node = kaa_list_begin(self->topics);
- WRITE_BUFFER(&topics_count, buffer, sizeof(topics_count));
- while (topic_node) {
- kaa_topic_t *topic = kaa_list_get_data(topic_node);
-
- WRITE_BUFFER(&topic->id, buffer, sizeof(topic->id));
- WRITE_BUFFER(&topic->subscription_type, buffer, sizeof(topic->subscription_type));
- WRITE_BUFFER(&topic->name_length, buffer, sizeof(topic->name_length));
- WRITE_BUFFER(topic->name, buffer, topic->name_length);
- topic_node = kaa_list_next(topic_node);
- }
-
- WRITE_BUFFER(&self->topic_list_hash, buffer, sizeof(self->topic_list_hash));
- WRITE_BUFFER(KAA_SDK_TOKEN, buffer, sizeof(KAA_SDK_TOKEN));
-
- ext_status_store(buffer_head, buffer_size);
-
- KAA_FREE(buffer_head);
-
- self->has_update = false;
-
- return KAA_ERR_NONE;
-}
diff --git a/client/client-multi/client-c/src/kaa/kaa_status.h b/client/client-multi/client-c/src/kaa/kaa_status.h
deleted file mode 100644
index 3bd827ce79..0000000000
--- a/client/client-multi/client-c/src/kaa/kaa_status.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef KAA_STATUS_H_
-#define KAA_STATUS_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "kaa_error.h"
-#include "kaa_common.h"
-#include "collections/kaa_list.h"
-#include "platform/ext_sha.h"
-
-typedef struct {
- uint64_t topic_id;
- uint32_t sqn_number;
-} kaa_topic_state_t;
-
-#ifndef KAA_STATUS_T
-# define KAA_STATUS_T
-typedef struct
-{
- uint32_t event_seq_n;
- bool is_registered;
- bool is_attached;
- bool is_updated;
- kaa_digest endpoint_public_key_hash;
- kaa_digest profile_hash;
- bool profile_needs_resync; /**< Indicates that profile should be resynced */
-
- kaa_list_t *topic_states; /**< States of topics received */
- kaa_list_t *topics; /**< Whole set of topics */
- int32_t topic_list_hash; /**< List hash */
- char *endpoint_access_token;
- bool has_update; /**< Indicates that status was changed on the client size */
-} kaa_status_t;
-
-#endif
-
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-#endif /* KAA_STATUS_H_ */
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/__ashldi3.c b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/__ashldi3.c
deleted file mode 100644
index 3698a3736c..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/__ashldi3.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-
-
-
-uint64_t __ashldi3(uint64_t a, int b)
-{
- if (b <= 0 ) {
- return a;
- }
- if (b >= 64) {
- return 0;
- }
- uint32_t aLow = (uint32_t) a;
- uint32_t aHigh = (uint32_t) (a >> 32);
- if (b >= 32) {
- aHigh = (aLow << b);
- aLow = 0;
- } else {
- aHigh = (aHigh << b) + (aLow >> (32 - b));
- aLow = (aLow << b);
- }
- return ((uint64_t) aHigh << 32) + aLow;
-}
-
-
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_configuration_persistence.c b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_configuration_persistence.c
deleted file mode 100644
index 81e60f4cb6..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_configuration_persistence.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
-@file econais_ec19d_configuration_persistence.c
- Created on: Feb 23, 2015
- Author: Andriy Panasenko
-*/
-
-
-#include
-#include
-#include "platform/ext_configuration_persistence.h"
-#include "econais_ec19d_file_utils.h"
-
-#define KAA_CONFIGURATION_STORAGE "kaa_configuration.bin"
-
-void ext_configuration_read(char **buffer, size_t *buffer_size, bool *needs_deallocation)
-{
- econais_ec19d_binary_file_read(KAA_CONFIGURATION_STORAGE, buffer, buffer_size, needs_deallocation);
-}
-
-void ext_configuration_store(const char *buffer, size_t buffer_size)
-{
- econais_ec19d_binary_file_store(KAA_CONFIGURATION_STORAGE, buffer, buffer_size);
-}
-
-void ext_configuration_delete(void)
-{
- econais_ec19d_binary_file_delete(KAA_CONFIGURATION_STORAGE);
-}
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_defaults.h b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_defaults.h
deleted file mode 100644
index 9a9ab5c418..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_defaults.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
-@file econais_ec19d_defaults.h
- Created on: Mar 26, 2015
- Author: Andriy Panasenko
-*/
-
-#ifndef ECONAIS_EC19D_DEFAULTS_H_
-#define ECONAIS_EC19D_DEFAULTS_H_
-
-#define KAA_TCP_CHANNEL_IN_BUFFER_SIZE 246
-#define KAA_TCP_CHANNEL_OUT_BUFFER_SIZE 1015
-
-#define KAA_TCP_CHANNEL_MAX_TIMEOUT 200u
-#define KAA_TCP_CHANNEL_PING_TIMEOUT (KAA_TCP_CHANNEL_MAX_TIMEOUT / 2)
-
-#define KAATCP_PARSER_MAX_MESSAGE_LENGTH 999
-
-#define KAA_MAX_LOG_MESSAGE_LENGTH 247
-
-#endif /* ECONAIS_EC19D_DEFAULTS_H_ */
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_file_utils.c b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_file_utils.c
deleted file mode 100644
index 14a5c63d88..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_file_utils.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
-@file econais_ec19d_file_utils.c
-*/
-#include
-#include
-#include "econais_ec19d_file_utils.h"
-#include "kaa_common.h"
-
-int econais_ec19d_binary_file_read(const char *file_name, char **buffer, size_t *buffer_size, bool *needs_deallocation)
-{
- KAA_RETURN_IF_NIL4(file_name, buffer, buffer_size, needs_deallocation, -1);
-
- *buffer = NULL;
- *buffer_size = 0;
- *needs_deallocation = false;
-
- sndc_file_ref_t status_file = sndc_file_open(file_name, DE_FRDONLY);
- KAA_RETURN_IF_NIL(status_file, -1);
-
- sndc_file_seek(status_file, 0, SEEK_END);
- *buffer_size = sndc_file_tell(status_file);
- *buffer = (char*)sndc_mem_calloc(*buffer_size, sizeof(char));
- KAA_RETURN_IF_NIL(*buffer, -1);
-
-
- sndc_file_seek(status_file, 0, SEEK_SET);
- if (sndc_file_read(status_file, *buffer, *buffer_size) == 0) {
- sndc_mem_free(*buffer);
- return -1;
- }
- *needs_deallocation = true;
- sndc_file_close(status_file);
- return 0;
-}
-
-int econais_ec19d_binary_file_store(const char *file_name, const char *buffer, size_t buffer_size)
-{
- KAA_RETURN_IF_NIL3(file_name, buffer, buffer_size, -1);
- sndc_file_ref_t status_file = sndc_file_open(file_name, DE_FCREATE|DE_FWRONLY|DE_FTRUNC);
-
- if (status_file) {
- int i = sndc_file_write(status_file, (void*)buffer, buffer_size);
- sndc_file_close(status_file);
- return 0 ? (i >= 0) : -1;
- }
- return -1;
-}
-
-int econais_ec19d_binary_file_delete(const char *file_name)
-{
- return sndc_file_delete(file_name);
-}
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_file_utils.h b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_file_utils.h
deleted file mode 100644
index be5e3a182b..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_file_utils.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
-@file econais_ec19d_file_utils.h
-*/
-
-#ifndef ECONAIS_EC19D_FILE_UTILS_H_
-#define ECONAIS_EC19D_FILE_UTILS_H_
-
-#include
-#include
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int econais_ec19d_binary_file_read(const char *file_name, char **buffer, size_t *buffer_size, bool *needs_deallocation);
-
-
-int econais_ec19d_binary_file_store(const char *file_name, const char *buffer, size_t buffer_size);
-
-
-int econais_ec19d_binary_file_delete(const char *file_name);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* ECONAIS_EC19D_FILE_UTILS_H_ */
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_kaa_client.c b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_kaa_client.c
deleted file mode 100644
index bff35deee0..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_kaa_client.c
+++ /dev/null
@@ -1,832 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- *@file kaa_client.c
-*/
-#include
-#include
-#include
-
-#include
-typedef long long int64_t;
-
-#include "kaa_error.h"
-#include "kaa_common.h"
-#include "kaa.h"
-#include "utilities/kaa_log.h"
-#include "platform/ext_sha.h"
-#include "platform/ext_transport_channel.h"
-#include "platform/ext_system_logger.h"
-#include "platform/time.h"
-#include "platform-impl/common/kaa_tcp_channel.h"
-#include "platform-impl/common/ext_log_upload_strategies.h"
-#include "kaa_bootstrap_manager.h"
-#include "kaa_channel_manager.h"
-#include "kaa_configuration_manager.h"
-#include "kaa_logging.h"
-#include "platform/ext_log_storage.h"
-#include "platform/ext_log_upload_strategy.h"
-#include "econais_ec19d_file_utils.h"
-
-#include "kaa_context.h"
-
-#define KAA_CLIENT_T
-
-typedef enum {
- BOOTSRAP_UNDEF,
- BOOTSRAP_STARTED,
- BOOTSRAP_FINISHED
-} bootstrap_client_state_t;
-
-struct kaa_client_t {
- char *thread_name;
- bool_t operate;
- sndc_sem_t start_semophore;
- sndc_sem_t logging_semophore;
- unsigned long max_update_time;
- struct sndc_timeval timeval;
- kaa_context_t *kaa_context;
- kaa_transport_channel_interface_t bootstrap_channel;
- unsigned int bootstrap_channel_id;
- bootstrap_client_state_t bootstrap_state;
- kaa_transport_channel_interface_t operations_channel;
- unsigned int operations_channel_id;
- void *log_storage_context;
- void *log_upload_strategy_context;
- sndc_mem_stats_t mem_stat;
-};
-
-#define KAA_DEMO_UPLOAD_COUNT_THRESHOLD 1 /* Count of collected serialized logs needed to initiate log upload */
-
-#define KAA_DEMO_LOG_GENERATION_FREQUENCY 3 /* seconds */
-
-#include "platform/kaa_client.h"
-
-//Forward declaration of internal functions
-kaa_error_t kaa_init_security_stuff(void);
-
-/* forward declarations */
-
-void print_mem_stat(kaa_client_t *kaa_client);
-/*
- * Strategy-specific configuration parameters used by Kaa log collection feature.
- */
-#define KAA_DEMO_MAX_UPLOAD_THRESHOLD 15 /* Size of collected serialized logs needed to initiate log upload */
-/* Max size of a log batch has been sent by SDK during one upload. */
-#define KAA_DEMO_MAX_LOG_BUCKET_SIZE (KAA_TCP_CHANNEL_OUT_BUFFER_SIZE >> 3)
-#define KAA_DEMO_MAX_LOGS_IN_BUCKET 16 /* Max count of logs in one bucket */
-#define KAA_DEMO_MAX_CLEANUP_THRESHOLD 100 /* Max size of an inner log storage. If size is exceeded, elder logs will be removed. */
-
-#define KAA_DEMO_LOG_GENERATION_FREQUENCY 3 /* seconds */
-
-_Static_assert(KAA_DEMO_MAX_LOG_BUCKET_SIZE, "Maximum bucket size cannot be 0!");
-
-/*
- * Kaa status and public key storage file names.
- */
-#define KAA_KEY_STORAGE "key.txt"
-#define KAA_STATUS_STORAGE "status.conf"
-
-static size_t kaa_public_key_length;
-static char *kaa_public_key;
-static kaa_digest kaa_public_key_hash;
-
-static kaa_extension_id BOOTSTRAP_SERVICE[] = { KAA_EXTENSION_BOOTSTRAP };
-static const int BOOTSTRAP_SERVICE_COUNT = sizeof(BOOTSTRAP_SERVICE) / sizeof(kaa_extension_id);
-
-/*
- * Define services which should be used.
- * Don't define unused services, it may cause an error.
- */
-static kaa_extension_id OPERATIONS_SERVICES[] = { KAA_EXTENSION_PROFILE
- , KAA_EXTENSION_CONFIGURATION
- , KAA_EXTENSION_USER
- , KAA_EXTENSION_EVENT
- , KAA_EXTENSION_LOGGING};
-static const int OPERATIONS_SERVICES_COUNT = sizeof(OPERATIONS_SERVICES) / sizeof(kaa_extension_id);
-
-void thread_run_fn(uintptr_t arg);
-
-kaa_error_t kaa_client_create(kaa_client_t **kaa_client, kaa_client_props_t *props)
-{
- KAA_RETURN_IF_NIL2(kaa_client, props, KAA_ERR_BADPARAM);
-
- kaa_error_t error_code = kaa_init_security_stuff();
- KAA_RETURN_IF_ERR(error_code);
-
- kaa_client_t *self = sndc_mem_calloc(1,sizeof(kaa_client_t));
- KAA_RETURN_IF_NIL(self,KAA_ERR_NOMEM);
-
- self->thread_name = sndc_mem_strdup("Kaa-Client-Thread");
- self->operate = true;
- self->max_update_time = props->max_update_time;
-
- print_mem_stat(self);
- sndc_printf("Initializing Kaa SDK...\n");
- sndc_thrd_delay(TRACE_DELAY * SNDC_MILLISECOND);
-
- error_code = kaa_init(&self->kaa_context);
- if (error_code) {
- sndc_printf("Error during Kaa context creation %d\n", error_code);
- sndc_thrd_delay(TRACE_DELAY * SNDC_MILLISECOND);
- goto error;
- }
-
- KAA_LOG_INFO(self->kaa_context->logger, KAA_ERR_NONE, "Kaa framework initialized.");
-
- print_mem_stat(self);
- error_code = kaa_log_collector_init(self);
- if (error_code) {
- sndc_printf("Failed to init Kaa log collector %d\n", error_code);
- sndc_thrd_delay(TRACE_DELAY * SNDC_MILLISECOND);
- goto error;
- }
-
- KAA_LOG_INFO(self->kaa_context->logger, KAA_ERR_NONE, "Kaa log collector initialized.");
-
- *kaa_client = self;
-
- /* initialize semaphore */
- sndc_sem_init(&self->start_semophore, 0);
- sndc_sem_init(&self->logging_semophore, 0);
-
- int status = sndc_thrd_create(
- self->thread_name,
- thread_run_fn,
- (uintptr_t)self,
- SNDC_THRD_PRIORITY_DEFAULT,
- THREAD_STACKSIZE_DMR_START); //Defined 4K-8 bytes of stack
-
- switch (status) {
- case 0:
-
- break;
- case -EINVAL:
- error_code = KAA_ERR_BADPARAM;
- break;
- case -ENOMEM:
- error_code = KAA_ERR_NOMEM;
- break;
- default:
- error_code = KAA_ERR_BADDATA;
- break;
- }
-
- return error_code;
-
-error:
-
- sndc_printf("Kaa initialization failed. error_code %d\n", error_code);
- sndc_thrd_delay(TRACE_DELAY * SNDC_MILLISECOND);
- kaa_client_destroy(self);
-
- return error_code;
-}
-
-kaa_error_t kaa_client_stop(kaa_client_t *kaa_client)
-{
- KAA_RETURN_IF_NIL(kaa_client, KAA_ERR_BADPARAM);
- kaa_client->operate = false;
- return kaa_stop(kaa_client->kaa_context);
-}
-
-void kaa_client_destroy(kaa_client_t *kaa_client)
-{
- if(!kaa_client)
- return;
-
- if (kaa_client->start_semophore) {
- sndc_sem_destroy(kaa_client->start_semophore);
- kaa_client->start_semophore = NULL;
- }
-
- if (kaa_client->logging_semophore) {
- sndc_sem_destroy(kaa_client->logging_semophore);
- kaa_client->logging_semophore = NULL;
- }
-
- if (kaa_client->operations_channel.context) {
- kaa_client->operations_channel.destroy(kaa_client->operations_channel.context);
- kaa_client->operations_channel.context = NULL;
- }
-
- if (kaa_client->bootstrap_channel.context) {
- kaa_client->bootstrap_channel.destroy(kaa_client->bootstrap_channel.context);
- kaa_client->bootstrap_channel.context = NULL;
- }
-
- if (kaa_client->log_storage_context) {
- ext_log_storage_destroy(kaa_client->log_storage_context);
- kaa_client->log_storage_context = NULL;
- }
-
- if (kaa_client->kaa_context) {
- kaa_deinit(kaa_client->kaa_context);
- kaa_client->kaa_context = NULL;
- }
-
- if (kaa_client->thread_name) {
- sndc_mem_free(kaa_client->thread_name);
- }
- sndc_mem_free(kaa_client);
-}
-
-kaa_context_t* kaa_client_get_context(kaa_client_t *kaa_client)
-{
- KAA_RETURN_IF_NIL(kaa_client,NULL);
- return kaa_client->kaa_context;
-}
-
-kaa_error_t kaa_client_init_operations_channel(kaa_client_t *kaa_client)
-{
- KAA_RETURN_IF_NIL(kaa_client, KAA_ERR_BADPARAM);
- KAA_LOG_TRACE(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Start operations channel initialization");
- kaa_error_t error_code = kaa_tcp_channel_create(&kaa_client->operations_channel,
- kaa_client->kaa_context->logger, OPERATIONS_SERVICES, OPERATIONS_SERVICES_COUNT);
- if (error_code) {
- KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Operations channel initialization failed");
- return error_code;
- }
-
- KAA_LOG_TRACE(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Initializing Kaa SDK Operations channel added to transport channel manager");
-
- error_code = kaa_channel_manager_add_transport_channel(kaa_client->kaa_context->channel_manager,
- &kaa_client->operations_channel, &kaa_client->operations_channel_id);
- if (error_code) {
- KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Error during Kaa operations channel setting as transport");
- return error_code;
- }
-
- KAA_LOG_INFO(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Operations channel initialized successfully");
- print_mem_stat(kaa_client);
- return error_code;
-}
-
-kaa_error_t on_kaa_tcp_channel_event(void *context
- , kaa_tcp_channel_event_t event_type
- , kaa_fd_t fd)
-{
- KAA_RETURN_IF_NIL(context, KAA_ERR_BADPARAM);
- kaa_client_t *self = (kaa_client_t *)context;
-
- switch (event_type) {
- case SOCKET_CONNECTED:
- KAA_LOG_INFO(self->kaa_context->logger, KAA_ERR_NONE, "Bootstrap socket(%d) Connected", fd);
- if (self->bootstrap_state == BOOTSRAP_UNDEF)
- self->bootstrap_state = BOOTSRAP_STARTED;
- break;
- case SOCKET_DISCONNECTED:
- KAA_LOG_INFO(self->kaa_context->logger, KAA_ERR_NONE, "Bootstrap socket Disconnected");
- if (self->bootstrap_state == BOOTSRAP_STARTED)
- self->bootstrap_state = BOOTSRAP_FINISHED;
- break;
- default:
- KAA_LOG_ERROR(self->kaa_context->logger, KAA_ERR_NONE, "Bootstrap socket Error");
- self->bootstrap_state = BOOTSRAP_UNDEF;
- break;
- }
-
- return KAA_ERR_NONE;
-}
-
-kaa_error_t kaa_client_deinit_bootstrap_channel(kaa_client_t *kaa_client)
-{
- KAA_RETURN_IF_NIL(kaa_client, KAA_ERR_BADPARAM);
- KAA_LOG_TRACE(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Bootstrap channel deinitialization starting ....");
- print_mem_stat(kaa_client);
-
- kaa_error_t error_code = kaa_channel_manager_remove_transport_channel(
- kaa_client->kaa_context->channel_manager,kaa_client->bootstrap_channel_id);
-
- if (error_code) {
- KAA_LOG_TRACE(kaa_client->kaa_context->logger, error_code, "Bootstrap channel error removing from channel manager");
- return error_code;
- }
-
- kaa_client->bootstrap_channel.context = NULL;
- kaa_client->bootstrap_channel.destroy = NULL;
- kaa_client->bootstrap_channel.get_protocol_id = NULL;
- kaa_client->bootstrap_channel.get_supported_services = NULL;
- kaa_client->bootstrap_channel.init = NULL;
- kaa_client->bootstrap_channel.set_access_point = NULL;
- kaa_client->bootstrap_channel.sync_handler = NULL;
-
- kaa_client->bootstrap_state = BOOTSRAP_UNDEF;
- KAA_LOG_INFO(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Bootstrap channel deinitialized");
-
- return error_code;
-}
-
-
-kaa_error_t kaa_client_start(kaa_client_t *kaa_client
- , external_process_fn external_process
- , void *external_process_context
- , kaa_time_t max_delay)
-{
- KAA_RETURN_IF_NIL(kaa_client, KAA_ERR_BADPARAM);
- KAA_LOG_TRACE(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Kaa client starting ...");
- print_mem_stat(kaa_client);
-
- kaa_error_t error_code = kaa_check_readiness(kaa_client->kaa_context);
- if (error_code != KAA_ERR_NONE) {
- KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Cannot start Kaa client: Kaa context is not fully initialized");
- return error_code;
- }
-
- error_code = kaa_tcp_channel_create(&kaa_client->bootstrap_channel
- , kaa_client->kaa_context->logger
- , BOOTSTRAP_SERVICE
- , BOOTSTRAP_SERVICE_COUNT);
- if (error_code) {
- KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Error during Kaa bootstrap channel creation");
- return error_code;
- }
-
- error_code = kaa_tcp_channel_set_socket_events_callback(&kaa_client->bootstrap_channel,
- on_kaa_tcp_channel_event, (void*)kaa_client);
- if (error_code) {
- KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Error setting callback bootstrap channel");
- return error_code;
- }
-
-
- KAA_LOG_TRACE(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Kaa client - bootstrap channel initialized");
- print_mem_stat(kaa_client);
-
- error_code = kaa_channel_manager_add_transport_channel(kaa_client->kaa_context->channel_manager
- , &kaa_client->bootstrap_channel
- , &kaa_client->bootstrap_channel_id);
-
- if (error_code) {
- KAA_LOG_ERROR(kaa_client->kaa_context->logger, error_code, "Error setting bootstrap channel setting as transport");
- return error_code;
- }
-
- //Push running thread
- sndc_sem_post(&kaa_client->start_semophore);
- KAA_LOG_INFO(kaa_client->kaa_context->logger, KAA_ERR_NONE, "Kaa client started");
-
- return KAA_ERR_NONE;
-}
-
-void thread_run_fn(uintptr_t arg)
-{
- if(!arg) {
- sndc_printf("Kaa client thread function Error, no args\n");
- return;
- }
-
- kaa_client_t *self = (kaa_client_t *)arg;
- KAA_LOG_TRACE(self->kaa_context->logger, KAA_ERR_NONE, "Kaa client working thread started....");
- sndc_sem_post(&self->logging_semophore);
-
- sndc_sock_fdset r_set;
- sndc_sock_fdset w_set;
- sndc_sock_fdset x_set;
- int ops_fd = -1, bootstrap_fd = -1;
- bool_t fdset = false;
- uint16_t timeout = self->max_update_time;
- kaa_error_t error_code;
- KAA_LOG_TRACE(self->kaa_context->logger, KAA_ERR_NONE, "Kaa client working thread(%s) wait starting...", self->thread_name);
- sndc_sem_wait(&self->start_semophore);
- KAA_LOG_INFO(self->kaa_context->logger, KAA_ERR_NONE, "Kaa client working thread(%s) started", self->thread_name);
-
- while(self->operate) {
- int max_fd = 0;
- SNDC_FD_ZERO(&r_set);
- SNDC_FD_ZERO(&w_set);
- SNDC_FD_ZERO(&x_set);
-
- // This semaphore is used to synchronize main thread and kaa_client thread,
- // mostly for logging proposes.
- sndc_sem_tryWait(&self->logging_semophore);
-
- if (self->operations_channel.context)
- kaa_tcp_channel_get_descriptor(&self->operations_channel, &ops_fd);
- if(self->bootstrap_channel.context)
- kaa_tcp_channel_get_descriptor(&self->bootstrap_channel, &bootstrap_fd);
- KAA_LOG_DEBUG(self->kaa_context->logger, KAA_ERR_NONE, "IO LOOP: descriptors: bootstrap(%d), operations(%d)", bootstrap_fd, ops_fd);
-
- print_mem_stat(self);
-
- if (bootstrap_fd >= 0) {
- fdset = false;
- if (kaa_tcp_channel_is_ready(&self->bootstrap_channel, FD_READ)) {
- SNDC_FD_SET(bootstrap_fd, &r_set);
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Bootstrap READ set wait");
- fdset = true;
- }
- if (kaa_tcp_channel_is_ready(&self->bootstrap_channel, FD_WRITE)) {
- SNDC_FD_SET(bootstrap_fd, &w_set);
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Bootstrap WRITE set wait");
- fdset = true;
- }
- if (fdset) {
- max_fd = MAX(max_fd, bootstrap_fd);
- SNDC_FD_SET(bootstrap_fd, &x_set);
- }
- }
- if (ops_fd >= 0) {
- fdset = false;
- if (kaa_tcp_channel_is_ready(&self->operations_channel, FD_READ)) {
- SNDC_FD_SET(ops_fd, &r_set);
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Operations READ set wait");
- fdset = true;
- }
- if (kaa_tcp_channel_is_ready(&self->operations_channel, FD_WRITE)) {
- SNDC_FD_SET(ops_fd, &w_set);
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Operations WRITE set wait");
- fdset = true;
- }
- if (fdset) {
- max_fd = MAX(max_fd, ops_fd);
- SNDC_FD_SET(ops_fd, &x_set);
- }
- }
-
- kaa_tcp_channel_get_max_timeout(&self->operations_channel, &timeout);
- self->timeval.tv_sec = timeout;
- if (timeout > self->max_update_time)
- self->timeval.tv_sec = self->max_update_time;
-
- self->timeval.tv_usec = 0;
- sndc_sem_post(&self->logging_semophore);
- int r = sndc_sock_select(max_fd+1,&r_set,&w_set,&x_set,&self->timeval);
- sndc_sem_tryWait(&self->logging_semophore);
- if (r == 0) {
- uint32_t msec = sndc_sys_getTimestamp_msec();
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: timeout (%d) expired",
- self->timeval.tv_sec);
-
- // TODO why is it unused?
- (void)msec;
-
- if (self->bootstrap_state == BOOTSRAP_FINISHED && bootstrap_fd == -1) {
- sndc_printf("Bootstrap channel deinit, Operations channel init %d\n", bootstrap_fd);
- KAA_LOG_INFO(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Bootstrap channel finish processing switching to Operations channel");
- kaa_client_deinit_bootstrap_channel(self);
- kaa_client_init_operations_channel(self);
- }
-
- if (self->bootstrap_channel.context) {
- error_code = kaa_tcp_channel_check_keepalive(&self->bootstrap_channel);
- if (error_code) {
- KAA_LOG_ERROR(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Failed Keepalive Bootstrap(%d) check",
- bootstrap_fd);
- }
- }
- if (self->operations_channel.context) {
- error_code = kaa_tcp_channel_check_keepalive(&self->operations_channel);
- if (error_code) {
- KAA_LOG_ERROR(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Failed Keepalive Operations(%d) check",
- ops_fd);
- }
- }
- } else if (r > 0) {
- sndc_printf("FD SET return %d events\n", r);
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: select() return %d events", r);
- if (bootstrap_fd >= 0) {
- fdset = false;
- if (SNDC_FD_ISSET(bootstrap_fd, &r_set)) {
- fdset = true;
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Read Event Bootstrap(%d)", bootstrap_fd);
- error_code = kaa_tcp_channel_process_event(&self->bootstrap_channel, FD_READ);
- if (error_code) {
- KAA_LOG_ERROR(self->kaa_context->logger,
- error_code,
- "IO LOOP: Failed Read Event Bootstrap(%d)", bootstrap_fd);
- }
- }
- if (fdset)
- r--;
- if (r > 0) {
- fdset = false;
- if (SNDC_FD_ISSET(bootstrap_fd, &w_set)) {
- fdset = true;
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Write Event Bootstrap(%d)", bootstrap_fd);
- error_code = kaa_tcp_channel_process_event(&self->bootstrap_channel, FD_WRITE);
- if (error_code) {
- KAA_LOG_ERROR(self->kaa_context->logger,
- error_code,
- "IO LOOP: Failed Write Event Bootstrap(%d)", bootstrap_fd);
- }
- }
- if (fdset)
- r--;
- }
- if (r > 0) {
- fdset = false;
- if (SNDC_FD_ISSET(bootstrap_fd, &x_set)) {
- fdset = true;
- sndc_printf("Exception Event Bootstrap %d\n", bootstrap_fd);
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Exception Event Bootstrap(%d)", bootstrap_fd);
- error_code = kaa_tcp_channel_process_event(&self->bootstrap_channel, FD_EXCEPTION);
- if (error_code) {
- KAA_LOG_ERROR(self->kaa_context->logger,
- error_code,
- "IO LOOP: Failed Exception Event Bootstrap(%d)", bootstrap_fd);
- }
- }
- if (fdset)
- r--;
- }
- }
- if (r > 0 && ops_fd >= 0) {
- fdset = false;
- if (SNDC_FD_ISSET(ops_fd, &r_set)) {
- fdset = true;
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Read Event Operations(%d)", ops_fd);
- error_code = kaa_tcp_channel_process_event(&self->operations_channel, FD_READ);
- if (error_code) {
- KAA_LOG_ERROR(self->kaa_context->logger,
- error_code,
- "IO LOOP: Failed Read Event Operations(%d)", ops_fd);
- }
- }
- if (fdset)
- r--;
- if (r > 0) {
- fdset = false;
- if (SNDC_FD_ISSET(ops_fd, &w_set)) {
- fdset = true;
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Write Event Operations(%d)", ops_fd);
- error_code = kaa_tcp_channel_process_event(&self->operations_channel, FD_WRITE);
- if (error_code) {
- KAA_LOG_ERROR(self->kaa_context->logger,
- error_code,
- "IO LOOP: Failed Write Event Operations(%d)", ops_fd);
- }
- }
- }
- if (fdset)
- r--;
- if (r > 0) {
- fdset = false;
- if (SNDC_FD_ISSET(ops_fd, &x_set)) {
- fdset = true;
- sndc_printf("Exception Event Operations %d\n", ops_fd);
- KAA_LOG_DEBUG(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Exception Event Operations(%d)", ops_fd);
- error_code = kaa_tcp_channel_process_event(&self->operations_channel, FD_EXCEPTION);
- if (error_code) {
- KAA_LOG_ERROR(self->kaa_context->logger,
- error_code,
- "IO LOOP: Failed Exception Event Operations(%d)", ops_fd);
- }
- }
- }
- }
- } else {
- KAA_LOG_ERROR(self->kaa_context->logger,
- KAA_ERR_BAD_STATE,
- "IO LOOP: Error %d returned from select()", r);
- }
- }
-
- KAA_LOG_INFO(self->kaa_context->logger,
- KAA_ERR_NONE,
- "IO LOOP: Finished.");
-}
-
-
-
-
-/*
- * External API to store/load the Kaa SDK status.
- */
-void ext_status_read(char **buffer, size_t *buffer_size, bool *needs_deallocation)
-{
- econais_ec19d_binary_file_read(KAA_STATUS_STORAGE, buffer, buffer_size, needs_deallocation);
-}
-
-void ext_status_store(const char *buffer, size_t buffer_size)
-{
- econais_ec19d_binary_file_store(KAA_STATUS_STORAGE, buffer, buffer_size);
-}
-
-
-/*
- * External API to retrieve a cryptographic public key.
- */
-void ext_get_endpoint_public_key(char **buffer, size_t *buffer_size, bool *needs_deallocation)
-{
- *buffer = kaa_public_key;
- *buffer_size = kaa_public_key_length;
- *needs_deallocation = false;
-}
-
-
-kaa_error_t kaa_init_security_stuff(void)
-{
- sndc_file_ref_t key_file = sndc_file_open(KAA_KEY_STORAGE, DE_FRDONLY);
-
- if (key_file) {
- sndc_file_seek(key_file, 0, SEEK_END);
- kaa_public_key_length = sndc_file_tell(key_file);
- kaa_public_key = (char*)sndc_mem_calloc(kaa_public_key_length, sizeof(char));
-
- if (kaa_public_key == NULL) {
- sndc_printf("Failed to allocate %u bytes for public key\n", kaa_public_key_length);
- return KAA_ERR_NOMEM;
- }
-
- sndc_file_seek(key_file, 0, SEEK_SET);
- if (sndc_file_read(key_file, kaa_public_key, kaa_public_key_length) == 0) {
- sndc_mem_free(kaa_public_key);
- sndc_printf("Failed to read public key (size %u)\n", kaa_public_key_length);
- return KAA_ERR_INVALID_PUB_KEY;
- }
- sndc_file_close(key_file);
- sndc_printf("Restored public key (size %u)\n", kaa_public_key_length);
- } else {
- sndc_printf("No RSA key file %s found\n", KAA_KEY_STORAGE);
- }
-
- ext_calculate_sha_hash(kaa_public_key, kaa_public_key_length, kaa_public_key_hash);
- sndc_printf("SHA calculated\n");
- return KAA_ERR_NONE;
-}
-
-/*
- * Initializes Kaa log collector.
- */
-static kaa_error_t kaa_log_collector_init(kaa_client_t *kaa_client)
-{
- KAA_RETURN_IF_NIL(kaa_client, KAA_ERR_BADPARAM);
-
- kaa_error_t error_code = ext_unlimited_log_storage_create(
- &kaa_client->log_storage_context,
- kaa_client->kaa_context->logger);
- if (error_code) {
- KAA_LOG_ERROR(kaa_client->kaa_context->logger,
- error_code,
- "Failed to create log storage");
- return error_code;
- }
-
- error_code = ext_log_upload_strategy_create(kaa_client->kaa_context
- ,&kaa_client->log_upload_strategy_context
- , KAA_LOG_UPLOAD_VOLUME_STRATEGY);
-
- if (error_code) {
- KAA_LOG_ERROR(kaa_client->kaa_context->logger,
- error_code,
- "Failed to create log upload strategy");
- return error_code;
- }
-
- error_code = ext_log_upload_strategy_set_threshold_count(kaa_client->log_upload_strategy_context
- , KAA_DEMO_UPLOAD_COUNT_THRESHOLD);
- if (error_code) {
- KAA_LOG_ERROR(kaa_client->kaa_context->logger,
- error_code,
- "Failed to create log upload strategy by volume set threshold count to %d",
- KAA_DEMO_UPLOAD_COUNT_THRESHOLD);
- return error_code;
- }
-
- kaa_log_bucket_constraints_t bucket_sizes = {
- .max_bucket_size = KAA_DEMO_MAX_LOG_BUCKET_SIZE,
- .max_bucket_log_count = KAA_DEMO_MAX_LOGS_IN_BUCKET,
- };
-
- error_code = kaa_logging_init(kaa_client->kaa_context->log_collector
- , kaa_client->log_storage_context
- , kaa_client->log_upload_strategy_context
- , &bucket_sizes);
-
- if (error_code) {
- KAA_LOG_ERROR(kaa_client->kaa_context->logger,
- error_code,
- "Failed to logging init");
- return error_code;
- }
- KAA_LOG_INFO(kaa_client->kaa_context->logger,
- KAA_ERR_NONE,
- "Log collector init complete");
- return error_code;
-
-}
-
-///*
-// * Example code for logging
-// */
-//kaa_error_t kaa_client_log_record(kaa_client_t *kaa_client, const char *record)
-//{
-// if (!kaa_client || !record) {
-// return KAA_ERR_BADPARAM;
-// }
-//
-// kaa_logging_record_t * kaa_record = kaa_logging_record_create();
-// if (!kaa_record) {
-// KAA_LOG_ERROR(kaa_client->kaa_context->logger,
-// KAA_ERR_NOT_INITIALIZED,
-// "Failed to allocate log record");
-// return KAA_ERR_NOT_INITIALIZED;
-// }
-//
-// kaa_record->body = kaa_string_move_create(record, NULL);
-//
-// //Wait until thread sleep in select()
-// sndc_sem_wait(&kaa_client->logging_semophore);
-//
-// kaa_error_t error_code = kaa_logging_add_record(kaa_client->kaa_context->log_collector, kaa_record);
-// if (error_code) {
-// KAA_LOG_ERROR(kaa_client->kaa_context->logger,
-// error_code,
-// "Failed to add log record");
-// }
-//
-// KAA_LOG_DEBUG(kaa_client->kaa_context->logger,
-// KAA_ERR_NONE,
-// "Kaa record %s logged", record);
-//
-// kaa_record->destroy(kaa_record);
-//
-// return KAA_ERR_NONE;
-//}
-
-/**
- * Example code for configuration update
- */
-//kaa_error_t kaa_client_configuration_update(kaa_client_t *kaa_client, const kaa_root_configuration_t *configuration)
-//{
-// if (!kaa_client || !configuration) {
-// return KAA_ERR_BADPARAM;
-// }
-// sndc_printf("New configuration update.... timeout %d\n", configuration->timeout);
-//
-// KAA_LOG_DEBUG(kaa_client->kaa_context->logger,
-// KAA_ERR_NONE,
-// "New configuration update.... timeout %d", configuration->timeout);
-// return KAA_ERR_NONE;
-//}
-
-void ext_write_log(FILE * sink, const char * buffer, size_t message_size)
-{
- if (!buffer) {
- return;
- }
- sndc_printf(buffer);
- sndc_thrd_delay(TRACE_DELAY * SNDC_MILLISECOND);
-}
-
-kaa_time_t ext_get_systime(void)
-{
- return (time_t) sndc_sys_getTimestamp_msec() / 1000;
-}
-
-void print_mem_stat(kaa_client_t *kaa_client)
-{
- if (!kaa_client)
- return;
- sndc_mem_getStats(&kaa_client->mem_stat);
- KAA_LOG_DEBUG(kaa_client->kaa_context->logger,
- KAA_ERR_NONE,
- "Memory: Total(%d)/Allocated(%d)",
- kaa_client->mem_stat.total,
- kaa_client->mem_stat.allocated);
-}
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_kaa_client_properies.h b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_kaa_client_properies.h
deleted file mode 100644
index 20139963ec..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_kaa_client_properies.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * @file econais_ec19d_kaa_client_properies.h
- *
- * Created on: Apr 16, 2015
- * Author: Andriy Panasenko
- */
-
-#ifndef ECONAIS_EC19D_KAA_CLIENT_PROPERIES_H_
-#define ECONAIS_EC19D_KAA_CLIENT_PROPERIES_H_
-
-typedef struct {
- unsigned long max_update_time;
-} kaa_client_props_t;
-
-#endif /* ECONAIS_EC19D_KAA_CLIENT_PROPERIES_H_ */
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_mem.h b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_mem.h
deleted file mode 100644
index c316eb719d..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_mem.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ECONAIS_EC19D_MEM_H_
-#define ECONAIS_EC19D_MEM_H_
-
-#include
-
-#ifndef __KAA_MALLOC
-#define __KAA_MALLOC(S) sndc_mem_malloc(S)
-#endif
-
-#ifndef __KAA_CALLOC
-#define __KAA_CALLOC(N,S) sndc_mem_calloc(N, S)
-#endif
-
-#ifndef __KAA_REALLOC
-#define __KAA_REALLOC(P, S) sndc_mem_realloc(P, S)
-#endif
-
-#ifndef __KAA_FREE
-#define __KAA_FREE(P) sndc_mem_free(P)
-#endif
-
-#endif /* ECONAIS_EC19D_MEM_H_ */
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_platform.h b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_platform.h
deleted file mode 100644
index af1a6d1a0a..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_platform.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- econais_ec19d_platform.h
- Created on: Jan 15, 2015
- Author: Andriy Panasenko
-*/
-
-#ifndef ECONAIS_EC19D_PLATFORM_H_
-#define ECONAIS_EC19D_PLATFORM_H_
-
-#include "sndc_sdk_api.h"
-
-#endif /* ECONAIS_EC19D_PLATFORM_H_ */
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_sock.h b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_sock.h
deleted file mode 100644
index 43047d499e..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_sock.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
-econais_ec19d_sock.h
- Created on: Jan 15, 2015
- Author: Andriy Panasenko
-*/
-
-#ifndef ECONAIS_EC19D_SOCK_H_
-#define ECONAIS_EC19D_SOCK_H_
-
-#include
-#include
-
-typedef int kaa_fd_t;
-
-typedef struct sndc_sockaddr kaa_sockaddr_t;
-typedef struct sndc_sockaddr_in kaa_sockaddr_storage_t;
-typedef sndc_socklen_t kaa_socklen_t;
-
-
-#define KAA_HTONS(hostshort) sndc_htons((hostshort))
-#define KAA_HTONL(hostlong) sndc_htonl((hostlong))
-#define KAA_HTONLL(hostlonglong) kaa_htonll((hostlonglong))
-
-#define KAA_NTOHS(netshort) sndc_ntohs((netshort))
-#define KAA_NTOHL(netlong) sndc_ntohl((netlong))
-#define KAA_NTOHLL(netlonglong) kaa_ntohll((netlonglong))
-
-#endif /* ECONAIS_EC19D_SOCK_H_ */
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_stdio.h b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_stdio.h
deleted file mode 100644
index c81a9e864b..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_stdio.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ECONAIS_EC19D_STDIO_H_
-#define ECONAIS_EC19D_STDIO_H_
-
-#include
-
-#endif /* ECONAIS_EC19D_STDIO_H_ */
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_tcp_utils.c b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_tcp_utils.c
deleted file mode 100644
index 6ca1a11c73..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_tcp_utils.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
-* @file econais_ec19d_tcp_utils.c
-*/
-
-#include
-#include
-#include
-
-#include "platform/sock.h"
-
-#include "platform/ext_tcp_utils.h"
-#include "utilities/kaa_log.h"
-#include "kaa_error.h"
-#include "kaa_common.h"
-
-#define START_BASE_PORT 49500
-#define PORT_RANG 10000
-/* Auxilaury function to get socket error status,
- * which is a socket level option, so set_sock_option is used */
-static kaa_error_t get_sock_error(kaa_fd_t sockid, int *sockerror)
-{
- KAA_RETURN_IF_NIL(sockerror, KAA_ERR_BADPARAM);
- if (sockid < 0)
- return KAA_ERR_BADPARAM;
-
- unsigned int sockerrlen = sizeof(*sockerror);
-
-
- if (sndc_sock_getsockopt(sockid, SNDC_SOL_SOCKET, SNDC_SO_ERROR,
- (void *)sockerror, &sockerrlen) != 0) {
- return KAA_ERR_BADDATA;
- }
-
- return KAA_ERR_NONE;
-}
-
-ext_tcp_utils_function_return_state_t ext_tcp_utils_getaddrbyhost(kaa_dns_resolve_listener_t *resolve_listener
- , const kaa_dns_resolve_info_t *resolve_props
- , kaa_sockaddr_t *result
- , kaa_socklen_t *result_size)
-{
- KAA_RETURN_IF_NIL4(resolve_props, result, result_size, resolve_props->hostname, RET_STATE_VALUE_ERROR);
-
- struct sndc_hostent *hostent;
-
- char hostname_str[resolve_props->hostname_length + 1];
- memcpy(hostname_str, resolve_props->hostname, resolve_props->hostname_length);
- hostname_str[resolve_props->hostname_length] = '\0';
-
- hostent = sndc_dns_gethostbyname(hostname_str);
- KAA_RETURN_IF_NIL(hostent, RET_STATE_VALUE_ERROR);
-
- KAA_RETURN_IF_NIL4(
- hostent->h_name,
- hostent->h_length,
- hostent->h_addr_list,
- *hostent->h_addr_list,
- RET_STATE_VALUE_ERROR);
-
- kaa_sockaddr_storage_t *result_sockaddr = (kaa_sockaddr_storage_t *)result;
- memset(result_sockaddr,0,sizeof(kaa_sockaddr_storage_t));
-
- sndc_in_addr_t *addr = (sndc_in_addr_t *) *hostent->h_addr_list;
-
- result_sockaddr->sin_family = SNDC_AF_INET;
- result_sockaddr->sin_port = sndc_htons(resolve_props->port);
- result_sockaddr->sin_addr.s_addr = *addr;
- result_sockaddr->sin_len = hostent->h_length;
-
- *result_size = sizeof(kaa_sockaddr_storage_t);
-
- return RET_STATE_VALUE_READY;
-}
-
-kaa_error_t ext_tcp_utils_set_sockaddr_port(kaa_sockaddr_t *addr, uint16_t port)
-{
- KAA_RETURN_IF_NIL2(addr,port,KAA_ERR_BADPARAM);
-
- if (addr->sa_family == SNDC_AF_INET) {
- ((struct sndc_sockaddr_in *)addr)->sin_port = sndc_htons(port);
- return KAA_ERR_NONE;
- } else {
- return KAA_ERR_SOCKET_INVALID_FAMILY;
- }
-}
-
-kaa_error_t ext_tcp_utils_open_tcp_socket(kaa_fd_t *fd
- , const kaa_sockaddr_t *destination
- , kaa_socklen_t destination_size)
-{
- KAA_RETURN_IF_NIL3(fd, destination, destination_size, KAA_ERR_BADPARAM);
-
- *fd = -1;
-
- if (destination->sa_family != SNDC_AF_INET) {
- return KAA_ERR_SOCKET_INVALID_FAMILY;
- }
-
- kaa_fd_t sock = sndc_sock_socket(SNDC_PF_INET, SNDC_SOCK_STREAM, SNDC_IPPROTO_TCP);
- if (sock < 0)
- return KAA_ERR_SOCKET_ERROR;
- int status = 0;
- int iteration = 10;
- struct sndc_sockaddr_in bind_sockaddr;
- do {
- memset(&bind_sockaddr, 0, sizeof(bind_sockaddr));
-
- bind_sockaddr.sin_family = SNDC_AF_INET;
- bind_sockaddr.sin_len = sizeof(bind_sockaddr);
- bind_sockaddr.sin_addr.s_addr = SNDC_INADDR_ANY;
-
- uint16_t bind_port = START_BASE_PORT + sndc_sys_getRandom() % PORT_RANG;
- bind_sockaddr.sin_port = sndc_htons(bind_port);
-
- status = sndc_sock_bind(sock, (struct sndc_sockaddr*) &bind_sockaddr, sizeof(bind_sockaddr));
- iteration--;
- } while (status && iteration);
-
- bool_t t = true;
- if (sndc_sock_ioctl(sock, SNDC_FIONBIO, (void *)&t) < 0) {
- ext_tcp_utils_tcp_socket_close(sock);
- return KAA_ERR_SOCKET_ERROR;
- }
-
- if (sndc_sock_fcntl(sock, SNDC_F_SETFL, SNDC_O_NONBLOCK) < 0) {
- ext_tcp_utils_tcp_socket_close(sock);
- return KAA_ERR_SOCKET_ERROR;
- }
-
- status = sndc_sock_connect(sock, destination, destination_size);
-
- if (status) {
- if (get_sock_error(sock, &status)) {
- ext_tcp_utils_tcp_socket_close(sock);
- return KAA_ERR_SOCKET_ERROR;
- }
- if (!(status == EINPROGRESS
- || status == EAGAIN)) {
- sndc_printf("Socket %d connect error %d\n", sock, status);
- ext_tcp_utils_tcp_socket_close(sock);
- return KAA_ERR_SOCKET_CONNECT_ERROR;
- }
- }
- *fd = sock;
- return KAA_ERR_NONE;
-}
-
-ext_tcp_socket_state_t ext_tcp_utils_tcp_socket_check(kaa_fd_t fd
- , const kaa_sockaddr_t *destination
- , kaa_socklen_t destination_size)
-{
- int status = 0;
- kaa_error_t error = get_sock_error(fd, &status);
- if (error) {
- return KAA_TCP_SOCK_ERROR;
- }
- switch (status) {
- case EINPROGRESS:
- case EALREADY:
- return KAA_TCP_SOCK_CONNECTING;
- case 0:
- case EISCONN:
- return KAA_TCP_SOCK_CONNECTED;
- default:
- return KAA_TCP_SOCK_ERROR;
- }
- return KAA_TCP_SOCK_CONNECTED;
-}
-
-ext_tcp_socket_io_errors_t ext_tcp_utils_tcp_socket_write(kaa_fd_t fd
- , const char *buffer
- , size_t buffer_size
- , size_t *bytes_written)
-{
- KAA_RETURN_IF_NIL2(buffer, buffer_size, KAA_TCP_SOCK_IO_ERROR);
- int write_result = sndc_sock_write(fd, (void *)buffer, buffer_size);
- if (write_result < 0) {
- int status = 0;
- kaa_error_t error = get_sock_error(fd, &status);
- KAA_RETURN_IF_ERR(error);
- if (status != EAGAIN)
- return KAA_TCP_SOCK_IO_ERROR;
- }
- if (bytes_written)
- *bytes_written = (write_result > 0) ? write_result : 0;
- return KAA_TCP_SOCK_IO_OK;
-}
-
-ext_tcp_socket_io_errors_t ext_tcp_utils_tcp_socket_read(kaa_fd_t fd
- , char *buffer
- , size_t buffer_size
- , size_t *bytes_read)
-{
- KAA_RETURN_IF_NIL2(buffer, buffer_size, KAA_TCP_SOCK_IO_ERROR);
- int read_result = sndc_sock_read(fd, buffer, buffer_size);
- if (!read_result)
- return KAA_TCP_SOCK_IO_EOF;
- if (read_result < 0) {
- int status = 0;
- kaa_error_t error = get_sock_error(fd, &status);
- KAA_RETURN_IF_ERR(error);
- if (status != EAGAIN)
- return KAA_TCP_SOCK_IO_ERROR;
- }
- if (bytes_read)
- *bytes_read = (read_result > 0) ? read_result : 0;
- return KAA_TCP_SOCK_IO_OK;
-}
-
-
-
-kaa_error_t ext_tcp_utils_tcp_socket_close(kaa_fd_t fd)
-{
- return (sndc_sock_close(fd) < 0) ? KAA_ERR_SOCKET_ERROR : KAA_ERR_NONE;
-}
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_time.h b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_time.h
deleted file mode 100644
index cadb39ba53..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/econais_ec19d_time.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef ECONAIS_EC19D_TIME_H_
-#define ECONAIS_EC19D_TIME_H_
-
-typedef uint32_t kaa_time_t;
-
-kaa_time_t ext_get_systime(void);
-
-#define KAA_TIME() ext_get_systime()
-
-#endif /* ECONAIS_EC19D_TIME_H_ */
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/filelist.mak b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/filelist.mak
deleted file mode 100644
index 28627e9d9f..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/filelist.mak
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright 2014-2015 CyberVision, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-
-CFILES-ECONAIS-PLAT = kaa/platform-impl/Econais/EC19D/econais_ec19d_kaa_client.c kaa/platform-impl/Econais/EC19D/__ashldi3.c kaa/platform-impl/Econais/EC19D/logger.c kaa/platform-impl/Econais/EC19D/sha.c kaa/platform-impl/Econais/EC19D/econais_ec19d_tcp_utils.c kaa/platform-impl/Econais/EC19D/econais_ec19d_file_utils.c kaa/platform-impl/Econais/EC19D/econais_ec19d_configuration_persistence.c
-CFILES-PLAT-IMPL = kaa/platform-impl/common/ext_log_storage_memory.c kaa/platform-impl/common/ext_log_upload_strategies.c kaa/platform-impl/common/kaa_failover_strategy.c kaa/platform-impl/common/kaa_tcp_channel.c kaa/platform-impl/common/kaa_htonll.c
-CFILES-PROTO = kaa/kaa_protocols/kaa_tcp/kaatcp_parser.c kaa/kaa_protocols/kaa_tcp/kaatcp_request.c
-CFILES-AVRO = kaa/avro_src/io.c kaa/avro_src/encoding_binary.c
-CFILES-COLLECTIONS = kaa/collections/kaa_list.c
-CFILES-UTIL = kaa/utilities/kaa_log.c kaa/utilities/kaa_mem.c kaa/utilities/kaa_buffer.c
-CFILES-GEN = kaa/gen/kaa_logging_gen.c kaa/gen/kaa_profile_gen.c kaa/gen/kaa_configuration_gen.c kaa/gen/kaa_notification_gen.c
-
-CFILES-KAA = $(CFILES-ECONAIS-PLAT) $(CFILES-PLAT-IMPL) $(CFILES-PROTO) $(CFILES-AVRO) $(CFILES-COLLECTIONS) $(CFILES-GEN) $(CFILES-UTIL) kaa/kaa.c kaa/kaa_common_schema.c kaa/kaa_logging.c kaa/kaa_status.c kaa/kaa_channel_manager.c kaa/kaa_platform_utils.c kaa/kaa_bootstrap_manager.c kaa/kaa_event.c kaa/kaa_platform_protocol.c kaa/kaa_profile.c kaa/kaa_user.c kaa/kaa_configuration_manager.c kaa/kaa_notification_manager.c
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/logger.c b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/logger.c
deleted file mode 100644
index 78924d7320..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/logger.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include
-
-#include "econais_ec19d_time.h"
-#include "platform/ext_system_logger.h"
-
-
-
-//void cext_write_log(FILE * sink, const char * buffer, size_t message_size)
-//{
-// if (!buffer) {
-// return;
-// }
-// sndc_printf(buffer);
-//}
-
-//time_t ext_get_systime()
-//{
-// return (time_t) sndc_sys_getTimestamp_msec();
-//}
-
-int ext_format_sprintf(char * buffer, size_t buffer_size, const char * format,
- const char * log_level_name, const char * truncated_name, int lineno,
- kaa_error_t error_code)
-{
- time_t t = ext_get_systime();
- struct tm* tp = gmtime(&t);
-
- return snprintf(buffer, buffer_size, format, 1900 + tp->tm_year,
- tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec,
- log_level_name, truncated_name, lineno, error_code);
-}
-
-int ext_snpintf(char * buffer, size_t buffer_size, const char * format, ...)
-{
- va_list args;
- va_start(args, format);
- int res_len = ext_logger_sprintf(buffer, buffer_size, format, args);
- va_end(args);
- return res_len;
-}
-
-typedef enum {
- DEFAULT, PERCENT_FIRST_FOUND, PERCENT_FOUND
-} sprintfState;
-typedef char* char_p;
-typedef void* void_p;
-typedef unsigned int uint;
-typedef long int longInt;
-typedef long long int longLongInt;
-typedef long unsigned int uLongInt;
-typedef long long unsigned int uLongLongInt;
-
-#define _INT_SPRINTF(type) \
- type carg = (type)va_arg(args, type); \
- int cp = snprintf(buffer_p, buffer_size_l, p_format, carg); \
- res_len += cp; \
- buffer_p += cp; \
- if (buffer_size_l <= cp) { \
- buffer_size_l = 0; \
- no_more_space_in_buffer = true; \
- } else { \
- buffer_size_l -= cp; \
- } \
- last_format = p + 1; \
- sndc_mem_free(p_format); \
- percent_pos = NULL; \
- state = DEFAULT;
-
-#define SPRNTF(type) \
- size_t p_format_size = (p - last_format)+2; \
- char *p_format = sndc_mem_malloc(p_format_size); \
- if (p_format == NULL) { \
- no_more_space_in_buffer = true; \
- break; \
- } \
- strncpy(p_format,last_format,p_format_size-1);\
- _INT_SPRINTF(type)
-
-#define SPRINTF_SUBST(type,symbols) \
- size_t formated_size = percent_pos - last_format; \
- size_t symbols_size = strlen(symbols); \
- size_t p_format_size = formated_size + symbols_size +2;\
- char *p_format = sndc_mem_malloc(p_format_size); \
- if (p_format == NULL) { \
- no_more_space_in_buffer = true; \
- break; \
- } \
- strncpy(p_format,last_format,formated_size);\
- strncpy(p_format + formated_size, symbols, symbols_size); \
- _INT_SPRINTF(type)
-
-int ext_logger_sprintf(char * buffer, size_t buffer_size, const char * format, va_list args)
-{
- int format_length = strnlen(format, buffer_size);
- int i = 0, res_len = 0;
- const char *zu_symbols = "%lu";
- const char *p_symbols = "0x%08X";
- char *p = (char *) format;
- char ch = *p;
- char *last_format = p;
- char *buffer_p = buffer;
- char *percent_pos = NULL;
- size_t buffer_size_l = buffer_size;
- bool_t no_more_space_in_buffer = false;
- sprintfState state = DEFAULT;
- bool_t longUsed = false;
- bool_t doubleLongUsed = false;
- bool_t zuFound = false;
- for (i = 0; i < format_length; i++) {
- ch = *p;
- switch (state) {
- case PERCENT_FIRST_FOUND:
- if (ch == '%') {
- //%% in format
- state = DEFAULT;
- break;
- }
- state = PERCENT_FOUND;
- case PERCENT_FOUND:
- if (ch == 'd') {
- //found correct integer
- if (doubleLongUsed) {
- SPRNTF(longLongInt);
- } else if (longUsed) {
- SPRNTF(longInt);
- } else {
- SPRNTF(int);
- }
- } else if (ch == 'u' || ch == 'x' || ch == 'X') {
- //found unsigned integer
- if (doubleLongUsed) {
- SPRNTF(uLongLongInt);
- } else if (longUsed) {
- SPRNTF(uLongInt);
- } else if (zuFound) {
- SPRINTF_SUBST(uLongInt, zu_symbols);
- } else {
- SPRNTF(uint);
- }
- } else if (ch == 's') {
- //found char *
- SPRNTF(char_p);
- } else if (ch == 'z') {
- zuFound = true;
- } else if (ch == 'p') {
- SPRINTF_SUBST(void_p, p_symbols);
- } else if (ch == 'l') {
- if (longUsed) {
- doubleLongUsed = true;
- } else {
- longUsed = true;
- }
- }
- break;
- default:
- if (ch == '%') {
- state = PERCENT_FIRST_FOUND;
- percent_pos = p;
- }
- break;
- }
- p++;
- if (no_more_space_in_buffer)
- break;
- }
- if (!no_more_space_in_buffer) {
- if (p >= last_format) {
- //Need to copy least bytes from format
- size_t tocopy = buffer_size_l;
- if (tocopy > (p - last_format)) {
- tocopy = p - last_format;
- }
- strncpy(buffer_p, last_format, tocopy);
- res_len += tocopy;
- }
- }
- return res_len;
-}
diff --git a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/sha.c b/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/sha.c
deleted file mode 100644
index 57ce15d62d..0000000000
--- a/client/client-multi/client-c/src/kaa/platform-impl/Econais/EC19D/sha.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2014-2016 CyberVision, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include