Home | History | Annotate | Download | only in message
      1 // Copyright 2012 Google Inc. All Rights Reserved.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #ifndef POLO_PAIRING_MESSAGE_OPTIONSMESSAGE_H_
     16 #define POLO_PAIRING_MESSAGE_OPTIONSMESSAGE_H_
     17 
     18 #include <set>
     19 #include <string>
     20 #include "polo/encoding/encodingoption.h"
     21 #include "polo/pairing/message/polomessage.h"
     22 
     23 namespace polo {
     24 namespace pairing {
     25 namespace message {
     26 
     27 // A message containing the Polo pairing options.
     28 class OptionsMessage : public PoloMessage {
     29  public:
     30   // The device role. The display device will be responsible for displaying
     31   // a secret code, and the user will enter the secret on the input device.
     32   enum ProtocolRole {
     33     kUnknown = 0,
     34     kInputDevice = 1,
     35     kDisplayDevice = 2,
     36   };
     37 
     38   // Creates an empty options message. The supported encodings and protocol
     39   // role preference should be set before sending this message.
     40   OptionsMessage();
     41 
     42   // Adds a supported input encoding.
     43   void AddInputEncoding(const encoding::EncodingOption& encoding);
     44 
     45   // Adds a supported output encoding.
     46   void AddOutputEncoding(const encoding::EncodingOption& encoding);
     47 
     48   // Determines whether the given input encoding is supported.
     49   bool SupportsInputEncoding(
     50       const encoding::EncodingOption& encoding) const;
     51 
     52   // Determines whether the given output encoding is supported.
     53   bool SupportsOutputEncoding(
     54       const encoding::EncodingOption& encoding) const;
     55 
     56   // Sets the protocol role preference.
     57   void set_protocol_role_preference(ProtocolRole preference);
     58 
     59   // Gets the protocol role preference.
     60   ProtocolRole protocol_role_preference() const;
     61 
     62   // Gets the set of supported input encodings.
     63   const encoding::EncodingOption::EncodingSet& input_encodings() const;
     64 
     65   // Gets the set of supported output encodings.
     66   const encoding::EncodingOption::EncodingSet& output_encodings() const;
     67 
     68   // @override
     69   virtual std::string ToString() const;
     70 
     71  private:
     72   ProtocolRole protocol_role_preference_;
     73   encoding::EncodingOption::EncodingSet input_encodings_;
     74   encoding::EncodingOption::EncodingSet output_encodings_;
     75 
     76   DISALLOW_COPY_AND_ASSIGN(OptionsMessage);
     77 };
     78 
     79 }  // namespace message
     80 }  // namespace pairing
     81 }  // namespace polo
     82 
     83 #endif  // POLO_PAIRING_MESSAGE_OPTIONSMESSAGE_H_
     84