Package floobits.common.protocol.buf

Examples of floobits.common.protocol.buf.Buf


        final LinkedList<Buf> missing = new LinkedList<Buf>();
        final LinkedList<String> conflictedPaths = new LinkedList<String>();
        for (Map.Entry entry : ri.bufs.entrySet()) {
            Integer buf_id = (Integer) entry.getKey();
            RoomInfoBuf b = (RoomInfoBuf) entry.getValue();
            Buf buf = Buf.createBuf(b.path, b.id, Encoding.from(b.encoding), b.md5, context, outbound);
            if (state.bufs == null) {
                Flog.warn("Buffer list became null. Probably disconnected. Bailing.");
                return;
            }
            state.bufs.put(buf_id, buf);
            state.pathsToIds.put(b.path, b.id);
            buf.read();
            if (buf.buf == null) {
                if (buf.path.equals("FLOOBITS_README.md") && buf.id == 1) {
                    outbound.getBuf(buf.id);
                    continue;
                }
View Full Code Here


                paths.add(context.toProjectRelPath(virtualFile.getPath()));
        }
        for (Map.Entry entry : ri.bufs.entrySet()) {
            Integer buf_id = (Integer) entry.getKey();
            RoomInfoBuf b = (RoomInfoBuf) entry.getValue();
            Buf buf = Buf.createBuf(b.path, b.id, Encoding.from(b.encoding), b.md5, context, outbound);
            try {
                state.bufs.put(buf_id, buf);
            } catch (NullPointerException e) {
                Flog.warn("state.buffs is null, tried to upload after disconnecting. This is a race condition.");
                return;
            }
            state.pathsToIds.put(b.path, b.id);
            if (!paths.contains(buf.path)) {
                outbound.deleteBuf(buf, false);
                continue;
            }
            paths.remove(buf.path);
            buf.read();
            if (buf.buf == null) {
                Flog.warn("%s is null but we want to upload it?", b.path);
                outbound.getBuf(buf.id);
                continue;
            }
View Full Code Here

        this.state = state;
        this.conn = conn;
    }

    public void getBuf(Integer buf_id) {
        Buf buf = state.bufs.get(buf_id);
        if (buf == null) {
            return;
        }
        synchronized (buf) {
            buf.set(null, null);
        }
        conn.write(new GetBuf(buf_id));
    }
View Full Code Here

        FlooPatch req = new FlooPatch(textPatch, before_md5, b);
        conn.write(req);
    }

    void createBuf(IFile virtualFile) {
        Buf buf = Buf.createBuf(virtualFile, context, this);
        if (buf == null) {
            return;
        }
        if (!state.can("patch")) {
            return;
View Full Code Here

    public void summon(String current, Integer offset) {
        if (!state.can("patch")) {
            return;
        }
        Buf buf = state.getBufByPath(current);
        if (Buf.isBad(buf)) {
            context.errorMessage(String.format("The file %s is not shared!", current));
            return;
        }
        ArrayList<ArrayList<Integer>> ranges = new ArrayList<ArrayList<Integer>>();
View Full Code Here

    void _on_rename_buf(JsonObject jsonObject) {
        final String name = jsonObject.get("old_path").getAsString();
        final String oldPath = context.absPath(name);
        final String newPath = context.absPath(jsonObject.get("path").getAsString());

        Buf buf = state.getBufByPath(oldPath);
        if (buf == null) {
            if (state.getBufByPath(newPath) == null) {
                Flog.warn("Rename oldPath and newPath don't exist. %s %s", oldPath, newPath);
            } else {
                Flog.info("We probably rename this, nothing to rename.");
View Full Code Here

        context.iFactory.removeHighlightsForUser(userId);
    }

    void _on_delete_buf(JsonObject obj) {
        final DeleteBuf deleteBuf = new Gson().fromJson(obj, (Type)DeleteBuf.class);
        Buf buf = state.bufs.get(deleteBuf.id);
        if (buf == null) {
            Flog.warn(String.format("Tried to delete a buf that doesn't exist: %d", deleteBuf.id));
            return;
        }
        editor.queue(buf, new RunLater<Buf>() {
            @Override
            public void run(Buf buf) {
                buf.cancelTimeout();
                if (state.bufs != null) {
                    state.bufs.remove(deleteBuf.id);
                    state.pathsToIds.remove(buf.path);
                }
                if (!deleteBuf.unlink) {
View Full Code Here

    }

    public void _on_highlight(JsonObject obj) {
        final FlooHighlight res = new Gson().fromJson(obj, (Type) FlooHighlight.class);
        state.lastHighlight = obj;
        final Buf buf = this.state.bufs.get(res.id);
        editor.queue(buf, new RunLater<Buf>() {
            @Override
            public void run(Buf arg) {
                IDoc iDoc = context.iFactory.getDocument(buf.path);
                if (iDoc == null) {
View Full Code Here

        });
    }

    void _on_saved(JsonObject obj) {
        final Integer id = obj.get("id").getAsInt();
        final Buf buf = this.state.bufs.get(id);
        editor.queue(buf, new RunLater<Buf>() {
            public void run(Buf b) {
                IDoc document = context.iFactory.getDocument(buf.path);
                if (document == null) {
                    return;
View Full Code Here

    }

    void _on_create_buf(JsonObject obj) {
        Gson gson = new Gson();
        GetBufResponse res = gson.fromJson(obj, (Type) CreateBufResponse.class);
        Buf buf;
        if (res.encoding.equals(Encoding.BASE64.toString())) {
            buf = new BinaryBuf(res.path, res.id, new Base64().decode(res.buf.getBytes()), res.md5, context, outbound);
        } else {
            buf = new TextBuf(res.path, res.id, res.buf, res.md5, context, outbound);
        }
        editor.queue(buf, new RunLater<Buf>() {
            @Override
            public void run(Buf buf) {
                if (state.bufs == null) {
                    return;
                }
                state.bufs.put(buf.id, buf);
                state.pathsToIds.put(buf.path, buf.id);
                buf.write();
                fileAddedMessageThrottler.statusMessage(String.format("Added the file, %s, to the workspace.", buf.path));
            }
        });
    }
View Full Code Here

TOP

Related Classes of floobits.common.protocol.buf.Buf

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.