Home | History | Annotate | Download | only in protocol
      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.
      4 //
      5 // MCS protocol for communication between Chrome client and Mobile Connection
      6 // Server .
      7 
      8 syntax = "proto2";
      9 
     10 option optimize_for = LITE_RUNTIME;
     11 option retain_unknown_fields = true;
     12 
     13 package mcs_proto;
     14 
     15 /*
     16    Common fields/comments:
     17 
     18     stream_id: no longer sent by server, each side keeps a counter
     19     last_stream_id_received: sent only if a packet was received since last time
     20     a last_stream was sent
     21     status: new bitmask including the 'idle' as bit 0.
     22 
     23  */
     24 
     25 /**
     26   TAG: 0
     27   */
     28 message HeartbeatPing {
     29   optional int32 stream_id = 1;
     30   optional int32 last_stream_id_received = 2;
     31   optional int64 status = 3;
     32 }
     33 
     34 /**
     35   TAG: 1
     36   */
     37 message HeartbeatAck {
     38   optional int32 stream_id = 1;
     39   optional int32 last_stream_id_received = 2;
     40   optional int64 status = 3;
     41 }
     42 
     43 message ErrorInfo {
     44   required int32 code = 1;
     45   optional string message = 2;
     46   optional string type = 3;
     47   optional  Extension extension = 4;
     48 }
     49 
     50 // MobileSettings class.
     51 // "u:f", "u:b", "u:s" - multi user devices reporting foreground, background
     52 // and stopped users.
     53 // hbping: heatbeat ping interval
     54 // rmq2v: include explicit stream IDs
     55 
     56 message Setting {
     57   required string name = 1;
     58   required string value = 2;
     59 }
     60 
     61 message HeartbeatStat {
     62   required string ip = 1;
     63   required bool timeout = 2;
     64   required int32 interval_ms = 3;
     65 }
     66 
     67 message HeartbeatConfig {
     68   optional bool upload_stat = 1;
     69   optional string ip = 2;
     70   optional int32 interval_ms = 3;
     71 }
     72 
     73 /**
     74   TAG: 2
     75   */
     76 message LoginRequest {
     77   enum AuthService {
     78     ANDROID_ID = 2;
     79   }
     80   required string id = 1; // Must be present ( proto required ), may be empty
     81                           // string.
     82   // mcs.android.com.
     83   required string domain = 2;
     84   // Decimal android ID
     85   required string user = 3;
     86 
     87   required string resource = 4;
     88 
     89   // Secret
     90   required string auth_token = 5;
     91 
     92   // Format is: android-HEX_DEVICE_ID
     93   // The user is the decimal value.
     94   optional string device_id = 6;
     95 
     96   // RMQ1 - no longer used
     97   optional int64 last_rmq_id = 7;
     98 
     99   repeated Setting setting = 8;
    100   //optional int32 compress = 9;
    101   repeated string received_persistent_id = 10;
    102 
    103   // Replaced by "rmq2v" setting
    104   // optional bool include_stream_ids = 11;
    105 
    106   optional bool adaptive_heartbeat = 12;
    107   optional HeartbeatStat heartbeat_stat = 13;
    108   // Must be true.
    109   optional bool use_rmq2 = 14;
    110   optional int64 account_id = 15;
    111 
    112   // ANDROID_ID = 2
    113   optional AuthService auth_service = 16;
    114 
    115   optional int32 network_type = 17;
    116   optional int64 status = 18;
    117 }
    118 
    119 /**
    120   * TAG: 3
    121   */
    122 message LoginResponse {
    123   required string id = 1;
    124   // Not used.
    125   optional string jid = 2;
    126   // Null if login was ok.
    127   optional ErrorInfo error = 3;
    128   repeated Setting setting = 4;
    129   optional int32 stream_id = 5;
    130   // Should be "1"
    131   optional int32 last_stream_id_received = 6;
    132   optional HeartbeatConfig heartbeat_config = 7;
    133   // used by the client to synchronize with the server timestamp.
    134   optional int64 server_timestamp = 8;
    135 }
    136 
    137 message StreamErrorStanza {
    138   required string type = 1;
    139   optional string text = 2;
    140 }
    141 
    142 /**
    143   * TAG: 4
    144   */
    145 message Close {
    146 }
    147 
    148 message Extension {
    149   // 12: SelectiveAck
    150   // 13: StreamAck
    151   required int32 id = 1;
    152   required bytes data = 2;
    153 }
    154 
    155 /**
    156   * TAG: 7
    157   * IqRequest must contain a single extension.  IqResponse may contain 0 or 1
    158   * extensions.
    159   */
    160 message IqStanza {
    161   enum IqType {
    162     GET = 0;
    163     SET = 1;
    164     RESULT = 2;
    165     IQ_ERROR = 3;
    166   }
    167 
    168   optional int64 rmq_id = 1;
    169   required IqType type = 2;
    170   required string id = 3;
    171   optional string from = 4;
    172   optional string to = 5;
    173   optional ErrorInfo error = 6;
    174 
    175   // Only field used in the 38+ protocol (besides common last_stream_id_received, status, rmq_id)
    176   optional Extension extension = 7;
    177 
    178   optional string persistent_id = 8;
    179   optional int32 stream_id = 9;
    180   optional int32 last_stream_id_received = 10;
    181   optional int64 account_id = 11;
    182   optional int64 status = 12;
    183 }
    184 
    185 message AppData {
    186   required string key = 1;
    187   required string value = 2;
    188 }
    189 
    190 /**
    191  * TAG: 8
    192  */
    193 message DataMessageStanza {
    194   // Not used.
    195   // optional int64 rmq_id = 1;
    196 
    197   // This is the message ID, set by client, DMP.9 (message_id)
    198   optional string id = 2;
    199 
    200   // Project ID of the sender, DMP.1
    201   required string from = 3;
    202 
    203   // Part of DMRequest - also the key in DataMessageProto.
    204   optional string to = 4;
    205 
    206   // Package name. DMP.2
    207   required string category = 5;
    208 
    209   // The collapsed key, DMP.3
    210   optional string token = 6;
    211 
    212   // User data + GOOGLE. prefixed special entries, DMP.4
    213   repeated AppData app_data = 7;
    214 
    215   // Not used.
    216   optional bool from_trusted_server = 8;
    217 
    218   // Part of the ACK protocol, returned in DataMessageResponse on server side.
    219   // It's part of the key of DMP.
    220   optional string persistent_id = 9;
    221 
    222   // In-stream ack. Increments on each message sent - a bit redundant
    223   // Not used in DMP/DMR.
    224   optional int32 stream_id = 10;
    225   optional int32 last_stream_id_received = 11;
    226 
    227   // Not used.
    228   // optional string permission = 12;
    229 
    230   // Sent by the device shortly after registration.
    231   optional string reg_id = 13;
    232 
    233   // Not used.
    234   // optional string pkg_signature = 14;
    235   // Not used.
    236   // optional string client_id = 15;
    237 
    238   // serial number of the target user, DMP.8
    239   // It is the 'serial number' according to user manager.
    240   optional int64 device_user_id = 16;
    241 
    242   // Time to live, in seconds.
    243   optional int32 ttl = 17;
    244   // Timestamp ( according to client ) when message was sent by app, in seconds
    245   optional int64 sent = 18;
    246 
    247   // How long has the message been queued before the flush, in seconds.
    248   // This is needed to account for the time difference between server and
    249   // client: server should adjust 'sent' based on his 'receive' time.
    250   optional int32 queued = 19;
    251 
    252   optional int64 status = 20;
    253 }
    254 
    255 /**
    256   Included in IQ with ID 13, sent from client or server after 10 unconfirmed
    257   messages.
    258  */
    259 message StreamAck {
    260   // No last_streamid_received required.  This is included within an IqStanza,
    261   // which includes the last_stream_id_received.
    262 }
    263 
    264 /**
    265   Included in IQ sent after LoginResponse from server with ID 12.
    266 */
    267 message SelectiveAck {
    268   repeated string id = 1;
    269 }
    270