blob: daaeac7dcff78e599053d41ef231160197174010 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.libreoffice.impressremote.communication;
import java.util.Random;
import android.text.TextUtils;
final class Protocol {
private Protocol() {
}
public static final String CHARSET = "UTF-8";
public static final class Pin {
private Pin() {
}
private static final int NUMBERS_COUNT = 4;
public static String generate() {
Random aRandomGenerator = new Random();
int aMaximumPin = (int) Math.pow(10, NUMBERS_COUNT) - 1;
int aPinNumber = aRandomGenerator.nextInt(aMaximumPin);
return String.format("%04d", aPinNumber);
}
}
public static final class Ports {
private Ports() {
}
public static final int SERVER_SEARCH = 1598;
public static final int CLIENT_CONNECTION = 1599;
}
public static final class Addresses {
private Addresses() {
}
public static final String SERVER_SEARCH = "239.0.0.1";
}
public static final class Messages {
private Messages() {
}
public static final String PAIRED = "LO_SERVER_SERVER_PAIRED";
public static final String VALIDATING = "LO_SERVER_VALIDATING_PIN";
public static final String ADVERTISE = "LOREMOTE_ADVERTISE";
public static final String SLIDE_SHOW_STARTED = "slideshow_started";
public static final String SLIDE_SHOW_FINISHED = "slideshow_finished";
public static final String SLIDE_UPDATED = "slide_updated";
public static final String SLIDE_PREVIEW = "slide_preview";
public static final String SLIDE_NOTES = "slide_notes";
}
public static final class Commands {
private Commands() {
}
public static final String PAIR_WITH_SERVER = "LO_SERVER_CLIENT_PAIR";
public static final String SEARCH_SERVERS = "LOREMOTE_SEARCH";
public static final String TRANSITION_NEXT = "transition_next";
public static final String TRANSITION_PREVIOUS = "transition_previous";
public static final String GO_TO_SLIDE = "goto_slide";
public static final String PRESENTATION_BLANK_SCREEN = "presentation_blank_screen";
public static final String PRESENTATION_RESUME = "presentation_resume";
public static final String PRESENTATION_START = "presentation_start";
public static final String PRESENTATION_STOP = "presentation_stop";
private static final String DELIMITER_PARAMETER = "\n";
private static final String DELIMITER_COMMAND = "\n\n";
public static String prepareCommand(String aCommand) {
return String.format("%s%s", aCommand, DELIMITER_COMMAND);
}
public static String prepareCommand(String... aParameters) {
String aCommand = TextUtils.join(DELIMITER_PARAMETER, aParameters);
return prepareCommand(aCommand);
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|