2 * Copyright (C) 2011 Lukáš Karas <lukas.karas@centrum.cz>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 import org.makneto 0.1 as Makneto
26 property bool fullscreen: false;
27 property int sessionWidth : sessionScene.width;
28 //property variant sessionModel: {};
29 property variant sessionId
31 signal whiteboardMessageReceived(string data, string contact)
32 signal textMessageReceived(string text, string contact)
33 signal chatStateChanged(variant chatState, string contact);
34 signal messageSent(string content);
37 console.log("II [SessionScene.qml]: "+msg);
40 console.log("EE [SessionScene.qml]: "+msg);
43 console.log("WW [SessionScene.qml]: "+msg);
45 function setSessionsModel(model){
46 chatWidget.sendMessage.connect(model.sendTextMessage);
47 chatWidget.changeChatState.connect(model.changeChatState);
48 boardComponent.sendWbMessage.connect(model.sendWhiteboardMessage);
49 sessionToolbar.requestCall.connect(model.startCall);
50 sessionToolbar.requestHangup.connect(model.hangup);
52 // initial setup sessin type
53 sessionTypeChanged(model.getSessionType(sessionId));
56 function sessionTypeChanged(type){
57 log("session type changed "+type+" (audio: "+Makneto.Session.SessionTypeAudio+", video: "+Makneto.Session.SessionTypeVideo+")")
58 setAudioCall( (type & Makneto.Session.SessionTypeAudio) !==0 );
59 setVideoCall( (type & Makneto.Session.SessionTypeVideo) !==0 );
65 height: parent.height * 0.6
66 width: parent.width * 0.6
72 height: boardComponent.height
73 anchors{ top: parent.top; right: parent.right; left: board.right }
78 anchors{top: boardComponent.bottom; right: parent.right; bottom: parent.bottom; left: parent.left}
86 Component.onCompleted:{
88 whiteboardMessageReceived.connect(boardComponent.whiteboardMessageReceived);
89 whiteboardMessageReceived.connect( function(data, contact){
90 if (!sessionScene.board){
94 messageSent.connect(boardComponent.messageSent);
95 textMessageReceived.connect(chatWidget.textMessageReceived);
96 chatStateChanged.connect(chatWidget.chatStateChanged);
97 //textMessageReceived("text", "contact");
107 // hack for nonfunctional clip property for WebView
108 boardComponent.hideWebView( (state !== "center") );
111 function updateLayout(){
113 if ((!videoCall) && videoComponent.state != "normal")
114 videoComponent.state = "normal";
115 if ((!board) && boardComponent.state != "normal")
116 boardComponent.state = "normal";
118 if (videoComponent.state == "fullscreen")
119 boardComponent.state = "normal";
122 sessionWidth = sessionScene.width;
124 // compute dimensions
125 var boardHeight = (board || videoCall)? sessionScene.height * 0.6: 0;
126 var videoHeight = boardHeight;
128 var boardWidth = board? (videoCall? sessionWidth * 0.6 : sessionWidth): 0;
129 var videoWidth = (sessionWidth - boardWidth);
132 boardComponent.z = (!board)? -1 : (boardComponent.state == "fullscreen"? 100: 0);
133 videoComponent.z = (!videoCall)? -1 : (videoComponent.state == "fullscreen"? 100: 0);
136 boardComponent.opacity = board? 1:0;
137 videoComponent.opacity = videoCall? 1:0;
140 fullscreen = (videoComponent.state == "fullscreen" || boardComponent.state == "fullscreen");
141 //main.getStageController().fullScreen( fullScreen );
143 main.getLeftPanel().state = "hided";
148 log("update layout {board:"+board+", videoCall:"+videoCall+"}");
149 log("board: "+boardWidth+"x"+boardHeight+" video: "+videoWidth+"x"+videoHeight+" / "+
150 boardComponent.width+"x"+boardComponent.height+" "+videoComponent.width+"x"+videoComponent.height);
155 boardComponent.width = boardWidth;
156 boardComponent.height = boardHeight;
157 //boardComponent.setDimensions(boardWidth, boardHeight);
158 videoComponent.width = videoWidth;
159 videoComponent.height = videoHeight;
163 property bool videoCall : false;
164 function setVideoCall(b){
165 if (b != sessionToolbar.videoCall){
166 sessionScene.videoCall = b;
167 sessionToolbar.state = sessionScene.videoCall || sessionScene.audioCall ? "call": "chat";
172 property bool audioCall : false;
173 function setAudioCall(b){
174 if (b != sessionScene.audioCall){
175 sessionScene.audioCall = b;
176 sessionToolbar.state = sessionScene.audioCall || sessionScene.audioCall ? "call": "chat";
181 property bool board : false
182 function setBoard(b){
183 if (b != sessionScene.board){
184 sessionScene.board = b;
189 function closeSession(){
190 if (sessionScene.videoCall || sessionScene.audioCall)
191 sessionToolbar.requestHangup(sessionScene.sessionId);
193 main.getSessionController().closeSession(sessionScene.sessionId);
195 function fullScreenVideo(){
196 if (videoComponent.state == "fullscreen")
198 videoComponent.state = "fullscreen";
201 function minimizeVideo(){
202 if (videoComponent.state == "normal")
204 videoComponent.state = "normal";