Search in sources :

Example 1 with Client

use of org.apache.openmeetings.db.entity.basic.Client in project openmeetings by apache.

the class StartSharingButton method onClick.

@Override
public void onClick(AjaxRequestTarget target) {
    try (InputStream jnlp = getClass().getClassLoader().getResourceAsStream("APPLICATION.jnlp")) {
        app = IOUtils.toString(jnlp, UTF_8);
        Client c = cm.get(uid);
        String sid = c.getSid();
        Long roomId = c.getRoom().getId();
        JSONObject s = VideoSettings.getInitJson(sid);
        String _url = s.getString(VideoSettings.URL);
        Room room = roomDao.get(roomId);
        app = app.replace("$native", String.valueOf(s.getBoolean(FLASH_NATIVE_SSL))).replace("$codebase", WebSession.get().getExtendedProperties().getCodebase()).replace("$applicationName", getApplicationName()).replace("$url", _url).replace("$fallback", s.getString(VideoSettings.FALLBACK)).replace("$sid", sid).replace("$labels", getLabels("730", "731", "732", "733", "734", "735", "737", "738", "739", "740", "741", "742", "844", "869", "870", "871", "872", "878", "1089", "1090", "1091", "1092", "1093", "1465", "1466", "1467", "1468", "1469", "1470", "1471", "1472", "1473", "1474", "1475", "1476", "1477", "1589", "1598", "1078")).replace("$defaultQuality", String.valueOf(cfgDao.getLong(CONFIG_SCREENSHARING_QUALITY, 1L))).replace("$defaultFps", String.valueOf(cfgDao.getLong(CONFIG_SCREENSHARING_FPS, 10L))).replace("$showFps", String.valueOf(cfgDao.getBool(CONFIG_SCREENSHARING_FPS_SHOW, true))).replace("$allowRemote", String.valueOf(cfgDao.getBool(CONFIG_SCREENSHARING_ALLOW_REMOTE, true))).replace("$allowRecording", String.valueOf(room.isAllowRecording() && (0 == scm.getRecordingCount(roomId)))).replace("$allowPublishing", String.valueOf(0 == scm.getPublishingCount(roomId)));
        download.initiate(target);
    } catch (Exception e) {
        log.error("Unexpected error while creating jnlp file", e);
    }
}
Also used : JSONObject(com.github.openjson.JSONObject) InputStream(java.io.InputStream) Client(org.apache.openmeetings.db.entity.basic.Client) Room(org.apache.openmeetings.db.entity.room.Room)

Example 2 with Client

use of org.apache.openmeetings.db.entity.basic.Client in project openmeetings by apache.

the class WbPanel method processWbAction.

@Override
protected void processWbAction(WbAction a, JSONObject obj, AjaxRequestTarget target) throws IOException {
    Client c = rp.getClient();
    if (c == null) {
        return;
    }
    switch(a) {
        case createObj:
        case modifyObj:
            {
                JSONObject o = obj.optJSONObject("obj");
                if (o != null && "pointer".equals(o.getString(ATTR_TYPE))) {
                    sendWbOthers(a, obj);
                    return;
                }
            }
            break;
        case downloadPdf:
            {
                boolean moder = c.hasRight(Room.Right.moderator);
                Room r = rp.getRoom();
                if ((moder && !r.isHidden(RoomElement.ActionMenu)) || (!moder && r.isAllowUserQuestions())) {
                    try (PDDocument doc = new PDDocument()) {
                        JSONArray arr = obj.getJSONArray("slides");
                        for (int i = 0; i < arr.length(); ++i) {
                            String base64Image = arr.getString(i).split(",")[1];
                            byte[] bb = Base64.decodeBase64(base64Image);
                            BufferedImage img = ImageIO.read(new ByteArrayInputStream(bb));
                            float width = img.getWidth();
                            float height = img.getHeight();
                            PDPage page = new PDPage(new PDRectangle(width, height));
                            PDImageXObject pdImageXObject = LosslessFactory.createFromImage(doc, img);
                            try (PDPageContentStream contentStream = new PDPageContentStream(doc, page, AppendMode.APPEND, false)) {
                                contentStream.drawImage(pdImageXObject, 0, 0, width, height);
                            }
                            doc.addPage(page);
                        }
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        doc.save(baos);
                        rp.startDownload(target, baos.toByteArray());
                    }
                }
                return;
            }
        case loadVideos:
            {
                StringBuilder sb = new StringBuilder("WbArea.initVideos(");
                JSONArray arr = new JSONArray();
                for (Entry<Long, Whiteboard> entry : wbm.list(roomId)) {
                    Whiteboard wb = entry.getValue();
                    for (JSONObject o : wb.list()) {
                        String ft = o.optString(ATTR_FILE_TYPE);
                        if (BaseFileItem.Type.Recording.name().equals(ft) || BaseFileItem.Type.Video.name().equals(ft)) {
                            JSONObject _sts = o.optJSONObject(PARAM_STATUS);
                            if (_sts == null) {
                                continue;
                            }
                            // copy
                            JSONObject sts = new JSONObject(_sts.toString());
                            sts.put("pos", sts.getDouble("pos") + (System.currentTimeMillis() - sts.getLong("updated")) * 1. / 1000);
                            arr.put(new JSONObject().put("wbId", wb.getId()).put("uid", o.getString("uid")).put(ATTR_SLIDE, o.getString(ATTR_SLIDE)).put(PARAM_STATUS, sts));
                        }
                    }
                }
                sb.append(arr.toString()).append(");");
                target.appendJavaScript(sb);
                return;
            }
        default:
            break;
    }
    // presenter-right
    if (c.hasRight(Right.presenter)) {
        switch(a) {
            case createWb:
                {
                    Whiteboard wb = wbm.add(roomId, c.getUser().getLanguageId());
                    sendWbAll(WbAction.createWb, getAddWbJson(wb));
                }
                break;
            case removeWb:
                {
                    long id = obj.optLong("wbId", -1);
                    if (id > -1) {
                        wbm.remove(roomId, id);
                        sendWbAll(WbAction.removeWb, obj);
                    }
                }
                break;
            case activateWb:
                {
                    long _id = obj.optLong("wbId", -1);
                    if (_id > -1) {
                        wbm.activate(roomId, _id);
                        sendWbAll(WbAction.activateWb, obj);
                    }
                }
                break;
            case renameWb:
                {
                    Whiteboard wb = wbm.get(roomId).get(obj.optLong("wbId", -1));
                    if (wb != null) {
                        wbm.update(roomId, wb.setName(obj.getString("name")));
                        sendWbAll(WbAction.renameWb, obj);
                    }
                }
                break;
            case setSlide:
                {
                    Whiteboard wb = wbm.get(roomId).get(obj.optLong("wbId", -1));
                    if (wb != null) {
                        wb.setSlide(obj.optInt(ATTR_SLIDE, 0));
                        wbm.update(roomId, wb);
                        sendWbOthers(WbAction.setSlide, obj);
                    }
                }
                break;
            case clearAll:
                {
                    clearAll(roomId, obj.getLong("wbId"));
                }
                break;
            case setSize:
                {
                    Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
                    wb.setZoom(obj.getDouble("zoom"));
                    wb.setZoomMode(ZoomMode.valueOf(obj.getString("zoomMode")));
                    wbm.update(roomId, wb);
                    sendWbOthers(WbAction.setSize, getAddWbJson(wb));
                }
                break;
            default:
                break;
        }
    }
    // wb-right
    if (c.hasRight(Right.presenter) || c.hasRight(Right.whiteBoard)) {
        switch(a) {
            case createObj:
                {
                    Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
                    JSONObject o = obj.getJSONObject("obj");
                    wb.put(o.getString("uid"), o);
                    wbm.update(roomId, wb);
                    addUndo(wb.getId(), new UndoObject(UndoObject.Type.add, o));
                    sendWbOthers(WbAction.createObj, obj);
                }
                break;
            case modifyObj:
                {
                    Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
                    JSONArray arr = obj.getJSONArray("obj");
                    JSONArray undo = new JSONArray();
                    for (int i = 0; i < arr.length(); ++i) {
                        JSONObject _o = arr.getJSONObject(i);
                        String uid = _o.getString("uid");
                        JSONObject po = wb.get(uid);
                        if (po != null) {
                            undo.put(po);
                            wb.put(uid, _o);
                        }
                    }
                    if (arr.length() != 0) {
                        wbm.update(roomId, wb);
                        addUndo(wb.getId(), new UndoObject(UndoObject.Type.modify, undo));
                    }
                    sendWbOthers(WbAction.modifyObj, obj);
                }
                break;
            case deleteObj:
                {
                    Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
                    JSONArray arr = obj.getJSONArray("obj");
                    JSONArray undo = new JSONArray();
                    for (int i = 0; i < arr.length(); ++i) {
                        JSONObject _o = arr.getJSONObject(i);
                        JSONObject u = wb.remove(_o.getString("uid"));
                        if (u != null) {
                            undo.put(u);
                        }
                    }
                    if (undo.length() != 0) {
                        wbm.update(roomId, wb);
                        addUndo(wb.getId(), new UndoObject(UndoObject.Type.remove, undo));
                    }
                    sendWbAll(WbAction.deleteObj, obj);
                }
                break;
            case clearSlide:
                {
                    Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
                    JSONArray arr = wb.clearSlide(obj.getInt(ATTR_SLIDE));
                    if (arr.length() != 0) {
                        wbm.update(roomId, wb);
                        addUndo(wb.getId(), new UndoObject(UndoObject.Type.remove, arr));
                    }
                    sendWbAll(WbAction.clearSlide, obj);
                }
                break;
            case save:
                wb2save = obj.getLong("wbId");
                fileName.open(target);
                break;
            case undo:
                {
                    Long wbId = obj.getLong("wbId");
                    UndoObject uo = getUndo(wbId);
                    if (uo != null) {
                        Whiteboard wb = wbm.get(roomId).get(wbId);
                        switch(uo.getType()) {
                            case add:
                                {
                                    JSONObject o = new JSONObject(uo.getObject());
                                    wb.remove(o.getString("uid"));
                                    wbm.update(roomId, wb);
                                    sendWbAll(WbAction.deleteObj, obj.put("obj", new JSONArray().put(o)));
                                }
                                break;
                            case remove:
                                {
                                    JSONArray arr = new JSONArray(uo.getObject());
                                    for (int i = 0; i < arr.length(); ++i) {
                                        JSONObject o = arr.getJSONObject(i);
                                        wb.put(o.getString("uid"), o);
                                    }
                                    wbm.update(roomId, wb);
                                    sendWbAll(WbAction.createObj, obj.put("obj", new JSONArray(uo.getObject())));
                                }
                                break;
                            case modify:
                                {
                                    JSONArray arr = new JSONArray(uo.getObject());
                                    for (int i = 0; i < arr.length(); ++i) {
                                        JSONObject o = arr.getJSONObject(i);
                                        wb.put(o.getString("uid"), o);
                                    }
                                    wbm.update(roomId, wb);
                                    sendWbAll(WbAction.modifyObj, obj.put("obj", arr));
                                }
                                break;
                        }
                    }
                }
                break;
            case videoStatus:
                {
                    Whiteboard wb = wbm.get(roomId).get(obj.getLong("wbId"));
                    String uid = obj.getString("uid");
                    JSONObject po = wb.get(uid);
                    if (po != null && "video".equals(po.getString(ATTR_TYPE))) {
                        JSONObject ns = obj.getJSONObject(PARAM_STATUS);
                        po.put(PARAM_STATUS, ns.put("updated", System.currentTimeMillis()));
                        wbm.update(roomId, wb.put(uid, po));
                        obj.put(ATTR_SLIDE, po.getInt(ATTR_SLIDE));
                        sendWbAll(WbAction.videoStatus, obj);
                    }
                }
                break;
            default:
                break;
        }
    }
}
Also used : PDPage(org.apache.pdfbox.pdmodel.PDPage) JSONArray(com.github.openjson.JSONArray) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BufferedImage(java.awt.image.BufferedImage) PDImageXObject(org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject) Entry(java.util.Map.Entry) JSONObject(com.github.openjson.JSONObject) ByteArrayInputStream(java.io.ByteArrayInputStream) PDDocument(org.apache.pdfbox.pdmodel.PDDocument) PDRectangle(org.apache.pdfbox.pdmodel.common.PDRectangle) PDPageContentStream(org.apache.pdfbox.pdmodel.PDPageContentStream) Client(org.apache.openmeetings.db.entity.basic.Client) Room(org.apache.openmeetings.db.entity.room.Room) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 3 with Client

use of org.apache.openmeetings.db.entity.basic.Client in project openmeetings by apache.

the class RoomClientPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    Client c = (Client) getDefaultModelObject();
    String status, statusTitle;
    if (c.hasRight(Right.moderator)) {
        status = "status-mod";
        statusTitle = "679";
    } else if (c.hasRight(Right.whiteBoard) || c.hasRight(Right.presenter)) {
        status = "status-wb";
        statusTitle = "678";
    } else {
        status = "status-user";
        statusTitle = "677";
    }
    status = String.format("%s %s", status, ((BasePage) getPage()).isRtl() ? ALIGN_LEFT : ALIGN_RIGHT);
    add(new WebMarkupContainer("status").add(AttributeModifier.append(ATTR_CLASS, status), AttributeModifier.replace(ATTR_TITLE, getString(statusTitle))));
}
Also used : Client(org.apache.openmeetings.db.entity.basic.Client) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 4 with Client

use of org.apache.openmeetings.db.entity.basic.Client in project openmeetings by apache.

the class ClientIcon method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    Client rc = getRoomClient();
    self = rc == null ? false : rc.getUid().equals(uid);
    update(null);
}
Also used : Client(org.apache.openmeetings.db.entity.basic.Client)

Example 5 with Client

use of org.apache.openmeetings.db.entity.basic.Client in project openmeetings by apache.

the class ClientManager method invalidate.

public void invalidate(Long userId, String sessionId) {
    Client client = getByKeys(userId, sessionId);
    if (client != null) {
        Map<String, String> invalid = Application.get().getInvalidSessions();
        if (!invalid.containsKey(client.getSessionId())) {
            invalid.put(client.getSessionId(), client.getUid());
            exit(client);
        }
    }
}
Also used : IClient(org.apache.openmeetings.db.entity.basic.IClient) Client(org.apache.openmeetings.db.entity.basic.Client)

Aggregations

Client (org.apache.openmeetings.db.entity.basic.Client)17 JSONObject (com.github.openjson.JSONObject)5 User (org.apache.openmeetings.db.entity.user.User)5 Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)3 IClient (org.apache.openmeetings.db.entity.basic.IClient)3 Room (org.apache.openmeetings.db.entity.room.Room)3 RoomMessage (org.apache.openmeetings.db.util.ws.RoomMessage)3 Whiteboards (org.apache.openmeetings.db.dto.room.Whiteboards)2 TextRoomMessage (org.apache.openmeetings.db.util.ws.TextRoomMessage)2 JSONArray (com.github.openjson.JSONArray)1 BufferedImage (java.awt.image.BufferedImage)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 HashSet (java.util.HashSet)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 IWsClient (org.apache.openmeetings.db.entity.basic.IWsClient)1 FileItem (org.apache.openmeetings.db.entity.file.FileItem)1 Recording (org.apache.openmeetings.db.entity.record.Recording)1