1 // Copyright 2010-2018, Google Inc. 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions are 6 // met: 7 // 8 // * Redistributions of source code must retain the above copyright 9 // notice, this list of conditions and the following disclaimer. 10 // * Redistributions in binary form must reproduce the above 11 // copyright notice, this list of conditions and the following disclaimer 12 // in the documentation and/or other materials provided with the 13 // distribution. 14 // * Neither the name of Google Inc. nor the names of its 15 // contributors may be used to endorse or promote products derived from 16 // this software without specific prior written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30 // The abstraction of Session class. 31 32 #ifndef MOZC_SESSION_SESSION_INTERFACE_H_ 33 #define MOZC_SESSION_SESSION_INTERFACE_H_ 34 35 #include "base/port.h" 36 #include "protocol/config.pb.h" 37 38 namespace mozc { 39 40 namespace commands { 41 class ApplicationInfo; 42 class Capability; 43 class Command; 44 class Request; 45 } // namespace commands 46 47 namespace composer { 48 class Table; 49 } // namespace composer 50 51 namespace session { 52 class SessionInterface { 53 public: ~SessionInterface()54 virtual ~SessionInterface() {} 55 56 virtual bool SendKey(commands::Command *command) = 0; 57 58 // Check if the input key event will be consumed by the session. 59 virtual bool TestSendKey(commands::Command *command) = 0; 60 61 // Perform the SEND_COMMAND command defined commands.proto. 62 virtual bool SendCommand(commands::Command *command) = 0; 63 64 virtual void SetConfig(config::Config *config) = 0; 65 66 // Set Request. Currently, this is especial for session::Session. SetRequest(const commands::Request * request)67 virtual void SetRequest(const commands::Request *request) {} 68 69 // Set composition Table. Currently, this is especial for session::Session. SetTable(const composer::Table * table)70 virtual void SetTable(const composer::Table *table) {} 71 72 // Set client capability for this session. Used by unittest. 73 virtual void set_client_capability( 74 const commands::Capability &capability) = 0; 75 76 // Set application information for this session. 77 virtual void set_application_info(const commands::ApplicationInfo 78 &application_info) = 0; 79 80 // Get application information 81 virtual const commands::ApplicationInfo &application_info() const = 0; 82 83 // Return the time when this instance was created. 84 virtual uint64 create_session_time() const = 0; 85 86 // return 0 (default value) if no command is executed in this session. 87 virtual uint64 last_command_time() const = 0; 88 }; 89 90 } // namespace session 91 } // namespace mozc 92 93 #endif // MOZC_SESSION_SESSION_INTERFACE_H_ 94