1 /* 2 Copyright (C) 2009 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 MAIN_CHANNEL_H_ 19 #define MAIN_CHANNEL_H_ 20 21 #include <stdint.h> 22 #include <spice/vd_agent.h> 23 #include <common/marshaller.h> 24 25 #include "red-channel.h" 26 27 #include "push-visibility.h" 28 29 // TODO: Defines used to calculate receive buffer size, and also by reds.c 30 // other options: is to make a reds_main_consts.h, to duplicate defines. 31 #define REDS_AGENT_WINDOW_SIZE 10 32 #define REDS_NUM_INTERNAL_AGENT_MESSAGES 1 33 34 struct RedsMigSpice { 35 char *host; 36 char *cert_subject; 37 int port; 38 int sport; 39 }; 40 41 struct MainChannel; 42 43 red::shared_ptr<MainChannel> main_channel_new(RedsState *reds); 44 45 /* This is a 'clone' from the reds.h Channel.link callback to allow passing link_id */ 46 MainChannelClient *main_channel_link(MainChannel *, RedClient *client, 47 RedStream *stream, uint32_t link_id, int migration, 48 RedChannelCapabilities *caps); 49 50 struct MainChannel final: public RedChannel 51 { 52 RedClient *get_client_by_link_id(uint32_t link_id); 53 void push_mouse_mode(SpiceMouseMode current_mode, int is_client_mouse_allowed); 54 void push_agent_connected(); 55 void push_agent_disconnected(); 56 void push_multi_media_time(uint32_t time); 57 /* tell MainChannel we have a new channel ready */ 58 void registered_new_channel(RedChannel *channel); 59 60 /* switch host migration */ 61 void migrate_switch(RedsMigSpice *mig_target); 62 63 /* semi seamless migration */ 64 65 /* returns the number of clients that we are waiting for their connection. 66 * try_seamless = 'true' when the seamless-migration=on in qemu command line */ 67 int migrate_connect(RedsMigSpice *mig_target, int try_seamless); 68 void migrate_cancel_wait(); 69 const RedsMigSpice* get_migration_target(); 70 /* returns the number of clients for which SPICE_MSG_MAIN_MIGRATE_END was sent*/ 71 int migrate_src_complete(int success); 72 void on_migrate_connected(gboolean success, gboolean seamless); 73 74 MainChannel(RedsState *reds); 75 on_connectfinal76 void on_connect(RedClient *client, RedStream *stream, int migration, 77 RedChannelCapabilities *caps) override {}; 78 79 // TODO: add refs and release (after all clients completed migration in one way or the other?) 80 RedsMigSpice mig_target; 81 int num_clients_mig_wait; 82 }; 83 84 #include "pop-visibility.h" 85 86 #endif /* MAIN_CHANNEL_H_ */ 87