1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Utility methods for MCS interactions.
7 #ifndef GOOGLE_APIS_GCM_BASE_MCS_UTIL_H_
8 #define GOOGLE_APIS_GCM_BASE_MCS_UTIL_H_
12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "google_apis/gcm/base/gcm_export.h"
16 #include "google_apis/gcm/protocol/mcs.pb.h"
25 // WARNING: the order of these tags must remain the same, as the tag values
26 // must be consistent with those used on the server.
28 kHeartbeatPingTag = 0,
36 kDataMessageStanzaTag,
37 kBatchPresenceStanzaTag,
38 kStreamErrorStanzaTag,
41 kBindAccountRequestTag,
42 kBindAccountResponseTag,
47 enum MCSIqStanzaExtension {
52 // Builds a LoginRequest with the hardcoded local data.
53 GCM_EXPORT scoped_ptr<mcs_proto::LoginRequest> BuildLoginRequest(
57 // Builds a StreamAck IqStanza message.
58 GCM_EXPORT scoped_ptr<mcs_proto::IqStanza> BuildStreamAck();
60 // Utility methods for building and identifying MCS protobufs.
61 GCM_EXPORT scoped_ptr<google::protobuf::MessageLite>
62 BuildProtobufFromTag(uint8 tag);
63 GCM_EXPORT int GetMCSProtoTag(const google::protobuf::MessageLite& message);
65 // RMQ utility methods for extracting/setting common data from/to protobufs.
66 GCM_EXPORT std::string GetPersistentId(
67 const google::protobuf::MessageLite& message);
68 GCM_EXPORT void SetPersistentId(
69 const std::string& persistent_id,
70 google::protobuf::MessageLite* message);
71 GCM_EXPORT uint32 GetLastStreamIdReceived(
72 const google::protobuf::MessageLite& protobuf);
73 GCM_EXPORT void SetLastStreamIdReceived(
74 uint32 last_stream_id_received,
75 google::protobuf::MessageLite* protobuf);
79 #endif // GOOGLE_APIS_GCM_BASE_MCS_UTIL_H_