1 /* 2 Copyright (C) 2009-2016 Red Hat, Inc. 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with this library; if not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef COMMON_GRAPHICS_CHANNEL_H_ 19 #define COMMON_GRAPHICS_CHANNEL_H_ 20 21 #include "red-channel.h" 22 #include "red-channel-client.h" 23 24 #include "push-visibility.h" 25 26 #define COMMON_CLIENT_TIMEOUT (NSEC_PER_SEC * 30) 27 28 class CommonGraphicsChannel: public RedChannel 29 { 30 public: get_during_target_migrate()31 bool get_during_target_migrate() const 32 { 33 return during_target_migrate; 34 } 35 set_during_target_migrate(bool value)36 void set_during_target_migrate(bool value) 37 { 38 during_target_migrate = value; 39 } 40 protected: 41 using RedChannel::RedChannel; 42 43 private: 44 bool during_target_migrate = false; /* TRUE when the client that is associated with the channel 45 is during migration. Turned off when the vm is started. 46 The flag is used to avoid sending messages that are artifacts 47 of the transition from stopped vm to loaded vm (e.g., recreation 48 of the primary surface) */ 49 }; 50 51 enum { 52 RED_PIPE_ITEM_TYPE_INVAL_ONE = RED_PIPE_ITEM_TYPE_CHANNEL_BASE, 53 54 RED_PIPE_ITEM_TYPE_COMMON_LAST 55 }; 56 57 class CommonGraphicsChannelClient: public RedChannelClient 58 { 59 enum { CHANNEL_RECEIVE_BUF_SIZE = 1024 }; 60 uint8_t recv_buf[CHANNEL_RECEIVE_BUF_SIZE]; 61 62 public: 63 using RedChannelClient::RedChannelClient; 64 65 protected: 66 virtual uint8_t *alloc_recv_buf(uint16_t type, uint32_t size) override; 67 virtual void release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg) override; 68 virtual bool config_socket() override; 69 }; 70 71 /* pipe item used to release a specific cached item on the client */ 72 struct RedCachePipeItem final: public RedPipeItemNum<RED_PIPE_ITEM_TYPE_INVAL_ONE> { 73 SpiceMsgDisplayInvalOne inval_one; 74 }; 75 76 #include "pop-visibility.h" 77 78 #endif /* COMMON_GRAPHICS_CHANNEL_H_ */ 79