client-cpp  0.6.3
MetaDataTransport.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef METADATATRANSPORT_HPP_
18 #define METADATATRANSPORT_HPP_
19 
20 #include <vector>
21 #include <algorithm>
22 
23 #include "kaa/KaaDefaults.hpp"
28 
29 namespace kaa {
30 
32 public:
34  : clientStatus_(status), publicKeyHash_(keyHash), timeout_(timeout) {}
35 
36  std::shared_ptr<SyncRequestMetaData> createSyncRequestMetaData() {
37  std::shared_ptr<SyncRequestMetaData> request(new SyncRequestMetaData);
38 
39  request->applicationToken = APPLICATION_TOKEN;
40  request->endpointPublicKeyHash.set_bytes(publicKeyHash_);
41 
42  SharedDataBuffer buffer = clientStatus_->getProfileHash();
43 
44  std::vector<std::uint8_t> profileHash;
45  profileHash.reserve(buffer.second);
46 
47  for (size_t i = 0; i < buffer.second; ++i) {
48  profileHash.push_back(buffer.first[i]);
49  }
50 
51  request->profileHash.set_bytes(profileHash);
52 
53  request->timeout.set_long(timeout_);
54 
55  return request;
56  }
57 
58 private:
59  IKaaClientStateStoragePtr clientStatus_;
60  EndpointObjectHash publicKeyHash_;
61  long timeout_;
62 };
63 
64 } // namespace kaa
65 
66 
67 #endif /* METADATATRANSPORT_HPP_ */
std::shared_ptr< SyncRequestMetaData > createSyncRequestMetaData()
std::shared_ptr< IKaaClientStateStorage > IKaaClientStateStoragePtr
const char *const APPLICATION_TOKEN
MetaDataTransport(IKaaClientStateStoragePtr status, EndpointObjectHash &keyHash, long timeout)
std::pair< boost::shared_array< std::uint8_t >, std::uint32_t > SharedDataBuffer